Skip to main content
The order book is a real-time record of all open buy and sell orders for a trading pair. Shadowbook maintains a separate order book for each pair, updated as orders are placed and filled on-chain. Every order is an on-chain transaction. When you place an order, you submit a Cardano transaction that locks your funds in the Shadowbook smart contract. The order remains open until the protocol fills it or you cancel it — both of which are also on-chain transactions.

Bids and asks

The order book has two sides:
  • Bids — buy orders, sorted from the highest price to the lowest. Buyers are willing to purchase the base asset at or below these prices.
  • Asks — sell orders, sorted from the lowest price to the highest. Sellers are willing to sell the base asset at or above these prices.
The gap between the highest bid and the lowest ask is the spread.

Price levels

Each side of the order book is aggregated into price levels. A price level groups all open orders at the same price and reports the total liquidity available at that price.
FieldTypeDescription
priceDecimalPricePrice ratio (quote per base unit)
accumulated_liquidityu64Total base asset available at this price, in lovelace or token units

Spot price

The spot field on the order book response is the price of the most recent trade for the pair. It reflects the last execution price, not the current best bid or ask. If no trades have occurred, spot is null.

Reading the order book

To interpret the order book:
  1. The best bid is bids[0] — the highest price a buyer will pay.
  2. The best ask is asks[0] — the lowest price a seller will accept.
  3. A trade occurs when a new order crosses the spread (a buy order at or above the best ask, or a sell order at or below the best bid).

Get order book

Fetch a live snapshot of the order book for any trading pair.