Uniswap V4 Hooks

Implement Uniswap V4 hooks with BaseHook, permission flags, and HookMiner.

Updated Nov 5, 2025
One-click install
npx skills add https://github.com/cyotee/crane --skill uniswap-v4-hooks-cyotee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Uniswap V4 Hooks
Source: https://github.com/cyotee/crane/tree/main/.claude/skills/uniswap-v4-hooks
Command: npx skills add https://github.com/cyotee/crane --skill uniswap-v4-hooks-cyotee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Hooks enable Uniswap V4 pool customization by allowing external contracts to react to key lifecycle events. This skill helps developers understand and implement a hook system to modify swap behavior, fees, access control, and oracle interactions.

Core Features & Use Cases

  • Hook interface and permission flags
  • BaseHook abstraction
  • HookMiner for deterministic addresses
  • BeforeSwapDelta usage
  • Example hooks like Swap Fee Hook and Access Control Hook
  • Flow of callback events (beforeSwap/afterSwap)

Quick Start

Deploy a minimal whitelist hook using the BaseHook example and attach it to a pool via HookMiner with the desired flags.

Frequently Asked Questions about Uniswap V4 Hooks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement Uniswap V4 hooks for custom swap fees and access control?

To implement Uniswap V4 hooks, use a base hook contract to define custom logic for dynamic fees and access control. This framework provides the necessary permission flags and callback interfaces to modify pool operations during swaps and liquidity changes.

What are Uniswap V4 permission flags and how do they work with smart contracts?

Uniswap V4 permission flags are settings that dictate which lifecycle callbacks a hook receives, such as beforeSwap or afterSwap. They enable smart contracts to execute specific access control or dynamic fee logic when triggered by pool operations.

How do I use HookMiner to find a deterministic address for my Uniswap V4 hook?

Use HookMiner to calculate a deterministic address for your Uniswap V4 hook by mining for the specific permission flags required. This process ensures your smart contract deploys to an address that matches the required prefix for pool attachment.

Can I use Uniswap V4 hooks to build a custom oracle for liquidity pools?

Yes, you can build a custom oracle using Uniswap V4 hooks by implementing logic within the beforeSwap and afterSwap callbacks. This allows smart contracts to capture and store price data dynamically during pool operations.

What is BeforeSwapDelta in Uniswap V4 hook development?

BeforeSwapDelta is a value used in Uniswap V4 hooks to calculate and return custom swap deltas. It allows developers to modify the exact token amounts exchanged during a swap operation within the beforeSwap callback.

Does BaseHook abstraction support both beforeSwap and afterSwap interactions?

Yes, the BaseHook abstraction supports both beforeSwap and afterSwap interactions. It provides a structured flow for smart contracts to execute custom logic before and after pool operations occur.