Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/vault-exit/VaultExitBundlesV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ contract VaultExitBundlesV1 is IVaultExitBundlesV1, IMorphoSupplyCallback, IMorp
/// @dev The allowance/permit of shares can also be used to bound the max burned shares.
/// @dev The vault's idle assets are withdrawn first.
/// @dev The assetsToDeallocate amount is floor((exitAssets - assetsToWithdrawFromIdle) * WAD / (WAD + penalty)).
/// @dev The in-kind portion is withdrawn in a number of iterations that is bounded by N the number of markets in the adapter (each of them can result in a rounding error against the users). The assets value of the sum of the shares withdrawn can be greater than exitAssets, but no greater that exitAssets+N.
/// @dev The in-kind portion is withdrawn in a number of iterations that is bounded by N the number of markets in the adapter (each of them can result in a rounding error against the users). The sum of the assets passed as argument to the withdraw function can be greater than exitAssets, but no greater than exitAssets+N.
/// @dev Requires Morpho Blue to have at least assetsToDeallocate in loan token balance.
/// @dev Requires the sender to have enough shares to withdraw exitAssets+N.
/// @dev Requires the sender to have enough shares to:
/// - first withdraw assetsToWithdrawFromIdle
/// - then withdraw ceil(assets * penalty / WAD) and withdraw assets, for each market in the list, where the sum of the assets is equal to assetsToDeallocate.
/// @dev It may be the case that the vault became liquid, but calling this function still yields positions on the markets, and potentially pays the penalty.
/// @dev If the liquidity adapter has some liquidity, withdrawing from the vault instead of calling this function avoids the penalty.
/// @dev It's acknowledged that it is possible to call this function with duplicate markets in the list.
Expand Down Expand Up @@ -175,7 +177,7 @@ contract VaultExitBundlesV1 is IVaultExitBundlesV1, IMorphoSupplyCallback, IMorp
/// @dev Starts by withdrawing everything the vault can pay without penalty: its idle assets and the liquidity available through the liquidity adapter.
/// @dev The assetsToDeallocate amount is floor((exitAssets - assetsToWithdraw) * WAD / (WAD + penalty)), where assetsToWithdraw is the amount withdrawn without penalty.
/// @dev The assetsToDeallocate amount is force deallocated by looping over the adapter's markets, taking from each market as much as its liquidity and the adapter's position allow before moving to the next one.
/// @dev The assets are withdrawn in a number of iterations that is bounded by N the number of markets in the adapter (each of them can result in a rounding error for the users). The assets value of the sum of the shares redeemed can be greater than exitAssets, but no greater that exitAssets+N.
/// @dev The assets are withdrawn in a number of iterations that is bounded by N the number of markets in the adapter (each of them can result in a rounding error for the users). The sum of the assets passed as argument to the withdraw function can be greater than exitAssets, but no greater than exitAssets+N.
/// @dev The referral fee is deducted from the withdrawn assets; the remainder is sent to msg.sender.
/// @dev Fee = withdrawnAssets * referralFeePct / WAD; net = withdrawnAssets - fee.
/// @dev minSharePriceE27 lower-bounds the realized exit share price (withdrawn assets per share, scaled by 1e27). The force deallocate penalty is deducted from the withdrawn assets, so it lowers this price.
Expand Down
Loading