> For the complete documentation index, see [llms.txt](https://docs.hydromancer.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hydromancer.xyz/readme/builder-guides/hip-3-market-monitoring.md).

# HIP-3 market monitoring

Monitor a Hyperliquid HIP-3 DEX: oracle and mark prices, open interest caps, net deposits and liquidity.

A HIP-3 DEX sets its own oracle prices and runs under its own limits. The requests below show each price update, the caps of each market and how liquid it is.

HIP-3 deployers and the teams that support them usually need to:

* watch every oracle update, including failed ones
* track open interest against the DEX's caps
* measure liquidity on each market
* keep a price history

**At a glance**

| What you need                         | Use                                                                                                                                                                                                                                                                                                                      |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Every oracle update, live             | [setOracleUpdates](https://docs.hydromancer.xyz/readme/websocket/prices-data-and-asset-context/setoracleupdates)                                                                                                                                                                                                         |
| Accepted oracle and mark prices, live | [perpPrices](https://docs.hydromancer.xyz/readme/websocket/prices-data-and-asset-context/perpprices), [allPerpPrices](https://docs.hydromancer.xyz/readme/websocket/prices-data-and-asset-context/allperpprices)                                                                                                         |
| Price history                         | [perpPriceHistoryByTime](https://docs.hydromancer.xyz/readme/rest-api/asset-data/perppricehistorybytime), [oraclePriceHistory](https://docs.hydromancer.xyz/readme/rest-api/asset-data/oraclepricehistory), [oraclePriceHistoryByTime](https://docs.hydromancer.xyz/readme/rest-api/asset-data/oraclepricehistorybytime) |
| DEX details and caps                  | [perpDexs](https://docs.hydromancer.xyz/readme/rest-api/metadata/perpdexs), [perpDexLimits](https://docs.hydromancer.xyz/readme/rest-api/metadata/perpdexlimits)                                                                                                                                                         |
| Net deposits                          | [perpDexStatus](https://docs.hydromancer.xyz/readme/rest-api/metadata/perpdexstatus)                                                                                                                                                                                                                                     |
| Current open interest per market      | [metaAndAssetCtxs](https://docs.hydromancer.xyz/readme/rest-api/metadata/metaandassetctxs)                                                                                                                                                                                                                               |
| Liquidity and trading cost            | [marketLiquidity](https://docs.hydromancer.xyz/readme/rest-api/market-data/marketliquidity), [slippageHistory](https://docs.hydromancer.xyz/readme/rest-api/market-data/slippagehistory)                                                                                                                                 |
| Leverage tiers                        | [marginTable](https://docs.hydromancer.xyz/readme/rest-api/metadata/margintable)                                                                                                                                                                                                                                         |

**Oracle and mark prices**

The [setOracleUpdates](https://docs.hydromancer.xyz/readme/websocket/prices-data-and-asset-context/setoracleupdates) stream delivers every oracle submission of a DEX. Subscribe with the DEX name in `dex`, such as `xyz`.

Each update has `oracle_pxs`, `mark_pxs` and `external_perp_pxs` as lists of `[coin, price]` pairs. Failed submissions stay visible with `success: false` and the reason in `error`, which makes this the stream to alert on.

[perpPrices](https://docs.hydromancer.xyz/readme/websocket/prices-data-and-asset-context/perpprices) streams the accepted oracle and mark price of up to 200 perps, one message per block. When a DEX publishes more than once in a block, the last one is the accepted price. The add-on [allPerpPrices](https://docs.hydromancer.xyz/readme/websocket/prices-data-and-asset-context/allperpprices) covers every perp.

For history, [perpPriceHistoryByTime](https://docs.hydromancer.xyz/readme/rest-api/asset-data/perppricehistorybytime) returns the accepted prices of a perp in a time range. Each row has `time`, `blockNumber`, `oraclePx`, `markPx`, `extPerpPx` and `updateClass`. `updateClass` shows how the network sourced the price: `Deployer`, `Fallback` or `Normal`. [oraclePriceHistory](https://docs.hydromancer.xyz/readme/rest-api/asset-data/oraclepricehistory) returns the most recent oracle updates of a coin, newest first, and [oraclePriceHistoryByTime](https://docs.hydromancer.xyz/readme/rest-api/asset-data/oraclepricehistorybytime) the updates in a time range, oldest first.

**Caps and deposits**

[perpDexLimits](https://docs.hydromancer.xyz/readme/rest-api/metadata/perpdexlimits) returns one DEX's limits:

* `totalOiCap` - the open interest cap for the whole DEX
* `coinToOiCap` - the cap of each market, as `[coin, cap]` pairs
* `maxTransferNtl` - the transfer limit

[perpDexStatus](https://docs.hydromancer.xyz/readme/rest-api/metadata/perpdexstatus) returns the DEX's `totalNetDeposit`, and [perpDexs](https://docs.hydromancer.xyz/readme/rest-api/metadata/perpdexs) lists every DEX with its deployer, fee recipient and per-asset streaming open interest caps.

[metaAndAssetCtxs](https://docs.hydromancer.xyz/readme/rest-api/metadata/metaandassetctxs) with your `dex` returns the current `openInterest` and `markPx` of each market, to compare against those caps.

**Liquidity**

[marketLiquidity](https://docs.hydromancer.xyz/readme/rest-api/market-data/marketliquidity) and [slippageHistory](https://docs.hydromancer.xyz/readme/rest-api/market-data/slippagehistory) accept HIP-3 markets such as `xyz:GOLD`. The first returns the depth near the best price, and the second the estimated cost of trading a given dollar amount, so you can track both over time for each market.

To see which addresses are quoting, follow the [L4 orderbook streaming](https://docs.hydromancer.xyz/readme/builder-guides/l4-orderbook-streaming) guide.

**Margin tiers and new markets**

[marginTable](https://docs.hydromancer.xyz/readme/rest-api/metadata/margintable) returns the leverage tiers of a margin table: each tier's `lowerBound` and `maxLeverage`. A market's `marginTableId` is in its metadata. [perpDeployAuctionStatus](https://docs.hydromancer.xyz/readme/rest-api/token-deployment/perpdeployauctionstatus) returns the current perp deploy auction.

**Putting it together**

1. Subscribe to `setOracleUpdates` for your DEX, and alert on `success: false` or a missing update.
2. On a schedule, compare `metaAndAssetCtxs` open interest with `perpDexLimits`.
3. Record `marketLiquidity` and `slippageHistory` for each market to track liquidity over time.

For S3 exports of a DEX's activity, positions and order book state, see [HIP-3 DEX](https://docs.hydromancer.xyz/readme/builder-guides/hip-3-dex).
