NablaBackstopPool
The backstop pool takes most of the risk of a set of swap pools backed by it. Whenever a swap pool is low on reserves and a LPer wants to withdraw some liquidity, they can conduct an insurance withdrawal (burn swap pool shares, reimbursed in backstop liquidity) to avoid paying a high slippage. The backstop pool owns all excess liquidity in its swap pools, but is also liable for potential liquidity gaps. In return, the backstop pool receives a cut of the swap fees.
Withdrawal
SwapPoolConfig
router
router instance for this backstop pool
getBackedPool
enumerate swap pools backed by this backstop pool
Parameters
Name | Type | Description |
---|---|---|
_index | uint256 | index of the swap pool in |
Return Values
Name | Type | Description |
---|---|---|
swapPool_ | address | swap pool address |
getBackedPoolCount
get swap pool count backed by this backstop pool
Return Values
Name | Type | Description |
---|---|---|
count_ | uint256 | number of swap pools |
getInsuranceFee
get insurance withdrawal fee for a given swap pool
Parameters
Name | Type | Description |
---|---|---|
_swapPool | address | address of the swap pool |
Return Values
Name | Type | Description |
---|---|---|
feeBps_ | uint256 | insurance witdrawal fee, in basis points (0.01%) |
deposit
Deposits amount of tokens into pool Will change cov ratio of pool, will increase delta to 0
By calling this function the price feeds get updated (IPriceOracleAdapter.updatePriceFeeds)
Parameters
Name | Type | Description |
---|---|---|
_depositAmount | uint256 | The amount of backstop pool tokens to be deposited |
_minLPAmountOut | uint256 | The minimum amount of backstop pool LP tokens to mint |
_deadline | uint256 | Unix timestamp after which the transaction will revert |
_priceUpdateData | bytes[] | Array of price update data of all assets involved (backstop pool and all swapPools as within coveredSwapPools[]) |
Return Values
Name | Type | Description |
---|---|---|
sharesToMint_ | uint256 | Total number of backstop pool LP tokens minted |
initiateWithdraw
Starts the withdrawal process or overrides an existing one The user must finalize the withdrawal after the delay period has passed but before the claim period ends through finalizeWithdrawBackstopLiquidity()
or finalizeWithdrawExcessSwapLiquidity()
Parameters
Name | Type | Description |
---|---|---|
_sharesToBurn | uint256 | The liquidity to be withdrawn, an amount of backstop pool LP tokens |
Return Values
Name | Type | Description |
---|---|---|
success_ | bool | Confirmation of success |
cancelWithdraw
Cancels an initiated withdrawal
Return Values
Name | Type | Description |
---|---|---|
success_ | bool | Confirmation of success |
finalizeWithdrawBackstopLiquidity
Finalizes the withdrawal process after the delay period has passed but before the claim period ends Withdraws backstop liquidity amount of asset ensuring minimum amount required
By calling this function the price feeds get updated (IPriceOracleAdapter.updatePriceFeeds)
Parameters
Name | Type | Description |
---|---|---|
_minimumAmount | uint256 | Reject withdrawal if resulting amount is below |
_deadline | uint256 | Unix timestamp after which the transaction will revert |
_priceUpdateData | bytes[] | Array of price update data of all assets involved (backstop pool and all swapPools as within coveredSwapPools[]) |
Return Values
Name | Type | Description |
---|---|---|
payoutAmount_ | uint256 | Amount of |
redeemSwapPoolShares
Withdraw from a swap pool using backstop liquidity without slippage (backstop burn) only possible if swap pool's coverage ratio < 100%
By calling this function the price feeds get updated (IPriceOracleAdapter.updatePriceFeeds)
Parameters
Name | Type | Description |
---|---|---|
_swapPool | address | swap pool address |
_shares | uint256 | number of swap pool LP tokens to redeem, uses decimals of swap pool |
_minAmountOut | uint256 | minimum amount of backstop liquidity to receive, uses decimals of backstop pool |
_deadline | uint256 | Unix timestamp after which the transaction will revert |
_priceUpdateData | bytes[] | Array of price update data of all assets involved (backstop pool and this swapPool) |
Return Values
Name | Type | Description |
---|---|---|
amountOut_ | uint256 | amount of backstop liquidity paid-out, uses decimals of backstop pool |
finalizeWithdrawExcessSwapLiquidity
Finalizes the withdrawal process after the delay period has passed but before the claim period ends Withdraw from backstop pool, but receive excess liquidity of a swap pool instead of backstop liquidity
By calling this function the price feeds get updated (IPriceOracleAdapter.updatePriceFeeds)
Parameters
Name | Type | Description |
---|---|---|
_swapPool | address | swap pool address, must have a coverage ratio > 100% |
_minAmount | uint256 | minimum amount of swap pool liquidity to receive, uses decimals of swap pool |
_deadline | uint256 | Unix timestamp after which the transaction will revert |
_priceUpdateData | bytes[] | Array of price update data of all assets involved (backstop pool and all swapPools as within coveredSwapPools[]) |
Return Values
Name | Type | Description |
---|---|---|
swapAmount_ | uint256 | amount of swap pool liquidity paid-out, uses decimals of swap pool |
redeemCrossSwapPoolShares
getTotalPoolWorth
return worth of the whole backstop pool in asset()
, incl. all swap pools' excess liquidity and the backstop pool's liabilities this is a fixed point number, using the backstop pool decimals
ignoring if pools are paused or not, since liabilities still apply and we don't want the backstop pool worth to jump
Parameters
Name | Type | Description |
---|---|---|
_allTokenPrices | uint256[] | array of all token prices ([0] backstop pool token, [1] swap pool token_i, [2] swap pool token_i+1, ... [n] swap pool token_n) as within coveredSwapPools[] |
Return Values
Name | Type | Description |
---|---|---|
value_ | int256 | total value of all backstop pool shares, in |
totalExcessLiquidity_ | int256 | total excess liquidity of all swap pools, in |
sharesTargetWorth
Returns the worth of an amount of pool shares (LP tokens) in underlying principle
Parameters
Name | Type | Description |
---|---|---|
_sharesToBurn | uint256 | The number of LP tokens to burn |
_allTokenPrices | uint256[] | array of all token prices ([0] backstop pool token, [1] swap pool token_i, [2] swap pool token_i+1, ... [n] swap pool token_n) as within coveredSwapPools[] |
Return Values
Name | Type | Description |
---|---|---|
amount_ | uint256 | The amount of |
getPoolState
returns the backstop pool state
Parameters
Name | Type | Description |
---|---|---|
_allTokenPrices | uint256[] | array of all token prices ([0] backstop pool token, [1] swap pool token_i, [2] swap pool token_i+1, ... [n] swap pool token_n) as within coveredSwapPools[] |
Return Values
Name | Type | Description |
---|---|---|
reserves_ | uint256 | current amount of |
totalPoolWorth_ | int256 | total worth of the pool in |
totalSupply_ | uint256 | total amount of LP tokens minted |
getWithdrawal
Get information about a user's initiated withdrawal
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The user who initiated the withdrawal |
Return Values
Name | Type | Description |
---|---|---|
startClaimPeriod_ | uint128 | The time when the withdrawal can be finalized, a unix timestamp |
endClaimPeriod_ | uint128 | The time when the withdrawal can no longer be finalized, a unix timestamp |
sharesToBurn_ | uint256 | The amount of LP tokens to burn |
getWithdrawalDelayAndClaimPeriod
Get the delay and claim period for withdrawals
Return Values
Name | Type | Description |
---|---|---|
delay_ | uint128 | The delay before initiated withdrawals can be finalized, in seconds |
claimPeriod_ | uint128 | The period within which initiated withdrawals can be claimed, in seconds |
Last updated