Total Value Locked (TVL)
Total Value Locked (TVL) represents the total amount of assets locked within decentralized finance (DeFi) protocols on the Hedera network. This metric provides insights into liquidity, ecosystem adoption, and capital efficiency within Hedera’s DeFi landscape.
To access this Hedera network statistic (and others) via Hgraph's GraphQL & REST APIs, get started here.
GraphQL API Endpoint: network_tvl
Methodology
-
Data Source
- TVL data is retrieved from the DeFiLlama API.
-
HTTP Retrieval & JSON Parsing
- The procedure calls
http_get('https://api.llama.fi/v2/historicalChainTvl/Hedera')
and parses the JSON to extractdate
(in seconds) andtvl
.
- The procedure calls
-
Timestamp Conversion & Daily Range Calculation
- Each
date_sec
is converted withto_timestamp(date_sec)
, and a daily time range is computed using theint8range
function.
- Each
-
Insertion into Metrics Table
- Each record is inserted into the table. If a matching record exists, the TVL value is updated.
-
Final Output
- Each row represents a daily TVL measurement with its corresponding time range.
Use Case Example
Monitoring TVL helps gauge overall network health by reflecting the amount of capital engaged in Hedera's DeFi ecosystem. For example, a rising TVL indicates increasing liquidity and user confidence.
GraphQL API Examples
Test out these queries using our developer playground.
Fetch most recent Hedera TVL
query GetLatestTVL {
ecosystem_metric(
where: {name: {_eq: "network_tvl"}}
order_by: {end_date: desc_nulls_last}
limit: 1
) {
total
end_date
}
}
Fetch daily TVL (timeseries)
query DailyTVL {
ecosystem_metric(
order_by: {end_date: desc_nulls_last}
limit: 8760
where: {name: {_eq: "network_tvl"}, period: {_eq: "day"}}
) {
total
end_date
}
}
7 day percentage change
query TVL7DayChange {
current: ecosystem_metric(
where: {name: {_eq: "network_tvl"}, period: {_eq: "day"}}
order_by: {start_date: desc}
limit: 1
offset: 0
) {
total
}
previous: ecosystem_metric(
where: {name: {_eq: "network_tvl"}, period: {_eq: "day"}}
order_by: {start_date: desc}
limit: 1
offset: 7
) {
total
}
}
Available Time Periods
day
TVL is aggregated from DeFi protocols and updates daily. If values seem incorrect, check the most recent transactions affecting locked assets.
SQL Implementation
Below is a link to the Hedera Stats GitHub repository. The repo contains the SQL function that calculates the Total Value Locked statistic outlined in this methodology.
SQL Function: ecosystem.dashboard_network_tvl
Dependencies
- Hedera mirror node
- Internet access (to fetch data via
http_get
from DeFiLlama)