Guardian
AI-powered DeFi guardian that predicts liquidations and rescues positions across chains using ACE privately
What it is
Guardian is an autonomous DeFi protection agent built on Chainlink CRE that predicts liquidation risk hours before it happens and automatically rescues positions across chains.
Problem:
$3.4 billion was liquidated in DeFi last year.
Every existing protection tool (DeFi Saver, Instadapp, Gelato) is reactive they trigger after your health factor is already critical.
By then, gas is spiking, everyone's racing to exit, and you're paying a premium to survive.
Guardian is predictive. Every 30 seconds, a CRE workflow runs a 9-step pipeline:
- Protocol Monitoring : Reads Aave V3 health factors and Synthetix Perps margin ratios using Chainlink Data Feeds
2. Market Intelligence Signals : Makes Confidential HTTP calls to Nansen (whale flow intelligence), DeFiLlama (TVL anomalies), CoinGecko (price momentum), and Fear & Greed Index
3. AI Risk Processing: Sends all signals to Gemini AI via CRE Secrets for encrypted API key storage
4. Dual Risk Engine : Computes a dual-engine risk score: 60% deterministic rules + 40% AI prediction, so even if the AI hallucinates, the rules-based engine provides a floor
5. On Chain Risk Reporting: Writes risk assessments on-chain to the Guardian contract
6. Rescue Detection: Detects cross-chain rescue opportunities when health factor drops below minimum threshold
7. Cross Chain Collateral Rescue: Triggers CCIP cross-chain collateral teleportation from a reserve vault to rescue the at-risk position
8. Sends real-time Telegram alerts via Confidential HTTP (bot token invisible to node operators)
9. MEV Resistant Rescue Execution (ACE Pipeline) Executes a 5-step ACE privacy pipeline for MEV-proof rescue: balance verification, stealth address generation, private transfer with hidden sender, time-locked withdrawal ticket with deadline safety guard, and compliance-ready audit trail.
- Private Transfer TX: 019ccee3-787e-7e71-9b6a-e0e0114ff5ab
- Withdrawal ID: 019ccee3-7950-782c-8bf2-7bd92fbc37c3
- Withdrawal Ticket Hash:
0x2778dd11a02674bee58b29470dbea2fb260a621cdbd549b314c01fe1486e076b
- ACE Vault Contract: https://sepolia.etherscan.io/address/0xE588a6c73933BFD66Af9b4A07d48bcE59c0D2d13
- Stealth Address Generated: 0x834B1372988cbA39Fa99d22955D6767F09e230d
Guardian monitors 5 positions across 2 chains (Base Sepolia + Ethereum Sepolia) covering 3 protocols (Aave V3, Morpho Blue, Synthetix Perps).
It uses 6 Chainlink services in a single workflow: CRE orchestration, Confidential HTTP, CRE Secrets, Data Feeds, CCIP, and ACE.
How it Works
How is it built?:
Guardian is implemented as a single CRE TypeScript workflow that orchestrates six Chainlink services.
Chainlink Services Used:
- CRE Workflow : Main orchestration layer running on a 5 minute cron trigger on the Decentralized Oracle Network (DON).
- Chainlink Data Feeds : Reads ETH/USD and BTC/USD prices to calculate position health factors and margin risk.
- Confidential HTTP : Makes secure API calls to external intelligence sources including: Nansen , DeFiLlama , CoinGecko , Fear and Greed Index , Telegram Requests and responses remain hidden from node operators.
- CRE Secrets : Provides encrypted storage for sensitive credentials including: Gemini AI API key , Nansen API key ,Telegram bot token , Guardian private key
- CCIP (Cross Chain Interoperability Protocol) : Enables cross chain collateral rescue from an Ethereum Sepolia reserve vault to positions on Base Sepolia.
- ACE (Autonomous Confidential Execution) : Implements a 5 step privacy pipeline using EIP 712 signed authorization to perform MEV resistant rescue transfers.
Relevant Links:
ACE Vault (Ethereum Sepolia):
https://sepolia.etherscan.io/address/0xE588a6c73933BFD66Af9b4A07d48bcE59c0D2d13
Guardian Contract (Base Sepolia):
https://sepolia.basescan.org/address/0x018dd6E5BDe618C5169c7A21dfDE2a5a79aFa73d
Private Transfer Transaction ID (ACE):
019ccee3-787e-7e71-9b6a-e0e0114ff5ab , Off chain transaction verified via audit trail API.
Smart Contracts:
Guardian.sol
Handles risk registry, rescue trigger logic, and portfolio correlation tracking.
GuardianVault.sol
Acts as the cross chain collateral reserve and integrates with CCIP for rescue transfers.
The contracts are tested using Foundry with 45 passing tests.
Frontend:
A Next.js dashboard displays: Monitored positions , Live risk scores , Rescue history
CRE workflow execution status
Technology Stack:
TypeScript Solidity Foundry Chainlink CRE SDK viem wagmi Next.js Gemini AI via OpenRouter
Links
Created by
- Kamal Singh