Analyzing On-Chain Data
Overview
Analyze DeFi protocol metrics, chain-level TVL, fee revenue, DEX volumes, yield opportunities, and stablecoin market caps using DeFiLlama as the primary data source. Designed for DeFi researchers, protocol analysts, and yield farmers who need programmatic access to on-chain analytics without writing custom subgraph queries.
Prerequisites
- Python 3.8+ with
requests library installed
- DeFiLlama API access (free, no key required for most endpoints)
- Optional: CoinGecko API key for supplementary token price data
onchain_analytics.py CLI script available in the plugin directory
datafetcher.py and metricscalculator.py modules for programmatic usage
Instructions
- Run
python onchain_analytics.py protocols to retrieve the top DeFi protocols ranked by total value locked (TVL).
- Filter protocol results by category using
--category lending, --category dex, or --category "liquid staking" to narrow the scope.
- Filter by chain with
--chain ethereum or --chain arbitrum to isolate chain-specific protocol data.
- Sort results by alternative metrics using
--sort marketshare or --sort tvlto_mcap to surface undervalued protocols.
- Run
python onchain_analytics.py chains to retrieve chain-level TVL rankings across all tracked networks.
- Run
python onchain_analytics.py fees --protocol aave to pull fee and revenue data for a specific protocol.
- Run
python onchain_analytics.py dex --chain ethereum to analyze DEX trading volumes filtered by chain.
- Run
python onchain_analytics.py yields --min-tvl 5000000 --chain ethereum to identify yield opportunities above a minimum TVL threshold.
- Run
python onchain_analytics.py trends --threshold 5 to detect protocols with significant TVL changes (threshold is percentage).
- Export results in JSON or CSV format using
--format json or --format csv and redirect to file for downstream analysis.
See ${CLAUDESKILLDIR}/references/implementation.md for the full four-step implementation workflow.
Output
- Protocol rankings table with name, TVL, market share percentage, and TVL-to-market-cap ratio
- Chain TVL rankings showing aggregate locked value per network
- Fee and revenue reports per protocol with daily/weekly/monthly breakdowns
- DEX volume tables with per-chain and per-DEX breakdowns
- Yield opportunity listings filtered by minimum TVL and chain, including APY and pool details
- Trending protocol alerts showing TVL percentage changes above the configured threshold
- Stablecoin