Skip to content

Instantly share code, notes, and snippets.

@hanniabu
Last active June 6, 2025 14:02
Show Gist options
  • Select an option

  • Save hanniabu/930f443b521448675dd2d3a4ec80fa92 to your computer and use it in GitHub Desktop.

Select an option

Save hanniabu/930f443b521448675dd2d3a4ec80fa92 to your computer and use it in GitHub Desktop.

ETH Used on L1+L2

Category Amount
Staking 34,418,680 (28.5%)
DeFi 4,942,902 (4.1%)
CEX 9,348,559 (7.7%)
Other 415 (0.0%)
Liquid Staking 19,283,004
Exported 4,213,178 (3.5%)
Collateral Usage 39,361,582 (32.6%)
Supply 120,807,048

Exported = Locked in bridges

Source:

python script:

import requests
import os
import json


def get_eth_collateral():
  # frontend https://defillama.com/token-usage?token=ETH
  eth_usage_data = requests.get('https://api.llama.fi/tokenProtocols/ETH').json()
  validatorqueue_data = requests.get('https://raw.githubusercontent.com/etheralpha/validatorqueue-com/refs/heads/main/historical_data.json').json()
  eth_price = requests.get('https://api.etherscan.io/v2/api?chainid=1&module=stats&action=ethprice&apikey=J4Q6NZGFYDPWKKEYXQM4HJABBR11V6EGME').json()
  eth_price = int(float(eth_price['result']['ethusd']))
  eth_used = {
    'Staking': 0,
    'DeFi':0,
    'CEX': 0,
    'Other': 0,
    'Liquid Staking': 0, # excluded from staking + collateral usage
    'Exported': 0,
    'Collateral Usage': 0, # staking + defi
    'Supply': 0
  }

  # example response dict schema
  # {
    # "name":"Sky Lending",
    # "category":"CDP",
    # "amountUsd":{
    #    "WETH":2035126390.630317,
    #    "WSTETH":355628108.2335537,
    #    "ETH":249027.58033727747
    # }
  # },

  liquid_staking = ['Liquid Staking', 'Liquid Restaking', 'Restaking']
  cex = ['CEX']
  exported = ['Chain', 'Bridge'] # include eth + all derivates
  other = ['Payments', 'Governance Incentives', 'Gaming', 'AI Agents', 'Developer Tools', 'Charity Fundraising']
  # everything else is defi
  
  # tally ETH and WETH
    # ETH derivates ignored since it's double dipping
    # WETH included because it's not accounted for as an independent protocol
  for item in eth_usage_data:
    eth = 0
    if item['category'] in exported:
      for asset in item['amountUsd']:
        if 'ETH' in asset:
          eth += item['amountUsd'][asset] / eth_price
      eth_used['Exported'] += eth
    else:
      if 'ETH' in item['amountUsd']:
        eth += item['amountUsd']['ETH'] / eth_price
      if 'WETH' in item['amountUsd']:
        eth += item['amountUsd']['WETH'] / eth_price
      # categorize
      if item['category'] in liquid_staking:
        eth_used['Liquid Staking'] += eth
      elif item['category'] in cex:
        eth_used['CEX'] += eth
      elif item['category'] in other:
        eth_used['Other'] += eth
      else:
        eth_used['DeFi'] += eth

  # staked eth
  staked_amount = validatorqueue_data[-1]['staked_amount']
  supply = validatorqueue_data[-1]['supply']
  eth_used['Staking'] = staked_amount
  eth_used['Supply'] = supply
  eth_used['Collateral Usage'] = eth_used['Staking'] + eth_used['DeFi']

  for key in eth_used:
    eth_used[key] = round(eth_used[key])
  eth_used['Staking'] = f"{eth_used['Staking']} ({round(eth_used['Staking'] / supply * 1000) / 10}%)"
  eth_used['DeFi'] = f"{eth_used['DeFi']} ({round(eth_used['DeFi'] / supply * 1000) / 10}%)"
  eth_used['CEX'] = f"{eth_used['CEX']} ({round(eth_used['CEX'] / supply * 1000) / 10}%)"
  eth_used['Other'] = f"{eth_used['Other']} ({round(eth_used['Other'] / supply * 1000) / 10}%)"
  eth_used['Collateral Usage'] = f"{eth_used['Collateral Usage']} ({round(eth_used['Collateral Usage'] / supply * 1000) / 10}%)"
  print(json.dumps(eth_used, indent=4))



get_eth_collateral()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment