Contract con_mintorburn_v2


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'] = 6
26 metadata['sell_tax'] = 8
27 metadata['redistribute_tau_perc'] = 80
28 metadata['dev_perc_of_tax'] = 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 @export
39 def balance_of(address: str):
40 return balances[address]
41
42 @export
43 def allowance(owner: str, spender: str):
44 return balances[owner, spender]
45
46 # LST002
47 @export
48 def change_metadata(key: str, value: Any):
49 assert ctx.caller == metadata['operator'
50 ], 'Only operator can set metadata!'
51 metadata[key] = value
52
53 @export
54 def change_holders(value: Any):
55 assert ctx.caller == metadata['operator'
56 ], 'Only operator can set metadata!'
57 holders.set(value)
58
59 # LST001
60 @export
61 def approve(amount: float, to: str):
62 assert amount > 0, 'Cannot send negative balances!'
63 balances[ctx.caller, to] += amount
64 return balances[ctx.caller, to]
65
66 def mint_or_burn(amount: float):
67 outcome = random.randint(1,2)
68 if(outcome == 1):
69 return amount + amount/100*metadata['mint_or_burn_percentage']
70 else:
71 balances[metadata["burn_address"]] += amount/100*metadata['mint_or_burn_percentage']
72 return amount - amount/100*metadata['mint_or_burn_percentage']
73
74 def calc_taxes(amount: float, trade_type: str):
75 if(trade_type == "buy"):
76 return amount/100*metadata['buy_tax']
77 elif(trade_type == "sell"):
78 return amount/100*metadata['sell_tax']
79
80 def pay_dev_fee(amount:float):
81 rocketswap = I.import_module(metadata['rocketswap_contract'])
82 tokens_for_dev = amount/100*metadata['dev_perc_of_tax']
83 balances[ctx.this, metadata['rocketswap_contract']] += tokens_for_dev
84 currency_amount = rocketswap.sell(contract=ctx.this,token_amount=tokens_for_dev)
85 currency.approve(amount=currency_amount,to=metadata['operator'])
86 currency.transfer(amount=currency_amount,to=metadata['operator'])
87
88 def pay_redistribute_tau(amount:float):
89 rocketswap = I.import_module(metadata['rocketswap_contract'])
90 tokens_for_ins = amount/100*metadata['redistribute_tau_perc']
91 balances[ctx.this, metadata['rocketswap_contract']] += tokens_for_ins
92 currency_amount = rocketswap.sell(contract=ctx.this,token_amount=tokens_for_ins)
93 metadata['tau_pool'] += currency_amount
94
95 @export
96 def redistribute_tau():
97 for key in holders.get():
98 if(type((balances[key]/circulating_supply.get()*100)) == decimal):
99 currency.transfer(amount=metadata["tau_pool"]/100*(balances[key]/circulating_supply.get()*100),to=key)
100 else:
101 currency.transfer(amount=metadata["tau_pool"]/100*decimal(balances[key]/circulating_supply.get()*100),to=key)
102 metadata['tau_pool'] = decimal(0)
103
104
105 @export
106 def token_swap(amount:float):
107 assert amount > 0, 'Cannot swap negative balances!'
108 assert metadata['swap_enabled'] == True or ctx.caller == metadata['operator'], "The token swap is currently not enabled"
109 old_mob = I.import_module(metadata['old_contract'])
110 old_mob.transfer_from(amount=amount, to=ctx.this, main_account=ctx.caller)
111 balances[ctx.caller] += amount
112 circulating_supply.set(circulating_supply.get() + amount)
113 holders_list = holders.get()
114 if(balances[ctx.caller] < metadata['min_token_for_redistribution']):
115 if(ctx.caller in holders_list):
116 holders_list.remove(ctx.caller)
117 holders.set(holders_list)
118 else:
119 if(ctx.caller not in holders_list):
120 holders_list.append(ctx.caller)
121 holders.set(holders_list)
122
123 def processTransferNonStandard(amount: float, to: str, main_account: str=""):
124 modified_amount = mint_or_burn(amount=amount)
125 if(ctx.caller == metadata['rocketswap_contract'] and to != ctx.this and main_account == "" and metadata['is_initial_liq_ready']):
126 taxes = calc_taxes(amount=modified_amount,trade_type="buy")
127 if(taxes > 1):
128 balances[ctx.this] += taxes
129 pay_dev_fee(amount=taxes)
130 pay_redistribute_tau(amount=taxes)
131 modified_amount -= taxes
132 elif(to==metadata['rocketswap_contract'] and ctx.signer == main_account and metadata['is_initial_liq_ready']):
133 taxes = calc_taxes(amount=modified_amount,trade_type="sell")
134 if(taxes > 1):
135 balances[ctx.this] += taxes
136 pay_dev_fee(amount=taxes)
137 pay_redistribute_tau(amount=taxes)
138 modified_amount -= taxes
139
140 return modified_amount
141
142 # LST001
143 @export
144 def transfer(amount: float, to: str):
145 assert amount > 0, 'Cannot send negative balances!'
146 sender = ctx.caller
147 assert balances[sender] >= amount, 'Not enough coins to send!'
148 balances[sender] -= amount
149 balances[to] += processTransferNonStandard(amount, to)
150 holders_list = holders.get()
151 if(balances[sender] < metadata['min_token_for_redistribution'] and sender != metadata['rocketswap_contract']):
152 if(sender in holders_list):
153 holders_list.remove(sender)
154 holders.set(holders_list)
155 else:
156 if(sender not in holders_list):
157 holders_list.append(sender)
158 holders.set(holders_list)
159
160 # LST001
161 @export
162 def transfer_from(amount: float, to: str, main_account: str):
163 assert amount > 0, 'Cannot send negative balances!'
164 sender = ctx.caller
165 assert balances[main_account, sender
166 ] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'.format(
167 balances[main_account, sender], amount)
168 assert balances[main_account] >= amount, 'Not enough coins to send! You have {} and are trying to spend {} ({})'.format(
169 balances[main_account], amount, main_account)
170 balances[main_account, sender] -= amount
171 balances[main_account] -= amount
172 balances[to] += processTransferNonStandard(amount, to, main_account)
173 holders_list = holders.get()
174 if(balances[main_account] < metadata['min_token_for_redistribution'] and main_account != metadata['rocketswap_contract']):
175 if(main_account in holders_list):
176 holders_list.remove(main_account)
177 holders.set(holders_list)
178 else:
179 if(main_account not in holders_list):
180 holders_list.append(main_account)
181 holders.set(holders_list)
182

Byte Code

e30000000000000000000000000500000040000000736c010000640064016c005a0065015a02650364006402640364048d035a0465036402640564068d025a0565066402640764068d025a0765066402640864068d025a0865096a0a830001006409640a84005a0b650c64028301650d640b9c01640c640d840483015a0e650c64028301650d650d640e9c02640f6410840483015a0f650c64028301650d651064119c0264126413840483015a11650c64028301651064149c0164156416840483015a12650c640283016513650d64179c0264186419840483015a146513641a9c01641b641c84045a156513650d641d9c02641e641f84045a166513641a9c016420642184045a176513641a9c016422642384045a18650c6402830164246425840083015a19650c640283016513641a9c0164266427840483015a1a64306513650d650d64299c03642a642b84055a1b650c640283016513650d64179c02642c642d840483015a1c650c640283016513650d650d64299c03642e642f840483015a1d640153002931e9000000004eda11636f6e5f6d696e746f726275726e5f7632da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000da1263697263756c6174696e675f737570706c79da07686f6c6465727363000000000000000000000000030000004300000073960000006401740064023c006403740064043c006405740064063c0074016a02740064073c006408740064093c00640a7400640b3c00640c7400640d3c00640e7400640f3c006410740064113c006412740064133c006414740064153c006416740064173c006416740064183c0064197400641a3c007403641b83017400641c3c0074046a05641b8301010074066a0567008301010064005300291d4eda1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f31da13726f636b6574737761705f636f6e74726163747a0c4d696e74206f72204275726eda0a746f6b656e5f6e616d65da034d4f42da0c746f6b656e5f73796d626f6cda086f70657261746f72e902000000da176d696e745f6f725f6275726e5f70657263656e74616765e906000000da076275795f746178e908000000da0873656c6c5f746178e950000000da157265646973747269627574655f7461755f70657263e914000000da0f6465765f706572635f6f665f746178da4030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303064656164da0c6275726e5f61646472657373da0e636f6e5f6d696e746f726275726eda0c6f6c645f636f6e747261637446da1469735f696e697469616c5f6c69715f7265616479da0c737761705f656e61626c656469a0252600da1c6d696e5f746f6b656e5f666f725f7265646973747269627574696f6e7201000000da087461755f706f6f6c2907da0a5f5f6d65746164617461da03637478da0663616c6c6572da07646563696d616cda145f5f63697263756c6174696e675f737570706c79da03736574da095f5f686f6c64657273a90072290000007229000000da00da045f5f5f5f0c000000732200000000010801080108010a0108010801080108010802080108010801080108010c010a01722b0000002901da0761646472657373630100000000000000010000000200000043000000730800000074007c001900530029014e2901da0a5f5f62616c616e6365732901722c00000072290000007229000000722a000000da0a62616c616e63655f6f662100000073020000000002722e0000002902da056f776e6572da077370656e646572630200000000000000020000000300000043000000730c00000074007c007c0166021900530029014e2901722d0000002902722f000000723000000072290000007229000000722a000000da09616c6c6f77616e6365260000007302000000000272310000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720f0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904722300000072240000007222000000da0e417373657274696f6e4572726f7229027232000000723300000072290000007229000000722a000000da0f6368616e67655f6d657461646174612b0000007306000000000210010601723500000029017233000000630100000000000000010000000300000043000000732400000074006a017402640119006b027316740364028301820174046a057c00830101006400530029034e720f0000007a1f4f6e6c79206f70657261746f722063616e20736574206d657461646174612129067223000000722400000072220000007234000000722800000072270000002901723300000072290000007229000000722a000000da0e6368616e67655f686f6c6465727332000000730600000000021001060172360000002902da06616d6f756e74da02746f63020000000000000002000000040000004300000073340000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c00740174026a037c0166021900530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e6365732129047234000000722d0000007223000000722400000029027237000000723800000072290000007229000000722a000000da07617070726f7665390000007306000000000210011601723900000029017237000000630100000000000000020000000600000043000000736000000074006a016401640283027d017c0164016b0272287c007c0064031b007402640419001400170053007403740264051900050019007c0064031b007402640419001400370003003c007c007c0064031b007402640419001400180053006400530029064ee9010000007210000000e9640000007211000000721b0000002904da0672616e646f6dda0772616e64696e747222000000722d00000029027237000000da076f7574636f6d6572290000007229000000722a000000da0e5f5f6d696e745f6f725f6275726e40000000730c00000000010c010801140214010c01723f00000029027237000000da0a74726164655f7479706563020000000000000002000000030000004300000073340000007c0164016b0272187c0064021b00740064031900140053007c0164046b0272307c0064021b00740064051900140053006400530029064eda03627579723b0000007213000000da0473656c6c72150000002901722200000029027237000000724000000072290000007229000000722a000000da0c5f5f63616c635f74617865734a000000730800000000010801100108017243000000630100000000000000040000000400000043000000737000000074006a0174026401190083017d017c0064021b0074026403190014007d02740374046a057402640119006602050019007c02370003003c007c016a0674046a057c0264048d027d0374076a087c0374026405190064068d02010074076a097c0374026405190064068d0201006400530029074e720b000000723b000000721900000029027205000000da0c746f6b656e5f616d6f756e74720f000000290272370000007238000000290ada0149da0d696d706f72745f6d6f64756c657222000000722d0000007223000000da04746869737242000000da0863757272656e63797239000000da087472616e7366657229047237000000da0a726f636b657473776170da0e746f6b656e735f666f725f646576da0f63757272656e63795f616d6f756e7472290000007229000000722a000000da0d5f5f7061795f6465765f66656551000000730e00000000010e0110011a01080108011201724d000000630100000000000000040000000400000043000000735c00000074006a0174026401190083017d017c0064021b0074026403190014007d02740374046a057402640119006602050019007c02370003003c007c016a0674046a057c0264048d027d0374026405050019007c03370003003c006400530029064e720b000000723b000000721700000029027205000000724400000072210000002907724500000072460000007222000000722d00000072230000007247000000724200000029047237000000724a000000da0e746f6b656e735f666f725f696e73724c00000072290000007229000000722a000000da165f5f7061795f7265646973747269627574655f7461755b000000730c00000000010e0110011a0108010801724f0000006300000000000000000100000006000000430000007398000000788674006a01830044005d7a7d00740274037c00190074046a0183001b0064011400830174056b02725674066a0774086402190064011b0074037c00190074046a0183001b006401140014007c0064038d020100710a74066a0774086402190064011b00740574037c00190074046a0183001b0064011400830114007c0064038d020100710a5700740564048301740864023c006400530029054e723b0000007221000000290272370000007238000000720100000029097228000000da03676574da0474797065722d000000722600000072250000007248000000724900000072220000002901723200000072290000007229000000722a000000da107265646973747269627574655f74617564000000730e00000000020e011c010e011e0210012201725200000063010000000000000003000000050000004300000073d80000007c0064016b047310740064028301820174016403190064046b02733274026a037401640519006b027332740064068301820174046a0574016407190083017d017c016a067c0074026a0774026a0364088d030100740874026a03050019007c00370003003c0074096a0a74096a0b83007c00170083010100740c6a0b83007d02740874026a0319007401640919006b0072b474026a037c026b0672d47c026a0d74026a0383010100740c6a0a7c02830101006e2074026a037c026b0772d47c026a0e74026a0383010100740c6a0a7c028301010064005300290a4e72010000007a1e43616e6e6f742073776170206e656761746976652062616c616e63657321721f00000054720f0000007a2754686520746f6b656e20737761702069732063757272656e746c79206e6f7420656e61626c6564721d000000290372370000007238000000da0c6d61696e5f6163636f756e747220000000290f723400000072220000007223000000722400000072450000007246000000da0d7472616e736665725f66726f6d7247000000722d0000007226000000722700000072500000007228000000da0672656d6f7665da06617070656e6429037237000000da076f6c645f6d6f62da0c686f6c646572735f6c69737472290000007229000000722a000000da0a746f6b656e5f7377617070000000731e00000000021001120110010e01140112011201080112010a010c010c010a010c017259000000722a000000290372370000007238000000725300000063030000000000000005000000040000004300000073da00000074007c0064018d017d0374016a027403640219006b0272767c0174016a046b0372767c0264036b027276740364041900727674057c03640564068d027d047c0464076b0472d6740674016a04050019007c04370003003c0074077c0464018d01010074087c0464018d0101007c037c0438007d036e607c017403640219006b0272d674016a097c026b0272d674036404190072d674057c03640864068d027d047c0464076b0472d6740674016a04050019007c04370003003c0074077c0464018d01010074087c0464018d0101007c037c0438007d037c03530029094e29017237000000720b000000722a000000721e0000007241000000290272370000007240000000723a0000007242000000290a723f00000072230000007224000000722200000072470000007243000000722d000000724d000000724f000000da067369676e65722905723700000072380000007253000000da0f6d6f6469666965645f616d6f756e74da05746178657372290000007229000000722a000000da1c5f5f70726f636573735472616e736665724e6f6e5374616e6461726483000000732600000000010a010e01140106010c01080112010a010a010a010c0112020c01080112010a010a010801725d00000063020000000000000004000000060000004300000073b20000007c0064016b047310740064028301820174016a027d0274037c0219007c006b05732a740064038301820174037c02050019007c00380003003c0074037c010500190074047c007c018302370003003c0074056a0683007d0374037c0219007407640419006b0072927c027407640519006b0372927c027c036b0672ae7c036a087c028301010074056a097c03830101006e1c7c027c036b0772ae7c036a0a7c028301010074056a097c03830101006400530029064e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64217220000000720b000000290b723400000072230000007224000000722d000000725d000000722800000072500000007222000000725500000072270000007256000000290472370000007238000000da0673656e646572725800000072290000007229000000722a00000072490000009a000000731c000000000210010601140110011601080110010c0108010a010c0108010a01724900000063030000000000000005000000070000004300000073fe0000007c0064016b047310740064028301820174016a027d0374037c027c03660219007c006b05733e740064036a0474037c027c03660219007c0083028301820174037c0219007c006b057360740064046a0474037c0219007c007c0283038301820174037c027c036602050019007c00380003003c0074037c02050019007c00380003003c0074037c010500190074057c007c017c028303370003003c0074066a0783007d0474037c0219007408640519006b0072de7c027408640619006b0372de7c027c046b0672fa7c046a097c028301010074066a0a7c04830101006e1c7c027c046b0772fa7c046a0b7c028301010074066a0a7c04830101006400530029074e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a454e6f7420656e6f75676820636f696e7320746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d20287b7d297220000000720b000000290c723400000072230000007224000000722d000000da06666f726d6174725d0000007228000000725000000072220000007255000000722700000072560000002905723700000072380000007253000000725e000000725800000072290000007229000000722a0000007254000000ac00000073280000000002100106010a010c01120106010c011001140110011801080110010c0108010a010c0108010a0172540000002901722a000000291e7248000000da09696d706f72746c69627245000000da0448617368722d0000007222000000da085661726961626c6572260000007228000000723c000000da0473656564722b000000da085f5f6578706f7274da03737472722e0000007231000000da03416e7972350000007236000000da05666c6f61747239000000723f0000007243000000724d000000724f00000072520000007259000000725d00000072490000007254000000722900000072290000007229000000722a000000da083c6d6f64756c653e01000000733e00000008010401060108010c01040108010c010803081506011004060112040601120606011006060112060e0a10070e0a0e09100c060110121417060112110601