Contract con_yeti_contract_2


Contract Code


  
1 I = importlib
2
3 rswp_reserves = ForeignHash(foreign_contract='con_rocketswap_official_v1_1', foreign_name='reserves')
4 balances = Hash(default_value=0)
5 metadata = Hash()
6
7 TOKEN_CONTRACT = 'con_yeti_contract'
8
9 WALLET_CHIEF = 'ec9decc889a17d4ea22afbd518f767a136f36301a0b1aa9a660f3f71d61f5b2b'
10 WALLET_NIEL = '1910513066afbe592d6140c0055de3cb068fe7c17584a654a704ac7e60b2df04'
11 WALLET_YETI_LP = 'a690e68d8a049ea7c8ad4e16b166e321bd5ebc0dba4dc10d2ea01bf6eed84cca'
12 WALLET_YETI_RAIN = 'e8dc708028e049397b5baf9579924dde58ce5bebee5655da0b53066117572e73'
13 WALLET_YETI_MARKETING = '3466e7576d1b70aef675ee4149b0d83cf21f69f4cfade801249d5afaad7c7ac9'
14 WALLET_YETI_CHARITY = '4c66b7ba687222d44df2c3c989ae4cc50185abfcee8ea5356afcc5344c4a5f94'
15 WALLET_YETI_BUYBACK = 'b22e0df3949428211989867c4e4febd851af3c1c044a8d892e8a07b7034e94dc'
16 WALLET_DEV = '42a13c664781a24ab4aca978abb685d9c07ef9ae64a2af865a043e3186a66907'
17
18 @construct
19 def init():
20 # Token info
21 balances[WALLET_CHIEF] = 94_000_000_000
22 balances[WALLET_NIEL] = 5_000_000_000
23 balances[WALLET_DEV] = 1_000_000_000
24 metadata['token_name'] = 'YETI TOKEN'
25 metadata['token_symbol'] = 'YETI'
26 metadata['owners'] = [WALLET_CHIEF, WALLET_NIEL, WALLET_DEV]
27 # Swap info
28 metadata['swap_token'] = 'con_marmite100_contract'
29 metadata['swap_end'] = now + datetime.timedelta(days=180) # HOW MANY DAYS TO AGREE ON? 6 MONTHS?
30 metadata['swap_rate'] = decimal('1')
31 # Wallets
32 metadata['rewards_contract'] = 'con_yeti_rewards'
33 metadata['LP_wallet'] = WALLET_YETI_LP
34 metadata['rain_wallet'] = WALLET_YETI_RAIN
35 metadata['marketing_wallet'] = WALLET_YETI_MARKETING
36 metadata['charity_wallet'] = WALLET_YETI_CHARITY
37 metadata['buyback_wallet'] = WALLET_YETI_BUYBACK
38 metadata['burn_wallet'] = 'yeti_burn_wallet'
39 # TODO: rule out contracts by checking for "con_"
40
41 metadata['blacklisted_wallets'] = [
42 '1b6a98bc717d568379218ca87b2b8f67b561ee1e50049da1af8f104270816a6b',
43 WALLET_CHIEF,
44 WALLET_NIEL,
45 WALLET_YETI_LP,
46 WALLET_YETI_RAIN,
47 WALLET_YETI_MARKETING,
48 WALLET_YETI_CHARITY,
49 WALLET_YETI_BUYBACK
50 ]
51
52 # Rates
53 metadata['buy_tax'] = decimal('0.02') #2%
54 metadata['sell_tax'] = decimal('0.05') #5%
55 metadata['rewards%'] = decimal('0.1') #10% of tax
56 metadata['LP%'] = decimal('0.35') #35% of tax
57 metadata['rain%'] = decimal('0.05') #5% of tax
58 metadata['marketing%'] = decimal('0.5') #50% of tax
59 metadata['charity%'] = decimal('0.00') #0% of tax
60 metadata['buyback%'] = decimal('0.00') #0% of tax
61 metadata['burn%'] = decimal('0.00') #0% of tax
62 # DEX
63 metadata['dex'] = ['con_rocketswap_official_v1_1']
64 # Reward token
65 metadata['reward_token'] = 'con_lusd_lst001'
66
67 metadata['bridge'] = ['con_lamden_link_bsc_v1', 'con_lamden_link_weth_v1']
68
69
70 # LST002 with governance
71
72 @export
73 def change_metadata(key: str, value: Any):
74 assert_owner()
75 owners = metadata['owners']
76 caller = ctx.caller
77
78 metadata[caller, key] = {'v':value, 'time':now}
79 agreed = False
80 for owner in owners:
81 if metadata[owner, key] is None:
82 # Without this initial value, we cannot later compare the proposed value "v"
83 metadata[owner, key] = {'v':'', 'time':''}
84
85 # Ensure caller's proposed value is not compared to itself
86 if owner != caller and metadata[owner, key]['v'] == metadata[caller, key]['v'] :
87 metadata[key] = value
88 agreed = True
89
90 if agreed:
91 for owner in owners:
92 # Prevent proposed value been used again by some owner in the future
93 metadata[caller, key] = str(now)
94 return f'{key} = {value}'
95
96 return agreed
97
98
99 # LST001 with extra features
100
101 @export
102 def mint(amount: float, to: str):
103 assert ctx.caller in metadata['bridge'], f'Only bridge can mint!'
104 assert amount > 0, 'Cannot mint negative balances!'
105 balances[to] += amount
106
107 @export
108 def transfer(amount: float, to: str):
109 assert amount > 0, 'Cannot send negative balances!'
110
111 sender = ctx.caller
112 signer = ctx.signer
113
114 assert balances[sender] >= amount, 'Not enough YETI to send!'
115
116 if signer not in metadata['owners'] and sender in metadata['dex']:
117 tax_amount = amount * metadata['buy_tax']
118 amount_to_buyer = amount - tax_amount
119
120 balances[sender] -= amount
121 balances[to] += amount_to_buyer
122 # Transfers to YETI fund wallets
123 balances[metadata['marketing_wallet']] += tax_amount * metadata['marketing%']
124 balances[metadata['LP_wallet']] += tax_amount * metadata['LP%']
125 balances[metadata['rewards_contract']] += tax_amount * metadata['rewards%']
126 balances[metadata['rain_wallet']] += tax_amount * metadata['rain%']
127 balances[metadata['charity_wallet']] += tax_amount * metadata['charity%']
128 balances[metadata['buyback_wallet']] += tax_amount * metadata['buyback%']
129 balances[metadata['burn_wallet']] += tax_amount * metadata['burn%']
130
131 return
132
133 balances[sender] -= amount
134 balances[to] += amount
135
136 @export
137 def approve(amount: float, to: str):
138 assert amount > 0, 'Cannot send negative balances!'
139
140 sender = ctx.caller
141 balances[sender, to] += amount
142 return balances[sender, to]
143
144 @export
145 def transfer_from(amount: float, to: str, main_account: str):
146 assert amount > 0, 'Cannot send negative balances!'
147
148 spender = ctx.caller
149 signer = ctx.signer
150
151 tax_amount = amount * metadata['sell_tax']
152 amount_to_spend = tax_amount + amount
153
154 if signer not in metadata['owners']:
155 assert balances[main_account] > amount_to_spend, \
156 f'Not enough tokens to pay tax! Expected tax to pay is {tax_amount}'
157 assert balances[main_account, spender] >= amount_to_spend, \
158 f'Not enough YETI approved to send! You have {balances[main_account, spender]} \
159 and are trying to spend {amount}'
160 assert balances[main_account] >= amount, 'Not enough YETI to send!'
161
162 balances[main_account, spender] -= amount
163 balances[main_account] -= amount
164 balances[to] += amount
165
166 if signer not in metadata['owners'] and to in metadata['dex']:
167 pay_tax(tax_amount, spender, main_account)
168
169 def pay_tax(tax_amount, spender, main_account):
170 # check if there is a rocketswap market for this token
171 if rswp_reserves[TOKEN_CONTRACT] == None: # reserve initial value is None in testing environment
172 return
173 if rswp_reserves[TOKEN_CONTRACT] == [0,0]: # reserve initial value on mainnet
174 return
175
176 balances[main_account, spender] -= tax_amount
177 balances[main_account] -= tax_amount
178 # Transfers to YETI fund wallets
179 balances[metadata['marketing_wallet']] += tax_amount * metadata['marketing%']
180 balances[metadata['LP_wallet']] += tax_amount * metadata['LP%']
181 balances[metadata['rewards_contract']] += tax_amount * metadata['rewards%']
182 balances[metadata['rain_wallet']] += tax_amount * metadata['rain%']
183 balances[metadata['charity_wallet']] += tax_amount * metadata['charity%']
184 balances[metadata['buyback_wallet']] += tax_amount * metadata['buyback%']
185 balances[metadata['burn_wallet']] += tax_amount * metadata['burn%']
186
187 @export
188 def distribute_rewards(addresses: list, holder_min: float,
189 distribute_min: float, fee_cover_perc: float):
190 assert_owner()
191 rewards_contract = I.import_module(metadata['rewards_contract'])
192 rewards_contract.distribute_rewards(contract=metadata['reward_token'],
193 addresses=addresses, holder_min=holder_min,
194 distribute_min=distribute_min, fee_cover_perc=fee_cover_perc)
195
196 @export
197 def swap_token(amount: float):
198 caller = ctx.caller
199 assert amount > 0, 'Cannot send negative balances!'
200 assert caller not in metadata['blacklisted_wallets'], 'this wallet is blacklisted'
201 assert not caller.startswith('con_'), 'Caller is a contract!'
202 assert balances[WALLET_CHIEF] > amount, f'Token amount left is {balances[WALLET_CHIEF]} \
203 and you are trying to swap for {amount}'
204 assert now < metadata['swap_end'], 'Swap is over!'
205
206 contract = metadata['swap_token']
207 swap_token = I.import_module(contract)
208
209 swap_token.transfer_from(amount=amount, to=metadata['burn_wallet'], main_account=caller)
210 amount_of_yeti = amount * metadata['swap_rate']
211 balances[caller] += amount_of_yeti
212 balances[WALLET_CHIEF] -= amount_of_yeti
213
214 @export
215 def execute_proposal_after_a_month(key: str):
216 assert_owner()
217 caller = ctx.caller
218 assert metadata[caller, key], 'Proposal does not exist!'
219 assert now > metadata[caller, key]['time'] + datetime.timedelta(weeks=4) , \
220 'Proposal must be 1 month old!'
221 metadata[key] = metadata[caller, key]['v']
222 return True
223
224 def assert_owner():
225 assert ctx.caller in metadata['owners'], 'Only owner can call this method!'
226

Byte Code

e30000000000000000000000000600000040000000733001000065005a016502640064016402640364048d045a03650464056402640664078d035a0565046402640864098d025a06640a5a07640b5a08640c5a09640d5a0a640e5a0b640f5a0c64105a0d64115a0e64125a0f6413641484005a106511640283016512651364159c0264166417840483015a146511640283016515651264189c026419641a840483015a166511640283016515651264189c02641b641c840483015a176511640283016515651264189c02641d641e840483015a18651164028301651565126512641f9c0364206421840483015a196422642384005a1a651164028301651b65156515651564249c0464256426840483015a1c651164028301651564279c0164286429840483015a1d6511640283016512642a9c01642b642c840483015a1e642d642e84005a1f642f53002930da1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f31da087265736572766573da13636f6e5f796574695f636f6e74726163745f32da0d727377705f72657365727665732904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d65da08636f6e7472616374da046e616d65e900000000da0862616c616e6365732903da0d64656661756c745f76616c756572070000007208000000da086d65746164617461290272070000007208000000da11636f6e5f796574695f636f6e7472616374da4065633964656363383839613137643465613232616662643531386637363761313336663336333031613062316161396136363066336637316436316635623262da4031393130353133303636616662653539326436313430633030353564653363623036386665376331373538346136353461373034616337653630623264663034da4061363930653638643861303439656137633861643465313662313636653332316264356562633064626134646331306432656130316266366565643834636361da4065386463373038303238653034393339376235626166393537393932346464653538636535626562656535363535646130623533303636313137353732653733da4033343636653735373664316237306165663637356565343134396230643833636632316636396634636661646538303132343964356166616164376337616339da4034633636623762613638373232326434346466326333633938396165346363353031383561626663656538656135333536616663633533343463346135663934da4062323265306466333934393432383231313938393836376334653466656264383531616633633163303434613864383932653861303762373033346539346463da4034326131336336363437383161323461623461636139373861626236383564396330376566396165363461326166383635613034336533313836613636393037630000000000000000000000000800000043000000733c0100006401740074013c006402740074023c006403740074033c006404740464053c006406740464073c007401740274036703740464083c0064097404640a3c00740574066a07640b640c8d0117007404640d3c007408640e83017404640f3c006410740464113c007409740464123c00740a740464133c00740b740464143c00740c740464153c00740d740464163c006417740464183c006419740174027409740a740b740c740d67087404641a3c007408641b83017404641c3c007408641d83017404641e3c007408641f8301740464203c00740864218301740464223c007408641d8301740464233c00740864248301740464253c00740864268301740464273c00740864268301740464283c00740864268301740464293c00642a67017404642b3c00642c7404642d3c00642e642f6702740464303c006400530029314e6c03000000002cac4557006c0300000000720b5404006900ca9a3b7a0a5945544920544f4b454eda0a746f6b656e5f6e616d65da0459455449da0c746f6b656e5f73796d626f6cda066f776e657273da17636f6e5f6d61726d6974653130305f636f6e7472616374da0a737761705f746f6b656ee9b40000002901da0464617973da08737761705f656e64da0131da09737761705f72617465da10636f6e5f796574695f72657761726473da10726577617264735f636f6e7472616374da094c505f77616c6c6574da0b7261696e5f77616c6c6574da106d61726b6574696e675f77616c6c6574da0e636861726974795f77616c6c6574da0e6275796261636b5f77616c6c6574da10796574695f6275726e5f77616c6c6574da0b6275726e5f77616c6c6574da4031623661393862633731376435363833373932313863613837623262386636376235363165653165353030343964613161663866313034323730383136613662da13626c61636b6c69737465645f77616c6c6574737a04302e3032da076275795f7461787a04302e3035da0873656c6c5f7461787a03302e317a0872657761726473257a04302e33357a034c50257a057261696e257a03302e357a0a6d61726b6574696e67257a04302e30307a0863686172697479257a086275796261636b257a056275726e257201000000da03646578da0f636f6e5f6c7573645f6c7374303031da0c7265776172645f746f6b656eda16636f6e5f6c616d64656e5f6c696e6b5f6273635f7631da17636f6e5f6c616d64656e5f6c696e6b5f776574685f7631da06627269646765290eda0a5f5f62616c616e636573da0c57414c4c45545f4348494546da0b57414c4c45545f4e49454cda0a57414c4c45545f444556da0a5f5f6d65746164617461da036e6f77da086461746574696d65da0974696d6564656c7461da07646563696d616cda0e57414c4c45545f594554495f4c50da1057414c4c45545f594554495f5241494eda1557414c4c45545f594554495f4d41524b4554494e47da1357414c4c45545f594554495f43484152495459da1357414c4c45545f594554495f4255594241434ba90072420000007242000000da00da045f5f5f5f1a000000733e0000000001080108010801080108010e01080114010c010801080108010801080108010802020108010e010c010c010c010c010c010c010c010c010c010a01080172440000002902da036b6579da0576616c756563020000000000000006000000050000004300000073c20000007400830001007401640119007d0274026a037d037c01740464029c0274017c037c0066023c0064037d0478627c0244005d5a7d0574017c057c006602190064006b0872566404640464029c0274017c057c0066023c007c057c036b03723074017c057c00660219006405190074017c037c0066021900640519006b0272307c0174017c003c0064067d04713057007c0472be781c7c0244005d147d0574057404830174017c037c0066023c00719857007c009b0064077c019b009d0353007c04530029084e72190000002902da0176da0474696d654672430000007247000000547a03203d202906da0e5f5f6173736572745f6f776e65727238000000da03637478da0663616c6c65727239000000da037374722906724500000072460000007219000000724b000000da06616772656564da056f776e6572724200000072420000007243000000da0f6368616e67655f6d657461646174613e00000073220000000002060108010601120104010a0110011201180110010801080104010a0114010e01724f0000002902da06616d6f756e74da02746f630200000000000000020000000400000043000000733a00000074006a017402640119006b06731674036402830182017c0064036b047326740364048301820174047c01050019007c00370003003c006400530029054e72330000007a154f6e6c79206272696467652063616e206d696e742172090000007a1e43616e6e6f74206d696e74206e656761746976652062616c616e636573212905724a000000724b0000007238000000da0e417373657274696f6e4572726f727234000000290272500000007251000000724200000072420000007243000000da046d696e745300000073060000000002160110017253000000630200000000000000060000000600000043000000736a0100007c0064016b047310740064028301820174016a027d0274016a037d0374047c0219007c006b05733074006403830182017c037405640419006b076f467c027405640519006b06900172467c0074056406190014007d047c007c0418007d0574047c02050019007c00380003003c0074047c01050019007c05370003003c007404740564071900050019007c047405640819001400370003003c007404740564091900050019007c047405640a19001400370003003c0074047405640b1900050019007c047405640c19001400370003003c0074047405640d1900050019007c047405640e19001400370003003c0074047405640f1900050019007c047405641019001400370003003c007404740564111900050019007c047405641219001400370003003c007404740564131900050019007c047405641419001400370003003c006400530074047c02050019007c00380003003c0074047c01050019007c00370003003c006400530029154e72090000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a184e6f7420656e6f756768205945544920746f2073656e64217219000000722e000000722c00000072250000007a0a6d61726b6574696e672572230000007a034c502572220000007a08726577617264732572240000007a057261696e2572260000007a08636861726974792572270000007a086275796261636b2572290000007a056275726e2529067252000000724a000000724b000000da067369676e657272340000007238000000290672500000007251000000da0673656e6465727254000000da0a7461785f616d6f756e74da0f616d6f756e745f746f5f6275796572724200000072420000007243000000da087472616e736665725a0000007332000000000210010601060114011a010c0108011001100110010c011c0110010c0110010c0110010c0110010c0110010c0104011001725800000063020000000000000003000000040000004300000073360000007c0064016b047310740064028301820174016a027d0274037c027c016602050019007c00370003003c0074037c027c0166021900530029034e72090000007a1e43616e6e6f742073656e64206e656761746976652062616c616e6365732129047252000000724a000000724b00000072340000002903725000000072510000007255000000724200000072420000007243000000da07617070726f766577000000730800000000021001060114017259000000290372500000007251000000da0c6d61696e5f6163636f756e7463030000000000000007000000050000004300000073f20000007c0064016b047310740064028301820174016a027d0374016a037d047c0074046403190014007d057c057c0017007d067c047404640419006b07728274057c0219007c066b047356740064057c059b009d028301820174057c027c03660219007c066b0573827400640674057c027c03660219009b0064077c009b009d048301820174057c0219007c006b057396740064088301820174057c027c036602050019007c00380003003c0074057c02050019007c00380003003c0074057c01050019007c00370003003c007c047404640419006b0772ee7c017404640919006b0672ee74067c057c037c028303010064005300290a4e72090000007a1e43616e6e6f742073656e64206e656761746976652062616c616e63657321722d00000072190000007a354e6f7420656e6f75676820746f6b656e7320746f2070617920746178212045787065637465642074617820746f20706179206973207a2b4e6f7420656e6f756768205945544920617070726f76656420746f2073656e642120596f752068617665207a2520202020202020202020202020616e642061726520747279696e6720746f207370656e64207a184e6f7420656e6f756768205945544920746f2073656e6421722e00000029077252000000724a000000724b000000725400000072380000007234000000da095f5f7061795f746178290772500000007251000000725a000000da077370656e64657272540000007256000000da0f616d6f756e745f746f5f7370656e64724200000072420000007243000000da0d7472616e736665725f66726f6d7f000000732000000000021001060106010c0108010c01060114010a01220114011401100110011801725e000000630300000000000000030000000600000043000000731001000074007401190064006b027210640053007400740119006401640167026b0272246400530074027c027c016602050019007c00380003003c0074027c02050019007c00380003003c007402740364021900050019007c007403640319001400370003003c007402740364041900050019007c007403640519001400370003003c007402740364061900050019007c007403640719001400370003003c007402740364081900050019007c007403640919001400370003003c0074027403640a1900050019007c007403640b19001400370003003c0074027403640c1900050019007c007403640d19001400370003003c0074027403640e1900050019007c007403640f19001400370003003c006400530029104e720900000072250000007a0a6d61726b6574696e672572230000007a034c502572220000007a08726577617264732572240000007a057261696e2572260000007a08636861726974792572270000007a086275796261636b2572290000007a056275726e252904da0f5f5f727377705f7265736572766573da0e544f4b454e5f434f4e54524143547234000000723800000029037256000000725c000000725a000000724200000072420000007243000000725b00000093000000732200000000010c010401100104011401100110010c011c0110010c011c0110010c0110010c01725b0000002904da09616464726573736573da0a686f6c6465725f6d696eda0e646973747269627574655f6d696eda0e6665655f636f7665725f70657263630400000000000000050000000700000043000000733000000074008300010074016a0274036401190083017d047c046a047403640219007c007c017c027c0364038d0501006400530029044e7222000000723000000029057207000000726100000072620000007263000000726400000029057249000000da0149da0d696d706f72745f6d6f64756c657238000000da12646973747269627574655f726577617264732905726100000072620000007263000000726400000072220000007242000000724200000072430000007267000000a7000000730a000000000306010e010a01040172670000002901725000000063010000000000000005000000050000004300000073cc00000074006a017d017c0064016b04731674026402830182017c017403640319006b07732a74026404830182017c016a04640583010c00733e74026406830182017405740619007c006b047362740264077405740619009b0064087c009b009d048301820174077403640919006b0073767402640a830182017403640b19007d0274086a097c0283017d037c036a0a7c007403640c19007c01640d8d0301007c007403640e190014007d0474057c01050019007c04370003003c0074057406050019007c04380003003c0064005300290f4e72090000007a1e43616e6e6f742073656e64206e656761746976652062616c616e63657321722b0000007a1a746869732077616c6c657420697320626c61636b6c6973746564da04636f6e5f7a1543616c6c6572206973206120636f6e7472616374217a15546f6b656e20616d6f756e74206c656674206973207a28202020202020202020616e6420796f752061726520747279696e6720746f207377617020666f7220721e0000007a0d53776170206973206f76657221721b0000007229000000290372500000007251000000725a0000007220000000290b724a000000724b00000072520000007238000000da0a7374617274737769746872340000007235000000723900000072650000007266000000725e00000029057250000000724b0000007207000000721b000000da0e616d6f756e745f6f665f79657469724200000072420000007243000000721b000000b1000000731e0000000002060110010e010601140106011e01140108010a010c0108010c011001721b00000029017245000000630100000000000000020000000500000043000000736000000074008300010074016a027d0174037c017c006602190073207404640183018201740574037c017c00660219006402190074066a07640364048d0117006b047348740464058301820174037c017c00660219006406190074037c003c006407530029084e7a1850726f706f73616c20646f6573206e6f74206578697374217248000000e9040000002901da057765656b737a1d50726f706f73616c206d7573742062652031206d6f6e7468206f6c642172470000005429087249000000724a000000724b000000723800000072520000007239000000723a000000723b00000029027245000000724b000000724200000072420000007243000000da1e657865637574655f70726f706f73616c5f61667465725f615f6d6f6e7468c4000000730e0000000002060106011401220106011401726d000000630000000000000000000000000300000043000000731a00000074006a017402640119006b06731674036402830182016400530029034e72190000007a204f6e6c79206f776e65722063616e2063616c6c2074686973206d6574686f64212904724a000000724b0000007238000000725200000072420000007242000000724200000072430000007249000000cf00000073040000000001100172490000004e2920da09696d706f72746c69627265000000da0b466f726569676e48617368725f000000da044861736872340000007238000000726000000072350000007236000000723d000000723e000000723f0000007240000000724100000072370000007244000000da085f5f6578706f7274724c000000da03416e79724f000000da05666c6f6174725300000072580000007259000000725e000000725b000000da046c6973747267000000721b000000726d00000072490000007242000000724200000072420000007243000000da083c6d6f64756c653e0100000073460000000401020104010a01060108010c01040204020402040204020402040204010403082406011214060112060601121c06011207060114130814060104011208060110120601100a