-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfeed.parity.py
More file actions
57 lines (48 loc) · 2.1 KB
/
feed.parity.py
File metadata and controls
57 lines (48 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from grapheneapi import GrapheneClient
from grapheneexchange import GrapheneExchange
import json
import fractions
class Config():
wallet_host = "localhost"
wallet_port = 8090
wallet_user = ""
wallet_password = ""
if __name__ == '__main__':
graphene = GrapheneClient(Config)
asset_symbol = "PEG.PARITY"
producers = ["init0", "init1", "init2", "init3", "init4", "init5", "init6", "init7", "init8", "init9", "init10"]
price = 1
asset = graphene.rpc.get_asset(asset_symbol)
base = graphene.rpc.get_asset("1.3.0")
price = price * 10 ** asset["precision"] / 10 ** base["precision"]
denominator = 1e5
numerator = round(price*1e5)
for producer in producers:
account = graphene.rpc.get_account(producer)
price_feed = {"settlement_price": {
"quote": {"asset_id": "1.3.0",
"amount": denominator
},
"base": {"asset_id": asset["id"],
"amount": numerator
}
},
"maintenance_collateral_ratio" : 1200,
"maximum_short_squeeze_ratio" : 1100,
"core_exchange_rate": {
"quote": {"asset_id": "1.3.0",
"amount": int(denominator * 1.05)
},
"base": {"asset_id": asset["id"],
"amount": numerator
}}}
handle = graphene.rpc.begin_builder_transaction()
op = [19, # id 19 corresponds to price feed update operation
{"asset_id" : asset["id"],
"feed" : price_feed,
"publisher" : account["id"]
}]
graphene.rpc.add_operation_to_builder_transaction(handle, op)
graphene.rpc.set_fees_on_builder_transaction(handle, "1.3.0")
tx = graphene.rpc.sign_builder_transaction(handle, True)
print(json.dumps(tx, indent=4))