staking docs

Staking

constructor

constructor(address grgVault, address poolRegistry, address rigoToken) public

Setting owner to null address prevents admin direct calls to implementation.

Initializing immutable implementation address is used to allow delegatecalls only. Direct calls to the implementation contract are effectively locked.

Parameters

init

function init() public

Initialize storage owned by this contract.

This function should not be called directly. The StakingProxy contract will call it in attachStakingContract().

MixinConstants

_PPM_DENOMINATOR

uint32 _PPM_DENOMINATOR

_NIL_POOL_ID

bytes32 _NIL_POOL_ID

_NIL_ADDRESS

address _NIL_ADDRESS

_MIN_TOKEN_VALUE

uint256 _MIN_TOKEN_VALUE

MixinDeploymentConstants

constructor

constructor(address grgVault, address poolRegistry, address rigoToken) internal

_implementation

address _implementation

_rigoToken

address _rigoToken

_grgVault

address _grgVault

_poolRegistry

address _poolRegistry

getGrgContract

function getGrgContract() public view virtual returns (contract IRigoToken)

An overridable way to access the deployed GRG contract.

Must be view to allow overrides to access state.

Return Values

getGrgVault

function getGrgVault() public view virtual returns (contract IGrgVault)

An overridable way to access the deployed grgVault.

Must be view to allow overrides to access state.

Return Values

getPoolRegistry

function getPoolRegistry() public view virtual returns (contract IPoolRegistry)

An overridable way to access the deployed rigoblock pool registry.

Must be view to allow overrides to access state.

Return Values

MixinStorage

stakingContract

address stakingContract

Address of staking contract.

Return Values

_globalStakeByStatus

mapping(uint8 => struct IStructs.StoredBalance) _globalStakeByStatus

_ownerStakeByStatus

mapping(uint8 => mapping(address => struct IStructs.StoredBalance)) _ownerStakeByStatus

_delegatedStakeToPoolByOwner

mapping(address => mapping(bytes32 => struct IStructs.StoredBalance)) _delegatedStakeToPoolByOwner

_delegatedStakeByPoolId

mapping(bytes32 => struct IStructs.StoredBalance) _delegatedStakeByPoolId

poolIdByRbPoolAccount

mapping(address => bytes32) poolIdByRbPoolAccount

Mapping from RigoBlock pool subaccount to pool Id of rigoblock pool

0 RigoBlock pool subaccount address.

Return Values

_poolById

mapping(bytes32 => struct IStructs.Pool) _poolById

rewardsByPoolId

mapping(bytes32 => uint256) rewardsByPoolId

mapping from pool ID to reward balance of members

0 Pool ID.

Return Values

currentEpoch

uint256 currentEpoch

The current epoch.

Return Values

currentEpochStartTimeInSeconds

uint256 currentEpochStartTimeInSeconds

The current epoch start time.

Return Values

_cumulativeRewardsByPool

mapping(bytes32 => mapping(uint256 => struct IStructs.Fraction)) _cumulativeRewardsByPool

_cumulativeRewardsByPoolLastStored

mapping(bytes32 => uint256) _cumulativeRewardsByPoolLastStored

validPops

mapping(address => bool) validPops

Registered RigoBlock Proof_of_Performance contracts, capable of paying protocol fees.

0 The address to check.

Return Values

epochDurationInSeconds

uint256 epochDurationInSeconds

Minimum seconds between epochs.

Return Values

rewardDelegatedStakeWeight

uint32 rewardDelegatedStakeWeight

Return Values

minimumPoolStake

uint256 minimumPoolStake

Minimum amount of stake required in a pool to collect rewards.

Return Values

cobbDouglasAlphaNumerator

uint32 cobbDouglasAlphaNumerator

Numerator for cobb douglas alpha factor.

Return Values

cobbDouglasAlphaDenominator

uint32 cobbDouglasAlphaDenominator

Denominator for cobb douglas alpha factor.

Return Values

poolStatsByEpoch

mapping(bytes32 => mapping(uint256 => struct IStructs.PoolStats)) poolStatsByEpoch

Stats for each pool that generated fees with sufficient stake to earn rewards.

See _minimumPoolStake in MixinParams.

Parameters

Return Values

aggregatedStatsByEpoch

mapping(uint256 => struct IStructs.AggregatedStats) aggregatedStatsByEpoch

Aggregated stats across all pools that generated fees with sufficient stake to earn rewards.

See _minimumPoolStake in MixinParams.

Parameters

Return Values

grgReservedForPoolRewards

uint256 grgReservedForPoolRewards

The GRG balance of this contract that is reserved for pool reward payouts.

Return Values

IGrgVault

StakingProxySet

event StakingProxySet(address stakingProxyAddress)

Emmitted whenever a StakingProxy is set in a vault.

Parameters

InCatastrophicFailureMode

event InCatastrophicFailureMode(address sender)

Emitted when the Staking contract is put into Catastrophic Failure Mode

Parameters

Deposit

event Deposit(address staker, uint256 amount)

Emitted when Grg Tokens are deposited into the vault.

Parameters

Withdraw

event Withdraw(address staker, uint256 amount)

Emitted when Grg Tokens are withdrawn from the vault.

Parameters

GrgProxySet

event GrgProxySet(address grgProxyAddress)

Emitted whenever the Grg AssetProxy is set.

Parameters

setStakingProxy

function setStakingProxy(address stakingProxyAddress) external

Sets the address of the StakingProxy contract.

Note that only the contract staker can call this function.

Parameters

enterCatastrophicFailure

function enterCatastrophicFailure() external

Vault enters into Catastrophic Failure Mode.

*** WARNING - ONCE IN CATOSTROPHIC FAILURE MODE, YOU CAN NEVER GO BACK! *** Note that only the contract staker can call this function.

setGrgProxy

function setGrgProxy(address grgProxyAddress) external

Sets the Grg proxy.

Note that only the contract staker can call this. Note that this can only be called when not in Catastrophic Failure mode.

Parameters

depositFrom

function depositFrom(address staker, uint256 amount) external

Deposit an amount of Grg Tokens from staker into the vault.

Note that only the Staking contract can call this. Note that this can only be called when not in Catastrophic Failure mode.

Parameters

withdrawFrom

function withdrawFrom(address staker, uint256 amount) external

Withdraw an amount of Grg Tokens to staker from the vault.

Note that only the Staking contract can call this. Note that this can only be called when not in Catastrophic Failure mode.

Parameters

withdrawAllFrom

function withdrawAllFrom(address staker) external returns (uint256)

Withdraw ALL Grg Tokens to staker from the vault.

Note that this can only be called when in Catastrophic Failure mode.

Parameters

balanceOf

function balanceOf(address staker) external view returns (uint256)

Returns the balance in Grg Tokens of the staker

Parameters

Return Values

balanceOfGrgVault

function balanceOfGrgVault() external view returns (uint256)

Returns the entire balance of Grg tokens in the vault.

Return Values

IStaking

addPopAddress

function addPopAddress(address addr) external

Adds a new proof_of_performance address.

Parameters

createStakingPool

function createStakingPool(address rigoblockPoolAddress) external returns (bytes32 poolId)

Create a new staking pool. The sender will be the staking pal of this pool.

Note that a staking pal must be payable. When governance updates registry address, pools must be migrated to new registry, or this contract must query from both.

Parameters

Return Values

setStakingPalAddress

function setStakingPalAddress(bytes32 poolId, address newStakingPalAddress) external

Allows the operator to update the staking pal address.

Parameters

decreaseStakingPoolOperatorShare

function decreaseStakingPoolOperatorShare(bytes32 poolId, uint32 newOperatorShare) external

Decreases the operator share for the given pool (i.e. increases pool rewards for members).

Parameters

endEpoch

function endEpoch() external returns (uint256 numPoolsToFinalize)

Begins a new epoch, preparing the prior one for finalization.

Throws if not enough time has passed between epochs or if the previous epoch was not fully finalized.

Return Values

finalizePool

function finalizePool(bytes32 poolId) external

Instantly finalizes a single pool that earned rewards in the previous epoch,

crediting it rewards for members and withdrawing operator's rewards as GRG. This can be called by internal functions that need to finalize a pool immediately. Does nothing if the pool is already finalized or did not earn rewards in the previous epoch.

Parameters

init

function init() external

Initialize storage owned by this contract.

This function should not be called directly. The StakingProxy contract will call it in attachStakingContract().

moveStake

function moveStake(struct IStructs.StakeInfo from, struct IStructs.StakeInfo to, uint256 amount) external

Moves stake between statuses: 'undelegated' or 'delegated'.

Delegated stake can also be moved between pools. This change comes into effect next epoch.

Parameters

creditPopReward

function creditPopReward(address poolAccount, uint256 popReward) external payable

Credits the value of a pool's pop reward.

Only a known RigoBlock pop can call this method. See (MixinPopManager).

Parameters

removePopAddress

function removePopAddress(address addr) external

Removes an existing proof_of_performance address.

Parameters

setParams

function setParams(uint256 _epochDurationInSeconds, uint32 _rewardDelegatedStakeWeight, uint256 _minimumPoolStake, uint32 _cobbDouglasAlphaNumerator, uint32 _cobbDouglasAlphaDenominator) external

Set all configurable parameters at once.

Parameters

stake

function stake(uint256 amount) external

Stake GRG tokens. Tokens are deposited into the GRG Vault.

Unstake to retrieve the GRG. Stake is in the 'Active' status.

Parameters

unstake

function unstake(uint256 amount) external

Unstake. Tokens are withdrawn from the GRG Vault and returned to the staker.

Stake must be in the 'undelegated' status in both the current and next epoch in order to be unstaked.

Parameters

withdrawDelegatorRewards

function withdrawDelegatorRewards(bytes32 poolId) external

Withdraws the caller's GRG rewards that have accumulated until the last epoch.

Parameters

computeRewardBalanceOfDelegator

function computeRewardBalanceOfDelegator(bytes32 poolId, address member) external view returns (uint256 reward)

Computes the reward balance in GRG of a specific member of a pool.

Parameters

Return Values

computeRewardBalanceOfOperator

function computeRewardBalanceOfOperator(bytes32 poolId) external view returns (uint256 reward)

Computes the reward balance in GRG of the operator of a pool.

Parameters

Return Values

getCurrentEpochEarliestEndTimeInSeconds

function getCurrentEpochEarliestEndTimeInSeconds() external view returns (uint256)

Returns the earliest end time in seconds of this epoch.

The next epoch can begin once this time is reached. Epoch period = [startTimeInSeconds..endTimeInSeconds)

Return Values

getGlobalStakeByStatus

function getGlobalStakeByStatus(enum IStructs.StakeStatus stakeStatus) external view returns (struct IStructs.StoredBalance balance)

Gets global stake for a given status.

Parameters

Return Values

getOwnerStakeByStatus

function getOwnerStakeByStatus(address staker, enum IStructs.StakeStatus stakeStatus) external view returns (struct IStructs.StoredBalance balance)

Gets an owner's stake balances by status.

Parameters

Return Values

getTotalStake

function getTotalStake(address staker) external view returns (uint256)

Returns the total stake for a given staker.

Parameters

Return Values

getParams

function getParams() external view returns (uint256 _epochDurationInSeconds, uint32 _rewardDelegatedStakeWeight, uint256 _minimumPoolStake, uint32 _cobbDouglasAlphaNumerator, uint32 _cobbDouglasAlphaDenominator)

Retrieves all configurable parameter values.

Return Values

getStakeDelegatedToPoolByOwner

function getStakeDelegatedToPoolByOwner(address staker, bytes32 poolId) external view returns (struct IStructs.StoredBalance balance)

Returns stake delegated to pool by staker.

Parameters

Return Values

getStakingPool

function getStakingPool(bytes32 poolId) external view returns (struct IStructs.Pool)

Returns a staking pool

Parameters

getStakingPoolStatsThisEpoch

function getStakingPoolStatsThisEpoch(bytes32 poolId) external view returns (struct IStructs.PoolStats)

Get stats on a staking pool in this epoch.

Parameters

Return Values

getTotalStakeDelegatedToPool

function getTotalStakeDelegatedToPool(bytes32 poolId) external view returns (struct IStructs.StoredBalance balance)

Returns the total stake delegated to a specific staking pool, across all members.

Parameters

Return Values

getGrgContract

function getGrgContract() external view returns (contract IRigoToken)

An overridable way to access the deployed GRG contract.

Must be view to allow overrides to access state.

Return Values

getGrgVault

function getGrgVault() external view returns (contract IGrgVault)

An overridable way to access the deployed grgVault.

Must be view to allow overrides to access state.

Return Values

getPoolRegistry

function getPoolRegistry() external view returns (contract IPoolRegistry)

An overridable way to access the deployed rigoblock pool registry.

Must be view to allow overrides to access state.

Return Values

IStakingEvents

Stake

event Stake(address staker, uint256 amount)

Emitted by MixinStake when GRG is staked.

Parameters

Unstake

event Unstake(address staker, uint256 amount)

Emitted by MixinStake when GRG is unstaked.

Parameters

MoveStake

event MoveStake(address staker, uint256 amount, uint8 fromStatus, bytes32 fromPool, uint8 toStatus, bytes32 toPool)

Emitted by MixinStake when GRG is unstaked.

Parameters

PopAdded

event PopAdded(address exchangeAddress)

Emitted by MixinExchangeManager when an exchange is added.

Parameters

PopRemoved

event PopRemoved(address exchangeAddress)

Emitted by MixinExchangeManager when an exchange is removed.

Parameters

StakingPoolEarnedRewardsInEpoch

event StakingPoolEarnedRewardsInEpoch(uint256 epoch, bytes32 poolId)

Emitted by MixinExchangeFees when a pool starts earning rewards in an epoch.

Parameters

EpochEnded

event EpochEnded(uint256 epoch, uint256 numPoolsToFinalize, uint256 rewardsAvailable, uint256 totalFeesCollected, uint256 totalWeightedStake)

Emitted by MixinFinalizer when an epoch has ended.

Parameters

EpochFinalized

event EpochFinalized(uint256 epoch, uint256 rewardsPaid, uint256 rewardsRemaining)

Emitted by MixinFinalizer when an epoch is fully finalized.

Parameters

RewardsPaid

event RewardsPaid(uint256 epoch, bytes32 poolId, uint256 operatorReward, uint256 membersReward)

Emitted by MixinFinalizer when rewards are paid out to a pool.

Parameters

ParamsSet

event ParamsSet(uint256 epochDurationInSeconds, uint32 rewardDelegatedStakeWeight, uint256 minimumPoolStake, uint256 cobbDouglasAlphaNumerator, uint256 cobbDouglasAlphaDenominator)

Emitted whenever staking parameters are changed via the setParams() function.

Parameters

StakingPoolCreated

event StakingPoolCreated(bytes32 poolId, address operator, uint32 operatorShare)

Emitted by MixinStakingPool when a new pool is created.

Parameters

RbPoolStakingPoolSet

event RbPoolStakingPoolSet(address rbPoolAddress, bytes32 poolId)

Emitted by MixinStakingPool when a rigoblock pool is added to its staking pool.

Parameters

OperatorShareDecreased

event OperatorShareDecreased(bytes32 poolId, uint32 oldOperatorShare, uint32 newOperatorShare)

Emitted when a staking pool's operator share is decreased.

Parameters

GrgMintEvent

event GrgMintEvent(uint256 grgAmount)

Emitted when an inflation mint call is executed successfully.

Parameters

CatchStringEvent

event CatchStringEvent(string reason)

Emitted whenever an inflation mint call is reverted.

Parameters

ReturnDataEvent

event ReturnDataEvent(bytes reason)

Emitted to catch any other inflation mint call fail.

Parameters

IStakingProxy

StakingContractAttachedToProxy

event StakingContractAttachedToProxy(address newStakingContractAddress)

Emitted by StakingProxy when a staking contract is attached.

Parameters

StakingContractDetachedFromProxy

event StakingContractDetachedFromProxy()

Emitted by StakingProxy when a staking contract is detached.

attachStakingContract

function attachStakingContract(address stakingImplementation) external

Attach a staking contract; future calls will be delegated to the staking contract.

Note that this is callable only by an authorized address.

Parameters

detachStakingContract

function detachStakingContract() external

Detach the current staking contract.

Note that this is callable only by an authorized address.

batchExecute

function batchExecute(bytes[] data) external returns (bytes[] batchReturnData)

Batch executes a series of calls to the staking contract.

Parameters

assertValidStorageParams

function assertValidStorageParams() external view

Asserts initialziation parameters are correct.

Asserts that an epoch is between 5 and 30 days long. Asserts that 0 < cobb douglas alpha value <= 1. Asserts that a stake weight is <= 100%. Asserts that pools allow >= 1 maker. Asserts that all addresses are initialized.

IStorage

stakingContract

function stakingContract() external view returns (address)

Address of staking contract.

Return Values

poolIdByRbPoolAccount

function poolIdByRbPoolAccount(address) external view returns (bytes32)

Mapping from RigoBlock pool subaccount to pool Id of rigoblock pool

0 RigoBlock pool subaccount address.

Return Values

rewardsByPoolId

function rewardsByPoolId(bytes32) external view returns (uint256)

mapping from pool ID to reward balance of members

0 Pool ID.

Return Values

currentEpoch

function currentEpoch() external view returns (uint256)

The current epoch.

Return Values

currentEpochStartTimeInSeconds

function currentEpochStartTimeInSeconds() external view returns (uint256)

The current epoch start time.

Return Values

validPops

function validPops(address popAddress) external view returns (bool)

Registered RigoBlock Proof_of_Performance contracts, capable of paying protocol fees.

0 The address to check.

Return Values

epochDurationInSeconds

function epochDurationInSeconds() external view returns (uint256)

Minimum seconds between epochs.

Return Values

rewardDelegatedStakeWeight

function rewardDelegatedStakeWeight() external view returns (uint32)

Return Values

minimumPoolStake

function minimumPoolStake() external view returns (uint256)

Minimum amount of stake required in a pool to collect rewards.

Return Values

cobbDouglasAlphaNumerator

function cobbDouglasAlphaNumerator() external view returns (uint32)

Numerator for cobb douglas alpha factor.

Return Values

cobbDouglasAlphaDenominator

function cobbDouglasAlphaDenominator() external view returns (uint32)

Denominator for cobb douglas alpha factor.

Return Values

poolStatsByEpoch

function poolStatsByEpoch(bytes32 key, uint256 epoch) external view returns (uint256 feesCollected, uint256 weightedStake, uint256 membersStake)

Stats for each pool that generated fees with sufficient stake to earn rewards.

See _minimumPoolStake in MixinParams.

Parameters

Return Values

aggregatedStatsByEpoch

function aggregatedStatsByEpoch(uint256 epoch) external view returns (uint256 rewardsAvailable, uint256 numPoolsToFinalize, uint256 totalFeesCollected, uint256 totalWeightedStake, uint256 totalRewardsFinalized)

Aggregated stats across all pools that generated fees with sufficient stake to earn rewards.

See _minimumPoolStake in MixinParams.

Parameters

Return Values

grgReservedForPoolRewards

function grgReservedForPoolRewards() external view returns (uint256)

The GRG balance of this contract that is reserved for pool reward payouts.

Return Values

IStorageInit

init

function init() external

Initialize storage owned by this contract.

IStructs

PoolStats

struct PoolStats {
  uint256 feesCollected;
  uint256 weightedStake;
  uint256 membersStake;
}

AggregatedStats

struct AggregatedStats {
  uint256 rewardsAvailable;
  uint256 numPoolsToFinalize;
  uint256 totalFeesCollected;
  uint256 totalWeightedStake;
  uint256 totalRewardsFinalized;
}

StoredBalance

struct StoredBalance {
  uint64 currentEpoch;
  uint96 currentEpochBalance;
  uint96 nextEpochBalance;
}

StakeStatus

enum StakeStatus {
  UNDELEGATED,
  DELEGATED
}

StakeInfo

struct StakeInfo {
  enum IStructs.StakeStatus status;
  bytes32 poolId;
}

Fraction

struct Fraction {
  uint256 numerator;
  uint256 denominator;
}

Pool

struct Pool {
  address operator;
  address stakingPal;
  uint32 operatorShare;
  uint32 stakingPalShare;
}

LibCobbDouglas

cobbDouglas

function cobbDouglas(uint256 totalRewards, uint256 fees, uint256 totalFees, uint256 stake, uint256 totalStake, uint32 alphaNumerator, uint32 alphaDenominator) internal pure returns (uint256 rewards)

The cobb-douglas function used to compute fee-based rewards for staking pools in a given epoch. This function does not perform bounds checking on the inputs, but the following conditions need to be true: 0 <= fees / totalFees <= 1 0 <= stake / totalStake <= 1 0 <= alphaNumerator / alphaDenominator <= 1

Parameters

Return Values

LibFixedMath

Signed, fixed-point, 127-bit precision math library.

FIXED_1

int256 FIXED_1

MIN_FIXED_VAL

int256 MIN_FIXED_VAL

FIXED_1_SQUARED

int256 FIXED_1_SQUARED

LN_MAX_VAL

int256 LN_MAX_VAL

LN_MIN_VAL

int256 LN_MIN_VAL

EXP_MAX_VAL

int256 EXP_MAX_VAL

EXP_MIN_VAL

int256 EXP_MIN_VAL

mul

function mul(int256 a, int256 b) internal pure returns (int256 c)

Returns the multiplication of two fixed point numbers, reverting on overflow.

div

function div(int256 a, int256 b) internal pure returns (int256 c)

Returns the division of two fixed point numbers.

mulDiv

function mulDiv(int256 a, int256 n, int256 d) internal pure returns (int256 c)

Performs (a * n) / d, without scaling for precision.

uintMul

function uintMul(int256 f, uint256 u) internal pure returns (uint256)

Returns the unsigned integer result of multiplying a fixed-point number with an integer, reverting if the multiplication overflows. Negative results are clamped to zero.

toFixed

function toFixed(uint256 n, uint256 d) internal pure returns (int256 f)

Convert unsigned n / d to a fixed-point number. Reverts if n / d is too large to fit in a fixed-point number.

ln

function ln(int256 x) internal pure returns (int256 r)

Get the natural logarithm of a fixed-point number 0 < x <= LN_MAX_VAL

exp

function exp(int256 x) internal pure returns (int256 r)

Compute the natural exponent for a fixed-point number EXP_MIN_VAL <= x <= 1

_mul

function _mul(int256 a, int256 b) private pure returns (int256 c)

Returns the multiplication two numbers, reverting on overflow.

_div

function _div(int256 a, int256 b) private pure returns (int256 c)

Returns the division of two numbers, reverting on division by zero.

LibSafeDowncast

downcastToUint96

function downcastToUint96(uint256 a) internal pure returns (uint96 b)

Safely downcasts to a uint96 Note that this reverts if the input value is too large.

downcastToUint64

function downcastToUint64(uint256 a) internal pure returns (uint64 b)

Safely downcasts to a uint64 Note that this reverts if the input value is too large.

MixinPopManager

addPopAddress

function addPopAddress(address addr) external

Adds a new proof_of_performance address.

Parameters

removePopAddress

function removePopAddress(address addr) external

Removes an existing proof_of_performance address.

Parameters

MixinPopRewards

onlyPop

modifier onlyPop()

Asserts that the call is coming from a valid pop.

creditPopReward

function creditPopReward(address poolAccount, uint256 popReward) external payable

Credits the value of a pool's pop reward.

Only a known RigoBlock pop can call this method. See (MixinPopManager).

Parameters

getStakingPoolStatsThisEpoch

function getStakingPoolStatsThisEpoch(bytes32 poolId) external view returns (struct IStructs.PoolStats)

Get stats on a staking pool in this epoch.

Parameters

Return Values

_computeMembersAndWeightedStake

function _computeMembersAndWeightedStake(bytes32 poolId, uint256 totalStake) private view returns (uint256 membersStake, uint256 weightedStake)

Computes the members and weighted stake for a pool at the current epoch.

Parameters

Return Values

MixinStake

stake

function stake(uint256 amount) external

Stake GRG tokens. Tokens are deposited into the GRG Vault.

Unstake to retrieve the GRG. Stake is in the 'Active' status.

Parameters

unstake

function unstake(uint256 amount) external

Unstake. Tokens are withdrawn from the GRG Vault and returned to the staker.

Stake must be in the 'undelegated' status in both the current and next epoch in order to be unstaked.

Parameters

moveStake

function moveStake(struct IStructs.StakeInfo from, struct IStructs.StakeInfo to, uint256 amount) external

Moves stake between statuses: 'undelegated' or 'delegated'.

Delegated stake can also be moved between pools. This change comes into effect next epoch.

Parameters

_delegateStake

function _delegateStake(bytes32 poolId, address staker, uint256 amount) private

Delegates a owners stake to a staking pool.

Parameters

_undelegateStake

function _undelegateStake(bytes32 poolId, address staker, uint256 amount) private

Un-Delegates a owners stake from a staking pool.

Parameters

MixinStakeBalances

getGlobalStakeByStatus

function getGlobalStakeByStatus(enum IStructs.StakeStatus stakeStatus) external view returns (struct IStructs.StoredBalance balance)

Gets global stake for a given status.

Parameters

Return Values

getOwnerStakeByStatus

function getOwnerStakeByStatus(address staker, enum IStructs.StakeStatus stakeStatus) external view returns (struct IStructs.StoredBalance balance)

Gets an owner's stake balances by status.

Parameters

Return Values

getTotalStake

function getTotalStake(address staker) public view returns (uint256)

Returns the total stake for a given staker.

Parameters

Return Values

getStakeDelegatedToPoolByOwner

function getStakeDelegatedToPoolByOwner(address staker, bytes32 poolId) public view returns (struct IStructs.StoredBalance balance)

Returns stake delegated to pool by staker.

Parameters

Return Values

getTotalStakeDelegatedToPool

function getTotalStakeDelegatedToPool(bytes32 poolId) public view returns (struct IStructs.StoredBalance balance)

Returns the total stake delegated to a specific staking pool, across all members.

Parameters

Return Values

MixinStakeStorage

This mixin contains logic for managing stake storage.

_moveStake

function _moveStake(struct IStructs.StoredBalance fromPtr, struct IStructs.StoredBalance toPtr, uint256 amount) internal

Moves stake between states: 'undelegated' or 'delegated'. This change comes into effect next epoch.

Parameters

_loadCurrentBalance

function _loadCurrentBalance(struct IStructs.StoredBalance balancePtr) internal view returns (struct IStructs.StoredBalance balance)

Loads a balance from storage and updates its fields to reflect values for the current epoch.

Parameters

Return Values

_increaseCurrentAndNextBalance

function _increaseCurrentAndNextBalance(struct IStructs.StoredBalance balancePtr, uint256 amount) internal

Increments both the current and next fields.

Parameters

_decreaseCurrentAndNextBalance

function _decreaseCurrentAndNextBalance(struct IStructs.StoredBalance balancePtr, uint256 amount) internal

Decrements both the current and next fields.

Parameters

_increaseNextBalance

function _increaseNextBalance(struct IStructs.StoredBalance balancePtr, uint256 amount) internal

Increments the next field (but not the current field).

Parameters

_decreaseNextBalance

function _decreaseNextBalance(struct IStructs.StoredBalance balancePtr, uint256 amount) internal

Decrements the next field (but not the current field).

Parameters

_storeBalance

function _storeBalance(struct IStructs.StoredBalance balancePtr, struct IStructs.StoredBalance balance) private

Stores a balance in storage.

Parameters

_arePointersEqual

function _arePointersEqual(struct IStructs.StoredBalance balancePtrA, struct IStructs.StoredBalance balancePtrB) private pure returns (bool areEqual)

Returns true iff storage pointers resolve to same storage location.

Parameters

Return Values

MixinCumulativeRewards

_isCumulativeRewardSet

function _isCumulativeRewardSet(struct IStructs.Fraction cumulativeReward) internal pure returns (bool)

returns true iff Cumulative Rewards are set

_addCumulativeReward

function _addCumulativeReward(bytes32 poolId, uint256 reward, uint256 stake) internal

Sets a pool's cumulative delegator rewards for the current epoch, given the rewards earned and stake from the last epoch, which will be summed with the previous cumulative rewards for this pool. If the last cumulative reward epoch is the current epoch, this is a no-op.

Parameters

_updateCumulativeReward

function _updateCumulativeReward(bytes32 poolId) internal

Sets a pool's cumulative delegator rewards for the current epoch, using the last stored cumulative rewards. If we've already set a CR for this epoch, this is a no-op.

Parameters

_computeMemberRewardOverInterval

function _computeMemberRewardOverInterval(bytes32 poolId, uint256 memberStakeOverInterval, uint256 beginEpoch, uint256 endEpoch) internal view returns (uint256 reward)

Computes a member's reward over a given epoch interval.

Parameters

Return Values

_getCumulativeRewardAtEpoch

function _getCumulativeRewardAtEpoch(bytes32 poolId, uint256 epoch) private view returns (struct IStructs.Fraction cumulativeReward)

Fetch the cumulative reward for a given epoch. If the corresponding CR does not exist in state, then we backtrack to find its value by querying epoch-1 and then most recent CR.

Parameters

Return Values

MixinStakingPool

onlyStakingPoolOperator

modifier onlyStakingPoolOperator(bytes32 poolId)

Asserts that the sender is the operator of the input pool.

Parameters

onlyDelegateCall