RouterUtil
Overview
RouterUtil.sol
provides miscellaneous utils and preview functions related to Router executions.
spotExchangeRate
Gives the spot exchange rate of token i in terms of token j.
For example spotExchangeRate(any, 1, 0)
gives you the PT/IBT quote (how much IBT is worth one PT).
in IBT while spotExchangeRate(any, 0, 1)
gives you the IBT/PT quote (how much PT is worth one IBT).
For the IBT-PT curve pools deployed with the factory, the coin at index 0 is the Interest Bearing Token and the coin at index 1 is the Principal Token.
Exchange rate is in 18 decimals
convertIBTToYTSpot
Returns the maximal amount of YT one can obtain with a given amount of IBT (i.e without fees or slippage).
This function is used for setting initial guess for the root finding algorithms used when performing flash swaps. This method should not be used to evaluate a precise YT price.
previewFlashSwapIBTToExactYT
Estimates the amount of IBT required to perform a flash swap to obtain a specific amount of YT.
previewFlashSwapExactIBTToYT
Estimates the amount of YT that can be obtained by providing a specific amount of IBT in a flash swap.
previewFlashSwapExactYTToIBT
Estimates the amount of IBT that can be obtained by swapping a specific amount of YT.
getDx
Estimate the required input amount of a token (dx
) for a Curve pool swap, given a target output amount (targetDy
).
previewAddLiquidityWithAsset
Estimate the amount of LP tokens the user will get by routing assets for LP tokens (see Routing).
previewAddLiquidityWithIBT
Estimate the amount of LP tokens the user will get by routing IBTs for LP tokens (see Routing).
previewAddLiquidity
Estimate the amount of LP tokens the user will get by adding amounts
liquidity. amounts
is an array of the amount for token 0, the IBT and for token 1, the Principal Token.
previewRemoveLiquidityForAsset
Estimate the amount of underlying token (assets) a user will get for burning _lpAmount
LP tokens and redeeming PT and IBT for underlying. (see Routing).
previewRemoveLiquidityForIBT
Estimate the amount of IBTs a user will get for burning _lpAmount
LP tokens and redeeming PT for IBT. (see Routing).
previewRemoveLiquidity
Estimate the amounts of IBT and PT received for burning _lpAmount
LP tokens.
previewRemoveLiquidityOneCoin
Estimate the amounts of either IBT or PT received for burning _lpAmount
LP tokens. _i=0
for IBT and _i=1
for PT.
Last updated