Skip to main content
The lighter.dex.trades table contains all DEX trades on Lighter including voluntary trades, liquidations, and deleverages. Use trade_type to filter by event type.

Table Details

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

Table Columns

Trade Type

Column NameDescription
trade_typeType of trade event: ‘trade’, ‘liquidation’, or ‘deleverage’
market_type’perpetuals’ or ‘spot’

Market Information

Column NameDescription
coinMarket symbol (e.g., BTC, ETH/USDC)
token_a_symbolBase token symbol
token_b_symbolQuote token symbol
market_idLighter market ID
max_leverageMaximum leverage for this market

Trade Details

Column NameDescription
amountTrade size in base asset units
priceExecution price
usd_amountUSD value of the trade
timestampUTC timestamp of the trade
transaction_hashOn-chain transaction hash
trade_idUnique trade identifier
unique_idAlias of trade_id
block_heightBlock height of the trade

Participants

Column NameDescription
buyerAccount ID of the buyer (bid side)
sellerAccount ID of the seller (ask side)
maker_account_idAccount ID of the maker
taker_account_idAccount ID of the taker
is_maker_askTrue if the maker is on the ask (sell) side

Order Information

Column NameDescription
buyer_order_idOrder ID of the buyer’s order
seller_order_idOrder ID of the seller’s order
buyer_client_idClient-assigned order ID for buyer
seller_client_idClient-assigned order ID for seller

Fees

Column NameDescription
fee_tokenToken in which fees are paid
buyer_feeFee paid by buyer in USD
seller_feeFee paid by seller in USD
maker_fee_rateMaker fee as decimal fraction
maker_fee_amountMaker fee in USD
taker_fee_rateTaker fee as decimal fraction
taker_fee_amountTaker fee in USD

Position Changes

Column NameDescription
buyer_start_positionBuyer’s position size before this trade
seller_start_positionSeller’s position size before this trade
buyer_position_sign_changedWhether buyer’s position flipped direction
seller_position_sign_changedWhether seller’s position flipped direction

Liquidation Fields

Column NameDescription
liquidated_account_idAccount ID of the liquidated party. NULL for regular trades
counterparty_account_idAccount ID of the counterparty. NULL for regular trades
liquidation_fee_rateLiquidation fee rate. NULL for regular trades
liquidation_fee_amountLiquidation fee in USD. NULL for regular trades
liquidated_max_leverageLiquidated account’s max leverage. NULL for regular trades

Market Parameters

Column NameDescription
collateral_symbolCollateral asset symbol (e.g., USDC)
maintenance_margin_fractionMarket maintenance margin fraction
closeout_margin_fractionMarket closeout margin fraction

Sample Query

SELECT
    timestamp,
    coin,
    trade_type,
    amount,
    price,
    usd_amount,
    buyer,
    seller
FROM lighter.dex.trades
WHERE timestamp >= CURRENT_DATE - 7
ORDER BY timestamp DESC
LIMIT 100