> 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/fluid-vaults.md). Agents can also search and read this documentation through its [MCP server](https://docs.kpk.io/~gitbook/mcp).

# Fluid Vaults

One immutable meta-adapter that reports an account's collateral and debt across any Fluid T1 vault.

One immutable meta-adapter that reports an account's collateral and debt across any Fluid T1 vault. Per vault it emits a `Collateral` leg (supply) and a `Borrowed` leg (debt), aggregated over the account's Fluid NFT positions in that vault.

* **Type:** Meta-adapter
* **protocolSubId:** `keccak256("fluid-vaults")`
* **Instance key:** the Fluid T1 vault address, widened to `bytes32`.
* **Source:** `FluidVaultsMetaBalanceAdapter.sol`

{% hint style="warning" %}
Only Fluid **T1** vaults are supported; Smart vaults (T2/T3/T4) have a different, longer `constantsView` layout. This is **enforced onchain**: the token read is gated on the VaultResolver's `getVaultType(vault)` and fails closed, so a mis-configured non-T1 instance reports nothing, no legs and no underlying assets. The guard matters because adding an instance is a `MANAGER` config transaction rather than a deploy.
{% endhint %}

## Positions returned

Up to two legs per vault:

| Leg        | PositionKind | isDebt  | Description                                            |
| ---------- | ------------ | ------- | ------------------------------------------------------ |
| Collateral | `Collateral` | `false` | Total supplied collateral, in the vault's supply token |
| Borrow     | `Borrowed`   | `true`  | Total outstanding debt, in the vault's borrow token    |

A leg is dropped when its amount is zero, when the token is not registered in NAVCalculator, or when filtered out by `assetFilter`. If the account **has debt** in the vault and the borrow token is unregistered, the vault reports **nothing at all**, the collateral leg included, rather than collateral with no offsetting debt.

The NFT aggregation is **complete or nothing**: if a position read runs out of gas mid-loop, the vault raises `FluidPositionGasExhausted(vault, nftId, stipend, consumed)` rather than returning a partial sum. Each NFT contributes both a supply and a borrow, so silently omitting one moves equity by `supply − borrow`, an over-report for an underwater position. See [Never report collateral without its debt](https://docs.kpk.io/funds/infrastructure/architecture/onchain-accounting/balance-adapters.md#how-an-adapter-is-built).

## Balance calculation

<figure><picture><source srcset="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2Fva3vVOyU2nix9zsbf2BY%2Fmeta-fluid-vaults_D.png?alt=media&amp;token=afffc79a-c58b-42df-9733-23d4bfbcfd2b" media="(prefers-color-scheme: dark)"><img src="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2FPc6r22eFzNZOjmnsc81I%2Fmeta-fluid-vaults.png?alt=media&amp;token=326d585d-5155-4e39-8a9d-5877742a7963" alt="Flowchart of the Fluid Vaults balance adapter: read calls derive position legs into PositionBalance entries."></picture><figcaption><p>Fluid Vaults adapter: how the underlying balances reported to the NAV Calculator are derived.</p></figcaption></figure>

The supply and borrow tokens come from the vault's `constantsView()` (`supplyToken`, `borrowToken`). Amounts are aggregated across the account's Fluid NFT positions via the VaultResolver (logic in `FluidVaultLib`):

```
nftIds = VaultResolver.positionsNftIdOfUser(account)
for each nftId where VaultResolver.vaultByNftId(nftId) == vault:
    pos = VaultResolver.positionByNftId(nftId)
    if pos.isLiquidated: skip
    collateral += pos.supply
    debt       += pos.borrow
```

`collateral` is reported in supply-token decimals, `debt` in borrow-token decimals. Liquidated positions are skipped.

## Identity

* **positionId:** `abi.encode(address vault)`
* **positionKind:** `Collateral` (supply leg), `Borrowed` (debt leg)

The position has no `labels` field. `positionLabels(positionId)` returns `["Vault", "<collateral>/<debt> #<vaultId>"]`, e.g. `["Vault", "wstETH/USDC #4"]`, surfaced only by the verbose reads (`getAccountPositionsVerbose` / `getAccountNavVerbose`); the full breadcrumb is `[protocolName, ...labels]`.

A Fluid vault is not an ERC20, so the leaf is built from the token pair plus Fluid's per-vault id, because the pair alone is not unique. Symbols resolve from the NAV's registered-asset record (which maps the ERC-7528 native sentinel to the native symbol), then a direct ERC20 read, then `"?"`, so an unreadable side renders as `"?/USDC"`.

## Constructor

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

| Parameter        | Description                                                                                                       |
| ---------------- | ----------------------------------------------------------------------------------------------------------------- |
| `vaultResolver_` | Fluid VaultResolver address (chain-level constant) used for NFT enumeration and per-NFT reads. Must be a contract |
| `navCalculator_` | NAVCalculator address, used for the registered-asset registry. Must be a contract                                 |

## Registration

Register with `addMetaBalanceAdapter(adapter, instances)`, then add or remove vaults with `addMetaInstances(adapter, instances)` / `removeMetaInstances(adapter, instances)`. The instance coordinate is the T1 vault address widened to `bytes32`.


---

# 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/fluid-vaults.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.
