ShieldSwap
Private AMM Swaps Powered by AI
What it is
ShieldSwap is a privacy-preserving automated market maker that solves DeFi's critical privacy problem while enabling optimal execution timing.
PROBLEM:
Traditional DEXs expose complete financial privacy - wallet addresses, transaction amounts, timing, and trading patterns are all publicly visible. Existing privacy solutions like Tornado Cash only allow same-token withdrawals without price optimization, forcing users to choose between privacy and optimal execution.
WHAT IT IS:
ShieldSwap is the first AMM where users can deposit tokens anonymously into privacy pools, swap INSIDE the pool with AI-powered market analysis, and withdraw to ANY address with zero on-chain links. We combine three cutting-edge technologies: Zero-Knowledge SNARKs for privacy, Chainlink infrastructure for decentralized automation and price data, and AI-powered market analysis for optimal timing.
HOW IT WORKS:
PRIVACY LAYER: Users deposit tokens (MockETH/MockBTC) and receive a secret note. The system generates cryptographic commitments stored in Merkle trees - only the hash goes on-chain, with no wallet address link.
INTELLIGENCE LAYER: A Chainlink CRE workflow monitors pool vs. market prices every 30 seconds. It fetches real-time data from Chainlink Data Feeds (ETH/USD, BTC/USD) and sends market context to GPT-4o-mini for analysis. Users set custom thresholds (e.g., "execute when pool within 5% of market").
EXECUTION LAYER: When conditions are optimal (AI confidence >80%, deviation within threshold), the system executes swapAndWithdraw() through our Uniswap V2-style AMM. Tokens are swapped inside the privacy pool and sent to the recipient address.
The innovation: Complete deposit-to-withdrawal privacy while swapping between different tokens with intelligent timing - something no existing privacy protocol offers.
How it Works
SMART CONTRACTS (Solidity + Foundry):
- 4x ShieldPool contracts with Merkle tree implementations for anonymous deposits
- SSPair (Uniswap V2-style AMM) using constant product formula (x*y=k)
- SSRouter for swap routing and liquidity management
- 2x Mock ERC20 tokens (MockETH, MockBTC)
- Deployed on Sepolia testnet
PRIVACY ARCHITECTURE (ZK-Ready):
- Complete Merkle tree implementation (20 levels) for commitment storage
- MiMC hash function for generating commitments from nullifier + secret
- Nullifier tracking to prevent double-withdrawals
- ZK-SNARK circuit designed (withdraw.circom) for production use
- Currently using simplified verifier for rapid hackathon testing
- Full Groth16 proof generation and MPC ceremony planned for production
CHAINLINK INTEGRATION:
- CRE SDK (TypeScript) for autonomous monitoring workflow
- EVMClient capability reads pool reserves and Chainlink Data Feeds (ETH/USD, BTC/USD)
- HTTP capability for OpenAI GPT-4o-mini API integration
- Cron trigger for 30-second price monitoring intervals
- Workflow computes deviation: (poolPrice - marketPrice) / marketPrice
- AI analyzes market conditions and returns swap decisions with confidence scores
- Simulation-tested with complete autonomous execution architecture
FRONTEND (React + TypeScript):
- Vite for fast development and builds
- Wagmi + RainbowKit for seamless wallet integration
- Ethers.js v6 for blockchain interaction
- Real-time Chainlink Data Feed integration for price displays
- Secret note generation and management system
- Animated UI with particle effects and glassmorphism design
- Deployed on Vercel at shieldswap-rouge.vercel.app
AI & AUTOMATION:
- GPT-4o-mini analyzes pool vs market price deviations
- Custom prompt engineering for reliable JSON decision outputs
- Confidence scoring system (0-100%)
- Rule-based fallback logic for API failures
- Deterministic execution logic ready for CRE deployment
ARCHITECTURE HIGHLIGHTS:
- Denomination-based pools (100, 10, 1) for amount obfuscation
- Privacy preserved: commitments in Merkle tree, secrets stay client-side
- Swap-inside-pool innovation: deposit TokenA, withdraw TokenB
- Complete separation between depositor and recipient addresses
Links
Created by
- Harsh Yadav