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")(brandgearbox, ecosystemgearbox-v3)Instance key: the Credit Account address, widened to
bytes32
This page documents the design; Deployment addresses is the authority on whether it is live. If this adapter has no entry there, it is not deployed and has no instance set — the contract and its unit tests exist without being wired into the deploy configuration.
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:
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
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 bypositionKind+balanceAsset.asset.positionInstanceId:
bytes32(0)— the Credit Account address is a stable anchor, so its identity lives inpositionId; there is no separate ephemeral handle.positionKind:
Borrowed·Collaterallabels: there is no
labelsfield on the position. The adapter implementspositionLabels(positionId), which returns["Credit Account", "<credit-manager name()>"]— falling back to the pool's underlying asset symbol (e.g."USDC") when the credit manager'sname()is missing or empty. Surfaced only by the verbose reads; the full breadcrumb is[protocolName, ...labels].
Constructor
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