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 IAsset interface

  • Manages 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:

  1. Manager approves wrapper for WETH

  2. Wrapper transfers WETH from manager

  3. Wrapper updates balances[vault][manager][positionId]

  4. Position value queried via Oracle Registry

Price Valuation:

2. ERC4626AssetWrapper

Wraps ERC4626 yield-bearing vaults (Aave, Compound, etc.).

Example Usage:

How It Works:

  1. Manager has aUSDC shares

  2. Wrapper transfers aUSDC shares from manager

  3. Wrapper tracks shares in balances[vault][manager][positionId]

  4. Value calculated as: shares × sharePrice (via convertToAssets)

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:

  1. Deploy: Anyone deploys wrapper via factory

  2. Whitelist: Governance whitelists via FluxVaultFactory.whitelistAsset(wrapper)

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

  1. Implement IAsset Fully: All functions must be implemented correctly

  2. Use Factory Pattern: Link to FluxVaultFactory for oracle access

  3. Enforce Access Control: Only account (vault) can modify positions

  4. Handle Edge Cases: Zero amounts, non-existent positions, etc.

  5. Optimize Gas: Minimize storage, use efficient data structures

  6. Document Behavior: Clearly document position ID semantics

For Vault Creators

  1. Vet Wrappers: Only include audited, trusted wrappers in strategies

  2. Check Oracle Support: Ensure Oracle Registry supports the asset

  3. Understand Risks: Custom wrappers may have unique risks

  4. Test Integration: Verify wrapper works correctly with vaults

  5. Monitor Whitelisting: Track governance whitelist updates

For Managers

  1. Register Before Use: Call locked_registerWrapper() before depositing

  2. Track Position IDs: Use consistent position IDs for accounting

  3. Monitor Valuations: Understand how wrappers are priced

  4. Handle Failures: Wrapper interactions can fail (e.g., paused)

  5. Optimize Routes: Some wrappers may be more gas-efficient than others


Comparison with Other Protocols

Feature
Flux Wrappers
Morpho Markets
Aave V3

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