Uniswap v4 hook that holds a refundable deposit on informed swaps and settles it on a signed price
Every automated market maker has a quiet leak: a pool learns the price only from the trades it receives, so after the market moves it keeps quoting the old price until a bot trades against it. The bot keeps the difference and the liquidity providers pay for it. Touchstone is a Uniswap v4 hook that recovers part of that value without changing the price any trader gets.
When a swap looks informed (large, first in its block, part of fast one-sided flow, or moving toward a stale price), the hook takes a small refundable deposit out of the swap's own output, in the same transaction and with a single wallet signature. A few seconds later anyone can settle it with a signed Pyth price. The trade is measured against that price: if its markout beats a margin, part of the excess goes to the liquidity providers and the rest returns to the trader. Benign flow is refunded in full and can earn a rebate.
Around that core sit four markets: clawback on informed trades, a rented arbitrage licence that pays rent to the pool, rebates for benign flow, and quote integrity. For the last one, previewDeposit, a URC-4 indicative quote and a guarded router show the deposit before the user signs and enforce limits inside the transaction.
Backtested on 184,145 real Ethereum USDC/WETH swaps from a held-out window, the trigger flagged the trades carrying 98.9% of toxic markout while asking a deposit on 23.4% of swaps (historical backtest, pre-registered). Seven verified contracts run on Arbitrum Sepolia, with a dashboard that executes a real swap and follows its settlement.
The contracts are Solidity 0.8.26 built with Foundry on Uniswap v4. The hook uses the beforeInitialize, beforeSwap, afterSwap and afterSwapReturnDelta permissions:
The hook address is mined with CREATE2 to carry its flag bits, and the deploy script predicts nonces to wire seven contracts in one pass.
Settlement is a separate contract. It verifies one signed Pyth update through the unique-update call and applies a confidence margin. It clips an overshooting swap to its in-the-money leg, so padding cannot dilute the markout. It splits the retained amount into a tip, a rebate pool and LP income that vests over time through a donation. The hook rechecks that the payout conserves the deposit exactly before paying.
Partner technologies:
Notable engineering:
Off-chain:
These counts are from my earlier runs: 254 forge tests, a 23,993-byte hook and seven contracts verified on Arbiscan. The 98.9% / 23.4% backtest figu2 results.

