Withdraw
There are 3 functions that can be used to withdraw (burning the shares and withdrawing the tokens):
withdrawredeemredeemWithoutSwap
withdraw
Here is the function interface:
/// @param assets The amount of assets to withdraw
/// @param receiver The address that will receive the withdrawn assets
/// @param owner The address that owns the shares being withdrawn
/// @param minimumReceive The minimum amount of assets to be received by the receiver
/// @param checkSlippage When burning liquidity from Ambient Pool, Tempest's Vault checks the slippage of the pool price vs oracle price to prevent attacker from manipulating pool price and arbitrage burned liquidity.
/// However, in some cases, user is too panic and want to withdraw regardless of the price. Checking slippage may cause the withdrawing failed, especially if the price moves rapidly.
/// So that checkSlippage indicates that the vault should check slippage when burning liquidity or not.
/// Be careful when withdrawing with checkSlippage = false because of the chance to be arbitraged.
/// @return shares The amount of shares burned for the withdrawal
function withdraw(
uint256 assets,
address receiver,
address owner,
uint256 minimumReceive,
bool checkSlippage
) external returns (uint256 shares)When performing the withdrawal, Tempest's Vault burns provided liquidity in Ambient Pool based on the amount of assets to be withdrawn. The ratio of burned liquidity will be equal to the ratio of withdrawn assets to total assets in the Vault.
After burning liquidity, Tempest's Vault swaps dual-side burned tokens to single-side tokens and sends single-side tokens to receiver. Similar to single-side tokens depositing, Tempest's Vault performs the swap at oracle price with a small slippage and via the Ambient Pool directly.
Finally, the corresponding amount of the Vault's shares will be calculated and burned.
redeem
Here is the function interface:
redeem is similar to withdraw, but the client provide shares as parameter instead of assets .
Tempest's Vault supports 2 below functions to convert between shares and assets :
redeemWithoutSwap
Here is the function interface:
redeemWithoutSwap is similar to redeem but no swap is performed by Tempest's Vault. Both dual-side tokens will be sent to receiver after the withdrawl. redeemWithoutSwap can be used in case of the large withdrawl so the pool does have enough liquidity for the swap.
Last updated