Skip to main content
A fill is one trade matched between two traders. Each of its two sides gets its own row, and a side is called a leg. Each row carries both the leg’s size and the fees charged on it, so fees, volume or both read from one table.
  • facts.perp_trades: one row per leg of a perpetual fill.
  • facts.order_book_trades: one row per leg of a spot or outcome-market fill.
trade_id is shared by both legs of one fill. Within a fill, (trader_address, crossed) picks out a leg. crossed is true on the taker’s leg: the trader who accepted an order that was already there. It is false on the maker’s leg: the trader whose order was sitting waiting. That pair also handles a self-trade, where one address is on both sides and the two legs differ only on crossed.

Tables

facts.perp_trades holds one row per leg of a perpetual fill, keyed by block_timestamp, perp_market_id, trade_id, trader_address and crossed.
ColumnTypeDescription
block_timestampTIMESTAMPTime of the block this trade landed in.
block_numberINT64Number of that block.
trade_idINT64Identifier shared by both legs of the same fill. Part of the row key, alongside perp_market_id, trader_address and crossed.
perp_market_idSTRINGMarket the trade executed in, keyed like dimensions.perp_markets.
interface_app_idSTRINGThe app whose front end the trade came through, read from the registry table.
exchange_app_idSTRINGThe venue that matched the trade.
token_idSTRINGThe market’s settlement token.
chain_idSTRINGChain the trade executed on.
project_idSTRINGProject the exchange app belongs to.
trader_addressSTRINGAddress of the trader on this side.
sideSTRINGWhich side this leg is: B for the buyer, A for the seller.
crossedBOOLTrue on the taker’s leg, the trader who accepted an order that was already there; false on the maker’s.
priceBIGNUMERICPrice the trade filled at, in the settlement token.
feeBIGNUMERICFee charged on this leg, in fee_token, before anything is shared out.
fee_tokenSTRINGToken the fee was charged in.
builder_feeBIGNUMERICThe front end’s share inside that fee.
deployer_feeBIGNUMERICThe share going to whoever listed the market, inside that fee.
trade_amountBIGNUMERICHow much was traded, in whatever the market tracks.

Sample queries

Put a filter on block_timestamp in every query. Both tables are partitioned on it, and leaving the filter out reads the whole history.
Read one perpetual market’s trades on a single day. trade_amount is how much was traded, measured in whatever the market tracks, and price is the price it filled at. Multiply them for the trade’s notional value: the value of the contracts traded, which is not the same as cash changing hands.

Notes

A fee is charged on each side separately, so a fee total adds up every row. Volume is different. Both legs of an ordinary fill describe one trade at one value, so counting both doubles the venue’s volume. Count one leg per fill. Both tables carry token amounts and no dollar column. Amounts become dollars once, on the market-and-token daily tables described on Metrics, which is what makes every broader total agree with the ones beneath it.