How a filter is priced
The cost is calculated per pair (one chain and one event kind):- A chain-wide pair costs 10. A pair is chain-wide when it has no filter, or when its filter doesn’t pin any address. The server has to check a chain-wide filter against every trade on the chain.
- Any other pair costs 1 for every started 500 pinned addresses: 1 to 500 addresses cost 1, 501 to 1,000 cost 2, and so on.
poolAddress, tokenAddress and sender values in eq and in conditions. How they combine:
Examples, per pair:
Subscription cost and the connection budget
A subscription costs the sum of its pairs. Each pair is priced with its own filter, so a per-kind filter map can mix cheap and chain-wide pairs. The total cost of all subscriptions on one connection must be 100 or less. A subscribe that would go over is refused:The message text doesn’t describe this channel’s cost model. On the multi-events stream, the 100 is a budget of cost units calculated as described on this page, not a count of subscriptions or list entries.
Worked examples
Four chain-wide pairs: 40.SUBSCRIPTION_LIMIT.
A mixed map: 22.
Keeping costs down
- Pin something. A filter that names tokens, pools or wallets costs 1 per 500 of them instead of 10.
- Ask for one event kind.
swap-enrichedcontains everyswapfield, so requesting both doubles the cost for the same trades. - Only list the chains you need. Each chain adds its own pairs.
- Sampling reduces the number of events, not the cost.
Connection limits
A full list of 500 addresses takes about 22 KB of JSON, so a subscribe message can hold at most two full lists before it reaches 64 KiB.
Heartbeat
The server sends a WebSocket protocol ping frame everyheartbeatMs (30,000 ms, also given in the welcome message). Browsers and most WebSocket libraries answer with a pong automatically. If you turned automatic pongs off, answer them yourself.
The application-level {"op":"ping"} doesn’t count as a pong. It doesn’t keep the connection alive and it counts toward the 20-messages-per-second limit.
Slow consumers
If your client reads more slowly than trades arrive, data piles up on the server. Past 4 MiB the server closes the connection with4008. Reconnect and resume from your cursors. If it keeps happening, narrow the filter, request fewer chains or kinds, or move processing off the thread that reads the socket.
Close codes
Subscriptions are removed when a connection closes. After any of these, subscribe again on the new connection. See the reconnect recipe.
Error codes
Errors are sent as{ "type": "error", "id"?, "code", "message", "details"? } and don’t close the connection. Codes the multi-events stream can send:
After a subscribe error, the id is free to use again, except after
DUPLICATE_SUBSCRIPTION, where the existing subscription keeps it.