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
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.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.Wallet that sent the transaction. This is the field the
sender filter checks. Empty string if unknown.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).The pool’s base token:
token0 or token1. It is resolved in this order:- If one side is a stablecoin, the other side is the base.
- Otherwise, if one side is the native coin or its wrapped version (for example WETH), the other side is the base.
- Otherwise, if one side is another token ChainQuery treats as a quote asset, the other side is the base.
- Otherwise,
token0is the base.
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:
The same object for the other token of the pool (whichever of
token0 and token1 isn’t baseToken), or null.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.
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 notype 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.
baseToken. This is the same rule the server uses for the type filter.
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.