Withdraw from the Vault
Here we only cover how to withdraw the initial principal deposited into the Vault. For withdrawing any yield generated by the principal, read the Reward System.
There are two ways you can withdraw your principal:
1. Withdraw the underlying LP token
You can either use the standard ERC4626 Withdraw or Redeem functions.
Here, the Vault distributes rewards first to ensure correct distribution of rewards, unstakes LP tokens to meet the withdrawal and sends the tokens to the user.
Withdraw is withdrawing an exact amount of underlying LP tokens by burning shares in the vault Redeem is withdrawing a number of underlying LP tokens dictated by the exact amount of shares burnt by the user.
2. Withdraw in non LP tokens:
You can use the function below to burn an arbitrary amount of shares to receive an exact amount of LP tokens. Then these LP tokens are swapped through into the exitToken and sent to the receiver.
For this specific StEth-Eth example, there are extra steps to be compatible with native ETH but all Vaults follow this fundamental logic when withdrawing ERC20 tokens that are not the underlying LP token
Withdraw LP tokens by burning shares in the vault
Swap the LP tokens into the exitToken and send this to the user.
Last updated