Skip to main content
The controller is the integrator-facing lending contract. The pool is owned by the controller and is not called directly by users. Types are defined in Data types. Error codes are listed in Errors. Events are listed in Events.
In production, governance owns the controller. Owner-gated configuration is reached through governance proposal, timelock, and execution.

User Operations

FunctionAuthReturnsNotes
supply(caller, account_id, spoke_id, assets)calleru64assets: Vec<(HubAssetKey, i128)>. account_id = 0 creates an account on spoke_id.
borrow(caller, account_id, borrows, to)account owner/delegate()borrows: Vec<(HubAssetKey, i128)>. Tokens go to to when set, otherwise caller.
withdraw(caller, account_id, withdrawals, to)account owner/delegateVec<(HubAssetKey, i128)>Amount 0 closes the position for that hub asset.
repay(caller, account_id, payments)payer()Permissionless repayment; overpayment is refunded to payer.
liquidate(liquidator, account_id, debt_payments)liquidator()Requires target health factor below one; self-liquidation is rejected.
flash_loan(caller, asset, amount, receiver, data)caller()asset: HubAssetKey; receiver must repay amount plus fee in callback.
renew_account(caller, account_id)account owner()Extends account storage TTL.

Strategy Operations

FunctionAuthReturnsNotes
multiply(caller, account_id, spoke_id, collateral, debt_to_flash_loan, debt, mode, swap, initial_payment, convert_swap)calleru64Opens or adjusts leveraged account on spoke_id. collateral, debt, and initial_payment use HubAssetKey.
swap_debt(caller, account_id, existing_debt, amount, new_debt, swap)account owner/delegate()Refinances debt from one hub asset to another.
swap_collateral(caller, account_id, current, amount, new, swap)account owner/delegate()Replaces supplied collateral through aggregator route.
repay_debt_with_collateral(caller, account_id, collateral, collateral_amount, debt, swap, close_position)account owner/delegate()Uses collateral proceeds to repay debt.
migrate_from_blend(caller, account_id, spoke_id, hub_id, blend_pool, collateral_assets, supply_assets, debt_caps)calleru64Migrates a Blend V2 position into controller positions on hub_id.

Maintenance

These calls are caller-signed and do not require special protocol authority.
FunctionNotes
update_indexes(caller, assets)assets: Vec<HubAssetKey>. Accrues pool indexes.
update_account_threshold(caller, asset, has_risks, account_ids)Refreshes stored collateral risk parameters for accounts.
clean_bad_debt(caller, account_id)Socializes eligible residual bad debt.
claim_revenue(caller, assets)Claims pool revenue for Vec<HubAssetKey> and forwards to accumulator.
add_rewards(caller, rewards)Adds external rewards for Vec<(HubAssetKey, i128)>.

Owner-Gated Configuration

In production these calls are executed through governance timelock:
  • set_liquidity_pool_template
  • deploy_pool
  • approve_token / revoke_token
  • create_liquidity_pool
  • upgrade_liquidity_pool_params
  • upgrade_pool
  • set_position_limits
  • set_min_borrow_collateral_usd
  • add_spoke
  • deprecate_spoke
  • add_asset_to_spoke
  • edit_asset_in_spoke
  • remove_asset_from_spoke
  • set_market_oracle_config
  • set_oracle_tolerance
  • disable_token_oracle
  • set_aggregator
  • set_accumulator
  • approve_blend_pool / revoke_blend_pool
  • ownership, upgrade, and migration entrypoints

Views

Common views:
  • health_factor(account_id)
  • total_collateral_in_usd(account_id)
  • total_borrow_in_usd(account_id)
  • ltv_collateral_in_usd(account_id)
  • collateral_amount_for_hub_asset(account_id, hub_asset)
  • borrow_amount_for_hub_asset(account_id, hub_asset)
  • max_withdraw(account_id, hub_asset)
  • max_borrow(account_id, hub_asset)
  • max_supply(account_id, hub_asset)
  • get_market_index(hub_asset)
  • get_account_positions(account_id)
  • get_account_attributes(account_id)
  • get_spoke(spoke_id)
  • get_spoke_asset(spoke_id, hub_asset)
  • get_markets_detailed(hub_assets)
  • get_market_indexes_detailed(hub_assets)
  • get_liquidation_estimate(account_id, debt_payments)
  • get_pool_address()
  • get_min_borrow_collateral_usd()
  • is_blend_pool_approved(pool)

Notes

  • HubAssetKey is the market coordinate used by user flows, pool rows, keeper, and most views.
  • Account creation uses spoke_id, not an account category.
  • Price activation uses AssetOracle(asset).