> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsidemax.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# marketState: Get Current Mark, Index, and Last Price

> Fetch the current mark price, index price, last trade price, and funding rate index for a contract to align local state on startup or reconnect.

The `marketState` query returns the current mark price, index (oracle) price, last trade price, funding rate index, and price readiness flag for a contract. Use this on startup or after a reconnect to synchronize your local price state before relying on WebSocket updates. It also serves as a lightweight check to confirm that a contract is ready to accept orders.

<Note>
  Check `priceReady` before placing orders. If the mark price is unavailable, order placement may be rejected by the exchange until prices are published.
</Note>

## Request

```json theme={"system"}
{"type": "marketState", "asset": "1"}
```

<ParamField body="type" type="string" required>
  Must be `"marketState"`.
</ParamField>

<ParamField body="asset" type="string" required>
  The contract ID to fetch market state for, expressed as a decimal string (e.g. `"1"`). Use the `contractId` from `configs`.
</ParamField>

## Response

```json theme={"system"}
{
  "type": "marketState",
  "asset": "1",
  "markPx": "1133770",
  "indexPx": "1133800",
  "lastPx": "1133700",
  "priceReady": true,
  "fundingIndex": "55",
  "fundingLastTimestamp": 1782270000000
}
```

<ResponseField name="markPx" type="string">
  Current mark price used for PnL calculation and liquidation checks (raw integer string). Returns `"0"` if the mark price has not yet been published for this contract.
</ResponseField>

<ResponseField name="indexPx" type="string">
  Current index (oracle) price sourced from external feeds (raw integer string). Returns `"0"` if not yet published. Used to compute the funding rate.
</ResponseField>

<ResponseField name="lastPx" type="string">
  Price of the most recent trade on this contract (raw integer string). Returns `"0"` if no trades have occurred yet.
</ResponseField>

<ResponseField name="priceReady" type="boolean">
  `true` if mark and index prices are available and valid for trading. `false` indicates prices have not been published yet — orders placed while this is `false` may be rejected.
</ResponseField>

<ResponseField name="fundingIndex" type="string">
  Cumulative funding rate index snapshot at the time of the last funding settlement. Use this to compute unrealized funding payments for open positions.
</ResponseField>

<ResponseField name="fundingLastTimestamp" type="integer">
  Unix millisecond timestamp of the most recent funding settlement event.
</ResponseField>
