> 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/balance-adapters/lido-withdrawal-queue.md).

# Lido Withdrawal Queue

A plain adapter that reports the native ETH owed to an account from open requests in Lido's WithdrawalQueueERC721.

A plain adapter that reports the native ETH owed to an account from open requests in Lido's `WithdrawalQueueERC721`. An unstake request locks stETH and mints an ERC-721 request id; the claim pays native ETH, so the position is denominated in ETH (priced via the ETH feed, not stETH).

* **Type:** Plain adapter
* **protocolSubId:** `keccak256("lido-withdrawal")`
* **Source:** `LidoWithdrawalQueueBalanceAdapter.sol`

## Positions returned

One `Supplied` leg per open (un-claimed) request, all sharing one static positionId:

| Leg                   | PositionKind | isDebt  | isLocked | Description                                                |
| --------------------- | ------------ | ------- | -------- | ---------------------------------------------------------- |
| Per finalised request | `Supplied`   | `false` | `false`  | Native ETH from a finalised request, withdrawable now      |
| Per pending request   | `Supplied`   | `false` | `true`   | Native ETH from a not-yet-finalised request, still pending |

Each leg is denominated in native ETH (in `balanceAsset`), with `positionInstanceId = bytes32(requestId)`. A zero-amount leg is omitted; the position is dropped if native ETH is not registered in NAVCalculator, if there are no open requests, or if `assetFilter` excludes it. `getAdapterBalances` still reports the summed total.

## Balance calculation

<figure><picture><source srcset="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2FaXRvecNK1v0zh1rD8FbM%2Fadapter-lido-withdrawal-queue_D.png?alt=media&amp;token=6e8e184f-87b8-4bba-b9bb-1bb16df5b86f" media="(prefers-color-scheme: dark)"><img src="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2FbbXoBkmHpJK82pCpFEih%2Fadapter-lido-withdrawal-queue.png?alt=media&amp;token=dd734a8c-093d-4b2b-a884-4db922f1fea6" alt="Flowchart of the Lido Withdrawal Queue balance adapter: read calls derive position legs into PositionBalance entries."></picture><figcaption><p>Lido Withdrawal Queue adapter: how the underlying balances reported to the NAV Calculator are derived.</p></figcaption></figure>

The adapter reads `balanceOf(account)` first as a zero short-circuit, then reads the **full** request set with **no adapter-level cap**. A third party can inflate the list, but each request is real, claimable ETH, so the cost falls on that account's own read. If the list outgrows the forwarded gas, the read **reverts** (`AdapterGasExhausted`) for that account instead of omitting the leg; see [a starved read is not an empty read](https://docs.kpk.io/funds/infrastructure/architecture/onchain-accounting/balance-adapters.md#how-an-adapter-is-built). It emits one leg per un-claimed request:

```
for each request (skipping isClaimed):
    if isFinalized and lastCheckpoint != 0:
        amount = getClaimableEther([id], findCheckpointHints([id], 1, lastCheckpoint))[0]; isLocked = false
    else:
        amount = min(getPooledEthByShares(status.amountOfShares), status.amountOfStETH); isLocked = true
    emit leg { amount, isLocked, positionInstanceId = bytes32(id) }
```

A request is finalised iff `isFinalized && lastCheckpoint != 0`; it uses Lido's exact claimable ETH and `isLocked=false`. Pending requests report the **conservative** `min(getPooledEthByShares(amountOfShares), amountOfStETH)`: `amountOfStETH` is snapshotted at request time, but a Lido **negative rebase** before finalisation caps the payout at the lower share value. If the share read reverts, the adapter falls back to `amountOfStETH`. Claimable lookups run one request at a time because `findCheckpointHints` requires an ascending-sorted id array.

## Identity

* **positionId:** `abi.encode(withdrawalQueue)` (static; the Lido `WithdrawalQueueERC721` address)
* **positionKind:** `Supplied`
* **positionInstanceId:** `bytes32(requestId)` (the per-request ERC-721 id; the NFT is burned on claim)
* **Labels:** `positionLabels(positionId)` returns `["Withdrawal Queue", "stETH"]`, shown only on the verbose reads; full breadcrumb `["Lido", "Withdrawal Queue", "stETH"]`. The request id is not in the label.

Every leg shares one positionId. The reconciliation key is `keccak256(abi.encode(chainId, protocolSubId, positionId, balanceAsset.asset, positionKind))`; it excludes `isLocked` and `positionInstanceId`, so all of an account's open requests reconcile into one coordinate and sum to the full ETH owed. Read `isLocked` per leg for the claimable and pending split.

## Constructor

```solidity
constructor(address withdrawalQueue_, address underlyingToken_, address navCalculator_)
```

| Parameter          | Description                                                                                                |
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
| `withdrawalQueue_` | Lido `WithdrawalQueueERC721` contract. Must be a contract                                                  |
| `underlyingToken_` | Asset positions are denominated in: what Lido pays on claim (native ETH; the ERC-7528 sentinel on mainnet) |
| `navCalculator_`   | NAVCalculator address, used for asset-registry filtering. Must be a contract                               |

## Registration

Registered as a plain adapter with `addBalanceAdapters([adapter])` and removed with `removeBalanceAdapters([adapter])`.


---

# 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/balance-adapters/lido-withdrawal-queue.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.
