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

function token() external view returns (address)

Return Values

priorityPool

Returns the address of the priority pool for this pool

function priorityPool() external view returns (address)

Return Values

totalShares

Returns the total amount of shares in the pool

function totalShares() external view returns (uint256)

Return Values

sharesOf

Returns the amount of shares owned by an account

function sharesOf(address _account) public view returns (uint256)

Parameters

Return Values

getSharesByStake

Returns the amount of shares that corresponds to an amount of stake

function getSharesByStake(uint256 _amount) public view returns (uint256)

Parameters

Return Values

getStakeByShares

Returns the amount of stake that corresponds to an amount of shares

function getStakeByShares(uint256 _amount) public view returns (uint256)

Parameters

Return Values

totalStaked

Returns the total amount of tokens in the pool

function totalStaked() external view returns (uint256)

Return Values

getStrategies

Returns a list of all active strategies

function getStrategies() external view returns (address[])

Return Values

getFees

Returns a list of all fees

function getFees() external view returns (struct StakingPool.Fee[])

Return Values

getMaxDeposits

Returns the maximum amount that can be deposited into the pool

function getMaxDeposits() public view returns (uint256)

Return Values

getMinDeposits

Returns the minimum amount that must remain the pool

function getMinDeposits() public view returns (uint256)

Return Values

getUnusedDeposits

Returns the amount of tokens in the pool that are not deposited into a strategy

function getUnusedDeposits() external view returns (uint256)

Return Values

getStrategyDepositRoom

Returns the available deposit room for this pool's strategies

function getStrategyDepositRoom() external view returns (uint256)

Return Values

canDeposit

Returns the available deposit room in the pool

function canDeposit() external view returns (uint256)

Return Values

canWithdraw

Returns the available withdrawal room in the pool

function canWithdraw() external view returns (uint256)

Return Values

getStrategyRewards

Returns the amount of rewards earned since the last update and the amount of fees that will be paid on the rewards

function getStrategyRewards(uint256[] _strategyIdxs) external view returns (int256, uint256)

Parameters

Return Values

Write Functions

deposit

Deposits staking tokens and mints liquid staking tokens

function deposit(address _account, uint256 _amount) external

Parameters

withdraw

Withdraws staking tokens and burns liquid staking tokens

function withdraw(address _account, address _receiver, uint256 _amount) external

Parameters

transferAndCall

Transfers tokens to an address and calls onTokenTransfer with additional data if the recipient is a contract

function transferAndCall(address _to, uint256 _value, bytes _data) external returns (bool)

Parameters

strategyDeposit

Deposits tokens into a strategy

function strategyDeposit(uint256 _index, uint256 _amount) external

Parameters

strategyWithdraw

Withdraws tokens from a strategy

function strategyWithdraw(uint256 _index, uint256 _amount) external

Parameters

addStrategy

Adds a new strategy

function addStrategy(address _strategy) external

Parameters

removeStrategy

Removes a strategy

function removeStrategy(uint256 _index, bytes _strategyUpdateData) external

Parameters

reorderStrategies

Reorders strategies

function reorderStrategies(uint256[] _newOrder) external

Parameters

addFee

Adds a new fee

function addFee(address _receiver, uint256 _feeBasisPoints) external

Parameters

updateFee

Updates an existing fee

function updateFee(uint256 _index, address _receiver, uint256 _feeBasisPoints) external

Parameters

updateStrategyRewards

Updates and distributes rewards based on balance changes in strategies

function updateStrategyRewards(uint256[] _strategyIdxs, bytes _data) public

Parameters

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

function depositLiquidity() public

transferShares

Transfers shares from the sender to another account

function transferShares(address _receipient, uint256 _sharesAmount) external

Parameters

transferShares

Transfers shares between accounts

function transferSharesFrom(address _sender, address _receipient, uint256 _sharesAmount) external

Parameters

setPriorityPool

Sets the address of the priority pool

function setPriorityPool(address _priorityPool) external

Parameters

Last updated