Skip to main content
An order book is a live list of all open buy and sell orders for a trading pair. Shadowbook keeps a separate order book for each pair and updates it as orders are placed, filled, or cancelled. Every order is an on-chain Cardano transaction. When you place an order, your funds are locked in the Shadowbook smart contract under your terms. The order stays open until it gets filled, or you cancel it. Your funds remain in self-custody.

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

Spot is the price of the last completed trade. It’s not always the same as the current best bid or ask. If no trades happened yet, spot can be 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.