Contract con_nebula_test


Contract Code


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

Byte Code

e3000000000000000000000000050000004000000073e6010000650064006401640264038d035a0165006401640464058d025a0265036401640664058d025a0465036401640764058d025a0565036401640864058d025a0665036401640964058d025a0765036401640a64058d025a0865036401640b64058d025a09650a640c83015a0b640d5a0c640e5a0d640f5a0e6410641167025a0f6412641384005a106511640183016512651364149c0264156416840483015a146511640183016515651264179c0264186419840483015a166511640183016515651264179c02641a641b840483015a17651164018301651565126512641c9c03641d641e840483015a186515641f9c016420642184045a19651164018301651564229c0164236424840483015a1a651164018301651264259c0164266427840483015a1b651164018301651264259c0164286429840483015a1c6511640183016515641f9c01642a642b840483015a1d651164018301642c642d840083015a1e651164018301642e642f840083015a1f65116401830164306431840083015a206511640183016515641f9c0164326433840483015a21651164018301651264349c0164356436840483015a2265116401830164376438840083015a236511640183016439643a840083015a24651164018301643b640a840083015a25643c643d84005a26643e5300293fe900000000da0f636f6e5f6e6562756c615f74657374da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000da0b7461785f70657263656e74da0c737761705f616c6c6f776564da0e7661756c745f636f6e7472616374da0d7461785f626c61636b6c697374da0c746f74616c5f737570706c79da0d737761705f656e645f646174657a04302e3031da134e4542554c415f4255524e5f41444452455353da12494e5445524e414c5f4e45425f5641554c54da11636f6e5f676f6c645f636f6e7472616374da4061653764313464366439623834343366383831626136323434373237623639623638313031306537383264346665343832646266623062366163613032643564da406537383765643539303737343266613864353062336361323730316162386530336563373439636564383036613135636461623830306131323764376638363363000000000000000000000000050000004300000073720000006401740074016a023c006402740364033c006404740364053c0074016a02740364063c0074046a0564078301010074066a0564088301010074076a05640967018301010074086a057409740a6a0b640a640b8d01170083010100740c6a05640c83010100740d6a05640d8301010064005300290e4e69809698007a0b4e6562756c612054455354da0a746f6b656e5f6e616d65da044e454254da0c746f6b656e5f73796d626f6cda086f70657261746f72e90200000046da1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f31e9780000002901da0464617973da007201000000290eda0a5f5f62616c616e636573da03637478da0663616c6c6572da0a5f5f6d65746164617461da0d5f5f7461785f70657263656e74da03736574da0e5f5f737761705f616c6c6f776564da0f5f5f7461785f626c61636b6c697374da0f5f5f737761705f656e645f64617465da036e6f77da086461746574696d65da0974696d6564656c7461da105f5f7661756c745f636f6e7472616374da0e5f5f746f74616c5f737570706c79a900722a000000722a000000721b000000da045f5f5f5f11000000731400000000010a01080108010a010a010a010c0116010a01722b0000002902da036b6579da0576616c756563020000000000000002000000030000004300000073120000007400830001007c0174017c003c006400530029014e2902da0e5f5f6173736572745f6f776e6572721f0000002902722c000000722d000000722a000000722a000000721b000000da0f6368616e67655f6d657461646174611e000000730400000000020601722f0000002902da06616d6f756e74da02746f63020000000000000002000000040000004300000073600000007c0064016b0473107400640283018201740174026a0319007c006b0573267400640383018201740174026a03050019007c00380003003c0074017c01050019007c00370003003c007c0174046a0583006b06725c74067c00830101006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212907da0e417373657274696f6e4572726f72721c000000721d000000721e0000007223000000da03676574da095f5f7061795f746178290272300000007231000000722a000000722a000000721b000000da087472616e7366657224000000730c000000000210011601120110010c017235000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e6365732129047232000000721c000000721d000000721e000000290272300000007231000000722a000000722a000000721b000000da07617070726f76652e0000007304000000000210017236000000290372300000007231000000da0c6d61696e5f6163636f756e74630300000000000000030000000500000043000000739e0000007c0064016b047310740064028301820174017c0274026a03660219007c006b05733c740064036a0474017c0274026a03660219007c0083028301820174017c0219007c006b057350740064048301820174017c0274026a036602050019007c00380003003c0074017c02050019007c00380003003c0074017c01050019007c00370003003c007c0174056a0683006b06729a74077c00830101006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e642129087232000000721c000000721d000000721e000000da06666f726d61747223000000723300000072340000002903723000000072310000007237000000722a000000722a000000721b000000da0d7472616e736665725f66726f6d340000007314000000000210010c010c01140114011601100110010c01723900000029017230000000630100000000000000040000000400000043000000738e00000074007c0064011b0074016a028300140083017d017c0164026b04728a7400740374046a0519007c01180083017d02740374046a0519007c016b057352740664036a077c02640514006404170083018301820174086a028300736074097d036e0874086a0283007d0374037c03050019007c01370003003c00740374046a05050019007c01380003003c006400530029064ee96400000072010000007a334e6f7420656e6f75676820636f696e7320746f2070617920666f72204e4542207461782e204d697373696e67207b7d204e4542e901000000e9ffffffff290ada03696e7472200000007233000000721c000000721d000000da067369676e6572723200000072380000007228000000da0e494e5445524e414c5f5641554c5429047230000000da0a7461785f616d6f756e74da0a646966666572656e6365da057661756c74722a000000722a000000721b0000007234000000420000007316000000000114010801120108010c011001080106020801100172340000002901da0e7461785f696e5f70657263656e74630100000000000000010000000200000043000000732c0000007400830001007c0064016b0572167c0064026b01731e740164038301820174026a037c00830101006400530029044e7201000000723a0000007a1f56616c7565206d757374206265206265747765656e203020616e64203130302904722e00000072320000007220000000722100000029017243000000722a000000722a000000721b000000da077365745f74617851000000730600000000020601180172440000002901da09726563697069656e74630100000000000000020000000200000043000000733a0000007400830001007c0074016a0283006b07731a740364018301820174016a0283007d017c016a047c008301010074016a057c01830101006400530029024e7a22526563697069656e7420616c7265616479206f6e2074617820626c61636b6c6973742906722e000000722300000072330000007232000000da06617070656e64722100000029027245000000da036c7374722a000000722a000000721b000000da146164645f746f5f7461785f626c61636b6c69737458000000730c000000000206010e01060108010a017248000000630100000000000000020000000200000043000000733a0000007400830001007c0074016a0283006b06731a740364018301820174016a0283007d017c016a047c008301010074016a057c01830101006400530029024e7a1e526563697069656e74206e6f74206f6e2074617820626c61636b6c6973742906722e000000722300000072330000007232000000da0672656d6f76657221000000290272450000007247000000722a000000722a000000721b000000da1972656d6f76655f66726f6d5f7461785f626c61636b6c69737462000000730a00000000020601140108010a01724a0000006301000000000000000300000005000000430000007384000000740074016a0283006b007314740364018301820174046a02830064026b02732874036403830182017c0064046b047338740364058301820174056a06740783017d017c016a087c007409740a6a0b64068d0301007c00740c14007d02740d740a6a0b050019007c02370003003c00740e6a0f740e6a0283007c021700830101006400530029074e7a115377617020706572696f6420656e646564547a285377617070696e6720474f4c4420666f72204e45422063757272656e746c792064697361626c656472010000007a1e43616e6e6f742073776170206e656761746976652062616c616e636573212903723000000072310000007237000000291072250000007224000000723300000072320000007222000000da09696d706f72746c6962da0d696d706f72745f6d6f64756c65da0d474f4c445f434f4e54524143547239000000da0c4255524e5f41444452455353721d000000721e000000da0b535741505f464143544f52721c0000007229000000722100000029037230000000da04676f6c64da0b737761705f616d6f756e74722a000000722a000000721b000000da09737761705f676f6c646b00000073120000000002140106010e0110010a011201080112017252000000630000000000000000000000000200000043000000731400000074008300010074016a026401830101006400530029024e542903722e00000072220000007221000000722a000000722a000000722a000000721b000000da0b656e61626c655f73776170780000007304000000000206017253000000630000000000000000000000000200000043000000731400000074008300010074016a026401830101006400530029024e462903722e00000072220000007221000000722a000000722a000000722a000000721b000000da0c64697361626c655f737761707e0000007304000000000206017254000000630000000000000000000000000200000043000000730c00000074006a01830074021800530029014e2903722400000072330000007225000000722a000000722a000000722a000000721b000000da1374696d655f756e74696c5f737761705f656e6484000000730200000000027255000000630100000000000000010000000400000043000000734c0000007c0064016b0473107400640283018201740174026a0319007c006b057326740064038301820174017404050019007c00370003003c00740174026a03050019007c00380003003c006400530029044e72010000007a1c43616e6e6f74206275726e206e6567617469766520616d6f756e74217a194e6f7420656e6f75676820636f696e7320746f206275726e2129057232000000721c000000721d000000721e000000724e00000029017230000000722a000000722a000000721b000000da046275726e8900000073080000000002100116011001725600000029017205000000630100000000000000010000000200000043000000731400000074008300010074016a027c00830101006400530029014e2903722e0000007228000000722100000029017205000000722a000000722a000000721b000000da097365745f7661756c74910000007304000000000206017257000000630000000000000000000000000500000043000000733a00000074008300010074016a02830073167403640183018201740474016a02830005001900740474051900370003003c006402740474053c006400530029034e7a175661756c7420636f6e7472616374206e6f74207365742172010000002906722e000000722800000072330000007232000000721c000000723f000000722a000000722a000000722a000000721b000000da14666c7573685f696e7465726e616c5f7661756c74970000007308000000000206011001180172580000006300000000000000000000000004000000430000007314000000740074016a02830074037404190018008301530029014e2905723d00000072290000007233000000721c000000724e000000722a000000722a000000722a000000721b000000da1263697263756c6174696e675f737570706c799f000000730200000000027259000000630000000000000000000000000200000043000000730c000000740074016a0283008301530029014e2903723d00000072290000007233000000722a000000722a000000722a000000721b000000720c000000a400000073020000000002630000000000000000000000000200000043000000731600000074006a0174026b06731274036401830182016400530029024e7a1d4f6e6c792065786563757461626c65206279206f70657261746f7273212904721d000000721e000000da094f50455241544f52537232000000722a000000722a000000722a000000721b000000722e000000a900000073020000000001722e0000004e2927da0448617368721c000000721f000000da085661726961626c65722000000072220000007228000000722300000072290000007224000000da07646563696d616c724f000000724e000000723f000000724d000000725a000000722b000000da085f5f6578706f7274da03737472da03416e79722f000000da05666c6f6174723500000072360000007239000000723400000072440000007248000000724a00000072520000007253000000725400000072550000007256000000725700000072580000007259000000720c000000722e000000722a000000722a000000722a000000721b000000da083c6d6f64756c653e0100000073540000000e010c010c010c010c010c010c010c01080104010401040102010603080d0601120506011209060112050601140d0e0f0601100606011009060110080601100c1006100610050601100706011005100810051005