> 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/architecture/onchain-accounting/meta-balance-adapters/pancakeswap-v3.md). Agents can also search and read this documentation through its [MCP server](https://docs.kpk.io/~gitbook/mcp).

# PancakeSwap V3

A meta-adapter that reports an account's PancakeSwap V3 concentrated-liquidity LP across every configured pool, the in-range liquidity (Supplied) and the full uncollected fees (Fees) of each NFT posi

A **meta-adapter** that reports an account's **PancakeSwap V3 concentrated-liquidity LP**: in-range liquidity (`Supplied`) and full uncollected fees (`Fees`) of every NFT position. It subclasses the [Uniswap V3](https://docs.kpk.io/funds/infrastructure/architecture/onchain-accounting/meta-balance-adapters/uniswap-v3.md) meta-adapter and differs in two ways: the `pancakeswap-v3` slug, and an overridden `_slot0` read (below). Everything else is identical.

* **Type:** Meta-adapter
* **protocolSubId:** `keccak256("pancakeswap-v3")` (brand `pancakeswap`, ecosystem `pancakeswap-v3`)
* **Instance key:** the PancakeSwap V3 pool address, widened to bytes32.
* **Source:** `PancakeSwapV3PoolsMetaBalanceAdapter.sol`

{% hint style="info" %}
PancakeSwap declares `slot0().feeProtocol` as `uint32` where Uniswap uses `uint8`, so the strict full-tuple decode needs a PancakeSwap-specific ABI. The override changes how the tuple is *decoded*, not which price is used.
{% endhint %}

## Positions returned

Per NFT in a configured pool, up to four legs (token0/token1 × liquidity/fees):

| Leg              | PositionKind | isDebt  | isLocked | Description                                                                    |
| ---------------- | ------------ | ------- | -------- | ------------------------------------------------------------------------------ |
| token0 liquidity | `Supplied`   | `false` | `false`  | token0 amount of the position's in-range liquidity                             |
| token1 liquidity | `Supplied`   | `false` | `false`  | token1 amount of the position's in-range liquidity                             |
| token0 fees      | `Fees`       | `false` | `false`  | Full uncollected token0 fees (settled `tokensOwed0` + `feeGrowthInside` delta) |
| token1 fees      | `Fees`       | `false` | `false`  | Full uncollected token1 fees (settled `tokensOwed1` + `feeGrowthInside` delta) |

**Both** pool tokens must be registered in NAVCalculator or the whole instance is dropped; a bad instance discards only its own pool. Legs with zero amount, or assets excluded by `assetFilter`, are dropped. Discovery is bounded by `MAX_POSITIONS` (1000); see [Uniswap V3](https://docs.kpk.io/funds/infrastructure/architecture/onchain-accounting/meta-balance-adapters/uniswap-v3.md#positions-returned).

## Balance calculation

<figure><picture><source srcset="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2FPWJExTUqZH1HSQMF888W%2Fmeta-pancakeswap-v3_D.png?alt=media&amp;token=8e648776-4a15-47c3-815b-82c7815a628c" media="(prefers-color-scheme: dark)"><img src="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2F9fPjSaQvQhGUdtIEkxG7%2Fmeta-pancakeswap-v3.png?alt=media&amp;token=95a47da4-3192-49f1-bc7b-35463f80164a" alt="Flowchart of the PancakeSwap V3 balance adapter: read calls derive position legs into PositionBalance entries."></picture><figcaption><p>PancakeSwap V3 adapter: how the underlying balances reported to the NAV Calculator are derived.</p></figcaption></figure>

Identical to [Uniswap V3](https://docs.kpk.io/funds/infrastructure/architecture/onchain-accounting/meta-balance-adapters/uniswap-v3.md#balance-calculation) apart from the `_slot0` decode: the adapter reads `NPM.positions(tokenId)` and the pool's live `slot0`, then derives the legs via `UniswapV3PoolLib.positionAmounts(...)`.

* **Liquidity legs (`Supplied`):** in-range amounts at the **live `slot0`** price. See the [Uniswap V3 note](https://docs.kpk.io/funds/infrastructure/architecture/onchain-accounting/meta-balance-adapters/uniswap-v3.md#balance-calculation) on why this is safe under the async NAV-consumer model.
* **Fee legs (`Fees`):** settled `tokensOwed0` / `tokensOwed1` **plus** the `feeGrowthInside` delta.

## Identity

* **positionId:** `abi.encode(address pool)`, the instance coordinate. All of an account's NFTs in the same pool share one positionId and **sum**.
* **positionInstanceId:** `bytes32(tokenId)`, the NFT id, excluded from the identity key.
* **positionKind:** `Supplied` for liquidity legs, `Fees` for fee legs.
* **labels:** there is no `labels` field on the position. `positionLabels(positionId)` returns `["AMM Liquidity Pool", "<sym0>/<sym1> <fee>%"]`, read live from the pool and shown only on the verbose reads.

## Constructor

```solidity
constructor(
    address positionManager_,
    address navCalculator_
)
```

| Parameter          | Description                                                                                   |
| ------------------ | --------------------------------------------------------------------------------------------- |
| `positionManager_` | The PancakeSwap V3 NonfungiblePositionManager (canonical CREATE2 address). Must be a contract |
| `navCalculator_`   | NAVCalculator contract for asset-registry access. Must be a contract                          |

Pool addresses are **not** pinned; they are the governed instance set on NAVCalculator. Like its base, the adapter is `GPL-2.0-or-later` (it links the Uniswap V3 math libraries).

## Registration

Register once with `addMetaBalanceAdapter(adapter, pools)`, then enable each pool with `addMetaInstances(adapter, pools)` and drop coverage with `removeMetaInstances`. The adapter reads its active set from `NAV_CALCULATOR.getMetaInstances(address(this))`. See Meta balance adapters.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
