Contract con_nebula


Contract Code

1 balances = Hash(default_value=0)
2 metadata = Hash()
3
4 tax_percent = Variable()
5 swap_allowed = Variable()
6 vault_contract = Variable()
7 tax_blacklist = Variable()
8 total_supply = Variable()
9 swap_end_date = Variable()
10
11 SWAP_FACTOR = 0.01
12 BURN_ADDRESS = 'NEBULA_BURN_ADDRESS'
13 INTERNAL_VAULT = 'INTERNAL_NEB_VAULT'
14 GOLD_CONTRACT = 'con_gold_contract'
15 OPERATORS = [
16 'ae7d14d6d9b8443f881ba6244727b69b681010e782d4fe482dbfb0b6aca02d5d',
17 'e787ed5907742fa8d50b3ca2701ab8e03ec749ced806a15cdab800a127d7f863'
18 ]
19
20 @construct
21 def seed():
22 balances[ctx.caller] = 0
23
24 metadata['token_name'] = "Nebula"
25 metadata['token_symbol'] = "NEB"
26 metadata['operator'] = ctx.caller
27
28 tax_percent.set(2)
29 swap_allowed.set(False)
30 tax_blacklist.set(['con_rocketswap_official_v1_1'])
31 swap_end_date.set(now + datetime.timedelta(days=120))
32 vault_contract.set('')
33 total_supply.set(0)
34
35 @export
36 def change_metadata(key: str, value: Any):
37 assert_owner()
38
39 metadata[key] = value
40
41 @export
42 def transfer(amount: float, to: str):
43 assert amount > 0, 'Cannot send negative balances!'
44 assert balances[ctx.caller] >= amount, 'Not enough coins to send!'
45
46 balances[ctx.caller] -= amount
47 balances[to] += amount
48
49 if to in tax_blacklist.get():
50 pay_tax(amount)
51
52 @export
53 def approve(amount: float, to: str):
54 assert amount > 0, 'Cannot send negative balances!'
55 balances[ctx.caller, to] += amount
56
57 @export
58 def transfer_from(amount: float, to: str, main_account: str):
59 assert amount > 0, 'Cannot send negative balances!'
60 assert balances[main_account, ctx.caller] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'\
61 .format(balances[main_account, ctx.caller], amount)
62 assert balances[main_account] >= amount, 'Not enough coins to send!'
63
64 balances[main_account, ctx.caller] -= amount
65 balances[main_account] -= amount
66 balances[to] += amount
67
68 if to in tax_blacklist.get():
69 pay_tax(amount)
70
71 # ------ TAX ------
72
73 def pay_tax(amount: float):
74 tax_amount = int(amount / 100 * tax_percent.get())
75
76 if tax_amount > 0:
77 difference = int(balances[ctx.signer] - tax_amount)
78 assert balances[ctx.signer] >= tax_amount, 'Not enough coins to pay for NEB tax. Missing {} NEB'.format((difference * -1) + 1)
79
80 if not vault_contract.get():
81 vault = INTERNAL_VAULT
82 else:
83 vault = vault_contract.get()
84
85 balances[vault] += tax_amount
86 balances[ctx.signer] -= tax_amount
87
88 @export
89 def set_tax(tax_in_percent: float):
90 assert_owner()
91 assert (tax_in_percent >= 0 and tax_in_percent <= 100), 'Value must be between 0 and 100'
92
93 tax_percent.set(tax_in_percent)
94
95 @export
96 def add_to_tax_blacklist(recipient: str):
97 assert_owner()
98 assert recipient not in tax_blacklist.get(), 'Recipient already on tax blacklist'
99
100 lst = tax_blacklist.get()
101 lst.append(recipient)
102 tax_blacklist.set(lst)
103
104 @export
105 def remove_from_tax_blacklist(recipient: str):
106 assert_owner()
107 assert recipient in tax_blacklist.get(), 'Recipient not on tax blacklist'
108
109 lst = tax_blacklist.get()
110 lst.remove(recipient)
111 tax_blacklist.set(lst)
112
113 # ------ SWAP ------
114
115 @export
116 def swap_gold(amount: float):
117 assert now < swap_end_date.get(), 'Swap period ended'
118 assert swap_allowed.get() == True, 'Swapping GOLD for NEB currently disabled'
119 assert amount > 0, 'Cannot swap negative balances!'
120
121 gold = importlib.import_module(GOLD_CONTRACT)
122 gold.transfer_from(amount=amount, to=BURN_ADDRESS, main_account=ctx.caller)
123
124 swap_amount = amount * SWAP_FACTOR
125
126 balances[ctx.caller] += swap_amount
127
128 total_supply.set(total_supply.get() + swap_amount)
129
130 @export
131 def enable_swap():
132 assert_owner()
133 swap_allowed.set(True)
134
135 @export
136 def disable_swap():
137 assert_owner()
138 swap_allowed.set(False)
139
140 @export
141 def time_until_swap_end():
142 return swap_end_date.get() - now
143
144 # ------ BURNING ------
145
146 @export
147 def burn(amount: float):
148 assert amount > 0, 'Cannot burn negative amount!'
149 assert balances[ctx.caller] >= amount, 'Not enough coins to burn!'
150
151 balances[BURN_ADDRESS] += amount
152 balances[ctx.caller] -= amount
153
154 # ------ VAULT ------
155
156 @export
157 def set_vault(contract: str):
158 assert_owner()
159 vault_contract.set(contract)
160
161 @export
162 def flush_internal_vault():
163 assert_owner()
164 assert vault_contract.get(), 'Vault contract not set!'
165
166 balances[vault_contract.get()] += balances[INTERNAL_VAULT]
167 balances[INTERNAL_VAULT] = 0
168
169 # ------ SUPPLY ------
170
171 @export
172 def circulating_supply():
173 return int(total_supply.get() - balances[BURN_ADDRESS])
174
175 @export
176 def total_supply():
177 return int(total_supply.get())
178
179 # ------ INTERNAL ------
180
181 def assert_owner():
182 assert ctx.caller in OPERATORS, 'Only executable by operators!'
183

Byte Code

e3000000000000000000000000050000004000000073e6010000650064006401640264038d035a0165006401640464058d025a0265036401640664058d025a0465036401640764058d025a0565036401640864058d025a0665036401640964058d025a0765036401640a64058d025a0865036401640b64058d025a09650a640c83015a0b640d5a0c640e5a0d640f5a0e6410641167025a0f6412641384005a106511640183016512651364149c0264156416840483015a146511640183016515651264179c0264186419840483015a166511640183016515651264179c02641a641b840483015a17651164018301651565126512641c9c03641d641e840483015a186515641f9c016420642184045a19651164018301651564229c0164236424840483015a1a651164018301651264259c0164266427840483015a1b651164018301651264259c0164286429840483015a1c6511640183016515641f9c01642a642b840483015a1d651164018301642c642d840083015a1e651164018301642e642f840083015a1f65116401830164306431840083015a206511640183016515641f9c0164326433840483015a21651164018301651264349c0164356436840483015a2265116401830164376438840083015a236511640183016439643a840083015a24651164018301643b640a840083015a25643c643d84005a26643e5300293fe900000000da0a636f6e5f6e6562756c61da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000da0b7461785f70657263656e74da0c737761705f616c6c6f776564da0e7661756c745f636f6e7472616374da0d7461785f626c61636b6c697374da0c746f74616c5f737570706c79da0d737761705f656e645f646174657a04302e3031da134e4542554c415f4255524e5f41444452455353da12494e5445524e414c5f4e45425f5641554c54da11636f6e5f676f6c645f636f6e7472616374da4061653764313464366439623834343366383831626136323434373237623639623638313031306537383264346665343832646266623062366163613032643564da406537383765643539303737343266613864353062336361323730316162386530336563373439636564383036613135636461623830306131323764376638363363000000000000000000000000050000004300000073720000006401740074016a023c006402740364033c006404740364053c0074016a02740364063c0074046a0564078301010074066a0564088301010074076a05640967018301010074086a057409740a6a0b640a640b8d01170083010100740c6a05640c83010100740d6a0564018301010064005300290d4e7201000000da064e6562756c61da0a746f6b656e5f6e616d65da034e4542da0c746f6b656e5f73796d626f6cda086f70657261746f72e90200000046da1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f31e9780000002901da0464617973da00290eda0a5f5f62616c616e636573da03637478da0663616c6c6572da0a5f5f6d65746164617461da0d5f5f7461785f70657263656e74da03736574da0e5f5f737761705f616c6c6f776564da0f5f5f7461785f626c61636b6c697374da0f5f5f737761705f656e645f64617465da036e6f77da086461746574696d65da0974696d6564656c7461da105f5f7661756c745f636f6e7472616374da0e5f5f746f74616c5f737570706c79a900722b000000722b000000721c000000da045f5f5f5f11000000731400000000010a01080108010a010a010a010c0116010a01722c0000002902da036b6579da0576616c756563020000000000000002000000030000004300000073120000007400830001007c0174017c003c006400530029014e2902da0e5f5f6173736572745f6f776e657272200000002902722d000000722e000000722b000000722b000000721c000000da0f6368616e67655f6d657461646174611e00000073040000000002060172300000002902da06616d6f756e74da02746f63020000000000000002000000040000004300000073600000007c0064016b0473107400640283018201740174026a0319007c006b0573267400640383018201740174026a03050019007c00380003003c0074017c01050019007c00370003003c007c0174046a0583006b06725c74067c00830101006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212907da0e417373657274696f6e4572726f72721d000000721e000000721f0000007224000000da03676574da095f5f7061795f746178290272310000007232000000722b000000722b000000721c000000da087472616e7366657224000000730c000000000210011601120110010c017236000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e6365732129047233000000721d000000721e000000721f000000290272310000007232000000722b000000722b000000721c000000da07617070726f76652e0000007304000000000210017237000000290372310000007232000000da0c6d61696e5f6163636f756e74630300000000000000030000000500000043000000739e0000007c0064016b047310740064028301820174017c0274026a03660219007c006b05733c740064036a0474017c0274026a03660219007c0083028301820174017c0219007c006b057350740064048301820174017c0274026a036602050019007c00380003003c0074017c02050019007c00380003003c0074017c01050019007c00370003003c007c0174056a0683006b06729a74077c00830101006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e642129087233000000721d000000721e000000721f000000da06666f726d61747224000000723400000072350000002903723100000072320000007238000000722b000000722b000000721c000000da0d7472616e736665725f66726f6d340000007314000000000210010c010c01140114011601100110010c01723a00000029017231000000630100000000000000040000000400000043000000738e00000074007c0064011b0074016a028300140083017d017c0164026b04728a7400740374046a0519007c01180083017d02740374046a0519007c016b057352740664036a077c02640514006404170083018301820174086a028300736074097d036e0874086a0283007d0374037c03050019007c01370003003c00740374046a05050019007c01380003003c006400530029064ee96400000072010000007a334e6f7420656e6f75676820636f696e7320746f2070617920666f72204e4542207461782e204d697373696e67207b7d204e4542e901000000e9ffffffff290ada03696e7472210000007234000000721d000000721e000000da067369676e6572723300000072390000007229000000da0e494e5445524e414c5f5641554c5429047231000000da0a7461785f616d6f756e74da0a646966666572656e6365da057661756c74722b000000722b000000721c0000007235000000420000007316000000000114010801120108010c011001080106020801100172350000002901da0e7461785f696e5f70657263656e74630100000000000000010000000200000043000000732c0000007400830001007c0064016b0572167c0064026b01731e740164038301820174026a037c00830101006400530029044e7201000000723b0000007a1f56616c7565206d757374206265206265747765656e203020616e64203130302904722f00000072330000007221000000722200000029017244000000722b000000722b000000721c000000da077365745f74617851000000730600000000020601180172450000002901da09726563697069656e74630100000000000000020000000200000043000000733a0000007400830001007c0074016a0283006b07731a740364018301820174016a0283007d017c016a047c008301010074016a057c01830101006400530029024e7a22526563697069656e7420616c7265616479206f6e2074617820626c61636b6c6973742906722f000000722400000072340000007233000000da06617070656e64722200000029027246000000da036c7374722b000000722b000000721c000000da146164645f746f5f7461785f626c61636b6c69737458000000730c000000000206010e01060108010a017249000000630100000000000000020000000200000043000000733a0000007400830001007c0074016a0283006b06731a740364018301820174016a0283007d017c016a047c008301010074016a057c01830101006400530029024e7a1e526563697069656e74206e6f74206f6e2074617820626c61636b6c6973742906722f000000722400000072340000007233000000da0672656d6f76657222000000290272460000007248000000722b000000722b000000721c000000da1972656d6f76655f66726f6d5f7461785f626c61636b6c69737462000000730a00000000020601140108010a01724b0000006301000000000000000300000005000000430000007384000000740074016a0283006b007314740364018301820174046a02830064026b02732874036403830182017c0064046b047338740364058301820174056a06740783017d017c016a087c007409740a6a0b64068d0301007c00740c14007d02740d740a6a0b050019007c02370003003c00740e6a0f740e6a0283007c021700830101006400530029074e7a115377617020706572696f6420656e646564547a285377617070696e6720474f4c4420666f72204e45422063757272656e746c792064697361626c656472010000007a1e43616e6e6f742073776170206e656761746976652062616c616e636573212903723100000072320000007238000000291072260000007225000000723400000072330000007223000000da09696d706f72746c6962da0d696d706f72745f6d6f64756c65da0d474f4c445f434f4e5452414354723a000000da0c4255524e5f41444452455353721e000000721f000000da0b535741505f464143544f52721d000000722a000000722200000029037231000000da04676f6c64da0b737761705f616d6f756e74722b000000722b000000721c000000da09737761705f676f6c646b00000073120000000002140106010e0110010a011201080112017253000000630000000000000000000000000200000043000000731400000074008300010074016a026401830101006400530029024e542903722f00000072230000007222000000722b000000722b000000722b000000721c000000da0b656e61626c655f73776170780000007304000000000206017254000000630000000000000000000000000200000043000000731400000074008300010074016a026401830101006400530029024e462903722f00000072230000007222000000722b000000722b000000722b000000721c000000da0c64697361626c655f737761707e0000007304000000000206017255000000630000000000000000000000000200000043000000730c00000074006a01830074021800530029014e2903722500000072340000007226000000722b000000722b000000722b000000721c000000da1374696d655f756e74696c5f737761705f656e6484000000730200000000027256000000630100000000000000010000000400000043000000734c0000007c0064016b0473107400640283018201740174026a0319007c006b057326740064038301820174017404050019007c00370003003c00740174026a03050019007c00380003003c006400530029044e72010000007a1c43616e6e6f74206275726e206e6567617469766520616d6f756e74217a194e6f7420656e6f75676820636f696e7320746f206275726e2129057233000000721d000000721e000000721f000000724f00000029017231000000722b000000722b000000721c000000da046275726e8900000073080000000002100116011001725700000029017205000000630100000000000000010000000200000043000000731400000074008300010074016a027c00830101006400530029014e2903722f0000007229000000722200000029017205000000722b000000722b000000721c000000da097365745f7661756c74910000007304000000000206017258000000630000000000000000000000000500000043000000733a00000074008300010074016a02830073167403640183018201740474016a02830005001900740474051900370003003c006402740474053c006400530029034e7a175661756c7420636f6e7472616374206e6f74207365742172010000002906722f000000722900000072340000007233000000721d0000007240000000722b000000722b000000722b000000721c000000da14666c7573685f696e7465726e616c5f7661756c74970000007308000000000206011001180172590000006300000000000000000000000004000000430000007314000000740074016a02830074037404190018008301530029014e2905723e000000722a0000007234000000721d000000724f000000722b000000722b000000722b000000721c000000da1263697263756c6174696e675f737570706c799f00000073020000000002725a000000630000000000000000000000000200000043000000730c000000740074016a0283008301530029014e2903723e000000722a0000007234000000722b000000722b000000722b000000721c000000720c000000a400000073020000000002630000000000000000000000000200000043000000731600000074006a0174026b06731274036401830182016400530029024e7a1d4f6e6c792065786563757461626c65206279206f70657261746f7273212904721e000000721f000000da094f50455241544f52537233000000722b000000722b000000722b000000721c000000722f000000a900000073020000000001722f0000004e2927da0448617368721d0000007220000000da085661726961626c657221000000722300000072290000007224000000722a0000007225000000da07646563696d616c7250000000724f0000007240000000724e000000725b000000722c000000da085f5f6578706f7274da03737472da03416e797230000000da05666c6f617472360000007237000000723a000000723500000072450000007249000000724b0000007253000000725400000072550000007256000000725700000072580000007259000000725a000000720c000000722f000000722b000000722b000000722b000000721c000000da083c6d6f64756c653e0100000073540000000e010c010c010c010c010c010c010c01080104010401040102010603080d0601120506011209060112050601140d0e0f0601100606011009060110080601100c1006100610050601100706011005100810051005