Skip to content

citojitu/DefiPulseAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DeFiPulseAI

Multi-Agent DeFi Analytics Pipeline β€” 7 specialized agents, on-chain data ingestion across 9 chains, and MiMo-powered reasoning that turns raw transactions into analyst-grade reports.

Python 3.10+ License: MIT Tests Powered by


What is this?

DeFiPulseAI is a production-grade multi-agent orchestration system that turns raw on-chain data into actionable DeFi intelligence. It uses MiMo (Xiaomi) as the primary reasoning engine and Claude as a cross-check backend, with the Hermes Agent framework orchestrating 7 specialized agents through configurable DAGs.

Five features, one pipeline

Feature What it does Example output
πŸ‹ Smart Money Tracker Identify alpha wallets, score their PnL, classify behavior "0xabc… is a swing_trader (conf 0.87), alpha 0.74"
🚨 Liquidation Risk Monitor Scan Aave/Compound positions, flag HF < 1.2 "0xdef…: HF 1.05 β€” URGENT, ETA to liq ~12 min"
πŸ” Wallet Forensics Deep multi-chain profile + LLM narrative "Active 18 months across 4 chains; preferred protocol: Uniswap; risk: LOW"
πŸ”“ Token Unlock Calendar Upcoming unlocks + LLM-derived dump-risk scores "ARB unlock in 5d: 2.3% supply, impact 78/100 β€” high risk"
πŸ’° Yield Scanner Cross-protocol APY compare + LP recommendations "Pendle PT-USDe 14d: 22% APY, strong_yes β€” TVL stable, IL=0"

Architecture

graph LR
  classDef agent fill:#4f46e5,stroke:#fff,color:#fff;
  classDef llm fill:#dc2626,stroke:#fff,color:#fff;
  classDef io fill:#059669,stroke:#fff,color:#fff;

  A[IngestionAgent]:::agent --> B[TransformationAgent]:::agent
  B --> C[EnrichmentAgent]:::agent
  C --> D[AnalyticsAgent]:::agent
  D --> E[AlertAgent]:::agent
  D --> F[ReportingAgent]:::agent
  G[SchedulerAgent]:::agent -.-> A

  C -.uses.-> M[MiMo]:::llm
  C -.cross-check.-> CL[Claude]:::llm

  A -.fetches.-> AL[Alchemy / Helius / Etherscan]:::io
  A -.fetches.-> DL[DefiLlama / CoinGecko / TheGraph]:::io
  E -.sends.-> TG[Telegram / Discord / Slack]:::io
  F -.writes.-> RP[Markdown / JSON / PDF]:::io
Loading

The 7 agents

  1. IngestionAgent (~450 LOC) β€” pulls data from Alchemy, Helius, Etherscan, DefiLlama, CoinGecko, The Graph
  2. TransformationAgent (~500 LOC) β€” normalizes/decodes/dedupes; chain-aware tx classification
  3. EnrichmentAgent (~400 LOC) β€” LLM-driven tagging, narrative generation, dump-risk scoring (uses MiMo + Claude)
  4. AnalyticsAgent (~450 LOC) β€” Gini, HHI, impermanent loss, health factor, alpha scoring
  5. AlertAgent (~370 LOC) β€” pattern matching β†’ Telegram / Discord / Slack webhook fan-out
  6. SchedulerAgent (~250 LOC) β€” recurring poll loops, DAG suggestions per feature
  7. ReportingAgent (~280 LOC) β€” Markdown render + structured table + metric extraction

Total: 3,400+ LOC of agent code, 6 adapters for upstream data, 5 feature wrappers, and 170+ unit tests.


Quickstart

git clone https://github.com/<you>/DeFiPulseAI
cd DeFiPulseAI
pip install -e ".[dev]"
cp .env.example .env  # fill in keys

Python API

import asyncio
from defipulse import load_config
from defipulse.features import WalletForensics, LiquidationRiskMonitor

async def main():
    config = load_config()

    # 1. Deep forensic profile of a single wallet
    async with await WalletForensics.from_config(config) as wf:
        report = await wf.run(
            "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
            chains=["ethereum", "base"],
        )
        print(report.summary)

    # 2. Liquidation risk poll across a set of borrowers
    async with await LiquidationRiskMonitor.from_config(config) as lr:
        at_risk = await lr.at_risk(
            ["0xabc...", "0xdef..."], threshold=1.2,
        )
        for row in at_risk:
            print(f"⚠️ {row['wallet']}: HF {row['health_factor']:.2f}")

asyncio.run(main())

CLI

# wallet forensics
defipulse forensics 0xabc... --chains ethereum,base

# liquidation scan
defipulse liquidation 0xabc... 0xdef...

# top alpha wallets
defipulse smart-money --chains ethereum --top 10

# yield opportunities
defipulse yields --chains ethereum --min-tvl 5000000

# upcoming token unlocks
defipulse unlocks --days 30

Configuration

All settings flow through .env β†’ defipulse.core.config.load_config():

# LLM providers
MIMO_API_KEY=...
MIMO_BASE_URL=https://9router.example.com/v1      # or SwiftRouter, or direct
MIMO_MODEL=mimo-v2-flash

ANTHROPIC_API_KEY=...                              # cross-check backend
CLAUDE_MODEL=claude-sonnet-4-6

# Data providers
ALCHEMY_API_KEY=...
HELIUS_API_KEY=...
ETHERSCAN_API_KEY=...
COINGECKO_API_KEY=...
THE_GRAPH_API_KEY=...

# Notifications (any subset)
TELEGRAM_BOT_TOKEN=...
TELEGRAM_CHAT_ID=...
DISCORD_WEBHOOK_URL=...
SLACK_WEBHOOK_URL=...

See .env.example for the full list.


Supported chains

Chain EVM? Native Adapter
Ethereum βœ… ETH Alchemy + Etherscan
Base βœ… ETH Alchemy + Etherscan
Arbitrum βœ… ETH Alchemy + Etherscan
Optimism βœ… ETH Alchemy + Etherscan
Polygon βœ… POL Alchemy + Etherscan
BSC βœ… BNB Etherscan
Avalanche βœ… AVAX Etherscan
Solana ❌ SOL Helius
Hyperliquid ❌ USDC (planned)

How the LLM is used

The EnrichmentAgent is where the LLM budget is spent. Each call has a narrow, structured contract:

Task Prompt β†’ Response LLM
Wallet classification "Given activity X, tag this wallet" β†’ {tag, confidence, reason} MiMo
Forensic narrative Multi-chain summary β†’ 2-paragraph profile MiMo
Forensic cross-check First-draft + raw evidence β†’ "missed any flags?" Claude
Unlock dump-risk score event metadata β†’ {impact_score: 0-100, rationale} MiMo
Yield review pool metadata β†’ {recommendation, rationale} MiMo

Why this matters: every LLM call has a tight JSON contract verified by complete_json(), so we never burn tokens on un-parseable output.


Testing

pytest tests/ -v          # all 170+ tests
pytest tests/ --cov       # with coverage
pytest -k "analytics"     # filter

Every external API is mocked via httpx.MockTransport β€” tests run offline and finish in under 5 seconds.


Project structure

DeFiPulseAI/
β”œβ”€β”€ src/defipulse/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ cli.py
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ config.py
β”‚   β”‚   β”œβ”€β”€ types.py
β”‚   β”‚   β”œβ”€β”€ mimo_client.py
β”‚   β”‚   β”œβ”€β”€ claude_client.py
β”‚   β”‚   β”œβ”€β”€ hermes_runtime.py
β”‚   β”‚   └── pipeline.py
β”‚   β”œβ”€β”€ adapters/
β”‚   β”‚   β”œβ”€β”€ base.py
β”‚   β”‚   β”œβ”€β”€ alchemy.py
β”‚   β”‚   β”œβ”€β”€ helius.py
β”‚   β”‚   β”œβ”€β”€ etherscan.py
β”‚   β”‚   β”œβ”€β”€ coingecko.py
β”‚   β”‚   β”œβ”€β”€ defillama.py
β”‚   β”‚   └── thegraph.py
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   β”œβ”€β”€ ingestion.py
β”‚   β”‚   β”œβ”€β”€ transformation.py
β”‚   β”‚   β”œβ”€β”€ enrichment.py
β”‚   β”‚   β”œβ”€β”€ analytics.py
β”‚   β”‚   β”œβ”€β”€ alert.py
β”‚   β”‚   β”œβ”€β”€ scheduler.py
β”‚   β”‚   └── reporting.py
β”‚   β”œβ”€β”€ features/
β”‚   β”‚   β”œβ”€β”€ smart_money.py
β”‚   β”‚   β”œβ”€β”€ liquidation_risk.py
β”‚   β”‚   β”œβ”€β”€ wallet_forensics.py
β”‚   β”‚   β”œβ”€β”€ token_unlock.py
β”‚   β”‚   └── yield_scanner.py
β”‚   └── utils/
β”‚       β”œβ”€β”€ cache.py
β”‚       β”œβ”€β”€ logger.py
β”‚       β”œβ”€β”€ retry.py
β”‚       └── rate_limit.py
β”œβ”€β”€ tests/                         # 170+ tests
β”œβ”€β”€ examples/                      # runnable scripts
β”œβ”€β”€ demo/                          # Next.js Vercel demo (web UI)
└── README.md

Roadmap

  • 7-agent core pipeline
  • 5 feature modules
  • CLI + Python API
  • 170+ unit tests
  • Vercel demo site
  • WebSocket support for real-time alerts
  • More chains: Sei, Sui, TON, Aptos
  • PDF report renderer
  • Backtest engine for yield strategies
  • On-chain identity resolution (ENS + Lens + Farcaster + SNS)
  • Governance proposal summarizer (DAO module)

License

MIT β€” see LICENSE.


Acknowledgments

  • Hermes Agent framework (in-tree implementation)
  • Xiaomi MiMo
  • Anthropic Claude
  • DefiLlama, Alchemy, Helius, Etherscan, CoinGecko, The Graph

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages