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.
1. Withdraw the underlying LP token
/** @dev See {IERC4626-withdraw}. */
/// Standard ERC4626 withdraw function but distributes rewards before withdraw
// and unstakes from the alluoPool in order to meet collateral commitments
function withdraw(
uint256 assets,
address receiver,
address owner
) public virtual override returns (uint256) {
_distributeReward(_msgSender());
require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max");
_unstakeForWithdraw(assets);
uint256 shares = previewWithdraw(assets);
_withdraw(_msgSender(), receiver, owner, assets, shares);
return shares;
}
2. Withdraw in non LP tokens:
Last updated