Contract con_yeti_contract


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

Byte Code

e30000000000000000000000000600000040000000733001000065005a016502640064016402640364048d045a03650464056402640664078d035a0565046402640864098d025a0664025a07640a5a08640b5a09640c5a0a640d5a0b640e5a0c640f5a0d64105a0e64115a0f6412641384005a106511640283016512651364149c0264156416840483015a146511640283016515651264179c0264186419840483015a166511640283016515651264179c02641a641b840483015a176511640283016515651264179c02641c641d840483015a18651164028301651565126512641e9c03641f6420840483015a196421642284005a1a651164028301651b65156515651564239c0464246425840483015a1c651164028301651564269c0164276428840483015a1d651164028301651264299c01642a642b840483015a1e642c642d84005a1f642e5300292fda1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f315a087265736572766573da11636f6e5f796574695f636f6e7472616374da0d727377705f72657365727665732904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d65da08636f6e7472616374da046e616d65e900000000da0862616c616e6365732903da0d64656661756c745f76616c756572060000007207000000da086d65746164617461290272060000007207000000da4065633964656363383839613137643465613232616662643531386637363761313336663336333031613062316161396136363066336637316436316635623262da4031393130353133303636616662653539326436313430633030353564653363623036386665376331373538346136353461373034616337653630623264663034da4061363930653638643861303439656137633861643465313662313636653332316264356562633064626134646331306432656130316266366565643834636361da4065386463373038303238653034393339376235626166393537393932346464653538636535626562656535363535646130623533303636313137353732653733da4033343636653735373664316237306165663637356565343134396230643833636632316636396634636661646538303132343964356166616164376337616339da4034633636623762613638373232326434346466326333633938396165346363353031383561626663656538656135333536616663633533343463346135663934da4062323265306466333934393432383231313938393836376334653466656264383531616633633163303434613864383932653861303762373033346539346463da4034326131336336363437383161323461623461636139373861626236383564396330376566396165363461326166383635613034336533313836613636393037630000000000000000000000000800000043000000733c0100006401740074013c006402740074023c006403740074033c006404740464053c006406740464073c007401740274036703740464083c0064097404640a3c00740574066a07640b640c8d0117007404640d3c007408640e83017404640f3c006410740464113c007409740464123c00740a740464133c00740b740464143c00740c740464153c00740d740464163c006417740464183c006419740174027409740a740b740c740d67087404641a3c007408641b83017404641c3c007408641d83017404641e3c007408641f8301740464203c00740864218301740464223c007408641d8301740464233c00740864248301740464253c00740864268301740464273c00740864268301740464283c00740864268301740464293c00642a67017404642b3c00642c7404642d3c00642e642f6702740464303c006400530029314e6c03000000002cac4557006c0300000000720b5404006900ca9a3b7a0a5945544920544f4b454eda0a746f6b656e5f6e616d65da0459455449da0c746f6b656e5f73796d626f6cda066f776e657273da17636f6e5f6d61726d6974653130305f636f6e7472616374da0a737761705f746f6b656ee9b40000002901da0464617973da08737761705f656e64da0131da09737761705f72617465da10636f6e5f796574695f72657761726473da10726577617264735f636f6e7472616374da094c505f77616c6c6574da0b7261696e5f77616c6c6574da106d61726b6574696e675f77616c6c6574da0e636861726974795f77616c6c6574da0e6275796261636b5f77616c6c6574da10796574695f6275726e5f77616c6c6574da0b6275726e5f77616c6c6574da4031623661393862633731376435363833373932313863613837623262386636376235363165653165353030343964613161663866313034323730383136613662da13626c61636b6c69737465645f77616c6c6574737a04302e3032da076275795f7461787a04302e3035da0873656c6c5f7461787a03302e317a0872657761726473257a04302e33357a034c50257a057261696e257a03302e357a0a6d61726b6574696e67257a04302e30307a0863686172697479257a086275796261636b257a056275726e257201000000da03646578da0f636f6e5f6c7573645f6c7374303031da0c7265776172645f746f6b656eda16636f6e5f6c616d64656e5f6c696e6b5f6273635f7631da17636f6e5f6c616d64656e5f6c696e6b5f776574685f7631da06627269646765290eda0a5f5f62616c616e636573da0c57414c4c45545f4348494546da0b57414c4c45545f4e49454cda0a57414c4c45545f444556da0a5f5f6d65746164617461da036e6f77da086461746574696d65da0974696d6564656c7461da07646563696d616cda0e57414c4c45545f594554495f4c50da1057414c4c45545f594554495f5241494eda1557414c4c45545f594554495f4d41524b4554494e47da1357414c4c45545f594554495f43484152495459da1357414c4c45545f594554495f4255594241434ba90072400000007240000000da00da045f5f5f5f1a000000733e0000000001080108010801080108010e01080114010c010801080108010801080108010802020108010e010c010c010c010c010c010c010c010c010c010a01080172420000002902da036b6579da0576616c756563020000000000000006000000050000004300000073c20000007400830001007401640119007d0274026a037d037c01740464029c0274017c037c0066023c0064037d0478627c0244005d5a7d0574017c057c006602190064006b0872566404640464029c0274017c057c0066023c007c057c036b03723074017c057c00660219006405190074017c037c0066021900640519006b0272307c0174017c003c0064067d04713057007c0472be781c7c0244005d147d0574057404830174017c037c0066023c00719857007c009b0064077c019b009d0353007c04530029084e72170000002902da0176da0474696d654672410000007245000000547a03203d202906da0e5f5f6173736572745f6f776e65727236000000da03637478da0663616c6c65727237000000da0373747229067243000000724400000072170000007249000000da06616772656564da056f776e6572724000000072400000007241000000da0f6368616e67655f6d657461646174613e00000073220000000002060108010601120104010a0110011201180110010801080104010a0114010e01724d0000002902da06616d6f756e74da02746f630200000000000000020000000400000043000000733a00000074006a017402640119006b06731674036402830182017c0064036b047326740364048301820174047c01050019007c00370003003c006400530029054e72310000007a154f6e6c79206272696467652063616e206d696e742172080000007a1e43616e6e6f74206d696e74206e656761746976652062616c616e636573212905724800000072490000007236000000da0e417373657274696f6e4572726f7272320000002902724e000000724f000000724000000072400000007241000000da046d696e745300000073060000000002160110017251000000630200000000000000060000000600000043000000736a0100007c0064016b047310740064028301820174016a027d0274016a037d0374047c0219007c006b05733074006403830182017c037405640419006b076f467c027405640519006b06900172467c0074056406190014007d047c007c0418007d0574047c02050019007c00380003003c0074047c01050019007c05370003003c007404740564071900050019007c047405640819001400370003003c007404740564091900050019007c047405640a19001400370003003c0074047405640b1900050019007c047405640c19001400370003003c0074047405640d1900050019007c047405640e19001400370003003c0074047405640f1900050019007c047405641019001400370003003c007404740564111900050019007c047405641219001400370003003c007404740564131900050019007c047405641419001400370003003c006400530074047c02050019007c00380003003c0074047c01050019007c00370003003c006400530029154e72080000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a184e6f7420656e6f756768205945544920746f2073656e64217217000000722c000000722a00000072230000007a0a6d61726b6574696e672572210000007a034c502572200000007a08726577617264732572220000007a057261696e2572240000007a08636861726974792572250000007a086275796261636b2572270000007a056275726e252906725000000072480000007249000000da067369676e6572723200000072360000002906724e000000724f000000da0673656e6465727252000000da0a7461785f616d6f756e74da0f616d6f756e745f746f5f6275796572724000000072400000007241000000da087472616e736665725a0000007332000000000210010601060114011a010c0108011001100110010c011c0110010c0110010c0110010c0110010c0110010c0104011001725600000063020000000000000003000000040000004300000073360000007c0064016b047310740064028301820174016a027d0274037c027c016602050019007c00370003003c0074037c027c0166021900530029034e72080000007a1e43616e6e6f742073656e64206e656761746976652062616c616e63657321290472500000007248000000724900000072320000002903724e000000724f0000007253000000724000000072400000007241000000da07617070726f7665770000007308000000000210010601140172570000002903724e000000724f000000da0c6d61696e5f6163636f756e7463030000000000000007000000050000004300000073f20000007c0064016b047310740064028301820174016a027d0374016a037d047c0074046403190014007d057c057c0017007d067c047404640419006b07728274057c0219007c066b047356740064057c059b009d028301820174057c027c03660219007c066b0573827400640674057c027c03660219009b0064077c009b009d048301820174057c0219007c006b057396740064088301820174057c027c036602050019007c00380003003c0074057c02050019007c00380003003c0074057c01050019007c00370003003c007c047404640419006b0772ee7c017404640919006b0672ee74067c057c037c028303010064005300290a4e72080000007a1e43616e6e6f742073656e64206e656761746976652062616c616e63657321722b00000072170000007a354e6f7420656e6f75676820746f6b656e7320746f2070617920746178212045787065637465642074617820746f20706179206973207a2b4e6f7420656e6f756768205945544920617070726f76656420746f2073656e642120596f752068617665207a2520202020202020202020202020616e642061726520747279696e6720746f207370656e64207a184e6f7420656e6f756768205945544920746f2073656e6421722c0000002907725000000072480000007249000000725200000072360000007232000000da095f5f7061795f7461782907724e000000724f0000007258000000da077370656e64657272520000007254000000da0f616d6f756e745f746f5f7370656e64724000000072400000007241000000da0d7472616e736665725f66726f6d7f000000732000000000021001060106010c0108010c01060114010a01220114011401100110011801725c000000630300000000000000030000000600000043000000731001000074007401190064006b027210640053007400740119006401640167026b0272246400530074027c027c016602050019007c00380003003c0074027c02050019007c00380003003c007402740364021900050019007c007403640319001400370003003c007402740364041900050019007c007403640519001400370003003c007402740364061900050019007c007403640719001400370003003c007402740364081900050019007c007403640919001400370003003c0074027403640a1900050019007c007403640b19001400370003003c0074027403640c1900050019007c007403640d19001400370003003c0074027403640e1900050019007c007403640f19001400370003003c006400530029104e720800000072230000007a0a6d61726b6574696e672572210000007a034c502572200000007a08726577617264732572220000007a057261696e2572240000007a08636861726974792572250000007a086275796261636b2572270000007a056275726e252904da0f5f5f727377705f7265736572766573da0e544f4b454e5f434f4e54524143547232000000723600000029037254000000725a0000007258000000724000000072400000007241000000725900000093000000732200000000010c010401100104011401100110010c011c0110010c011c0110010c0110010c0172590000002904da09616464726573736573da0a686f6c6465725f6d696eda0e646973747269627574655f6d696eda0e6665655f636f7665725f70657263630400000000000000050000000700000043000000733000000074008300010074016a0274036401190083017d047c046a047403640219007c007c017c027c0364038d0501006400530029044e7220000000722e00000029057206000000725f00000072600000007261000000726200000029057247000000da0149da0d696d706f72745f6d6f64756c657236000000da12646973747269627574655f726577617264732905725f00000072600000007261000000726200000072200000007240000000724000000072410000007265000000a7000000730a000000000306010e010a01040172650000002901724e00000063010000000000000005000000050000004300000073cc00000074006a017d017c0064016b04731674026402830182017c017403640319006b07732a74026404830182017c016a04640583010c00733e74026406830182017405740619007c006b047362740264077405740619009b0064087c009b009d048301820174077403640919006b0073767402640a830182017403640b19007d0274086a097c0283017d037c036a0a7c007403640c19007c01640d8d0301007c007403640e190014007d0474057c01050019007c04370003003c0074057406050019007c04380003003c0064005300290f4e72080000007a1e43616e6e6f742073656e64206e656761746976652062616c616e6365732172290000007a1a746869732077616c6c657420697320626c61636b6c6973746564da04636f6e5f7a1543616c6c6572206973206120636f6e7472616374217a15546f6b656e20616d6f756e74206c656674206973207a28202020202020202020616e6420796f752061726520747279696e6720746f207377617020666f7220721c0000007a0d53776170206973206f76657221721900000072270000002903724e000000724f0000007258000000721e000000290b7248000000724900000072500000007236000000da0a7374617274737769746872320000007233000000723700000072630000007264000000725c0000002905724e000000724900000072060000007219000000da0e616d6f756e745f6f665f796574697240000000724000000072410000007219000000b1000000731e0000000002060110010e010601140106011e01140108010a010c0108010c011001721900000029017243000000630100000000000000020000000500000043000000736000000074008300010074016a027d0174037c017c006602190073207404640183018201740574037c017c00660219006402190074066a07640364048d0117006b047348740464058301820174037c017c00660219006406190074037c003c006407530029084e7a1850726f706f73616c20646f6573206e6f74206578697374217246000000e9040000002901da057765656b737a1d50726f706f73616c206d7573742062652031206d6f6e7468206f6c6421724500000054290872470000007248000000724900000072360000007250000000723700000072380000007239000000290272430000007249000000724000000072400000007241000000da1e657865637574655f70726f706f73616c5f61667465725f615f6d6f6e7468c4000000730e0000000002060106011401220106011401726b000000630000000000000000000000000300000043000000731a00000074006a017402640119006b06731674036402830182016400530029034e72170000007a204f6e6c79206f776e65722063616e2063616c6c2074686973206d6574686f64212904724800000072490000007236000000725000000072400000007240000000724000000072410000007247000000cf00000073040000000001100172470000004e2920da09696d706f72746c69627263000000da0b466f726569676e48617368725d000000da044861736872320000007236000000725e00000072330000007234000000723b000000723c000000723d000000723e000000723f00000072350000007242000000da085f5f6578706f7274724a000000da03416e79724d000000da05666c6f6174725100000072560000007257000000725c0000007259000000da046c69737472650000007219000000726b00000072470000007240000000724000000072400000007241000000da083c6d6f64756c653e0100000073460000000401020104010a01060108010c01040204020402040204020402040204010403082406011214060112060601121c06011207060114130814060104011208060110120601100a