Contract con_yeti_transfer_from_1_3


Contract Code


  
1 I = importlib
2
3 YETI = "con_yeti_contract_11"
4
5 operator = Variable()
6
7
8 @construct
9 def init():
10 operator.set(YETI)
11
12
13 @export
14 def transfer_from(caller: str, contract: str, contract_method: str, amount:
15 float, to: str, main_account: str, tax_amount: float):
16 assert_operator()
17
18 yeti_balances = ForeignHash(foreign_contract=YETI, foreign_name="balances")
19
20 approved = yeti_balances[main_account, caller]
21 main_account_balance = yeti_balances[main_account]
22
23 if contract == "con_rocketswap_official_v1_1":
24 if contract_method == "sell":
25 amount_to_spend = amount + tax_amount
26
27 assert approved >= amount_to_spend, f"Not enough coins approved to send! You have {approved} and are trying to spend {amount_to_spend}"
28 assert main_account_balance >= amount_to_spend, f"Not enough coins to pay tax of {tax_amount}!"
29
30 return amount
31
32 else:
33 # here works in the case of contract_method == 'create_market'
34 # or contract_method == 'add_liquidity'
35 assert approved >= amount, f"Not enough coins approved to send! You have {approved} and are trying to spend {amount}"
36 assert main_account_balance >= amount, "Not enough coins to send!"
37
38 return amount
39
40
41 def assert_operator():
42 assert ctx.caller == operator.get(), "Only operator can call!"
43

Byte Code

e30000000000000000000000000900000040000000734a00000065005a0164005a0265036401640264038d025a046404640584005a05650664018301650765076507650865076507650864069c0764076408840483015a096409640a84005a0a640b5300290cda14636f6e5f796574695f636f6e74726163745f3131da1a636f6e5f796574695f7472616e736665725f66726f6d5f315f33da086f70657261746f722902da08636f6e7472616374da046e616d65630000000000000000000000000200000043000000730e00000074006a017402830101006400530029014e2903da0a5f5f6f70657261746f72da03736574da0459455449a90072090000007209000000da00da045f5f5f5f0600000073020000000001720b0000002907da0663616c6c65727204000000da0f636f6e74726163745f6d6574686f64da06616d6f756e74da02746fda0c6d61696e5f6163636f756e74da0a7461785f616d6f756e746307000000000000000b000000060000004300000073ae0000007400830001007401740264016402640364048d047d077c077c057c00660219007d087c077c0519007d097c0164056b0272aa7c0264066b02727a7c037c0617007d0a7c087c0a6b05735e740364077c089b0064087c0a9b009d04830182017c097c0a6b057376740364097c069b00640a9d03830182017c0353007c087c036b057396740364077c089b0064087c039b009d04830182017c097c036b0573a67403640b830182017c03530064005300290c4eda0862616c616e6365737202000000da0d796574695f62616c616e6365732904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d6572040000007205000000da1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f31da0473656c6c7a2c4e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207a1920616e642061726520747279696e6720746f207370656e64207a1f4e6f7420656e6f75676820636f696e7320746f2070617920746178206f6620fa01217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904da115f5f6173736572745f6f70657261746f72da0b466f726569676e486173687208000000da0e417373657274696f6e4572726f72290b720c0000007204000000720d000000720e000000720f00000072100000007211000000da0f5f5f796574695f62616c616e636573da08617070726f766564da146d61696e5f6163636f756e745f62616c616e6365da0f616d6f756e745f746f5f7370656e6472090000007209000000720a000000da0d7472616e736665725f66726f6d0a000000731c0000000003060104010c020c0108010801080108011c01180104021c0110017220000000630000000000000000000000000200000043000000731a00000074006a0174026a0383006b02731674046401830182016400530029024e7a174f6e6c79206f70657261746f722063616e2063616c6c212905da03637478720c0000007206000000da03676574721b000000720900000072090000007209000000720a00000072190000001f0000007302000000000172190000004e290bda09696d706f72746c6962da01497208000000da085661726961626c657206000000720b000000da085f5f6578706f7274da03737472da05666c6f617472200000007219000000720900000072090000007209000000720a000000da083c6d6f64756c653e01000000730e000000040104010c030804060106011613