About
# MEV-Protected Smart Trading Aggregator
## The Problem We're Solving
Every day, DeFi traders lose millions to MEV bots. When you submit a swap on any blockchain, sophisticated bots monitor the mempool and execute strategies to extract value from your trades:
### Types of MEV Attacks
- **Frontrunning:** Bots place orders ahead of yours by paying higher gas fees
- **Sandwich Attacks:** Your trade gets wrapped between two bot transactions, manipulating the price you receive
- **JIT Liquidity:** Bots provide liquidity microseconds before your trade and remove it immediately after, stealing LP fees without taking real risk
### The Limit Order Dilemma
While limit order protocols offer an alternative, they come with their own critical issues:
- Static spreads that don't adapt to market volatility
- Orders either remain unfilled during calm markets or give away too much edge during volatile periods
- **Example:** Setting a limit order to sell 2 ETH for 6,000 USDC when ETH = $3,000 makes sense today, but becomes problematic if ETH suddenly spikes to $100,000
## Our Three-Pronged Solution
### 1. MEV-Taxing Uniswap V4 Hook - The Protection Layer
#### Inspiration & Foundation
Our approach is inspired by Paradigm's research paper "Priority is All You Need", which demonstrates how priority fees can be leveraged by smart contracts to tax malicious actors attempting to exploit capital.
#### Important Compatibility Note
**Blockchain Requirements:** This MEV protection mechanism relies on standard priority fee ordering. It works optimally on:
**Supported:**
- L2s with standard sequencers (Optimism, Base, Arbitrum) - Chains using flashblocks for microsecond ordering
**Limited Effectiveness:**
- Ethereum mainnet due to PBS (Proposer-Builder Separation) and custom block building
#### How Our Hook Works
**Detection Algorithm:**
- Normal User Priority Fee: 1-5 gwei - MEV Bot Priority Fee: 50-1000+ gwei - Our Hook: Monitors these fees in real-time
**Smart Taxation Formula:**
```solidity if (priorityFee > threshold) { tax = (priorityFee - threshold) × feeMultiplier // Tax flows directly to LPs as compensation } ```
**Key Features:**
- **Frontrun Protection:** Bots can still frontrun but must compensate LPs - **JIT Penalty:** 4x higher tax rate for JIT liquidity (more extractive behavior) - **User-Friendly:** Regular users with normal priority fees pay nothing extra - **Flashblock Support:** Enhanced granularity for L2 chains with flashblock architecture
### 2. Dynamic Volatility-Based Limit Orders
Built as an extension to 1inch Limit Order Protocol
#### The Innovation
Traditional limit orders use fixed spreads, leading to poor execution in changing markets. Our dynamic system adapts spreads based on real-time market volatility.
#### Volatility Tracking System
- **Data Source:** 24-hour rolling price window via Pyth oracles
- **Update Frequency:** Hourly updates for fresh volatility data
- **Calculation Method:** Standard deviation of hourly returns
- **Special Cases:** Stablecoins receive fixed 1% volatility (computation savings)
#### Dynamic Spread Adjustment
| Market Condition | Volatility | Spread Behavior | Result | |------------------|------------|-----------------|--------| | Calm Markets | ~20% | Tight spreads | Competitive pricing | | Volatile Markets | ~200% | Wide spreads | Protection prioritized |
**Formula:** `finalSpread = baseSpread + (volatility × multiplier)`
### 3. Smart Routing Aggregator - Best of Both Worlds
#### The Challenge
Combining offchain limit orders with onchain AMM swaps in a single atomic transaction.
#### How It Works
**Step-by-Step Process:**
1. Scan available 1inch limit orders for liquidity 2. Check Uniswap V4 pool depths and current prices 3. Calculate optimal split to minimize slippage and maximize output 4. Execute everything in a single atomic transaction
#### Real-World Example
**User Input:** 100,000 USDC → ETH
**Aggregator Process:**
``` ├── Found: 30,000 USDC of limit orders @ 0.2% below market ├── Execute: Fill limit orders first (better price) ├── Route: Remaining 70,000 USDC through V4 (MEV protected) └── Result: Optimal blended rate, single transaction ```
**Outcome:** Better execution than any single venue
## Comparison to Existing Solutions
Similar intent-based execution as CoWSwap, UniswapX, and 1inch Fusion, but with:
- Built-in MEV protection at the AMM level
- Dynamic volatility-based limit order pricing
- Single transaction execution for gas efficiency
From the public ETHGlobal showcase page. Votes, swipes and the judge score are hackfeed's own.






