Skip to main content

velodrome

Divvi Protocol - KPI calculation functions


Divvi Protocol - KPI calculation functions / velodrome

velodrome

Functions

calculateKpi()

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

Defined in: velodrome/index.ts:62

Calculates trading fee revenue generated for Velodrome DEX on Optimism 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 Velodrome DEX liquidity pools. This metric quantifies the economic value generated by user interactions with the decentralized exchange and supports revenue sharing calculations for the Velodrome ecosystem.

Protocol Context: Velodrome is an Optimism-native AMM (Automated Market Maker) designed to serve as the central liquidity hub for the Optimism ecosystem. It builds on the vote-escrowed model with enhanced tokenomics and offers efficient token swaps with variable fee structures.

Supported Liquidity Pools: See 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

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 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

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 Velodrome 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