Skip to content
Agent Orchestration
Skill

/v4-hook-generator

Generate Uniswap v4 hook contracts via OpenZeppelin MCP. Use when building custom swap logic, async swaps, hook-owned liquidity, custom curves, dynamic fees, MEV protection, limit orders, or oracle hooks.

From plugin
uniswap-ai
23618 skills2 agents1 MCP

Claude Code

$ npx -y skills add uniswap/uniswap-ai --skill v4-hook-generator --agent claude-code

SKILL.md

v4-hook-generator.SKILL.md
name: v4-hook-generator
description: 'Generate Uniswap v4 hook contracts via OpenZeppelin MCP. Use when building custom swap logic, async swaps, hook-owned liquidity, custom curves, dynamic fees, MEV protection, limit orders, or oracle hooks.'
allowed-tools: Read, Glob, Grep, WebFetch, Bash
model: opus
license: MIT
metadata:
  author: uniswap
  version: '1.0.0'

v4 Hook Generator

Generate Uniswap v4 hook contracts via the OpenZeppelin Contracts Wizard MCP tool. This skill guides you through selecting the right hook type, configuring permissions and utilities, assembling the canonical MCP JSON, and invoking the MCP tool to produce ready-to-compile Solidity code.

> **Security companion**: Generated hook code touches fund-handling contracts. Always apply the > `v4-security-foundations` skill immediately after generation to audit permissions, delta > accounting, and access control before deploying to any network.

When to Use This Skill

Use this skill when you need to:

  • Scaffold a new Uniswap v4 hook contract from scratch
  • Select the right base hook type for a specific use case (fees, MEV protection, oracles, etc.)
  • Configure hook permissions, utility libraries, shares, and access control
  • Produce the canonical MCP tool call JSON to invoke the OpenZeppelin Contracts Wizard
  • Understand trade-offs between hook configuration options before committing to an implementation

**Prerequisite / companion skill**: `v4-security-foundations` — run it before writing custom logic and again before deployment. Hook misconfiguration can drain user funds.

Hook Type Decision Table

Choose the base hook type that matches your primary goal. If your hook has multiple goals, choose the type that covers the most critical concern and layer additional logic on top.

| Goal | Use Hook | | -------------------- | -------------------------- | | Custom swap logic | `BaseHook` | | Async/delayed swaps | `BaseAsyncSwap` | | Hook-owned liquidity | `BaseCustomAccounting` | | Custom curve | `BaseCustomCurve` | | Dynamic LP fees | `BaseDynamicFee` | | Dynamic swap fees | `BaseOverrideFee` | | Post-swap fees | `BaseDynamicAfterFee` | | Fixed hook fees | `BaseHookFee` | | MEV protection | `AntiSandwichHook` | | JIT protection | `LiquidityPenaltyHook` | | Limit orders | `LimitOrderHook` | | Yield on idle | `ReHypothecationHook` | | Oracle | `BaseOracleHook` | | V3-compatible oracle | `OracleHookWithV3Adapters` |

**Selection tips**:

  • `BaseHook` is the general-purpose starting point — choose a specialized type only when the

built-in logic provides concrete value.

  • `BaseCustomCurve` replaces the entire AMM math; only use it if you are implementing a novel

pricing algorithm.

  • `AntiSandwichHook` and `LiquidityPenaltyHook` both address MEV but target different actors

(traders vs. JIT LPs). Clarify which attack vector you are mitigating.

  • `OracleHookWithV3Adapters` is appropriate when downstream integrations expect a Uniswap v3

`IUniswapV3Pool`-compatible oracle interface.

Minimal Decision Checklist

Before calling the MCP tool, confirm all six decisions:

1. **Hook type** — chosen from the decision table above 2. **Permissions to enable** — only the callbacks your logic actually uses (`beforeSwap`, `afterSwap`, etc.) 3. **Utility libraries** — `currencySettler`, `safeCast`, `transientStorage` as needed 4. **Shares** — `false`, `ERC20`, `ERC6909`, or `ERC1155` 5. **Access control** — `ownable`, `roles`, or `managed` 6. **Hook inputs** — `blockNumberOffset`, `maxAbsTickDelta` (only for hook types that use them)

Permission Configuration

All 14 permission flags with guidance on when to enable each. Start with all flags `false` and enable only what your hook logic requires. Every enabled permission increases the hook's attack surface and requires a specific bit to be set in the hook's deployed address (see address encoding note below).

| Permission Flag | Enable When | Risk | | --------------------------------- | --------------------------------------------------------------------------------------------------------------- | -------- | | `beforeInitialize` | You need to validate or restrict pool creation params | LOW | | `afterInitialize` | You need to set up state after a pool is created | LOW | | `beforeAddLiquidity` | You need to gate or transform LP deposits | MEDIUM | | `afterAddLiquidity` | You track LP positions or distribute rewards | LOW | | `beforeRemoveLiquidity` | You need lock-up periods or fee-on-exit logic | HIGH | | `afterRemoveLiquidity` | You track position removals for accounting | LOW | | `beforeSwap` | You modify swap behavior, apply dynamic fees, or block | HIGH | | `afterSwap` | You observe final swap state for oracles or accounting | MEDIUM | | `beforeDonate` | You restrict who may donate to the pool | LOW | | `afterDonate` | You track donation events

Read more
@uniswap
Ships withuniswap-ai

Uniswap-specific AI tools (skills, plugins, agents) for developers and AI agents integrating the Uniswap ecosystem.

23618 skills2 agents1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
236
Star history of uniswap/uniswap-ai on GitHub, a chart by star-history.com

Other skills on uniswap-ai.

configurator

configurator

Configure CCA (Continuous Clearing Auction) smart contract parameters through an interactive bulk form flow. Use when user says…

@uniswap@uniswapInstall Skill
deployer

deployer

Deploy CCA (Continuous Clearing Auction) smart contracts using the Factory pattern. Use when user says "deploy auction", "deploy…

@uniswap@uniswapInstall Skill
liquidity-planner

liquidity-planner

This skill should be used when the user asks to "provide liquidity", "create LP position", "add liquidity to pool", "become a…

@uniswap@uniswapInstall Skill
swap-planner

swap-planner

This skill should be used when the user asks to "swap tokens", "trade ETH for USDC", "exchange tokens on Uniswap", "buy tokens",…

@uniswap@uniswapInstall Skill
v4-security-foundations

v4-security-foundation…

Security-first Uniswap v4 hook development. Use when user mentions "v4 hooks", "hook security", "PoolManager", "beforeSwap",…

@uniswap@uniswapInstall Skill

More skills from other plugins.

1password

1password

Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.

openclaw11d395k
@steipete@steipeteInstall Skill
jira-tickets

jira-tickets

Read and update Jira tickets through Orca's saved Jira connections. Use when a task comes from Jira or the user asks for Jira…

orca9d128k
@stablyai@stablyaiInstall Skill
agentmail

agentmail

Use your assigned AgentMail inbox to read email tasks, explicitly send or reply, and check delivery. Provided automatically by…

paperclip10d114k
@paperclipai@paperclipaiInstall Skill
adr-create

adr-create

Create a new Architecture Decision Record with sequential numbering and AgentDB registration

@ruvnet@ruvnetInstall Skill

Questions about v4-hook-generator.

Which coding agents can use v4-hook-generator?
v4-hook-generator installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.