StakingEscrow

details

v5.5.1

notice

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

events

Initialized(uint256)

notice

Issuer is initialized with a reserved reward

methods

batchDeposit(address[],uint256[],uint256[],uint16[])

notice

Batch deposit. Allowed only initial deposit for each staker

params

_numberOfSubStakes

Number of sub-stakes which belong to staker in _values and _periods arrays

_periods

Amount of periods during which tokens will be locked for each staker

_stakers

Stakers

_values

Amount of tokens to deposit for each staker

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

_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

_hoursPerPeriod

Size of period in hours

_isTestContract

True if contract is only for tests

_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

_token

Token contract

deposit(address,uint256,uint16)

notice

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

params

_periods

Amount of periods during which tokens will be locked

_staker

Staker

_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

_periods

Amount of periods during which tokens will be locked

_staker

Staker address

_value

Amount of tokens to deposit

divideStake(uint256,uint256,uint16)

notice

Divide sub stake into two parts

params

_index

Index of the sub stake

_newValue

New sub stake value

_periods

Amount of periods for extending sub stake

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() + _periods) period as well as stakers and their locked tokens

params

_maxStakers

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

_periods

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

_periods

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.

isReStakeLocked(address)

notice

Checks if reStake parameter is available for changing

params

_staker

Staker

lockAndCreate(uint256,uint16)

notice

Lock some tokens as a new sub-stake

params

_periods

Amount of periods during which tokens will be locked

_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

lockReStake(uint16)

notice

Lock reStake parameter. Only if this parameter is not locked

params

_lockReStakeUntilPeriod

Can’t change reStake value until this period

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

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

_index

Index of the sub stake

_periods

Amount of periods for extending 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 locked

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.

setAdjudicator(address)

notice

Set adjudicator address

setPolicyManager(address)

notice

Set policy manager address

setReStake(bool)

notice

Set reStake parameter. If true then all staking rewards will be added to locked stake Only if this parameter is not locked

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

setWorkLock(address)

notice

Set worklock address

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