Contract con_tttttt


Contract Code


  
1 I = importlib
2
3 metadata = Hash()
4
5 balances = Hash(default_value=0)
6 allowances = Hash(default_value=0)
7
8 MIN_SUPPLY = 10_000_000
9 BURN_ADDRESS = 'BURN'
10
11 @construct
12 def seed():
13 balances[ctx.caller] = 10_000_000_000
14
15 metadata['token_name'] = "TEST"
16 metadata['token_symbol'] = "TTTTT"
17 metadata['operator'] = ctx.caller
18 metadata['dex'] = 'con_rocketswap_official_v1_1'
19 metadata['threshold'] = 2
20 metadata['bonus'] = 0.03
21 metadata['burn'] = 0.001
22
23 @export
24 def change_metadata(key: str, value: Any):
25 assert ctx.caller == metadata['operator'], 'Only owner can set metadata!'
26 metadata[key] = value
27
28 @export
29 def transfer(amount: float, to: str):
30 assert amount > 0, 'Cannot send negative balances!'
31 assert balances[ctx.caller] >= amount, 'Not enough coins to send!'
32
33 balances[ctx.caller] -= amount
34 balances[to] += amount
35
36 @export
37 def approve(amount: float, to: str):
38 assert amount > 0, 'Cannot send negative balances!'
39 allowances[ctx.caller, to] += amount
40
41 @export
42 def transfer_from(amount: float, to: str, main_account: str):
43 assert amount > 0, 'Cannot send negative balances!'
44 assert allowances[main_account, ctx.caller] >= amount, f'You approved {allowances[main_account, ctx.caller]} but need {amount}'
45 assert balances[main_account] >= amount, 'Not enough coins to send!'
46
47 allowances[main_account, ctx.caller] -= amount
48 balances[main_account] -= amount
49 balances[to] += amount
50
51 @export
52 def redeem(token_contract: str, token_amount: float):
53 dex_prices = ForeignHash(foreign_contract=metadata['dex'], foreign_name='prices')
54
55 assert token_contract in dex_prices, 'Token not available on DEX'
56
57 current_value = token_amount * dex_prices[token_contract]
58
59 assert current_value >= metadata['threshold'], f'Contribution must be worth at least {metadata["threshold"]} TAU'
60
61 actual_value = I.import_module(metadata['dex']).sell(token_contract, token_amount)
62
63 I.import_module(metadata['dex']).add_liquidity(ctx.this, actual_value)
64
65 king_amount = actual_value / dex_prices[ctx.this]
66 king_total = king_amount + (king_amount * metadata['bonus'])
67
68 transfer(amount=king_total, to=ctx.caller)
69 transfer(amount=balances[ctx.this] * metadata['burn'], to=BURN_ADDRESS)
70
71 assert int(total_supply()) >= MIN_SUPPLY, f'Can not exceed minimum supply of {MIN_SUPPLY} KING'
72
73 @export
74 def burn(amount: float):
75 transfer(amount=amount, to=BURN_ADDRESS)
76 assert_owner()
77
78 @export
79 def remove_liquidity(amount: float):
80 I.import_module(metadata['dex']).remove_liquidity(ctx.this, amount)
81 assert_owner()
82
83 @export
84 def withdraw(contract: str, amount: float):
85 if contract == ctx.this:
86 transfer(amount=amount, to=ctx.caller)
87 else:
88 I.import_module(contract).transfer(amount=amount, to=ctx.caller)
89 assert_owner()
90
91 @export
92 def total_supply():
93 return f'{sum(balances.all())}'
94
95 def assert_owner():
96 assert ctx.caller == metadata['operator'], 'Only executable by owner!'
97

Byte Code

e30000000000000000000000000500000040000000731601000065005a0165026400640164028d025a03650264036400640464058d035a04650264036400640664058d035a0564075a0664085a076409640a84005a08650964008301650a650b640b9c02640c640d840483015a0c650964008301650d650a640e9c02640f6410840483015a0e650964008301650d650a640e9c0264116412840483015a0f650964008301650d650a650a64139c0364146415840483015a10650964008301650a650d64169c0264176418840483015a11650964008301650d64199c01641a641b840483015a12650964008301650d64199c01641c641d840483015a13650964008301650a650d641e9c02641f6420840483015a1465096400830164216422840083015a156423642484005a16642553002926da0a636f6e5f747474747474da086d657461646174612902da08636f6e7472616374da046e616d65e900000000da0862616c616e6365732903da0d64656661756c745f76616c756572030000007204000000da0a616c6c6f77616e6365736980969800da044255524e63000000000000000000000000030000004300000073500000006401740074016a023c006402740364033c006404740364053c0074016a02740364063c006407740364083c0064097403640a3c007404640b83017403640c3c007404640d83017403640e3c0064005300290f4e6c03000000006417280900da0454455354da0a746f6b656e5f6e616d65da055454545454da0c746f6b656e5f73796d626f6cda086f70657261746f72da1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f31da03646578e902000000da097468726573686f6c647a04302e3033da05626f6e75737a05302e303031da046275726e2905da0a5f5f62616c616e636573da03637478da0663616c6c6572da0a5f5f6d65746164617461da07646563696d616ca900721a000000721a000000da00da045f5f5f5f09000000731000000000010a01080108010a01080108010c01721c0000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720e0000007a1c4f6e6c79206f776e65722063616e20736574206d65746164617461212904721600000072170000007218000000da0e417373657274696f6e4572726f722902721d000000721e000000721a000000721a000000721b000000da0f6368616e67655f6d657461646174611400000073040000000002160172200000002902da06616d6f756e74da02746f630200000000000000020000000400000043000000734c0000007c0064016b0473107400640283018201740174026a0319007c006b0573267400640383018201740174026a03050019007c00380003003c0074017c01050019007c00370003003c006400530029044e72050000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904721f000000721500000072160000007217000000290272210000007222000000721a000000721a000000721b000000da087472616e736665721a000000730800000000021001160112017223000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72050000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904721f000000da0c5f5f616c6c6f77616e63657372160000007217000000290272210000007222000000721a000000721a000000721b000000da07617070726f7665220000007304000000000210017225000000290372210000007222000000da0c6d61696e5f6163636f756e74630300000000000000030000000500000043000000738e0000007c0064016b047310740064028301820174017c0274026a03660219007c006b0573407400640374017c0274026a03660219009b0064047c009b009d048301820174047c0219007c006b057354740064058301820174017c0274026a036602050019007c00380003003c0074047c02050019007c00380003003c0074047c01050019007c00370003003c006400530029064e72050000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a0d596f7520617070726f766564207a0a20627574206e656564207a194e6f7420656e6f75676820636f696e7320746f2073656e64212905721f00000072240000007216000000721700000072150000002903722100000072220000007226000000721a000000721a000000721b000000da0d7472616e736665725f66726f6d28000000730e000000000210010c01240114011601100172270000002902da0e746f6b656e5f636f6e7472616374da0c746f6b656e5f616d6f756e7463020000000000000007000000060000004300000073e6000000740074016401190064026403640464058d047d027c007c026b06732474026406830182017c017c027c00190014007d037c037401640719006b057350740264087401640719009b0064099d038301820174036a0474016401190083016a057c007c0183027d0474036a0474016401190083016a0674076a087c04830201007c047c0274076a0819001b007d057c057c057401640a1900140017007d0674097c0674076a0a640b8d0201007409740b74076a0819007401640c19001400740c640b8d020100740d740e83008301740f6b0573e27402640d740f9b00640e9d038301820164005300290f4e7210000000da067072696365737201000000da0a6465785f7072696365732904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d65720300000072040000007a1a546f6b656e206e6f7420617661696c61626c65206f6e2044455872120000007a24436f6e747269627574696f6e206d75737420626520776f727468206174206c65617374207a0420544155721300000029027221000000722200000072140000007a2143616e206e6f7420657863656564206d696e696d756d20737570706c79206f66207a05204b494e472910da0b466f726569676e486173687218000000721f000000da0149da0d696d706f72745f6d6f64756c65da0473656c6cda0d6164645f6c69717569646974797216000000da0474686973722300000072170000007215000000da0c4255524e5f41444452455353da03696e74da0c746f74616c5f737570706c79da0a4d494e5f535550504c59290772280000007229000000da0c5f5f6465785f707269636573da0d63757272656e745f76616c7565da0c61637475616c5f76616c7565da0b6b696e675f616d6f756e74da0a6b696e675f746f74616c721a000000721a000000721b000000da0672656465656d33000000731e000000000208010c0110010c010e0112011001060118010e0110010e011a010801723d00000029017221000000630100000000000000010000000400000043000000731600000074007c00740164018d0201007402830001006400530029024e290272210000007222000000290372230000007234000000da0e5f5f6173736572745f6f776e657229017221000000721a000000721a000000721b000000721400000046000000730400000000020c017214000000630100000000000000010000000300000043000000732200000074006a0174026401190083016a0374046a057c00830201007406830001006400530029024e72100000002907722f00000072300000007218000000da1072656d6f76655f6c697175696469747972160000007233000000723e00000029017221000000721a000000721a000000721b000000723f0000004c000000730400000000021801723f000000290272030000007221000000630200000000000000020000000400000043000000733a0000007c0074006a016b02721a74027c0174006a0364018d0201006e1674046a057c0083016a027c0174006a0364018d0201007406830001006400530029024e29027221000000722200000029077216000000723300000072230000007217000000722f0000007230000000723e000000290272030000007221000000721a000000721a000000721b000000da08776974686472617752000000730800000000020a01100216017240000000630000000000000000000000000200000043000000730e000000740074016a02830083019b00530029014e2903da0373756d7215000000da03616c6c721a000000721a000000721a000000721b00000072360000005b000000730200000000027236000000630000000000000000000000000300000043000000731a00000074006a017402640119006b02731674036402830182016400530029034e720e0000007a194f6e6c792065786563757461626c65206279206f776e6572212904721600000072170000007218000000721f000000721a000000721a000000721a000000721b000000723e0000006000000073020000000001723e0000004e2917da09696d706f72746c6962722f000000da044861736872180000007215000000722400000072370000007234000000721c000000da085f5f6578706f7274da03737472da03416e797220000000da05666c6f6174722300000072250000007227000000723d0000007214000000723f00000072400000007236000000723e000000721a000000721a000000721a000000721b000000da083c6d6f64756c653e01000000733000000004010c010e010e0104010403080b0601120506011207060112050601140a060112120601100506011005060112081005