> 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/kelp-withdrawal-queue.md).

# Kelp Withdrawal Queue

A plain adapter that reports assets owed to an account from open requests in Kelp DAO's rsETH exit queue (the LRTWithdrawalManager).

A plain adapter that reports assets owed to an account from open requests in Kelp DAO's rsETH exit queue (the `LRTWithdrawalManager`). Unstaking rsETH burns it and records a per-(asset, user) request in the chosen payout asset (stETH, ETHx, or native ETH). Supported assets come from `lrtConfig().getSupportedAssetList()` at runtime.

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

## Positions returned

One `Supplied` leg per open request, for each payout asset registered in NAVCalculator:

| Leg                  | PositionKind | isDebt  | isLocked | Description                        |
| -------------------- | ------------ | ------- | -------- | ---------------------------------- |
| Per unlocked request | `Supplied`   | `false` | `false`  | Unlocked request, withdrawable now |
| Per cooling request  | `Supplied`   | `false` | `true`   | Still-cooling request              |

Each leg is valued at its request's `expectedAssetAmount`. All legs share one positionId, so they are told apart by `balanceAsset.asset`, `isLocked` and `positionInstanceId` (the per-request `userNonce`). A zero-amount leg is omitted; requests for assets not registered in NAVCalculator are dropped, as are assets excluded by `assetFilter`.

## Balance calculation

<figure><picture><source srcset="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2FmLzx5jINwz90BN7ud9Vh%2Fadapter-kelp-withdrawal-queue_D.png?alt=media&amp;token=f6c88064-0392-49ef-b329-29fa9292da42" media="(prefers-color-scheme: dark)"><img src="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2F3qC5vcrYZbdMss8WuzTn%2Fadapter-kelp-withdrawal-queue.png?alt=media&amp;token=d80fec95-ac04-47ac-8b36-102b0514ac9f" alt="Flowchart of the Kelp Withdrawal Queue balance adapter: read calls derive position legs into PositionBalance entries."></picture><figcaption><p>Kelp Withdrawal Queue adapter: how the underlying balances reported to the NAV Calculator are derived.</p></figcaption></figure>

For each supported asset, the open-request count is `end - begin` from the per-(asset, user) deque, the full set with **no adapter-level cap**:

```
(begin, end) = userAssociatedNonces(asset, account)
count = end - begin
for i in 0 .. count:
    (_, expectedAssetAmount, withdrawalStartBlock, userNonce) = getUserWithdrawalRequest(asset, account, i)
    unlocked = userNonce < nextLockedNonce(asset)
               and block.number >= withdrawalStartBlock + withdrawalDelayBlocks()
    emit leg { amount = expectedAssetAmount, isLocked = !unlocked, positionInstanceId = bytes32(userNonce) }
```

A request is unlocked (`isLocked=false`) iff `userNonce < nextLockedNonce(asset)` **and** `block.number >= withdrawalStartBlock + withdrawalDelayBlocks()`; otherwise `isLocked=true`. Claimed requests are popped off the front of the deque, so only live claims are counted. Kelp keys requests to the unstaking `msg.sender`, so a third party cannot inflate another account's queue.

## Identity

* **positionId:** `abi.encode(withdrawalManager)` (static; the Kelp `LRTWithdrawalManager` address)
* **positionKind:** `Supplied`
* **positionInstanceId:** `bytes32(userNonce)` (the per-request absolute nonce; the request is popped off the deque on claim)
* **Labels:** `positionLabels(positionId)` returns `["Withdrawal Queue", "rsETH"]`, shown only on the verbose reads; full breadcrumb `["Kelp DAO", "Withdrawal Queue", "rsETH"]`. The request nonce is not in the label.

The positionId is the same across all payout assets. The reconciliation key is `keccak256(abi.encode(chainId, protocolSubId, positionId, balanceAsset.asset, positionKind))`; it includes `balanceAsset.asset` but excludes `isLocked` and `positionInstanceId`, so each payout asset's legs reconcile into one coordinate and sum. Read `isLocked` per leg for the breakdown.

## Constructor

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

| Parameter            | Description                                                                     |
| -------------------- | ------------------------------------------------------------------------------- |
| `withdrawalManager_` | Kelp `LRTWithdrawalManager` contract (the rsETH exit queue). Must be a contract |
| `navCalculator_`     | NAVCalculator address, used for asset-registry filtering. Must be a contract    |

The payout asset is determined per request, so there is no `underlyingToken_` parameter.

## 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/kelp-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.
