Docs · Hooks

Uniswap v4 hooks in one page

The PoolManager, the pool key, the callbacks and the deltas: just enough of v4 to read a hook report.

One contract holds every pool

In Uniswap v4 there is no contract per pool. A single PoolManager holds every pool and every pool's tokens. On Robinhood Chain it lives at 0x8366a39CC670B4001A1121B8F6A443A643e40951. A pool is a record inside it, identified by the hash of its pool key:

Field Meaning
currency0, currency1 The two tokens, sorted by address. The zero address is native ETH.
fee The LP fee in hundredths of a basis point, or 0x800000 for a dynamic fee.
tickSpacing How far apart the ticks where liquidity can start or stop are.
hooks The hook contract, or the zero address for none.

Because the hook is part of the key, the same pair can exist many times, once per hook and fee. Two pools that trade the same token can behave in entirely different ways.

The hook is called around everything

A pool has four kinds of action: it is initialized once, liquidity is added and removed, it is swapped against, and fees can be donated to its LPs. For each, the PoolManager can call the hook before and after. That gives ten callbacks:

beforeInitialize, afterInitialize, beforeAddLiquidity, afterAddLiquidity, beforeRemoveLiquidity, afterRemoveLiquidity, beforeSwap, afterSwap, beforeDonate, afterDonate.

A callback is ordinary code. It can read and write the hook's storage, call other contracts, and revert. A revert in a callback reverts the action it wraps: a beforeSwap that reverts refuses the swap, an afterRemoveLiquidity that reverts refuses the withdrawal.

Which callbacks run is written in the address

A hook does not register its callbacks. They are encoded in the last 14 bits of its address, which the deployer mines with CREATE2 until the address has the right bits. The PoolManager reads those bits and calls only the callbacks they switch on. Ten bits are the ten callbacks; four more are the return delta permissions described below. The permission bits lists them all.

This is what makes a hook readable without its source. Whatever the code says, a callback whose bit is off is never called.

Deltas and settlement

Every action happens inside an unlock. A caller (a router, usually) asks the PoolManager to unlock, and inside that call it swaps or changes liquidity. Each action produces a delta for each token: what the caller owes the PoolManager or is owed by it. At the end of the unlock every delta must be zero: tokens paid in, tokens taken out. If not, the whole call reverts.

A hook with a return-delta permission can add its own delta to an action. On a swap it can take part of the input or part of the output; on a liquidity change it can charge the LP going in or coming out. It can also add rather than take. This is the mechanism behind every "hook tax".

Dynamic fees

A pool created with the fee field set to 0x800000 has a dynamic fee. The fee is not fixed in the key: the hook can update the stored fee whenever it wants, and with beforeSwap it can return a fee for each individual swap. The rate you see today is the rate the hook chose today. Check 04 judges where it stands, and fails a pool fee above 10%.

What can go wrong for a user

  • A tax on each swap, on top of the pool fee, through a swap return delta.
  • A tax that differs by direction, by sender, by size or by time since launch.
  • A swap that goes through in one direction and is refused in the other.
  • Swaps refused unless they come through a particular router.
  • Deposits refused (the pool is closed to outside LPs), or withdrawals refused.
  • LPs charged on the way in or out through a liquidity return delta.
  • A fee, a tax rate or the code itself changed later by whoever holds the keys.

None of these is wrong by itself. A launch hook that taxes buys for the first hour and sends the tax to a burn is a design, not a scam. The problem is not knowing, and that is the part censoredHooks is for.

On Robinhood Chain

Hooks are everywhere here. Launchpads attach a hook to every memecoin pool they create, and Pons V2 graduates its tokens into v4 pools. More than 28,000 distinct hooks sit behind those pools, and most of them have no verified source. The board grades the ones that matter most, and any other can be scanned on demand.