V4HOOKSCUT SHEET DIRECTORY

Learn / OpenZeppelin

last updated 2026-08-27

Build with OpenZeppelin hooks

OpenZeppelin/uniswap-hooks is an MIT Solidity library for secure, modular Uniswap v4 hooks. Prefer it (or Uniswap’s BaseHook) over a blank contract so caller checks and permission validation are already there.

The library is experimental and not a substitute for an audit. Use it as the correct starting shape — then read secure v4 hooks before you ship.

Install (Foundry)

forge install OpenZeppelin/uniswap-hooks

# remappings.txt
@openzeppelin/uniswap-hooks/=lib/uniswap-hooks/src/

Hardhat is not currently supported upstream because v4 core/periphery are not published as npm packages.

What to inherit

PathUse for
src/base/BaseHook, BaseCustomAccounting, BaseCustomCurve, BaseAsyncSwap
src/fee/Dynamic fee / after-fee building blocks
src/general/AntiSandwichHook, LimitOrderHook, LiquidityPenaltyHook, ReHypothecationHook
src/oracles/Oracle-oriented hooks
src/utils/CurrencySettler and helpers

Minimal BaseHook pattern

External callbacks are gated with onlyPoolManager. You implement getHookPermissions and the matching _beforeSwap / _afterSwap internals. Full excerpt on the BaseHook cut sheet.

modifier onlyPoolManager() {
    if (msg.sender != address(poolManager)) revert NotPoolManager();
    _;
}

function beforeSwap(...) external onlyPoolManager returns (bytes4, BeforeSwapDelta, uint24) {
    return _beforeSwap(...);
}

Ready-made patterns in the library

Agent workflow

  1. Match the job on v4hooks and open the cut sheet.
  2. If the pattern is “start from a base,” use OpenZeppelin BaseHook, not a blank IHooks.
  3. Copy the full file from the listing’s source.url, not only the excerpt.
  4. Run the security checklist before deploy.

Sources