Architecture

Every swap passes through the hook.

No new infrastructure. Just a Uniswap V4 pool with the ExtractableValueHook address baked into PoolKey.hooks. Five signals score the trade. The fee scales. The proceeds split. All in one transaction.

  1. 1

    Swap submitted

    Trader, arbitrageur, or MEV searcher calls swap() on the EV pool. The V4 PoolManager routes through beforeSwap().

  2. 2

    Hook classifies

    Five signals score the trade: block basefee premium, slippage tolerance, recent volume burst, gas priority, and same-block-position. Output is a toxicity score in [0, 1].

  3. 3

    Dynamic fee applied

    The hook returns a BeforeSwapDelta equal to baseFee × (1 + 16 × score). Benign trades pay 30 bps. Maximum-toxicity trades pay 510 bps.

  4. 4

    Proceeds split in afterSwap

    The accumulated tax is settled: 65% to LP claim balances, 25% to a burn, 10% to protocol-owned-liquidity reinforcement. All in the same transaction. No relayer.

swap() beforeSwap() score & price Uniswap V4 pool afterSwap() settle & split LP 65% burn 25% POL 10%
Classifier

Five on-chain signals. No oracles. No relayer trust.

All five are derivable from block.basefee, tx.gasprice, the swap parameters, and the pool's recent activity history. Everything is verifiable inside the hook in O(1) time.

ฯƒโ‚

Basefee premium

How far above the median block basefee this transaction sits. Sandwiches outbid the basefee aggressively to win position; honest retail does not.

ฯƒโ‚‚

Slippage tolerance

Wide amountOutMin tolerances are the calling card of swaps designed to be re-quoted by a bundler. Tight slippage signals an intended trade.

ฯƒโ‚ƒ

Volume burst

Has this pool seen more than 4× its 30-block median volume in the last block? Sandwiches arrive in clusters; benign flow does not.

ฯƒโ‚„

Same-block adjacency

Did the same EOA, or a known router proxy, swap the opposite direction in the same block? Direct sandwich-leg fingerprint.

ฯƒโ‚…

Gas-priority percentile

Where this transaction's priority fee sits within the pool's last-block distribution. Top-decile gas is overwhelmingly extractive.

V4 hook permissions

Only the swap path is hooked.

Liquidity actions go straight through the PoolManager untouched. LP-side gas costs match a vanilla V4 pool.

function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
    return Hooks.Permissions({
        beforeInitialize:                false,
        afterInitialize:                 true,
        beforeAddLiquidity:              false,
        afterAddLiquidity:               false,
        beforeRemoveLiquidity:           false,
        afterRemoveLiquidity:            false,
        beforeSwap:                      true,   // classify + price
        afterSwap:                       true,   // settle + split
        beforeDonate:                    false,
        afterDonate:                     false,
        beforeSwapReturnDelta:           true,   // returns the tax delta
        afterSwapReturnDelta:            false,
        afterAddLiquidityReturnDelta:    false,
        afterRemoveLiquidityReturnDelta: false
    });
}

Want the full math?

Classifier weights, calibration data, security assumptions, audit plan, deploy steps.

Read the docs See the mechanic