4.4 KiB
4.4 KiB
title, order
| title | order |
|---|---|
| v4 Hook Generator | 4 |
v4 Hook Generator
Generate Uniswap v4 hook contracts using the OpenZeppelin Contracts Wizard MCP. Select the right hook type, configure permissions and utilities, and produce the canonical MCP tool call JSON — all guided by a structured decision workflow.
Invocation
/v4-hook-generator
Or describe what you want to build:
"Generate a v4 hook with dynamic fees based on volatility"
"Create a hook that implements custom accounting for my AMM curve"
What It Does
This skill guides you through the full hook generation workflow:
- Select a hook type from a 14-type decision table matched to your goal
- Configure permissions — choose only the flags your hook needs, with guidance on address encoding implications
- Choose utility libraries —
currencySettler,safeCast,transientStoragewith when-to-use notes - Set shares and access control —
false,ERC20,ERC6909,ERC1155shares;ownable,roles,managedaccess - Assemble the MCP tool call JSON — produces the canonical schema ready to pass to the OpenZeppelin MCP tool
- Hand off to security review — prompts you to run
v4-security-foundationson the generated code
Hook Type Decision Table
| Goal | Hook Type |
|---|---|
| General-purpose hook | BaseHook |
| Async/off-chain swap execution | BaseAsyncSwap |
| Custom accounting logic | BaseCustomAccounting |
| Custom AMM curve | BaseCustomCurve |
| Dynamic fee based on pool state | BaseDynamicFee |
| Override fee per swap | BaseOverrideFee |
| Dynamic fee applied after swap | BaseDynamicAfterFee |
| Fee distribution to hook | BaseHookFee |
| MEV / sandwich protection | AntiSandwichHook |
| Liquidity penalty enforcement | LiquidityPenaltyHook |
| On-chain limit orders | LimitOrderHook |
| LP position re-hypothecation | ReHypothecationHook |
| Price oracle | BaseOracleHook |
| Oracle with Uniswap v3 adapters | OracleHookWithV3Adapters |
MCP Tool Call Schema
The skill assembles and outputs a JSON object conforming to the OpenZeppelin Contracts Wizard MCP tool schema:
{
"hook": "<HookTypeName>",
"name": "MyHook",
"pausable": false,
"currencySettler": false,
"safeCast": false,
"transientStorage": false,
"shares": {
"options": false
},
"permissions": {
"beforeInitialize": false,
"afterInitialize": false,
"beforeAddLiquidity": false,
"afterAddLiquidity": false,
"beforeRemoveLiquidity": false,
"afterRemoveLiquidity": false,
"beforeSwap": false,
"afterSwap": false,
"beforeDonate": false,
"afterDonate": false,
"beforeSwapReturnDelta": false,
"afterSwapReturnDelta": false,
"afterAddLiquidityReturnDelta": false,
"afterRemoveLiquidityReturnDelta": false
},
"inputs": {},
"access": "ownable",
"info": {
"license": "MIT"
}
}
Key Topics Covered
- Hook type selection: Match your goal to one of 14 OpenZeppelin base hook types using the decision table
- Permission flags: All 14 flags explained with risk guidance; note that permissions encode into the hook address and HookMiner may be needed
- Utility libraries: When to use
currencySettler(token settlement),safeCast(integer casting), andtransientStorage(intra-transaction state) - Shares configuration: Trade-offs between
false(no LP shares),ERC20,ERC6909, andERC1155 - Access control: How
ownable,roles, andmanagedeach change the constructor shape - Hook inputs: Which hook types use
blockNumberOffsetandmaxAbsTickDelta - Security handoff: MCP returns code only (does not write files) — always follow up with
v4-security-foundations
Related Resources
- Uniswap Hooks Plugin - Parent plugin
- v4 Security Foundations - Security review companion skill (run after generation)
- Uniswap v4 Docs - Official documentation
- OpenZeppelin Contracts Wizard - Underlying generation tool