> For the complete documentation index, see [llms.txt](https://k4k3ru.gitbook.io/k4k3ru-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://k4k3ru.gitbook.io/k4k3ru-docs/api/market-hub/get-spread-snapshot.md).

# Get a Cross-Market Spread Snapshot

`MarketHub.Spread.Get` evaluates gross cross-market price differences for a canonical symbol and base-asset quantity. Order-book markets use quantity-specific VWAP; AMMs use the latest pool mid. It supports `spot-spot`, `spot-perp`, `perp-spot`, and `perp-perp` routes.

The HTTP JSON-RPC method is public and does not require request authentication. Gateway applies a per-IP, per-method rate limit.

## Request

```json
{
  "id": "1",
  "method": "MarketHub.Spread.Get",
  "params": {
    "symbol": "BTC/USDC",
    "baseAsset": "BTC",
    "quantity": "0.1",
    "maxAgeSeconds": 30,
    "minimumGrossSpreadBps": "0",
    "routeFamilies": ["spot-spot", "spot-perp", "perp-spot", "perp-perp"]
  }
}
```

`assetClass` defaults to `crypto`, `minimumGrossSpreadBps` defaults to `0`, and omitted `routeFamilies` enables all four families. Canonical symbols must match exactly; stablecoin parity and wrapped-asset aliases are not applied. `sourceFilter` can restrict broad venue categories, liquidity models, or AMM chains.

## Evaluation

Order-book venues (CEX and DEX) consume asks for buying and bids for selling to calculate VWAP for the requested base quantity. Insufficient depth excludes that direction; a fresh BBO may be used only if its displayed quantity covers the request.

AMMs use each pool's latest state-derived mid from the AMMPool store (sqrt price, active bin or reserves, depending on protocol). The same mid is used for buying and selling, and the indicative quote amount is mid multiplied by the requested quantity. This does not simulate execution, include pool fees or price impact, or guarantee available quantity. No quantity quote calculation, tick acquisition, RPC call or public AMM BBO fallback occurs. Quote readiness and tick coverage do not gate a fresh pool price.

AMM price receipt times must be younger than `maxAgeSeconds` (an optional unsigned integer in seconds; omitted or zero defaults to 5; maximum 4294967295); recalculation does not refresh them. CEX and order-book DEX retain their existing five-second freshness window (ten seconds for Hyperliquid). Every network-qualified pool is evaluated independently, including multiple pools at one venue. Route IDs distinguish chains, networks and pools. For AMM legs, `ConsumedLevelCount` (`lc`) is zero and `VWAP` contains the pool mid; timestamps retain the price receipt time. Subscribe reevaluates expiry locally once per second even without new market events. The result echoes the normalized `maxAgeSeconds` for subscription routing. `maxAgeSeconds` applies only to AMMs and forms part of the subscription key; use the same value when unsubscribing. For example, add `"maxAgeSeconds": 60` to Spread Get or Subscribe parameters to allow AMM prices younger than one minute.

Order-book venues consume synchronized, fresh depth to calculate VWAP, falling back to a sufficiently sized fresh BBO when necessary. Private AMM evaluations do not replace the publicly streamed BBO or OrderBook. The same individual market or pool is never used for both legs. Distinct pools at the same venue, and Spot and Perp views at the same venue, may form a route.

Only routes at or above `minimumGrossSpreadBps` appear in `er` (`eligibleRoutes`). Gross spread does not separately deduct trading fees, funding, borrow costs, gas, slippage beyond the quoted state or observed depth, or transfer costs. AMM pool fees are not included in the mid price; this is not a net-profit estimate.

Route direction describes the two priced legs, not a complete execution strategy. For example, `perp-spot` means buying the perpetual and selling Spot. Selling Spot requires existing inventory or a supported margin borrow; selling existing inventory while buying the perpetual leaves long exposure rather than creating a new delta-neutral position. Consumers must evaluate inventory, margin availability, net delta, funding, borrow cost, fees, and exit execution before trading.

## Response

```json
{
  "id": "1",
  "result": {
    "ac": "crypto",
    "s": "BTC/USDC",
    "ba": "BTC",
    "qa": "USDC",
    "q": "0.1",
    "maxAgeSeconds": 30,
    "mgsb": "0",
    "rf": ["spot-spot", "spot-perp", "perp-spot", "perp-perp"],
    "emc": 4,
    "erc": 12,
    "prc": 12,
    "er": [],
    "ts": 1788533857086000
  }
}
```

`emc`, `erc`, and `prc` are the evaluated market, route, and successfully priced route counts. Eligible routes contain the buy and sell Venue, market type, VWAP, quote amount, consumed level count, source book version, timestamp, gross spread, and gross spread in basis points.

Each eligible-route leg also carries execution identity when available:

* `vs`: Venue-native market symbol.
* `bai` / `qai`: Venue- or chain-native base and quote asset identifiers.
* `pid`: On-chain AMM pool identifier. It is omitted for order-book markets.
* `c` / `n`: AMM chain and network. They are omitted for chain-independent CEX markets.

These identifiers allow a TradeHub implementation to resolve the quoted market or pool without relying only on canonical asset symbols. Each AMM leg reports the individual pool supplying its mid price; no composite AMM price is used.

Possible errors include `invalid_parameter`, `not_found`, `rate_limit_error`, and `unexpected`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://k4k3ru.gitbook.io/k4k3ru-docs/api/market-hub/get-spread-snapshot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
