#btc = enode.create_contract(acc, btcfile, bt_cstcb, [acc.address], True); #print("btc address:", btc.address) #btd = enode.create_contract(acc, btdfile, bt_cstcb, [acc.address], True); #print("btd address:", btd.address) # get contract: BTA, BTB, BTC, BTD qts = ["0x8e4d8D520f52B044e1E8B054D763B723B7C3E716", "0x45e110F81bBf89041A63Bc2403058743bc552bAF", "0x7B29ed69368B0Ed0d3b21A857BaEeF788B13c626", "0x60423Ebc63245631Ea71bdF58CF23A3949329cDb"] bta = enode.get_contract(qts[0], btafile) btb = enode.get_contract(qts[1], btbfile) btc = enode.get_contract(qts[2], btcfile) btd = enode.get_contract(qts[3], btdfile) # transfer token: BTA, BTB, BTC, BTD TRANS_VALUE = 1000000 * MAGNITUDE #accounts = ["0xfcff222a998b0cfa175d769663fb8d750c93b24f", # "0xab890808775d51e9bf9fa76f40ee5fff124dece5", # "0xFc2003889D3430A7D0931B5adE5c7A101356Efd7", # ] accounts = ["0xFc2003889D3430A7D0931B5adE5c7A101356Efd7"] for act in accounts: act = Web3.toChecksumAddress(act) print("transfer toke for acc", act) enode.call_func(acc, bta.functions.transfer(act, TRANS_VALUE), False) enode.call_func(acc, btb.functions.transfer(act, TRANS_VALUE), False) enode.call_func(acc, btc.functions.transfer(act, TRANS_VALUE), False) enode.call_func(acc, btd.functions.transfer(act, TRANS_VALUE), False)
return to orderset = AttributeDict({ 'baseToken': btoken.address, 'quoteToken': qtoken.address, 'relayer': relayer.address }) so1 = get_order(200, 20, 0, True, acc) so2 = get_order(200, 19, 0, True, acc) so3 = get_order(200, 18, 0, True, acc) bo = get_order(550, 55, 0, False, acc) print(so1) print(so2) print(so3) print(bo) print(orderset) enode.call_func( relayer, hd.functions.matchOrders( bo, [so3, so2, so1], [50 * MAGNITUDE, 100 * MAGNITUDE, 200 * MAGNITUDE], orderset), True) #enode.call_func(relayer, hd.functions.matchOrders(bo, [so3, so2], [50 * MAGNITUDE, 100 * MAGNITUDE], orderset), True) #enode.call_func(relayer, hd.functions.matchOrders(bo, (so3,), (50 * MAGNITUDE,), orderset), True) ################### match order ##############end
# get ether node enode = EtherNode(ETH_NODE_HTTP) # decrype keystore file acc = enode.decrypt_keystore(ownerfile, "123456") print("acc address:", acc.address) relayer = acc print("relayer address:", relayer.address) # get contract proxy = enode.get_contract(proxyaddr, proxyjson) hd = enode.get_contract(hdaddr, hdjson) tm = enode.get_contract(ymaddr, tmjson) APPROVE_VALUE = 10**27 # approve for qt in qts: print("approve proxy for token:", qt) qtoken = enode.get_contract(qt, tptjson) enode.call_func(acc, qtoken.functions.approve(proxy.address, APPROVE_VALUE), True) # check approve for qt in qts: print("check approve proxy for token:", qt) qtoken = enode.get_contract(qt, tptjson) aq = qtoken.functions.allowance(relayer.address, proxy.address).call() print("relayer quote token appove:", aq)
from ether_node import EtherNode randaddr = "0x53bf75a6948ce0B0A7680d87881008972c7CcBcB" randfile = "../build/contracts/Random.json" ownerfile = "./keystore/UTC--2019-07-20T04-00-01.800933268Z--a9535b10ee96b4a03269d0e0def417af97477fd6" if __name__ == "__main__": # get ether node enode = EtherNode() # decrype keystore file acc = enode.decrypt_keystore(ownerfile) random = enode.get_contract(randaddr, randfile) rnum = enode.call_func(acc, random.functions.random(1), True) print("random number:", rnum)