# Order lifecycle

> Every Wagyu order status and customerState, which one to show, when the user must act, and how to read swap, bridge and session orders.

An order has two state fields. Use them for different jobs:

- **`customerState`** is the authority for the screen: what the user sees, and whether they must do something. Build your UI on it.
- **`status`** is the coarse outcome, useful for filters, analytics and deciding when to stop polling.

Do not infer what the user must do from `status`, from elapsed time, or from whether a field is present.

## Read an order

| Order | REST read | Optional live updates |
| --- | --- | --- |
| Swap | `GET /v2/swaps/{id}` | WebSocket `/v2/swaps/{id}/events` |
| Bridge | `GET /v2/bridges/{id}` | WebSocket `/v2/bridges/{id}/events` |
| Every order of a session | `GET /v2/orders` | WebSocket `/v2/orders/events` |

Send the owner session in `X-Session-ID`, or `?verify=<destination-address>` for a read-only view of one order. A missing order and a wrong proof both return `404`. See [Live updates](https://docs.wagyu.xyz/live-updates.md) for the sockets.

## Statuses

| `status` | Meaning | Final? |
| --- | --- | --- |
| `awaiting_deposit` | Waiting for the user's deposit. Show the funding instruction. | No |
| `awaiting_hxmr` | A bridge withdrawal is waiting for the user to send HXMR (wrapped XMR on Hyperliquid). Show the funding instruction. | No |
| `processing` | A deposit was seen and the order is moving. May include an unconfirmed deposit. | No |
| `completed` | Done. Show the actual output. | Yes |
| `refunded` | The deposit was returned. | Yes |
| `failed` | The order failed. Check `customerState`: it can still ask for a refund address. A recovery can still complete or refund it. | No |
| `expired` | No deposit arrived before `expiresAt`. A late deposit is still recovered by support. | No |
| `needs_review` | Legacy value. Treat it as `processing`. | No |

### Legacy statuses

These values stay in the contract so that orders created before a wrapped token closed can still be read. No new order gets them. Show such an order as waiting on support, and never ask the user to send the closed token: see the [changelog](https://docs.wagyu.xyz/changelog.md).

| `status` | Meaning |
| --- | --- |
| `awaiting_xmr1` | An older bridge withdrawal from before HXMR. Support settles these orders. |
| `awaiting_zec1` | An old bridge withdrawal waiting for ZEC1. The Zcash bridge closed on 2026-11-21; support settles or refunds these orders. |
| `awaiting_trx1` | An old bridge withdrawal waiting for TRX1. The Tron bridge was retired on 2026-11-11. |

Stop polling on `completed` or `refunded`: only those two are final.

`failed` and `expired` are not. A recovery or a late deposit can still move either to `completed` or `refunded`, so keep reading the order every 10 minutes for 7 days before you treat it as over. Act on `customerState` whenever it asks for an action.

## customerState

`customerState.kind` is one of eight values:

| `kind` | Extra fields | What to show |
| --- | --- | --- |
| `awaiting_deposit` | optional `notice` | The funding instruction. A notice means a deposit arrived but is short; see below. |
| `processing` | `stage`, optional `notice` | Progress, using `stage`. |
| `action_required` | `action` | A form for that action. This is the **only** state that enables an action. |
| `paused` | `reason`, optional `minimumDepositAmount` | The order is waiting, not failed. Keep tracking. |
| `completed` | — | The result. |
| `refunded` | — | The refund. |
| `expired` | — | Expiry. |
| `failed` | — | Failure. |

### Stages while processing

The contract defines these stage names but no further meaning; the labels are a suggestion for your screen.

| `stage` | Suggested label |
| --- | --- |
| `processing` | Processing |
| `confirming` | Confirming your deposit. Show `confirmations` of `requiredConfirmations` when present. |
| `routing` | Routing |
| `trading` | Trading |
| `sending` | Sending your funds |
| `refunding` | Refunding |

Do not estimate completion from elapsed time. Typical durations per route are published by [`GET /v2/swaps/route-stats`](https://docs.wagyu.xyz/public-data.md#how-long-a-swap-takes).

### Notices

| Where | `notice.kind` | Meaning |
| --- | --- | --- |
| `awaiting_deposit` | `below_expected` | A token deposit arrived but is under the requested amount. The user can top up the same address until `expiresAt`. |
| `awaiting_deposit` | `below_minimum` | A native-coin deposit (such as XMR) arrived under the order minimum. Carries `minimumDepositAmount`. |
| `processing` | `checking` | Informational. No action needed. |

How each deposit case resolves is on [Deposits and refunds](https://docs.wagyu.xyz/deposits.md).

### Actions

Show a control only while `customerState.kind` is `action_required`, and only for its `action`:

| `action` | What the user does | Route |
| --- | --- | --- |
| `refund_address` | Gives an address to receive a refund. | [`PUT /v2/orders/{id}/refund-address`](https://docs.wagyu.xyz/api-reference/submit-refund-address.md) |
| `payout_address` | Gives a replacement destination address. The order asks for one only when it needs it. | [`PUT /v2/orders/{id}/payout-address`](https://docs.wagyu.xyz/api-reference/submit-payout-address.md) |
| `coinflip` | Accepts or declines the optional bonus flip on this order. | [`PUT /v2/swaps/{id}/coinflip`](https://docs.wagyu.xyz/api-reference/resolve-coinflip.md) |

Every action needs the owner session. The `?verify=` proof and integrator keys cannot perform actions.

### Pauses

| `reason` | Meaning |
| --- | --- |
| `preparing_refund` | A refund is being prepared. Not a failure. |
| `below_minimum` | A deposit is parked under its minimum. With `minimumDepositAmount`, a top-up to the same address that reaches it continues the order automatically; without it, contact support. |

## What arrived versus what was asked

| Field | Meaning |
| --- | --- |
| `depositAmount` | What the order asked for, in atomic units. |
| `observedDepositAmount` | What actually arrived, in the same unit. Every transfer to the deposit address adds to it. Use it for "you sent". |
| `expectedOutput` | The quoted output for `depositAmount`. |
| `fundedExpectedOutput` | The quote rescaled to what arrived, when that differs. Use it for "you receive" until the order completes. |
| `actualOutput` | What was delivered, on completed orders. Its unit is `deliveredToken` when present, otherwise `toToken`. |
| `deliveredToken` | Present only when the order completed in a different asset of the same value than `toToken` (for example USDC for a USDT quote). |
| `expiresAt` | The funding deadline. |

`completed` does not always mean the destination received an asset: if the user opted into the bonus flip, check `coinflipLost` first.

## A session's orders

`GET /v2/orders` with `X-Session-ID` lists every order of that session (swaps, bridges and coinflip tables; `product` tells them apart). A row can carry `customerState` as last recorded, which can lag the order read by about two minutes and is absent when none is recorded or the record is stale, and `depositObserved`, whether a deposit was seen. Read the order itself before offering an action. A new session simply returns `{ "orders": [] }`.

> **Locked orders:** A read can answer `409 conflict` with the message "For your security, this order can now only be viewed or changed by our support team." An order can be locked for security reasons or because it is under a compliance block or legal hold. The order is then handled by support only: show the message and the order ID, and point the user to [support](https://t.me/wagyu_support).

## Delete an order

`DELETE /v2/orders/{id}` permanently removes a completed or refunded order. It needs the owner session. It does not cancel anything or move funds.

## Hyperliquid execution receipts

Swaps that trade on Hyperliquid expose their fills:

- The order includes up to 200 saved fills in `hlFills`, with `hlFillsStatus` (`pending`, `complete` or `incomplete`) and `hlFillsNextCursor`.
- Older fills: `GET /v2/swaps/{id}/fills` returns `{ fills, status, nextCursor }`. Send `nextCursor` back as `before`; `limit` is 1–200.
- Deduplicate fills by `tradeId`, not `txHash`: several fills can share a hash.
- A `null` cursor means there are no older saved receipts, not that collection is complete. For the user's payout, use the final status and `actualOutput`.

---
Source: https://docs.wagyu.xyz/order-lifecycle · Built from the live Wagyu API on 2026-12-04.
