Interface Reference

Complete API documentation for all Flux Protocol contract interfaces.

Table of Contents


IFluxVault

The core vault contract implementing ERC4626 with position management.

Inherits: IERC4626

Location: src/interfaces/IFluxVault.sol

Main Entry Points

unlock(bytes calldata data)

Triggers the unlock callback for manager to execute strategy.

Parameters:

  • data: Arbitrary data passed to executor's fluxUnlockCallback

Access: Anyone (but requires registered executor)

Flow:

  1. Accrue interest

  2. Verify caller has registered executor

  3. Set lock to caller

  4. Call executor's fluxUnlockCallback(data)

  5. Verify position health after callback

  6. Release lock

Example:

Reverts:

  • NoExecutorRegistered() - Caller hasn't registered executor

  • PositionNotHealthy() - Position unhealthy after callback


liquidate(address manager, IAsset[] calldata additionalWrappers, bytes calldata data)

Liquidate an unhealthy manager position.

Parameters:

  • manager: Address of manager to liquidate

  • additionalWrappers: Extra wrappers that may hold positions

  • data: Arbitrary data for liquidator's callback

Access: Anyone (permissionless)

Flow:

  1. Accrue interest

  2. Verify position is liquidatable

  3. Transfer all manager positions to liquidator

  4. Call liquidator's fluxUnlockCallback with (minPayment, trueDebt, data)

  5. Verify liquidator prepared minimum payment

  6. Take payment, record any bad debt

  7. Delete manager position

Example:

Reverts:

  • PositionNotActive() - Manager has no position

  • PositionNotLiquidatable() - Position is healthy

  • InsufficientPayment() - Liquidator didn't prepare enough


Locked Operations

Called only during unlock/liquidation callback (when vault lock is held).

locked_borrow(uint256 amount)

Borrow capital from vault.

Parameters:

  • amount: Amount to borrow in base asset

Access: Lock holder only

Effects:

  • Increases manager's principal debt

  • Deposits borrowed amount to manager's working capital (base wrapper)

  • Emits Borrowed(manager, amount, newDebt)

Example:

Reverts:

  • InsufficientIdleLiquidity() - Vault doesn't have enough liquidity


locked_repay(uint256 amount)

Repay borrowed capital.

Parameters:

  • amount: Amount to repay in base asset

Access: Lock holder only

Effects:

  • Withdraws from manager's working capital (base wrapper)

  • Reduces manager's principal debt

  • Emits Repaid(manager, amount, remainingDebt)

Example:


locked_depositBond(uint256 amount)

Post bond collateral.

Parameters:

  • amount: Amount of base asset to post as bond

Access: Lock holder only

Effects:

  • Transfers base asset from caller

  • Deposits to manager's bond position (base wrapper)

  • Updates manager's bond balance

Example:


locked_withdrawBond(uint256 amount)

Withdraw bond collateral.

Parameters:

  • amount: Amount to withdraw

Access: Lock holder only

Constraints:

  • Can only withdraw if position remains healthy

  • Bond ratio must stay above minimum

Example:


locked_registerWrapper(address wrapper)

Register an asset wrapper for use.

Parameters:

  • wrapper: Address of wrapper contract

Access: Lock holder only

Constraints:

  • Wrapper must be whitelisted by factory

  • Wrapper must be allowed in vault's strategy

  • Cannot register same wrapper twice

Example:

Reverts:

  • WrapperNotWhitelisted() - Wrapper not approved by governance

  • WrapperNotAllowed() - Strategy doesn't allow this wrapper

  • WrapperAlreadyRegistered() - Already registered


locked_depositToWrapper(IAsset wrapper, bytes32 positionId, uint256 amount)

Deposit assets into a wrapper position.

Parameters:

  • wrapper: Wrapper contract address

  • positionId: Position identifier (use bytes32(0) for working capital)

  • amount: Amount to deposit

Access: Lock holder only

Flow:

  1. Approve wrapper to spend tokens

  2. Call wrapper.deposit(vault, manager, positionId, amount)

Example:


locked_withdrawFromWrapper(IAsset wrapper, bytes32 positionId, uint256 amount)

Withdraw assets from wrapper position.

Parameters:

  • wrapper: Wrapper contract address

  • positionId: Position identifier

  • amount: Amount to withdraw (type(uint256).max for all)

Access: Lock holder only

Effects:

  • Calls wrapper.withdraw(vault, manager, positionId, recipient, amount)

  • Assets sent to lock holder

Example:


locked_claimFromWrapper(IAsset wrapper, bytes32 positionId, uint256 amountOrTokenId)

Claim pre-received assets.

Use Case: Claim airdrops, rewards, or assets already sent to wrapper

Example:


locked_interactWithWrapper(address wrapper, bytes calldata data)

Call arbitrary function on wrapper.

Parameters:

  • wrapper: Wrapper address

  • data: Encoded function call

Use Case: Advanced wrapper interactions (staking, voting, etc.)

Example:


View Functions - Vault/LP

getIdleLiquidity()

Get available liquidity for borrowing.

Returns: Amount of base asset in vault (not borrowed)

Example:


getProjectedLpIndex()

Calculate current LP index including accrued interest.

Returns:

  • newIndex: Projected LP index (1e18 scale)

  • totalGrowth: Total interest growth since last checkpoint

  • protocolCut: Protocol's share of growth

  • protocolFeeEarned: Protocol fee in asset terms

  • creatorCut: Creator's share of growth

  • creatorFeeEarned: Creator fee in asset terms

Example:


View Functions - Manager/Position

getManagerTrueDebt(address manager)

Get manager's current debt including accrued interest.

Returns: Current debt in base asset

Formula: principalDebt * currentLpIndex / snapshotLpIndex

Example:


getManagerPosition(address manager)

Get manager's position details.

Returns:

  • principalDebt: Original borrowed amount

  • bondAmount: Bond balance (in base wrapper)

  • lastLpIndexSnapshot: LP index when position was created/updated

Example:


getBondBalance(address manager)

Get manager's bond amount (in base wrapper).

Example:


getWorkingCapital(address manager)

Get manager's working capital (in base wrapper).

Use: Check how much base asset manager can use for operations


getRegisteredWrappers(address manager)

Get all wrappers registered by manager.

Example:


isPositionHealthy(address manager)

Quick check if position is healthy.

Returns: true if health ratio >= liquidation threshold

Example:


Immutable Constants

STRATEGY()

Returns vault's strategy contract (immutable).


FACTORY()

Returns factory that deployed this vault (immutable).


BASE_ASSET_WRAPPER()

Returns wrapper for vault's base asset (immutable).


VAULT_CREATOR()

Returns address that created the vault (immutable).


ERC4626 Functions

Flux vaults implement standard ERC4626:

See ERC4626 Specification for details.


IAsset

Universal interface for asset wrappers.

Location: src/interfaces/IAsset.sol

Three-Layer Position Model

Positions are identified by three components:

Example:

Core Functions

deposit(address account, address subaccount, bytes32 positionId, uint256 amount)

Deposit assets into position.

Parameters:

  • account: Main account (typically vault address)

  • subaccount: Subaccount (typically manager address)

  • positionId: Position identifier

  • amount: Amount to deposit

Access: Typically vault only

Example:


withdraw(address account, address subaccount, bytes32 positionId, address recipient, uint256 amount)

Withdraw assets from position.

Parameters:

  • account: Account to withdraw from

  • subaccount: Subaccount to withdraw from

  • positionId: Position to withdraw from

  • recipient: Address to receive assets

  • amount: Amount to withdraw (type(uint256).max for all)

Example:


getValue(address account, address subaccount, bytes32 positionId)

Get USD value of position.

Returns: Value in USD with 18 decimals

Implementation: Calls oracle to convert balance to USD

Example:


getBalance(address account, address subaccount, bytes32 positionId)

Get actual balance held.

Returns: Balance in native asset units

Difference from getValue:

  • getBalance: Raw balance (e.g., 10 WETH)

  • getValue: USD value (e.g., $25,000)


underlyingAsset()

Get underlying ERC20 token.

Example:


ledgerTransferSubaccount(address fromSubaccount, address toSubaccount)

Transfer entire subaccount (all positions).

Use: Liquidations (transfer all manager positions to liquidator)

Access: Vault only


IStrategy

Strategy interface defining economic parameters and risk evaluation.

Location: src/interfaces/IStrategy.sol

Risk Evaluation

evaluateLiquidation(address vault, address manager)

Check if position can be liquidated.

Returns:

  • canLiquidate: Whether position is unhealthy

  • minPayment: Minimum payment liquidator must provide

  • oraclePrices: Oracle prices used (for event logging)

Example:


evaluateADL(address vault, address manager)

Check if position can be ADL'd.

Returns:

  • canADL: Whether position is eligible for ADL

  • managerNetEquityUSD: Manager's net equity to return

Example:


Rate Parameters

annualRate()

Returns: Annual interest rate (18 decimals, e.g., 0.1e18 = 10%)


vaultCreatorFeeRate()

Returns: Creator fee in basis points (e.g., 1000 = 10%)


Risk Parameters

minBondRatio()

Returns: Minimum bond ratio (18 decimals, e.g., 0.2e18 = 20%)


liquidationThreshold()

Returns: Health ratio below which position is liquidatable (18 decimals)

Example: 1.1e18 = 110% (position liquidatable when health < 110%)


adlThreshold()

Returns: Health ratio below which position can be ADL'd (18 decimals)

Example: 1.2e18 = 120%


adlUtilizationThreshold()

Returns: Vault utilization required for ADL (18 decimals)

Example: 0.95e18 = 95% utilization


isAssetAllowed(address wrapper)

Returns: Whether wrapper can be used in this strategy


IFluxVaultFactory

Factory for deploying vaults and managing protocol.

Location: src/interfaces/IFluxVaultFactory.sol

Vault Creation

createVault(...)

Parameters:

  • asset: Base asset (USDC, WETH, etc.)

  • baseAssetWrapper: Wrapper for base asset

  • strategy: Strategy contract

  • accessPolicy: Access control (address(0) = permissionless)

  • name: Vault name

  • symbol: Share symbol

Returns: Deployed vault address


Executor Management

deployWeirollExecutor()

Returns: Deployed executor address (auto-registered to caller)


registerExecutor(address manager, address executor)

Parameters:

  • manager: Manager address

  • executor: Executor contract address


getExecutor(address manager)

Returns: Executor for given manager


Asset Whitelisting

whitelistAsset(address asset)

Access: Governance only

Effect: Approve wrapper for use in vaults


isAssetWhitelisted(address asset)

Returns: Whether asset wrapper is whitelisted


Fee Management

protocolFeeRate()

Returns: Protocol fee in basis points


setProtocolFeeRate(uint256 newRate)

Access: Governance only

Constraints: Max 10% (1000 bps)


IFluxVaultLens

Read-only aggregation contract for batch queries.

Location: src/interfaces/IFluxVaultLens.sol

Manager Queries

getManagerPositionValue(address vault, address manager)

Get total collateral value.

Returns: Total value in USD (18 decimals)

Aggregates:

  • Bond value

  • Working capital value

  • All wrapper positions

Example:


getManagerHealth(address vault, address manager)

Get health ratio.

Returns: Health ratio (18 decimals, e.g., 1.5e18 = 150%)


getManagerDetails(address vault, address manager)

Get comprehensive position data.

Returns (ManagerDetails struct):

  • Position data (debt, bond, timestamp)

  • Collateral breakdown by wrapper

  • Health ratio

  • Liquidation status

  • Wrapper addresses

Use: Single call to populate full UI


Vault Queries

getVaultStats(address vault)

Get vault overview.

Returns (VaultStats struct):

  • Total assets

  • Idle liquidity

  • Utilization %

  • Bad debt

  • Share price

  • LP index

  • Interest accrued


Liquidation Preview

previewLiquidation(address vault, address manager)

Preview liquidation profitability.

Returns (LiquidationPreview struct):

  • Can liquidate?

  • Min payment required

  • Estimated collateral seized

  • Estimated profit

  • Health ratio

Use: Liquidator bots to evaluate opportunities


IOracleRegistry

Centralized oracle system.

Location: src/interfaces/IOracleRegistry.sol

Price Queries

getValueUSD(address asset, uint256 amount)

Convert amount to USD value.

Parameters:

  • asset: Token address

  • amount: Amount in token's decimals

Returns: Value in USD (18 decimals)

Example:


getPrice(address asset)

Get price of 1 unit.

Returns: Price in USD (18 decimals) for 1 unit of asset


Oracle Management

addOracle(address asset, address feed)

Add price feed for asset.

Access: Governance only


getLastUpdate(address asset)

Get timestamp of last oracle update.

Use: Check oracle freshness


Summary

Key Interfaces:

Interface
Purpose
Main Functions

IFluxVault

Core vault operations

unlock, liquidate, locked_* operations

IAsset

Asset wrapper standard

deposit, withdraw, getValue

IStrategy

Risk parameters

evaluateLiquidation, evaluateADL, param getters

IFluxVaultFactory

Vault deployment

createVault, registerExecutor, whitelistAsset

IFluxVaultLens

Batch queries

getManagerDetails, getVaultStats, previewLiquidation

IOracleRegistry

Price feeds

getValueUSD, getPrice

ABI Locations:

  • npm: @flux-protocol/contracts/abi/*.json

  • GitHub: out/[Contract].sol/[Contract].json

  • Block Explorer: Contract page → Download ABI


Last updated