For the complete documentation index, see llms.txt. This page is also available as Markdown.

Gearbox Credit Accounts

One immutable meta-adapter that reports the borrow side of an account's Gearbox V3 Credit Accounts — the collateral basket netted against the debt.

One immutable meta-adapter that reports the borrow side of Gearbox V3 — each Credit Account's collateral basket netted against its debt. The supply side (passive liquidity in the ERC-4626 farming pools) is the separate Gearbox Markets adapter. Which Credit Accounts it queries is a governed instance set on the NAV Calculator; the adapter holds no per-account state.

  • Type: Meta-adapter

  • protocolSubId: keccak256("gearbox-v3-credit-accounts") (brand gearbox, ecosystem gearbox-v3)

  • Instance key: the Credit Account address, widened to bytes32


Why key on the Credit Account

Gearbox exposes only the reverse lookup — creditAccountInfo(ca).borrower and creditAccounts() (every open account) — with no borrower → creditAccount view. So the meta instance is the Credit Account address, and each read confirms creditAccountInfo(ca).borrower == account. A queried sub-account therefore only ever sees the Credit Accounts it actually owns; a closed or liquidated account reads borrower == address(0) and contributes nothing.


Positions returned

Per Credit Account the account owns, one debt leg plus one leg per enabled collateral token:

Leg
PositionKind
isDebt
isLocked
Description

Borrowed

Borrowed

true

false

Total owed in the pool's underlying — debt + accruedInterest + accruedFees from calcDebtAndCollateral(ca, DEBT_ONLY)

Collateral

Collateral

false

false

One leg per enabled token the account holds (balanceOf(creditAccount))

NAV nets the collateral basket against the debt into the account's equity contribution. Collateral tokens that are unregistered/unpriced in NAVCalculator (or excluded by assetFilter) and zero balances are skipped.

Never over-reports. The adapter values the debt first. If the debt can't be read — or can't be reported, because the underlying is unreadable or unregistered on NAVCalculator — it drops the whole Credit Account (empty) rather than emit collateral with no offsetting debt, which would overstate equity. Dropping an unregistered collateral token while still counting the full debt likewise only ever under-reports. See Never report collateral without its debt.


Balance calculation

Flowchart of the Gearbox Credit Accounts balance adapter: each cached Credit Account is checked for ownership and a readable debt, then valued into a Borrowed leg plus per-token Collateral legs.
Gearbox Credit Accounts adapter — how the underlying balances reported to the NAV Calculator are derived.

For each cached Credit Account, the adapter resolves its Credit Manager, confirms borrower == account, values the debt, then enumerates enabled collateral tokens:

Collateral is valued at instantaneous on-chain token balances priced by NAVCalculator; the debt is the total owed in the pool's underlying.


Identity

  • positionId: abi.encode(address creditAccount) — all legs of one Credit Account (the Borrowed leg and every Collateral leg) share this anchor and are told apart by positionKind + balanceAsset.asset.

  • positionInstanceId: bytes32(0) — the Credit Account address is a stable anchor, so its identity lives in positionId; there is no separate ephemeral handle.

  • positionKind: Borrowed · Collateral

  • labels: there is no labels field on the position. The adapter implements positionLabels(positionId), which returns ["Credit Account", "<credit-manager name()>"] — falling back to the pool's underlying asset symbol (e.g. "USDC") when the credit manager's name() is missing or empty. Surfaced only by the verbose reads; the full breadcrumb is [protocolName, ...labels].


Constructor

Parameter
Description

navCalculator_

NAV Calculator contract (asset registry + instance set)


Registration

Meta-adapter. Register once and seed its Credit Accounts with addMetaBalanceAdapter(adapter, instances), then adjust with addMetaInstances(adapter, instances) / removeMetaInstances(adapter, instances) (MANAGER-gated). Each instance coordinate is a Credit Account address widened to bytes32 (decoded via _toAddress). A malformed coordinate is isolated per-instance by the fan-out.

Last updated