aave
Divvi Protocol - KPI calculation functions
Divvi Protocol - KPI calculation functions / aave
aave
Functions
calculateKpi()
function calculateKpi(params): Promise<KpiResult<string>>
Defined in: aave/index.ts:104
Calculates lending protocol revenue generated for Aave across multiple networks.
KPI Unit: USD (United States Dollars)
Business Purpose: Measures the interest and fee revenue attributable to a specific user's lending and borrowing activity on Aave protocol. This metric quantifies the economic value generated by user interactions with Aave's money markets and supports protocol revenue analysis.
Protocol Context: Aave is a decentralized lending protocol that allows users to lend and borrow cryptocurrencies. It generates revenue through interest rate spreads and various fees, with revenue allocation determined by reserve factors set per asset market.
Supported Networks: Multiple EVM-compatible networks where Aave has deployed lending pools
Reserve Factor Model: Each asset market has a specific reserve factor (for example 20%) that determines the portion of interest that goes to the protocol treasury versus liquidity providers.
Data Sources:
- The Graph: Aave subgraphs for lending events, reserve data, and interest calculations
- RPC Queries: Reserve factors and pool configurations via Viem public client calls
- Token Price API: Historical token prices via
fetchTokenPrices
utility for USD conversion - Block Data: Timestamps via
getBlockRange
utility for temporal filtering
Business Assumptions:
- Revenue is derived from reserve factor applied to liquidity provider income
- User's revenue contribution is proportional to their deposits within time window
- USD conversion uses token prices at the end of the calculation period
- Reserve factors are applied consistently across all supported markets
- Interest calculations account for compound interest and variable rate changes
Revenue Sources:
- Interest rate spreads between lending and borrowing rates
- Reserve factors applied to total protocol interest
- Liquidation fees and flash loan fees
- Protocol-specific fees (varies by network and governance decisions)
Calculation Method:
- Queries user's deposits across all supported networks
- Calculates user earnings and retrieves reserve factor data for each position
- Calculates protocol revenue portion using reserve factors applied to interest payments
- Applies temporal filtering to include only activity within specified time window
- Converts all amounts to USD using historical token prices at the end of the calculation period
- Aggregates revenue across all networks and asset markets
- Returns total protocol revenue attributable to user's activity
Parameters
params
Calculation parameters
address
string
User wallet address to calculate lending protocol 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 lending protocol revenue in USD generated by user's activity