A hook is a contract that a Uniswap v4 pool names when it is created. The pool's home contract, the PoolManager, calls the hook at chosen moments: before and after a swap, before and after liquidity changes, at creation and on donations.
What hooks can do
- Set the fee for each swap instead of using a fixed tier.
- Refuse a trade, for example when a per-block cap is full.
- Take a share of what goes in or comes out, to burn it, donate it or hold it in a pot.
- Track positions for rewards, or lock liquidity until a date.
14 switches in the address
Which of these moments a hook is called at is not decided by its code but by its address. The last 14 bits of the address are switches. That means you can check a hook's powers without reading any code.
A hook is fixed for the life of a pool. Choose carefully, and read before you trade.