swap-integration
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.
Security Assessment
Detected risks:
About swap-integration
swap-integration is Uniswap's official skill for building token-swap functionality into frontends, backend scripts/bots, and smart contracts. It solves the routing and integration complexity of on-chain trading by pointing developers at the right method for their context: the hosted Trading API for apps and scripts, the Universal Router SDK for direct transaction construction, and direct Universal Router `execute()` calls for on-chain composability. A decision table and routing-type reference (CLASSIC, UniswapX Dutch auctions, MEV-protected priority orders, wrap/unwrap, bridge, and more) help pick an approach per chain.
The documented Trading API flow is a three-step sequence — check approval, get a quote, then request a signable swap transaction — authenticated with an `x-api-key` header obtained from the Uniswap Developer Portal. The skill includes concrete request/response shapes, key parameters (slippage tolerance, exact-input/output, routing preference, urgency), and installation snippets for the SDK packages.
Notably, the skill is security-conscious: it mandates strict input validation before interpolating any user value (regex-checked Ethereum addresses, numeric amounts, chain IDs from the official list), forbids hardcoding API keys, rejects shell metacharacters, and requires an explicit user-confirmation prompt before any transaction that spends gas or transfers tokens. It targets web3 and DeFi developers integrating swaps. Because generated code can construct and submit value-transferring on-chain transactions, the capability is financially sensitive, though the built-in confirmation gate and validation rules substantially mitigate accidental or unauthorized fund movement.
FAQ
Which integration method should I use?
Use the Trading API for React/Next.js frontends, backend scripts, and bots; use the Universal Router SDK when you need full control over transaction construction; and call the Universal Router directly for smart-contract/on-chain integrations.
What are the prerequisites?
Familiarity with viem basics is assumed, and the Trading API requires an API key registered at the Uniswap Developer Portal, sent as an x-api-key header along with a universal-router-version header on every request.
How does it prevent unsafe transactions?
It requires validating and rejecting malformed addresses, amounts, chain IDs, and inputs containing shell metacharacters, forbids hardcoded keys, and mandates an explicit user-confirmation step showing the transaction summary before any gas-spending or token-transferring transaction is executed.
What chains and routing types are supported?
It documents CLASSIC AMM swaps across all supported chains plus UniswapX routing (DUTCH_V2/V3, priority orders, limit orders), wrap/unwrap, bridge, and quickroute, with per-type chain availability noted in the reference table.
Install swap-integration
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
uniswap/uniswap-ai