Contract con_mintorburn_v3


Contract Code


  
1 # -> MintOrBurn.com <-
2 # LST001
3 import currency
4 I = importlib
5
6
7 balances = Hash(default_value=0)
8 # LST002
9 metadata = Hash()
10 circulating_supply = Variable()
11 holders = Variable()
12 random.seed()
13 # LST001
14 # LST002
15 @construct
16 def seed():
17
18 metadata['rocketswap_contract'] = "con_rocketswap_official_v1_1"
19
20 # LST002
21 metadata['token_name'] = "Mint or Burn"
22 metadata['token_symbol'] = "MOB"
23 metadata['operator'] = ctx.caller
24 metadata['mint_or_burn_percentage'] = 2
25 metadata['buy_tax'] = decimal(6)
26 metadata['sell_tax'] = decimal(8)
27 metadata['redistribute_tau_perc'] = decimal(80)
28 metadata['dev_perc_of_tax'] = decimal(20)
29 metadata['burn_address'] = "000000000000000000000000000000000000000000000000000000000000dead"
30 metadata['old_contract'] = "con_mintorburn"
31 metadata['is_initial_liq_ready'] = False
32 metadata['swap_enabled'] = False
33 metadata['min_token_for_redistribution'] = 2500000
34 metadata['tau_pool'] = decimal(0)
35 circulating_supply.set(0)
36 holders.set([]) # Only people who own > min_token_for_redistribution MOB or list gets too long
37
38 # v1 to v2 swaps but v2 was broken and v1 tokens are gone
39 balances['ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89'] = 697891683
40 balances['25410ac58295c8fe956c443135606fa385da5a3c80dea693148ed94a1bafe56d'] = 86528693
41 balances['2091efd8e68e9700e2896c1930c09e05f4f642bb9fefb305733c02b0d509e388'] = 235212
42
43 @export
44 def balance_of(address: str):
45 return balances[address]
46
47 @export
48 def allowance(owner: str, spender: str):
49 return balances[owner, spender]
50
51 # LST002
52 @export
53 def change_metadata(key: str, value: Any):
54 assert ctx.caller == metadata['operator'
55 ], 'Only operator can set metadata!'
56 metadata[key] = value
57
58 @export
59 def change_holders(value: Any):
60 assert ctx.caller == metadata['operator'
61 ], 'Only operator can set metadata!'
62 holders.set(value)
63
64 # LST001
65 @export
66 def approve(amount: float, to: str):
67 assert amount > 0, 'Cannot send negative balances!'
68 balances[ctx.caller, to] += amount
69 return balances[ctx.caller, to]
70
71 def mint_or_burn(amount: float):
72 outcome = random.randint(1,2)
73 if(outcome == 1):
74 return amount + amount/100*metadata['mint_or_burn_percentage']
75 else:
76 balances[metadata["burn_address"]] += amount/100*metadata['mint_or_burn_percentage']
77 return amount - amount/100*metadata['mint_or_burn_percentage']
78
79 def calc_taxes(amount: float, trade_type: str):
80 if(trade_type == "buy"):
81 return amount/100*metadata['buy_tax']
82 elif(trade_type == "sell"):
83 return amount/100*metadata['sell_tax']
84
85 def pay_dev_fee(amount:float, tx_type:str):
86 if(tx_type == "sell"):
87 rocketswap = I.import_module(metadata['rocketswap_contract'])
88 tokens_for_dev = amount/100*metadata['dev_perc_of_tax']
89 balances["con_mintorburn_v3", metadata['rocketswap_contract']] += tokens_for_dev
90 currency_amount = rocketswap.sell(contract="con_mintorburn_v3",token_amount=tokens_for_dev)
91 currency.approve(amount=currency_amount,to=metadata['operator'])
92 currency.transfer(amount=currency_amount,to=metadata['operator'])
93 else:
94 rocketswap = I.import_module(metadata['rocketswap_contract'])
95 tokens_for_dev = amount/100*metadata['dev_perc_of_tax']
96 balances["con_mintorburn_v3", metadata['rocketswap_contract']] += tokens_for_dev
97 currency_amount = rocketswap.sell(contract="con_mintorburn_v3",token_amount=tokens_for_dev)
98 currency.approve(amount=currency_amount,to=metadata['operator'])
99 currency.transfer(amount=currency_amount,to=metadata['operator'])
100
101 def pay_redistribute_tau(amount:float, tx_type:str):
102 if(tx_type == "sell"):
103 rocketswap = I.import_module(metadata['rocketswap_contract'])
104 tokens_for_ins = amount/100*metadata['redistribute_tau_perc']
105 balances["con_mintorburn_v3", metadata['rocketswap_contract']] += tokens_for_ins
106 currency_amount = rocketswap.sell(contract="con_mintorburn_v3",token_amount=tokens_for_ins)
107 metadata['tau_pool'] += currency_amount
108 else:
109 rocketswap = I.import_module(metadata['rocketswap_contract'])
110 tokens_for_ins = amount/100*metadata['redistribute_tau_perc']
111 balances["con_mintorburn_v3", metadata['rocketswap_contract']] += tokens_for_ins
112 currency_amount = rocketswap.sell(contract="con_mintorburn_v3",token_amount=tokens_for_ins)
113 metadata['tau_pool'] += currency_amount
114
115 @export
116 def redistribute_tau():
117 for key in holders.get():
118 if(type((balances[key]/circulating_supply.get()*100)) == decimal):
119 currency.transfer(amount=metadata["tau_pool"]/100*(balances[key]/circulating_supply.get()*100),to=key)
120 else:
121 currency.transfer(amount=metadata["tau_pool"]/100*decimal(balances[key]/circulating_supply.get()*100),to=key)
122 metadata['tau_pool'] = decimal(0)
123
124
125 @export
126 def token_swap(amount:float):
127 assert amount > 0, 'Cannot swap negative balances!'
128 assert metadata['swap_enabled'] == True or ctx.caller == metadata['operator'], "The token swap is currently not enabled"
129 old_mob = I.import_module(metadata['old_contract'])
130 old_mob.transfer_from(amount=amount, to=ctx.this, main_account=ctx.caller)
131 balances[ctx.caller] += amount
132 circulating_supply.set(circulating_supply.get() + amount)
133 holders_list = holders.get()
134 if(balances[ctx.caller] < metadata['min_token_for_redistribution']):
135 if(ctx.caller in holders_list):
136 holders_list.remove(ctx.caller)
137 holders.set(holders_list)
138 else:
139 if(ctx.caller not in holders_list):
140 holders_list.append(ctx.caller)
141 holders.set(holders_list)
142
143 def processTransferNonStandard(amount: float, to: str, main_account: str=""):
144 modified_amount = mint_or_burn(amount=amount)
145 if(ctx.caller == metadata['rocketswap_contract'] and to != ctx.this and main_account == "" and metadata['is_initial_liq_ready']):
146 taxes = calc_taxes(amount=modified_amount,trade_type="buy")
147 if(taxes > 1):
148 balances["con_mintorburn_v3"] += taxes
149 pay_dev_fee(amount=taxes,tx_type="buy")
150 pay_redistribute_tau(amount=taxes,tx_type="buy")
151 modified_amount -= taxes
152 elif(to==metadata['rocketswap_contract'] and ctx.signer == main_account and metadata['is_initial_liq_ready']):
153 taxes = calc_taxes(amount=modified_amount,trade_type="sell")
154 if(taxes > 1):
155 balances["con_mintorburn_v3"] += taxes
156 pay_dev_fee(amount=taxes,tx_type="sell")
157 pay_redistribute_tau(amount=taxes,tx_type="sell")
158 modified_amount -= taxes
159
160 return modified_amount
161
162 # LST001
163 @export
164 def transfer(amount: float, to: str):
165 assert amount > 0, 'Cannot send negative balances!'
166 sender = ctx.caller
167 assert balances[sender] >= amount, 'Not enough coins to send!'
168 balances[sender] -= amount
169 balances[to] += processTransferNonStandard(amount, to)
170 holders_list = holders.get()
171 if(balances[sender] < metadata['min_token_for_redistribution'] and sender != metadata['rocketswap_contract']):
172 if(sender in holders_list):
173 holders_list.remove(sender)
174 holders.set(holders_list)
175 else:
176 if(sender not in holders_list):
177 holders_list.append(sender)
178 holders.set(holders_list)
179
180 # LST001
181 @export
182 def transfer_from(amount: float, to: str, main_account: str):
183 assert amount > 0, 'Cannot send negative balances!'
184 sender = ctx.caller
185 assert balances[main_account, sender
186 ] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {} ({})'.format(
187 balances[main_account, sender], amount, ctx.caller)
188 assert balances[main_account] >= amount, 'Not enough coins to send! You have {} and are trying to spend {} ({})'.format(
189 balances[main_account], amount, main_account)
190 balances[main_account, sender] -= amount
191 balances[main_account] -= amount
192 balances[to] += processTransferNonStandard(amount, to, main_account)
193 holders_list = holders.get()
194 if(balances[main_account] < metadata['min_token_for_redistribution'] and main_account != metadata['rocketswap_contract']):
195 if(main_account in holders_list):
196 holders_list.remove(main_account)
197 holders.set(holders_list)
198 else:
199 if(main_account not in holders_list):
200 holders_list.append(main_account)
201 holders.set(holders_list)
202

Byte Code

e300000000000000000000000005000000400000007370010000640064016c005a0065015a02650364006402640364048d035a0465036402640564068d025a0565066402640764068d025a0765066402640864068d025a0865096a0a830001006409640a84005a0b650c64028301650d640b9c01640c640d840483015a0e650c64028301650d650d640e9c02640f6410840483015a0f650c64028301650d651064119c0264126413840483015a11650c64028301651064149c0164156416840483015a12650c640283016513650d64179c0264186419840483015a146513641a9c01641b641c84045a156513650d641d9c02641e641f84045a166513650d64209c026421642284045a176513650d64209c026423642484045a18650c6402830164256426840083015a19650c640283016513641a9c0164276428840483015a1a64316513650d650d642a9c03642b642c84055a1b650c640283016513650d64179c02642d642e840483015a1c650c640283016513650d650d642a9c03642f6430840483015a1d640153002932e9000000004eda11636f6e5f6d696e746f726275726e5f7633da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000da1263697263756c6174696e675f737570706c79da07686f6c6465727363000000000000000000000000030000004300000073be0000006401740064023c006403740064043c006405740064063c0074016a02740064073c006408740064093c007403640a83017400640b3c007403640c83017400640d3c007403640e83017400640f3c00740364108301740064113c006412740064133c006414740064153c006416740064173c006416740064183c0064197400641a3c007403641b83017400641c3c0074046a05641b8301010074066a05670083010100641d7407641e3c00641f740764203c006421740764223c006400530029234eda1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f31da13726f636b6574737761705f636f6e74726163747a0c4d696e74206f72204275726eda0a746f6b656e5f6e616d65da034d4f42da0c746f6b656e5f73796d626f6cda086f70657261746f72e902000000da176d696e745f6f725f6275726e5f70657263656e74616765e906000000da076275795f746178e908000000da0873656c6c5f746178e950000000da157265646973747269627574655f7461755f70657263e914000000da0f6465765f706572635f6f665f746178da4030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303064656164da0c6275726e5f61646472657373da0e636f6e5f6d696e746f726275726eda0c6f6c645f636f6e747261637446da1469735f696e697469616c5f6c69715f7265616479da0c737761705f656e61626c656469a0252600da1c6d696e5f746f6b656e5f666f725f7265646973747269627574696f6e7201000000da087461755f706f6f6c6963fb9829da406666363135343465613934656161656235646630386564383633633461393338653931323961626136636565653566333162363638316264656465313162383969b5522805da403235343130616335383239356338666539353663343433313335363036666133383564613561336338306465613639333134386564393461316261666535366469cc960300da40323039316566643865363865393730306532383936633139333063303965303566346636343262623966656662333035373333633032623064353039653338382908da0a5f5f6d65746164617461da03637478da0663616c6c6572da07646563696d616cda145f5f63697263756c6174696e675f737570706c79da03736574da095f5f686f6c64657273da0a5f5f62616c616e636573a900722d000000722d000000da00da045f5f5f5f0c000000732800000000010801080108010a0108010c010c010c010c02080108010801080108010c010a010a0308030803722f0000002901da0761646472657373630100000000000000010000000200000043000000730800000074007c001900530029014e2901722c00000029017230000000722d000000722d000000722e000000da0a62616c616e63655f6f662a0000007302000000000272310000002902da056f776e6572da077370656e646572630200000000000000020000000300000043000000730c00000074007c007c0166021900530029014e2901722c000000290272320000007233000000722d000000722d000000722e000000da09616c6c6f77616e63652f0000007302000000000272340000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720f0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904722600000072270000007225000000da0e417373657274696f6e4572726f72290272350000007236000000722d000000722d000000722e000000da0f6368616e67655f6d65746164617461340000007306000000000210010601723800000029017236000000630100000000000000010000000300000043000000732400000074006a017402640119006b027316740364028301820174046a057c00830101006400530029034e720f0000007a1f4f6e6c79206f70657261746f722063616e20736574206d657461646174612129067226000000722700000072250000007237000000722b000000722a00000029017236000000722d000000722d000000722e000000da0e6368616e67655f686f6c646572733b000000730600000000021001060172390000002902da06616d6f756e74da02746f63020000000000000002000000040000004300000073340000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c00740174026a037c0166021900530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e6365732129047237000000722c000000722600000072270000002902723a000000723b000000722d000000722d000000722e000000da07617070726f7665420000007306000000000210011601723c0000002901723a000000630100000000000000020000000600000043000000736000000074006a016401640283027d017c0164016b0272287c007c0064031b007402640419001400170053007403740264051900050019007c0064031b007402640419001400370003003c007c007c0064031b007402640419001400180053006400530029064ee9010000007210000000e9640000007211000000721b0000002904da0672616e646f6dda0772616e64696e747225000000722c0000002902723a000000da076f7574636f6d65722d000000722d000000722e000000da0e5f5f6d696e745f6f725f6275726e49000000730c00000000010c010801140214010c0172420000002902723a000000da0a74726164655f7479706563020000000000000002000000030000004300000073340000007c0164016b0272187c0064021b00740064031900140053007c0164046b0272307c0064021b00740064051900140053006400530029064eda03627579723e0000007213000000da0473656c6c7215000000290172250000002902723a0000007243000000722d000000722d000000722e000000da0c5f5f63616c635f7461786573530000007308000000000108011001080172460000002902723a000000da0774785f7479706563020000000000000005000000040000004300000073de0000007c0164016b02727274006a0174026402190083017d027c0064031b0074026404190014007d03740364057402640219006602050019007c03370003003c007c026a0464057c0364068d027d0474056a067c0474026407190064088d02010074056a077c0474026407190064088d0201006e6874006a0174026402190083017d027c0064031b0074026404190014007d03740364057402640219006602050019007c03370003003c007c026a0464057c0364068d027d0474056a067c0474026407190064088d02010074056a077c0474026407190064088d0201006400530029094e7245000000720b000000723e0000007219000000720200000029027205000000da0c746f6b656e5f616d6f756e74720f0000002902723a000000723b0000002908da0149da0d696d706f72745f6d6f64756c657225000000722c0000007245000000da0863757272656e6379723c000000da087472616e736665722905723a0000007247000000da0a726f636b657473776170da0e746f6b656e735f666f725f646576da0f63757272656e63795f616d6f756e74722d000000722d000000722e000000da0d5f5f7061795f6465765f6665655a0000007322000000000108010e0110011001080106010801120114020e01100110010801060108011201725000000063020000000000000005000000040000004300000073b60000007c0164016b02725e74006a0174026402190083017d027c0064031b0074026404190014007d03740364057402640219006602050019007c03370003003c007c026a0464057c0364068d027d0474026407050019007c04370003003c006e5474006a0174026402190083017d027c0064031b0074026404190014007d03740364057402640219006602050019007c03370003003c007c026a0464057c0364068d027d0474026407050019007c04370003003c006400530029084e7245000000720b000000723e00000072170000007202000000290272050000007248000000722100000029057249000000724a0000007225000000722c00000072450000002905723a0000007247000000724d000000da0e746f6b656e735f666f725f696e73724f000000722d000000722d000000722e000000da165f5f7061795f7265646973747269627574655f7461756f000000731e000000000108010e011001100108010601080112020e011001100108010601080172520000006300000000000000000100000006000000430000007398000000788674006a01830044005d7a7d00740274037c00190074046a0183001b0064011400830174056b02725674066a0774086402190064011b0074037c00190074046a0183001b006401140014007c0064038d020100710a74066a0774086402190064011b00740574037c00190074046a0183001b0064011400830114007c0064038d020100710a5700740564048301740864023c006400530029054e723e00000072210000002902723a000000723b00000072010000002909722b000000da03676574da0474797065722c00000072290000007228000000724b000000724c000000722500000029017235000000722d000000722d000000722e000000da107265646973747269627574655f74617582000000730e00000000020e011c010e011e0210012201725500000063010000000000000003000000050000004300000073d80000007c0064016b047310740064028301820174016403190064046b02733274026a037401640519006b027332740064068301820174046a0574016407190083017d017c016a067c0074026a0774026a0364088d030100740874026a03050019007c00370003003c0074096a0a74096a0b83007c00170083010100740c6a0b83007d02740874026a0319007401640919006b0072b474026a037c026b0672d47c026a0d74026a0383010100740c6a0a7c02830101006e2074026a037c026b0772d47c026a0e74026a0383010100740c6a0a7c028301010064005300290a4e72010000007a1e43616e6e6f742073776170206e656761746976652062616c616e63657321721f00000054720f0000007a2754686520746f6b656e20737761702069732063757272656e746c79206e6f7420656e61626c6564721d0000002903723a000000723b000000da0c6d61696e5f6163636f756e747220000000290f72370000007225000000722600000072270000007249000000724a000000da0d7472616e736665725f66726f6dda0474686973722c0000007229000000722a0000007253000000722b000000da0672656d6f7665da06617070656e642903723a000000da076f6c645f6d6f62da0c686f6c646572735f6c697374722d000000722d000000722e000000da0a746f6b656e5f737761708e000000731e00000000021001120110010e01140112011201080112010a010c010c010a010c01725d000000722e0000002903723a000000723b000000725600000063030000000000000005000000040000004300000073de00000074007c0064018d017d0374016a027403640219006b0272787c0174016a046b0372787c0264036b027278740364041900727874057c03640564068d027d047c0464076b0472da74066408050019007c04370003003c0074077c04640564098d02010074087c04640564098d0201007c037c0438007d036e627c017403640219006b0272da74016a097c026b0272da74036404190072da74057c03640a64068d027d047c0464076b0472da74066408050019007c04370003003c0074077c04640a64098d02010074087c04640a64098d0201007c037c0438007d037c035300290b4e2901723a000000720b000000722e000000721e00000072440000002902723a0000007243000000723d00000072020000002902723a00000072470000007245000000290a724200000072260000007227000000722500000072580000007246000000722c00000072500000007252000000da067369676e65722905723a000000723b0000007256000000da0f6d6f6469666965645f616d6f756e74da057461786573722d000000722d000000722e000000da1c5f5f70726f636573735472616e736665724e6f6e5374616e64617264a1000000732600000000010a010e01140106010c01080110010c010c010a010c0112020c01080110010c010c010801726100000063020000000000000004000000060000004300000073b20000007c0064016b047310740064028301820174016a027d0274037c0219007c006b05732a740064038301820174037c02050019007c00380003003c0074037c010500190074047c007c018302370003003c0074056a0683007d0374037c0219007407640419006b0072927c027407640519006b0372927c027c036b0672ae7c036a087c028301010074056a097c03830101006e1c7c027c036b0772ae7c036a0a7c028301010074056a097c03830101006400530029064e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64217220000000720b000000290b723700000072260000007227000000722c0000007261000000722b000000725300000072250000007259000000722a000000725a0000002904723a000000723b000000da0673656e646572725c000000722d000000722d000000722e000000724c000000b8000000731c000000000210010601140110011601080110010c0108010a010c0108010a01724c00000063030000000000000005000000070000004300000073020100007c0064016b047310740064028301820174016a027d0374037c027c03660219007c006b057342740064036a0474037c027c03660219007c0074016a0283038301820174037c0219007c006b057364740064046a0474037c0219007c007c0283038301820174037c027c036602050019007c00380003003c0074037c02050019007c00380003003c0074037c010500190074057c007c017c028303370003003c0074066a0783007d0474037c0219007408640519006b0072e27c027408640619006b0372e27c027c046b0672fe7c046a097c028301010074066a0a7c04830101006e1c7c027c046b0772fe7c046a0b7c028301010074066a0a7c04830101006400530029074e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a4e4e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d20287b7d297a454e6f7420656e6f75676820636f696e7320746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d20287b7d297220000000720b000000290c723700000072260000007227000000722c000000da06666f726d61747261000000722b000000725300000072250000007259000000722a000000725a0000002905723a000000723b00000072560000007262000000725c000000722d000000722d000000722e0000007257000000ca00000073280000000002100106010a010c01160106010c011001140110011801080110010c0108010a010c0108010a0172570000002901722e000000291e724b000000da09696d706f72746c69627249000000da0448617368722c0000007225000000da085661726961626c657229000000722b000000723f000000da0473656564722f000000da085f5f6578706f7274da0373747272310000007234000000da03416e7972380000007239000000da05666c6f6174723c00000072420000007246000000725000000072520000007255000000725d0000007261000000724c0000007257000000722d000000722d000000722d000000722e000000da083c6d6f64756c653e01000000733e00000008010401060108010c01040108010c010803081e06011004060112040601120606011006060112060e0a100710151013100c060110121417060112110601