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]
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
market_ids | number[] | No | Filter 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
| Field | Type | Description |
|---|---|---|
channel | string | Always "trades" |
type | string | Always "update" |
market_id | string | Market ID |
data | object | Trade object (see below) |
tx_hash | string | Transaction hash |
block_number | number | Blockchain block number |
log_index | number | Log index within the block |
block_timestamp | string | Blockchain timestamp (nanoseconds) |
timestamp | string | Server timestamp (nanoseconds) |
Trade Object Fields
| Field | Type | Description |
|---|---|---|
id | string | Unique trade ID (maker_order_id:taker_order_id) |
maker_order_id | number | Maker's order ID |
taker_order_id | number | Taker's order ID |
maker | string | Maker's address |
taker | string | Taker's address |
maker_side | number | Maker's side: 0 = Buy, 1 = Sell |
price | string | Trade price (decimal) |
size | string | Trade size (decimal) |
fee_maker | string | Fee paid by maker (decimal) |
fee_taker | string | Fee paid by taker (decimal) |
fee_liquidation | string | Liquidation fee, if applicable (decimal) |
Maker Side
| Value | Description |
|---|---|
0 | Maker was buying (long) |
1 | Maker 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.