liskV0
Divvi Protocol - KPI calculation functions
Divvi Protocol - KPI calculation functions / liskV0
liskV0
Functions
calculateKpi()
function calculateKpi(params): Promise<KpiResult<string>>
Defined in: liskV0/index.ts:48
Calculates gas usage for Lisk infrastructure activity.
KPI Unit: Gas units (computational units consumed)
Business Purpose: Measures the computational resources (gas) consumed by a specific user's transactions on Lisk network. This metric quantifies the infrastructure utilization generated by user interactions and supports gas usage analysis for network sustainability and resource allocation.
Protocol Context: Lisk tracks gas consumption to measure network utilization and infrastructure impact. Gas usage serves as a proxy for computational resource consumption and network contribution, supporting infrastructure funding decisions and network optimization.
Network: Lisk Mainnet
Data Sources:
- HyperSync: Transaction and gas usage data from Lisk network via HyperSync client
- Block Data: Timestamps via
getBlockRange
utility for temporal filtering
Business Assumptions:
- Gas usage accurately represents computational resource consumption
- User's infrastructure impact is proportional to total gas consumed within time window
- All transaction types contribute equally to network utilization regardless of purpose
- Gas measurements include both successful and failed transaction attempts
- Infrastructure funding allocation can be based on proportional gas contribution
Gas Types: Transaction execution gas, contract interaction gas, token transfer gas, and smart contract deployment gas
Calculation Method:
- Queries all transactions initiated by user wallet within the specified time window
- Retrieves transaction receipts to extract gas used for each transaction
- Filters transactions by block timestamp to ensure they fall within the time range
- Aggregates total gas consumed across all user transactions
- Returns total gas usage representing user's infrastructure utilization
Parameters
params
Calculation parameters
address
string
User wallet address to calculate gas usage for
endTimestampExclusive
Date
End of time window for gas calculation (exclusive)
redis?
RedisClientType
startTimestamp
Date
Start of time window for gas calculation (inclusive)
Returns
Promise
<KpiResult
<string
>>
Promise resolving to total gas units consumed by user's transactions