AI-driven Uniswap v4 dark pool for zero-slippage, MEV-resistant token swaps
ShadowMesh: The Agentic Dark Pool The Core Problem: Intent Leakage & The Trust Assumption In modern DeFi, large-volume execution suffers from a fatal trilemma involving Privacy, Decentralization, and MEV. If institutions trade on public AMMs, they suffer brutal MEV sandwich attacks and slippage. If they use public limit order books, they broadcast their intent to the market, causing preemptive price crashes. Traditional finance solves this with "Dark Pools," but bringing this to Web3 has historically required a centralized matching engine—reintroducing trust assumptions and single points of failure.
The ShadowMesh Breakthrough: Agentic P2P Settlement ShadowMesh introduces a fundamentally new DeFi primitive: The Trustless Agentic Dark Pool. We completely eliminate the centralized matching engine by shifting the negotiation phase entirely off-chain to a decentralized P2P mesh network, operated by autonomous AI agents, while maintaining deterministic, cryptographically guaranteed on-chain settlement via Uniswap v4.
Deep Architecture Breakdown:
The Sovereign AI Negotiators (Gemini + Pyth) Instead of users submitting static limit orders, they deploy autonomous Gemini-powered agents equipped with hidden parameters (max/min reserve prices). To ensure these agents do not hallucinate and are anchored to reality, their logic loops strictly query the Pyth Network Hermes Oracle before every turn. This provides sub-second, real-world spot pricing to inform their high-frequency haggling algorithms.
The Dark Mesh (Gensyn AXL) To prevent mempool monitoring and metadata leakage, the agents do not communicate over a centralized server. They establish an Agent-to-Agent (A2A) connection over the Gensyn AXL P2P Mesh Network. This creates a true "Dark Room"—a decentralized, off-chain communication layer where high-frequency negotiation produces zero public footprint.
The Deterministic State Lock (EIP-712) The critical challenge of Agentic DeFi is bridging probabilistic AI outputs to deterministic smart contracts. ShadowMesh solves this using a cryptographic "State Lock." The exact millisecond the Buyer and Seller agents reach an agreement over the mesh, they generate a highly structured DarkPoolIntent payload. Both agents autonomously sign this payload using the EIP-712 cryptographic standard. This converts an off-chain AI hallucination into an immutable, mathematically verifiable on-chain commitment.
MEV-Proof Routing (KeeperHub) If the signed EIP-712 agreement were broadcast to the public mempool, searchers would snipe it. ShadowMesh neutralizes this vector by routing the payload directly through KeeperHub. Acting as a private relayer, KeeperHub bypasses the public mempool entirely, wrapping the trade and delivering it stealthily to the Uniswap Router.
The On-Chain Arbiter (Uniswap v4 Hooks) The final, trustless arbiter of the ShadowMesh protocol is our custom Uniswap v4 Hook. ShadowMesh hooks into the beforeSwap execution phase. Before allowing the router to touch the liquidity pool, the Hook intercepts the transaction, unpacks the payload, and mathematically recovers the EIP-712 signatures of both the AI Buyer and Seller. It verifies that the requested swap parameters match the exact intent signed off-chain. If any external actor attempts to alter the swap amount or slippage by even a single wei, the Hook’s _validateIntentForSwap function forcefully reverts the transaction (InvalidSwap()).
The Result: ShadowMesh achieves what was previously impossible: zero intent leakage, off-chain computational privacy, and trustless on-chain execution. By vertically integrating Pyth, Gensyn, KeeperHub, and Uniswap v4, we have laid the foundation for the future of institutional-grade, Agentic DeFi.
How We Built ShadowMesh
ShadowMesh is built on a vertically integrated stack that bridges off-chain AI reasoning with on-chain deterministic execution. The architecture is split into three main layers: the AI Mesh (Off-chain), the Relayer (Mid-chain), and the Settlement Layer (On-chain).
The AI Mesh Layer (Off-Chain) We built the Buyer and Seller autonomous agents using Node.js and TypeScript, powered by the Gemini LLM. To ensure these agents traded based on reality, we integrated the Pyth Network Hermes Oracle. Before every negotiation turn, the agents fetch the live spot price of WETH to establish their baselines. For communication, we completely bypassed centralized servers and utilized the Gensyn AXL P2P network. This allowed the agents to haggle over a decentralized, private mesh, ensuring zero intent leakage.
The State Lock & Relayer (Mid-Chain) Once the AI agents agree on a price, they generate a strictly typed DarkPoolIntent payload. Both agents sign this using the EIP-712 cryptographic standard via ethers.js. To prevent MEV sniping, this signed payload is not broadcast to the public mempool. Instead, it is handed to KeeperHub, our stealth relayer, which bypasses the public mempool and routes the execution directly to the Uniswap Router.
The Settlement Layer (On-Chain) The final execution environment is built on Uniswap v4. We wrote custom Solidity contracts using Hardhat/Foundry to interface with the v4 PoolManager. The core of this is the ShadowMeshHook, which intercepts the KeeperHub transaction.
The "Hacky" & Notable Engineering: Bridging probabilistic AI with strict EVM environments required two notable technical maneuvers:
The CREATE2 Hook Mining: Uniswap v4 uses address prefixes to determine which hook callbacks are active (e.g., the address must start with specific bytes to enable beforeSwap). We couldn't just deploy the contract normally; we had to write a custom deployer script that brute-forced thousands of cryptographic salts using the CREATE2 opcode to mine a smart contract address that perfectly matched the Uniswap v4 routing requirements.
The Probabilistic-to-Deterministic Bridge: Getting two AIs to haggle is easy; getting them to output a mathematically flawless execution payload is incredibly hard. The "hackiest" thing we built was the internal prompt engineering that acts as a "State Lock." We forced the Gemini models to pause their conversational loop the exact millisecond their price bounds overlapped, inject the agreed numbers into a rigid JSON schema, and instantly pass it to an off-chain signer. We successfully turned conversational AI output into an immutable, legally binding cryptographic signature.

