Learn / DeFi and earning

What are Uniswap v4 hooks?

Uniswap v4 hooks are optional smart contracts attached to a pool that run custom code before or after swaps and liquidity changes, such as custom fees.

DeFi and earning Illustration: Cryptoweek

Uniswap v4 hooks are small smart contracts that a pool creator can attach to a Uniswap v4 pool to change how it behaves. A hook runs its own code at fixed moments, such as just before a swap or just after liquidity is added. Developers can add features, from custom fee rules to new pricing curves, without changing the core protocol. For how Uniswap works in general, see what Uniswap is.

What is Uniswap v4?

Uniswap v4 is the fourth version of Uniswap's exchange contracts. Uniswap's blog says it went live on January 31, 2025 on 10 networks, including Ethereum, Arbitrum, Base, Polygon, OP Mainnet and BNB Chain. Besides hooks, the release added native ETH support, which saves gas on ETH pairs, and lower costs. Uniswap says creating a pool became up to 99.99% cheaper than in earlier versions. v4 keeps the price-range design explained in concentrated liquidity.

How do Uniswap v4 hooks work?

Uniswap's docs list the points where a hook can act:

  • Initialization: before or after a pool is created, which happens once.
  • Liquidity: before or after liquidity is added or removed.
  • Swaps: before or after each swap.
  • Donations: before or after tokens are donated to a pool.

Each pool can have one hook, but one hook can serve many pools. The hook is chosen when the pool is created, and the set of callbacks it uses is encoded in the hook contract's own address. Uniswap gives example uses such as custom automated market makers with different pricing curves, liquidity mining rewards, and lending or derivatives built on v4 liquidity. The docs also note that building a hook does not guarantee Uniswap's own app will route trades to it. Uniswap counted more than 150 hooks built at launch.

What is the Uniswap v4 PoolManager?

In v3, each pool was a separate contract. In v4, the PoolManager is a single contract, often called a singleton, that holds the state and logic of every pool. Uniswap's developer docs say this cuts gas costs for creating pools and for swaps that pass through several pools.

The PoolManager also uses flash accounting. Tokens move into the contract, the steps of a trade happen inside it, and only the final balances are settled at the end, after a solvency check. Temporary data is kept in transient storage, an Ethereum feature that is cheaper because it only lasts for one transaction.

Are Uniswap v4 hooks secure?

The core contracts went through heavy review. Uniswap's blog cites nine independent audits, a $2.35 million security competition and a bug bounty of up to $15.5 million, with no critical bugs found. Hooks are a different matter, because anyone can write one.

Uniswap's security framework for hook developers lists the main risks: accounting mistakes, reentrancy, math errors, unreliable external data, hooks that take over swap pricing, and dynamic fees that could be raised after seeing a trade. It advises avoiding upgradeable hooks where possible and placing any upgrade rights with a multisig or a timelock, never a single key. It also sets audit, bug bounty and monitoring levels by risk score. Traders and liquidity providers can use the same points as questions: who controls the hook, can it change, and has it been audited. Trading steps are in how to use Uniswap.

This guide explains how things work. It is not financial, legal or tax advice. Last updated .