X Layer Β· chainId 196 ● Checking RPC... 7 MCP Tools FastAPI + Vercel

Real-time DeFi anomaly detection on X Layer

An autonomous AI agent that monitors X Layer DeFi protocols (Uniswap, Aave), detects price manipulation, liquidity drains, and unusual trading activity, and generates severity-classified alerts with on-chain risk scores.

Architecture
AI AgentOrchestrator
β†’
scan_poolFetch reserves
β†’
detect_anomalyHeuristics
β†’
risk_score0-100 scale
β†’
generate_alertClassified
Agent calls tools in sequence: observe β†’ detect β†’ assess β†’ alert
X Layer RPCReal on-chain data
↔
SQLite /tmpAudit trail
↔
VercelServerless
β€”
Pool Scans
β€”
Anomalies
β€”
Alerts
β€”
Avg Risk
β€”
X Layer Block
MCP-Style Tools (7)

Each tool follows the Model Context Protocol pattern with name, description, and JSON Schema input. Click to test live.

πŸ“‘ Live API Output
Ready. Click "Run Autonomous Agent Demo" or any tool above to see live API responses.
What's Real vs Mocked

βœ… Real (Live On-Chain)

  • X Layer RPC calls (eth_chainId, eth_blockNumber, eth_gasPrice)
  • eth_call against pool contracts (getReserves, totalSupply)
  • eth_getBalance for wallet health checks
  • Live block number and gas price from X Layer mainnet
  • SQLite persistence of scans, anomalies, alerts (Vercel /tmp)
  • Anomaly detection heuristics (reserve imbalance, liquidity drain)
  • Composite risk scoring (0-100) with severity classification
  • Agent orchestration (tool-chaining: scanβ†’detectβ†’scoreβ†’alert)

⚠️ Mocked / Simulated

  • Pool reserve values fall back to deterministic simulation if RPC eth_call returns zeros (demo pool addresses)
  • Aave V3 health factor is derived from address hash (real Aave integration requires Pool.getUserAccountData which needs a funded position)
  • Baseline reserve ratios are hardcoded (production would use a time-series DB)
  • "Unusual activity" heuristic uses block-number parity as a proxy for tx volume (production would use mempool/trace data)
  • No LLM API key required β€” the agent orchestration is deterministic (reproducible in serverless)