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

# Stader Withdrawal Queue

A plain adapter that reports the ETH owed to an account from open requests in Stader's UserWithdrawalManager.

A plain adapter that reports the ETH owed to an account from open requests in Stader's `UserWithdrawalManager`. An unstake request burns ETHx and records a sequential request id. The position is denominated in the configured underlying (the native-ETH sentinel or WETH on mainnet), not ETHx. Open requests are enumerable **onchain** through `getRequestIdsByUser(account)`, so no assistant or cache is needed.

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

## Positions returned

One `Supplied` leg per open request, all sharing one static positionId. A request is either fully claimable or fully locked, so each emits one leg:

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

The payout token is carried in `balanceAsset`, with `positionInstanceId = bytes32(requestId)`. A zero-amount leg is omitted; the position is dropped if that asset 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%2FgiLKSp3irYAKrBwKUfYl%2Fadapter-stader-withdrawal-queue_D.png?alt=media&amp;token=06d40874-db20-4f02-97bf-da1d66260386" media="(prefers-color-scheme: dark)"><img src="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2FhOZ9DOT4ZYsvA4MoXOFL%2Fadapter-stader-withdrawal-queue.png?alt=media&amp;token=8361003a-81a8-4de1-a363-b2aea1231bd8" alt="Flowchart of the Stader Withdrawal Queue balance adapter: read calls derive position legs into PositionBalance entries."></picture><figcaption><p>Stader Withdrawal Queue adapter: how the underlying balances reported to the NAV Calculator are derived.</p></figcaption></figure>

The adapter reads the live request ids with `getRequestIdsByUser(account)` and values each with `userWithdrawRequests(id)`:

```
ids = getRequestIdsByUser(account)                    // live set only (protocol-bounded); empty ⇒ no positions
for requestId in ids:
    (_, ethXAmount, ethExpected, ethFinalized, _) = userWithdrawRequests(requestId)
    if ethFinalized > 0: amount = ethFinalized;                          isLocked = false   // exact, withdrawable now
    else:                amount = min(ethExpected, previewWithdraw(ethXAmount)); isLocked = true    // live-rate cap
    emit leg { amount, isLocked, positionInstanceId = bytes32(requestId) }
```

Stader removes an id on claim (swap-and-pop in `deleteRequestId`), so the array holds only un-claimed requests. A request is claimable iff `ethFinalized > 0`, using `ethFinalized` (exact) and `isLocked=false`. A **pending** request is valued **conservatively** as `min(ethExpected, STAKE_POOL_MANAGER.previewWithdraw(ethXAmount))` with `isLocked=true`: `ethExpected` is frozen at request time, so a later ETHx/ETH rate drop (slashing) would overstate it. If the live read reverts, the adapter falls back to `ethExpected`.

There is **no adapter-level cap**: the full list is enumerated (Stader bounds it at `maxNonRedeemedUserRequestCount`, 1000 on mainnet). A spammed account can only exhaust gas in its own `getAccountNav` read; the failure is liveness-only and never yields a wrong value.

{% hint style="info" %}
**Third-party injection is self-defeating.** `requestWithdraw(ethXAmount, _owner)` pulls the *caller's* ETHx but records the request under an arbitrary `_owner`, claimable only by `_owner`. An injected request is real, claimable and self-funded, equivalent to an airdrop, which the wallet ERC-20 adapter also reports.
{% endhint %}

## Identity

* **positionId:** `abi.encode(userWithdrawalManager)` (static; the Stader `UserWithdrawalManager` address)
* **positionKind:** `Supplied`
* **positionInstanceId:** `bytes32(requestId)` (the per-request sequential id; the storage entry is deleted on claim)
* **Labels:** `positionLabels(positionId)` returns `["Withdrawal Queue", "ETHx"]`, shown only on the verbose reads; full breadcrumb `["Stader", "Withdrawal Queue", "ETHx"]`. 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 amount owed. Read `isLocked` per leg for the claimable and pending split.

## Constructor

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

| Parameter                | Description                                                                  |
| ------------------------ | ---------------------------------------------------------------------------- |
| `userWithdrawalManager_` | Stader `UserWithdrawalManager` contract. Must be a contract                  |
| `underlyingToken_`       | Asset positions are denominated in (native-ETH sentinel / WETH on mainnet)   |
| `navCalculator_`         | NAVCalculator address, used for asset-registry filtering. Must be a contract |

The `StaderStakePoolsManager`, whose `previewWithdraw` provides the live-rate cap for pending requests, is derived at construction from `userWithdrawalManager.staderConfig().getStakePoolManager()`, so it is not a constructor argument.

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