Skip to content

designsheva/FhenRoute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

FhenRoute

A Uniswap V4 hook that encrypts your swap parameters using Fhenix FHE so MEV bots can't front-run you.

The Problem

Every time you make a trade on a DEX, bots can see it before it executes. They jump ahead of you, move the price, and you end up paying more. This is called front-running, and it costs traders hundreds of millions of dollars every year. In 2025 alone, sandwich attacks hit $289 million across Ethereum.

The root cause is simple: your trade is visible in the mempool before it goes through.

What FhenRoute Does

FhenRoute sits between you and Uniswap. When you submit a swap, FhenRoute encrypts your trade details using Fully Homomorphic Encryption (FHE) before they ever touch the mempool. Bots see encrypted gibberish instead of your actual trade. The swap still executes normally through Uniswap V4, but nobody can extract value from you because they can't read what you're doing.

Think of it like whispering your order to the cashier instead of shouting it in a crowded room.

How It Works

  1. You connect your wallet and pick a token pair
  2. You enter how much you want to swap
  3. FhenRoute encrypts your trade amount client-side using Fhenix cofhejs
  4. The encrypted intent gets submitted to the FhenRoute hook contract on Uniswap V4
  5. Fhenix CoFHE coprocessor processes the encrypted data off-chain
  6. The swap executes through Uniswap with your parameters protected until the moment of execution
  7. Bots never see your trade details. You get a fair price.

Tech Stack

  • Smart Contracts: Solidity 0.8.20+, Foundry
  • FHE Layer: Fhenix CoFHE (@fhenixprotocol/cofhe-contracts/FHE.sol)
  • DEX Integration: Uniswap V4 Hooks (beforeSwap)
  • Client SDK: cofhejs for client-side encryption
  • Frontend: React
  • Testnet: Arbitrum Sepolia (CoFHE is live here)

Architecture

Trader (Frontend)
    │
    │  encrypts swap params using cofhejs
    ▼
FhenRoute Hook Contract (Uniswap V4 beforeSwap)
    │
    │  stores encrypted intent, validates via FHE operations
    ▼
Fhenix CoFHE Coprocessor (off-chain)
    │
    │  processes encrypted computation, returns results
    ▼
Uniswap V4 Pool Manager
    │
    │  swap executes, trader gets fair price
    ▼
Done. Bots saw nothing.

What Makes This Different

There are other projects working on encrypted trading. AlphaEngine by Fhenix is a full infrastructure stack using CoFHE + EigenLayer AVS + multichain settlement. The Iceberg hook does encrypted limit orders.

FhenRoute is intentionally simpler. It focuses on one thing: encrypting regular swaps so everyday traders stop losing money to bots. No complex operator networks, no multichain routing. Just plug in, encrypt, swap.

Project Status

This project is being built for the Fhenix Wave Hack buildathon.

Current phase: Ideation and architecture (Wave 1)

Build Plan

Wave 1 (now): Concept, architecture, this README

Wave 2: Core hook contract that accepts encrypted swap amounts via InEuint128, validates using FHE operations, and hooks into Uniswap V4 beforeSwap. Basic React frontend with wallet connect and encrypted swap submission. Deploy to Arbitrum Sepolia.

Wave 3: Encrypted slippage protection, multiple pending swaps with FIFO ordering, and a basic display showing how much value was protected per swap.

Running Locally (coming in Wave 2)

# Clone
git clone https://github.com/designsheva/FhenRoute.git
cd FhenRoute

# Install Foundry (stable build)
curl -L https://foundry.paradigm.xyz | bash
foundryup

# Install deps
forge install

# Build
forge build

# Test with mock FHE contracts
forge test

Key References

Team

Built by a small team for the Fhenix Wave Hack.

License

MIT

About

A privacy middleware for DEX trades using Fhenix FHE on Uniswap V4. Encrypts swap parameters to protect traders from MEV and front-running.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors