Contract con_yeti_contract_test_1


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

Byte Code

e30000000000000000000000000600000040000000733001000065005a016502640064016402640364048d045a03650464056402640664078d035a0565046402640864098d025a0664025a07640a5a08640b5a09640c5a0a640d5a0b640e5a0c640f5a0d64105a0e64115a0f6412641384005a106511640283016512651364149c0264156416840483015a146511640283016515651264179c0264186419840483015a166511640283016515651264179c02641a641b840483015a176511640283016515651264179c02641c641d840483015a18651164028301651565126512641e9c03641f6420840483015a196421642284005a1a651164028301651b65156515651564239c0464246425840483015a1c651164028301651564269c0164276428840483015a1d651164028301651264299c01642a642b840483015a1e642c642d84005a1f642e5300292fda1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f31da087265736572766573da18636f6e5f796574695f636f6e74726163745f746573745f31da0d727377705f72657365727665732904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d65da08636f6e7472616374da046e616d65e900000000da0862616c616e6365732903da0d64656661756c745f76616c756572070000007208000000da086d65746164617461290272070000007208000000da4065633964656363383839613137643465613232616662643531386637363761313336663336333031613062316161396136363066336637316436316635623262da4031393130353133303636616662653539326436313430633030353564653363623036386665376331373538346136353461373034616337653630623264663034da4061363930653638643861303439656137633861643465313662313636653332316264356562633064626134646331306432656130316266366565643834636361da4065386463373038303238653034393339376235626166393537393932346464653538636535626562656535363535646130623533303636313137353732653733da4033343636653735373664316237306165663637356565343134396230643833636632316636396634636661646538303132343964356166616164376337616339da4034633636623762613638373232326434346466326333633938396165346363353031383561626663656538656135333536616663633533343463346135663934da4062323265306466333934393432383231313938393836376334653466656264383531616633633163303434613864383932653861303762373033346539346463da4034326131336336363437383161323461623461636139373861626236383564396330376566396165363461326166383635613034336533313836613636393037630000000000000000000000000700000043000000733a0100006401740074013c006402740074023c006403740074033c006404740464053c006406740464073c007401740274036703740464083c0064097404640a3c00740574066a07640b640c8d0117007404640d3c007408640e83017404640f3c006410740464113c007409740464123c00740a740464133c00740b740464143c00740c740464153c00740d740464163c006417740464183c00641974017409740a740b740c740d67077404641a3c007408641b83017404641c3c007408641d83017404641e3c007408641f8301740464203c00740864218301740464223c007408641d8301740464233c00740864248301740464253c00740864268301740464273c00740864268301740464283c00740864268301740464293c00642a67017404642b3c00642c7404642d3c00642e642f6702740464303c006400530029314e6c03000000002cac4557006c0300000000720b5404006900ca9a3b7a0a5945544920544f4b454eda0a746f6b656e5f6e616d65da0459455449da0c746f6b656e5f73796d626f6cda066f776e657273da17636f6e5f6d61726d6974653130305f636f6e7472616374da0a737761705f746f6b656ee9b40000002901da0464617973da08737761705f656e64da0131da09737761705f72617465da10636f6e5f796574695f72657761726473da10726577617264735f636f6e7472616374da094c505f77616c6c6574da0b7261696e5f77616c6c6574da106d61726b6574696e675f77616c6c6574da0e636861726974795f77616c6c6574da0e6275796261636b5f77616c6c6574da10796574695f6275726e5f77616c6c6574da0b6275726e5f77616c6c6574da4031623661393862633731376435363833373932313863613837623262386636376235363165653165353030343964613161663866313034323730383136613662da13626c61636b6c69737465645f77616c6c6574737a04302e3032da076275795f7461787a04302e3035da0873656c6c5f7461787a03302e317a0872657761726473257a04302e33357a034c50257a057261696e257a03302e357a0a6d61726b6574696e67257a04302e30307a0863686172697479257a086275796261636b257a056275726e257201000000da03646578da0f636f6e5f6c7573645f6c7374303031da0c7265776172645f746f6b656eda16636f6e5f6c616d64656e5f6c696e6b5f6273635f7631da17636f6e5f6c616d64656e5f6c696e6b5f776574685f7631da06627269646765290eda0a5f5f62616c616e636573da07575f4348494546da06575f4e49454cda05575f444556da0a5f5f6d65746164617461da036e6f77da086461746574696d65da0974696d6564656c7461da07646563696d616cda04575f4c50da06575f5241494eda09575f4d41524b45544eda09575f43484152495459da09575f4255594241434ba90072410000007241000000da00da045f5f5f5f13000000733c0000000001080108010801080108010e01080114010c010801080108010801080108010802020114010c010c010c010c010c010c010c010c010c010a01080172430000002902da036b6579da0576616c756563020000000000000006000000050000004300000073c20000007400830001007401640119007d0274026a037d037c01740464029c0274017c037c0066023c0064037d0478627c0244005d5a7d0574017c057c006602190064006b0872566404640464029c0274017c057c0066023c007c057c036b03723074017c057c00660219006405190074017c037c0066021900640519006b0272307c0174017c003c0064067d04713057007c0472be781c7c0244005d147d0574057404830174017c037c0066023c00719857007c009b0064077c019b009d0353007c04530029084e72180000002902da0176da0474696d654672420000007246000000547a03203d202906da0e5f5f6173736572745f6f776e65727237000000da03637478da0663616c6c65727238000000da037374722906724400000072450000007218000000724a000000da06616772656564da056f776e6572724100000072410000007242000000da0f6368616e67655f6d657461646174613600000073220000000002060108010601120104010a0110011201180110010801080104010a0114010e01724e0000002902da06616d6f756e74da02746f630200000000000000020000000400000043000000733a00000074006a017402640119006b06731674036402830182017c0064036b047326740364048301820174047c01050019007c00370003003c006400530029054e72320000007a154f6e6c79206272696467652063616e206d696e742172090000007a1e43616e6e6f74206d696e74206e656761746976652062616c616e6365732129057249000000724a0000007237000000da0e417373657274696f6e4572726f7272330000002902724f0000007250000000724100000072410000007242000000da046d696e744b00000073060000000002160110017252000000630200000000000000060000000600000043000000736a0100007c0064016b047310740064028301820174016a027d0274016a037d0374047c0219007c006b05733074006403830182017c037405640419006b076f467c027405640519006b06900172467c0074056406190014007d047c007c0418007d0574047c02050019007c00380003003c0074047c01050019007c05370003003c007404740564071900050019007c047405640819001400370003003c007404740564091900050019007c047405640a19001400370003003c0074047405640b1900050019007c047405640c19001400370003003c0074047405640d1900050019007c047405640e19001400370003003c0074047405640f1900050019007c047405641019001400370003003c007404740564111900050019007c047405641219001400370003003c007404740564131900050019007c047405641419001400370003003c006400530074047c02050019007c00380003003c0074047c01050019007c00370003003c006400530029154e72090000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a184e6f7420656e6f756768205945544920746f2073656e64217218000000722d000000722b00000072240000007a0a6d61726b6574696e672572220000007a034c502572210000007a08726577617264732572230000007a057261696e2572250000007a08636861726974792572260000007a086275796261636b2572280000007a056275726e25290672510000007249000000724a000000da067369676e6572723300000072370000002906724f0000007250000000da0673656e6465727253000000da0a7461785f616d6f756e74da0f616d6f756e745f746f5f6275796572724100000072410000007242000000da087472616e73666572520000007332000000000210010601060114011a010c0108011001100110010c011c0110010c0110010c0110010c0110010c0110010c0104011001725700000063020000000000000003000000040000004300000073360000007c0064016b047310740064028301820174016a027d0274037c027c016602050019007c00370003003c0074037c027c0166021900530029034e72090000007a1e43616e6e6f742073656e64206e656761746976652062616c616e63657321290472510000007249000000724a00000072330000002903724f00000072500000007254000000724100000072410000007242000000da07617070726f76656f0000007308000000000210010601140172580000002903724f0000007250000000da0c6d61696e5f6163636f756e7463030000000000000007000000050000004300000073f20000007c0064016b047310740064028301820174016a027d0374016a037d047c0074046403190014007d057c057c0017007d067c047404640419006b07728274057c0219007c066b047356740064057c059b009d028301820174057c027c03660219007c066b0573827400640674057c027c03660219009b0064077c009b009d048301820174057c0219007c006b057396740064088301820174057c027c036602050019007c00380003003c0074057c02050019007c00380003003c0074057c01050019007c00370003003c007c047404640419006b0772ee7c017404640919006b0672ee74067c057c037c028303010064005300290a4e72090000007a1e43616e6e6f742073656e64206e656761746976652062616c616e63657321722c00000072180000007a354e6f7420656e6f75676820746f6b656e7320746f2070617920746178212045787065637465642074617820746f20706179206973207a2b4e6f7420656e6f756768205945544920617070726f76656420746f2073656e642120596f752068617665207a2520202020202020202020202020616e642061726520747279696e6720746f207370656e64207a184e6f7420656e6f756768205945544920746f2073656e6421722d000000290772510000007249000000724a000000725300000072370000007233000000da095f5f7061795f7461782907724f00000072500000007259000000da077370656e64657272530000007255000000da0f616d6f756e745f746f5f7370656e64724100000072410000007242000000da0d7472616e736665725f66726f6d77000000732000000000021001060106010c0108010c01060114010a01220114011401100110011801725d000000630300000000000000030000000600000043000000731001000074007401190064006b027210640053007400740119006401640167026b0272246400530074027c027c016602050019007c00380003003c0074027c02050019007c00380003003c007402740364021900050019007c007403640319001400370003003c007402740364041900050019007c007403640519001400370003003c007402740364061900050019007c007403640719001400370003003c007402740364081900050019007c007403640919001400370003003c0074027403640a1900050019007c007403640b19001400370003003c0074027403640c1900050019007c007403640d19001400370003003c0074027403640e1900050019007c007403640f19001400370003003c006400530029104e720900000072240000007a0a6d61726b6574696e672572220000007a034c502572210000007a08726577617264732572230000007a057261696e2572250000007a08636861726974792572260000007a086275796261636b2572280000007a056275726e252904da0f5f5f727377705f7265736572766573da0e544f4b454e5f434f4e54524143547233000000723700000029037255000000725b0000007259000000724100000072410000007242000000725a0000008b000000732200000000010c010401100104011401100110010c011c0110010c011c0110010c0110010c01725a0000002904da09616464726573736573da0a686f6c6465725f6d696eda0e646973747269627574655f6d696eda0e6665655f636f7665725f70657263630400000000000000050000000700000043000000733000000074008300010074016a0274036401190083017d047c046a047403640219007c007c017c027c0364038d0501006400530029044e7221000000722f00000029057207000000726000000072610000007262000000726300000029057248000000da0149da0d696d706f72745f6d6f64756c657237000000da12646973747269627574655f7265776172647329057260000000726100000072620000007263000000722100000072410000007241000000724200000072660000009f000000730a000000000306010e010a01040172660000002901724f00000063010000000000000005000000050000004300000073cc00000074006a017d017c0064016b04731674026402830182017c017403640319006b07732a74026404830182017c016a04640583010c00733e74026406830182017405740619007c006b047362740264077405740619009b0064087c009b009d048301820174077403640919006b0073767402640a830182017403640b19007d0274086a097c0283017d037c036a0a7c007403640c19007c01640d8d0301007c007403640e190014007d0474057c01050019007c04370003003c0074057406050019007c04380003003c0064005300290f4e72090000007a1e43616e6e6f742073656e64206e656761746976652062616c616e63657321722a0000007a1a746869732077616c6c657420697320626c61636b6c6973746564da04636f6e5f7a1543616c6c6572206973206120636f6e7472616374217a15546f6b656e20616d6f756e74206c656674206973207a28202020202020202020616e6420796f752061726520747279696e6720746f207377617020666f7220721d0000007a0d53776170206973206f76657221721a00000072280000002903724f00000072500000007259000000721f000000290b7249000000724a00000072510000007237000000da0a7374617274737769746872330000007234000000723800000072640000007265000000725d0000002905724f000000724a0000007207000000721a000000da0e616d6f756e745f6f665f79657469724100000072410000007242000000721a000000a9000000731e0000000002060110010e010601140106011e01140108010a010c0108010c011001721a00000029017244000000630100000000000000020000000500000043000000736000000074008300010074016a027d0174037c017c006602190073207404640183018201740574037c017c00660219006402190074066a07640364048d0117006b047348740464058301820174037c017c00660219006406190074037c003c006407530029084e7a1850726f706f73616c20646f6573206e6f74206578697374217247000000e9040000002901da057765656b737a1d50726f706f73616c206d7573742062652031206d6f6e7468206f6c6421724600000054290872480000007249000000724a0000007237000000725100000072380000007239000000723a00000029027244000000724a000000724100000072410000007242000000da1e657865637574655f70726f706f73616c5f61667465725f615f6d6f6e7468bc000000730e0000000002060106011401220106011401726c000000630000000000000000000000000300000043000000731a00000074006a017402640119006b06731674036402830182016400530029034e72180000007a204f6e6c79206f776e65722063616e2063616c6c2074686973206d6574686f642129047249000000724a0000007237000000725100000072410000007241000000724100000072420000007248000000c700000073040000000001100172480000004e2920da09696d706f72746c69627264000000da0b466f726569676e48617368725e000000da044861736872330000007237000000725f00000072340000007235000000723c000000723d000000723e000000723f000000724000000072360000007243000000da085f5f6578706f7274724b000000da03416e79724e000000da05666c6f6174725200000072570000007258000000725d000000725a000000da046c6973747266000000721a000000726c00000072480000007241000000724100000072410000007242000000da083c6d6f64756c653e0100000073460000000401020104010a01060108010c01040104010401040104010401040104010403082306011214060112060601121c06011207060114130814060104011208060110120601100a