Divvi Protocol - KPI calculation functions / aerodrome
Functions
calculateKpi()
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
- 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
- Iterates through all supported Aerodrome liquidity pools
- For each pool, fetches user’s swap events within the time window
- Calculates USD volume of swaps using historical token prices at transaction timestamps
- Retrieves pool-specific fee rate from the liquidity pool smart contract
- Applies fee rate to swap volume to determine trading fee revenue per pool
- Aggregates revenue across all pools for total user-attributed trading fee revenue
Parameters
params
Calculation parametersaddress
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
Suggest changes to this pageLast updated: Aug 6, 2025, 3:51 PM