Skip to main content
The lighter.dex.order_books table provides flattened order book updates. One row per market/update/side/level.

Table Details

PropertyValue
Clustering Key(s)to_date("timestamp") (base table)

Table Columns

Market Information

Column NameDescription
market_idLighter market ID
symbolMarket symbol (e.g., BTC, ETH/USDC)
market_type’perpetuals’ or ‘spot’
base_symbolBase asset symbol
quote_symbolQuote asset symbol
collateral_symbolCollateral asset symbol for perpetuals. NULL for spots
base_l1_addressL1 contract address of the base asset. NULL for perpetuals

Order Book Data

Column NameDescription
timestampUTC timestamp of the order book update
side’ask’ or ‘bid’
level0-based index within the ask or bid array
pricePrice at this level in quote asset units
sizeSize at this level in base asset units
usd_amountDollar value at this level (price * size)

Sequence Information

Column NameDescription
nonceGlobal sequence number at update time
begin_nonceSequence number at the start of the batch
book_offsetPer-market incrementing version counter

Sample Query

The underlying data is clustered by to_date("timestamp"). Filter by date for efficient queries. Example using the raw table (same clustering applies when querying the view):
SELECT
    market_id,
    timestamp,
    nonce,
    asks,
    bids
FROM lighter.raw.order_books
WHERE timestamp >= CURRENT_DATE
ORDER BY timestamp DESC
LIMIT 100
To query the flattened view lighter.dex.order_books (symbol, side, level, price, size, usd_amount), use the same date filter: WHERE timestamp >= CURRENT_DATE (and optionally AND symbol = 'BTC').