Hookr.fun_
Learn · August 23, 2026

Uniswap v4 hooks, explained

A Uniswap v4 hook is a smart contract attached to a specific pool that runs code at defined points in the pool's own operations — before and after swaps, liquidity changes, and donations — letting a pool carry custom rules like dynamic fees, trade caps, or automatic burns with no off-chain infrastructure operating them.

Last updatedAugust 23, 2026Hookr.fun · Robinhood Chain

Short answer

A Uniswap v4 hook is a smart contract attached to a specific pool that runs code at defined points in the pool's own operations — before and after swaps, liquidity changes, and donations — letting a pool carry custom rules like dynamic fees, trade caps, or automatic burns with no off-chain infrastructure operating them.

One contract per pool, called during execution

Uniswap v4 holds every pool in a single PoolManager contract, and each pool names one hook address at creation. During a swap, the manager calls the hook at fixed checkpoints — typically beforeSwap and afterSwap — and the hook can read the swap's parameters, return an adjusted fee, cap or redirect amounts, or donate proceeds to LPs before the swap completes.

Which checkpoints a hook may run is committed on chain in the upper bits of the hook's own address: the flags are visible to anyone before they interact with the pool. That is what makes a hooked pool inspectable — permissions are part of the address you can verify, not a promise in a document.

What hooks can do

Common patterns include dynamic fees that respond to volatility or trade size, limits on trade size during a launch window, automatic routing of part of a buy to a dead address or to LPs, and pots funded per trade. All of it runs inside the pool's own execution — no keeper, no bot, and no oracle unless the mechanic itself reads one.

The flip side: a hook is privileged code inside every swap. What it is allowed to do is bounded by the permission flags it declares, and what it actually does should be readable from its parameters. If neither is checkable, treat the pool as untrusted.

Composable blocks, not bespoke code

Hookr treats five well-defined behaviors as blocks: Anti-Snipe (launch-window buy caps plus an extra LP fee), Surge Fees (size-scaled LP fees), Auto Burn (a share of actual buy output sent to the dead address), LP Rewards (ETH-side donations to in-range LPs), and the Nth-buy Pot (a deterministic pot paid by a public counter — not random). A creator stacks up to five of them, tunes the parameters, and Hookr compiles one hook with exactly that stack.

When a market's pool opens, it is created with that hook already attached, and no owner function can retune the stack afterwards — not the creator's, not Hookr's.

Related: The five hook blocks in the docsMechanics, parameters, and stated trade-offs for every block.

Costs and limits

Hook logic costs gas on top of the base swap — Hookr's builder estimates the overhead per block per swap. Cuts apply only to exact-input buys: a sell pays just the LP fee, and an exact-output buy bypasses output-side cuts, which is why Anti-Snipe explicitly blocks exact-output buys during its guard window so its cap cannot be routed around.

Related: Hook blueprintsPublished stacks others launch with; launching with one routes its author royalty.