Trades Channel

Real-time trade feed for all matched orders. This is a public channel that broadcasts every trade as it happens.

Subscribe

{
  "method": "subscribe",
  "params": {
    "channel": "trades",
    "market_ids": [1, 2]
  }
}
ParameterTypeRequiredDescription
market_idsnumber[]NoFilter by market IDs. Empty = all markets

Message Format

Update

Sent immediately when a trade occurs. There is no snapshot for this channel.

{
  "channel": "trades",
  "type": "update",
  "market_id": "1",
  "data": {
    "id": "123456789:987654321",
    "maker_order_id": 123456789,
    "taker_order_id": 987654321,
    "maker": "0x1234567890123456789012345678901234567890",
    "taker": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
    "maker_side": 0,
    "price": "50000.5",
    "size": "1.25",
    "fee_maker": "0.00125",
    "fee_taker": "0.0025",
    "fee_liquidation": "0"
  },
  "tx_hash": "0xabc123def456...",
  "block_number": 12345678,
  "log_index": 5,
  "block_timestamp": "1703123456000000000",
  "timestamp": "1703123456123456789"
}

Update Message Fields

FieldTypeDescription
channelstringAlways "trades"
typestringAlways "update"
market_idstringMarket ID
dataobjectTrade object (see below)
tx_hashstringTransaction hash
block_numbernumberBlockchain block number
log_indexnumberLog index within the block
block_timestampstringBlockchain timestamp (nanoseconds)
timestampstringServer timestamp (nanoseconds)

Trade Object Fields

FieldTypeDescription
idstringUnique trade ID (maker_order_id:taker_order_id)
maker_order_idnumberMaker's order ID
taker_order_idnumberTaker's order ID
makerstringMaker's address
takerstringTaker's address
maker_sidenumberMaker's side: 0 = Buy, 1 = Sell
pricestringTrade price (decimal)
sizestringTrade size (decimal)
fee_makerstringFee paid by maker (decimal)
fee_takerstringFee paid by taker (decimal)
fee_liquidationstringLiquidation fee, if applicable (decimal)

Maker Side

ValueDescription
0Maker was buying (long)
1Maker was selling (short)

The taker's side is always opposite to the maker's side.

Examples

Subscribe to all trades

{
  "method": "subscribe",
  "params": {
    "channel": "trades"
  }
}

Subscribe to specific markets

{
  "method": "subscribe",
  "params": {
    "channel": "trades",
    "market_ids": [1, 2]
  }
}

Subscribe to single market

{
  "method": "subscribe",
  "params": {
    "channel": "trades",
    "market_ids": [1]
  }
}

Unsubscribe

{
  "method": "unsubscribe",
  "params": {
    "channel": "trades"
  }
}

Testing with wscat

# Connect
wscat -c ws://localhost:8090/ws

# Subscribe to all trades
{"method":"subscribe","params":{"channel":"trades"}}

# Subscribe to market 1 only
{"method":"subscribe","params":{"channel":"trades","market_ids":[1]}}

# Unsubscribe
{"method":"unsubscribe","params":{"channel":"trades"}}

Notes

No Snapshot

Unlike other channels (orders, orderbook), the trades channel does not send a snapshot on subscription. It only streams new trades as they occur.

Price Format

All price and size fields are in decimal format (human-readable), not wei.

  • Example price: "50000.5" = $50,000.50
  • Example size: "1.25" = 1.25 units

Real-time Delivery

Trades are broadcast immediately when the MatchOrder event is processed from the blockchain. There is no batching or throttling.

Public Channel

This channel does not require authentication. All trades are public market data.