Divvi Protocol - KPI calculation functions / beefy
Functions
calculateKpi()
- Beefy API: Vault configurations, TVL data, and strategy metadata from
api.beefy.finance
- RPC Queries: User deposit/withdrawal events via Viem public client calls to vault contracts
- Token Price API: Historical token prices via
fetchTokenPrices
utility for USD conversion - Block Data: Timestamps via
getBlockRange
utility for temporal filtering
- Revenue attribution is proportional to user’s share of vault deposits within time window
- USD conversion uses token prices at time of each transaction
- Fee distribution is immediate and based on real-time vault performance
- Retrieves all configurations for vaults with which user has had transactions from Beefy API
- Filters vaults by supported networks and active status
- For each vault, queries user’s deposit/withdrawal events within time window
- For each vault, queries historical Fee events within time window
- Calculates user’s proportional share of vault deposits at the time of each Fee event
- Determines user contribution to management fee based off their proportional share of vault TVL
- Converts to USD using historical token prices at transaction timestamps
- Aggregates user fee contribution across all vaults and networks to get total user fee contribution
Parameters
params
Calculation parametersaddress
string
User wallet address to calculate vault management fees 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 vault management fee revenue in USD
Suggest changes to this pageLast updated: Aug 6, 2025, 3:51 PM