Skip to main content
WSS
wss://stream.blockdb.io/v1/evm/
Messages
subscribe
type:object
unsubscribe
type:object
subscribe_response
type:object
unsubscribe_response
type:object
update
type:object

Description

The Swap Fees stream delivers real-time per-swap fee accounting for AMM pools. Each message includes executed swap sizes, computed fee amounts, and fee splits across recipients.

Subscription Parameters

chain_id
number
required
Target EVM network.
pool_uids
string[]
Filter updates to specific BlockDB pool identifiers.
token_in_addresses
string[]
Filter by input token addresses.

Message Fields

pool_uid
string
BlockDB pool identifier.
token_in
string
Address of the input token.
token_out
string
Address of the output token.
amount_in
string
Executed input amount.
amount_out
string
Executed output amount.
fee_amount_total
string
Total fee amount in fee_token units.
block_number
number
Block height where the swap occurred.
_tracing_id
string
Row-level lineage hash for correlation.

Subscription Example

# Use wscat to connect and subscribe
wscat -c wss://stream.blockdb.io/v1/evm/ \
  -H "Authorization: Bearer $BLOCKDB_API_KEY" \
  -x '{"action": "subscribe", "dataset_id": "0303", "chain_id": 1, "params": {"token_in_addresses": ["c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"]}}'

Response Example

{
  "chain_id": 1,
  "dataset_id": "0303",
  "is_reorg": false,
  "data": {
    "pool_uid": "88e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000",
    "token_in": "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "token_out": "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "fee_token": "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "amount_in": "5.000000000000000000",
    "amount_out": "15850.000000000000000000",
    "fee_amount_total": "0.015000000000000000",
    "block_number": 19000042,
    "_tracing_id": "0303c0ffee0000000000000000000000000000000000000000000000000001",
    "_created_at": "2025-12-20T12:35:01Z"
  }
}