Skip to main content
The data object of every event message is one trade. Its event field tells you the kind: swap or swap-enriched. A swap-enriched payload has every swap field plus two token objects. All addresses are lowercase hex strings.

swap

"swap"
Event kind.
string
Chain identifier, for example "evm:1".
number
Block that contains the trade.
number
Position of the transaction in the block.
number
Position of the swap log in the block.
number
Block time in Unix epoch milliseconds.
string
Transaction hash.
string
Pool address. For pools identified by a 32-byte id (for example Uniswap v4 or PancakeSwap Infinity), this is the 0x-prefixed 64-hex id.
string
Protocol of the pool, for example uniswap-v2, uniswap-v3, uniswap-v4, pancakeswap-v3, clanker-v4 or fourmeme. Values are lowercase and case-sensitive. Can be missing on some trades. See Protocols and launchpads and GET /protocols for the values in use.
"TRADE"
Always "TRADE": the stream only carries trades.
string
Wallet that sent the transaction. This is the field the sender filter checks. Empty string if unknown.
string
Recipient of the swap output. Present only when known.
string
Address of the pool’s first token.
string
Address of the pool’s second token.
string
Signed integer amount of token0 in base units (not adjusted for decimals). Positive means the token went into the pool (the trader sold it); negative means it came out of the pool (the trader received it).
string
Same as rawAmount0, for token1.
number
rawAmount0 adjusted for decimals, with the same sign.
number
rawAmount1 adjusted for decimals, with the same sign.
number
USD price of token0 at this trade.
number
USD price of token1 at this trade.
number
USD value of the trade. This is the field the tokenAmountUsd filter checks.
number | null
Gas fee of the transaction in USD, or null if unknown.
number
USD price of the chain’s native coin at this trade.
string
The pool’s base token: token0 or token1. It is resolved in this order:
  1. If one side is a stablecoin, the other side is the base.
  2. Otherwise, if one side is the native coin or its wrapped version (for example WETH), the other side is the base.
  3. Otherwise, if one side is another token ChainQuery treats as a quote asset, the other side is the base.
  4. Otherwise, token0 is the base.
For a memecoin/WETH pool the base is the memecoin; for a WETH/USDC pool it is WETH.

Example

A purchase of about 71.4 WETH for 250,000 USDC on Ethereum. USDC went into the pool (rawAmount0 positive) and WETH came out (rawAmount1 negative), so the trader bought WETH.

swap-enriched

Every field of swap, with event set to "swap-enriched", plus:
object | null
Metadata of the token named by baseToken, or null.
object | null
The same object for the other token of the pool (whichever of token0 and token1 isn’t baseToken), or null.
A token object is null when:
  • the token isn’t in ChainQuery’s token store yet, or
  • the metadata lookup failed or took longer than 2 seconds. The event is then sent without enrichment and isn’t sent again.
Treat null as “metadata unavailable” and fall back to the address. Token metadata can be a few seconds old. Subscribers that only ask for swap never wait for enrichment. A swap-enriched event can arrive slightly later than the swap event for the same trade.

Example

A sale of 2 WETH for USDC on Base.

Deriving buy or sell

The payload has no type or side field. Work it out from the sign of the raw amount of a reference token:
  • If the reference token’s raw amount is positive, the token went into the pool: the trader sold it.
  • Otherwise (negative or zero), it came out of the pool: the trader bought it.
Use the token you care about as the reference. If you don’t have one, use baseToken. This is the same rule the server uses for the type filter.
Parse raw amounts as big integers (BigInt in JavaScript, int in Python). They often exceed the safe integer range of a JavaScript number. In the Ethereum example above, the base token is WETH and rawAmount1 is negative, so the trade is a WETH buy. In the Base example, the base token is WETH and rawAmount0 is positive, so it is a WETH sell.

Field names in filters and payloads

Filters use different names from the payload for some fields: See Filters.