3.2 KiB

CLAUDE.md - uniswap-trading Plugin

Overview

This plugin provides comprehensive guidance for integrating Uniswap swaps into frontends, backends, and smart contracts. It supports the Trading API, Universal Router SDK, and direct smart contract integration.

Plugin Components

Skills (./skills/)

  • swap-integration: Comprehensive guide for integrating Uniswap swaps via Trading API, Universal Router SDK, or direct smart contract calls. Covers frontend hooks, backend scripts, Solidity integrations, Permit2 patterns, ERC-4337 smart account integration, L2 WETH handling, rate limiting, and troubleshooting.
  • pay-with-any-token: Pay HTTP 402 Payment Required challenges (MPP and x402) by swapping or bridging tokens via the Uniswap Trading API. Supports WWW-Authenticate header-based and JSON body-based MPP challenges, cross-chain bridging to Tempo, and automatic stablecoin swaps.
  • v4-sdk-integration: App-layer SDK guide for building swap and liquidity experiences directly with the Uniswap v4 SDK. Covers V4Planner swap construction, Quoter callStatic, StateView pool reads, PositionManager multicall operations, and Permit2 approval flow.

Agents (./agents/)

  • swap-integration-expert: Expert agent for complex Uniswap swap integration questions, Trading API debugging, Universal Router encoding, Permit2 patterns, ERC-4337 smart account integration, and L2-specific patterns.

File Structure

uniswap-trading/
├── .claude-plugin/
│   └── plugin.json
├── agents/
│   └── swap-integration-expert.md
├── skills/
│   ├── swap-integration/
│   │   ├── SKILL.md
│   │   └── references/
│   │       └── advanced-patterns.md
│   ├── pay-with-any-token/
│   │   ├── SKILL.md
│   │   └── references/
│   │       ├── trading-api-flows.md
│   │       └── credential-construction.md
│   └── v4-sdk-integration/
│       └── SKILL.md
├── project.json
├── package.json
├── CLAUDE.md
└── README.md

Integration Methods

  1. Trading API (Recommended for most use cases)

    • REST API at https://trade-api.gateway.uniswap.org/v1
    • Handles routing optimization automatically
    • 3-step flow: check_approval -> quote -> swap
  2. Universal Router SDK

    • Direct SDK usage with @uniswap/universal-router-sdk
    • Full control over transaction construction
    • Command-based architecture
  3. Direct Smart Contract Integration

    • Solidity contracts calling Universal Router
    • For on-chain integrations and DeFi composability

Supported Chains

See the official supported chains list for the current set of chains supported by the Trading API.

  • uniswap-viem: Foundational EVM blockchain integration using viem/wagmi (prerequisite knowledge)
  • uniswap-hooks: Uniswap v4 hook development with security-first approach

Key References

  • Trading API: https://trade-api.gateway.uniswap.org/v1
  • Universal Router: github.com/Uniswap/universal-router
  • SDKs: @uniswap/universal-router-sdk, @uniswap/v3-sdk, @uniswap/sdk-core
  • Permit2: Token approval infrastructure