Skip to main content

Description

The Swaps endpoint provides per-swap fee accounting for AMM pools. Each swap record includes executed token amounts, computed fee amounts, and fee splits across recipients (LPs/users, protocol, extra destinations). This data enables revenue attribution, pool economics analysis, and feeds into yield prediction models.

Endpoint Matrix

EndpointSummaryDataset IDTypical Latency
POST /evm/swaps/feesPer-swap fee accounting (executed sizes + fee amounts)0303< 250 ms

Parameter Conventions

from_block
number
Starting block height (inclusive) for swap fee records.
to_block
number
Ending block height (inclusive) for swap fee records.
from_timestamp
string
Starting timestamp (ISO-8601). If it falls between blocks, the next block after this timestamp is used.
to_timestamp
string
Ending timestamp (ISO-8601). If it falls between blocks, the last block before this timestamp is used.
pool_uids
string[]
BlockDB pool identifiers for filtering swap fees by pool.
pool_addresses
string[]
Pool contract addresses to scope swap fee data.
token_in_addresses
string[]
Filter by input token addresses.
token_out_addresses
string[]
Filter by output token addresses.
fee_token_addresses
string[]
Filter by fee token addresses.
chain_id
number
required
Chain identifier for the target EVM network. See Chain enumeration for supported values.

Usage Guidance

  • Join with fee terms — Link swap fees to pool fee configuration via pool_uid to understand fee splits
  • Time-series analysis — Swap fees are ordered by block/time; use ranges for historical revenue analysis
  • Filter by tokens — Use token_in_addresses and token_out_addresses to analyze specific trading pairs
  • Revenue attribution — Fee split fields (fee_amount_user, fee_amount_protocol, fee_amount_extra) enable precise revenue attribution
  • Feed yield models — Swap fee data is the primary input for yield/ROI predictions (see /evm/yields)

Fee Calculation

Swap fees are computed using the pool’s fee terms (from /evm/pools/fee-terms):
  • fee_amount_total ≈ amount_in * total_fee
  • fee_amount_user ≈ amount_in * user_fee (when available)
  • fee_amount_protocol ≈ amount_in * protocol_fee (when available)
  • fee_amount_extra ≈ amount_in * extra_fee (when available)
Fee amounts are denominated in the fee_token, which may differ from token_in or token_out depending on the pool type.

Common Patterns

Calculate pool revenue over time:
{
  "chain_id": 1,
  "pool_uids": [
    "88e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000"
  ],
  "from_timestamp": "2025-01-01T00:00:00Z",
  "to_timestamp": "2025-01-31T23:59:59Z"
}
Analyze fees for a specific trading pair:
{
  "chain_id": 1,
  "token_in_addresses": [
    "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
  ],
  "token_out_addresses": [
    "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
  ],
  "from_block": 19000000
}
Track protocol revenue:
{
  "chain_id": 1,
  "pool_addresses": [
    "88e6a0c2ddd26feeb64f039a2c41296fcb3f564"
  ],
  "from_timestamp": "2025-12-01T00:00:00Z",
  "to_timestamp": "2025-12-31T23:59:59Z"
}

Dataset Relationships

  • Pools → Swap Fees: Join pool metadata to swap fees using pool_uid
  • Fee Terms → Swap Fees: Fee terms define the fee calculation rules applied to each swap
  • Swap Fees → Yields: Yield predictions are derived from historical swap fees and current reserves
  • Swap Fees → Reserves: Swap fees indicate liquidity changes that affect reserve snapshots
  • Swap Fees → Prices: Swap execution prices are captured in the pricing layers

See Also