Priority Pool

The PriorityPool allows users to queue asset tokens which are eventually deposited into a StakingPool when deposit room becomes available. The liquid staking tokens (LSTs) minted by the StakingPool are then distributed using a merkle tree.

Each user will continuously receive LSTs as more depositd are made into the StakingPool until they have received an amount equal to the amount of asset tokens they deposited into the PriorityPool. The rate at which each user receives LSTs is dependent on the user's reSDL balance in the SDLPool. A higher reSDL balance entitles the user to receive LSTs at a faster rate than a user with a smaller reSDL balance. Users that hold no reSDL can also deposit into the PriorityPool but they will receive no LSTs as long as there are users with deposits in the PriorityPool that also hold reSDL.

The secondary function of the PriorityPool is to act as a liquidity buffer for the StakingPool it deposits into. When a user redeems LSTs for the underlying asset token, these LSTs will be swapped with queued asset tokens from the PriorityPool if possible before withdrawing tokens from the StakingPool. This both reduces gas costs for the user and ensures that the StakingPool earns the most yield possible as yield earning asset tokens remain in the pool instead of being withdrawn.

View Functions

token

Returns the address of the token this pool handles

function token() external view returns (address)

Return Values

NameTypeDescription

token

address

address of token

stakingPool

Returns the address of the staking pool that this pool deposits into

function stakingPool() external view returns (address)

Return Values

NameTypeDescription

stakingPool

address

address of staking pool

sdlPool

Returns the address of the SDL pool

function sdlPool() external view returns (address)

Return Values

NameTypeDescription

sdlPool

address

address of SDL pool

distributionOracle

Returns the address of the oracle that handles distribution of liquid staking tokens

function distributionOracle() external view returns (address)

Return Values

NameTypeDescription

distributionOracle

address

address of distribution oracle

queueDepositMin

Returns the minimum amount of tokens required to execute a deposit

function queueDepositMin() external view returns (uint256)

Return Values

NameTypeDescription

depositMin

uint256

queue deposit minimum

queueDepositMax

Returns the maximum amount of tokens that can be deposited in a single deposit

function queueDepositMax() external view returns (uint256)

Return Values

NameTypeDescription

depositMax

uint256

queue deposit maximum

poolStatus

Returns the current status of the pool

0 - OPEN (nothing disabled) 1 - DRAINING (deposits disabled) 2 - CLOSED (deposits/withdrawals disabled)

function poolStatus() external view returns (PoolStatus)

Return Values

NameTypeDescription

poolStatus

PoolStatus

current status of the pool

merkleRoot

Returns the merkle root for the latest distribution tree

function merkleRoot() external view returns (bytes32)

Return Values

NameTypeDescription

merkleRoot

bytes32

current merkle root

ipfsHash

Returns the ipfs hash of the balance data for the latest distribution tree

function ipfsHash() external view returns (bytes32)

Return Values

NameTypeDescription

ipfsHash

bytes32

current ipfsHash

merkleTreeSize

Returns the number of unique addresses contained in the latest distribution tree

function merkleTreeSize() external view returns (uint256)

Return Values

NameTypeDescription

merkleTreeSize

uint256

current merkle tree size

totalQueued

Returns the total amount of token deposits in the pool waiting to be deposited into the staking pool

function totalQueued() external view returns (uint256)

Return Values

NameTypeDescription

totalQueued

uint256

total deposits in the pool

getAccounts

Returns a list of all accounts that have deposited into the pool in the order that they appear in the distribution tree

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

Return Values

NameTypeDescription

accounts

address[]

list of accounts

getAccountIndex

Returns the index of an account representing it's position in the distribution tree

function getAccountIndex(address _account) external view returns (uint256)

Parameters

NameTypeDescription

_account

address

account address

Return Values

NameTypeDescription

index

uint256

account index

getQueuedTokens

Returns an account's current amount of deposits in the pool (_distributionAmount is stored on IPFS)

function getQueuedTokens(address _account, uint256 _distributionAmount) public view returns (uint256)

Parameters

NameTypeDescription

_account

address

account address

_distributionAmount

uint256

account's distribution amount from the latest distribution tree

Return Values

NameTypeDescription

queuedTokens

uint256

amount of queued tokens for account

getLSDTokens

Returns an account's current amount of withdrawable liquid staking tokens (_distributionShareAmount is stored on IPFS)

function getLSDTokens(address _account, uint256 _distributionShareAmount) external view returns (uint256)

Parameters

NameTypeDescription

_account

address

account address

_distributionShareAmount

uint256

account's distribution share amounts from the latest distribution tree

Return Values

NameTypeDescription

lsdTokens

uint256

withdrawable LSD tokens for account

canWithdraw

Returns the total amount of asset tokens that an account can withdraw (includes account's queued tokens and stLINK balance and takes into account both priority pool and staking pool liquidity)

function canWithdraw(address _account, uint256 _distributionAmount) external view returns (uint256)

Parameters

NameTypeDescription

_account

address

account address

_distributionAmount

uint256

account's distribution amount from the latest distribution tree

Return Values

NameTypeDescription

canWithdraw

uint256

amount of withrawable tokens

checkUpkeep

Returns whether a call should be made to performUpkeep to deposit queued/unused tokens into the staking pool

function checkUpkeep(bytes) external view returns (bool, bytes)

Return Values

NameTypeDescription

upkeepNeeded

bool

whether a call should be made to performUpkeep

getDepositsSinceLastUpdate

Returns the amount of deposits since the last call to updateDistribution and the amount of shares received for those deposits

function getDepositsSinceLastUpdate() external view returns (uint256, uint256)

Return Values

NameTypeDescription

deposits

uint256

amount of deposits

shares

uint256

amount of shares

getAccountData

Returns account data used for calculating a new merkle tree (a new merkle tree is calculated based on users' reSDL balance and the number of tokens they have queued)

function getAccountData() external view returns (address[], uint256[], uint256[])

Return Values

NameTypeDescription

accounts

address[]

list of all accounts that have ever queued tokens

sdlBalances

uint256[]

list of SDL balances for each account

queuedBalances

uint256[]

list of queued token amounts for each account (ignores distributed LSD tokens)

Write Functions

onTokenTransfer

ERC677 implementation to receive a token deposit or withdrawal

function onTokenTransfer(address _sender, uint256 _value, bytes _calldata) external

Parameters

NameTypeDescription

_sender

address

sender of the transfer

_value

uint256

value of the transfer

_calldata

bytes

encoded shouldQueue (whether tokens should be queued)

deposit

Deposits asset tokens into the staking pool and/or priority pool

function deposit(uint256 _amount, bool _shouldQueue) external

Parameters

NameTypeDescription

_amount

uint256

amount to deposit

_shouldQueue

bool

whether tokens should be queued if there's no room in the staking pool

withdraw

Withdraws asset tokens by withdrawing deposits from the priority pool and/or staking pool

function withdraw(uint256 _amountToWithdraw, uint256 _amount, uint256 _sharesAmount, bytes32[] _merkleProof, bool _shouldUnqueue) external

Parameters

NameTypeDescription

_amountToWithdraw

uint256

amount of tokens to withdraw

_amount

uint256

amount as recorded in sender's merkle tree entry

_sharesAmount

uint256

shares amount as recorded in sender's merkle tree entry

_merkleProof

bytes32[]

merkle proof for sender's merkle tree entry

_shouldUnqueue

bool

whether tokens should be unqueued before taking LSD tokens

unqueueTokens

Withdraws queued deposits from the priority pool

function unqueueTokens(uint256 _amountToUnqueue, uint256 _amount, uint256 _sharesAmount, bytes32[] _merkleProof) external

Parameters

NameTypeDescription

_amountToUnqueue

uint256

amount of tokens to unqueue

_amount

uint256

amount as recorded in sender's merkle tree entry

_sharesAmount

uint256

shares amount as recorded in sender's merkle tree entry

_merkleProof

bytes32[]

merkle proof for sender's merkle tree entry

claimLSDTokens

Claims withdrawable LSD tokens

function claimLSDTokens(uint256 _amount, uint256 _sharesAmount, bytes32[] _merkleProof) external

Parameters

NameTypeDescription

_amount

uint256

amount as recorded in sender's merkle tree entry

_sharesAmount

uint256

shares amount as recorded in sender's merkle tree entry

_merkleProof

bytes32[]

merkle proof for sender's merkle tree entry

depositQueuedTokens

Deposits queued and/or unused tokens

function depositQueuedTokens(uint256 _queueDepositMin, uint256 _queueDepositMax) external

Parameters

NameTypeDescription

_queueDepositMin

uint256

min amount of tokens required for deposit

_queueDepositMax

uint256

max amount of tokens that can be deposited at once

performUpkeep

Deposits queued and/or unused tokens

function performUpkeep(bytes) external

updateDistribution

Distributes a new batch of liquid staking tokens to users that have queued deposits

function updateDistribution(bytes32 _merkleRoot, bytes32 _ipfsHash, uint256 _amountDistributed, uint256 _sharesAmountDistributed) external

Parameters

NameTypeDescription

_merkleRoot

bytes32

new merkle root for the distribution tree

_ipfsHash

bytes32

new ipfs hash for the distribution tree (CIDv0, no prefix - only hash)

_amountDistributed

uint256

amount of LSD tokens distributed in this distribution

_sharesAmountDistributed

uint256

amount of LSD shares distributed in this distribution

pauseForUpdate

Pauses queueing and unqueueing so a new merkle tree can be generated

function pauseForUpdate() external

setPoolStatus

Sets the pool's status

function setPoolStatus(enum PriorityPool.PoolStatus _status) external

Parameters

NameTypeDescription

_status

PoolStatus

pool status

setPoolStatusClosed

Sets the pool's status to CLOSED

function setPoolStatusClosed() external

setQueueDepositParams

Sets the minimum and maximum amount that can be deposited in a single deposit

function setQueueDepositParams(uint128 _queueDepositMin, uint128 _queueDepositMax) external

Parameters

NameTypeDescription

_queueDepositMin

uint128

min amount of tokens required for deposit

_queueDepositMax

uint128

max amount of tokens that can be deposited at once

setDistributionOracle

Sets the distribution oracle

function setDistributionOracle(address _distributionOracle) external

Parameters

NameTypeDescription

_distributionOracle

address

address of oracle

Last updated