StakingBase
contract StakingBase
is OwnedEternalStorage, IStaking
The base contract for the StakingAuRa and StakingHBBFT contracts.
Index
- Claimed
- StakeMoved
- Staked
- WithdrawalOrdered
- Withdrawn
- _addPoolActive
- _addPoolDelegator
- _addPoolDelegatorInactive
- _addPoolInactive
- _addPoolToBeElected
- _addPoolToBeRemoved
- _deletePoolToBeElected
- _deletePoolToBeRemoved
- _getCurrentBlockNumber
- _getMaxCandidates
- _initialize
- _isPoolToBeElected
- _isWithdrawAllowed
- _removePool
- _removePoolDelegator
- _removePoolDelegatorInactive
- _removePoolInactive
- _setCandidateMinStake
- _setDelegatorMinStake
- _setLikelihood
- _setOrderWithdrawEpoch
- _setOrderedWithdrawAmount
- _setOrderedWithdrawAmountTotal
- _setPoolDelegatorInactiveIndex
- _setPoolDelegatorIndex
- _setPoolInactiveIndex
- _setPoolIndex
- _setPoolToBeElectedIndex
- _setPoolToBeRemovedIndex
- _setStakeAmount
- _setStakeAmountByCurrentEpoch
- _setStakeAmountTotal
- _stake
- _stake
- _withdraw
- _withdrawCheckPool
- areStakeAndWithdrawAllowed
- claimOrderedWithdraw
- clearUnremovableValidator
- erc20Restricted
- erc20TokenContract
- gasPriceIsValid
- getCandidateMinStake
- getDelegatorMinStake
- getPools
- getPoolsInactive
- getPoolsLikelihood
- getPoolsToBeElected
- getPoolsToBeRemoved
- incrementStakingEpoch
- isInitialized
- isPoolActive
- maxWithdrawAllowed
- maxWithdrawOrderAllowed
- moveStake
- onTokenTransfer
- onlyBlockRewardContract
- onlyInitialized
- onlyValidatorSetContract
- orderWithdraw
- orderWithdrawEpoch
- orderedWithdrawAmount
- orderedWithdrawAmountTotal
- poolDelegatorInactiveIndex
- poolDelegatorIndex
- poolDelegators
- poolDelegatorsInactive
- poolInactiveIndex
- poolIndex
- poolToBeElectedIndex
- poolToBeRemovedIndex
- removeMyPool
- removePool
- setCandidateMinStake
- setDelegatorMinStake
- setErc20TokenContract
- stake
- stakeAmount
- stakeAmountByCurrentEpoch
- stakeAmountMinusOrderedWithdraw
- stakeAmountTotal
- stakeAmountTotalMinusOrderedWithdraw
- stakeNative
- stakingEpoch
- validatorSetContract
- withdraw
Reference
Events
- Claimed- event Claimed(address fromPoolStakingAddress, address staker, uint256 stakingEpoch, uint256 amount)- Emitted by the `claimOrderedWithdraw` function to signal the staker withdrew the specified amount of requested tokens/coins from the specified pool during the specified staking epoch. - Parameters:
- fromPoolStakingAddress- The pool from which the `staker` withdrew the `amount`.- staker- The address of the staker that withdrew the `amount`.- stakingEpoch- The serial number of the staking epoch during which the claim was made.- amount- The withdrawal amount.
 
- StakeMoved- event StakeMoved(address fromPoolStakingAddress, address toPoolStakingAddress, address staker, uint256 stakingEpoch, uint256 amount)- Emitted by the `moveStake` function to signal the staker moved the specified amount of stake from one pool to another during the specified staking epoch. - Parameters:
- fromPoolStakingAddress- The pool from which the `staker` moved the stake.- toPoolStakingAddress- The destination pool where the `staker` moved the stake.- staker- The address of the staker who moved the `amount`.- stakingEpoch- The serial number of the staking epoch during which the `amount` was moved.- amount- The stake amount.
 
- Staked- event Staked(address toPoolStakingAddress, address staker, uint256 stakingEpoch, uint256 amount)- Emitted by the `stake` function to signal the staker placed a stake of the specified amount for the specified pool during the specified staking epoch. - Parameters:
- toPoolStakingAddress- The pool in which the `staker` placed the stake.- staker- The address of the staker that placed the stake.- stakingEpoch- The serial number of the staking epoch during which the stake was made.- amount- The stake amount.
 
- WithdrawalOrdered- event WithdrawalOrdered(address fromPoolStakingAddress, address staker, uint256 stakingEpoch, int256 amount)- Emitted by the `orderWithdraw` function to signal the staker ordered the withdrawal of the specified amount of their stake from the specified pool during the specified staking epoch. - Parameters:
- fromPoolStakingAddress- The pool from which the `staker` ordered a withdrawal of the `amount`.- staker- The address of the staker that ordered the withdrawal of the `amount`.- stakingEpoch- The serial number of the staking epoch during which the order was made.- amount- The ordered withdrawal amount. Can be either positive or negative. See the `orderWithdraw` function.
 
- Withdrawn- event Withdrawn(address fromPoolStakingAddress, address staker, uint256 stakingEpoch, uint256 amount)- Emitted by the `withdraw` function to signal the staker withdrew the specified amount of a stake from the specified pool during the specified staking epoch. - Parameters:
- fromPoolStakingAddress- The pool from which the `staker` withdrew the `amount`.- staker- The address of staker that withdrew the `amount`.- stakingEpoch- The serial number of the staking epoch during which the withdrawal was made.- amount- The withdrawal amount.
 
Modifiers
- gasPriceIsValid- modifier gasPriceIsValid()- Ensures the transaction gas price is not zero. 
- onlyBlockRewardContract- modifier onlyBlockRewardContract()- Ensures the caller is the BlockReward contract address (EternalStorageProxy proxy contract for BlockReward). 
- onlyInitialized- modifier onlyInitialized()- Ensures the `initialize` function was called before. 
- onlyValidatorSetContract- modifier onlyValidatorSetContract()- Ensures the caller is the ValidatorSet contract address (EternalStorageProxy proxy contract for ValidatorSet). 
Functions
- _addPoolActive- function _addPoolActive(address _stakingAddress, bool _toBeElected) internal- Adds the specified staking address to the array of active pools returned by the `getPools` getter. Used by the `stake` and `orderWithdraw` functions. - Parameters:
- _stakingAddress- The pool added to the array of active pools.- _toBeElected- The boolean flag which defines whether the specified address should be added simultaneously to the `poolsToBeElected` array. See the `getPoolsToBeElected` getter.
 
- _addPoolDelegator- function _addPoolDelegator(address _poolStakingAddress, address _delegator) internal- Adds the specified address to the array of the current active delegators of the specified pool. Used by the `stake` and `orderWithdraw` functions. See the `poolDelegators` getter. - Parameters:
- _poolStakingAddress- The pool staking address.- _delegator- The delegator's address.
 
- _addPoolDelegatorInactive- function _addPoolDelegatorInactive(address _poolStakingAddress, address _delegator) internal- Adds the specified address to the array of the current inactive delegators of the specified pool. Used by the `_removePoolDelegator` function. - Parameters:
- _poolStakingAddress- The pool staking address.- _delegator- The delegator's address.
 
- _addPoolInactive- function _addPoolInactive(address _stakingAddress) internal- Adds the specified staking address to the array of inactive pools returned by the `getPoolsInactive` getter. Used by the `_removePool` function. - Parameters:
- _stakingAddress- The pool added to the array of inactive pools.
 
- _addPoolToBeElected- function _addPoolToBeElected(address _stakingAddress) internal- Adds the specified staking address to the array of pools returned by the `getPoolsToBeElected` getter. Used by the `_addPoolActive` function. See the `getPoolsToBeElected` getter. - Parameters:
- _stakingAddress- The pool added to the `poolsToBeElected` array.
 
- _addPoolToBeRemoved- function _addPoolToBeRemoved(address _stakingAddress) internal- Adds the specified staking address to the array of pools returned by the `getPoolsToBeRemoved` getter. Used by withdrawal functions. See the `getPoolsToBeRemoved` getter. - Parameters:
- _stakingAddress- The pool added to the `poolsToBeRemoved` array.
 
- _deletePoolToBeElected- function _deletePoolToBeElected(address _stakingAddress) internal- Deletes the specified staking address from the array of pools returned by the `getPoolsToBeElected` getter. Used by the `_addPoolToBeRemoved` and `_removePool` functions. See the `getPoolsToBeElected` getter. - Parameters:
- _stakingAddress- The pool deleted from the `poolsToBeElected` array.
 
- _deletePoolToBeRemoved- function _deletePoolToBeRemoved(address _stakingAddress) internal- Deletes the specified staking address from the array of pools returned by the `getPoolsToBeRemoved` getter. Used by the `_addPoolToBeElected` and `_removePool` functions. See the `getPoolsToBeRemoved` getter. - Parameters:
- _stakingAddress- The pool deleted from the `poolsToBeRemoved` array.
 
- _getCurrentBlockNumber- function _getCurrentBlockNumber() internal view returns (uint256)- Returns the current block number. Needed mostly for unit tests. - Returns:
- uint256
 
- _getMaxCandidates- function _getMaxCandidates() internal pure returns (uint256)- Returns the max number of candidates (including validators). See the MAX_CANDIDATES constant. Needed mostly for unit tests. - Returns:
- uint256
 
- _initialize- function _initialize(address _validatorSetContract, address[] _initialStakingAddresses, uint256 _delegatorMinStake, uint256 _candidateMinStake, bool _erc20Restricted) internal- Initializes the network parameters. Used by the `initialize` function of a child contract. - Parameters:
- _validatorSetContract- The address of the `ValidatorSet` contract.- _initialStakingAddresses- The array of initial validators' staking addresses.- _delegatorMinStake- The minimum allowed amount of delegator stake in STAKE_UNITs.- _candidateMinStake- The minimum allowed amount of candidate/validator stake in STAKE_UNITs.- _erc20Restricted- Defines whether this staking contract restricts using ERC20/677 contract. If it's set to `true`, native staking coins are used instead of ERC staking tokens.
 
- _isPoolToBeElected- function _isPoolToBeElected(address _stakingAddress) internal view returns (bool, uint256)- Determines if the specified pool is in the `poolsToBeElected` array. See the `getPoolsToBeElected` getter. Used by the `_setLikelihood` function. - Parameters:
- _stakingAddress- The staking address of the pool.
- Returns:
- `bool toBeElected` - The boolean flag indicating whether the `_stakingAddress` is in the `poolsToBeElected` array. `uint256 index` - The position of the item in the `poolsToBeElected` array if `toBeElected` is `true`.
 
- _isWithdrawAllowed- function _isWithdrawAllowed(address _miningAddress) internal view returns (bool)- Returns `true` if withdrawal from the pool of the specified validator is allowed at the moment. Used by all withdrawal functions. - Parameters:
- _miningAddress- The mining address of the validator's pool.
- Returns:
- bool
 
- _removePool- function _removePool(address _stakingAddress) internal- Removes the specified staking address from the array of active pools returned by the `getPools` getter. Used by the `removePool` and withdrawal functions. - Parameters:
- _stakingAddress- The pool removed from the array of active pools.
 
- _removePoolDelegator- function _removePoolDelegator(address _poolStakingAddress, address _delegator) internal- Removes the specified address from the array of the current active delegators of the specified pool. Used by the withdrawal functions. See the `poolDelegators` getter. - Parameters:
- _poolStakingAddress- The pool staking address.- _delegator- The delegator's address.
 
- _removePoolDelegatorInactive- function _removePoolDelegatorInactive(address _poolStakingAddress, address _delegator) internal- Removes the specified address from the array of the inactive delegators of the specified pool. Used by the `_addPoolDelegator` and `_removePoolDelegator` functions. - Parameters:
- _poolStakingAddress- The pool staking address.- _delegator- The delegator's address.
 
- _removePoolInactive- function _removePoolInactive(address _stakingAddress) internal- Removes the specified staking address from the array of inactive pools returned by the `getPoolsInactive` getter. Used by the `_addPoolActive` and `_removePool` functions. - Parameters:
- _stakingAddress- The pool removed from the array of inactive pools.
 
- _setCandidateMinStake- function _setCandidateMinStake(uint256 _minStake) internal- Sets (updates) the limit of the minimum candidate stake (CANDIDATE_MIN_STAKE). Used by the `_initialize` and `setCandidateMinStake` functions. - Parameters:
- _minStake- The value of a new limit in STAKE_UNITs.
 
- _setDelegatorMinStake- function _setDelegatorMinStake(uint256 _minStake) internal- Sets (updates) the limit of the minimum delegator stake (DELEGATOR_MIN_STAKE). Used by the `_initialize` and `setDelegatorMinStake` functions. - Parameters:
- _minStake- The value of a new limit in STAKE_UNITs.
 
- _setLikelihood- function _setLikelihood(address _poolStakingAddress) internal- Calculates (updates) the probability of being selected as a validator for the specified pool and updates the total sum of probability coefficients. See the `getPoolsLikelihood` getter. Used by the staking and withdrawal functions. - Parameters:
- _poolStakingAddress- The address of the pool for which the probability coefficient must be updated.
 
- _setOrderWithdrawEpoch- function _setOrderWithdrawEpoch(address _poolStakingAddress, address _staker, uint256 _stakingEpoch) internal- Sets the number of the staking epoch during which the specified staker ordered the latest withdraw from the specified pool. Used by the `orderWithdraw` function to allow the ordered amount to be claimed only in future staking epochs. See also the `orderWithdrawEpoch` getter. - Parameters:
- _poolStakingAddress- The pool staking address from which the withdrawal will occur.- _staker- The staker's address that ordered the withdrawal.- _stakingEpoch- The number of the current staking epoch.
 
- _setOrderedWithdrawAmount- function _setOrderedWithdrawAmount(address _poolStakingAddress, address _staker, uint256 _amount) internal- Sets the current amount of staking tokens/coins ordered for withdrawal from the specified pool by the specified staker. Used by the `orderWithdraw` and `claimOrderedWithdraw` functions. - Parameters:
- _poolStakingAddress- The pool staking address from which the amount will be withdrawn.- _staker- The staker's address that ordered the withdrawal.- _amount- The amount of staking tokens ordered for withdrawal.
 
- _setOrderedWithdrawAmountTotal- function _setOrderedWithdrawAmountTotal(address _poolStakingAddress, uint256 _amount) internal- Sets the total amount of staking tokens/coins ordered for withdrawal from the specified pool by all its stakers. - Parameters:
- _poolStakingAddress- The pool staking address from which the amount will be withdrawn.- _amount- The total amount of staking tokens/coins ordered for withdrawal.
 
- _setPoolDelegatorInactiveIndex- function _setPoolDelegatorInactiveIndex(address _poolStakingAddress, address _delegator, uint256 _index) internal- Sets the delegator's index in the `poolDelegatorsInactive` array. Used by the `_addPoolDelegatorInactive` and `_removePoolDelegatorInactive` functions. - Parameters:
- _poolStakingAddress- The pool staking address.- _delegator- The delegator's address.- _index- The index of the delegator in the `poolDelegatorsInactive` array.
 
- _setPoolDelegatorIndex- function _setPoolDelegatorIndex(address _poolStakingAddress, address _delegator, uint256 _index) internal- Sets the delegator's index in the array returned by the `poolDelegators` getter. Used by the `_addPoolDelegator` and `_removePoolDelegator` functions. - Parameters:
- _poolStakingAddress- The pool staking address.- _delegator- The delegator's address.- _index- The index of the delegator in the `poolDelegators` array.
 
- _setPoolInactiveIndex- function _setPoolInactiveIndex(address _stakingAddress, uint256 _index) internal- Sets the index for the specified address which indicates the position of the address in the array returned by the `getPoolsInactive` getter. Used by the `_addPoolInactive` and `_removePoolInactive` functions. - Parameters:
- _stakingAddress- The pool staking address.- _index- The index value.
 
- _setPoolIndex- function _setPoolIndex(address _stakingAddress, uint256 _index) internal- Sets the index for the specified address which indicates the position of the address in the array returned by the `getPools` getter. Used by the `_addPoolActive` and `_removePool` functions. - Parameters:
- _stakingAddress- The pool staking address.- _index- The index value.
 
- _setPoolToBeElectedIndex- function _setPoolToBeElectedIndex(address _stakingAddress, uint256 _index) internal- Sets the index for the specified address which indicates the position of the address in the array returned by the `getPoolsToBeElected` getter. Used by the `_addPoolToBeElected` and `_deletePoolToBeElected` functions. - Parameters:
- _stakingAddress- The pool staking address.- _index- The index value.
 
- _setPoolToBeRemovedIndex- function _setPoolToBeRemovedIndex(address _stakingAddress, uint256 _index) internal- Sets the index for the specified address which indicates the position of the address in the array returned by the `getPoolsToBeRemoved` getter. Used by the `_addPoolToBeRemoved` and `_deletePoolToBeRemoved` functions. - Parameters:
- _stakingAddress- The pool staking address.- _index- The index value.
 
- _setStakeAmount- function _setStakeAmount(address _poolStakingAddress, address _staker, uint256 _amount) internal- Sets the amount of staking tokens/coins currently staked into the specified pool by the specified staker. Used by the `stake`, `withdraw`, and `claimOrderedWithdraw` functions. See the `stakeAmount` getter. - Parameters:
- _poolStakingAddress- The pool staking address.- _staker- The staker's address.- _amount- The amount of staking tokens/coins.
 
- _setStakeAmountByCurrentEpoch- function _setStakeAmountByCurrentEpoch(address _poolStakingAddress, address _staker, uint256 _amount) internal- Sets the amount of staking tokens/coins staked into the specified pool by the specified staker during the current staking epoch (see the `stakingEpoch` getter). See also the `stakeAmountByCurrentEpoch` getter. Used by the `_stake` and `_withdraw` functions. - Parameters:
- _poolStakingAddress- The pool staking address.- _staker- The staker's address.- _amount- The amount of staking tokens/coins.
 
- _setStakeAmountTotal- function _setStakeAmountTotal(address _poolStakingAddress, uint256 _amount) internal- Sets the total amount of staking tokens/coins currently staked into the specified pool. - Parameters:
- _poolStakingAddress- The pool staking address.- _amount- The total amount of staking tokens/coins.
 
- _stake- function _stake(address _toPoolStakingAddress, uint256 _amount) internal- The internal function used by the `stake` and `addPool` functions. See the `stake` public function for more details. - Parameters:
- _toPoolStakingAddress- The staking address of the pool where the tokens/coins should be staked.- _amount- The amount of tokens/coins to be staked.
 
- _stake- function _stake(address _poolStakingAddress, address _staker, uint256 _amount) internal- The internal function used by the `_stake` and `moveStake` functions. See the `stake` public function for more details. - Parameters:
- _poolStakingAddress- The staking address of the pool where the tokens/coins should be staked.- _staker- The staker's address.- _amount- The amount of tokens/coins to be staked.
 
- _withdraw- function _withdraw(address _poolStakingAddress, address _staker, uint256 _amount) internal- The internal function used by the `withdraw` and `moveStake` functions. See the `withdraw` public function for more details. - Parameters:
- _poolStakingAddress- The staking address of the pool from which the tokens/coins should be withdrawn.- _staker- The staker's address.- _amount- The amount of the tokens/coins to be withdrawn.
 
- _withdrawCheckPool- function _withdrawCheckPool(address _poolStakingAddress, address _staker) internal- The internal function used by the `_withdraw` and `claimOrderedWithdraw` functions. Contains a common logic for these functions. - Parameters:
- _poolStakingAddress- The staking address of the pool from which the tokens/coins are withdrawn.- _staker- The staker's address.
 
- areStakeAndWithdrawAllowed- abstract function areStakeAndWithdrawAllowed() public view returns (bool)- Returns a boolean flag indicating whether the stake and withdraw operations are allowed at the moment. - Returns:
- bool
 
- claimOrderedWithdraw- function claimOrderedWithdraw(address _poolStakingAddress) external- Withdraws the staking tokens/coins from the specified pool ordered during the previous staking epochs with the `orderWithdraw` function. The ordered amount can be retrieved by the `orderedWithdrawAmount` getter. - Modifiers:
- gasPriceIsValid onlyInitialized
- Parameters:
- _poolStakingAddress- The staking address of the pool from which the ordered tokens/coins are withdrawn.
 
- clearUnremovableValidator- function clearUnremovableValidator(address _unremovableStakingAddress) external- Adds the `unremovable validator` to either the `poolsToBeElected` or the `poolsToBeRemoved` array depending on their own stake in their own pool when they become removable. This allows the `ValidatorSet._newValidatorSet` function to recognize the unremovable validator as a regular removable pool. Called by the `ValidatorSet.clearUnremovableValidator` function. - Modifiers:
- onlyValidatorSetContract
- Parameters:
- _unremovableStakingAddress- The staking address of the unremovable validator.
 
- erc20Restricted- function erc20Restricted() public view returns (bool)- Returns a boolean flag indicating whether this contract restricts using ERC20/677 contract. If it returns `true`, native staking coins are used instead of ERC staking tokens. - Returns:
- bool
 
- erc20TokenContract- function erc20TokenContract() public view returns (address)- Returns the address of the ERC20/677 staking token contract. - Returns:
- address
 
- getCandidateMinStake- function getCandidateMinStake() public view returns (uint256)- Returns the limit of the minimum candidate stake (CANDIDATE_MIN_STAKE). - Returns:
- uint256
 
- getDelegatorMinStake- function getDelegatorMinStake() public view returns (uint256)- Returns the limit of the minimum delegator stake (DELEGATOR_MIN_STAKE). - Returns:
- uint256
 
- getPools- function getPools() external view returns (address[])- Returns an array of the current active pools (the staking addresses of candidates and validators). The size of the array cannot exceed MAX_CANDIDATES. A pool can be added to this array with the `_addPoolActive` function which is called by the `stake` or `orderWithdraw` function. A pool is considered active if its address has at least the minimum stake and this stake is not ordered to be withdrawn. - Returns:
- address[]
 
- getPoolsInactive- function getPoolsInactive() external view returns (address[])- Returns an array of the current inactive pools (the staking addresses of former candidates). A pool can be added to this array with the `_addPoolInactive` function which is called by `_removePool`. A pool is considered inactive if it is banned for some reason, if its address has zero stake, or if its entire stake is ordered to be withdrawn. - Returns:
- address[]
 
- getPoolsLikelihood- function getPoolsLikelihood() external view returns (int256[], int256)- Returns the list of probability coefficients of being selected as a validator for each corresponding address in the `poolsToBeElected` array (see the `getPoolsToBeElected` getter) and a sum of these coefficients. Used by the `ValidatorSet._newValidatorSet` function when randomly selecting new validators at the last block of a staking epoch. A pool's coefficient is updated every time any staked amount is changed in this pool (see the `_setLikelihood` function). - Returns:
- `int256[] likelihoods` - The array of the coefficients. The array length is always equal to the length of the `poolsToBeElected` array. `int256 sum` - The sum of the coefficients.
 
- getPoolsToBeElected- function getPoolsToBeElected() external view returns (address[])- Returns the list of pools (their staking addresses) which will participate in a new validator set selection process in the `ValidatorSet._newValidatorSet` function. This is an array of pools which will be considered as candidates when forming a new validator set (at the last block of a staking epoch). This array is kept updated by the `_addPoolToBeElected` and `_deletePoolToBeElected` functions. - Returns:
- address[]
 
- getPoolsToBeRemoved- function getPoolsToBeRemoved() external view returns (address[])- Returns the list of pools (their staking addresses) which will be removed by the `ValidatorSet._newValidatorSet` function from the active `pools` array (at the last block of a staking epoch). This array is kept updated by the `_addPoolToBeRemoved` and `_deletePoolToBeRemoved` functions. A pool is added to this array when the pool's address withdraws all of its own staking tokens from the pool, inactivating the pool. - Returns:
- address[]
 
- incrementStakingEpoch- function incrementStakingEpoch() external- Increments the serial number of the current staking epoch. Called by the `ValidatorSet._newValidatorSet` at the last block of the finished staking epoch. - Modifiers:
- onlyValidatorSetContract
 
- isInitialized- function isInitialized() public view returns (bool)- Returns a boolean flag indicating if the `initialize` function has been called. - Returns:
- bool
 
- isPoolActive- function isPoolActive(address _stakingAddress) public view returns (bool)- Returns a flag indicating whether a specified address is in the `pools` array. See the `getPools` getter. - Parameters:
- _stakingAddress- The staking address of the pool.
- Returns:
- bool
 
- maxWithdrawAllowed- function maxWithdrawAllowed(address _poolStakingAddress, address _staker) public view returns (uint256)- Returns the maximum amount which can be withdrawn from the specified pool by the specified staker at the moment. Used by the `withdraw` function. - Parameters:
- _poolStakingAddress- The pool staking address from which the withdrawal will be made.- _staker- The staker address that is going to withdraw.
- Returns:
- uint256
 
- maxWithdrawOrderAllowed- function maxWithdrawOrderAllowed(address _poolStakingAddress, address _staker) public view returns (uint256)- Returns the maximum amount which can be ordered to be withdrawn from the specified pool by the specified staker at the moment. Used by the `orderWithdraw` function. - Parameters:
- _poolStakingAddress- The pool staking address from which the withdrawal will be ordered.- _staker- The staker address that is going to order the withdrawal.
- Returns:
- uint256
 
- moveStake- function moveStake(address _fromPoolStakingAddress, address _toPoolStakingAddress, uint256 _amount) external- Moves staking tokens/coins from one pool to another. A staker calls this function when they want to move their tokens/coins from one pool to another without withdrawing their tokens/coins. - Modifiers:
- gasPriceIsValid onlyInitialized
- Parameters:
- _fromPoolStakingAddress- The staking address of the source pool.- _toPoolStakingAddress- The staking address of the target pool.- _amount- The amount of staking tokens/coins to be moved. The amount cannot exceed the value returned by the `maxWithdrawAllowed` getter.
 
- onTokenTransfer- function onTokenTransfer(address , uint256 , bytes ) public pure returns (bool)- Prevents sending tokens directly to the `Staking` contract address by the `ERC677BridgeTokenRewardable.transferAndCall` function. - Parameters:
- - address- - uint256- - bytes
- Returns:
- bool
 
- orderWithdraw- function orderWithdraw(address _poolStakingAddress, int256 _amount) external- Orders a token/coin withdrawal from the staking address of the specified pool to the staker's address. The requested tokens/coins can be claimed after the current staking epoch is complete using the `claimOrderedWithdraw` function. - Modifiers:
- gasPriceIsValid onlyInitialized
- Parameters:
- _poolStakingAddress- The staking address of the pool from which the amount will be withdrawn.- _amount- The amount to be withdrawn. A positive value means the staker wants to either set or increase their withdrawal amount. A negative value means the staker wants to decrease a withdrawal amount that was previously set. The amount cannot exceed the value returned by the `maxWithdrawOrderAllowed` getter.
 
- orderWithdrawEpoch- function orderWithdrawEpoch(address _poolStakingAddress, address _staker) public view returns (uint256)- Returns the number of the staking epoch during which the specified staker ordered the latest withdraw from the specified pool. Used by the `claimOrderedWithdraw` function to allow the ordered amount to be claimed only in future staking epochs. - Parameters:
- _poolStakingAddress- The pool staking address from which the withdrawal will occur.- _staker- The staker address that ordered the withdrawal.
- Returns:
- uint256
 
- orderedWithdrawAmount- function orderedWithdrawAmount(address _poolStakingAddress, address _staker) public view returns (uint256)- Returns the current amount of staking tokens/coins ordered for withdrawal from the specified pool by the specified staker. Used by the `orderWithdraw` and `claimOrderedWithdraw` functions. - Parameters:
- _poolStakingAddress- The pool staking address from which the amount will be withdrawn.- _staker- The staker address that ordered the withdrawal.
- Returns:
- uint256
 
- orderedWithdrawAmountTotal- function orderedWithdrawAmountTotal(address _poolStakingAddress) public view returns (uint256)- Returns the current total amount of staking tokens/coins ordered for withdrawal from the specified pool by all of its stakers. - Parameters:
- _poolStakingAddress- The pool staking address from which the amount will be withdrawn.
- Returns:
- uint256
 
- poolDelegatorInactiveIndex- function poolDelegatorInactiveIndex(address _poolStakingAddress, address _delegator) public view returns (uint256)- Returns the delegator's index in the `poolDelegatorsInactive` array. Used by the `_removePoolDelegatorInactive` function. A delegator is considered inactive if they have withdrawn all their tokens from the specified pool or their entire stake is ordered to be withdrawn. - Parameters:
- _poolStakingAddress- The pool staking address for which the inactive delegator's index is returned.- _delegator- The delegator address.
- Returns:
- uint256
 
- poolDelegatorIndex- function poolDelegatorIndex(address _poolStakingAddress, address _delegator) public view returns (uint256)- Returns the delegator's index in the array returned by the `poolDelegators` getter. Used by the `_removePoolDelegator` function. - Parameters:
- _poolStakingAddress- The pool staking address.- _delegator- The delegator's address.
- Returns:
- If the returned value is zero, it may mean the array doesn't contain the delegator. Check if the delegator is in the array using the `poolDelegators` getter.
 
- poolDelegators- function poolDelegators(address _poolStakingAddress) public view returns (address[])- Returns an array of the current active delegators of the specified pool. A delegator is considered active if they have staked into the specified pool and their stake is not ordered to be withdrawn. - Parameters:
- _poolStakingAddress- The pool staking address.
- Returns:
- address[]
 
- poolDelegatorsInactive- function poolDelegatorsInactive(address _poolStakingAddress) public view returns (address[])- Returns an array of the current inactive delegators of the specified pool. A delegator is considered inactive if their entire stake is ordered to be withdrawn but not yet claimed. - Parameters:
- _poolStakingAddress- The pool staking address.
- Returns:
- address[]
 
- poolInactiveIndex- function poolInactiveIndex(address _stakingAddress) public view returns (uint256)- Returns the pool's index in the array returned by the `getPoolsInactive` getter. Used by the `_removePoolInactive` function. - Parameters:
- _stakingAddress- The pool staking address.
- Returns:
- uint256
 
- poolIndex- function poolIndex(address _stakingAddress) public view returns (uint256)- Returns the pool's index in the array returned by the `getPools` getter. Used by the `_removePool` function. - Parameters:
- _stakingAddress- The pool staking address.
- Returns:
- If the returned value is zero, it may mean the array doesn't contain the address. Check the address is in the array using the `isPoolActive` getter.
 
- poolToBeElectedIndex- function poolToBeElectedIndex(address _stakingAddress) public view returns (uint256)- Returns the pool's index in the array returned by the `getPoolsToBeElected` getter. Used by the `_deletePoolToBeElected` and `_isPoolToBeElected` functions. - Parameters:
- _stakingAddress- The pool staking address.
- Returns:
- If the returned value is zero, it may mean the array doesn't contain the address. Check the address is in the array using the `getPoolsToBeElected` getter.
 
- poolToBeRemovedIndex- function poolToBeRemovedIndex(address _stakingAddress) public view returns (uint256)- Returns the pool's index in the array returned by the `getPoolsToBeRemoved` getter. Used by the `_deletePoolToBeRemoved` function. - Parameters:
- _stakingAddress- The pool staking address.
- Returns:
- If the returned value is zero, it may mean the array doesn't contain the address. Check the address is in the array using the `getPoolsToBeRemoved` getter.
 
- removeMyPool- function removeMyPool() external- Removes the candidate's or validator's pool from the `pools` array (a list of active pools which can be retrieved by the `getPools` getter). When a candidate or validator wants to remove their pool, they should call this function from their staking address. A validator cannot remove their pool while they are an `unremovable validator`. - Modifiers:
- gasPriceIsValid onlyInitialized
 
- removePool- function removePool(address _stakingAddress) external- Removes a specified pool from the `pools` array (a list of active pools which can be retrieved by the `getPools` getter). Called by the `ValidatorSet._removeMaliciousValidator` or the `ValidatorSet._newValidatorSet` function when a pool must be removed by the algorithm. - Modifiers:
- onlyValidatorSetContract
- Parameters:
- _stakingAddress- The staking address of the pool to be removed.
 
- setCandidateMinStake- function setCandidateMinStake(uint256 _minStake) external- Sets (updates) the limit of the minimum candidate stake (CANDIDATE_MIN_STAKE). Can only be called by the `owner`. - Modifiers:
- onlyOwner onlyInitialized
- Parameters:
- _minStake- The value of a new limit in STAKE_UNITs.
 
- setDelegatorMinStake- function setDelegatorMinStake(uint256 _minStake) external- Sets (updates) the limit of minimum delegator stake (DELEGATOR_MIN_STAKE). Can only be called by the `owner`. - Modifiers:
- onlyOwner onlyInitialized
- Parameters:
- _minStake- The value of a new limit in STAKE_UNITs.
 
- setErc20TokenContract- function setErc20TokenContract(address _erc20TokenContract) external- Sets (updates) the address of the ERC20/ERC677 staking token contract. Can only be called by the `owner`. Cannot be called if there was at least one stake in native coins before. - Modifiers:
- onlyOwner onlyInitialized
- Parameters:
- _erc20TokenContract- The address of the contract.
 
- stake- function stake(address _toPoolStakingAddress, uint256 _amount) external- Moves the specified amount of staking tokens from the staker's address to the staking address of the specified pool. A staker calls this function when they want to make a stake into a pool. - Modifiers:
- gasPriceIsValid onlyInitialized
- Parameters:
- _toPoolStakingAddress- The staking address of the pool where the tokens should be staked.- _amount- The amount of tokens to be staked.
 
- stakeAmount- function stakeAmount(address _poolStakingAddress, address _staker) public view returns (uint256)- Returns the amount of staking tokens/coins currently staked into the specified pool by the specified staker. Doesn't take into account the ordered amount to be withdrawn (use the `stakeAmountMinusOrderedWithdraw` instead). - Parameters:
- _poolStakingAddress- The pool staking address.- _staker- The staker's address.
- Returns:
- uint256
 
- stakeAmountByCurrentEpoch- function stakeAmountByCurrentEpoch(address _poolStakingAddress, address _staker) public view returns (uint256)- Returns the amount of staking tokens/coins staked into the specified pool by the specified staker during the current staking epoch (see the `stakingEpoch` getter). Used by the `stake`, `withdraw`, and `orderWithdraw` functions. - Parameters:
- _poolStakingAddress- The pool staking address.- _staker- The staker's address.
- Returns:
- uint256
 
- stakeAmountMinusOrderedWithdraw- function stakeAmountMinusOrderedWithdraw(address _poolStakingAddress, address _staker) public view returns (uint256)- Returns the amount of staking tokens/coins currently staked into the specified pool by the specified staker taking into account the ordered amount to be withdrawn. See also the `stakeAmount` and `orderedWithdrawAmount`. - Parameters:
- _poolStakingAddress- The pool staking address.- _staker- The staker's address.
- Returns:
- uint256
 
- stakeAmountTotal- function stakeAmountTotal(address _poolStakingAddress) public view returns (uint256)- Returns the total amount of staking tokens/coins currently staked into the specified pool. Doesn't take into account the ordered amounts to be withdrawn (use the `stakeAmountTotalMinusOrderedWithdraw` instead). - Parameters:
- _poolStakingAddress- The pool staking address.
- Returns:
- uint256
 
- stakeAmountTotalMinusOrderedWithdraw- function stakeAmountTotalMinusOrderedWithdraw(address _poolStakingAddress) public view returns (uint256)- Returns the total amount of staking tokens/coins currently staked into the specified pool taking into account the ordered amounts to be withdrawn. See also the `stakeAmountTotal` and `orderedWithdrawAmountTotal` getters. - Parameters:
- _poolStakingAddress- The pool staking address.
- Returns:
- uint256
 
- stakeNative- function stakeNative(address _toPoolStakingAddress) external payable- Receives the staking coins from the staker's address to the staking address of the specified pool. A staker calls this function when they want to make a stake into a pool. - Modifiers:
- gasPriceIsValid onlyInitialized
- Parameters:
- _toPoolStakingAddress- The staking address of the pool where the coins should be staked.
 
- stakingEpoch- function stakingEpoch() public view returns (uint256)- Returns the serial number of the current staking epoch. - Returns:
- uint256
 
- validatorSetContract- function validatorSetContract() public view returns (IValidatorSet)- Returns the address of the `ValidatorSet` contract. - Returns:
- IValidatorSet
 
- withdraw- function withdraw(address _fromPoolStakingAddress, uint256 _amount) external- Moves the specified amount of staking tokens/coins from the staking address of the specified pool to the staker's address. A staker calls this function when they want to withdraw their tokens/coins. - Modifiers:
- gasPriceIsValid onlyInitialized
- Parameters:
- _fromPoolStakingAddress- The staking address of the pool from which the tokens/coins should be withdrawn.- _amount- The amount of tokens/coins to be withdrawn. The amount cannot exceed the value returned by the `maxWithdrawAllowed` getter.