Impact Rebated Fees
A Uniswap v4 hook that prices MEV after the fact

Overview
Liquidity providers lose money to traders who are ahead of a price move. When a trade is followed by the price continuing in the same direction, it means the pool was still quoting the wrong price after that trade finished — and it is about to be traded against again at a price that is still stale.
A pool has one fee and no way to tell those traders apart, so it charges everyone enough to survive them. Someone swapping a few hundred dollars ends up paying a fee sized for damage they did not cause. This hook charges the trades that leave the pool mispriced and gives everyone else their money back.
It works in two transactions, sixty seconds apart. At the swap, the pool’s own fee is untouched and the hook takes an additional 25 bps, holding it as an ERC-6909 claim inside the PoolManager so the escrow never leaves Uniswap’s vault. Every trader is charged identically here, because the hook cannot yet know who was informed — the next sixty seconds have not happened.
At settlement, anyone can call settle(). The hook reads a running price-×time accumulator, subtracts the bookmark it saved, and divides by elapsed time to get the average price across the window. If the price kept drifting the way the trade was positioned by more than 20 ticks, the escrow is donated to the LPs; otherwise it goes back to the trader. No oracle, no off-chain service — the pool’s own price path is the entire signal.
Every comparable design (PegGuard, TRIDENT, DAMM, Nezlobin directional fees, Arb Controller) classifies a trade before it executes, which means predicting, and a fee set in advance has to be conservative. Settling afterwards has no classification error on the charging side, because it observes the outcome instead of forecasting it.
Key highlights
- Prize-track winner at the UHI-10 Hookathon, themed “The Fair Flow Frontier: MEV protection and sustainable low-fee liquidity on Uniswap v4.”
- Replayed against 26,209 real USDC/WETH mainnet swaps: +32.7% LP revenue over the base fee alone, for an expected cost of 0.71 bps to an uninformed trader.
- Recovers 42.8% of the $305,032 that informed flow captured over the sample — the gap is deliberate, since recovering all of it would double what ordinary traders pay.
- Measures drift from the post-swap price, not the pre-swap price or the price paid. The first version used the price paid and failed: a trader’s own impact reverting made every threshold flag fewer trades than random chance.
- Zero external dependencies — no Pyth, no Chainlink, no AVS — which is the property that distinguishes it from every prior attempt at the same goal.
- Declares only afterSwap and afterSwapReturnDelta, so it never touches pricing and routers quote the pool normally. Verified against the v4 Quoter on the live pool.
What it does
- 25 bps refundable deposit held as an ERC-6909 claim inside the PoolManager — escrow never leaves Uniswap’s vault
- Permissionless settlement with a 2% bounty, so a trader who settles their own receipt pays nothing net
- Unsettled escrow defaults to the LPs after ten minutes — failing in the safe direction
- 20-tick drift threshold chosen on trader cost rather than on flag count; revenue-maximising settings charge ordinary traders three times as much
- Replay test walks a real mainnet tick series through the hook’s accumulator and asserts the Solidity drift matches an offline Python reference across all 200 cases
- Next.js demo with a live settlement queue, countdown timers, and an offline snapshot fallback