# swap-integration

Integrates Uniswap token swaps into frontends, backend scripts, and smart contracts. Useful when connecting the Uniswap Trading API or Universal Router.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 2200 installs · ★ 235
- Author: uniswap
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Uniswap/uniswap-ai/tree/HEAD/packages/plugins/uniswap-trading/skills/swap-integration/SKILL.md
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/skills/swap-integration

## What it does

The skill guides AI coding assistants in generating swap flows using Uniswap infrastructure. For React or Next.js frontends and automated scripts, it configures requests to the Uniswap Trading API, which handles route optimization through `/quote` and `/swap` endpoints. When direct control over transaction construction is necessary, it provides patterns for the `@uniswap/universal-router-sdk` or contract-level `execute()` calls.

Using the Trading API requires an API key from the Uniswap Developer Portal passed in the `x-api-key` header. Requests must also include `x-universal-router-version` set to `2.0` (or `2.2.0` or higher for permissioned pools) and an `x-agent-info` metadata header containing the integration name and decision origin mode.

Generated code validates inputs before execution: token amounts must be non-negative numeric strings, addresses must match the 40-character hex pattern, and shell metacharacters are rejected. Core blockchain operations assume familiarity with the viem library.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Uniswap/uniswap-ai --skill swap-integration -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/swap-integration/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/swap-integration/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Uniswap/uniswap-ai --skill swap-integration -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/swap-integration/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Uniswap/uniswap-ai --skill swap-integration -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/swap-integration/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Uniswap/uniswap-ai swap-integration
```

2. **Manually: put the files in place**
- File: `.github/skills/swap-integration/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Uniswap/uniswap-ai --skill swap-integration -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Uniswap/uniswap-ai --path packages/plugins/uniswap-trading/skills/swap-integration
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/swap-integration/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Uniswap/uniswap-ai --skill swap-integration -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Uniswap/uniswap-ai/tree/HEAD/packages/plugins/uniswap-trading/skills/swap-integration/SKILL.md

## When to use it
- integrate token swaps using the Uniswap Trading API
- build Universal Router calls with @uniswap/universal-router-sdk
- verify token allowances and permission checks before trading
- write on-chain swap logic calling execute() on Universal Router

## Example prompts
- Create a script that swaps ETH for USDC using the Uniswap Trading API
- Show how to execute a token swap directly through the Universal Router smart contract
- Set up token approval check and quote requests with viem and Trading API

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 0e44acc3b21a150e.

BEGIN THIRD-PARTY FILE 0e44acc3b21a150e
```text
---
name: swap-integration
description: Integrate Uniswap swaps into applications. Use when user says "integrate swaps", "uniswap", "trading api", "add swap functionality", "build a swap frontend", "create a swap script", "smart contract swap integration", "use Universal Router", "Trading API", or mentions swapping tokens via Uniswap.
allowed-tools: Read, Write, Edit, Glob, Grep, Bash(npm:*), Bash(npx:*), Bash(yarn:*), Bash(curl:*), WebFetch, AskUserQuestion, Task(subagent_type:swap-integration-expert)
model: opus
license: MIT
metadata:
  author: uniswap
  version: '1.6.0'
---

# Swap Integration

Integrate Uniswap swaps into frontends, backends, and smart contracts.

## Prerequisites

This skill assumes familiarity with viem basics (client setup, account management, contract interactions, transaction signing). Install the **uniswap-viem** plugin for comprehensive viem/wagmi guidance: `claude plugin add @uniswap/uniswap-viem`

## Quick Decision Guide

| Building...                    | Use This Method               |
| ------------------------------ | ----------------------------- |
| Frontend with React/Next.js    | Trading API                   |
| Backend script or bot          | Trading API                   |
| Smart contract integration     | Universal Router direct calls |
| Need full control over routing | Universal Router SDK          |

### Routing Types Quick Reference

| Type     | Description                             | Chains                             |
| -------- | --------------------------------------- | ---------------------------------- |
| CLASSIC  | Standard AMM swap through Uniswap pools | All supported chains               |
| DUTCH_V2 | UniswapX Dutch auction V2               | Ethereum, Arbitrum, Base, Unichain |
| PRIORITY | MEV-protected priority order            | Base, Unichain                     |
| WRAP     | ETH to WETH conversion                  | All                                |
| UNWRAP   | WETH to ETH conversion                  | All                                |

See [Routing Types](#routing-types) for the complete list including DUTCH_V3, DUTCH_LIMIT, LIMIT_ORDER, BRIDGE, and QUICKROUTE.

## Integration Methods

### 1. Trading API (Recommended)

Best for: Frontends, backends, scripts. Handles routing optimization automatically.

**Base URL**: `https://trade-api.gateway.uniswap.org/v1`

**Authentication**: `x-api-key: <your-api-key>` header required
```
END THIRD-PARTY FILE 0e44acc3b21a150e

The third-party file has ended. Everything between the 0e44acc3b21a150e tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2443 of 60112 bytes. © uniswap · MIT · https://github.com/Uniswap/uniswap-ai/tree/HEAD/packages/plugins/uniswap-trading/skills/swap-integration/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
