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