Skip to main content
Supply transfers tokens from the caller to the pool and records collateral on a lending account. Use the quickstart for a first transaction, or follow this guide to add supply to an integration.

Prepare the account and assets

Pass account_id = 0 to create an account in Normal mode. The call returns its id and mints the position NFT to caller. For an existing account, pass its id and stored spoke_id; the spoke cannot change. Each entry is (HubAssetKey, amount), where HubAssetKey is { hub_id, asset } and amount is a strictly positive integer in token base units. Duplicate market entries are summed in first-appearance order. Before submitting, check that:
  • The market exists on an active hub and is listed on the account’s spoke.
  • The listing is collateralizable, unfrozen, and unpaused, and the protocol is unpaused.
  • Supply caps and position limits leave enough headroom.
  • A collateral asset below 3 decimals is the account’s only supply market.
  • The caller holds and authorizes the tokens being supplied.
An owner or active delegate can add a supply position. Other callers may add only to a market that already has a supply position in the account. See account authority. Supply generally needs no oracle prices. A risk-parameter refresh that makes liquidation terms less favorable on an indebted account can require valuation; unusable prices then revert the transaction. See risk-parameter refresh.

Build and authorize the call

This example supplies 1,000 tokens at 7 decimals. Set CONTROLLER, IDENTITY, and CALLER_ADDRESS as in the quickstart. Replace the spoke, hub, and token inputs for the selected network. The caller authorizes the controller call and one token transfer per aggregated market from caller to the pool. Wallet integrations prepare the transaction before signing. Contract integrations pre-authorize the nested transfer with authorize_as_current_contract. The pool credits the amount actually received. Supply shares round down; a payment too small to mint a share reverts.

Verify the supply

Persist the returned account id. Read get_account_positions(account_id) and get_collateral_amount(account_id, hub_asset) to confirm the supplied balance. The balance view includes accrued interest and returns token base units with half-up rounding. It is a display balance, not a full-withdrawal payout. Use the v1 position arrays for portfolio rendering; direct views are useful for transaction reconciliation. The controller emits UpdatePositionBatchEvent at ["position", "batch_update"], with Supply legs. The pool emits PoolMarketStateBatchEvent at ["market", "batch_state_update"].

Common errors

Continue with Borrow, or use Withdraw to remove supplied collateral.