Skip to main content
POST
https://api.blockdb.io
/
v1
/
evm
/
swaps
/
fees
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
}

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

chain_id
number
required
Target EVM network. See the Chain enumeration for supported values.

Range Filters (mutually exclusive)

from_block
number
Starting block number (inclusive) for the query. Use with to_block.
to_block
number
Ending block number (inclusive) for the query. Use with from_block.
from_timestamp
string
Starting timestamp (ISO-8601). If it falls between blocks, the next block after this timestamp is used. Use with to_timestamp.
to_timestamp
string
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

exchange_ids
number[]
Filter swaps by exchange IDs. See the DigitalExchange enumeration for supported values.
pool_uids
string[]
Filter by BlockDB pool identifiers (uid from /evm/pools).
pool_addresses
string[]
Filter by pool contract addresses (hex string, 20 bytes, no 0x prefix).
pool_ids
string[]
Filter by protocol-specific pool identifiers (e.g., Uniswap V4 pool_id).
pool_type_ids
number[]
Filter by AMM archetype. See the PoolType enumeration for supported values.

Token Selectors (directional)

token_in_addresses
string[]
Restrict to swaps where the input token is in this set (hex string, 20 bytes, no 0x prefix).
token_out_addresses
string[]
Restrict to swaps where the output token is in this set (hex string, 20 bytes, no 0x prefix).
fee_token_addresses
string[]
Restrict to swaps where the fee is denominated in one of these tokens (hex string, 20 bytes, no 0x prefix).

Pagination Controls

limit
number
default:"250"
Recommended default 250; maximum 1000 to stay under ~10 MB responses.
cursor
string
Pagination cursor from a prior call.

Response Fields

chain_id
number
EVM chain ID echoed at the response root.

Meta

meta
object
Echo of request metadata applied to the response.
meta.request_window
object
Block/timestamp bounds derived from the request.
meta.filters
object
Filters echoed from the request (selectors, pagination state, etc.).

Data

data
object[]
Array of per-swap fee records matching the request.
data.chain_id
number
Chain ID for the swap-fee record.
data.id
number
Stable identifier for the swap-fee record.
data.pool_uid
string
BlockDB pool identifier (uid from /evm/pools).
data.token_in
string
20-byte address of the input token (direction of trade).
data.token_out
string
20-byte address of the output token for this swap direction.
data.fee_token
string
Token address the fee is denominated in (typically token_in).
data.amount_in
string
Executed input amount (decimals-adjusted). Returned as a string to preserve precision.
data.amount_out
string
Executed output amount (decimals-adjusted). Returned as a string to preserve precision.
data.fee_amount_total
string
Total fee amount in fee_token units (decimals-adjusted). Returned as a string to preserve precision.
data.fee_amount_user
string | null
User/LP share of fees in fee_token units (nullable).
data.fee_amount_protocol
string | null
Protocol share of fees in fee_token units (nullable).
data.fee_amount_extra
string | null
Extra destination share of fees in fee_token units (nullable).
data.block_number
number
Block height where the swap event was observed.
data.block_time
string
UTC timestamp of the block containing the swap.
data.tx_index
number
Zero-based transaction index within the block.
data.log_index
number
Zero-based log index within the transaction.
data._tracing_id
string
Row-level lineage hash (hex string, no 0x prefix).
data._parent_tracing_ids
string[]
Lineage references of immediate parents.
data._genesis_tracing_ids
string[]
Lineage references to the original on-chain artifacts that seeded this record.
data._created_at
string
Record creation timestamp (ISO-8601).
data._updated_at
string
Last update timestamp (ISO-8601).

Envelope Fields

cursor
string | null
Cursor token for pagination.
count
number
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
}