Staking Pool
StakingPool
is one of the most important pieces of the protocol as it handles the liquid staking of tokens. When a user stakes some amount of tokens (such as LINK), they receive liquid staking tokens (such as stLINK) at a 1:1 ratio. These liquid staking tokens represent a userโs staked balance and must be burned to withdraw the underlying tokens they represent.
Once tokens have been staked into the pool, they are deposited into one or more strategy contracts controlled by the pool. These strategies then take the deposited tokens and use them to earn rewards which are distributed to stakers.
In the case of LINK staking, the tokens are deposited into the Chainlink staking contracts.
The liquid staking token issued by StakingPool
is a rebasing token so rewards will be automatically distributed to stakers without any action on their part. This is possible by using a โsharesโ accounting model where a share represents a certain percentage ownership of the pool. When a user stakes, they receive a number of shares determined by the ratio of total shares to total tokens in the pool. The amount of shares a user owns remains constant unless they stake or withdraw but the ratio of total shares to total tokens changes with each rebase so their shares will be worth more tokens after each rebase. The new token value of their shares will be automatically reflected in their token balance.
While unlikely, it is also possible for a rebase to be negative if strategies earned net negative rewards since the last rebase due to slashing penalties. In this case, each share will be worth less tokens so a userโs token balance will decrease.
ERC20 Functions
All standard ERC20 functions are implemented for StakingPool
View Functions
token
Returns the staking token for the pool
Return Values
Name | Type | Description |
---|---|---|
token | address | Address of staking token |
priorityPool
Returns the address of the priority pool for this pool
Return Values
Name | Type | Description |
---|---|---|
priorityPool | address | address of priority pool |
totalShares
Returns the total amount of shares in the pool
Return Values
Name | Type | Description |
---|---|---|
sharesAmount | uint256 | Total shares in the pool |
sharesOf
Returns the amount of shares owned by an account
Parameters
Name | Type | Description |
---|---|---|
_account | address | Address of account |
Return Values
Name | Type | Description |
---|---|---|
sharesBalance | uint256 | Total shares owned by account |
getSharesByStake
Returns the amount of shares that corresponds to an amount of stake
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | Amount of stake |
Return Values
Name | Type | Description |
---|---|---|
sharesAmount | uint256 | Corresponding amount of shares |
getStakeByShares
Returns the amount of stake that corresponds to an amount of shares
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | Amount of shares |
Return Values
Name | Type | Description |
---|---|---|
stakeAmount | uint256 | Corresponding amount of stake |
totalStaked
Returns the total amount of tokens in the pool
Return Values
Name | Type | Description |
---|---|---|
stakedAmount | uint256 | Total tokens in the pool |
getStrategies
Returns a list of all active strategies
Return Values
Name | Type | Description |
---|---|---|
strategies | address[] | List of strategy contract addresses |
getFees
Returns a list of all fees
Return Values
Name | Type | Description |
---|---|---|
fees | struct Fee[] | list of fees |
getMaxDeposits
Returns the maximum amount that can be deposited into the pool
Return Values
Name | Type | Description |
---|---|---|
maxDeposits | uint256 | maximum deposit limit |
getMinDeposits
Returns the minimum amount that must remain the pool
Return Values
Name | Type | Description |
---|---|---|
minDeposits | uint256 | minimum deposit limit |
getUnusedDeposits
Returns the amount of tokens in the pool that are not deposited into a strategy
Return Values
Name | Type | Description |
---|---|---|
unusedDeposits | uint256 | amount of deposits outside a strategy |
getStrategyDepositRoom
Returns the available deposit room for this pool's strategies
Return Values
Name | Type | Description |
---|---|---|
strategyDepositRoom | uint256 | available deposit room in strategies |
canDeposit
Returns the available deposit room in the pool
Return Values
Name | Type | Description |
---|---|---|
canDeposit | uint256 | available deposit room |
canWithdraw
Returns the available withdrawal room in the pool
Return Values
Name | Type | Description |
---|---|---|
canWithdraw | uint256 | available withdrawal room |
getStrategyRewards
Returns the amount of rewards earned since the last update and the amount of fees that will be paid on the rewards
Parameters
Name | Type | Description |
---|---|---|
_strategyIdxs | uint256[] | Indexes of strategies to sum rewards/fees for |
Return Values
Name | Type | Description |
---|---|---|
rewards | int256 | Total rewards |
fees | uint256 | Total fees |
Write Functions
deposit
Deposits staking tokens and mints liquid staking tokens
Parameters
Name | Type | Description |
---|---|---|
_account | address | address of account to stake for |
_amount | uint256 | amount to stake |
withdraw
Withdraws staking tokens and burns liquid staking tokens
Parameters
Name | Type | Description |
---|---|---|
_account | address | Address of account to withdraw for |
_receiver | address | Address to receive withdrawal |
_amount | uint256 | Amount to withdraw |
transferAndCall
Transfers tokens to an address and calls onTokenTransfer
with additional data if the recipient is a contract
Parameters
Name | Type | Description |
---|---|---|
_to | address | Address to send the tokens to |
_value | uint256 | Value of token transfer |
_data | bytes | Calldata included in the transfer |
strategyDeposit
Deposits tokens into a strategy
Parameters
Name | Type | Description |
---|---|---|
_index | uint256 | Index of strategy |
_amount | uint256 | Amount to deposit |
strategyWithdraw
Withdraws tokens from a strategy
Parameters
Name | Type | Description |
---|---|---|
_index | uint256 | Index of strategy |
_amount | uint256 | Amount to withdraw |
addStrategy
Adds a new strategy
Parameters
Name | Type | Description |
---|---|---|
_strategy | address | Address of strategy contract |
removeStrategy
Removes a strategy
Parameters
Name | Type | Description |
---|---|---|
_index | uint256 | Index of strategy |
_strategyUpdateData | bytes | optional data to pass to updateStrategyRewards |
reorderStrategies
Reorders strategies
Parameters
Name | Type | Description |
---|---|---|
_newOrder | uint256[] | List containing strategy indexes in a new order |
addFee
Adds a new fee
Parameters
Name | Type | Description |
---|---|---|
_receiver | address | Address of fee receiver |
_feeBasisPoints | uint256 | Fee in basis points |
updateFee
Updates an existing fee
Parameters
Name | Type | Description |
---|---|---|
_index | uint256 | Index of fee |
_receiver | address | Address of fee receiver |
_feeBasisPoints | uint256 | Fee in basis points |
updateStrategyRewards
Updates and distributes rewards based on balance changes in strategies
Parameters
Name | Type | Description |
---|---|---|
_strategyIdxs | uint256[] | Indexes of strategies to update rewards for |
_data | bytes | optional encoded data to be passed to each strategy |
depositLiquidity
Deposits available liquidity into strategies by order of priority
Deposits into strategies[0] until its limit is reached, then strategies[1], and so on
transferShares
Transfers shares from the sender to another account
Parameters
Name | Type | Description |
---|---|---|
_receipient | address | account to transfer shares to |
_sharesAmount | uint256 | amount of shares to transfer |
transferShares
Transfers shares between accounts
Parameters
Name | Type | Description |
---|---|---|
_sender | address | account to transfer shares from |
_receipient | address | account to transfer shares to |
_sharesAmount | uint256 | amount of shares to transfer |
setPriorityPool
Sets the address of the priority pool
Parameters
Name | Type | Description |
---|---|---|
_priorityPool | address | address of priority pool |
Last updated