Divvi Protocol - KPI calculation functions / aave
Functions
calculateKpi()
- 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
- 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
- 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)
- 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 parametersaddress
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
Suggest changes to this pageLast updated: Aug 6, 2025, 3:51 PM