Transaction:

1afe070d878cd6f928c76875ba890e68a881207c68ec6f7619c042baa4f7bd2c
Status
Failed
Timestamp
10/13/2021, 12:07:07 AM
Result
AssertionError('Staking needs to be open for at least 48 minutes',)
Block Number
42675
SubBlock Number
0
Nonce
678
Processor
89f67bb871351a1629d66676e4bd92bbacb23bd0649b890542ef98f1b664a497
Stamps Used
31 ( 2.38 dTAU )
Contract Name
submission
Function Name
submit_contract
Signature
8b16aedb48fcc97cdd67bc5c272ae49aaf806c6359a3260ac4790a4559f3af3d754728e17c46aea626e0d3701e6c9f2704dcd38735a21f61cc48f622825cc006

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 >= 48, '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
currency
Variable
balances
New Value
154