A stealth shield against MEV, encrypting trades and settling them fair.
GhostLock: MEV Reaper is a cutting-edge DeFi platform that significantly endeavours to protect traders from Maximal Extractable Value (MEV) attacks through a 3-layer defense strategy: ENCRYPT β RANDOMIZE β EQUALIZE. Built on Base Sepolia and Arbitrum One, it leverages blocklock encryption, VRF-based ordering, and AI-optimized batch auctions to eliminate front-running, sandwich attacks, and price manipulations at each levels.
- π ENCRYPT (Layer 1): Blocklock time-locked encryption hides trading intents until execution block
- π² RANDOMIZE (Layer 2): EpochRNG VRF-based fair ordering prevents sandwich attacks via deterministic randomization
- β‘ EQUALIZE (Layer 3): Batch auctions with uniform pricing eliminate front-running opportunities and price manipulations.
- π€ Trade Intents Settlement: Automated solver with AI-optimized clearing prices
- π Transparency Panel: Gas estimates, unlock block ETA, expected receive amounts via 1inch API
- π³ Mock ERC-20 Tokens: ETH, USDC, WETH for development and testing
- π Multi-Chain: Deployed on Base Sepolia (testnet) and Arbitrum One (mainnet-ready)
- Framework: React 18 with TypeScript
- Styling: TailwindCSS with custom design system
- Animations: Framer Motion + Three.js for 3D components
- Web3: Wagmi + RainbowKit for wallet integration
- State: Zustand for client state management
- Runtime: Node.js with Express framework
- Blockchain: Ethers.js for smart contract interaction
- APIs: RESTful API design with comprehensive endpoints
- Solver Service: Automated batch settlement with epoch seed management (Layer 2)
- Scheduler: Proactive epoch seed monitoring and VRF request handling
- Real-time: WebSocket support for live updates
- GhostLockIntents: Manages encrypted trading intents
- EpochRNG: Provides verifiable randomness for fair ordering
- BatchSettlement: Handles uniform-price batch auctions
- MockTokens: Test tokens for development and testing
Purpose: Prevents sandwich attacks by randomizing intent execution order using verifiable randomness.
How it works:
- Backend solver automatically requests VRF seed from Drand network via EpochRNG contract for each epoch
- When intents are decrypted (after Layer 1), solver ensures epoch seed exists before processing
- Intents are grouped by epoch and ordered deterministically using
keccak256(epochSeed || requestId || user) - This creates fair, unbiased sequencing that attackers cannot predict or manipulate
- Same seed always produces same order β verifiable and deterministic
Implementation:
- Backend:
solver.jsautomatically requests epoch seeds, waits for VRF callback, then orders intents - Backend:
scheduler.jsproactively monitors and pre-requests seeds for upcoming epochs - Frontend:
useEpochRNGhook reads seeds for display,useAutoEpochSeedRequestmonitors availability (read-only) - Utilities:
epoch-ordering.tsprovides deterministic comparison functions matching backend logic
Tackles:
- β Sandwich attacks (can't predict order to insert front/back-run)
- β Front-running (order is randomized, not first-come-first-served)
- β MEV extraction via sequencing manipulation
Compared to other MEV-resistant efforts, GhostLock stands apart:
-
Flashbots / SUAVE
- Focus: private mempools + off-chain transaction sequencing.
- Limitation: requires trust in relays / builders; opaque order-flow markets.
- GhostLock advantage: no trusted relay; instead, ciphertexts are natively encrypted on-chain and decrypted only after safe block height. No privileged actors.
-
CoW Protocol
- Focus: batch auctions with solver competition.
- Limitation: intents visible before clearing β still exploitable; solvers can extract flow.
- GhostLock advantage: adds 3-layer protection (ENCRYPT + RANDOMIZE + EQUALIZE), so intents remain hidden until reveal, then shuffled via VRF to remove sequencing edge, then settled uniformly. GhostLock inherits batch auction fairness but eliminates pre-reveal leakage and sequencing manipulation.
-
MEV-Boost / PBS
- Focus: splitting block builders and proposers.
- Limitation: improves validator decentralization but not user-level trade protection.
- GhostLock advantage: user-first MEV protection, solving leakage at the transaction level.
-
Secret Network / TEEs
- Focus: hardware-enforced secrecy.
- Limitation: trust in hardware enclaves, supply-chain risk.
- GhostLock advantage: cryptographic, open, and verifiable; no hardware black box.
- Decryption timing mismatch: If unlock block < inclusion block, could allow premature reveal. Mitigation β safety margins + epoch alignment.
- Solver centralization: Current AI call is centralized; roadmap includes solver marketplace + bond/slashing to prevent manipulation.
- Metadata leakage: Ciphertext size/timing may leak info. Roadmap β padding + dummy intents.
- Latency vs UX tradeoff: Batch auctions add delay (~minutes). Mitigation β deploy on L2 for faster block times.
- Oracle/API dependency: Reliance on 1inch & external VRF oracles. Add fallback quoting + distributed randomness in roadmap.
- Node.js 18+ and npm
- Clone the repository
git clone https://github.com/your-org/ghostlock-mev-reaper.git
cd ghostlock-mev-reaper- Install dependencies
# Install root dependencies
npm install
# Install server dependencies
cd server && npm install && cd ..- Environment Setup
# Copy environment files
cp .env.example .env
cp server/.env.example server/.env
# Update with your configuration
# - Add your WalletConnect Project ID
# - Configure RPC URLs
# - Set contract addresses (after deployment)- Start Development Servers
# Terminal 1: Start frontend
npm run dev
# Terminal 2: Start backend API
npm run server- Access the Application locally
- Frontend:
http://localhost:3000 - Backend API:
http://localhost:4800 - Health Check: Preview
- Peak the server here π: Preview
- BaseSepolia Faucets
- GHOSTLOCK_INTENTS -
0xB049f2a5E2aeEa5950675EA89d0DA79E5749fB5C - BATCH_SETTLEMENT -
0x8aF0Ec5b9a22d02acdC0fb3ad75831fef3208706 - EPOCH_RNG -
0xA785F4B588013C9761b6B2Dff025e058C42cb798 - MOCK_ETH -
0xE8901D9f2f262f4F09E30344aA8470eCEbc64CBD
- GHOSTLOCK_INTENTS -
0x2Ad463E1f6783e610504A1027D6AdE8b2DcF10b2 - EPOCH_RNG -
0x96EE446A832b7AdcF598C4B2340131f622677c25
GET /api/auctions- List all auctionsGET /api/auctions/:id- Get specific auctionGET /api/auctions/stats- Get auction statistics
GET /api/markets- List all marketsGET /api/markets/:id- Get specific marketGET /api/markets/stats- Get market statistics
- Batch auctions with uniform pricing - Solver Competiton board
- Liveness guarantees β Bond + slashing for missed reveals, fallback threshold revealers, and permissionless settlement calls so no one can grief the auction.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Dcipher Network upholding the permissionless threshold signing network
- Blocklock Protocol for time-locked encryption
- Randomness Protocol for VRF implementation
- Base for the underlying blockchain infrastructure
- Drand for distributed randomness beacon
Happy building! ππ