Contract con_reflecttau


Contract Code


  
1 # non stamp ballooning
2 import currency
3 I = importlib
4
5 # LST001
6 balances = Hash(default_value=0)
7
8 forward_holders_index = Hash(default_value=False)
9 reverse_holders_index = Hash(default_value=False)
10
11 holders_amount = Variable()
12 reflections = Hash(default_value=0.0)
13 # LST002
14 metadata = Hash()
15 total_supply = Variable()
16
17 # LST001
18 # LST002
19 @construct
20 def seed():
21
22 metadata['rocketswap_contract'] = "con_rocketswap_official_v1_1"
23
24 # LST002
25 metadata['token_name'] = "ReflectTAU.io"
26 metadata['token_symbol'] = "RTAU"
27 metadata['operator'] = ctx.caller
28 metadata['buy_tax'] = decimal(8)
29 metadata['sell_tax'] = decimal(8)
30 metadata['redistribute_tau_perc'] = decimal(80)
31 metadata['dev_perc_of_tax'] = decimal(20)
32 metadata['is_initial_liq_ready'] = False
33 metadata['tau_pool'] = decimal(0)
34
35 balances[ctx.caller] = 1000000000
36 forward_holders_index[1] = ctx.caller
37 reverse_holders_index[ctx.caller] = 1
38
39 total_supply.set(1000000000)
40 holders_amount.set(1)
41
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 # LST001
59 @export
60 def approve(amount: float, to: str):
61 assert amount > 0, 'Cannot send negative balances!'
62 balances[ctx.caller, to] += amount
63 return balances[ctx.caller, to]
64
65 def calc_taxes(amount: float, trade_type: str):
66 if(trade_type == "buy"):
67 return amount/100*metadata['buy_tax']
68 elif(trade_type == "sell"):
69 return amount/100*metadata['sell_tax']
70
71 def process_taxes(taxes: float, trade_type:str):
72 balances["con_reflecttau"] += taxes
73 pay_dev_fee(amount=taxes)
74 pay_redistribute_tau(amount=taxes)
75 return taxes
76
77 def pay_dev_fee(amount:float):
78 rocketswap = I.import_module(metadata['rocketswap_contract'])
79 tokens_for_dev = amount/100*metadata['dev_perc_of_tax']
80 balances["con_reflecttau", metadata['rocketswap_contract']] += tokens_for_dev
81 currency_amount = rocketswap.sell(contract="con_reflecttau",token_amount=tokens_for_dev)
82 currency.approve(amount=currency_amount,to=metadata['operator'])
83 currency.transfer(amount=currency_amount,to=metadata['operator'])
84
85 def pay_redistribute_tau(amount:float):
86 rocketswap = I.import_module(metadata['rocketswap_contract'])
87 tokens_for_ins = amount/100*metadata['redistribute_tau_perc']
88 balances["con_reflecttau", metadata['rocketswap_contract']] += tokens_for_ins
89 currency_amount = rocketswap.sell(contract="con_reflecttau",token_amount=tokens_for_ins)
90 metadata['tau_pool'] += currency_amount
91
92 def processTransferNonStandard(amount: float, to: str, main_account: str=""):
93 if(ctx.caller == metadata['rocketswap_contract'] and to != ctx.this and main_account == "" and metadata['is_initial_liq_ready']):
94 taxes = process_taxes(taxes=calc_taxes(amount=amount,trade_type="buy"), trade_type="buy")
95 amount -= taxes
96 if(reverse_holders_index[to] == False):
97 new_holders_amount = holders_amount.get() + 1
98 holders_amount.set(new_holders_amount)
99 forward_holders_index[new_holders_amount] = to
100 reverse_holders_index[to] = new_holders_amount
101
102
103 elif(to==metadata['rocketswap_contract'] and ctx.signer == main_account and metadata['is_initial_liq_ready']):
104 taxes = process_taxes(taxes=calc_taxes(amount=amount,trade_type="sell"), trade_type="sell")
105 amount -= taxes
106 if(balances[main_account] > 1000000):
107 if(reverse_holders_index[main_account] == False):
108 new_holders_amount = holders_amount.get() + 1
109 holders_amount.set(new_holders_amount)
110 forward_holders_index[new_holders_amount] = main_account
111 reverse_holders_index[main_account] = new_holders_amount
112 else:
113 if(reverse_holders_index[main_account] != False):
114 forward_holders_index[reverse_holders_index] = False
115 reverse_holders_index[main_account] = False
116 return amount
117
118 def get_total_supply_without_rocketswap():
119 return total_supply.get() - balances[metadata['rocketswap_contract']]
120
121 @export
122 def redistribute_tau(start:int, end:int): #limit because global stumps limit can exceed, so we do in batches
123 assert ctx.caller == metadata['operator'
124 ], 'Only operator redistribute!'
125 maximum = holders_amount.get()+1
126 if(end > maximum):
127 end = holders_amount.get()+1
128 for holder_id in range(start, end):
129 if(forward_holders_index[holder_id] != False):
130 reflections[forward_holders_index[holder_id]] += metadata["tau_pool"]/100*(balances[forward_holders_index[holder_id]]/get_total_supply_without_rocketswap()*100)
131 metadata['tau_pool'] = decimal(0)
132
133 @export
134 def claim_tau():
135 assert reflections[ctx.caller] > 0, "There is nothing to claim"
136 currency.transfer(amount=reflections[ctx.caller],to=ctx.caller)
137 reflections[ctx.caller] = decimal(0)
138
139 # LST001
140 @export
141 def transfer(amount: float, to: str):
142 assert amount > 0, 'Cannot send negative balances!'
143 sender = ctx.caller
144 assert balances[sender] >= amount, 'Not enough coins to send!'
145 balances[sender] -= amount
146 balances[to] += processTransferNonStandard(amount, to)
147
148 # LST001
149 @export
150 def transfer_from(amount: float, to: str, main_account: str):
151 assert amount > 0, 'Cannot send negative balances!'
152 sender = ctx.caller
153 assert balances[main_account, sender
154 ] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {} ({})'.format(
155 balances[main_account, sender], amount, ctx.caller)
156 assert balances[main_account] >= amount, 'Not enough coins to send! You have {} and are trying to spend {} ({})'.format(
157 balances[main_account], amount, main_account)
158 balances[main_account, sender] -= amount
159 balances[main_account] -= amount
160 balances[to] += processTransferNonStandard(amount, to, main_account)
161
162
163
164

Byte Code

e300000000000000000000000005000000400000007388010000640064016c005a0065015a02650364006402640364048d035a04650364056402640664048d035a05650364056402640764048d035a0665076402640864098d025a0865036509640a83016402640b64048d035a0a65036402640c64098d025a0b65076402640d64098d025a0c640e640f84005a0d650e64028301650f64109c0164116412840483015a10650e64028301650f650f64139c0264146415840483015a11650e64028301650f651264169c0264176418840483015a13650e640283016514650f64199c02641a641b840483015a156514650f641c9c02641d641e84045a166514650f641f9c026420642184045a17651464229c016423642484045a18651464229c016425642684045a1964366514650f650f64289c036429642a84055a1a642b642c84005a1b650e64028301651c651c642d9c02642e642f840483015a1d650e6402830164306431840083015a1e650e640283016514650f64199c0264326433840483015a1f650e640283016514650f650f64289c0364346435840483015a20640153002937e9000000004eda0e636f6e5f7265666c656374746175da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d6546da15666f72776172645f686f6c646572735f696e646578da15726576657273655f686f6c646572735f696e646578da0e686f6c646572735f616d6f756e742902720500000072060000007a03302e30da0b7265666c656374696f6e73da086d65746164617461da0c746f74616c5f737570706c79630000000000000000000000000300000043000000739c0000006401740064023c006403740064043c006405740064063c0074016a02740064073c00740364088301740064093c007403640883017400640a3c007403640b83017400640c3c007403640d83017400640e3c00640f740064103c00740364118301740064123c006413740474016a023c0074016a02740564143c006414740674016a023c0074076a0864138301010074096a086414830101006400530029154eda1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f31da13726f636b6574737761705f636f6e74726163747a0d5265666c6563745441552e696fda0a746f6b656e5f6e616d65da0452544155da0c746f6b656e5f73796d626f6cda086f70657261746f72e908000000da076275795f746178da0873656c6c5f746178e950000000da157265646973747269627574655f7461755f70657263e914000000da0f6465765f706572635f6f665f74617846da1469735f696e697469616c5f6c69715f72656164797201000000da087461755f706f6f6c6900ca9a3be901000000290ada0a5f5f6d65746164617461da03637478da0663616c6c6572da07646563696d616cda0a5f5f62616c616e636573da175f5f666f72776172645f686f6c646572735f696e646578da175f5f726576657273655f686f6c646572735f696e646578da0e5f5f746f74616c5f737570706c79da03736574da105f5f686f6c646572735f616d6f756e74a90072270000007227000000da00da045f5f5f5f0f000000731e00000000010801080108010a010c010c010c010c0108010c010a010a010a010a0172290000002901da0761646472657373630100000000000000010000000200000043000000730800000074007c001900530029014e290172210000002901722a000000722700000072270000007228000000da0a62616c616e63655f6f662100000073020000000002722b0000002902da056f776e6572da077370656e646572630200000000000000020000000300000043000000730c00000074007c007c0166021900530029014e290172210000002902722c000000722d000000722700000072270000007228000000da09616c6c6f77616e63652600000073020000000002722e0000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e72120000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904721e000000721f000000721d000000da0e417373657274696f6e4572726f722902722f0000007230000000722700000072270000007228000000da0f6368616e67655f6d657461646174612b000000730600000000021001060172320000002902da06616d6f756e74da02746f63020000000000000002000000040000004300000073340000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c00740174026a037c0166021900530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e63657321290472310000007221000000721e000000721f000000290272330000007234000000722700000072270000007228000000da07617070726f7665320000007306000000000210011601723500000029027233000000da0a74726164655f7479706563020000000000000002000000030000004300000073340000007c0164016b0272187c0064021b00740064031900140053007c0164046b0272307c0064021b00740064051900140053006400530029064eda03627579e9640000007214000000da0473656c6c72150000002901721d000000290272330000007236000000722700000072270000007228000000da0c5f5f63616c635f74617865733900000073080000000001080110010801723a0000002902da0574617865737236000000630200000000000000020000000400000043000000732800000074006401050019007c00370003003c0074017c0064028d01010074027c0064028d0101007c00530029034e72020000002901723300000029037221000000da0d5f5f7061795f6465765f666565da165f5f7061795f7265646973747269627574655f7461752902723b0000007236000000722700000072270000007228000000da0f5f5f70726f636573735f7461786573400000007308000000000110010a010a01723e00000029017233000000630100000000000000040000000400000043000000736c00000074006a0174026401190083017d017c0064021b0074026403190014007d02740364047402640119006602050019007c02370003003c007c016a0464047c0264058d027d0374056a067c0374026406190064078d02010074056a077c0374026406190064078d0201006400530029084e720e00000072380000007219000000720200000029027205000000da0c746f6b656e5f616d6f756e7472120000002902723300000072340000002908da0149da0d696d706f72745f6d6f64756c65721d00000072210000007239000000da0863757272656e63797235000000da087472616e7366657229047233000000da0a726f636b657473776170da0e746f6b656e735f666f725f646576da0f63757272656e63795f616d6f756e74722700000072270000007228000000723c00000047000000731000000000010e01100110010801060108011201723c000000630100000000000000040000000400000043000000735800000074006a0174026401190083017d017c0064021b0074026403190014007d02740364047402640119006602050019007c02370003003c007c016a0464047c0264058d027d0374026406050019007c03370003003c006400530029074e720e00000072380000007217000000720200000029027205000000723f000000721b000000290572400000007241000000721d00000072210000007239000000290472330000007244000000da0e746f6b656e735f666f725f696e737246000000722700000072270000007228000000723d00000052000000730e00000000010e0110011001080106010801723d0000007228000000290372330000007234000000da0c6d61696e5f6163636f756e74630300000000000000050000000500000043000000731601000074006a017402640119006b0272787c0174006a036b0372787c0264026b0272787402640319007278740474057c00640464058d02640464068d027d037c007c0338007d0074067c01190064076b02727674076a088300640817007d0474076a097c04830101007c01740a7c043c007c0474067c013c006e9a7c017402640119006b026f9474006a0b7c026b026f9474026403190090017212740474057c00640964058d02640964068d027d037c007c0338007d00740c7c021900640a6b0472f474067c02190064076b0272f274076a088300640817007d0474076a097c04830101007c02740a7c043c007c0474067c023c006e1e74067c02190064076b03900172126407740a74063c00640774067c023c007c005300290b4e720e0000007228000000721a00000072370000002902723300000072360000002902723b000000723600000046721c00000072390000006940420f00290d721e000000721f000000721d000000da0474686973723e000000723a00000072230000007226000000da0367657472250000007222000000da067369676e657272210000002905723300000072340000007248000000723b000000da126e65775f686f6c646572735f616d6f756e74722700000072270000007228000000da1c5f5f70726f636573735472616e736665724e6f6e5374616e646172645c000000733400000000010e011401060106010e0108010c010c010a0108010a010c01140206010e0108010c010c010c010a0108010a010e0108010801724d000000630000000000000000000000000400000043000000731400000074006a018300740274036401190019001800530029024e720e00000029047224000000724a0000007221000000721d0000007227000000722700000072270000007228000000da255f5f6765745f746f74616c5f737570706c795f776974686f75745f726f636b6574737761707a00000073020000000001724e0000002902da057374617274da03656e64630200000000000000040000000800000043000000739800000074006a017402640119006b027316740364028301820174046a058300640317007d027c017c026b04723674046a058300640317007d01785074067c007c01830244005d427d0374077c03190064046b037242740874077c0319000500190074026405190064061b00740974077c0319001900740a83001b00640614001400370003003c0071425700740b64078301740264053c006400530029084e72120000007a1b4f6e6c79206f70657261746f722072656469737472696275746521721c00000046721b00000072380000007201000000290c721e000000721f000000721d00000072310000007226000000724a000000da0572616e67657222000000da0d5f5f7265666c656374696f6e737221000000724e00000072200000002904724f0000007250000000da076d6178696d756dda09686f6c6465725f6964722700000072270000007228000000da107265646973747269627574655f7461757e0000007314000000000216010c0108010c0110010c010c010a0120017255000000630000000000000000000000000400000043000000733e000000740074016a02190064016b047316740364028301820174046a05740074016a02190074016a0264038d020100740664018301740074016a023c006400530029044e72010000007a195468657265206973206e6f7468696e6720746f20636c61696d29027233000000723400000029077252000000721e000000721f00000072310000007242000000724300000072200000007227000000722700000072270000007228000000da09636c61696d5f7461758c0000007306000000000216011601725600000063020000000000000003000000060000004300000073540000007c0064016b047310740064028301820174016a027d0274037c0219007c006b05732a740064038301820174037c02050019007c00380003003c0074037c010500190074047c007c018302370003003c006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e642129057231000000721e000000721f0000007221000000724d000000290372330000007234000000da0673656e646572722700000072270000007228000000724300000093000000730a00000000021001060114011001724300000063030000000000000004000000070000004300000073a40000007c0064016b047310740064028301820174016a027d0374037c027c03660219007c006b057342740064036a0474037c027c03660219007c0074016a0283038301820174037c0219007c006b057364740064046a0474037c0219007c007c0283038301820174037c027c036602050019007c00380003003c0074037c02050019007c00380003003c0074037c010500190074057c007c017c028303370003003c006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a4e4e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d20287b7d297a454e6f7420656e6f75676820636f696e7320746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d20287b7d2929067231000000721e000000721f0000007221000000da06666f726d6174724d00000029047233000000723400000072480000007257000000722700000072270000007228000000da0d7472616e736665725f66726f6d9c00000073160000000002100106010a010c01160106010c0110011401100172590000002901722800000029217242000000da09696d706f72746c69627240000000da0448617368722100000072220000007223000000da085661726961626c65722600000072200000007252000000721d00000072240000007229000000da085f5f6578706f7274da03737472722b000000722e000000da03416e797232000000da05666c6f61747235000000723a000000723e000000723c000000723d000000724d000000724e000000da03696e7472550000007256000000724300000072590000007227000000722700000072270000007228000000da083c6d6f64756c653e010000007342000000080104010e0104010a0104010a010c0108010a010c010c03081206011004060112040601120606011206100710070e0b0e0a141e08040601120d1007060112080601