Factories
Flux Protocol's factory system enables permissionless deployment of vaults, strategies, and asset wrappers. Anyone can create these components, fostering innovation while maintaining safety through validated parameters and governance whitelisting.
Overview
Flux has three main factories:
FluxVaultFactory: Deploy vaults, register executors, manage protocol fees
StrategyFactory: Deploy strategies (Immutable, Mutable, or Flexible Margin)
AssetWrapperFactory: Deploy vanilla ERC20/ERC4626 wrappers
┌─────────────────────────────────────────────────────────┐
│ Flux Ecosystem │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────────┐ ┌──────────────────────┐ │
│ │ AssetWrapper │ │ StrategyFactory │ │
│ │ Factory │ │ │ │
│ ├───────────────────┤ ├──────────────────────┤ │
│ │ deployERC20() │ │ deployImmutable() │ │
│ │ deployERC4626() │ │ deployMutable() │ │
│ │ │ │ deployFlexMargin() │ │
│ └──────┬────────────┘ └────────┬─────────────┘ │
│ │ │ │
│ │ Wrappers Strategies │
│ │ │ │
│ └────────────┬───────────────┘ │
│ ▼ │
│ ┌─────────────────────────┐ │
│ │ FluxVaultFactory │ │
│ ├─────────────────────────┤ │
│ │ createVault() │ │
│ │ registerExecutor() │ │
│ │ whitelistAsset() │◄─── Governance │
│ │ setProtocolFeeRate() │ │
│ └──────────┬──────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Flux Vaults │ │
│ └────────────────┘ │
└─────────────────────────────────────────────────────────┘Key Principles:
Permissionless deployment: Anyone can deploy components
Parameter validation: Factories validate safety constraints
Governance whitelisting: Protocol governance approves wrappers
No upgrades: Deployed components are immutable (unless using Mutable strategy)
Enumeration: All deployments tracked for discoverability
FluxVaultFactory
The central factory for creating vaults and managing protocol-level settings.
Core Responsibilities
Vault Creation: Deploy new ERC4626 vaults with custom strategies
Executor Registration: Register Weiroll executors for managers
Protocol Fees: Set and collect protocol fees across all vaults
Oracle Registry: Manage centralized oracle system
Asset Whitelisting: Governance approval of wrapper contracts
Interface
Creating a Vault
Basic Vault (Permissionless Deposits)
Vault with Whitelist Access
Vault with Graduated Deposit Caps
For vaults that want to start small and scale gradually:
Use Cases for Deposit Caps:
New Vaults: Limit large deposits initially to test strategies
Risk Management: Cap exposure during high utilization
Bootstrap Phase: No caps until vault reaches minimum size
Gradual Scaling: Increase caps as vault proves itself
Executor Registration
Managers must register an executor before borrowing. Two options:
Option 1: Deploy Weiroll Executor (Recommended)
Advantages:
Battle-tested executor implementation
Supports complex multi-step strategies via Weiroll
Composable with Weiroll recipes
No custom development needed
Option 2: Register Custom Executor
Requirements for Custom Executors:
Must implement
IFluxUnlockCallbackMust call
vault.unlock()from the executor addressCannot be shared across multiple managers
Cannot be changed after registration
Example Custom Executor:
Vault Registry
Check if an address is a Flux vault:
Protocol Fees
Governance Functions (only governance multisig):
Fee Distribution:
Asset Whitelisting
Why Whitelisting?
Even though anyone can deploy wrappers via AssetWrapperFactory, governance must approve them before they can be used in vaults. This prevents:
Malicious wrappers that steal funds
Wrappers with incorrect oracle integration
Wrappers for extremely illiquid assets
Wrappers that don't follow IAsset spec
Governance Workflow:
Checking Whitelist Status:
StrategyFactory
Deploy economic parameter sets for vaults. Three strategy types available.
Strategy Types Comparison
Parameter Updates
Never
Via 7-day timelock
Via 7-day timelock
Liquidation Threshold
Derived (>100%)
Derived (>100%)
Direct (50-200%)
Minimum Bond Ratio
Fixed at deployment
Fixed at deployment
Can be minimal
Interest Rate
Fixed at deployment
Updatable
Updatable
Curator Fee
Fixed at deployment
Updatable
Updatable
Asset Allowlist
Fixed at deployment
Can add assets
Can add assets
ADL (Auto-Deleveraging)
Enabled
Enabled
Disabled
Best For
Conservative LPs
Active management
Single-user vaults
Interface
Strategy Parameters
Standard Strategy Parameters
Derived Values:
Flexible Margin Parameters
Key Difference: Liquidation threshold is set directly, not derived. This allows:
Sub-100% thresholds: Liquidate at 90% = stop-loss at -10% loss
Minimal bonds:
minBondRatio = 0.01%for self-managed vaultsCustom guardrails: Set liquidation at any health ratio you want
Deploying Strategies
1. Immutable Strategy (Maximum Trust)
Best for conservative vaults prioritizing LP trust.
Characteristics:
✅ No governance risk - LPs know exactly what they're getting
✅ Predictable economics forever
❌ Cannot adapt to market changes
❌ Cannot add new assets even if audited
❌ Cannot adjust rates to stay competitive
2. Mutable Strategy (Flexible Management)
Best for active vault curators who want to stay competitive.
What Can Be Updated (via 7-day timelock):
✅ Annual interest rate
✅ Curator fee rate
✅ Allowed assets (can add, cannot remove)
What CANNOT Be Updated (set at deployment):
❌ Minimum bond ratio
❌ Liquidation buffer
❌ ADL buffer
❌ ADL utilization threshold
❌ Liquidation profit margin
Updating Parameters:
Adding Assets:
3. Flexible Margin Strategy (Single-User Vaults)
Best for self-managed vaults with custom liquidation logic.
Use Cases:
Stop-Loss Automation:
Leveraged Long with Tight Stop:
Delta-Neutral Strategy:
Personal Capital Efficiency:
Restrictions:
Liquidation threshold must be 50-200% (0.5e18 to 2e18)
Min bond ratio can be 0-100%
ADL is always disabled
Typically used with access policies (single LP/manager)
Parameter Validation
Before deploying, you can validate parameters:
Common Validation Errors:
Strategy Enumeration
Discover all deployed strategies:
AssetWrapperFactory
Permissionless deployment of vanilla ERC20 and ERC4626 wrappers.
Why a Wrapper Factory?
Problem: Every asset needs a wrapper to be used in Flux vaults. Manually deploying wrappers for every token doesn't scale.
Solution: Anyone can deploy a vanilla wrapper for any asset. Governance then whitelists vetted wrappers.
Interface
Deploying Wrappers
ERC20 Wrapper
One wrapper per token (singleton pattern).
ERC4626 Wrapper
One wrapper per vault token.
Benefits of ERC4626 Wrappers:
Auto-compound yield while used as collateral
Managers earn yield on idle capital
Vault supports heterogeneous USDC sources (Aave, Compound, etc.)
Wrapper Lifecycle
Full Flow:
Custom Wrappers
For specialized assets (Uniswap V3 positions, Aerodrome LP tokens, etc.), deploy custom wrappers outside the factory:
Custom Wrapper Requirements:
Implement
IAssetinterface correctlyIntegrate with oracle registry
Handle 3-layer position model (account/subaccount/positionId)
Pass comprehensive audit
No token approval vulnerabilities
Reentrancy protection
Correct decimal handling
See Asset Wrappers Concept for full IAsset specification.
Preventing Duplicates
The factory enforces singleton pattern:
Why Prevent Duplicates?
Avoids confusion about which wrapper is "official"
Prevents governance from having to whitelist multiple identical wrappers
Reduces surface area for attacks (only one wrapper to audit)
Simplifies discovery and enumeration
Enumerating Wrappers
Discover all deployed wrappers:
Factory Architecture
Design Principles
1. Permissionless Innovation
Anyone can deploy:
Asset wrappers for any token
Strategies with custom parameters
Vaults with any combination of assets/strategy
No gatekeeping at deployment level.
2. Governance Safety
Deployment ≠ Approval:
Asset wrappers must be whitelisted by governance
Strategies are permissionless but validate parameters
Vaults can only use whitelisted wrappers
3. Discoverability
All deployments tracked:
Enumerate all strategies
Enumerate all wrappers (ERC20 and ERC4626)
Check if address is a Flux vault
Query wrapper for specific token
4. No Upgrades
Deployed components are immutable:
Vaults use EIP-1167 minimal proxies (immutable logic)
Immutable strategies locked forever
Wrappers are not upgradeable
Only Mutable/Flexible strategies allow parameter changes (via timelock)
5. Composability
Mix and match:
Any vault + any strategy + any whitelisted wrappers
Executor registry shared across all vaults
Oracle registry shared across all assets
Security Model
Threat Mitigation:
Malicious wrapper steals funds
Governance whitelisting
Strategy with unsafe parameters
Factory validation
Vault using unvetted wrapper
Factory checks whitelist
Manager registers malicious executor
One executor per manager, non-transferable
Governance compromise
Timelock on parameter updates
Oracle manipulation
Centralized oracle registry, governance-controlled
Integration Examples
For Vault Creators
For Protocol Developers
For Governance
Best Practices
For Wrapper Deployers
Do:
Deploy wrappers for widely-used assets
Test thoroughly before governance submission
Include audit reports in governance proposal
Verify oracle support exists
Check for existing wrapper first
Don't:
Deploy duplicate wrappers
Deploy for illiquid or experimental tokens
Deploy without testing on testnet
Assume governance will whitelist automatically
For Strategy Creators
Do:
Start with conservative parameters
Validate parameters before deployment
Consider LP risk tolerance
Research competitive rates
Document strategy reasoning
Don't:
Use extreme parameters without justification
Ignore liquidation buffer requirements
Set fees higher than market standard
Deploy immutable strategy without thorough testing
For Vault Creators
Do:
Verify all wrappers are whitelisted
Choose strategy matching your LP base
Set clear access policies if restricting
Monitor vault health regularly
Communicate with LPs about changes (if mutable)
Don't:
Use unwhitelisted wrappers
Change mutable strategy parameters frequently
Ignore LP feedback on governance decisions
Deploy without testing complete flow
For Governance
Do:
Require audits for wrapper whitelisting
Test wrappers on testnet first
Verify oracle availability before approving
Check liquidity for liquidation scenarios
Use timelock for protocol changes
Don't:
Whitelist unaudited wrappers
Approve wrappers for illiquid assets
Change protocol fees without community discussion
Whitelist wrappers without oracle support
Summary
Flux's factory system provides:
Permissionless Innovation: Anyone can deploy vaults, strategies, and wrappers
Safety Through Validation: Parameter checks prevent unsafe configurations
Governance Oversight: Whitelisting ensures only vetted wrappers are used
Composability: Mix and match components freely
Discoverability: Enumerate all deployments for analytics
No Lock-In: Immutable contracts, no upgrade risk
Three Factories:
FluxVaultFactory: Deploy vaults, manage protocol settings
StrategyFactory: Deploy economic parameter sets (Immutable/Mutable/Flexible)
AssetWrapperFactory: Deploy vanilla wrappers for ERC20/ERC4626 tokens
Key Flows:
Last updated