Contract con_trd


Contract Code


  
1 import con_rocketswap_official_v1_1 as rswp
2 import currency as tau
3
4 I = importlib
5
6 @export
7 def buy(token_contract: str, tau_amount: float):
8 tau.transfer_from(amount=tau_amount, to=ctx.this, main_account=ctx.signer)
9 tau.approve(amount=tau_amount, to='con_rocketswap_official_v1_1')
10 rswp.buy(contract=token_contract, currency_amount=tau_amount)
11 balances = ForeignHash(foreign_contract=token_contract, foreign_name='balances')
12 I.import_module(token_contract).transfer(amount=balances[ctx.this], to=ctx.caller)
13
14 @export
15 def sell(token_contract: str, token_amount: float):
16 I.import_module(token_contract).transfer_from(amount=token_amount, to=ctx.this, main_account=ctx.signer)
17 I.import_module(token_contract).approve(amount=token_amount, to='con_rocketswap_official_v1_1')
18 rswp.sell(contract=token_contract, token_amount=token_amount)
19 balances = ForeignHash(foreign_contract='currency', foreign_name='balances')
20 tau.transfer(amount=balances[ctx.this], to=ctx.caller)
21
22 @export
23 def withdraw(token_contract: str):
24 assert ctx.signer == 'ae7d14d6d9b8443f881ba6244727b69b681010e782d4fe482dbfb0b6aca02d5d', 'Nope'
25 balances = ForeignHash(foreign_contract=token_contract, foreign_name='balances')
26 I.import_module(token_contract).transfer(amount=balances[ctx.this], to=ctx.caller)

Byte Code

e30000000000000000000000000400000040000000735e000000640064016c005a01640064016c025a0365045a056506640283016507650864039c0264046405840483015a096506640283016507650864069c0264076408840483015a0a650664028301650764099c01640a640b840483015a0b64015300290ce9000000004eda07636f6e5f7472642902da0e746f6b656e5f636f6e7472616374da0a7461755f616d6f756e74630200000000000000030000000600000043000000736000000074006a017c0174026a0374026a0464018d03010074006a057c01640264038d02010074066a077c007c0164048d02010074087c0064056406640564078d047d0274096a0a7c0083016a0b7c0274026a03190074026a0c64038d0201006400530029084e2903da06616d6f756e74da02746fda0c6d61696e5f6163636f756e74da1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f312902720500000072060000002902da08636f6e7472616374da0f63757272656e63795f616d6f756e74da0862616c616e63657372020000002904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d657209000000da046e616d65290dda03746175da0d7472616e736665725f66726f6dda03637478da0474686973da067369676e6572da07617070726f7665da0472737770da03627579da0b466f726569676e48617368da0149da0d696d706f72745f6d6f64756c65da087472616e73666572da0663616c6c6572290372030000007204000000da0a5f5f62616c616e636573a900721d000000da00721600000006000000730e000000000214010e010e0104010c011201721600000029027203000000da0c746f6b656e5f616d6f756e74630200000000000000030000000600000043000000736600000074006a017c0083016a027c0174036a0474036a0564018d03010074006a017c0083016a067c01640264038d02010074076a087c007c0164048d0201007409640564066407640664088d047d02740a6a0b7c0274036a04190074036a0c64038d0201006400530029094e2903720500000072060000007207000000720800000029027205000000720600000029027209000000721f000000da0863757272656e6379720b00000072020000002904720c000000720d0000007209000000720e000000290d72180000007219000000721000000072110000007212000000721300000072140000007215000000da0473656c6c7217000000720f000000721a000000721b00000029037203000000721f000000721c000000721d000000721d000000721e000000722100000011000000731000000000020c010e010c0108010e0104010c01722100000029017203000000630100000000000000020000000600000043000000734200000074006a0164016b027312740264028301820174037c0064036404640364058d047d0174046a057c0083016a067c0174006a07190074006a0864068d0201006400530029074eda4061653764313464366439623834343366383831626136323434373237623639623638313031306537383264346665343832646266623062366163613032643564da044e6f7065720b00000072020000002904720c000000720d0000007209000000720e000000290272050000007206000000290972110000007213000000da0e417373657274696f6e4572726f72721700000072180000007219000000721a0000007212000000721b00000029027203000000721c000000721d000000721d000000721e000000da0877697468647261771d000000730a0000000002120104010c0112017225000000290c720800000072150000007220000000720f000000da09696d706f72746c69627218000000da085f5f6578706f7274da03737472da05666c6f6174721600000072210000007225000000721d000000721d000000721d000000721e000000da083c6d6f64756c653e0100000073100000000801080104030601120a0601120b0601