← 返回 Skills 市场
wpank

Uniswap Build Hook

作者 wpank · GitHub ↗ · v0.1.0
cross-platform ⚠ suspicious
823
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install build-hook
功能描述
Build a Uniswap V4 hook. Use when user wants to create a custom V4 hook contract. Generates Solidity code, Foundry tests, mines CREATE2 address for hook flags, and produces deployment scripts. Handles the full hook development lifecycle.
使用说明 (SKILL.md)

Build Hook

Overview

Builds a complete Uniswap V4 hook by delegating to the hook-builder agent. Handles the full development lifecycle: understanding requirements, determining hook flags, generating Solidity contracts, generating Foundry tests, mining a CREATE2 address with correct flag bits, and producing deployment scripts. Returns production-ready code artifacts written directly to the project.

When to Use

Activate when the user asks:

  • "Build a V4 hook"
  • "Create a limit order hook"
  • "Build a dynamic fee hook"
  • "Create a TWAMM hook"
  • "Custom hook for V4"
  • "Hook that charges higher fees during volatility"
  • "Build a hook that distributes LP fees to stakers"
  • "Create a hook with oracle integration"

Parameters

Parameter Required Default Description
behavior Yes -- Hook behavior description (e.g., "limit orders", "dynamic fees", "TWAMM", "oracle-based pricing")
callbacks No Auto-detect Specific V4 callbacks if the user knows them (e.g., "beforeSwap, afterSwap")
constraints No -- Gas budget, security requirements, or specific design constraints
chain No ethereum Target chain for deployment (affects PoolManager address)

Workflow

  1. Extract parameters from the user's request: identify the hook behavior, any explicitly mentioned callbacks, constraints, and target chain.

  2. Delegate to hook-builder: Invoke Task(subagent_type:hook-builder) with the full context. The hook-builder agent will:

    • Understand the requirements and determine which callbacks are needed
    • Map callbacks to hook flags and validate the flag combination
    • Generate a Solidity contract extending BaseHook with proper NatSpec
    • Generate comprehensive Foundry tests (unit, integration, edge cases, gas snapshots)
    • Mine a CREATE2 salt that produces an address encoding the required flags
    • Produce a deployment script with verification steps
  3. Present results to the user with a summary covering:

    • Files written (contract path, test path, deployment script path)
    • Hook architecture explanation (what it does, how state flows)
    • Callbacks implemented and their flag bitmask
    • Gas estimates per callback (from Foundry test output)
    • Next steps for the developer (run tests, deploy to testnet, mainnet considerations)

Output Format

Present a summary followed by the generated files:

V4 Hook Built: LimitOrderHook

  Contract:   src/hooks/LimitOrderHook.sol (187 lines)
  Tests:      test/hooks/LimitOrderHook.t.sol (12 tests)
  Deployment: script/DeployLimitOrderHook.s.sol

  Callbacks: beforeSwap, afterSwap
  Flags:     0x00C0
  CREATE2:   Salt mined, address verified

  Gas Estimates:
    beforeSwap: ~45,000 gas
    afterSwap:  ~32,000 gas
    Total overhead per swap: ~77,000 gas

  Architecture:
    Orders are placed at specific ticks and stored in an on-chain order book.
    During beforeSwap, the hook checks for matching orders at the target tick.
    Matched orders are filled atomically within the same transaction.

  Next Steps:
    1. Run tests: forge test --match-contract LimitOrderHookTest
    2. Deploy to testnet: forge script script/DeployLimitOrderHook.s.sol --rpc-url sepolia
    3. Verify on Etherscan: forge verify-contract \x3Caddress> LimitOrderHook

Important Notes

  • This skill delegates entirely to the hook-builder agent -- it does not call MCP tools directly.
  • The hook-builder generates production-quality Solidity code with reentrancy protection and access control.
  • CREATE2 address mining ensures the deployed address encodes the correct hook flags in its leading bytes (required by V4 PoolManager).
  • Foundry must be installed for test generation and compilation. If not found, the skill will provide installation instructions.
  • Generated code uses Solidity ^0.8.26 and imports from @uniswap/v4-core and @uniswap/v4-periphery.

Error Handling

Error User-Facing Message Suggested Action
INVALID_CALLBACK_COMBINATION "The requested behavior requires conflicting callbacks." Simplify hook behavior or split into multiple hooks
CREATE2_MINING_TIMEOUT "Could not mine a valid CREATE2 address within time limit." Increase mining time limit or reduce required flags
FORGE_NOT_INSTALLED "Foundry (forge) is required but not installed." Install: curl -L https://foundry.paradigm.xyz | bash && foundryup
VAGUE_REQUIREMENTS "Need more detail about the desired hook behavior." Describe specific behavior (e.g., "limit orders that execute at tick boundaries")
COMPILATION_ERROR "Generated contract has compilation errors." Review error output and adjust requirements
安全使用建议
This skill is internally consistent with its purpose, but take these precautions before installing or running it: 1) Verify the provenance — the README points to a GitHub path but the skill metadata lists the source as unknown; confirm the repository and author. 2) Review the hook-builder subagent implementation (Task(subagent_type:hook-builder)) because the skill delegates full code generation and mining to that agent and it could perform additional actions. 3) Expect CREATE2 mining to be CPU/time intensive; test on a dev machine or CI with resource limits. 4) Carefully review generated deployment scripts before using them — they will need RPC URLs and private keys to deploy; never paste private keys into third-party agents and prefer using environment-based or hardware wallet signing. 5) The suggested Foundry install uses curl | bash — if you accept that, run it only from the official Foundry sources and on trusted machines. If you want a lower-risk path, ask the skill to provide code only (no automatic mining or deployment scripts) so you can run compilation/mining locally under your control.
功能分析
Type: OpenClaw Skill Name: build-hook Version: 0.1.0 The `SKILL.md` file grants the AI agent access to powerful `Bash` tools, specifically `Bash(forge:*)`, `Bash(npm:*)`, and `Bash(git:*)`. While `forge` is directly relevant to the skill's stated purpose of Uniswap V4 hook development, the inclusion of `npm` and `git` provides broad capabilities for package installation, arbitrary script execution, and repository interaction. These tools, even if scoped, present significant attack surface for supply chain attacks or data exfiltration if the agent is prompted maliciously. Additionally, the `SKILL.md` includes a `curl | bash` command as a suggested installation step for Foundry in its error handling, which, while intended for the user, represents a risky execution pattern that could be exploited via prompt injection if the agent misinterprets its instructions. There is no clear evidence of intentional malicious behavior within the provided files, but the broad permissions and potential for misuse classify this as suspicious.
能力评估
Purpose & Capability
The name and description match what the SKILL.md instructs: generate Solidity, tests, CREATE2 mining and deployment scripts. Allowed tools (forge/npm/git, Task(subagent_type:hook-builder), an MCP getter) are appropriate for that workflow. Minor inconsistency: SKILL.md says it 'does not call MCP tools directly' but mcp__uniswap__get_supported_chains appears in allowed-tools; also the README lists a GitHub install path while the skill metadata marks source as unknown — you should verify the subagent and repo origin before use.
Instruction Scope
Instructions stay within the described development workflow and do not ask to read unrelated system files or credentials. However the skill delegates all behavior to a Task(subagent_type:hook-builder); that subagent could expand scope (read files, request secrets, call external endpoints). The skill itself does not include guardrails requiring code review of generated artifacts.
Install Mechanism
This is an instruction-only skill with no install spec (lowest disk risk). The SKILL.md includes a suggested Foundry install command (curl ... | bash) in its error/help text — a common but higher-risk convenience pattern; the skill won't automatically run it, it only suggests it to the user.
Credentials
The skill requests no environment variables or credentials, which is proportionate. Be aware generated deployment scripts will typically require RPC URLs and private keys to deploy — the skill does not request those but the developer will need to provide them; review scripts to ensure they don't hard-code or exfiltrate secrets.
Persistence & Privilege
always is false and the skill does not request persistent system changes. It delegates to a subagent but does not claim to modify other skills or global agent config.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install build-hook
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /build-hook 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Initial release: build Uniswap V4 hooks end-to-end. - Generates custom V4 hook contracts based on user requirements. - Produces Solidity code, Foundry tests, CREATE2-mined address for flag encoding, and deployment scripts. - Extracts parameters from natural language prompts (behavior, callbacks, constraints, chain). - Summarizes generated artifacts, hook architecture, callbacks with gas estimates, and next steps. - Handles errors such as missing Foundry install, vague requirements, compilation failure, or CREATE2 mining timeouts.
元数据
Slug build-hook
版本 0.1.0
许可证
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Uniswap Build Hook 是什么?

Build a Uniswap V4 hook. Use when user wants to create a custom V4 hook contract. Generates Solidity code, Foundry tests, mines CREATE2 address for hook flags, and produces deployment scripts. Handles the full hook development lifecycle. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 823 次。

如何安装 Uniswap Build Hook?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install build-hook」即可一键安装,无需额外配置。

Uniswap Build Hook 是免费的吗?

是的,Uniswap Build Hook 完全免费(开源免费),可自由下载、安装和使用。

Uniswap Build Hook 支持哪些平台?

Uniswap Build Hook 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Uniswap Build Hook?

由 wpank(@wpank)开发并维护,当前版本 v0.1.0。

💬 留言讨论