beefy
Divvi Protocol - KPI calculation functions
Divvi Protocol - KPI calculation functions / beefy
beefy
Functions
calculateKpi()
function calculateKpi(params): Promise<KpiResult<string>>
Defined in: beefy/index.ts:214
Calculates vault management fee revenue generated for Beefy Finance protocol.
KPI Unit: USD (United States Dollars)
Business Purpose: Measures the vault management fee revenue attributable to a specific user's deposit activity in Beefy vaults over a given time span. This metric quantifies the economic value generated by user participation in Beefy's yield optimization strategies and supports fee distribution calculations.
Protocol Context: Beefy Finance is a decentralized yield optimization platform that automatically compounds yields for users across multiple DeFi protocols. It charges a performance fee for managing user deposits and generating optimized returns.
Supported Networks: Multiple EVM-compatible networks where Beefy has deployed vault strategies
Data Sources:
- 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
Business Assumptions:
- 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
Calculation Method:
- 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 parameters
address
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