Asset Wrappers
Asset Wrappers provide a unified interface for managing heterogeneous assets within Flux vaults. They enable managers to hold positions in any tokenized asset—from standard ERC20 tokens to Uniswap V3 NFTs to yield-bearing vaults.
What is an Asset Wrapper?
An Asset Wrapper is a smart contract that:
Implements the
IAssetinterfaceManages positions for multiple vaults and managers
Integrates with the Oracle Registry for pricing
Provides a consistent API regardless of underlying asset type
Think of wrappers as "adapters" that translate diverse asset types into a common position tracking format that Flux vaults understand.
Why Asset Wrappers?
Traditional lending protocols are limited to simple ERC20 tokens. Flux's wrapper architecture enables:
Heterogeneous Asset Support
✓ ERC20 tokens (USDC, WETH, etc.)
✓ ERC4626 vaults (Aave aTokens, Compound cTokens, etc.)
✓ Uniswap V3 LP positions (NFTs)
✓ Aerodrome LP positions
✓ Any custom asset type with proper wrapper
Unified Position Management
Managers interact with all assets through the same interface:
Permissionless Deployment
Anyone can deploy vanilla wrappers via AssetWrapperFactory:
The IAsset Interface
All wrappers implement the IAsset interface:
The 3-Layer Position Model
Asset wrappers track positions using three layers:
Example:
Why Three Layers?
Isolation: Each vault's positions are completely isolated
Flexibility: Position IDs can represent:
Generic positions (0x00 for fungible assets)
Specific token IDs (for NFTs)
Semantic groupings (separate position IDs for different strategies)
Security: Only the account (vault) can modify its own positions
Built-In Wrapper Types
1. ERC20AssetWrapper
Wraps standard ERC20 tokens for use in Flux vaults.
Example Usage:
How It Works:
Manager approves wrapper for WETH
Wrapper transfers WETH from manager
Wrapper updates
balances[vault][manager][positionId]Position value queried via Oracle Registry
Price Valuation:
2. ERC4626AssetWrapper
Wraps ERC4626 yield-bearing vaults (Aave, Compound, etc.).
Example Usage:
How It Works:
Manager has aUSDC shares
Wrapper transfers aUSDC shares from manager
Wrapper tracks shares in
balances[vault][manager][positionId]Value calculated as:
shares × sharePrice(viaconvertToAssets)
Auto-Compounding:
Automatically captures yield growth without manager action.
3. Custom Wrappers
For specialized assets (NFTs, LP positions, etc.), deploy custom wrappers.
Example: Uniswap V3 Wrapper
Wrapper Security Model
Isolated Namespaces
Each vault operates in its own namespace:
Why This Matters:
One wrapper deployment serves unlimited vaults
Vaults cannot interfere with each other
Zero trust assumptions between vaults
Access Control
Wrappers enforce strict access control:
Security Guarantee: Only the vault can modify positions in its namespace.
Factory Integration
All wrappers are linked to the FluxVaultFactory:
This ensures:
Consistent oracle pricing across all vaults
Governance can update oracle registry
Wrappers stay synchronized with protocol
Asset Wrapper Factory
The AssetWrapperFactory enables permissionless wrapper deployment:
Deploying Vanilla Wrappers
Duplicate Prevention
Factory prevents duplicate wrappers:
Why: Prevents fragmentation, ensures consistent pricing.
Whitelisting Flow
After deployment, wrappers must be whitelisted:
Deploy: Anyone deploys wrapper via factory
Whitelist: Governance whitelists via
FluxVaultFactory.whitelistAsset(wrapper)Use: Strategies can include wrapper in allowed assets
Oracle Integration
Wrappers don't store prices - they query the Oracle Registry:
How It Works
Oracle Registry Flow
Benefits:
Wrappers don't need oracle logic
Oracle sources can be upgraded without redeploying wrappers
Centralized price governance
Consistent pricing across all vaults
Working with Wrappers
As a Manager
Register Wrapper
Adds wrapper to manager's allowed list for this vault.
Deposit to Wrapper
Withdraw from Wrapper
Token is sent to manager (subaccount).
Claim Assets
For pre-received assets (e.g., airdrops, rewards):
Wrapper checks its balance increased and credits position.
As a Liquidator
During liquidation, access seized collateral:
Wrapper Lifecycle
1. Deployment
2. Whitelisting
3. Strategy Inclusion
4. Manager Usage
5. Oracle Pricing
6. Liquidation
Advanced Wrapper Features
Custom Position IDs
Managers can use multiple position IDs per wrapper:
Batch Operations
Wrappers support efficient batch queries:
Position Transfer (Liquidation)
During liquidation, entire subaccounts can be transferred:
Wrapper Best Practices
For Wrapper Developers
Implement IAsset Fully: All functions must be implemented correctly
Use Factory Pattern: Link to
FluxVaultFactoryfor oracle accessEnforce Access Control: Only
account(vault) can modify positionsHandle Edge Cases: Zero amounts, non-existent positions, etc.
Optimize Gas: Minimize storage, use efficient data structures
Document Behavior: Clearly document position ID semantics
For Vault Creators
Vet Wrappers: Only include audited, trusted wrappers in strategies
Check Oracle Support: Ensure Oracle Registry supports the asset
Understand Risks: Custom wrappers may have unique risks
Test Integration: Verify wrapper works correctly with vaults
Monitor Whitelisting: Track governance whitelist updates
For Managers
Register Before Use: Call
locked_registerWrapper()before depositingTrack Position IDs: Use consistent position IDs for accounting
Monitor Valuations: Understand how wrappers are priced
Handle Failures: Wrapper interactions can fail (e.g., paused)
Optimize Routes: Some wrappers may be more gas-efficient than others
Comparison with Other Protocols
Asset Types
Any (NFT, ERC20, ERC4626, custom)
ERC20, ERC4626
ERC20 only
Deployment
Permissionless (factory)
Permissionless
Governance approval
Pricing
Oracle Registry
Per-market oracle
Shared oracle
Position Model
3-layer (account/subaccount/positionId)
Per-market balances
Per-pool balances
Isolation
Vault-level namespaces
Market-level
Pool-level
Custom Assets
✓ Full support
Limited
Not supported
Last updated