project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5
project screenshot 6

Detox-Hook

DetoxHook transforms MEV extraction into LP earnings via Uniswap V4 hooks and Pyth real-time oracles

Detox-Hook

Created At

ETHGlobal Prague

Winner of

Blockscout

Blockscout - Big Blockscout Explorer Pool Prize

Prize Pool

Pyth Network

Pyth Network - Most Innovative use of Pyth pull oracle (Price Feeds) 1st place

ETHGlobal

ETHGlobal - šŸ† ETHGlobal Prague 2025 Finalist

Project Description

DETOX HOOK – a revolutionary Uniswap V4 Hook that transforms toxic arbitrage extraction into sustainable LP earnings, creating the first on-chain MEV protection system that benefits liquidity providers instead of sophisticated bots.

THE PROBLEM: MEV bots extract $1B+ annually from Uniswap pools while LPs suffer impermanent loss. When pools become mispriced vs global markets, sophisticated arbitrageurs capture profits, leaving LPs with depleted reserves.

OUR SOLUTION: DetoxHook monitors every swap against real-time Pyth Network oracle prices. When traders attempt swaps at prices significantly better than global market rates (indicating arbitrage extraction), the hook intelligently intervenes to:

• Capture 70% of arbitrage profit through dynamic fee adjustment • Instantly donate 80% of captured value to LPs via PoolManager.donate() • Allow normal swaps unaffected – only opportunistic arbitrage pays the toll • Maintain fair pricing without off-chain intervention

PERMISSIONLESS ACCESS: Every liquidity provider in the Uniswap V4 ecosystem can initialize a pool attaching DetoxHook and thereby reap its benefits. No gatekeeping, no special permissions – just deploy a pool with our hook address and start earning from MEV instead of losing to it.

THE PYTH ADVANTAGE: This system is only possible with Pyth's unique capabilities: šŸ”„ Real-time data queried within the same transaction (400ms updates) šŸ”„ Confidence intervals ensuring price reliability before triggering fees šŸ”„ Freshness validation preventing stale data from creating false arbitrage šŸ”„ Institutional-grade data from 90+ first-party providers

LIVE RESULTS: Deployed on Arbitrum Sepolia at 0x444F320aA27e73e1E293c14B22EfBDCbce0e0088 with 2 active ETH/USDC pools. Real Pyth integration working with <500ms oracle latency.

Game theory aligned: arbitrageurs still profit (30% of opportunity), LPs get boosted returns (15-25% increase), protocols capture sustainable revenue, and regular traders enjoy fairer prices with reduced sandwich risk.

This represents the future of fair DeFi – where advanced oracle technology enables MEV protection that benefits everyone, not just the bots.

How it's Made

Architecture: DetoxHook leverages Uniswap V4's revolutionary hook system, deploying a custom contract attached to pools at creation. The UniSwap V4 PoolManager triggers our callbacks at critical moments during each swap.

PYTH ORACLE INTEGRATION (Core Innovation): DetoxHook utilizes Pyth's revolutionary "pull" oracle model, which provides fresh data exactly when needed rather than continuously pushing stale updates. In beforeSwap(), we fetch live prices from Pyth Network for both tokens. This real-time data access within the same transaction is what makes MEV detection possible:

function beforeSwap(...) external override returns (...) {
    // Fetch live prices WITHIN the swap transaction using Pyth's pull model
    PythStructs.Price memory ethPrice = pyth.getPriceUnsafe(ethPriceId);
    PythStructs.Price memory usdcPrice = pyth.getPriceUnsafe(usdcPriceId);
    
    // Validate confidence and freshness
    require(block.timestamp - ethPrice.publishTime < 30, "Price too stale");
    uint256 confidenceRatio = (ethPrice.conf * 10000) / uint256(ethPrice.price);
    require(confidenceRatio < 100, "Price confidence too wide");
    
    // Calculate real-time market rate
    uint256 marketPrice = (ethPrice.price * 1e18) / usdcPrice.price;
}

Arbitrage Detection Algorithm: We calculate the execution price from Uniswap's swap parameters and compare against Pyth's real-time market price. If a trader would get ETH at $1700 when Pyth reports market price at $1800 (5.5% arbitrage opportunity), our threshold triggers.

Dynamic Fee Mechanics: Instead of blocking trades, we apply intelligent fee scaling:

uint256 arbProfit = calculateArbProfit(marketPrice, poolPrice, swapAmount);
uint256 captureRate = 70; // Capture 70% of arb profit  
uint256 dynamicFee = (arbProfit * captureRate) / 100;
// Trader gets 1.65% benefit, hook captures 3.85% for LPs

Value Distribution: Captured fees are split 80% to LPs via PoolManager.donate() (distributed pro-rata) and 20% to protocol. This creates sustainable tokenomics while maximizing LP benefits.

WHY PYTH'S PULL MODEL IS ESSENTIAL: • Traditional push oracles continuously update on-chain (expensive, often stale) • Pyth's pull model provides fresh data exactly when needed for each transaction • 400ms updates and pull-based architecture provide fresh data exactly when needed • Confidence intervals prevent false positives that could harm legitimate traders • Cross-chain availability means same protection on all supported networks

Technical Stack: Built with Foundry for smart contracts, integrated with Pyth Network for price feeds, deployed on Arbitrum Sepolia for L2 efficiency. Our hook uses BEFORE_SWAP_FLAG and BEFORE_SWAP_RETURNS_DELTA_FLAG permissions for maximum control.

Production Deployment: Live at 0x444F320aA27e73e1E293c14B22EfBDCbce0e0088 with 2 active ETH/USDC pools, comprehensive testing suite (37/37 tests passing), and modular deployment scripts. Gas optimized: 188k deployment, 21k operations.

Innovation: This is the first production MEV protection hook for Uniswap V4, proving that real-time oracle-powered MEV capture and redistribution is not only possible but economically sustainable.

background image mobile

Join the mailing list

Get the latest news and updates