Swap Integration
Integrate Uniswap swaps into frontends, backends, and smart contracts using the Trading API, Universal Router SDK, or direct contract calls.
Invocation
/swap-integration
Or describe your requirements naturally:
Help me add Uniswap swap functionality to my Next.js app
What It Does
This skill helps you:
- Choose the right integration method: Trading API, Universal Router SDK, or direct smart contract calls
- Build swap flows: Frontend React hooks, backend Node.js scripts, and Solidity integrations
- Handle Permit2: Signature-based approvals, legacy approvals, and the rules for including permit data
- Avoid common pitfalls: Null field handling, swap request body format, pre-broadcast validation, and L2 WETH handling
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 |
Integration Methods
Trading API (Recommended)
REST API with a 3-step flow: check_approval -> quote -> swap. Handles routing optimization automatically across all Uniswap protocol versions.
Universal Router SDK
Direct SDK usage with @uniswap/universal-router-sdk for full control over transaction construction, including manual command building with RoutePlanner.
Smart Contract Integration
On-chain Solidity contracts calling the Universal Router's execute() function with encoded commands for DeFi composability.
Routing Types
| 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 |
Additional types include DUTCH_V3, DUTCH_LIMIT, LIMIT_ORDER, BRIDGE, and QUICKROUTE.
Key Topics Covered
- Trading API reference with request/response examples
- Universal Router command encoding and SDK patterns
- Permit2 integration (SignatureTransfer and AllowanceTransfer modes)
- UniswapX auction types by chain (Exclusive Dutch, Open Dutch, Priority Gas)
- ERC-4337 smart account integration
- Rate limiting and retry strategies
- Contract addresses for all supported chains
Related Resources
1---2name: swap-integration-33description: Integrate Uniswap swaps into frontends, backends, and smart contracts using the Trading API, Universal Router SDK, or direct contract calls.4---56# Swap Integration78Integrate Uniswap swaps into frontends, backends, and smart contracts using the Trading API, Universal Router SDK, or direct contract calls.910## Invocation1112```text13/swap-integration14```1516Or describe your requirements naturally:1718```text19Help me add Uniswap swap functionality to my Next.js app20```2122## What It Does2324This skill helps you:2526- **Choose the right integration method**: Trading API, Universal Router SDK, or direct smart contract calls27- **Build swap flows**: Frontend React hooks, backend Node.js scripts, and Solidity integrations28- **Handle Permit2**: Signature-based approvals, legacy approvals, and the rules for including permit data29- **Avoid common pitfalls**: Null field handling, swap request body format, pre-broadcast validation, and L2 WETH handling3031## Quick Decision Guide3233| Building... | Use This Method |34| ------------------------------ | ----------------------------- |35| Frontend with React/Next.js | Trading API |36| Backend script or bot | Trading API |37| Smart contract integration | Universal Router direct calls |38| Need full control over routing | Universal Router SDK |3940## Integration Methods4142### Trading API (Recommended)4344REST API with a 3-step flow: `check_approval` -> `quote` -> `swap`. Handles routing optimization automatically across all Uniswap protocol versions.4546### Universal Router SDK4748Direct SDK usage with `@uniswap/universal-router-sdk` for full control over transaction construction, including manual command building with `RoutePlanner`.4950### Smart Contract Integration5152On-chain Solidity contracts calling the Universal Router's `execute()` function with encoded commands for DeFi composability.5354## Routing Types5556| Type | Description | Chains |57| -------- | --------------------------------------- | ---------------------------------- |58| CLASSIC | Standard AMM swap through Uniswap pools | All supported chains |59| DUTCH_V2 | UniswapX Dutch auction V2 | Ethereum, Arbitrum, Base, Unichain |60| PRIORITY | MEV-protected priority order | Base, Unichain |61| WRAP | ETH to WETH conversion | All |62| UNWRAP | WETH to ETH conversion | All |6364Additional types include DUTCH_V3, DUTCH_LIMIT, LIMIT_ORDER, BRIDGE, and QUICKROUTE.6566## Key Topics Covered6768- Trading API reference with request/response examples69- Universal Router command encoding and SDK patterns70- Permit2 integration (SignatureTransfer and AllowanceTransfer modes)71- UniswapX auction types by chain (Exclusive Dutch, Open Dutch, Priority Gas)72- ERC-4337 smart account integration73- Rate limiting and retry strategies74- Contract addresses for all supported chains7576## Related Resources7778- [Uniswap Trading Plugin](/plugins/uniswap-trading) - Parent plugin79- [viem Integration](/skills/viem-integration) - Prerequisite EVM blockchain setup80- [Universal Router GitHub](https://github.com/Uniswap/universal-router) - Source code81- [Uniswap Docs](https://docs.uniswap.org) - Official documentation82- [Uniswap API Docs](https://api-docs.uniswap.org/introduction) - Official API documentation