Hooks

Discover Uniswap v4 hooks and how custom smart contract logic extends pool behavior.

Introduction

Uniswap v4 inherits all of the capital efficiency gains of Uniswap v3 while introducing major architectural improvements. The key innovations are the Hook System and Singleton Architecture, which together enable unprecedented protocol customization and gas optimization.

How Hooks Work

Hooks allow developers to customize and extend the behavior of liquidity pools. They are external smart contracts that can be attached to individual pools to intercept and modify the execution flow at specific points during pool-related actions.

Hook callbacks can run around major operations such as pool initialization, liquidity changes, swaps, and donations.

Hooks can be used to build features such as custom pricing logic, dynamic fee strategies, custom oracle behavior, and advanced order mechanics. Hooks are optional, set at pool creation, and one hook contract can serve multiple pools.

Singleton Architecture

The hook system in v4 is built on singleton architecture. Unlike previous versions where each pool was a separate smart contract, v4 manages pools through a single contract: PoolManager. This design enables:

  • Efficient Pool Creation: Pools are created as state updates rather than contract deployments, significantly reducing gas costs
  • Gas Optimization: Multi-hop swaps and complex operations are streamlined through a single contract
  • Flash Accounting: Token balances are tracked internally and settled at the end of transactions, minimizing transfers
  • Native ETH Support: Direct ETH trading without the need to wrap to WETH, improving user experience

These core features are just the beginning of what's possible with Uniswap v4.

To explore conceptually how flash accounting, native ETH support, dynamic fees, and custom accounting are enabled by v4, read the v4 whitepaper.

For technical implementations and detailed guides, visit the v4 documentation.