DEV Community

Atlas Whoff
Atlas Whoff

Posted on

AI-Powered DeFi Analysis: Using Claude with Live On-Chain Data for Protocol Research

DeFi protocol analysis requires on-chain data, smart contract understanding, and real-time market context. AI models can do the reasoning — but only if they have access to the actual data. Here's how to build a DeFi research tool with Claude and live blockchain feeds.

The Data Problem in DeFi Analysis

Most AI-powered DeFi tools fail because the model is reasoning about stale or fabricated data:

  • "Aave has around $10B TVL" (was true 18 months ago)
  • "The current ETH staking yield is approximately 4%" (approximate is worthless for trading)
  • "Uniswap V3 is the dominant DEX" (market share shifts constantly)

Real DeFi analysis requires live TVL, current APYs, on-chain transaction flows, and wallet movements.

Architecture: Claude + DeFi Data MCP

// MCP tools exposed to Claude
const defiTools = [
  {
    name: 'get_protocol_tvl',
    description: 'Get current TVL for any DeFi protocol',
    inputSchema: {
      type: 'object',
      properties: {
        protocol: { type: 'string', description: 'Protocol slug e.g. aave-v3, uniswap-v3, compound-v3' },
        chain: { type: 'string', description: 'Chain filter e.g. ethereum, arbitrum, all' }
      },
      required: ['protocol']
    }
  },
  {
    name: 'get_yield_opportunities',
    description: 'Find yield opportunities above a minimum APY',
    inputSchema: {
      type: 'object',
      properties: {
        minApy: { type: 'number', description: 'Minimum APY percentage' },
        token: { type: 'string', description: 'Token to deposit e.g. ETH, USDC' },
        riskLevel: { type: 'string', enum: ['low', 'medium', 'high'] }
      }
    }
  },
  {
    name: 'compare_protocols',
    description: 'Compare TVL, APY, and risk metrics across multiple protocols',
    inputSchema: {
      type: 'object',
      properties: {
        protocols: { type: 'array', items: { type: 'string' } },
        metrics: { type: 'array', items: { type: 'string' } }
      },
      required: ['protocols']
    }
  }
]
Enter fullscreen mode Exit fullscreen mode

Sample Analysis Sessions

Yield optimization:

User: I have 50 ETH. Where should I deploy it for yield?

Claude [fetches ETH yield opportunities]:
  - Lido staking: 3.8% APY, 32B TVL, low risk
  - Rocket Pool: 4.1% APY, 3.2B TVL, low-medium risk  
  - Aave ETH supply: 2.1% APY, liquid, ultra-low risk
  - Pendle PT-ETH: 5.2% APY, fixed until Dec 2026, medium risk

  Analysis: For 50 ETH, I'd split: 60% Lido (liquid staking, battle-tested),
  30% Rocket Pool (better decentralization, slightly higher yield),
  10% Pendle fixed rate (lock in 5.2% guaranteed).
  Total blended yield: ~4.1% = ~2.05 ETH/year at current prices.
Enter fullscreen mode Exit fullscreen mode

Protocol health check:

User: Is Curve Finance still safe to use?

Claude [fetches Curve TVL, security data, recent incidents]:
  Current TVL: $1.8B (down from peak $25B in 2022)
  Recent incidents: Vyper vulnerability (July 2023, $70M lost)
  Current audits: Multiple ongoing, post-exploit security improvements
  Oracle manipulation risk: Low on main pools, higher on factory pools

  Assessment: Main pools (3pool, TriCrypto) remain safe. Avoid newer
  factory pools without thorough auditing. TVL decline reflects
  market conditions, not security concerns on core infrastructure.
Enter fullscreen mode Exit fullscreen mode

On-Chain Whale Tracking

// Watch large DeFi movements
const largeDeposits = await getRecentDeposits({
  protocol: 'aave-v3',
  chain: 'ethereum',
  minAmount: 1_000_000, // $1M+
  timeWindow: '24h',
})

// Ask Claude to interpret the signal
const analysis = await claude.complete(`
  These large deposits into Aave V3 occurred in the last 24h:
  ${JSON.stringify(largeDeposits)}

  What does this suggest about institutional positioning?
  Are there any notable wallet addresses or patterns?
`)
Enter fullscreen mode Exit fullscreen mode

Risk Assessment Framework

Claude can evaluate DeFi risk with real data:

  • Smart contract risk: Audit history, time-since-deploy, TVL trend
  • Oracle risk: Price feed sources, manipulation history
  • Liquidity risk: Withdrawal queue depth, redemption mechanisms
  • Systemic risk: Protocol dependencies, contagion vectors

The Crypto Data MCP at whoffagents.com provides the live DeFi data layer for Claude — TVL, yields, wallet analysis, and cross-protocol comparisons. Free tier available, Pro at $19/mo.

Top comments (0)