ERC-900 Simple Staking Interface

Stagnant · Vaults & DeFi · created 2018-02-22

Defines the process of depositing (staking) tokens into a contract, and querying and releasing them, with common functions and events, so that different staking systems can be handled the same way.

Why it is needed

Applications that use staking, such as token curated registries, are increasing, but when each contract defines its own function names and event formats, wallets and other services have to redo integration work every time. Without a standard way to query how much a given address has staked, or how much was staked at a given past point in time, each service has to implement it separately, making it hard to reuse and forcing users to learn different usage for each service.

What to implement

In depth

Difference between stake and stakeFor

stake transfers and stakes the caller's own tokens. stakeFor stakes on behalf of another address (user) specified by the caller, but the tokens transferred come from the caller. Both functions accept a data field, which the source text explains can be used to add signalling information for more complex staking applications. Both functions must emit a Staked event when called.

Conditions for unstake's return

unstake releases the specified amount from staking. The source text states that tokens should be returned to the user, but if unstaking is currently not possible, the transaction must revert. The data field can be used to remove signalling information that was added at stake time. An Unstaked event must be emitted when called.

Query functions: totalStakedFor, totalStaked, token

totalStakedFor(addr) returns the total amount currently staked by a specific address, and totalStaked() returns the current total amount staked across the entire contract. token() returns the address of the token contract that this staking interface handles.

supportsHistory and the optional history functions

On the premise that not every staking system needs a complete historical record, the three functions lastStakedFor, totalStakedForAt, and totalStakedAt are OPTIONAL. supportsHistory() must accurately report true or false as to whether these three functions are implemented. lastStakedFor returns the block number at which the given address last staked, totalStakedForAt returns the total amount staked by a specific address at a specific block, and totalStakedAt returns the total amount staked across all addresses at a specific block.

Proposal status: Stagnant

This proposal was written in February 2018 and is currently in Stagnant status. In other words, it is a proposal where discussion has stopped progressing, and it may never be revised or formally adopted.

Original ERC · ← ERCs