> For the complete documentation index, see [llms.txt](https://docs.kpk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kpk.io/funds/infrastructure/onchain-accounting/meta-balance-adapters/gearbox.md).

# Gearbox Markets

One immutable meta-adapter that reports an account's passive-liquidity supply in *any* Gearbox V3 ERC-4626 farming pool. Which pools it queries is a governed instance set on the NAV Calculator; the adapter holds no per-pool state. The borrow side is covered by the sibling [Gearbox Credit Accounts](/funds/infrastructure/onchain-accounting/meta-balance-adapters/gearbox-credit-accounts.md) adapter.

* **Type:** Meta-adapter
* **protocolSubId:** `keccak256("gearbox-v3-markets")`
* **Instance key:** the market (pool) address, widened to `bytes32`
* **Source:** [`GearboxV3MarketsMetaBalanceAdapter.sol`](https://github.com/karpatkey/onchain-accounting/blob/main/src/balances/MetaBalanceAdapters/GearboxV3MarketsMetaBalanceAdapter.sol)

***

## Positions returned

One position per pool the account has shares in.

| Leg         | PositionKind | isDebt  | Description                             |
| ----------- | ------------ | ------- | --------------------------------------- |
| Pool supply | `Supplied`   | `false` | Pool shares converted to the underlying |

A pool returns an empty result when its asset is unregistered, excluded by `assetFilter`, or the converted balance is zero. Merkl rewards are not included.

***

## Balance calculation

<figure><img src="/files/d1cXpzYWQMnjTJfEApDc" alt="Flowchart of the Gearbox Markets balance adapter: read calls derive position legs into PositionBalance entries."><figcaption><p>Gearbox Markets adapter — how the underlying balances reported to the NAV Calculator are derived.</p></figcaption></figure>

```
amount = market.convertToAssets(market.balanceOf(account))
```

`convertToAssets` uses the pool's current share price (reflecting interest accrued from Gearbox credit accounts borrowing the pool's liquidity). The result is denominated in `market.asset()`.

***

## Identity

* **positionId:** `abi.encode(address market)` — the pool address
* **positionKind:** `Supplied`

There is no `labels` field on the position. The adapter implements `positionLabels(positionId)`, which returns `["Market", "<market ERC20 name()>"]` from the market's on-chain name — surfaced only by the verbose reads (`getAccountPositionsVerbose` / `getAccountNavVerbose`); the full breadcrumb is `[protocolName, ...labels]`.

***

## Constructor

```solidity
constructor(address navCalculator_)
```

| Parameter        | Description                                             |
| ---------------- | ------------------------------------------------------- |
| `navCalculator_` | NAV Calculator contract (asset registry + instance set) |

***

## Registration

Meta-adapter. Register once and seed its pools with `addMetaBalanceAdapter(adapter, instances)`, then adjust with `addMetaInstances(adapter, instances)` / `removeMetaInstances(adapter, instances)` (MANAGER-gated). Each instance coordinate is a **pool address widened to `bytes32`** (decoded via `_toAddress`). Adding a new pool is a config call — no new deploy.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kpk.io/funds/infrastructure/onchain-accounting/meta-balance-adapters/gearbox.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
