StakingEscrow

details

v5.7.1

notice

Contract holds and locks stakers tokens. Each staker that locks their tokens will receive some compensation

events

CommitmentMade(address,uint16,uint256)

notice

Signals that the worker associated with the staker made a commitment to next period

params

period

Period committed to

staker

Staker address

value

Amount of tokens staked for the committed period

Deposited(address,uint256,uint16)

notice

Signals that tokens were deposited

params

periods

Number of periods tokens will be locked

staker

Staker address

value

Amount deposited (in NuNits)

Divided(address,uint256,uint16,uint256,uint16)

notice

Signals that a sub-stake was divided

params

lastPeriod

Final locked period of old sub-stake

newValue

New sub-stake value (in NuNits)

oldValue

Old sub-stake value (in NuNits)

periods

Number of periods to extend sub-stake

staker

Staker address

Initialized(uint256)

notice

Issuer is initialized with a reserved reward

Locked(address,uint256,uint16,uint16)

notice

Signals that tokens were stake locked

params

firstPeriod

Starting lock period

periods

Number of periods tokens will be locked

staker

Staker address

value

Amount locked (in NuNits)

Merged(address,uint256,uint256,uint16)

notice

Signals that two sub-stakes were merged

params

lastPeriod

Final locked period of merged sub-stake

staker

Staker address

value1

Value of first sub-stake (in NuNits)

value2

Value of second sub-stake (in NuNits)

Migrated(address,uint16)

notice

Signals that the staker migrated their stake to the new period length

params

period

Period when migration happened

staker

Staker address

Minted(address,uint16,uint256)

notice

Signals that tokens were minted for previous periods

params

period

Previous period tokens minted for

staker

Staker address

value

Amount minted (in NuNits)

Prolonged(address,uint256,uint16,uint16)

notice

Signals that a sub-stake was prolonged

params

lastPeriod

Final locked period of old sub-stake

periods

Number of periods sub-stake was extended

staker

Staker address

value

Value of sub-stake

ReStakeSet(address,bool)

notice

Signals that the restake parameter was activated/deactivated

params

reStake

Updated parameter value

staker

Staker address

Slashed(address,uint256,address,uint256)

notice

Signals that the staker was slashed

params

investigator

Investigator address

penalty

Slashing penalty

reward

Value of reward provided to investigator (in NuNits)

staker

Staker address

SnapshotSet(address,bool)

notice

Signals that the snapshot parameter was activated/deactivated

params

snapshotsEnabled

Updated parameter value

staker

Staker address

WindDownSet(address,bool)

notice

Signals that the winddown parameter was activated/deactivated

params

staker

Staker address

windDown

Updated parameter value

Withdrawn(address,uint256)

notice

Signals that tokens were withdrawn to the staker

params

staker

Staker address

value

Amount withdraws (in NuNits)

WorkMeasurementSet(address,bool)

notice

internal event

WorkerBonded(address,address,uint16)

notice

Signals that a worker was bonded to the staker

params

staker

Staker address

startPeriod

Period bonding occurred

worker

Worker address

methods

bondWorker(address)

notice

Bond worker

params

_worker

Worker address. Must be a real address, not a contract

commitToNextPeriod()

notice

Make a commitment to the next period and mint for the previous period

constructor

notice

Constructor sets address of token contract and coefficients for minting

params

_issuanceDecayCoefficient
  1. Coefficient which modifies the rate at which the maximum issuance decays, only applicable to Phase 2. d = 365 * half-life / LOG2 where default half-life = 2. See Equation 10 in Staking Protocol & Economics paper

_adjudicator

Adjudicator contract

_firstPhaseMaxIssuance

(Imax) Maximum number of new tokens minted per period during Phase 1. See Equation 7 in Staking Protocol & Economics paper.

_firstPhaseTotalSupply

Total supply for the first phase

_genesisHoursPerPeriod

Size of period in hours at genesis

_hoursPerPeriod

Size of period in hours

_lockDurationCoefficient1

(k1) Numerator of the coefficient which modifies the extent to which a stake’s lock duration affects the subsidy it receives. Affects stakers differently. Applicable to Phase 1 and Phase 2. k1 = k2 * small_stake_multiplier where default small_stake_multiplier = 0.5. See Equation 8 in Staking Protocol & Economics paper.

_lockDurationCoefficient2

(k2) Denominator of the coefficient which modifies the extent to which a stake’s lock duration affects the subsidy it receives. Affects stakers differently. Applicable to Phase 1 and Phase 2. k2 = maximum_rewarded_periods / (1 - small_stake_multiplier) where default maximum_rewarded_periods = 365 and default small_stake_multiplier = 0.5. See Equation 8 in Staking Protocol & Economics paper.

_maxAllowableLockedTokens

Max amount of tokens that can be locked

_maximumRewardedPeriods

(kmax) Number of periods beyond which a stake’s lock duration no longer increases the subsidy it receives. kmax = reward_saturation * 365 where default reward_saturation = 1. See Equation 8 in Staking Protocol & Economics paper.

_minAllowableLockedTokens

Min amount of tokens that can be locked

_minLockedPeriods

Min amount of periods during which tokens can be locked

_minWorkerPeriods

Min amount of periods while a worker can’t be changed

_policyManager

Policy Manager contract

_token

Token contract

_workLock

WorkLock contract. Zero address if there is no WorkLock

deposit(address,uint256,uint16)

notice

Deposit tokens and create new sub-stake. Use this method to become a staker

params

_staker

Staker

_unlockingDuration

Amount of periods during which tokens will be unlocked when wind down is enabled

_value

Amount of tokens to deposit

depositAndIncrease(uint256,uint256)

details

This is preferable way to stake tokens because will be fewer active sub-stakes in the result

notice

Deposit tokens and increase lock amount of an existing sub-stake

params

_index

Index of the sub stake

_value

Amount of tokens which will be locked

depositFromWorkLock(address,uint256,uint16)

notice

Deposit tokens from WorkLock contract

params

_staker

Staker address

_unlockingDuration

Amount of periods during which tokens will be unlocked when wind down is enabled

_value

Amount of tokens to deposit

divideStake(uint256,uint256,uint16)

notice

Divide sub stake into two parts

params

_additionalDuration

Amount of periods for extending sub stake

_index

Index of the sub stake

_newValue

New sub stake value

findIndexOfPastDowntime(address,uint16)

details

If specified period is outside all downtime periods, the length of the array will be returned

notice

Find index of downtime structure that includes specified period

params

_period

Specified period number

_staker

Staker

finishUpgrade(address)

details

the onlyWhileUpgrading modifier works through a call to the parent finishUpgrade

getActiveStakers(uint16,uint256,uint256)

details

Note that activeStakers[0] in an array of uint256, but you want addresses. Careful when used directly!

notice

Get the value of locked tokens for active stakers in (getCurrentPeriod() + _offsetPeriods) period as well as stakers and their locked tokens

params

_maxStakers

Max stakers for looking, if set 0 then all will be used

_offsetPeriods

Amount of periods for locked tokens calculation

_startIndex

Start index for looking in stakers array

returns

activeStakers

Array of stakers and their locked tokens. Stakers addresses stored as uint256

allLockedTokens

Sum of locked tokens for active stakers

getAllTokens(address)

notice

Get all tokens belonging to the staker

getCompletedWork(address)

notice

Get work that completed by the staker

getCurrentPeriod()

returns

_0

Number of current period

getFlags(address)

notice

Get all flags for the staker

getLastCommittedPeriod(address)

notice

Get the last committed staker’s period

params

_staker

Staker

getLastPeriodOfSubStake(address,uint256)

notice

Get the last period of the sub stake

params

_index

Stake index

_staker

Staker

getLockedTokens(address,uint16)

details

This function is used by PreallocationEscrow so its signature can’t be updated.

notice

Get the value of locked tokens for a staker in a future period

params

_offsetPeriods

Amount of periods that will be added to the current period

_staker

Staker

getPastDowntime(address,uint256)

notice

Return the information about past downtime

getPastDowntimeLength(address)

notice

Return the length of the array of past downtime

getReservedReward()

notice

Returns the number of tokens that can be minted

getStakersLength()

notice

Return the length of the array of stakers

getSubStakeInfo(address,uint256)

notice

Return the information about sub stake

getSubStakesLength(address)

notice

Return the length of the array of sub stakes

getWorkerFromStaker(address)

notice

Get worker using staker’s address

initialize(uint256,address)

notice

Initialize reserved tokens for reward

isOwner()

returns

_0

true if msg.sender is the owner of the contract.

lockAndCreate(uint256,uint16)

notice

Lock some tokens as a new sub-stake

params

_unlockingDuration

Amount of periods during which tokens will be unlocked when wind down is enabled

_value

Amount of tokens which will be locked

lockAndIncrease(uint256,uint256)

notice

Increase lock amount of an existing sub-stake

params

_index

Index of the sub-stake

_value

Amount of tokens which will be locked

mergeStake(uint256,uint256)

details

It’s possible that both sub-stakes will be active after this transaction. But only one of them will be active until next call commitToNextPeriod (in the next period)

notice

Merge two sub-stakes into one if their last periods are equal

params

_index1

Index of the first sub-stake

_index2

Index of the second sub-stake

migrate(address)

notice

Migrate from the old period length to the new one. Can be done only once

params

_staker

Staker

mint()

notice

Mint tokens for previous periods if staker locked their tokens and made a commitment

owner()

returns

_0

the address of the owner.

previousPeriodSupply()

notice

Current supply is used in the minting formula and is stored to prevent different calculation for stakers which get reward in the same period. There are two values - supply for previous period (used in formula) and supply for current period which accumulates value before end of period.

prolongStake(uint256,uint16)

notice

Prolong active sub stake

params

_additionalDuration

Amount of periods for extending sub stake

_index

Index of the sub stake

receiveApproval(address,uint256,address,bytes)

notice

Implementation of the receiveApproval(address,uint256,address,bytes) method (see NuCypherToken contract). Deposit all tokens that were approved to transfer(param _extraData) Amount of periods during which tokens will be unlocked when wind down is enabled

params

_from

Staker

_tokenContract

Token contract address

_value

Amount of tokens to deposit

removeUnusedSubStake(uint16)

notice

Remove unused sub-stake to decrease gas cost for several methods

renounceOwnership()

details

Allows the current owner to relinquish control of the contract.

notice

Renouncing to ownership will leave the contract without an owner. It will not be possible to call the functions with the onlyOwner modifier anymore.

setReStake(bool)

notice

Set reStake parameter. If true then all staking rewards will be added to locked stake

params

_reStake

Value for parameter

setSnapshots(bool)

notice

Activate/deactivate taking snapshots of balances

params

_enableSnapshots

True to activate snapshots, False to deactivate

setWindDown(bool)

notice

Set windDown parameter. If true then stake’s duration will be decreasing in each period with commitToNextPeriod()

params

_windDown

Value for parameter

setWorkMeasurement(address,bool)

notice

Start or stop measuring the work of a staker

params

_measureWork

Value for measureWork parameter

_staker

Staker

returns

_0

Work that was previously done

slashStaker(address,uint256,address,uint256)

notice

Slash the staker’s stake and reward the investigator

params

_investigator

Investigator

_penalty

Penalty

_reward

Reward for the investigator

_staker

Staker’s address

transferOwnership(address)

details

Allows the current owner to transfer control of the contract to a newOwner.

params

newOwner

The address to transfer ownership to.

verifyState(address)

details

the onlyWhileUpgrading modifier works through a call to the parent verifyState

withdraw(uint256)

notice

Withdraw available amount of tokens to staker

params

_value

Amount of tokens to withdraw