All projects

Watcher AI

Autonomous AI agent that detects cross-chain cascade risks and runs protective mitigations via CRE + CCIP simulation on Tenderly Virtual TestNets.

Risk & Compliance CRE & AI Tenderly

What it is

WatcherAI is an autonomous risk intelligence system for DeFi. It monitors lending market utilization, reserve backing ratios, and liquidity velocity across multiple blockchains simultaneously, computes a cross-chain "cascade score" that measures how correlated the stress is,  and — when the score crosses policy thresholds — automatically runs escalating protective actions on-chain and broadcasts cross-chain alerts via Chainlink CCIP  so protocols on other chains can protect themselves too.
The system has two halves that work together: a Chainlink CRE workflow (compiled to WASM, designed to run on a DON) that reads live mainnet data and produces a risk decision, and a LangGraph AI agent (6-node directed acyclic graph with Gemini LLM reasoning) that takes that decision and orchestrates on-chain execution across 3 Tenderly Virtual TestNets.

What problem it solves
DeFi protocols today are monitored in isolation — one chain, one threshold. But systemic stress doesn't work that way. When liquidity gets squeezed, it tends to happen across multiple venues and chains at the same time, because the same capital, the same users, and the same strategies span multiple chains. A monitor that only watches Ethereum misses the fact that Arbitrum is also under pressure at the exact same moment — and that correlation is the real danger signal.
Watcher-AI solves this by computing a cascade score from correlated cross-chain stress signals, acting before any single threshold is breached, and propagating the signal cross-chain via CCIP so protocols on other chains can gate their own exposure. It gives DeFi protocols an autonomous, trustless, cross-chain early warning system with deterministic policy enforcement, on-chain auditability, and AI-powered explainability.

How it works
Every cycle, the CRE workflow runs a 10-step pipeline:

  1. Loads  risk  policy t hresholds from  CRE's confidential  secret store via runtime.getSecret().  The thresholds are never in source code.  The raw policy is hashed with keccak256 and bound to every decision for auditability.
  2. Resolves the Ethereum mainnet network via getNetwork() and instantiates an EVMClient.
  3. Reads the live Chainlink ETH/USD price feed on mainnet via EVMClient.callContract() at LAST_FINALIZED_BLOCK_NUMBER (MEV-resistant).
  4. Reads Lido stETH state — two on-chain calls (getTotalPooledEther and getTotalShares) — and computes the stETH-to-ETH deviation in basis points. This measures reserve backing health.
  5. Reads Aave V3 WETH reserve data on Ethereum mainnet (getReserveData) and computes utilization (total debt / total supply).
  6. Loops over additional chains (Arbitrum One) and reads the same Aave V3 data there. This is the cross-chain part — we compare utilization across venues.
  7. Fetches off- chain data with DON consensus:  DeFiLlama protocol TVL via HTTPClient + consensusMedianAggregation (each DON node fetches independently, they agree on the numeric median); CoinGecko ETH/USD via ConsensusAggregationByFields using median for the price number and identical for the source string.
  8. Feeds all inputs into the risk engine (computeRisk), which computes a cascade score from 0 to 100.  The cascade score is elevated when multiple chains show simultaneous rising stress — correlated liquidity pressure across chains is the cascade signature. It then applies the deterministic policy engine (applyPolicy) to map the risk level to a specific action (none, tighten_ltv, pause_market, or emergency_mode).
  9. Optionally writes a DON-signed on-chain attestation via  prepareReportRequest() + EVMClient.writeReport() to a SepoliaProof receiver contract — immutable audit trail.
  10. Posts the decision back to the agent via a callback (with runtime.getSecret() for auth token and runtime.now() for tamper-proof timestamp), using consensusIdenticalAggregation for the POST response.
    The LangGraph agent then takes the CRE decision and runs 6 nodes:
  • Monitor: runs the CRE workflow (via CLI simulate or gateway trigger) and parses the decision string + live metrics.
  • LLM: Gemini generates a natural-language narrative explaining why the risk level is what it is. If Gemini is unavailable, a deterministic fallback generates the explanation using the actual numbers. The LLM never decides the action — it only explains it.
  • Velocity: reads the previous cycle's metrics from a ReportStorage contract on the Tenderly VTN and computes how much utilization and stETH deviation changed since last cycle. If the delta exceeds the velocity threshold (e.g. 5% utilization change in one cycle), it escalates severity to CRITICAL.
  • Act: first runs a Tenderly Simulation API preflight (tenderly_simulateTransaction) to predict whether each mitigation tx will succeed or revert (and estimate gas). If the simulation predicts success, it executes real transactions on the ETH VTN: PolicyExecutor records the decision, MockMarketActions flips protocol state (pause, LTV, emergency), WatcherGuard sets the circuit breaker, ReportStorage stores the current metrics for next cycle's velocity check. If the cascade score is ≥ 70, it also calls CascadeAlertSender.broadcast() on the Sepolia VTN (CCIP ccipSend to Arbitrum), and then relays the message to CascadeInbox on the ARB VTN using Tenderly's unlocked-account feature (impersonating the CCIP router address).
  • Notify: fires a Discord webhook with the full assessment — decision, risk score, severity, cascade score, tx hashes, LLM narrative.
  • Proof: posts an immutable on-chain assessment record to the SepoliaProof contract — decision hash, action, level, utilization bps, stETH bps — creating a permanent audit trail.

How it Works

  • Chainlink CRE: 10-step WASM workflow (TypeScript) using 15+ CRE capabilities: CronCapability, HTTPCapability, EVMClient.callContract (Chainlink feed, Lido, Aave on ETH + Arbitrum), HTTPClient + consensusMedianAggregation (DeFiLlama) and ConsensusAggregationByFields (CoinGecko), runtime.getSecret() for policy, prepareReportRequest + writeReport() for on-chain attestation, runtime.now(), handler().
  • LangGraph: 6-node supervisor (monitor → llm → velocity → act → notify → proof); CRE is invoked as a tool by the monitor node.
  • Tenderly: 3 Virtual TestNets (ETH fork, Sepolia fork, Arbitrum Sepolia fork); 7 contracts (PolicyExecutor, MockMarketActions, WatcherGuard, ReportStorage, CascadeAlertSender, CascadeInbox, SepoliaProof); Tenderly Simulation API preflight before each mitigation tx; VTN relay by impersonating CCIP router for cross-chain demo.
  • CCIP: CascadeAlertSender (Sepolia) calls router.ccipSend(); CascadeInbox (Arbitrum Sepolia) implements ccipReceive() and exposes isCascadeActive().
  • Stack: Bun, viem, Gemini (with deterministic fallback).

Links

Created by

  • Aakash Mallik
  • Violina Doley