The following standard describes a common staking interface allowing for easy to use staking systems. The interface is kept simple allowing for various use cases to be implemented. This standard describes the common functionality for staking as well as providing information on stakes.
Motivation
As we move to more token models, having a common staking interface which is familiar to users can be useful. The common interface can be used by a variety of applications, this common interface could be beneficial especially to things like Token curated registries which have recently gained popularity.
Stakes a certain amount of tokens, this MUST transfer the given amount from the user.
The data field can be used to add signalling information in more complex staking applications
MUST trigger Staked event.
stakeFor
Stakes a certain amount of tokens, this MUST transfer the given amount from the caller.
The data field can be used to add signalling information in more complex staking applications
MUST trigger Staked event.
unstake
Unstakes a certain amount of tokens, this SHOULD return the given amount of tokens to the user, if unstaking is currently not possible the function MUST revert.
The data field can be used to remove signalling information in more complex staking applications
MUST trigger Unstaked event.
totalStakedFor
Returns the current total of tokens staked for an address.
totalStaked
Returns the current total of tokens staked.
token
Address of the token being used by the staking interface.
supportsHistory
MUST return true if the optional history functions are implemented, otherwise false.
lastStakedFor
OPTIONAL: As not all staking systems require a complete history, this function is optional.
Returns last block address staked at.
totalStakedForAt
OPTIONAL: As not all staking systems require a complete history, this function is optional.
Returns total amount of tokens staked at block for address.
totalStakedAt
OPTIONAL: As not all staking systems require a complete history, this function is optional.