Description
Retrieves per-swap fee accounting for AMM pools: executed swap sizes plus fee amounts denominated in the fee token. Fee splits (user/LP vs protocol vs extra) are provided when available.
Use this endpoint to:
- Compute pool revenue over time
- Attribute fees across recipients
- Feed pool yield/ROI models (see
/evm/yields)
Parameters
Target EVM network. See the Chain enumeration for supported values.
Range Filters (mutually exclusive)
Starting block number (inclusive) for the query. Use with to_block.
Ending block number (inclusive) for the query. Use with from_block.
Starting timestamp (ISO-8601). If it falls between blocks, the next block after this timestamp is used. Use with to_timestamp.
Ending timestamp (ISO-8601). If it falls between blocks, the last block before this timestamp is used. Use with from_timestamp.
Validation rule:
You must provide either a block range, a time range, or at least one direct selector.
Providing more than one option results in HTTP 400.
Providing none results in HTTP 400.
Pool Selectors
Filter swaps by exchange IDs. See the DigitalExchange enumeration for supported values.
Filter by BlockDB pool identifiers (uid from /evm/pools).
Filter by pool contract addresses (hex string, 20 bytes, no 0x prefix).
Filter by protocol-specific pool identifiers (e.g., Uniswap V4 pool_id).
Filter by AMM archetype. See the PoolType enumeration for supported values.
Token Selectors (directional)
Restrict to swaps where the input token is in this set (hex string, 20 bytes, no 0x prefix).
Restrict to swaps where the output token is in this set (hex string, 20 bytes, no 0x prefix).
Restrict to swaps where the fee is denominated in one of these tokens (hex string, 20 bytes, no 0x prefix).
Recommended default 250; maximum 1000 to stay under ~10 MB responses.
Pagination cursor from a prior call.
Response Fields
EVM chain ID echoed at the response root.
Echo of request metadata applied to the response.
Block/timestamp bounds derived from the request.
Filters echoed from the request (selectors, pagination state, etc.).
Data
Array of per-swap fee records matching the request.
Chain ID for the swap-fee record.
Stable identifier for the swap-fee record.
BlockDB pool identifier (uid from /evm/pools).
20-byte address of the input token (direction of trade).
20-byte address of the output token for this swap direction.
Token address the fee is denominated in (typically token_in).
Executed input amount (decimals-adjusted). Returned as a string to preserve precision.
Executed output amount (decimals-adjusted). Returned as a string to preserve precision.
Total fee amount in fee_token units (decimals-adjusted). Returned as a string to preserve precision.
User/LP share of fees in fee_token units (nullable).
Protocol share of fees in fee_token units (nullable).
Extra destination share of fees in fee_token units (nullable).
Block height where the swap event was observed.
UTC timestamp of the block containing the swap.
Zero-based transaction index within the block.
Zero-based log index within the transaction.
Row-level lineage hash (hex string, no 0x prefix).
Lineage references of immediate parents.
data._genesis_tracing_ids
Lineage references to the original on-chain artifacts that seeded this record.
Record creation timestamp (ISO-8601).
Last update timestamp (ISO-8601).
Envelope Fields
Cursor token for pagination.
Number of records returned in data.
curl -X POST "https://api.blockdb.io/v1/evm/swaps/fees" \
-H "Authorization: Bearer $BLOCKDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chain_id": 1,
"from_block": 19000000,
"to_block": 19000100,
"pool_uids": [
"88e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000"
],
"token_in_addresses": [
"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
],
"token_out_addresses": [
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
],
"limit": 250
}'
{
"chain_id": 1,
"meta": {
"request_window": {
"from_block": 19000000,
"to_block": 19000100
},
"filters": {
"pool_uids": [
"88e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000"
],
"token_in_addresses": [
"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
],
"token_out_addresses": [
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
],
"limit": 250,
"cursor": null
}
},
"data": [
{
"chain_id": 1,
"id": 123456789,
"pool_uid": "88e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000",
"block_number": 19000042,
"block_time": "2025-12-20T12:34:56Z",
"tx_index": 15,
"log_index": 88,
"token_in": "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"token_out": "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"fee_token": "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"amount_in": "5.000000000000000000",
"amount_out": "15850.000000000000000000",
"fee_amount_total": "0.015000000000000000",
"fee_amount_user": "0.012000000000000000",
"fee_amount_protocol": "0.003000000000000000",
"fee_amount_extra": "0.000000000000000000",
"_tracing_id": "0303c0ffee000000000000000000000000000000000000000000000000000001",
"_parent_tracing_ids": [
"0103c0ffee000000000000000000000000000000000000000000000000000001",
"0204c0ffee000000000000000000000000000000000000000000000000000001"
],
"_genesis_tracing_ids": [
"0103c0ffee000000000000000000000000000000000000000000000000000001"
],
"_created_at": "2025-12-20T12:35:01Z",
"_updated_at": "2025-12-20T12:35:01Z"
}
],
"cursor": null,
"count": 1
}