Contract con_doom


Contract Code


  
1 import submission
2
3
4 def ____():
5 contract = """import currency
6 #All transactions are pegged to TAU. If you send 1 TAU, and the conversion ratio is 1:1.1, the actual amount sent will be 0.91 sTAU.
7 balances = Hash(default_value=0)
8 tau_ratio = Variable()
9 total_supply = Variable()
10 tau_refund_amount = Variable()
11 operator = Variable()
12 @construct
13 def seed():
14 balances[ctx.signer] = 100
15 operator.set(ctx.signer)
16 total_supply.set(100)
17 tau_refund_amount.set(0)
18 tau_ratio.set(1)
19
20 @export
21 def transfer(amount: float, to: str):
22 assert amount > 0, 'Cannot send negative balances!'
23 amount = amount / tau_ratio.get()
24 sender = ctx.caller
25 if ctx.signer == ctx.caller and tau_refund_amount.get() > 0:
26 currency.transfer(tau_refund_amount.get(), ctx.caller)
27 assert balances[sender] >= amount, 'Not enough coins to send!'
28
29 balances[sender] -= amount
30 balances[to] += amount
31
32 @export
33 def balance_of(account: str):
34 return balances[account] * tau_ratio.get()
35
36 @export
37 def allowance(owner: str, spender: str):
38 return balances[owner, spender] * tau_ratio.get()
39
40 @export
41 def approve(amount: float, to: str):
42 assert amount > 0, 'Cannot send negative balances!'
43 amount = amount / tau_ratio.get()
44 sender = ctx.caller
45 balances[sender, to] += amount
46 return balances[sender, to] * tau_ratio.get()
47
48 @export
49 def transfer_from(amount: float, to: str, main_account: str):
50 assert amount > 0, 'Cannot send negative balances!'
51 amount = amount / tau_ratio.get()
52 sender = ctx.caller
53
54 assert balances[main_account, sender] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}' .format(balances[main_account, sender], amount)
55 assert balances[main_account] >= amount, 'Not enough coins to send!'
56
57 balances[main_account, sender] -= amount
58 balances[main_account] -= amount
59
60 balances[to] += amount
61
62 @export
63 def determine_ratio():
64 ratio = (currency.balance_of(ctx.this) / total_supply.get())
65 tau_ratio.set(ratio)
66 return ratio
67
68 @export
69 def legacy_transfer(amount: float, to: str):
70 assert amount > 0, 'Cannot send negative balances!'
71 total = total_supply.get()
72 ratio = currency.balance_of(ctx.this) / total
73 amount2 = amount / ratio
74 sender = ctx.caller
75
76 assert balances[sender] >= amount2, 'Not enough coins to send!'
77
78 balances[sender] -= amount2
79 tau_ratio.set(ratio)
80 total_supply.set(total - amount2)
81 currency.transfer(amount, to)
82
83 @export
84 def redeem(amount: float):
85 legacy_transfer(amount, ctx.caller)
86
87 @export
88 def mint(amount_in_tau: float):
89 assert amount_in_tau > 0, 'Cannot mint negative balances!'
90 sender = ctx.caller
91
92 ratio = currency.balance_of(ctx.this) / total_supply.get()
93 tau_ratio.set(ratio)
94 currency.transfer_from(amount_in_tau, ctx.this, ctx.caller)
95 amount = amount_in_tau / ratio
96 balances[sender] += amount
97 total_supply.set(total_supply.get() + amount)
98
99 @export
100 def set_cashback_amount(amount: float):
101 assert amount < 1, 'Too much!'
102 assert ctx.caller == operator.get()
103 tau_refund_amount.set(amount)
104 """
105 submission.submit_contract('currency_2', contract)
106
107
108 @__export('con_doom')
109 def a():
110 pass
111

Byte Code

e300000000000000000000000003000000400000007324000000640064016c005a006402640384005a0165026404830164056406840083015a03640153002907e9000000004e630000000000000000010000000300000043000000731400000064017d0074006a0164027c00830201006400530029034e61010c0000696d706f72742063757272656e63790a23416c6c207472616e73616374696f6e73206172652070656767656420746f205441552e20496620796f752073656e642031205441552c20616e642074686520636f6e76657273696f6e20726174696f20697320313a312e312c207468652061637475616c20616d6f756e742073656e742077696c6c20626520302e393120735441552e0a62616c616e636573203d20486173682864656661756c745f76616c75653d30290a7461755f726174696f203d205661726961626c6528290a746f74616c5f737570706c79203d205661726961626c6528290a7461755f726566756e645f616d6f756e74203d205661726961626c6528290a6f70657261746f72203d205661726961626c6528290a40636f6e7374727563740a646566207365656428293a0a2020202062616c616e6365735b6374782e7369676e65725d203d203130300a202020206f70657261746f722e736574286374782e7369676e6572290a20202020746f74616c5f737570706c792e73657428313030290a202020207461755f726566756e645f616d6f756e742e7365742830290a202020207461755f726174696f2e7365742831290a0a406578706f72740a646566207472616e7366657228616d6f756e743a20666c6f61742c20746f3a20737472293a0a2020202061737365727420616d6f756e74203e20302c202743616e6e6f742073656e64206e656761746976652062616c616e63657321270a20202020616d6f756e74203d20616d6f756e74202f207461755f726174696f2e67657428290a2020202073656e646572203d206374782e63616c6c65720a202020206966206374782e7369676e6572203d3d206374782e63616c6c657220616e64207461755f726566756e645f616d6f756e742e6765742829203e20303a0a202020202020202063757272656e63792e7472616e73666572287461755f726566756e645f616d6f756e742e67657428292c206374782e63616c6c6572290a202020206173736572742062616c616e6365735b73656e6465725d203e3d20616d6f756e742c20274e6f7420656e6f75676820636f696e7320746f2073656e6421270a0a2020202062616c616e6365735b73656e6465725d202d3d20616d6f756e740a2020202062616c616e6365735b746f5d202b3d20616d6f756e740a0a406578706f72740a6465662062616c616e63655f6f66286163636f756e743a20737472293a0a2020202072657475726e2062616c616e6365735b6163636f756e745d202a207461755f726174696f2e67657428290a0a406578706f72740a64656620616c6c6f77616e6365286f776e65723a207374722c207370656e6465723a20737472293a0a2020202072657475726e2062616c616e6365735b6f776e65722c207370656e6465725d202a207461755f726174696f2e67657428290a0a406578706f72740a64656620617070726f766528616d6f756e743a20666c6f61742c20746f3a20737472293a0a2020202061737365727420616d6f756e74203e20302c202743616e6e6f742073656e64206e656761746976652062616c616e63657321270a20202020616d6f756e74203d20616d6f756e74202f207461755f726174696f2e67657428290a2020202073656e646572203d206374782e63616c6c65720a2020202062616c616e6365735b73656e6465722c20746f5d202b3d20616d6f756e740a2020202072657475726e2062616c616e6365735b73656e6465722c20746f5d202a207461755f726174696f2e67657428290a0a406578706f72740a646566207472616e736665725f66726f6d28616d6f756e743a20666c6f61742c20746f3a207374722c206d61696e5f6163636f756e743a20737472293a0a2020202061737365727420616d6f756e74203e20302c202743616e6e6f742073656e64206e656761746976652062616c616e63657321270a20202020616d6f756e74203d20616d6f756e74202f207461755f726174696f2e67657428290a2020202073656e646572203d206374782e63616c6c65720a0a202020206173736572742062616c616e6365735b6d61696e5f6163636f756e742c2073656e6465725d203e3d20616d6f756e742c20274e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d2720202020202020202e666f726d61742862616c616e6365735b6d61696e5f6163636f756e742c2073656e6465725d2c20616d6f756e74290a202020206173736572742062616c616e6365735b6d61696e5f6163636f756e745d203e3d20616d6f756e742c20274e6f7420656e6f75676820636f696e7320746f2073656e6421270a0a2020202062616c616e6365735b6d61696e5f6163636f756e742c2073656e6465725d202d3d20616d6f756e740a2020202062616c616e6365735b6d61696e5f6163636f756e745d202d3d20616d6f756e740a0a2020202062616c616e6365735b746f5d202b3d20616d6f756e740a0a406578706f72740a6465662064657465726d696e655f726174696f28293a0a20202020726174696f203d202863757272656e63792e62616c616e63655f6f66286374782e7468697329202f20746f74616c5f737570706c792e6765742829290a202020207461755f726174696f2e73657428726174696f290a2020202072657475726e20726174696f0a0a406578706f72740a646566206c65676163795f7472616e7366657228616d6f756e743a20666c6f61742c20746f3a20737472293a0a2020202061737365727420616d6f756e74203e20302c202743616e6e6f742073656e64206e656761746976652062616c616e63657321270a20202020746f74616c203d20746f74616c5f737570706c792e6765742829200a20202020726174696f203d2063757272656e63792e62616c616e63655f6f66286374782e7468697329202f20746f74616c0a20202020616d6f756e7432203d20616d6f756e74202f20726174696f0a2020202073656e646572203d206374782e63616c6c65720a0a202020206173736572742062616c616e6365735b73656e6465725d203e3d20616d6f756e74322c20274e6f7420656e6f75676820636f696e7320746f2073656e6421270a0a2020202062616c616e6365735b73656e6465725d202d3d20616d6f756e74320a202020207461755f726174696f2e73657428726174696f290a20202020746f74616c5f737570706c792e73657428746f74616c202d20616d6f756e7432290a2020202063757272656e63792e7472616e7366657228616d6f756e742c20746f290a0a406578706f72740a6465662072656465656d28616d6f756e743a20666c6f6174293a0a202020206c65676163795f7472616e7366657228616d6f756e742c206374782e63616c6c6572290a0a406578706f72740a646566206d696e7428616d6f756e745f696e5f7461753a20666c6f6174293a0a2020202061737365727420616d6f756e745f696e5f746175203e20302c202743616e6e6f74206d696e74206e656761746976652062616c616e63657321270a2020202073656e646572203d206374782e63616c6c65720a0a20202020726174696f203d2063757272656e63792e62616c616e63655f6f66286374782e7468697329202f20746f74616c5f737570706c792e67657428290a202020207461755f726174696f2e73657428726174696f290a2020202063757272656e63792e7472616e736665725f66726f6d28616d6f756e745f696e5f7461752c206374782e746869732c206374782e63616c6c6572290a20202020616d6f756e74203d20616d6f756e745f696e5f746175202f20726174696f0a2020202062616c616e6365735b73656e6465725d202b3d20616d6f756e740a20202020746f74616c5f737570706c792e73657428746f74616c5f737570706c792e6765742829202b20616d6f756e74290a0a406578706f72740a646566207365745f636173686261636b5f616d6f756e7428616d6f756e743a20666c6f6174293a0a2020202061737365727420616d6f756e74203c20312c2027546f6f206d75636821270a20202020617373657274206374782e63616c6c6572203d3d206f70657261746f722e67657428290a202020207461755f726566756e645f616d6f756e742e73657428616d6f756e74290ada0a63757272656e63795f322902da0a7375626d697373696f6eda0f7375626d69745f636f6e74726163742901da08636f6e7472616374a9007206000000da00da045f5f5f5f040000007304000000006404017208000000da08636f6e5f646f6f6d63000000000000000000000000010000004300000073040000006400530029014e72060000007206000000720600000072060000007207000000da01616c00000073020000000002720a000000290472030000007208000000da085f5f6578706f7274720a0000007206000000720600000072060000007207000000da083c6d6f64756c653e01000000730400000008030868