Shadow Orders

MEV-resistant limit orders for Uniswap V4. Encrypt your trades with TEE, stop front-running.

Shadow Orders

Created At

HackMoney 2026

Project Description

Shadow Orders brings privacy-preserving limit orders to Uniswap V4 by leveraging Inco Network's Lightning SDK with Trusted Execution Environment (TEE) encryption.

Traditional DEX limit orders expose traders to MEV attacks—bots can see pending orders in the mempool and front-run them, causing slippage and losses. Shadow Orders solves this by encrypting order parameters (price, amount, direction) client-side before they hit the blockchain.

Users create limit orders through our Next.js frontend, where order details are encrypted using Inco Lightning TEE. The encrypted orders are stored on-chain via a custom Uniswap V4 hook deployed on Base Sepolia. When market prices reach the target, our keeper network automatically executes swaps—delivering tokens at the exact price users wanted, with zero MEV extraction.

Built on Uniswap V4's revolutionary hooks architecture, Shadow Orders integrates seamlessly with existing liquidity pools while adding a privacy layer that makes front-running impossible. MEV bots can see transactions but cannot decode order parameters, eliminating sandwich attacks and ensuring fair execution for all traders.

How it's Made

Shadow Orders is built with a modern full-stack architecture combining cutting-edge blockchain privacy technology:

Frontend (Next.js 15.5 + React 19): Built with TypeScript and Tailwind CSS for a responsive UI. Uses Wagmi v3.4 and RainbowKit v2.2 for seamless wallet integration. The frontend handles client-side encryption via Inco's Lightning SDK, encrypting order parameters (price, amount, direction) using TEE before blockchain submission. Real-time price tracking integrates CoinGecko API with React Query for caching and live market data simulation.

Smart Contracts (Solidity 0.8.26 + Foundry): The core is ShadowOrdersHook.sol—a custom Uniswap V4 hook that intercepts swap operations via beforeSwap() and afterSwap() callbacks. Orders are stored on-chain with encrypted parameters, making them invisible to MEV bots. The hook integrates directly with Uniswap V4's PoolManager on Base Sepolia (Chain ID 84532), leveraging concentrated liquidity pools while adding privacy guarantees.

Encryption (Inco Lightning + TEE): We chose Inco's Lightning SDK over traditional FHE because TEE offers 100x faster performance with lower gas costs—critical for mainnet viability. The Trusted Execution Environment provides hardware-backed security, ensuring encrypted values remain private throughout the entire order lifecycle. Each order parameter is encrypted separately using encrypt64() and encryptBool() functions.

Keeper Network (Node.js + Viem): A decentralized execution layer monitors OrderTriggered events emitted by the smart contract. When conditions are met, keepers pull tokens from users (via ERC20 approvals), execute swaps through Uniswap V4's PoolSwapTest contract, and transfer output tokens back to users. This trustless design ensures orders execute at target prices without revealing strategy to MEV searchers.

Notable Hacks:

  • Simulated price movements for demo purposes (±12% random walk, 2-second intervals) to showcase order execution without waiting for real market volatility
  • Client-side order tracking using localStorage with encryption status indicators and progress bars for user engagement
  • Custom pool initialization scripts using Foundry to deploy test token pairs with realistic liquidity on Base Sepolia
  • Gas optimization in the hook contract by batching order checks and using efficient storage patterns (mapping-based lookups vs array iterations)

Partner Technologies:

  • Uniswap V4 Hooks: Revolutionary architecture allowing custom logic injection at swap lifecycle points—essential for condition checking without forking the protocol
  • Inco Network: Lightning SDK provided practical TEE encryption with sub-second performance, making privacy viable for production DEX use
  • Base (Coinbase L2): Low gas costs (~$0.01 per swap) and 2-second block times enable responsive order execution and keeper profitability
  • CoinGecko API: Real-time price feeds for accurate market data and simulation calibration

The combination of Uniswap V4's extensibility, Inco's TEE encryption, and Base's L2 efficiency creates a practical privacy solution that works today—not just theoretical cryptography. All code is open source and deployed on testnet for immediate testing.

background image mobile

Join the mailing list

Get the latest news and updates