The best hack is the one that never happens.
A cryptographic airlock that makes DeFi exploits expensive, slow, and detectable using ML threat detection, guardian consensus, and cryptographic time-locks.
π¦ Uniswap Integration β’ π LI.FI Integration β’ π ENS Integration
|
|
|
- $3.8B stolen from DeFi protocols in 2022 alone
- Many hacked protocols were audited β audits aren't enough
- Zero security infrastructure that works across chains
DeFiGuardian creates a mandatory security checkpoint between users and protocols. Think of it like an airlock on a spaceship β nothing gets through without proper verification. By combining ML threat detection, distributed guardian consensus, cryptographic time-locks, and cross-chain coordination, we turn "seconds to exploit" into "30 minutes to defend".
|
|
|
Threshold Signatures 7-of-10 Ed25519 Schnorr signing |
Verifiable Delay Functions Wesolowski with RSA-2048 |
Private Guardian Voting Groth16 via Circom + snarkjs |
|
Fraud Detection 47 features from Etherscan data |
Hook Integration Security built into every swap |
Cross-Chain Routing & security propagation |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 1: User Intent β
β - Transaction submitted to SDK β
β - Pre-flight: Is protocol paused? Is sender blacklisted? β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 2: ML Analysis β
β - XGBoost model analyzes sender history (47 features) β
β - Score >= 50 = FLAGGED for VDF delay β
β - ENS security profile applied if user has one β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 3: Parallel Processing β
β β
β ββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
β β VDF Time-Lock β β Guardian Network β β
β β (if flagged) β β 10 guardians vote β β
β β β β ZK proofs for privacy β β
β β 30 min delay β β FROST signature if approved β β
β ββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 4: Execution β
β - VDF proof + FROST signature verified on-chain β
β - Transaction executes (or blocked if rejected) β
β - Cross-chain broadcast if needed β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
GuardianHook Security checks on every swap:
|
Cross-Chain Routing Protected bridges & swaps:
|
Security Profiles User-defined protection:
|
| Contract | Address | Role |
|---|---|---|
| π SecurityMiddleware | 0x8A4364c08147b1Ec0025e7B1e848BF675f9Dc7b9 |
Main airlock β queue + execute |
| π₯ GuardianRegistry | 0x702e8307Bc9c8EC7489C6f9e5562EdA44bB9fB7d |
Security state & proposals |
| π¦ GuardianHook | 0xFce40025E4a77D5395188d82657A728521D839ec |
Uniswap v4 integration |
| β±οΈ VDFVerifier | 0xFAf997119B0FFDF62E149Cbfc3713267a7C8DaEA |
VDF proof verification |
| βοΈ FROSTVerifier | 0x02a59687A130D198a23F790866500489F6f88C12 |
Threshold signature verification |
| π ZKVoteVerifier | 0xb638C0997778F172ba4609B8E20252483cD87eEE |
Private voting verification |
Network: Sepolia (Chain ID: 11155111)
Deployer: 0x69E135540F4F5B69592365DFE7730c08ACe96CCb
DeFiGuardian/
β
βββ π sdk/ # TypeScript SDK β main integration point
β βββ core/ # Middleware, VDF client, ZK client, LI.FI, ENS
β βββ mockExamples/ # 5 demo scripts for testing
β
βββ π agent/ # Python ML Agent (Flask API)
β βββ main.py # /analyze, /review endpoints + SSE
β βββ models/ # XGBoost model + preprocessors
β
βββ π guardian-mock/ # Mock Guardian Network (Express)
β βββ src/ # Voting simulation + FROST signing
β
βββ π lib/ # Cryptographic libraries
β βββ frost/ # FROST threshold signatures (Ed25519)
β βββ vdf/ # Wesolowski VDF prover/verifier
β βββ zk/ # Circom circuits + Groth16
β
βββ π contracts/ # Solidity smart contracts
β βββ SecurityMiddleware.sol # Main airlock
β βββ GuardianRegistry.sol # Security state manager
β βββ hooks/GuardianHook.sol # Uniswap v4 Hook
β βββ verifiers/ # VDF, FROST, ZK verifiers
β
βββ π docs/ # Documentation
β βββ TECHNICAL.md # Complete technical reference
β βββ UNISWAP_INTEGRATION.md # Uniswap v4 partner docs
β βββ LIFI_INTEGRATION.md # LI.FI partner docs
β βββ ENS_SECURITY_PROFILES.md # ENS integration docs
β
βββ π ML_bot/ # Jupyter notebook for model training
- Node.js 18+
- Python 3.11+
- Sepolia RPC URL (Infura/Alchemy)
- Funded wallet (>0.01 ETH)
# Clone the repository
git clone https://github.com/Jayanth-M0625/DeFiGuardian.git
cd DeFiGuardian
# Start ML Agent (Terminal 1)
cd agent && uv run python main.py
# Start Guardian Mock (Terminal 2)
cd guardian-mock && npm install && npx ts-node src/server.ts
# Start VDF Worker (Terminal 3)
cd lib/vdf && npm install && npx ts-node server.ts
# Run demo (Terminal 4)
cd sdk && npm install
npx ts-node mockExamples/smallTx.ts --sepolia| Command | Scenario | Result |
|---|---|---|
npx ts-node mockExamples/smallTx.ts --sepolia |
0.1 ETH normal tx | β PASS |
npx ts-node mockExamples/bigTxPass.ts --sepolia |
500 ETH + VDF + approve | β PASS |
npx ts-node mockExamples/bigTxFail.ts --sepolia |
1000 ETH attack | β BLOCKED |
npx ts-node mockExamples/BigTxCrossPass.ts --sepolia |
Cross-chain 500 ETH | β PASS |
npx ts-node mockExamples/SmallTxCross.ts --sepolia |
Cross-chain 0.5 ETH | β PASS |
| Document | Description |
|---|---|
| π Technical Documentation | Complete SDK API, contract details, integration guide |
| π¦ Uniswap v4 Integration | GuardianHook for security-first trading |
| π LI.FI Integration | Cross-chain security with LI.FI aggregation |
| π ENS Security Profiles | User-defined security rules via ENS |
| π Project Overview | Non-technical overview of problem & solution |
| Constant | Value | Description |
|---|---|---|
π₯ GUARDIAN_COUNT |
10 |
Total guardians in network |
β
GUARDIAN_THRESHOLD |
7 |
Required approvals (7/10) |
β±οΈ VDF_DELAY |
30 min |
Time-lock when ML flags |
π’ VDF_ITERATIONS |
300M |
Sequential squarings |
π€ ML_THRESHOLD |
50 |
Score >= 50 = flagged |
This project is a proof of concept built for ETHGlobal 2025. It demonstrates potential directions for DeFi security infrastructure and is NOT intended for production use or real financial transactions.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY.
