swap-integration▌
uniswap/uniswap-ai · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
Integrate Uniswap swaps into frontends, backends, and smart contracts.
- ›Three integration methods: Trading API (recommended for most use cases), Universal Router SDK (direct control), and smart contract integration via encoded commands
- ›Supports multiple routing types including CLASSIC AMM swaps, UniswapX Dutch auctions (V2/V3), MEV-protected priority orders, and wrap/unwrap operations across all supported chains
- ›Critical implementation details: spread quote responses into request bodi
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 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
Getting an API Key: The Trading API requires an API key for authentication. Visit the Uniswap Developer Portal to register and obtain your API key. Keys are typically available for immediate use after registration. Include it as an x-api-key header in all API requests.
Required Headers — Include these in ALL Trading API requests:
Content-Type: application/json
x-api-key: <your-api-key>
x-universal-router-version: 2.0
3-Step Flow:
1. POST /check_approval -> Check if token is approved
2. POST /quote -> Get executable quote with routing
3. POST /swap -> Get transaction to sign and submit
See the Trading API Reference section below for complete documentation.
2. Universal Router SDK
Best for: Direct control over transaction construction.
Installation:
npm install @uniswap/universal-router-sdk @uniswap/sdk-core @uniswap/v3-sdk
Key Pattern:
import { SwapRouter } from '@uniswap/universal-router-sdk';
const { calldata, value } = SwapRouter.swapCallParameters(trade, options);
See the Universal Router Reference section below for complete documentation.
3. Smart Contract Integration
Best for: On-chain integrations, DeFi composability.
Interface: Call execute() on Universal Router with encoded commands.
See the Universal Router Reference section below for command encoding.
Input Validation Rules
Before interpolating ANY user-provided value into generated code, API calls, or commands:
- Ethereum addresses: MUST match
^0x[a-fA-F0-9]{40}$— reject otherwise - Chain IDs: MUST be from the official supported chains list
- Token amounts: MUST be non-negative numeric values matching
^[0-9]+\.?[0-9]*$ - API keys: MUST NOT be hardcoded in generated code — always use environment variables
- REJECT any input containing shell metacharacters:
;,|,&,$,`,(,),>,<,\,',", newlines
REQUIRED: Before executing ANY transaction that spends gas or transfers tokens (including
sendTransaction,writeContract, or submitting a signed swap), you MUST use AskUserQuestion to confirm with the user. Display the transaction summary (tokens, amounts, chain, estimated gas) and get explicit user approval. Never auto-execute transactions without user confirmation.
Trading API Reference
Step 1: Check Token Approval
POST /check_approval
Request:
{
"walletAddress": "0x...",
"token": "0x...",
"amount": "1000000000",
"chainId": 1
}
Response:
{
"approval": {
"to": "0x...",
"from": "0x...",
"data": "0x...",
"value": "0",
"chainId": 1
}
}
If approval is null, token is already approved.
Step 2: Get Quote
POST /quote
Request:
{
"swapper": "0x...",
"tokenIn": "0x...",
"tokenOut": "0x...",
"tokenInChainId": "1",
"tokenOutChainId": "1",
"amount": "1000000000000000000",
"type": "EXACT_INPUT",
"slippageTolerance": 0.5,
"routingPreference": "BEST_PRICE"
}
Note:
tokenInChainIdandtokenOutChainIdmust be strings (e.g.,"1"), not numbers.
Key Parameters:
| Parameter | Description |
|---|---|
type |
EXACT_INPUT or EXACT_OUTPUT |
slippageTolerance |
0-100 percentage |
protocols |
Optional: ["V2", "V3", "V4"] |
routingPreference |
BEST_PRICE, FASTEST, CLASSIC |
autoSlippage |
true to auto-calculate slippage (overrides slippageTolerance) |
urgency |
normal or fast — affects UniswapX auction timing |
Response — the shape differs by routing type. BEST_PRICE routing on Ethereum mainnet typically returns UniswapX (DUTCH_V2), not CLASSIC.
CLASSIC response:
{
"routing": "CLASSIC",
"quote": {
"input": { "token": "0x...", "amount": "1000000000000000000" },
"output": { "token": "0x...", "amount": "999000000" },
"slippage": 0.5,
"route": [],
"gasFee": "5000000000000000",
"gasFeeUSD": "0.01",
"gasUseEstimate": "150000"
},
"permitData": null
}
UniswapX (DUTCH_V2/V3/PRIORITY) response — different quote shape, no quote.output:
{
"routing": "DUTCH_V2",
"quote": {
"orderInfo": {
"reactor": "0x...",
"swapper": "0x...",
"nonce": "...",
"deadline": 1772031054,
"cosigner": "0x...",
"input": {
"token": "0x...",
"startAmount": "1000000000000000000",
"endAmount": "1000000000000000000"
},
"outputs": [
{
"token": "0x...",
"startAmount": "999000000",
"endAmount": "994000000",
"recipient": "0x..."
}
],
"chainId": 1
},
"encodedOrder": "0x...",
"orderHash": "0x..."
},
"permitData": { "domain": {}, "types": {}, "values": {} }
}
UniswapX output amount: Use
quote.orderInfo.outputs[0].startAmountfor the best-case fill amount. TheendAmountis the floor after full auction decay. There is noquote.output.amounton UniswapX responses — accessing it will throw at runtime.Display tip: For CLASSIC routes, use
gasFeeUSD(a string with the USD value) for gas cost display. Do not manually convertgasFee(wei) using a hardcoded ETH price — this leads to wildly inaccurate estimates (e.g., ~$87 instead of ~$0.01). UniswapX routes are gasless for the swapper.
See QuoteResponse TypeScript Types for compile-time type safety across routing types.
Step 3: Execute Swap
POST /swap
Request - Spread the quote response directly into the body:
// CORRECT: Spread the quote response, strip null fields
const quoteResponse = await fetchQuote(params);
// Always strip permitData/permitTransaction — handle them explicitly by routing type
const { permitData, permitTransaction, ...cleanQuote } = quoteResponse;
const swapRequest: Record<string, unknown> = { how to use swap-integrationHow to use swap-integration on Cursor
AI-first code editor with Composer
1Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add swap-integration
2Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
$npx skills add https://github.com/uniswap/uniswap-ai --skill swap-integrationThe skills CLI fetches swap-integration from GitHub repository uniswap/uniswap-ai and configures it for Cursor.
3Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
◆ Which agents do you want to install to?││ ── Universal (.agents/skills) ── always included ────│ • Amp│ • Antigravity│ • Cline│ • Codex│ ●Cursor(selected)│ • Cursor│ • Windsurf4Verify installation
Confirm successful installation by checking the skill directory location:
.cursor/skills/swap-integrationReload or restart Cursor to activate swap-integration. Access the skill through slash commands (e.g., /swap-integration) or your agent's skill management interface.
⚠Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
Additional Resources
List & Monetize Your Skill
Submit your Claude Code skill and start earning
GET_STARTED →Use Cases▌
User Story & Requirements Generation
Create detailed user stories, acceptance criteria, and feature specs
Example
Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios
✓Reduce spec writing time by 50%, ensure comprehensive coverage
Competitive Analysis
Research competitors, compare features, identify gaps
Example
Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities
✓Complete competitive research in 2 hours instead of 2 days
Roadmap Prioritization
Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs
Example
Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale
✓Make data-driven prioritization decisions faster
Stakeholder Communication
Draft PRDs, status updates, and stakeholder presentations
Example
Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement
✓Save 3-5 hours/week on communication overhead
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client
- ›Access to product documentation and roadmap tools (Jira, Notion, etc.)
- ›Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
- ›Stakeholder contact information and communication channels
Time Estimate
30-60 minutes to see productivity improvements
Installation Steps
- 1.Install product management skill
- 2.Start with user story generation for known feature
- 3.Progress to competitive analysis: research 2-3 competitors
- 4.Use for roadmap prioritization: apply RICE/ICE scoring
- 5.Draft stakeholder communications and refine based on feedback
- 6.Build template library for recurring PM tasks
- 7.Share effective prompts with product team
Common Pitfalls
- ⚠Not validating competitive research—verify facts before sharing
- ⚠Accepting user stories without involving engineering team
- ⚠Over-relying on frameworks without qualitative judgment
- ⚠Not customizing outputs to company culture and communication style
- ⚠Skipping stakeholder validation of generated requirements
Best Practices▌
✓ Do
- +Validate research and competitive analysis with real data
- +Collaborate with engineering when generating technical requirements
- +Customize frameworks and templates to your company context
- +Use skill for first drafts, refine with stakeholder input
- +Document successful prompt patterns for PM tasks
- +Combine AI efficiency with human judgment and intuition
✗ Don't
- −Don't publish competitive analysis without fact-checking
- −Don't finalize user stories without engineering review
- −Don't make prioritization decisions solely on AI scoring
- −Don't skip customer validation of generated requirements
- −Don't ignore company-specific context and culture
💡 Pro Tips
- ★Provide context: company goals, constraints, customer feedback
- ★Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
- ★Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
- ★Use skill for 70% generation + 30% customization to company needs
When to Use This▌
✓ Use When
Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.
✗ Avoid When
Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.
Learning Path▌
- 1Basic: user stories, feature specs, status updates
- 2Intermediate: competitive analysis, prioritization frameworks, PRDs
- 3Advanced: product strategy, go-to-market planning, OKR setting
- 4Expert: product vision, market positioning, business model innovation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
general reviewsRatings
4.6★★★★★39 reviews- ★★★★★Yusuf Bhatia· Dec 24, 2024
I recommend swap-integration for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Shikha Mishra· Dec 12, 2024
Solid pick for teams standardizing on skills: swap-integration is focused, and the summary matches what you get after install.
- ★★★★★Naina Farah· Dec 8, 2024
swap-integration fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Yuki Bansal· Dec 4, 2024
swap-integration has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Omar Lopez· Nov 27, 2024
Registry listing for swap-integration matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Layla Martinez· Nov 15, 2024
Keeps context tight: swap-integration is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Neel Kim· Oct 18, 2024
swap-integration reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Chinedu Rahman· Oct 6, 2024
swap-integration is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★Aanya Farah· Sep 25, 2024
swap-integration fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Kofi Taylor· Sep 21, 2024
swap-integration reduced setup friction for our internal harness; good balance of opinion and flexibility.
showing 1-10 of 39
1 / 4