Depositing & Withdrawing
Learn how to deposit assets into Flux vaults and withdraw them when needed. This guide covers all withdrawal types and best practices for liquidity providers.
Overview
Flux vaults implement the ERC4626 standard, providing a familiar interface for deposits and withdrawals. As an LP, you:
Deposit base assets (USDC, WETH, etc.)
Receive vault shares representing your claim
Earn yield from manager interest payments
Withdraw anytime (subject to available liquidity)
Depositing Assets
Basic Deposit Flow
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IFluxVault} from "@flux/interfaces/IFluxVault.sol";
// 1. Approve vault to spend your tokens
IERC20 baseAsset = IERC20(vault.asset());
baseAsset.approve(address(vault), depositAmount);
// 2. Deposit and receive shares
uint256 shares = IFluxVault(vault).deposit(depositAmount, msg.sender);
// shares now represent your claim on vault assetsPreview Deposit
Always preview deposits to know exactly how many shares you'll receive:
Mint Shares (Alternative Method)
Instead of specifying deposit amount, you can specify desired shares:
Deposit Limits
Check vault deposit limits before depositing:
Deposit limits can be affected by:
Vault capacity caps
Access policy restrictions
Per-user deposit limits
Strategy-specific constraints
First Deposit Protection
The first depositor to a vault should be aware of share manipulation risks:
Withdrawing Assets
Flux vaults implement ERC4626 standard withdrawals. Withdrawals succeed immediately if liquidity is available, otherwise they revert.
Standard Withdrawal
Withdraw immediately if liquidity is available:
When it works:
Sufficient idle liquidity available
Vault utilization <100%
Normal market conditions
When it fails:
Vault has insufficient idle liquidity
Must wait for managers to repay
High utilization (>95%)
What Happens When Liquidity is Low?
If the vault has insufficient liquidity for your withdrawal:
Transaction reverts - Your withdrawal fails with "Insufficient liquidity" error
Wait for repayments - Managers naturally repay debt over time
ADL may help - Vault's ADL Manager may trigger Auto-Deleveraging to free liquidity
Auto-Deleveraging (ADL) for LP Protection
When vault utilization is very high (typically >95%), the vault's ADL Manager can force-close healthy manager positions to free up liquidity for LP withdrawals.
Important: LPs don't trigger ADL directly - it's executed by the vault's designated ADL Manager (usually the vault creator).
See Auto-Deleveraging for details on how ADL protects LPs during high utilization.
Detailed Withdrawal Methods
Standard Withdrawal: Redeem
Standard Withdrawal: Withdraw
Redeem vs Withdraw:
redeem(): Specify shares to burn → receive assetswithdraw(): Specify assets to receive → burn shares
Best Practices
Before Depositing
Verify vault strategy: Understand risks and parameters
Check access policy: Ensure you're allowed to deposit
Review vault health: Check utilization and bad debt
Preview deposit: Know exact shares you'll receive
Before Withdrawing
Check liquidity: Is there enough idle liquidity?
Preview withdrawal: Know exact assets you'll receive
Check utilization: High utilization means withdrawal may fail
Be patient: If failed, wait for managers to repay or for ADL
Monitoring Your Position
Common Issues
Issue 1: Deposit Reverts
Issue 2: Withdrawal Fails (No Liquidity)
Issue 3: Slippage
Gas Optimization
Security Considerations
Reentrancy Protection
Flux vaults have built-in reentrancy protection, but integrators should still be careful:
Approval Management
Related Documentation
Understanding Shares & Returns - How share value grows
Auto-Deleveraging (ADL) - LP liquidity protection
LP Integration Guide - Full integration guide
Last updated