Uniswap 架构与设计集成 - Openclaw Skills

作者:互联网

2026-03-27

AI教程

什么是 设计集成 (Uniswap)?

此技能通过将复杂的设计决策委托给专门的集成代理,赋能开发者构建复杂的 Uniswap 集成。它评估各种方法(如交易 API、Universal Router SDK 或直接智能合约交互),以为您的特定 Openclaw Skills 项目推荐最佳路径。

该技能提供集成的全局视图,确保架构模式、依赖版本和安全缓解措施符合 Permit2 和 viem 等行业最佳实践。通过使用此工具,开发者可以避免 DeFi 开发中的常见坑点,并确保其 dApp 构建在稳健、可扩展的基础之上。

下载入口:https://github.com/openclaw/skills/tree/main/skills/wpank/design-integration

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install design-integration

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 design-integration。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

设计集成 (Uniswap) 应用场景

  • 规划新的 DeFi 仪表板或钱包应用程序。
  • 设计具有优化路由逻辑套利机器人。
  • 在现有的 dApp 后端中实现兑换功能。
  • 将旧版 Uniswap 集成迁移到现代 SDK。
  • 构建利用 Uniswap V4 hook 的自定义 DeFi 协议。
设计集成 (Uniswap) 工作原理
  1. 系统从用户提示词中提取项目参数,包括功能(兑换/流动性)、环境和目标链。
  2. 它触发 Openclaw Skills 生态系统中专门的集成架构子代理来评估技术需求。
  3. 架构代理分析现有代码库或项目规范,以确定最佳集成方法(API 对比 SDK)。
  4. 进行详细的安全审查,以识别潜在的攻击向量和特定的缓解措施。
  5. 该技能生成结构化蓝图,包括组件数据流、依赖项列表和逐步实施计划。

设计集成 (Uniswap) 配置指南

要利用此架构技能,请确保您的环境已配置为支持子代理委托和 Uniswap MCP 注册表。

# 确保 Uniswap MCP 已连接到您的环境
# 该技能将自动调用:
# mcp__uniswap__get_supported_chains

在 Openclaw Skills 中初始化请求时,请提供有关项目类型(例如“钱包应用”)和功能(例如“兑换”)的详细信息,以获得最准确的架构输出。

设计集成 (Uniswap) 数据架构与分类体系

该技能将数据组织成结构化的集成蓝图,涵盖以下分类:

章节 描述
推荐方法 主要和备选集成策略(例如交易 API 对比 SDK)
架构 组件级数据流映射(用户 -> 报价服务 -> 执行器)
依赖项 viem、wagmi 和 @uniswap/sdk-core 等 NPM 包及其版本列表
安全 对陈旧报价和 Permit2 过期缓解等攻击向量的分析
实施 带有预估开发工作量的顺序任务列表
复杂度 对构建技术难度的总体评估
name: design-integration
description: >-
  Design a Uniswap integration architecture. Use when user is building a
  project that needs to integrate Uniswap and wants recommendations on
  integration method (Trading API vs SDK vs direct contract), architecture
  patterns, required dependencies, and security considerations.
allowed-tools: >-
  Read, Write, Edit, Glob, Grep,
  Task(subagent_type:integration-architect),
  mcp__uniswap__get_supported_chains
model: opus

Design Integration

Overview

Designs a complete Uniswap integration architecture for any project by delegating to the integration-architect agent. Produces a comprehensive blueprint covering: integration method recommendation (Trading API vs Universal Router SDK vs direct contract vs V4 hooks), component architecture, dependency list with versions, security review with mitigations, and ordered implementation plan.

When to Use

Activate when the user asks:

  • "Help me integrate Uniswap"
  • "Design a swap integration"
  • "Architecture for a DEX aggregator"
  • "How to build an arbitrage bot"
  • "Uniswap integration plan"
  • "How should I add swaps to my dApp?"
  • "Best way to integrate Uniswap in my backend"
  • "Architecture for a DeFi protocol that uses Uniswap"
  • "What SDK should I use for Uniswap?"

Parameters

Parameter Required Default Description
projectType Yes -- Type of project (e.g., "DeFi dashboard", "arb bot", "wallet app", "DeFi protocol")
functionality Yes -- Required Uniswap functionality: "swap", "LP", "both", or "custom"
environment No Auto-detect Execution environment: "frontend", "backend", "smart contract", or "full-stack"
chains No ethereum Target chain(s): single chain name or comma-separated list
scale No -- Expected scale: transaction volume, concurrent users, latency requirements

Workflow

  1. Extract parameters from the user's request: identify the project type, required functionality, target environment, chains, and scale requirements. If the user has an existing codebase, note it for the agent to analyze.

  2. Delegate to integration-architect: Invoke Task(subagent_type:integration-architect) with the full context. The integration-architect will:

    • Understand the project context and requirements
    • Evaluate integration methods and recommend primary + fallback
    • Design the component architecture with data flow
    • Identify all dependencies (NPM packages, APIs, infrastructure)
    • Perform a security review with attack vectors and mitigations
    • Produce an ordered implementation plan with effort estimates
  3. Present the blueprint to the user covering:

    • Integration method recommendation with clear rationale
    • Architecture overview (components, data flow, error handling)
    • Complete dependency list with versions and purposes
    • Security considerations with specific mitigations
    • Step-by-step implementation order with effort estimates
    • Overall complexity assessment

Output Format

Present a structured integration blueprint:

Integration Blueprint: DeFi Dashboard with Swap (Ethereum + Base)

  Recommended Method: Trading API (primary), Universal Router SDK (fallback)
  Rationale: Trading API provides optimized routing with minimal frontend
             complexity. Fallback to SDK for advanced use cases or API downtime.

  Architecture:
    User -> QuoteService -> ApprovalManager -> SwapExecutor -> Wallet -> Chain
    
    Components:
      QuoteService:      Fetches and caches quotes from Trading API
      ApprovalManager:   Manages Permit2 approvals and allowances
      SwapExecutor:      Constructs and submits swap transactions
      ChainManager:      Multi-chain config and RPC connections

  Dependencies:
    @uniswap/sdk-core    ^5.8.0    Token and price primitives
    viem                 ^2.21.0   Ethereum client
    wagmi                ^2.14.0   React wallet hooks
    @tanstack/react-query ^5.0.0   Data fetching and caching

  Security:
    - Stale quotes: Refresh every 15s, enforce deadline (block.timestamp + 300s)
    - Approvals: Permit2 with exact amounts and 30-min expiry
    - Key management: wagmi wallet connection only, never handle keys

  Implementation Order:
    1. Wallet connection (wagmi)           — 1 day
    2. Chain configuration                 — 0.5 days
    3. Quote fetching service              — 1 day
    4. Permit2 approval flow               — 1 day
    5. Swap execution and tracking         — 1.5 days
    6. Error handling and retry logic      — 1 day

  Complexity: Medium

Important Notes

  • This skill delegates entirely to the integration-architect agent -- it does not call MCP tools directly.
  • The blueprint is tailored to the specific project type and requirements -- not a generic template.
  • For existing codebases, the agent will analyze the current code and recommend integration patterns that fit the existing architecture.
  • The implementation order considers dependencies between components -- follow the order for smoothest development.
  • Always uses viem (not ethers.js) and Permit2 (not legacy approve) per project conventions.

Error Handling

Error User-Facing Message Suggested Action
VAGUE_PROJECT "Need more detail about your project to recommend an integration approach." Describe project type and what Uniswap functionality is needed
DEPRECATED_APPROACH "The requested integration method is deprecated. Recommending alternatives." Follow the updated recommendation
UNSUPPORTED_CHAIN "Uniswap is not deployed on the specified chain." Choose from the 11 supported chains
CONFLICTING_REQUIREMENTS "The requirements conflict (e.g., frontend + direct contract calls)." Clarify the execution environment and adjust expectations

相关推荐