Transaction:

92aee682ec2f2e4d7abc540af12d74e7ba040d069b1fbd8ab0e7006b89913791
Status
Success
Timestamp
10/13/2021, 12:07:30 AM
Result
None
Block Number
42676
SubBlock Number
0
Nonce
679
Processor
89f67bb871351a1629d66676e4bd92bbacb23bd0649b890542ef98f1b664a497
Stamps Used
388 ( 29.8 dTAU )
Contract Name
submission
Function Name
submit_contract
Signature
0d0137a1892c3e0861359ad7338e33aaa67f171ef73b5c4890b56be4fd658056d399910b505ee54f263c1d6c829767de1854cdbe42aca2fd6d83264380ac8508

Kwargs

code
# If new dates need to be set, make sure to set start_date first, then start_period and then end_date staking = Hash(default_value=0) stake_con = Variable() emission_con = Variable() current_stake = Variable() total_emission = Variable() current_emission = Variable() max_single_emission = Variable() active = Variable() fee = Variable() start_date = Variable() start_date_end = Variable() end_date = Variable() OPERATORS = [ 'ae7d14d6d9b8443f881ba6244727b69b681010e782d4fe482dbfb0b6aca02d5d', 'e787ed5907742fa8d50b3ca2701ab8e03ec749ced806a15cdab800a127d7f863' ] @construct def seed(stake_contract: str, emission_contract: str, total_emission_amount: float, minutes_till_start: int, start_period_in_minutes: int, minutes_till_end: int, nebula_fee: float, max_single_emission_amount: float): assert start_period_in_minutes >= 5, 'Staking needs to be open for at least 48 minutes' stake_con.set(stake_contract) emission_con.set(emission_contract) current_stake.set(0) current_emission.set(0) total_emission.set(total_emission_amount) max_single_emission.set(max_single_emission_amount) start_date.set(now + datetime.timedelta(minutes=minutes_till_start)) start_date_end.set(start_date.get() + datetime.timedelta(minutes=start_period_in_minutes)) end_date.set(start_date_end.get() + datetime.timedelta(minutes=minutes_till_end)) fee.set(nebula_fee) active.set(False) @export def fund_vault(): vault = ForeignVariable(foreign_contract='con_nebula', foreign_name='vault_contract') if not vault.get(): vault = Variable() vault.set('INTERNAL_NEB_VAULT') total_fee = total_emission.get() / 100 * fee.get() importlib.import_module(emission_con.get()).transfer_from( main_account=ctx.caller, amount=total_fee, to=vault.get()) send_to_vault(emission_con.get(), total_emission.get()) active.set(True) @export def send_to_vault(contract: str, amount: float): importlib.import_module(contract).transfer_from( main_account=ctx.caller, amount=amount, to=ctx.this) @export def stake(amount: float): assert_active() assert now > start_date.get(), f'Staking not started yet: {start_date.get()}' assert now < start_date_end.get(), f'Staking period ended: {start_date_end.get()}' current_stake.set(current_stake.get() + amount) send_to_vault(stake_con.get(), amount) staking[ctx.caller] += amount user_emission = calculate_emission(ctx.caller) # Check if max single emission is exceeded assert user_emission <= max_single_emission.get(), 'Emission to high! Lower stake amount!' current_emission.set(current_emission.get() + user_emission) # Check if total emission is exceeded assert current_emission.get() <= total_emission.get(), 'Vault is full!' return f'Emission: {user_emission} {emission_con}' @export def unstake(): assert_active() assert now > end_date.get(), f'End date not reached: {end_date.get()}' assert staking[ctx.caller] != 0, f'No {stake_con} staked!' # Pay emissions to user importlib.import_module(emission_con.get()).transfer( amount=calculate_emission(ctx.caller), to=ctx.caller) # Pay stake to user importlib.import_module(stake_con.get()).transfer( amount=staking[ctx.caller], to=ctx.caller) staking[ctx.caller] = 0 @export def calculate_emission(address: str): if staking[address] == 0: return 0 stake_percent = staking[address] / current_stake.get() * 100 return decimal(total_emission.get() / 100 * stake_percent) @export def enable_vault(): assert_owner() active.set(True) @export def disable_vault(): assert_owner() active.set(False) @export def emergency_withdraw(contract: str, amount: float): assert_owner() importlib.import_module(contract).transfer(amount, ctx.caller) def assert_active(): assert active.get() == True, 'Vault inactive!' def assert_owner(): assert ctx.caller in OPERATORS, 'Only executable by operators!'
constructor_args
{"emission_contract":"con_gold_contract","max_single_emission_amount":5000,"minutes_till_end":5,"minutes_till_start":5,"nebula_fee":2,"stake_contract":"con_test_gold_contract","start_period_in_minutes":5,"total_emission_amount":500000}
name
con_vault_ext_001

State Changes

Contract
con_vault_ext_001
Variable
stake_con
New Value
con_test_gold_contract
Contract
con_vault_ext_001
Variable
emission_con
New Value
con_gold_contract
Contract
con_vault_ext_001
Variable
current_stake
New Value
0
Contract
con_vault_ext_001
Variable
current_emission
New Value
0
Contract
con_vault_ext_001
Variable
total_emission
New Value
500,000
Contract
con_vault_ext_001
Variable
max_single_emission
New Value
5,000
Contract
con_vault_ext_001
Variable
start_date
New Value
{"__time__":[2021,10,13,0,12,32,0]}
Contract
con_vault_ext_001
Variable
start_date_end
New Value
{"__time__":[2021,10,13,0,17,32,0]}
Contract
con_vault_ext_001
Variable
end_date
New Value
{"__time__":[2021,10,13,0,22,32,0]}
Contract
con_vault_ext_001
Variable
fee
New Value
2
Contract
con_vault_ext_001
Variable
active
New Value
false
Contract
con_vault_ext_001
Variable
__code__
New Value
__staking = Hash(default_value=0, contract='con_vault_ext_001', name='staking') __stake_con = Variable(contract='con_vault_ext_001', name='stake_con') __emission_con = Variable(contract='con_vault_ext_001', name='emission_con') __current_stake = Variable(contract='con_vault_ext_001', name='current_stake') __total_emission = Variable(contract='con_vault_ext_001', name='total_emission' ) __current_emission = Variable(contract='con_vault_ext_001', name= 'current_emission') __max_single_emission = Variable(contract='con_vault_ext_001', name= 'max_single_emission') __active = Variable(contract='con_vault_ext_001', name='active') __fee = Variable(contract='con_vault_ext_001', name='fee') __start_date = Variable(contract='con_vault_ext_001', name='start_date') __start_date_end = Variable(contract='con_vault_ext_001', name='start_date_end' ) __end_date = Variable(contract='con_vault_ext_001', name='end_date') OPERATORS = ['ae7d14d6d9b8443f881ba6244727b69b681010e782d4fe482dbfb0b6aca02d5d' , 'e787ed5907742fa8d50b3ca2701ab8e03ec749ced806a15cdab800a127d7f863'] def ____(stake_contract: str, emission_contract: str, total_emission_amount: float, minutes_till_start: int, start_period_in_minutes: int, minutes_till_end: int, nebula_fee: float, max_single_emission_amount: float ): assert start_period_in_minutes >= 5, 'Staking needs to be open for at least 48 minutes' __stake_con.set(stake_contract) __emission_con.set(emission_contract) __current_stake.set(0) __current_emission.set(0) __total_emission.set(total_emission_amount) __max_single_emission.set(max_single_emission_amount) __start_date.set(now + datetime.timedelta(minutes=minutes_till_start)) __start_date_end.set(__start_date.get() + datetime.timedelta(minutes= start_period_in_minutes)) __end_date.set(__start_date_end.get() + datetime.timedelta(minutes= minutes_till_end)) __fee.set(nebula_fee) __active.set(False) @__export('con_vault_ext_001') def fund_vault(): __vault = ForeignVariable(foreign_contract='con_nebula', foreign_name= 'vault_contract', contract='con_vault_ext_001', name='vault') if not __vault.get(): __vault = Variable(contract='con_vault_ext_001', name='vault') __vault.set('INTERNAL_NEB_VAULT') total_fee = __total_emission.get() / 100 * __fee.get() importlib.import_module(__emission_con.get()).transfer_from(main_account =ctx.caller, amount=total_fee, to=__vault.get()) send_to_vault(__emission_con.get(), __total_emission.get()) __active.set(True) @__export('con_vault_ext_001') def send_to_vault(contract: str, amount: float): importlib.import_module(contract).transfer_from(main_account=ctx.caller, amount=amount, to=ctx.this) @__export('con_vault_ext_001') def stake(amount: float): __assert_active() assert now > __start_date.get( ), f'Staking not started yet: {__start_date.get()}' assert now < __start_date_end.get( ), f'Staking period ended: {__start_date_end.get()}' __current_stake.set(__current_stake.get() + amount) send_to_vault(__stake_con.get(), amount) __staking[ctx.caller] += amount user_emission = calculate_emission(ctx.caller) assert user_emission <= __max_single_emission.get( ), 'Emission to high! Lower stake amount!' __current_emission.set(__current_emission.get() + user_emission) assert __current_emission.get() <= __total_emission.get(), 'Vault is full!' return f'Emission: {user_emission} {__emission_con}' @__export('con_vault_ext_001') def unstake(): __assert_active() assert now > __end_date.get(), f'End date not reached: {__end_date.get()}' assert __staking[ctx.caller] != 0, f'No {__stake_con} staked!' importlib.import_module(__emission_con.get()).transfer(amount= calculate_emission(ctx.caller), to=ctx.caller) importlib.import_module(__stake_con.get()).transfer(amount=__staking[ ctx.caller], to=ctx.caller) __staking[ctx.caller] = 0 @__export('con_vault_ext_001') def calculate_emission(address: str): if __staking[address] == 0: return 0 stake_percent = __staking[address] / __current_stake.get() * 100 return decimal(__total_emission.get() / 100 * stake_percent) @__export('con_vault_ext_001') def enable_vault(): __assert_owner() __active.set(True) @__export('con_vault_ext_001') def disable_vault(): __assert_owner() __active.set(False) @__export('con_vault_ext_001') def emergency_withdraw(contract: str, amount: float): __assert_owner() importlib.import_module(contract).transfer(amount, ctx.caller) def __assert_active(): assert __active.get() == True, 'Vault inactive!' def __assert_owner(): assert ctx.caller in OPERATORS, 'Only executable by operators!'
Contract
con_vault_ext_001
Variable
__compiled__
New Value
{"__bytes__":"e300000000000000000000000009000000400000007366010000650064006401640264038d035a0165026401640464058d025a0365026401640664058d025a0465026401640764058d025a0565026401640864058d025a0665026401640964058d025a0765026401640a64058d025a0865026401640b64058d025a0965026401640c64058d025a0a65026401640d64058d025a0b65026401640e64058d025a0c65026401640f64058d025a0d6410641167025a0e650f650f65106511651165116510651064129c086413641484045a1265136401830164156416840083015a14651364018301650f651064179c0264186419840483015a156513640183016510641a9c01641b641c840483015a16651364018301641d641e840083015a17651364018301650f641f9c0164206421840483015a1865136401830164226423840083015a1965136401830164246425840083015a1a651364018301650f651064179c0264266427840483015a1b6428642984005a1c642a642b84005a1d642c5300292de900000000da11636f6e5f7661756c745f6578745f303031da077374616b696e672903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da097374616b655f636f6e290272050000007206000000da0c656d697373696f6e5f636f6eda0d63757272656e745f7374616b65da0e746f74616c5f656d697373696f6eda1063757272656e745f656d697373696f6eda136d61785f73696e676c655f656d697373696f6eda06616374697665da03666565da0a73746172745f64617465da0e73746172745f646174655f656e64da08656e645f64617465da4061653764313464366439623834343366383831626136323434373237623639623638313031306537383264346665343832646266623062366163613032643564da40653738376564353930373734326661386435306233636132373031616238653033656337343963656438303661313563646162383030613132376437663836332908da0e7374616b655f636f6e7472616374da11656d697373696f6e5f636f6e7472616374da15746f74616c5f656d697373696f6e5f616d6f756e74da126d696e757465735f74696c6c5f7374617274da1773746172745f706572696f645f696e5f6d696e75746573da106d696e757465735f74696c6c5f656e64da0a6e6562756c615f666565da1a6d61785f73696e676c655f656d697373696f6e5f616d6f756e7463080000000000000008000000050000004300000073ae0000007c0464016b057310740064028301820174016a027c008301010074036a027c018301010074046a0264038301010074056a0264038301010074066a027c028301010074076a027c078301010074086a027409740a6a0b7c0364048d01170083010100740c6a0274086a0d8300740a6a0b7c0464048d01170083010100740e6a02740c6a0d8300740a6a0b7c0564048d01170083010100740f6a027c068301010074106a026405830101006400530029064ee9050000007a305374616b696e67206e6565647320746f206265206f70656e20666f72206174206c65617374203438206d696e7574657372010000002901da076d696e75746573462911da0e417373657274696f6e4572726f72da0b5f5f7374616b655f636f6eda03736574da0e5f5f656d697373696f6e5f636f6eda0f5f5f63757272656e745f7374616b65da125f5f63757272656e745f656d697373696f6eda105f5f746f74616c5f656d697373696f6eda155f5f6d61785f73696e676c655f656d697373696f6eda0c5f5f73746172745f64617465da036e6f77da086461746574696d65da0974696d6564656c7461da105f5f73746172745f646174655f656e64da03676574da0a5f5f656e645f64617465da055f5f666565da085f5f6163746976652908721400000072150000007216000000721700000072180000007219000000721a000000721b000000a900722f000000da00da045f5f5f5f15000000731c000000000410010a010a010a010a010a010a0116010e010c010e010c010a01723100000063000000000000000002000000060000004300000073820000007400640164026403640464058d047d007c006a018300732e74026403640464068d027d007c006a0364078301010074046a01830064081b0074056a01830014007d0174066a0774086a01830083016a09740a6a0b7c017c006a01830064098d030100740c74086a01830074046a01830083020100740d6a03640a8301010064005300290b4eda0a636f6e5f6e6562756c61da0e7661756c745f636f6e74726163747202000000da057661756c742904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d6572050000007206000000290272050000007206000000da12494e5445524e414c5f4e45425f5641554c54e9640000002903da0c6d61696e5f6163636f756e74da06616d6f756e74da02746f54290eda0f466f726569676e5661726961626c65722b000000da085661726961626c6572200000007224000000722d000000da09696d706f72746c6962da0d696d706f72745f6d6f64756c657221000000da0d7472616e736665725f66726f6dda03637478da0663616c6c6572da0d73656e645f746f5f7661756c74722e0000002902da075f5f7661756c74da09746f74616c5f666565722f000000722f0000007230000000da0a66756e645f7661756c74290000007314000000000204010c0108010c010a0114010e0112011201724600000029027205000000723a000000630200000000000000020000000500000043000000731e00000074006a017c0083016a0274036a047c0174036a0564018d0301006400530029024e29037239000000723a000000723b0000002906723e000000723f000000724000000072410000007242000000da047468697329027205000000723a000000722f000000722f0000007230000000724300000037000000730400000000020e0172430000002901723a00000063010000000000000002000000040000004300000073cc000000740083000100740174026a0383006b0473247404640174026a0383009b009d0283018201740174056a0383006b0073427404640274056a0383009b009d028301820174066a0774066a0383007c00170083010100740874096a0383007c0083020100740a740b6a0c050019007c00370003003c00740d740b6a0c83017d017c01740e6a0383006b0173927404640383018201740f6a07740f6a0383007c01170083010100740f6a03830074106a0383006b0173bc740464048301820164057c019b00640674119b009d04530029074e7a195374616b696e67206e6f742073746172746564207965743a207a165374616b696e6720706572696f6420656e6465643a207a25456d697373696f6e20746f206869676821204c6f776572207374616b6520616d6f756e74217a0e5661756c742069732066756c6c217a0a456d697373696f6e3a20fa01202912da0f5f5f6173736572745f61637469766572270000007226000000722b000000721e000000722a000000722200000072200000007243000000721f000000da095f5f7374616b696e6772410000007242000000da1263616c63756c6174655f656d697373696f6e72250000007223000000722400000072210000002902723a000000da0d757365725f656d697373696f6e722f000000722f0000007230000000da057374616b653d000000731c000000000206010e0110010e01100112010e0112010a010e01060112011801724d0000006300000000000000000000000004000000430000007390000000740083000100740174026a0383006b0473247404640174026a0383009b009d0283018201740574066a07190064026b0373427404640374089b0064049d038301820174096a0a740b6a03830083016a0c740d74066a07830174066a0764058d02010074096a0a74086a03830083016a0c740574066a07190074066a0764058d0201006402740574066a073c006400530029064e7a16456e642064617465206e6f7420726561636865643a2072010000007a034e6f207a08207374616b6564212902723a000000723b000000290e72490000007227000000722c000000722b000000721e000000724a00000072410000007242000000721f000000723e000000723f0000007221000000da087472616e73666572724b000000722f000000722f000000722f0000007230000000da07756e7374616b654f0000007310000000000206011e011e010e01120110011001724f0000002901da0761646472657373630100000000000000020000000300000043000000733800000074007c00190064016b0272106401530074007c00190074016a0283001b00640214007d01740374046a02830064021b007c0114008301530029034e720100000072380000002905724a0000007222000000722b000000da07646563696d616c722400000029027250000000da0d7374616b655f70657263656e74722f000000722f0000007230000000724b0000005b000000730800000000020c0104011401724b000000630000000000000000000000000200000043000000731400000074008300010074016a026401830101006400530029024e542903da0e5f5f6173736572745f6f776e6572722e0000007220000000722f000000722f000000722f0000007230000000da0c656e61626c655f7661756c74630000007304000000000206017254000000630000000000000000000000000200000043000000731400000074008300010074016a026401830101006400530029024e4629037253000000722e0000007220000000722f000000722f000000722f0000007230000000da0d64697361626c655f7661756c74690000007304000000000206017255000000630200000000000000020000000300000043000000731e00000074008300010074016a027c0083016a037c0174046a05830201006400530029014e29067253000000723e000000723f000000724e0000007241000000724200000029027205000000723a000000722f000000722f0000007230000000da12656d657267656e63795f77697468647261776f0000007304000000000206017256000000630000000000000000000000000200000043000000731800000074006a01830064016b02731474026402830182016400530029034e547a0f5661756c7420696e616374697665212903722e000000722b000000721e000000722f000000722f000000722f0000007230000000724900000075000000730200000000017249000000630000000000000000000000000200000043000000731600000074006a0174026b06731274036401830182016400530029024e7a1d4f6e6c792065786563757461626c65206279206f70657261746f727321290472410000007242000000da094f50455241544f5253721e000000722f000000722f000000722f00000072300000007253000000790000007302000000000172530000004e291eda0448617368724a000000723d000000721f00000072210000007222000000722400000072230000007225000000722e000000722d0000007226000000722a000000722c0000007257000000da03737472da05666c6f6174da03696e747231000000da085f5f6578706f727472460000007243000000724d000000724f000000724b00000072540000007255000000725600000072490000007253000000722f000000722f000000722f0000007230000000da083c6d6f64756c653e0100000073400000000e010c010c010c010c0204010801040108010c010c010c010c020c0102010603040106011212100e0601120506011011100c0601100710061006060112050804"}
Contract
con_vault_ext_001
Variable
__owner__
New Value
NULL
Contract
con_vault_ext_001
Variable
__submitted__
New Value
{"__time__":[2021,10,13,0,7,32,0]}
Contract
con_vault_ext_001
Variable
__developer__
New Value
ae7d14d6d9b8443f881ba6244727b69b681010e782d4fe482dbfb0b6aca02d5d
Contract
currency
Variable
balances
New Value
124