Flux Vault
Flux Vault is an ERC4626-compliant lending vault that enables liquidity providers to earn yield while managers access leveraged capital for trading heterogeneous assets.
What is a Flux Vault?
A Flux Vault combines traditional lending pool functionality with a sophisticated position tracking system. Each vault:
Has one base asset (e.g., USDC, WETH)
Allows managers to borrow capital by posting bonds (collateral)
Tracks manager positions across multiple asset types
Charges continuous interest on borrowed capital
Enforces health requirements through liquidations
Unlike traditional lending protocols where users borrow specific assets, Flux enables borrowing capital to trade any whitelisted asset.
Key Features
ERC-4626 Compatibility
Flux Vaults implement the ERC-4626 "Tokenized Vault" standard, providing:
Consistent interface for deposits/withdrawals
Composable vault shares
Compatibility with DeFi aggregators
Standard accounting methods
3-Layer Position Tracking
Positions are organized as: account → subaccount → positionId
This model enables:
Multi-asset positions per manager
Isolated accounting per vault
Efficient gas usage via flash accounting
Flash Accounting
Instead of storing position values onchain, Flux:
Queries wrapper contracts for real-time values during callbacks
Calculates total position value dynamically
Validates health at the end of
unlock()callbackReverts entire transaction if unhealthy
Benefits:
Lower storage costs
Always accurate position values
Simplified state management
Bond-Based Margin System
Managers must post a bond (collateral in base asset) to borrow capital.
Example (20% minimum bond ratio):
Manager wants to borrow 100K USDC
Required bond: 20K USDC (20% of 100K)
Total capital accessed: 100K USDC
Leverage: 5x (100K / 20K)
Health Check:
Where:
Total Position Value= Sum of all position values (bond + working capital + assets)True Debt= Principal debt + accrued interestLiquidation Threshold= Typically ~110% (1.1e18)
Core Vault Operations
For Liquidity Providers
Deposit
What happens:
LP transfers base asset to vault
Vault mints shares proportional to
amount / sharePriceShares represent claim on vault assets
Withdraw
Withdrawal Behavior:
Withdrawals succeed immediately if vault has sufficient idle liquidity
If insufficient liquidity, the withdrawal transaction reverts
LPs must wait for manager repayments or ADL to free up liquidity
No withdrawal queue or forced liquidation features
What to do if withdrawal fails:
Wait for natural manager repayments (managers close positions over time)
If vault utilization is very high (>95%), the ADL Manager may trigger Auto-Deleveraging to free liquidity
Monitor vault liquidity and retry when available
See Emergency Withdrawals Guide for detailed information on handling withdrawal failures.
For Managers
Register Executor
Before borrowing, managers must register an executor:
The executor implements IFluxUnlockCallback for position management.
Unlock Pattern
All manager operations use the unified unlock() callback:
Available Locked Operations
Capital Management:
locked_borrow(amount): Borrow capital from vaultlocked_repay(amount): Repay borrowed capital
Collateral Management:
locked_depositBond(amount): Add bond collaterallocked_withdrawBond(amount): Remove bond collateral
Asset Management:
locked_registerWrapper(wrapper): Enable new asset wrapperlocked_deregisterWrapper(wrapper): Remove asset wrapperlocked_depositToWrapper(wrapper, positionId, amount): Deposit to positionlocked_withdrawFromWrapper(wrapper, positionId, amount): Withdraw from positionlocked_claimFromWrapper(wrapper, positionId, amountOrTokenId): Claim pre-received assetslocked_moveFunds(fromPos, toPos, amount): Move funds between positions
Advanced:
locked_interactWithWrapper(wrapper, data): Custom wrapper interactions
For Liquidators
Liquidators maintain protocol health by liquidating underwater positions.
Liquidation Flow
Liquidation Bonus:
Healthy position (collateral ≥ debt): Zero bonus, pay full debt
Underwater position (collateral < debt): Pay
(1 - liquidationProfitMargin) × collateralValue
Interest Accrual
How Interest Works
Interest accrues continuously based on the vault's strategy:
Key Variables:
lastLpIndex: Current LP index (starts at 1e18)lastCheckpointTimestamp: Last time interest accruedprincipalDebt: Manager's debt before interestlastLpIndexSnapshot: LP index when manager last updated
Interest Collection
Anyone can trigger interest collection:
What happens:
Calculate accrued interest:
interest = trueDebt - principalDebtDeduct from manager's bond
Distribute to protocol, curator, and LPs
Update manager's snapshot
Fee Distribution
When interest is collected:
Configured in the vault's strategy contract.
Vault Configuration
Immutable Parameters (Set at Deployment)
Cannot be changed after deployment:
Base asset
Strategy (interest rates, bond ratios, allowed assets)
Access policy (who can deposit)
Base asset wrapper
Mutable Parameters (If Using Mutable Strategy)
Vaults using MutableFixedRateStrategy can update parameters with 7-day timelock:
Interest rate
Curator fee rate
Allowed asset wrappers (can add, cannot remove)
Access Control
Vaults can use different access policies:
Permissionless Access
Anyone can deposit as LP, anyone can borrow as manager (if they meet requirements).
Whitelist Access
Only whitelisted addresses can:
Deposit as LP
Borrow as manager
Implemented via WhitelistAccessPolicy or custom policies.
Safety Mechanisms
Auto-Deleveraging (ADL)
Vaults support ADL to protect LPs during high utilization:
Vault creator can set an ADL Manager
ADL Manager can force-close healthy positions when vault utilization is very high (>95%)
Managers receive their full net equity back (no penalties)
Helps free liquidity for LP withdrawals
See Auto-Deleveraging for complete documentation.
Deposit Policies
Vaults can optionally use deposit policies to restrict deposits:
Utilization-based caps
Per-user limits
Time-based restrictions
Custom logic via
IDepositPolicyinterface
Access Control
Vaults use access policies to control who can participate:
Permissionless (anyone can deposit/borrow)
Whitelisted (only approved addresses)
Custom policies via
IAccessPolicyinterface
Vault States
Utilization
High utilization (>95%) may trigger:
ADL (Auto-Deleveraging) for managers to free up liquidity
Withdrawal failures for LPs (must wait for repayments or ADL)
Idle Liquidity
Immediately available for withdrawals without liquidating managers.
Share Price
Increases over time as interest accrues to LPs.
Position Health
Health Ratio
Status:
≥ 1.1(110%): Healthy< 1.1(110%): Liquidatable
Total Position Value
Sum of all manager positions:
Bond (base asset)
Working capital (base asset)
Wrapped assets (valued via oracles)
Example:
What is a MetaVault in Flux?
A MetaVault is a "vault-of-vaults" - an ERC4626-compliant vault that holds shares in multiple underlying FluxVaults rather than directly managing lending positions.
Key Architecture: The Holding Pen Pattern
The most distinctive feature is the holding pen design:
User deposits → MetaVault mints shares → Assets stay in an idle pool (not immediately deployed)
Allocator later decides when/where to allocate assets to underlying vaults
On withdrawal: MetaVault first tries to fulfill from idle pool; if insufficient, the LP must wait or use forceDeallocate
This prevents deposits from getting locked in loans that can't easily be rebalanced.
Core Components
MetaVault (src/FluxMetaVault.sol)
Holds assets (idle pool + underlying vault shares)
Allocator (src/allocators/)
Manages vault list, penalties, and allocation rules
Curator
allocator.owner() - controls allocation strategy
Key Functions
allocate(vault, amount)
Allocator only
Move assets from idle pool → underlying vault
deallocate(vault, amount)
Allocator only
Pull assets from underlying vault → idle (no penalty)
forceDeallocate(vault, amount)
Anyone
Pull assets with a penalty (shares burned from caller)
setFee(newFee)
Curator only
Set performance fee (max 50%)
MetaVault vs Regular FluxVault
Purpose
Direct lending vault
Meta-allocator across multiple vaults
Deposits
Immediately available for lending
Go to idle pool first
Underlying
Base assets + manager positions
Shares in other FluxVaults
Withdrawals
Subject to manager liquidity
Limited by idle balance
Architecture Hierarchy
Why This Design?
Prevents liquidity deadlocks - LPs can always exit via forceDeallocate (with penalty)
Separates concerns - Asset custody (MetaVault) is separate from allocation logic (Allocator)
Flexible strategies - Different allocator implementations (SimpleAllocator, rule-based allocators) can be plugged in
Economic incentives - Force deallocate penalties benefit remaining LPs (share price increases)
Last updated