lighter.dex.order_books table provides flattened order book updates. One row per market/update/side/level.
Table Details
| Property | Value |
|---|---|
| Clustering Key(s) | to_date("timestamp") (base table) |
Table Columns
Market Information
| Column Name | Description |
|---|---|
| market_id | Lighter market ID |
| symbol | Market symbol (e.g., BTC, ETH/USDC) |
| market_type | ’perpetuals’ or ‘spot’ |
| base_symbol | Base asset symbol |
| quote_symbol | Quote asset symbol |
| collateral_symbol | Collateral asset symbol for perpetuals. NULL for spots |
| base_l1_address | L1 contract address of the base asset. NULL for perpetuals |
Order Book Data
| Column Name | Description |
|---|---|
| timestamp | UTC timestamp of the order book update |
| side | ’ask’ or ‘bid’ |
| level | 0-based index within the ask or bid array |
| price | Price at this level in quote asset units |
| size | Size at this level in base asset units |
| usd_amount | Dollar value at this level (price * size) |
Sequence Information
| Column Name | Description |
|---|---|
| nonce | Global sequence number at update time |
| begin_nonce | Sequence number at the start of the batch |
| book_offset | Per-market incrementing version counter |
Sample Query
The underlying data is clustered byto_date("timestamp"). Filter by date for efficient queries. Example using the raw table (same clustering applies when querying the 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').