# HTTP — `GET /v1/clearinghouseState`

One-shot account snapshot: positions, spot balances, margin, caps, the market
catalog, and venue status.

```http
GET /v1/clearinghouseState?user=0x0000000000000000000000000000000000000001
```

The endpoint is public. Set `user` to the account's EVM address. Without it,
the server reads a default account that is not yours. An address with no
Mosaiq account answers empty `positions`, zeros in `marginSummary` and
`userCaps`, an empty `tier`, and `withdrawableUsdc` `"0"`.

| HTTP | `code` | `detail` | When |
| --- | --- | --- | --- |
| `400` | `invalid_request` | `invalid_query` | `user` is not an EVM address. |
| `503` | `temporarily_unavailable` | `oracle_unavailable` | Mosaiq has no fresh price for a position of the account. |
| `503` | `temporarily_unavailable` | `risk_core_unavailable` | Mosaiq cannot read the account state right now. |

Right after an accepted placement, the margin and open-order usage can lag
until Mosaiq applies the venue acknowledgement.

REST returns `data.assetData`, `data.venueData`, `data.marketData`, and
`data.userData` together. The WebSocket `clearinghouseState` topic sends the
same four payloads as separate messages. See the
[user-data WebSocket](/api/websocket#clearinghousestate) for the stream contract.
The WebSocket market filter does not change this REST response.

```jsonc
{
  "status": "ok",
  "data": {
    "assetData": {
      "universe": [
        {
          "name": "BTC",
          "szDecimals": 5,
          "maxLeverage": 40,
          "marginTableId": 56,
          "constraints": {
            "sizeDecimals": 5,
            "sizeIncrement": "0.00001",
            "priceDecimals": 1,
            "tickSize": "0.1",
            "minNotional": "10",
            "supportsReduceOnly": true,
            "supportsPostOnly": true
          },
          "venues": [
            {
              "venue": "hyperliquid",
              "venueSymbol": "BTC",
              "instrumentType": "perp",
              "status": "active",
              "constraints": {
                "sizeDecimals": 5,
                "sizeIncrement": "0.00001",
                "priceDecimals": 1,
                "tickSize": "0.1",
                "minNotional": "10",
                "supportsReduceOnly": true,
                "supportsPostOnly": true
              },
              "lifecycle": {
                "state": "trading",
                "listing": 1
              }
            }
          ]
        }
      ]
    },
    "venueData": {
      "meta": {
        "venues": [
          {
            "venue": "hyperliquid",
            "status": "online",
            "lastCheckedAtMs": 1780000000000,
            "lastOkAtMs": 1780000000000
          }
        ]
      }
    },
    "marketData": {
      "marketCtxs": [
        {
          "name": "BTC",
          "venue": "hyperliquid",
          "funding": "0.0000125",
          "oraclePx": "65000"
        }
      ],
      "openInterestUsdc": {
        "BTC": "32500"
      }
    },
    "userData": {
      "user": "0x0000000000000000000000000000000000000001",
      "positions": [
        {
          "coin": "BTC",
          "venue": "hyperliquid",
          "entryPx": 64000,
          "szi": 0.5,
          "positionValue": 32500,
          "unrealizedPnl": 500,
          "unrealizedFunding": 0
        }
      ],
      "marginSummary": {
        "accountValue": 10500,
        "totalCashUsdc": 10000,
        "availableFunds": 8657.6,
        "excessLiquidity": 10093.75,
        "initialMarginUsed": 1842.4,
        "maintenanceMarginUsed": 406.25,
        "grossNotional": 32500,
        "cushion": 0.9613,
        "leverage": 3.095
      },
      "userCaps": {
        "scope": "owner",
        "tier": "beta",
        "openOrders": 0,
        "maxOpenOrders": 20,
        "maxSingleOrderNotionalUsdc": 50000,
        "openOrderNotionalUsdc": 0,
        "maxOpenOrderNotionalUsdc": 250000,
        "grossNotionalUsdc": 32500,
        "maxGrossNotionalUsdc": 500000,
        "initialMarginUsageRate": 0.1755,
        "maxInitialMarginUsageRate": 0.8,
        "maxAssetVenueNotionalUsdc": 100000,
        "assetVenueNotionals": [
          {
            "asset": "BTC",
            "venue": "hyperliquid",
            "notionalUsdc": 32500
          }
        ]
      },
      "withdrawableUsdc": "8657.6",
      "liquidation": null,
      "spotBalances": [
        {
          "coin": "HYPE",
          "venue": "hyperliquid",
          "total": "0.279804",
          "hold": "0",
          "sellable": "0.27"
        }
      ],
      "outcomeBalances": [
        {
          "a": "BTC-1D-261104-0600-GE76637-YES/USDC",
          "venue": "hyperliquid",
          "total": "25",
          "hold": "0",
          "sellable": "25",
          "midValueUsdc": "11",
          "expiryMs": 1793772000000
        }
      ]
    }
  },
  "server_time_ms": 1780000000100
}
```

## Positions and margin

`positions` are venue-scoped legs identified by `(coin, venue)`. Margin is
charged per leg: a long on one venue and a short on another are not netted.
Values in `positions`, `marginSummary`, and `userCaps` are JSON numbers.
Mosaiq values positions at the venue's oracle price.

* `szi`: the signed size, positive for a long and negative for a short.
* `entryPx`: the average entry price rounded to the venue's price decimals, for
  display only. `positionValue` and `unrealizedPnl` use the unrounded value, so
  they need not match `entryPx` exactly.
* `positionValue`: `|szi| × oracle price`.
* `unrealizedPnl`: `szi × (oracle price - average entry price)`.
* `unrealizedFunding`: always `0`. Mosaiq books funding to your cash as it
  settles. [`/v1/userFunding`](/api/user-funding) lists the payments.

`marginSummary`:

* `totalCashUsdc`: your USDC balance.
* `accountValue`: `totalCashUsdc` plus the `unrealizedPnl` of every position.
* `initialMarginUsed`: the initial margin of your positions and of every open
  order that is not reduce-only, whatever its time-in-force, plus the priority
  fees that your `Alo` orders will pay when Hyperliquid accepts them.
* `maintenanceMarginUsed`: the maintenance margin of your positions only.
* `availableFunds`: `accountValue - initialMarginUsed`, the room to open risk.
  It can be negative.
* `excessLiquidity`: `accountValue - maintenanceMarginUsed`, the distance to
  liquidation.
* `grossNotional`: the notional of your positions plus the remaining notional
  of your open orders.
* `cushion`: `excessLiquidity / accountValue`, or `0` when `accountValue` is
  zero or negative or the account has no maintenance margin.
* `leverage`: `grossNotional / accountValue`, or `0` when `accountValue` is
  zero or negative. There is no leverage setting.

`withdrawableUsdc` is what the account can move out now: by a transfer, or by a
withdrawal for a master account. It is the lower of the account's cash and its
available margin, with its orders in flight counted, so it can be below
`availableFunds` while an order is being placed. It is a decimal string, not a
JSON number.

* A transfer can move up to `withdrawableUsdc`.
* A withdrawal also needs no other pending withdrawal on the account, and room
  in the rolling withdrawal cap. So a withdrawal below `withdrawableUsdc` can
  still be refused.
* `withdrawableUsdc` is `null` when Mosaiq cannot price the account's margin,
  or while the account holds a position on a venue in an announced maintenance,
  until each market of that venue has a new price. Mosaiq then refuses a
  transfer from the account.

`liquidation` is `null` unless a [liquidation](/concepts/liquidation) of the
account is under way. During a liquidation it holds the liquidation `id`,
`startedAtMs`, and `positions`, the `(coin, venue)` legs that the liquidation is
closing:

```json
{
  "id": "0b0f9c0e-6d4e-8a1b-9f37-2c5d8e1a4b60",
  "startedAtMs": 1767225600000,
  "positions": [{ "coin": "BTC", "venue": "hyperliquid" }]
}
```

The `id` matches the `liquidationStarted` and `liquidationFinished` events of
the [`userEvents`](/api/websocket#userevents) topic.

`userCaps` are the limits of the owner's tier, and their usage. Mosaiq checks
them before it accepts an order. A refused order answers `limit_reached` on
`/v1/exchange`, with [`cap`](/api/errors#the-limit-in-cap) naming the limit.
Usage adds up the master account and every
[sub-account](/concepts/sub-accounts) of the owner, except
`initialMarginUsageRate`, because each account has its own margin. `userCaps`
does not name the owner of the account.

| Field | Meaning |
| --- | --- |
| `scope` | Always `owner`. |
| `tier` | The code of the owner's cap tier, such as `beta`. Empty for an address without an account. |
| `openOrders`, `maxOpenOrders` | The open orders of all the owner's accounts, and the limit. |
| `maxSingleOrderNotionalUsdc` | The largest notional of one order. |
| `openOrderNotionalUsdc`, `maxOpenOrderNotionalUsdc` | The remaining notional of those open orders, and the limit. |
| `grossNotionalUsdc`, `maxGrossNotionalUsdc` | The notional of all the owner's positions at the oracle price plus `openOrderNotionalUsdc`, and the limit. |
| `initialMarginUsageRate`, `maxInitialMarginUsageRate` | `initialMarginUsed / accountValue` of the `user` account only, and the limit. The rate is `1` when `accountValue` is zero or negative and `initialMarginUsed` is positive, and `0` when both are zero. |
| `maxAssetVenueNotionalUsdc` | The limit of the notional on one asset and venue. |
| `assetVenueNotionals` | The notional of positions and open orders on each `asset` and `venue`, as `notionalUsdc`, largest first. |

## Spot balances

`userData.spotBalances` lists the spot tokens that you hold, one row per token
and venue. The field is absent when you hold no token. `coin` is a token of
[`GET /v1/spotMeta`](/api/spot-meta). The amounts are decimal strings in token
units.

* `total`: the tokens on your account.
* `hold`: the tokens that your sell orders hold.
* `sellable`: `total - hold` rounded down to the lot of the token, the largest
  sale that the book accepts. The rest is dust that stays on your account:
  0.279804 HYPE gives `sellable` 0.27.

USDC is not a spot balance. Spot and outcome buys spend
[token cash](#token-cash), which Mosaiq fills from `totalCashUsdc` when a buy
needs it. Tokens never count as margin.

## Outcome balances

`userData.outcomeBalances` lists the HIP-4 outcome tokens that you hold, one row
per market. `spotBalances` never lists an outcome token. The field is absent
when you hold none. `a` is a market of
[`GET /v1/outcomeMeta`](/api/outcome-meta).

* `total`, `hold` and `sellable`: as for a spot balance, in whole tokens.
* `midValueUsdc`: `total × midPx` of the market, for display only. It is absent
  without a reference mid of at most 5 minutes, and once the market stopped
  trading. Outcome tokens never count as margin, and `marginSummary` never
  values them.
* `expiryMs`: when the market stops trading. Hyperliquid then redeems the
  tokens. Once Mosaiq books the settlement, the redeemed tokens leave the list,
  and [`GET /v1/outcomeSettlements`](/api/outcome-settlements) shows what they
  paid.

## Token cash

Token cash is your USDC on the Hyperliquid sub-account of your account. It pays
your spot and outcome buys, and it receives the proceeds of your sales and the
payouts of your outcome settlements. Mosaiq fills it from your USDC balance
when a buy needs it, and moves it back when a perp order or a withdrawal needs
it or after 24 hours without activity
([token cash](/api/exchange#token-cash)). The fields appear once your account
has moved USDC to token cash. An account that never did shows none of them.

* `tokenCashUsdc`: your confirmed token cash, a decimal string. It is never perp
  collateral and never withdrawable.
* `tokenCashPendingUsdc`: the move to token cash on its way. It has already left
  `totalCashUsdc` and `withdrawableUsdc`, and it is not token cash yet.
* `lastTokenCashTransfer`: your newest move. `requestId`, `direction` (`toTokens`
  or `toCash`), `amount`, `status` (`pending`, `confirmed` or `failed`), `cause`
  (`tokenBuy`, `perpMargin`, `withdrawal` or `idle`), and `reason` on a failed
  move: `venueRefused`, `notSubmitted` or `unknownOutcome`. Mosaiq never retries
  a failed move.

The `clientEquityUsdc` of [`/v1/liabilities`](/api/liabilities) counts both
balances, so it does not change when a move is reserved, confirmed or released.

`tokenAccount` names that sub-account once your first move to token cash
claims it. A perp-only account shows no `tokenAccount`.

* `venue`: `hyperliquid`.
* `address`: the sub-account that signs and holds your spot and outcome trades.
* `status`: whether your token orders may trade. `opening` until Mosaiq
  reconciles the sub-account with the ledger after its claim, a restart or a
  gap in its feed of the sub-account: your token orders are then refused with
  `temporarily_unavailable` and the detail `token_account_not_reconciled`. `open` once it matches. `closed` while a
  reconciliation finds a fault: your spot orders are refused with
  `temporarily_unavailable` and the detail `spot_unavailable`, and your outcome
  orders with the detail `token_account_closed`, and
  `reason` is the fault, such as `venue_unreadable`. One market can still be
  closed alone: the refusal of its order names it.

```json
"tokenAccount": {
  "venue": "hyperliquid",
  "address": "0x00000000000000000000000000000000000000a1",
  "status": "closed",
  "reason": "venue_unreadable"
}
```

## Market catalog

`assetData.universe` lists the assets you can trade, one entry per asset. Each
entry has one `venues` item per venue market.

| Field | Meaning |
| --- | --- |
| `name` | The asset's name. Use it as `a` on `/v1/exchange`. It is also `coin` in positions and `name` in `marketData.marketCtxs`. |
| `venues[*].status` | The status that the venue publishes for this market: `active`, `reduce_only`, `post_only`, `prelisted`, `delisted` or `inactive`. Mosaiq takes orders by `lifecycle`, not by this field. |
| `venues[*].lifecycle` | Where this perp market stands between its listing and its settlement, and which orders Mosaiq takes on it. See [Market lifecycle](#market-lifecycle). |
| `venues[*].constraints` | The size, price and notional rules that `/v1/exchange` checks for orders on this venue. |
| `constraints` | A summary of the venue constraints, for display. Orders are checked against the venue's own. |
| `maxLeverage`, `marginTableId` | Venue metadata. Mosaiq's margin can be stricter, see [Open interest and initial margin](#open-interest-and-initial-margin). |
| `onlyIsolated`, `venues[*].requiresIsolatedMargin` | Venue metadata: whether the venue trades the market in isolated margin only. Mosaiq margins every position in cross margin, whatever these fields say, so you can ignore them. `onlyIsolated` is `true` or `false` when the venue states it, and absent otherwise. `requiresIsolatedMargin` is present only on venues that have it. |
| `isDelisted` | Present only when `true`. |
| `constraints` fields other than `sizeDecimals` | Present only when the venue market has that rule. |

The catalog lists perps only. Spot markets are in
[`GET /v1/spotMeta`](/api/spot-meta), and outcome markets in
[`GET /v1/outcomeMeta`](/api/outcome-meta).

### Market lifecycle

`venues[*].lifecycle` tells you which orders Mosaiq takes on a perp market. Mosaiq
derives it from what the venue says, and from a settlement price that an
operator attests when the venue publishes none, as on Hyperliquid.

| Field | Meaning |
| --- | --- |
| `state` | One of the states below. Treat a state you do not know as `halted`. |
| `listing` | The listing of the market on this venue: `1` for its first listing, one more at each relist. A venue relists a market after it settles it, for example after a stock split. |
| `settlementPx` | The venue's settlement price, as a decimal string. Present once the venue settled the market and Mosaiq knows the price. |
| `settledAtMs` | When the venue settled the market, with `settlementPx`. |

| `state` | Orders that Mosaiq takes | Your position |
| --- | --- | --- |
| `trading` | Every order. | Open. |
| `reduce_only` | Reduce-only orders. Other orders answer `market_reduce_only`. | Open. |
| `halted` | No place or modify. Orders answer `inactive_market`. Cancels pass. | Open, valued at the last price. |
| `settling` | No place or modify. Orders answer `market_settled`. Cancels pass. | Mosaiq closes it at `settlementPx`, in a [`userFills`](/api/user-fills) row. Without `settlementPx`, it waits for the price. |
| `settled` | No order. Orders answer `market_settled`. | None. |

A settled market stays in the catalog. When the venue lists the asset again,
the same venue entry shows the next `listing` and `trading`. The new listing can
have other `constraints`.

`marketData.marketCtxs` has one entry per asset and venue:

* `funding` is the venue's predicted funding rate for the current hour, as a
  decimal: `0.0000125` is 0.00125% per hour. It can change until the hour ends.
  The rates that were actually paid are in [`/v1/userFunding`](/api/user-funding).
  Lighter rates are converted to the same decimal form. `funding` is absent when
  Mosaiq has no fresh rate for the market. A Hyperliquid rate stays fresh for 60
  seconds after its last update. Lighter sends a market only when its stats
  change, so a Lighter rate stays fresh while Mosaiq's Lighter feed is
  connected, and for 60 seconds after that feed disconnects or after Lighter
  sends the market without a rate.
* `oraclePx` is the venue's oracle price. When no live price is available, it
  shows the last funding settlement price, for display only. It is absent until
  Mosaiq has seen a price.

### Open interest and initial margin

`marketData.openInterestUsdc[name]` is Mosaiq's total open interest on the
asset, across all users and venues: the notional of positions at the oracle
price, plus the remaining notional of open orders that are not reduce-only. It
is `null` when Mosaiq cannot price a position. Do not read `null` as zero.

Each asset has a base initial-margin rate. It follows the venue's leverage, and
can be stricter than `maxLeverage`, for example when another venue of the asset
allows less leverage. The rate stays at the base rate until the asset's open
interest reaches its threshold, then rises linearly to 100% at twice the
threshold:

| Daily trading volume of the asset | Threshold |
| --- | --- |
| $75M or more | $10M |
| $20M to $75M | $5M |
| $5M to $20M | $2.5M |
| Under $5M | $1.25M |

The volumes are those of 2026-11-18. An asset listed after that date has no
threshold yet: its rate rises from the base rate at zero open interest to 100%
at $1M.

The maintenance rate does not depend on open interest. `marginSummary` shows
your current requirements, and Mosaiq checks each new order when you submit it.

## Venue status

`venueData.meta.venues[*].status` says whether Mosaiq can reach the venue:

| `status` | Meaning |
| --- | --- |
| `online` | The last check succeeded. |
| `offline` | The last check failed. `message` says why. |
| `unknown` | Mosaiq has not checked the venue yet. |

This is separate from the status of each market in
`assetData.universe[*].venues[*].status`.

`venueData.meta.recovery` appears only while a venue cannot take all orders. Its
`phase` is:

* `recovering`: Mosaiq is catching up with the venue, for example after a
  restart. Places and modifies on that venue are refused with
  `temporarily_unavailable` and the detail `venue_recovering`.
* `halted`: Mosaiq stopped trading on the venue after a failure. Places and
  modifies get the same refusal, except reduce-only ones. `haltCause` is a short
  code for the cause, and `message` is a description for people. Mosaiq can add
  new codes, so accept a value that you do not know.

Cancels pass in both phases, and orders on the other venues are not affected.
Until `recovery` no longer lists the venue, stop placing on it instead of
retrying each order.
