> 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/assisted-balance-adapters/stakewise-v3-exit-queue.md).

# StakeWise V3 Exit Queue

An assisted adapter that reports the assets owed to an account in StakeWise V3's exit queue, fed onchain by the owner Safe.

An **assisted** adapter that reports the assets owed to an account in StakeWise V3's exit queue. When shares enter the queue, their value is invisible to NAV: a position is identified only by the `positionTicket` that `enterExitQueue` returns, and there is no per-account enumeration. The owner submits each `(vault, positionTicket, timestamp)` tuple, and the adapter values it from live onchain reads.

* **Type:** Assisted adapter, permissionless and keyed on `msg.sender`
* **protocolSubId:** `keccak256("stakewise-v3-exit")`
* **Source:** `StakeWiseV3ExitQueueAssistedBalanceAdapter.sol`
* **Assistant:** `StakeWiseV3ExitQueueAssistant.sol`

{% hint style="warning" %}
This is not the [StakeWise V3](https://docs.kpk.io/funds/infrastructure/architecture/onchain-accounting/meta-balance-adapters/stakewise-v3.md) page. That meta-adapter reports active staking positions; this one reports shares already on their way out. A Fund using StakeWise needs both to see its full exposure.
{% endhint %}

## Positions returned

Up to two legs per exit ticket, split by claimability. Both are `Supplied`, not debt, denominated in the staking asset (native ETH on mainnet), with `positionInstanceId = bytes32(positionTicket)`.

| Leg       | isLocked | Description                                                         |
| --------- | -------- | ------------------------------------------------------------------- |
| Claimable | `false`  | Exited assets past the claim delay, withdrawable now                |
| Locked    | `true`   | Still-queued shares, and exited assets still inside the claim delay |

A zero leg is omitted. The position is dropped if the staking asset is not registered in the NAV Calculator, if no live tickets are cached, or if `assetFilter` excludes it.

## Feed surface

The surface is permissionless, with no roles and no `account` argument. Each coordinate is a tuple.

| Function                                                           | Purpose                                                                                                                                                        |
| ------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `submit(address vault, uint256 positionTicket, uint256 timestamp)` | Track one of the caller's exit positions. Reverts if the vault is not StakeWise-registered, the tuple is not owed to the caller, or the cache holds 256 tuples |
| `remove(address vault, uint256 positionTicket, uint256 timestamp)` | Stop tracking a position once it is claimed. Reverts while the position is still owed                                                                          |
| `positionsOf(address account)`                                     | View the cached tuples for an account (display only)                                                                                                           |
| `clearAccount()`                                                   | Drop all of the caller's cached tuples                                                                                                                         |

Exit positions have no `ownerOf`, so ownership is proven by `calculateExitedAssets(account, ...) > 0`: a tuple that is not the caller's resolves to zero and is rejected on `submit`.

### The assistant

Use the assistant instead of calling the vault directly. It is delegatecalled by the Safe, forwards the same StakeWise call, and keeps the adapter in step in the same transaction.

| Entrypoint                                                            | Does                                                            | Adapter call                                     |
| --------------------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------ |
| `enterExitQueue(vault, shares)`                                       | Enters the queue with the Safe as receiver and returns a ticket | `submit(vault, positionTicket, block.timestamp)` |
| `claimExitedAssets(vault, positionTicket, timestamp, exitQueueIndex)` | Claims exited assets to the Safe                                | `remove(vault, positionTicket, timestamp)`       |

Under delegatecall the vault sees the Safe as `msg.sender`, which StakeWise's claim path requires. Removal on claim is best effort and never blocks the claim: a partial claim leaves the ticket tracked, and an untracked ticket is ignored.

<figure><img src="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2Fgit-blob-0b1a711a0c19b58362160de670afcc05f9dfe42d%2Fadapter-stakewise-v3-exit-queue-enter.svg?alt=media" alt="Flow to enter the StakeWise exit queue through the assistant."><figcaption><p><strong>Entering the exit queue.</strong> The Safe delegatecalls the assistant, which enters the queue and submits the ticket to the adapter in one transaction.</p></figcaption></figure>

<figure><picture><source srcset="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2FqoFsWZ04Lhc324w3XN5H%2Fget-adapter-positions-vault_D.png?alt=media&amp;token=40d54cc9-867d-46c9-8fc5-cc3bc4920099" media="(prefers-color-scheme: dark)"><img src="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2FUjQk4Zz4zYwi6i6hz87k%2Fget-adapter-positions-vault.png?alt=media&amp;token=19cd5cef-9e1d-4f9b-ae7a-f21fbf90b966" alt="Flowchart of how the adapter values cached exit tuples."></picture><figcaption><p><strong>Balance calculation.</strong> How cached exit tuples are valued into position legs.</p></figcaption></figure>

{% hint style="info" %}
StakeWise re-queues a not-yet-checkpointed remainder under a **new** `positionTicket`. The caller must `submit` the new ticket separately, using the vault's re-queue event.
{% endhint %}

## Balance calculation

<figure><picture><source srcset="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2F71FFsvrbPb11H30VNiuW%2Fclaim-exited-assets-flow_D.png?alt=media&amp;token=37911036-a53a-4fe5-b5a0-f5875d8af4aa" media="(prefers-color-scheme: dark)"><img src="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2FU3B2S1PDEeFmjQjPonzo%2Fclaim-exited-assets-flow.png?alt=media&amp;token=4669404d-6e64-43cc-b1fa-687628e71ff8" alt="Flow to claim exited assets through the assistant."></picture><figcaption><p><strong>Claiming.</strong> The assistant claims to the Safe, then removes the ticket once it is fully consumed.</p></figcaption></figure>

For each cached tuple the adapter calls the vault with `receiver = account` and splits the position:

```
idx = vault.getExitQueueIndex(positionTicket)          // -1: not yet checkpointed
(leftShares, _, exited) = vault.calculateExitedAssets(account, positionTicket, timestamp, idx)
queued = vault.convertToAssets(leftShares)             // valued at the current rate
if block.timestamp >= timestamp + EXIT_CLAIM_DELAY:
    claimable = exited;  locked = queued
else:
    claimable = 0;       locked = exited + queued
```

A ticket that is not yet checkpointed is fully pending and is reported as locked. Each tuple is valued in isolation, so one bad tuple never drops the rest.

## Identity

* **positionId:** `abi.encode(vault)`, one per vault
* **positionKind:** `Supplied`
* **positionInstanceId:** `bytes32(positionTicket)`, shared by both legs of a ticket
* **Labels:** `["Exit Queue", "<receiptSymbol>"]`, for example `["Exit Queue", "osETH"]`, shown on the verbose reads

The reconciliation key excludes `isLocked` and `positionInstanceId`, so all of an account's tickets for a vault reconcile into one coordinate and sum. Read `isLocked` per leg for the claimable and locked split.

## Constructor

```solidity
constructor(
    address vaultsRegistry_,
    address underlyingToken_,
    string memory receiptSymbol_,
    address navCalculator_,
    uint256 exitClaimDelay_
)
```

| Parameter          | Description                                                                                    |
| ------------------ | ---------------------------------------------------------------------------------------------- |
| `vaultsRegistry_`  | StakeWise `VaultsRegistry`, which gates the vaults the cache accepts                           |
| `underlyingToken_` | Staking asset the queue pays out: native ETH on mainnet. All accepted vaults must settle in it |
| `receiptSymbol_`   | Receipt token symbol for the label (`"osETH"` on mainnet, `"osGNO"` on Gnosis). May be empty   |
| `navCalculator_`   | NAV Calculator, used for asset-registry metadata                                               |
| `exitClaimDelay_`  | StakeWise's post-checkpoint claim delay in seconds (`86400` on V3 mainnet)                     |

There is no admin or assistant argument. The assistant is deployed separately and pinned to this adapter. On mainnet every StakeWise V3 vault settles in ETH, so do not deploy against a non-ETH `underlyingToken` on a chain with a different staking asset.

## Registration

Register with `addBalanceAdapters([adapter])` and remove with `removeBalanceAdapters([adapter])`. The owner's own transactions then keep the cache current, typically through the assistant.


---

# 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/assisted-balance-adapters/stakewise-v3-exit-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.
