Back to Tools
TEMPLATE8 min read2025-06-23

Blockchain Data Analytics Templates — Dune Dashboards and On-Chain KPIs

Every production blockchain protocol needs on-chain analytics for transparency and decision-making. Here are the SQL query templates for Dune Analytics.

Enterprise Ready

Built for production environments.

Fast Results

Save hours of manual planning.

Professional

Trusted by blockchain teams.

Blockchain Tool

Interactive planning, estimation, calculations and enterprise-grade blockchain utilities.

AI

Assisted

24/7

Available

Tool Assistance

Ready to Build Your Analytics Dashboard?

Get expert guidance on on-chain analytics and Dune dashboard setup.

Tool Workspace

Use, understand, and apply the results

Tool Overview

Every production blockchain protocol needs on-chain analytics for transparency and decision-making. Here are the SQL query templates for Dune Analytics.

Key Result

Dune Analytics SQL query templates for blockchain protocols: Protocol TVL Dashboard (daily TVL tracking with USDC pricing), Unique Users Query (weekly depositor count and cumulative users), Protocol Revenue Query (daily fee revenue, annualized run rate). Shareable Dune Dashboard template with 6 panels: TVL (line chart), Daily Volume (bar chart), Unique Depositors (counter + line), Protocol Revenue (bar + cumulative), Top Depositors Table (whale concentration), Oracle Health (price feed staleness and divergence).

Protocol TVL Dashboard Query (Dune Analytics)

Example
-- Dune SQL: Track protocol TVL over time
-- Replace contract_address with your vault/pool address

WITH daily_balances AS (
    SELECT 
        DATE_TRUNC('day', block_time) AS day,
        SUM(CASE WHEN to = 0xYOUR_CONTRACT_ADDRESS 
            THEN value ELSE -value END) 
            / 1e6 AS usdc_delta  -- USDC has 6 decimals
    FROM erc20_ethereum.evt_Transfer
    WHERE (to = 0xYOUR_CONTRACT_ADDRESS 
           OR "from" = 0xYOUR_CONTRACT_ADDRESS)
      AND contract_address = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48  -- USDC
      AND block_time >= DATE '2024-01-01'
    GROUP BY 1
),
cumulative AS (
    SELECT 
        day,
        SUM(usdc_delta) OVER (ORDER BY day) AS tvl_usdc
    FROM daily_balances
)
SELECT 
    day,
    tvl_usdc,
    tvl_usdc * eth_price.price AS tvl_usd
FROM cumulative
LEFT JOIN prices.usd eth_price 
    ON eth_price.symbol = 'USDC'
    AND eth_price.minute = DATE_TRUNC('minute', cumulative.day)
ORDER BY day DESC

Unique Users Query

Example
-- Count unique depositors per week
SELECT 
    DATE_TRUNC('week', block_time) AS week,
    COUNT(DISTINCT "from") AS new_depositors,
    COUNT(DISTINCT "from") OVER (ORDER BY DATE_TRUNC('week', block_time)) AS cumulative_users
FROM erc20_ethereum.evt_Transfer
WHERE to = 0xYOUR_CONTRACT_ADDRESS
  AND contract_address = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
  AND block_time >= DATE '2024-01-01'
GROUP BY 1
ORDER BY 1 DESC

Protocol Revenue Query

Example
-- Track fee revenue collected by protocol treasury
WITH fee_events AS (
    SELECT 
        DATE_TRUNC('day', block_time) AS day,
        SUM(CAST(data AS DOUBLE) / 1e6) AS daily_fees_usdc
    FROM ethereum.logs
    WHERE contract_address = 0xYOUR_CONTRACT
      AND topic0 = 0xFEE_COLLECTED_EVENT_SIGNATURE
      AND block_time >= DATE '2024-01-01'
    GROUP BY 1
)
SELECT 
    day,
    daily_fees_usdc,
    SUM(daily_fees_usdc) OVER (ORDER BY day) AS cumulative_fees_usdc,
    daily_fees_usdc * 365 AS annualized_revenue_rate
FROM fee_events
ORDER BY day DESC

Shareable Dune Dashboard Template

PROTOCOL NAME — Analytics Dashboard

01

PANEL 1: TVL (Line Chart) — X-axis: Date | Y-axis: TVL in USD

02

PANEL 2: Daily Volume (Bar Chart) — X-axis: Date | Y-axis: Volume USD

03

PANEL 3: Unique Depositors (Counter + Line) — Total unique depositors + New depositors per week

04

PANEL 4: Protocol Revenue (Bar + Cumulative Line) — Daily fee revenue + Cumulative + Annualized run rate

05

PANEL 5: Top Depositors Table — Address | Balance | % of TVL | First Deposit Date

06

PANEL 6: Oracle Health — Price feed last updated (must be < 1 hour ago), Divergence between Chainlink and TWAP (must be < 1%)

Tool Assistance

Ready to Build Your Analytics Dashboard?

Get expert guidance on on-chain analytics and Dune dashboard setup.