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

struct Withdrawal {
  uint128 startClaimPeriod;
  uint128 endClaimPeriod;
  uint256 sharesToBurn;
}

SwapPoolConfig

struct SwapPoolConfig {
  uint128 insuranceFeeBps;
  bool isCovered;
}

router

contract IRouter router

router instance for this backstop pool

getBackedPool

function getBackedPool(uint256 _index) external view returns (address _swapPool)

enumerate swap pools backed by this backstop pool

Parameters

NameTypeDescription

_index

uint256

index of the swap pool in coveredSwapPools array

Return Values

NameTypeDescription

_swapPool

address

swap pool address

getBackedPoolCount

function getBackedPoolCount() external view returns (uint256 _count)

get swap pool count backed by this backstop pool

Return Values

NameTypeDescription

_count

uint256

number of swap pools

getInsuranceFee

function getInsuranceFee(address _swapPool) external view returns (uint256 _feeBps)

get insurance withdrawal fee for a given swap pool

Parameters

NameTypeDescription

_swapPool

address

address of the swap pool

Return Values

NameTypeDescription

_feeBps

uint256

insurance witdrawal fee, in basis points (0.01%)

deposit

function deposit(uint256 _depositAmount, bytes[] _priceUpdateData) external payable returns (uint256 _sharesToMint, int256 _fee)

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

NameTypeDescription

_depositAmount

uint256

The amount to be deposited

_priceUpdateData

bytes[]

Array of price update data of all assets involved (backstop pool and all swapPools as within coveredSwapPools[])

Return Values

NameTypeDescription

_sharesToMint

uint256

Total number of pool lp tokens minted

_fee

int256

The fee due to slippage (will be zero)

initiateWithdraw

function initiateWithdraw(uint256 _sharesToBurn) external returns (bool success)

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

NameTypeDescription

_sharesToBurn

uint256

The liquidity to be withdrawn, an amount of backstop pool LP tokens

Return Values

NameTypeDescription

success

bool

Confirmation of success

finalizeWithdrawBackstopLiquidity

function finalizeWithdrawBackstopLiquidity(uint256 _minimumAmount, bytes[] _priceUpdateData) external payable returns (uint256 _payoutAmount)

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

NameTypeDescription

_minimumAmount

uint256

Reject withdrawal if resulting amount is below

_priceUpdateData

bytes[]

Array of price update data of all assets involved (backstop pool and all swapPools as within coveredSwapPools[])

Return Values

NameTypeDescription

_payoutAmount

uint256

Amount of asset() tokens withdrawn

redeemSwapPoolShares

function redeemSwapPoolShares(address _swapPool, uint256 _shares, uint256 _minAmount, bytes[] _priceUpdateData) external payable returns (uint256 _netAmount)

withdraw from a swap pool using backstop liquidity without slippage only possible if swap pool's coverage ratio < 100%

By calling this function the price feeds get updated (IPriceOracleAdapter.updatePriceFeeds)

Parameters

NameTypeDescription

_swapPool

address

swap pool address

_shares

uint256

number of swap pool shares to redeem

_minAmount

uint256

minimum amount of backstop liquidity to receive

_priceUpdateData

bytes[]

Array of price update data of all assets involved (backstop pool and this swapPool)

Return Values

NameTypeDescription

_netAmount

uint256

amount of backstop liquidity paid-out

finalizeWithdrawExcessSwapLiquidity

function finalizeWithdrawExcessSwapLiquidity(address _swapPool, uint256 _minAmount, bytes[] _priceUpdateData) external payable returns (uint256 _swapAmount)

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

NameTypeDescription

_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

_priceUpdateData

bytes[]

Array of price update data of all assets involved (backstop pool and all swapPools as within coveredSwapPools[])

Return Values

NameTypeDescription

_swapAmount

uint256

amount of swap pool liquidity paid-out, uses decimals of swap pool

getTotalPoolWorth

function getTotalPoolWorth(uint256[] _allTokenPrices) public view returns (int256 _value)

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

NameTypeDescription

_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

NameTypeDescription

_value

int256

total value of all backstop pool shares, in asset()

sharesTargetWorth

function sharesTargetWorth(uint256 _sharesToBurn, uint256[] _allTokenPrices) public view returns (uint256 _amount)

Returns the worth of an amount of pool shares (LP tokens) in underlying principle

Parameters

NameTypeDescription

_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

NameTypeDescription

_amount

uint256

The amount of asset() tokens that the shares are worth

getPoolState

function getPoolState(uint256[] _allTokenPrices) external view returns (uint256 _reserves, int256 _totalPoolWorth, uint256 _totalSupply)

returns the backstop pool state

Parameters

NameTypeDescription

_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

NameTypeDescription

_reserves

uint256

current amount of asset in this pool

_totalPoolWorth

int256

total worth of the pool in asset()

_totalSupply

uint256

total amount of LP tokens minted

getWithdrawal

function getWithdrawal(address _sender) external view returns (uint128 _startClaimPeriod, uint128 _endClaimPeriod, uint256 _sharesToBurn)

Get information about a user's initiated withdrawal

Parameters

NameTypeDescription

_sender

address

The user who initiated the withdrawal

Return Values

NameTypeDescription

_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

function getWithdrawalDelayAndClaimPeriod() external view returns (uint128 _delay, uint128 _claimPeriod)

Get the delay and claim period for withdrawals

Return Values

NameTypeDescription

_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