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

# Markets

> Resolve Monaco trading pairs, product support, pair IDs, metadata, screeners, funding, mark prices, and index prices.

Markets are the tradable pair objects your integration uses for order entry, orderbooks, trades, candles, funding, and position risk. Resolve market IDs first, store the UUID, and pass it into product-specific workflows.

## Surface Map

| Surface | Use |
| - | - |
| REST | `GET /api/v1/market/pairs`, `/market/pairs/{tradingPairId}`, `/market/screener`, `/market/stats`, `/market/pairs/{tradingPairId}/metadata`, `/market/pairs/{tradingPairId}/perp/*`, `/mark-price`, `/index-price`, `/funding`, `/market/funding/history`, `/open-interest` |
| TypeScript SDK | `sdk.market.getPaginatedTradingPairs()`, `getTradingPair()`, `getTradingPairBySymbol()`, `getMarketMetadata()`, `getScreener()`, `getMarketStats()`, `getPerpMarketConfig()`, `getPerpMarketSummary()`, `getMarkPrice()`, `getIndexPrice()`, `getFundingState()`, `listFundingHistory()`, `listAllFundingHistory()`, `getOpenInterest()` |
| React SDK | `useMarket()` |
| WebSocket | [Orderbooks & Trades](/developers/orderbooks-trades) for live depth and executions, plus the public [`market_stats` channels](/reference/websockets#market-stats) for per-market and all-markets statistics |
| gRPC | `MarketService` |

## What a Pair Represents

For a symbol like `BTC/USDC`:

* `BTC` is the base asset.
* `USDC` is the quote asset.
* The pair has a Monaco trading pair UUID.
* The pair can support spot, perps, or both.
* The pair exposes base and quote asset IDs for vault operations.
* The pair carries order constraints such as tick size, minimum order size, maximum order size, and fee fields.

## Product Support

Monaco can expose separate active rows for spot and perps support. Your UI should derive product support from active pair data instead of assuming every asset supports every product.

* Spot enabled: show spot order entry and spot orderbook/trade surfaces.
* Perps enabled: show leverage, margin, funding, positions, liquidation, and reduce-only controls.
* Product unavailable: keep the market visible if useful, but disable product-specific order entry.

## Resolve Pairs

<CodeGroup>
  ```typescript TypeScript SDK theme={null}
  const pairs = await sdk.market.getPaginatedTradingPairs({
    page: 1,
    pageSize: 100,
    isActive: true,
  });

  const btc = await sdk.market.getTradingPairBySymbol("BTC/USDC");
  const samePair = await sdk.market.getTradingPair(btc.id);

  const btcSpot = pairs.tradingPairs.find((pair) => {
    return pair.symbol === "BTC/USDC" && pair.marketType === "SPOT";
  });

  const btcPerps = pairs.tradingPairs.find((pair) => {
    return pair.symbol === "BTC/USDC" && pair.marketType === "MARGIN";
  });
  ```

  ```bash REST theme={null}
  curl "https://staging.apimonaco.xyz/api/v1/market/pairs?page=1&pageSize=100&isActive=true"
  ```
</CodeGroup>

## Pair IDs vs Symbols

Symbols are human-readable. Pair IDs are stable API identifiers.

| Field | Use it for |
| - | - |
| `symbol` | Labels, search, display, route slugs |
| `id` / `tradingPairId` | Orders, orderbook, candles, trades, funding, risk, WebSockets |
| `baseAssetId` | Depositing or withdrawing the base asset |
| `quoteAssetId` | Depositing or withdrawing the quote asset, commonly USDC |
| `baseTokenContract` / `quoteTokenContract` | Wallet UI, explorers, token metadata, approvals |
| `baseAssetName` / `quoteAssetName` | Human-readable asset names (e.g. "Robinhood Markets" for HOOD) for name-based search and display alongside tickers |

## Query Map

| Need | REST endpoint | SDK method |
| - | - | - |
| Active markets and product support | `GET /api/v1/market/pairs` | `sdk.market.getPaginatedTradingPairs()` |
| One trading pair | `GET /api/v1/market/pairs/{tradingPairId}` | `sdk.market.getTradingPair()` |
| Screener rows | `GET /api/v1/market/screener` | `sdk.market.getScreener()` |
| Exchange lifetime stats | `GET /api/v1/market/stats` | `sdk.market.getMarketStats()` |
| Pair metadata | `GET /api/v1/market/pairs/{tradingPairId}/metadata` | `sdk.market.getMarketMetadata()` |
| Perps config | `GET /api/v1/market/pairs/{tradingPairId}/perp/config` | `sdk.market.getPerpMarketConfig()` |
| Perps summary | `GET /api/v1/market/pairs/{tradingPairId}/perp/summary` | `sdk.market.getPerpMarketSummary()` |
| Mark price | `GET /api/v1/market/pairs/{tradingPairId}/mark-price` | `sdk.market.getMarkPrice()` |
| Index price | `GET /api/v1/market/pairs/{tradingPairId}/index-price` | `sdk.market.getIndexPrice()` |
| Funding | `GET /api/v1/market/pairs/{tradingPairId}/funding` | `sdk.market.getFundingState()` |
| Funding history (one pair) | `GET /api/v1/market/pairs/{tradingPairId}/funding/history` | `sdk.market.listFundingHistory()` |
| Funding history (all markets) | `GET /api/v1/market/funding/history` | `sdk.market.listAllFundingHistory()` |
| Open interest (gross: longs plus shorts) | `GET /api/v1/market/pairs/{tradingPairId}/open-interest` | `sdk.market.getOpenInterest()` |

## Market Metadata

Use market metadata when rendering order tickets or validating inputs before submission.

```typescript theme={null}
const pair = await sdk.market.getTradingPairBySymbol("ETH/USDC");
const metadata = await sdk.market.getMarketMetadata(pair.id);

console.log({
  tickSize: pair.tickSize,
  minOrderSize: pair.minOrderSize,
  maxOrderSize: pair.maxOrderSize,
  lastPrice: metadata.lastPrice,
});
```

## Screener and Stats

Use the screener for market lists, cards, tickers, and leaderboards. Use market stats for exchange-wide lifetime totals.

The surge example uses `decimal.js` (`npm install decimal.js`) to divide decimal strings without converting amounts to JavaScript numbers.

```typescript theme={null}
import Decimal from "decimal.js";

const [screener, stats] = await Promise.all([
  sdk.market.getScreener({ page: 1, pageSize: 100, isActive: true }),
  sdk.market.getMarketStats(),
]);

for (const row of screener.items) {
  console.log(row.symbol, row.lastPrice, row.priceChangePercent24h);
  // openInterestBase / openInterestNotional are gross (longs plus shorts), null
  // for spot pairs and "0" for a margin pair with no open positions. The notional is a snapshot valued
  // at the latest trade price; for a mark-accurate notional call getPerpMarketSummary.
  console.log(row.openInterestBase, row.openInterestNotional);
  // latestFundingRate is the last settled rate; estimatedNextFundingRate is
  // the estimate for the window in progress, the same value getFundingState
  // returns. Both are null for spot pairs. The estimate can differ from what
  // settles: a window with too few samples settles at the previous rate.
  console.log(row.latestFundingRate, row.estimatedNextFundingRate);
  // OI surge compares the 24h average with the 7d average, analogous to
  // 24h volume versus average daily volume over 7d. Both are quote-unit
  // decimal strings; keep the ratio as a decimal string too.
  const average7d = row.openInterestNotionalAvg7d;
  const surge = row.openInterestNotionalAvg24h !== null && average7d !== null && new Decimal(average7d).gt(0)
    ? new Decimal(row.openInterestNotionalAvg24h).div(average7d).toString()
    : null;
  console.log(row.symbol, surge);
}

// The 1h, 24h, and 7d averages cover the valued completed UTC minutes in their
// windows and publish once at least 95% of those minutes are valued (57, 1368,
// and 9576). They are null for spot or below that coverage; known zero is "0".
// Windows warm after deployment with no historical backfill. Daily snapshot
// points carry openInterestNotionalAvg once at least 1368 of that completed
// UTC day's 1440 minutes are valued.

console.log(stats.totalQuoteVolumeLtd, stats.totalTradeCountLtd);
```

## Builder Notes

Oracle delivery is deployment-configured: Pyth-primary markets can stream
prices over WebSocket, with HTTP polling taking over when a stream stops
advancing. SEDA markets serve a Pyth Pro feed with an explicitly configured
Hyperliquid on-close fallback coin. SEDA answers from that coin when the
upstream market is shut, and also when its Pyth request fails during an open
session; either answer prices the market like any other tick. The server checks
the coin's metadata and index, but the operator must choose the same asset as
the Pyth feed; that cross-provider identity is not automatically verified. The
provider session is reported for monitoring. While a SEDA market's provider
reports the upstream market closed, the oracle lags the book by design, so the
market is not moved to post-only for the book diverging from it: it stays
tradable, liquidations included. In session, a book too far from the oracle
still restricts the market as before.
Consume the existing
mark/index price and `market_status` surfaces rather than inferring trading
availability from the provider or transport alone.

The engine refuses an oracle mark that would value an open position outside
the supported notional, margin or unrealized-PnL range and retains its last
accepted mark. Do not assume that every upstream tick changes position
valuation.

* Resolve and store trading pair IDs before querying orderbooks, trades, candles, funding, or placing orders.
* Public market data does not require authentication.
* User orders, balances, positions, and account streams do require authentication.

## Related Pages

* [Orderbooks & Trades](/developers/orderbooks-trades) for candles, orderbook snapshots, recent trades, and live streams.
* [Order Management](/developers/trade) for order placement and lifecycle.
* [Available Markets](/markets) for a live visual market table.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.