Lab: free tools · size first · stock scanner · crypto scanner · journal
Uniswap v4 Hooks Explained: Customizable AMM Logic
Uniswap v4 introduced "hooks," customizable smart contracts that can inject logic at specific points in the pool lifecycle (before/after swap, before/after liquidity changes). Hooks transform Uniswap from a fixed AMM into a programmable liquidity infrastructure layer, enabling dynamic fees, TWAMM (time-weighted AMM), on-chain limit orders, MEV redistribution, and custom oracle integrations within pools.
Uniswap v4, which launched in early 2025, lets pool creators attach hooks: custom contracts that run at points like before or after a swap or a liquidity change. Hooks enable dynamic fees, on-chain limit orders, custom oracles and more. They also mean each pool can behave differently, so a pool's hook code needs its own review. v4 also moved all pools into a single contract to cut gas costs.
Where hooks run
A hook is a separate contract attached to a pool when the pool is created. The PoolManager calls it at set points: before and after the pool is initialized, before and after liquidity is added or removed, before and after a swap, and before and after a donation to LPs. Some hooks can also change balances during a swap, which is how custom fees and custom pricing curves get built. Each pool gets at most one hook, while one hook can serve many pools. Hooks are optional, and a pool with no hook behaves like a v3 pool.
Details that matter
The hook can't be swapped out later. It's part of the pool's identity, so moving to a new hook means creating a new pool and moving liquidity. The functions a hook is allowed to run are encoded in the low bits of its contract address, which is why hook addresses are mined before deployment. Dynamic fees work by the hook setting the fee, either on the fly in beforeSwap or through a call to the PoolManager.
Risks for traders and LPs
Two pools for the same pair can now behave completely differently. A hook can charge its own fee, limit who adds liquidity, or carry a bug that traps funds. Before providing liquidity, find out which hook the pool uses, whether that code was audited, and who can change any settings inside it. Uniswap's own docs point out that building a hook doesn't guarantee its pool gets traffic from the Uniswap app, so plenty of hook pools will sit nearly empty.