Skip to main content
gTrade does not expose a public REST endpoint that returns the virtual order book (VOB) as a ready-made ladder. The VOB shown in the trading interface is derived client-side from public data:
  • trading variables from the chain-specific backend
  • the current price for the pair
  • SDK price-impact helpers
The VOB is synthetic. gTrade does not match orders through a resting order book; it uses shared vault liquidity and deterministic price-impact rules. The VOB is a visualization of available execution liquidity at different price-impact levels.

Public inputs

Use the chain-specific trading backend for pair, fee, depth-band, OI, skew, and collateral state:
For a smaller response, request only the fields needed for VOB construction:
The depth-band fields are:
  • pairInfos.pairDepthBands - per-pair depth-band slots
  • depthBandsMapping - global mapping for the 30 depth-band offsets
Use the pricing backend for the current pair price:
For a continuously updated VOB, fetch the initial /charts snapshot and then keep prices fresh with the price stream documented in Live prices and OHLC snapshots.

High-level flow

  1. Fetch trading variables from backend-<network>.gains.trade.
  2. Convert the raw backend response with transformGlobalTradingVariables.
  3. Fetch current prices from /charts or maintain them from the pricing WebSocket.
  4. Build the skew-adjusted market price with buildMarketPriceContext and getCurrentMarketPrice.
  5. Probe opening price impact for a set of target impacts and position sizes.
  6. Convert the probes into ask and bid levels.

Example

This example mirrors the approach used by the gTrade frontend: it creates a position-size ladder for one pair and one collateral.

Price selection

The frontend VOB uses the current pair price from the pricing feed and then applies skew-market-price logic through the SDK. For live integrations:
  • use /charts for the initial snapshot
  • subscribe to the price WebSocket for updates
  • rebuild or throttle the VOB when the selected pair price changes
See Mark + Index prices introduction if your integration separates mark and index prices.

Fixed-spread pairs

Some pairs do not have depth bands or skew depth. For those markets, the VOB has no size-dependent ladder. Show the fixed long and short execution prices from getFixedSpreadP instead.

Operational notes

  • No authentication is required for public read endpoints, but rate limits apply.
  • Prefer GET /trading-variables/all when you need currentBlock. Use keyed trading variables when you already have a current block from another source.
  • collateralIndex is 1-based in SDK helpers; array access is collaterals[collateralIndex - 1].
  • The displayed ask side corresponds to opening longs. The displayed bid side corresponds to opening shorts.
  • Pair availability and collateral availability vary by chain. Always derive pair and collateral metadata from the same chain backend you are using for the VOB.