Divvi Protocol - KPI calculation functions / velodrome
Functions
calculateKpi()
VELODROME_SUPPORTED_LIQUIDITY_POOL_ADDRESSES
in ./constants.ts
Network: Optimism Mainnet (and networks where Velodrome has deployed liquidity pools)
Revenue Model: Velodrome generates revenue through trading fees on token swaps, with fees varying by pool
based on volatility and token pair characteristics. Revenue is shared between liquidity providers and the protocol.
Data Sources:
- HyperSync: Optimism Network swap events from Velodrome 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 specified time window
- USD conversion uses token prices at time of each transaction for accuracy
- Only whitelisted liquidity pools are included in revenue calculations
- Fee rates are dynamically set per pool based on volatility and governance decisions
- Iterates through all supported Velodrome 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