> 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/balancer-v2-pools.md).

# Balancer V2 Pools

Reports an account's **wallet-held (unstaked)** Balancer V2 pool liquidity across any pool. It decomposes the account's BPT balance pro-rata into the pool's underlying tokens by reading the Balancer V2 Vault's live balances — the AMM-supplied LP only. Gauge-staked LP and rewards are the separate [Balancer V2 Gauges](/funds/infrastructure/onchain-accounting/meta-balance-adapters/balancer-v2-gauges.md) adapter.

* **Type:** Meta-adapter
* **protocolSubId:** `keccak256("balancer-v2-pools")`
* **Instance key:** the pool's **raw `bytes32` poolId** (used directly, not an address). The BPT (ERC20) address is the top 160 bits of the poolId.
* **Source:** [`BalancerV2PoolsMetaBalanceAdapter.sol`](https://github.com/karpatkey/onchain-accounting/blob/main/src/balances/MetaBalanceAdapters/balancer/BalancerV2PoolsMetaBalanceAdapter.sol)

***

## Positions returned

One leg per registered underlying pool token with a non-zero share:

| Leg    | PositionKind | isDebt  | Description                                                                |
| ------ | ------------ | ------- | -------------------------------------------------------------------------- |
| Supply | `Supplied`   | `false` | Pro-rata share of one underlying pool token, from the account's wallet BPT |

The pool's own pre-minted BPT (composable-stable pools) is excluded from the token list. Unregistered, zero-amount, and asset-filtered tokens are skipped.

***

## Balance calculation

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

Balancer V2 holds every pool's tokens in a single Vault. For BPT balance `walletBpt = BPT.balanceOf(account)` (returns nothing if zero), `BalancerV2PoolLib.shares` reads the Vault's `getPoolTokens(poolId)` balances and computes each token's pro-rata amount:

```
amount[i] = balances[i] * walletBpt / effectiveSupply
```

`effectiveSupply` is `getActualSupply()` when the pool exposes it (composable-stable: excludes pre-minted BPT, includes due protocol fees) and falls back to `totalSupply()` for legacy weighted/stable pools.

***

## Identity

* **positionId:** `abi.encode(bytes32 poolId)`
* **positionKind:** `Supplied`

There is no `labels` field on the position. The adapter implements `positionLabels(positionId)`, which returns `["AMM Liquidity Pool", "<sym0>/<sym1>/…"]` from the pool's underlying token symbols — surfaced only by the verbose reads (`getAccountPositionsVerbose` / `getAccountNavVerbose`); the full breadcrumb is `[protocolName, ...labels]`.

***

## Constructor

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

| Parameter        | Description                                                                                                  |
| ---------------- | ------------------------------------------------------------------------------------------------------------ |
| `vault_`         | Balancer V2 Vault address (must be a contract); the chain-level singleton that custodies every pool's tokens |
| `navCalculator_` | NAVCalculator address (must be a contract); source of the asset registry and the instance set                |

***

## Registration

Registered as a meta-adapter via `addMetaBalanceAdapter(adapter, instances)`, with the instance set adjusted by `addMetaInstances` / `removeMetaInstances`. Instance coordinates are passed as `bytes32` and stored as-is — for Balancer V2 each coordinate is the **raw `bytes32` poolId** (not an address widened to `bytes32`, as most meta-adapters use). The adapter recovers the BPT from the poolId's top 160 bits when it needs the ERC-20.


---

# 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/balancer-v2-pools.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.
