Skip to main content

aerodrome

Divvi Protocol - KPI calculation functions


Divvi Protocol - KPI calculation functions / aerodrome

aerodrome

Functions

calculateKpi()

function calculateKpi(params): Promise<KpiResult<string>>

Defined in: aerodrome/index.ts:56

Calculates trading fee revenue generated for Aerodrome DEX on Base Network.

Important Note: For multi-hop swaps (e.g., user -> pool 1 -> pool 2 -> user), only the trading fee from the final transfer (pool 2 -> user) is captured in the calculation. Intermediate transfer fees are not included.

KPI Unit: USD (United States Dollars)

Business Purpose: Measures the trading fee revenue attributable to a specific user's trading activity on Aerodrome DEX liquidity pools. This metric helps assess the economic value generated by user interactions with the decentralized exchange and is crucial for revenue sharing and incentive distribution calculations.

Protocol Context: Aerodrome is a next-generation AMM (Automated Market Maker) designed to serve as the central liquidity hub on Base Network, offering efficient token swaps with competitive fees.

Supported Liquidity Pools: See AERODROME_SUPPORTED_LIQUIDITY_POOL_ADDRESSES in ./constants.ts

Data Sources:

  • HyperSync: Base Network swap events from Aerodrome liquidity pools
  • RPC Queries: Pool fee rates via Viem public client calls to liquidity pool contracts
  • Token Price API: Historical token prices via fetchTokenPrices utility
  • Block Data: Timestamps via getBlockRange utility for temporal filtering

Business Assumptions:

  • Trading fees are proportional to trade volume and pool-specific fee rates
  • Revenue attribution is based on user's direct trading activity within time window
  • USD conversion uses token prices at time of each transaction for accuracy
  • Only supported liquidity pools are included in revenue calculations
  • Universal Router contract handles most trading interactions

Fee Structure: Variable fees per pool (typically 0.05% to 1.00% depending on pool volatility and type)

Calculation Method:

  1. Iterates through all supported Aerodrome liquidity pools
  2. For each pool, fetches user's swap events within the time window
  3. Calculates USD volume of swaps using historical token prices at transaction timestamps
  4. Retrieves pool-specific fee rate from the liquidity pool smart contract
  5. Applies fee rate to swap volume to determine trading fee revenue per pool
  6. Aggregates revenue across all pools for total user-attributed trading fee revenue

Parameters

params

Calculation parameters

address

string

User wallet address to calculate trading fee revenue for

endTimestampExclusive

Date

End of time window for revenue calculation (exclusive)

startTimestamp

Date

Start of time window for revenue calculation (inclusive)

Returns

Promise<KpiResult<string>>

Promise resolving to total trading fee revenue in USD generated by user's activity