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:

  1. Deposit base assets (USDC, WETH, etc.)

  2. Receive vault shares representing your claim

  3. Earn yield from manager interest payments

  4. 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 assets

Preview 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:

  1. Transaction reverts - Your withdrawal fails with "Insufficient liquidity" error

  2. Wait for repayments - Managers naturally repay debt over time

  3. 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 assets

  • withdraw(): Specify assets to receive → burn shares


Best Practices

Before Depositing

  1. Verify vault strategy: Understand risks and parameters

  2. Check access policy: Ensure you're allowed to deposit

  3. Review vault health: Check utilization and bad debt

  4. Preview deposit: Know exact shares you'll receive

Before Withdrawing

  1. Check liquidity: Is there enough idle liquidity?

  2. Preview withdrawal: Know exact assets you'll receive

  3. Check utilization: High utilization means withdrawal may fail

  4. 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


Last updated