Uniswap V4 Hooks

Uniswap v4 hooks are optional smart contracts that let a pool add custom logic at defined points in its lifecycle. A hook can run before or after actions such as pool initialization, liquidity changes, swaps, and donations. This lets developers extend a pool’s behavior while using Uniswap v4’s shared settlement system.

What a hook can do

Uniswap v4 defines ten callback functions: before and after initialization; before and after adding or removing liquidity; before and after a swap; and before and after a donation. A hook only needs to implement the callbacks it uses. Four additional permission flags let hooks return balance deltas for certain swap and liquidity actions, supporting custom accounting.

Depending on its code, a hook can support features such as dynamic fees, limit-order behavior, custom oracle logic, liquidity-management rules, or a different accounting curve. These are building blocks, not features guaranteed in every pool. A standard v4 pool can operate without a hook and retains the concentrated-liquidity model introduced in v3.

How a pool selects its hook

A pool can have one hook contract, and a hook contract can serve multiple pools. The hook address is part of the pool’s key and is fixed when the pool is initialized; it cannot later be attached, removed, or replaced for that pool. A different hook requires a different pool.

The address also encodes which hook permissions are enabled. Developers must deploy the contract at an address whose permission bits match its implemented callbacks. This makes the address and the hook’s declared behavior part of understanding a pool, but it does not make the hook code automatically safe.

Uses and risks

Hooks make it possible to experiment with pool-specific behavior without deploying an entirely separate AMM design. They also add code and assumptions to transactions. A hook can affect fees, execution, or accounting, and a bug or unexpected interaction may put users at risk. Review the exact pool, hook source code, permissions, and audits before interacting. Deploying a hook also does not guarantee that a particular interface or router will send trades to that pool.

History

  • August 2024: The Uniswap v4 core whitepaper described hooks and the protocol’s singleton and flash-accounting architecture.
  • January 31, 2025: Uniswap v4 went live, with hooks available as an optional way to customize pools.

Related Terms

See Also

Sources

  • Uniswap Developers — Hooks — Lists the ten callback functions, return-delta permissions, address-encoded permissions, and the rule that a pool’s hook is fixed at initialization.
  • Uniswap Developers — Architecture — Describes how hooks interact with the PoolManager and gives examples including limit orders, custom oracles, fee management, and automated liquidity management.
  • Uniswap v4 Core Whitepaper — Explains hooks, custom accounting, the singleton PoolManager, and flash accounting in the original design.
  • Uniswap Labs — Uniswap v4 Is Here — Announces the January 31, 2025 launch and describes hooks as modular pool extensions.