params.filters when you subscribe.
Grammar
A filter is a JSON object with exactly one key, the operator. An object with no key, an unknown key, or two keys is rejected withEach condition has one operator: eq, in, gt, gte, lt, lte, and, or.
eqandinvalues are JSON strings.- Comparison values are JSON numbers. The string
"100000"is rejected. eqandindon’t work ontokenAmountUsd, and comparisons don’t work on any other field. Usegteandltetogether for an exact USD range.
Fields
- Pool type values are the lowercase protocol slugs used across the API, such as
uniswap-v2,uniswap-v3,uniswap-v4,pancakeswap-v3orclanker-v4. See Protocols and launchpads."Uniswap-V3"matches nothing. - A trade without a
poolTypenever matches apoolTypecondition. - An invalid address is rejected with
Invalid <field>: must be a valid token or wallet address, or forpoolAddress,Invalid poolAddress: must be a valid token address or pool id.
type: buy or sell
The payload has no side field, so the server works out a side for each trade:
- Reference token. If the whole filter names exactly one distinct
tokenAddress(througheqorin, anywhere in the tree, including insideor) and that token is in the trade, it is the reference. Otherwise the reference is the trade’sbaseToken. - Side. If the reference token’s raw amount is positive (it went into the pool), the side is
sell. Otherwise it isbuy.
{ "and": [{ "eq": ["tokenAddress", WETH] }, { "eq": ["type", "buy"] }] } matches trades where WETH was bought, whichever side of the pool WETH is on.
See Deriving buy or sell to compute the same side on the client.
Limits
The whole subscribe message must also fit in 64 KiB. A full list of 500 addresses takes about 22 KB, so at most two full lists fit in one message. See Limits and subscription cost.
One filter or one per event kind
filters takes two forms:
- One filter. A single condition applies to every kind in
events. - A map. An object whose keys are all event kinds (
swap,swap-enriched) gives each kind its own filter. No event kind is named like an operator, so the two forms can’t be confused.
- Every kind in
eventsneeds an entry. A missing one fails withfilters.<kind>: every requested event needs a filter. - A key that isn’t in
eventsfails withfilters.<key>: not in events. - You can’t leave one kind unfiltered inside a map. Use a second subscription instead.
filters, every trade on the requested chains is delivered.
Cookbook
Each example shows the value ofparams.filters and its cost per pair. “Chain-wide” filters cost 10 per pair because the server checks them against every trade on the chain.
Uniswap v3 or v4 trades (chain-wide, 10)
Uniswap v3 or v4 trades (chain-wide, 10)
{ "in": ["poolType", ["uniswap-v3", "uniswap-v4"]] } is equivalent.Trades in specific pools (1)
Trades in specific pools (1)
Every trade of a token, in any pool (1)
Every trade of a token, in any pool (1)
Trades sent by a list of wallets (1 per started 500 wallets)
Trades sent by a list of wallets (1 per started 500 wallets)
Those wallets, only on Uniswap (1)
Those wallets, only on Uniswap (1)
Trades between $1,000 and $100,000 (chain-wide, 10)
Trades between $1,000 and $100,000 (chain-wide, 10)
WETH buys of $100,000 or more (1)
WETH buys of $100,000 or more (1)
Watched wallets or any trade of $100,000 or more (chain-wide, 10)
Watched wallets or any trade of $100,000 or more (chain-wide, 10)
gte branch pins nothing, so the whole or is chain-wide. See Limits and subscription cost.Sells of a token on one pool type (1)
Sells of a token on one pool type (1)
Validation errors
An invalid filter fails the subscription with codeINVALID_PARAMETERS. Each problem is listed in details with a dotted field path:
- The path starts with
filters, then the event kind when you use the map form, then the operators and array indexes down to the bad value. filters.and.0.gte.0is the field name (index 0) of thegtecondition that is the first child ofand.filters.swap-enriched.and.0.gte.0is the same position in theswap-enrichedfilter of a map.
INVALID_PARAMETERS, including bad addresses.
field path and code in your code. The wording of type and range messages (such as an expected number) may change.