swap-integration
Integrate PancakeSwap swaps into applications. Use when user says "integrate swaps", "pancakeswap", "smart router", "add swap functionality", "build a swap frontend", "create a swap script", "smart contract swap integration", "use Universal Router", or mentions swapping tokens via PancakeSwap.
What this skill does
# Swap Integration
Integrate PancakeSwap swaps into frontends, backends, and smart contracts.
## Quick Decision Guide
| Building... | Use This Method |
| ------------------------------------------ | ------------------------------------------------------------------------------ |
| Quick quote or prototype | PancakeSwap Routing API (Method 1) |
| Frontend with React/Next.js | Smart Router SDK + Universal Router (Method 2) |
| Backend script or trading bot | Smart Router SDK + Universal Router (Method 2) |
| Simple V2 swap, smart contract | Direct V2 Router contract calls (Method 3) |
| Need exact Universal Router encoding | Universal Router SDK directly (Method 2) |
| Swap through Infinity (v4) CL or Bin pools | Routing API (Method 1) or Smart Router SDK with Infinity pool types (Method 2) |
### Protocol Types
| Protocol | Description | Fee Tiers (bps) | Chains |
| ------------ | ------------------------------------------------------------------------------------------------ | ----------------------- | ------------- |
| V2 | Classic AMM (xy=k), constant product formula | 25 (0.25%) | BSC only |
| V3 | Concentrated liquidity (Uniswap V3-compatible) | 1, 5, 25, 100 (0.01–1%) | All chains |
| StableSwap | Low-slippage for correlated/pegged assets | 1, 4 (0.01–0.04%) | BSC only |
| Infinity CL | Concentrated liquidity in the v4 singleton PoolManager; supports hooks for custom logic | Same tiers as V3 | BSC, Base |
| Infinity Bin | Fixed-price-bin liquidity (similar to Trader Joe v2); tight ranges, predictable bin-level prices | Configurable | BSC, Base |
| Mixed | Split route across any combination of the above protocols | N/A (composite) | BSC primarily |
## Supported Chains
| Chain | Chain ID | V2 | V3 | StableSwap | Infinity CL | Infinity Bin | RPC |
| ----------------------- | -------- | --- | --- | ---------- | ----------- | ------------ | ------------------------------------------------------------------------ |
| BNB Smart Chain | 56 | ✅ | ✅ | ✅ | ✅ | ✅ | `https://bsc-dataseed1.binance.org` |
| BNB Smart Chain Testnet | 97 | ✅ | ❌ | ❌ | ❌ | ❌ | `https://bsc-testnet-rpc.publicnode.com or https://bsc-testnet.drpc.org` |
| Ethereum | 1 | ❌ | ✅ | ❌ | ❌ | ❌ | `https://cloudflare-eth.com` |
| Arbitrum One | 42161 | ❌ | ✅ | ❌ | ❌ | ❌ | `https://arb1.arbitrum.io/rpc` |
| Base | 8453 | ❌ | ✅ | ❌ | ✅ | ✅ | `https://mainnet.base.org` |
| Polygon | 137 | ❌ | ✅ | ❌ | ❌ | ❌ | `https://polygon-rpc.com` |
| zkSync Era | 324 | ❌ | ✅ | ❌ | ❌ | ❌ | `https://mainnet.era.zksync.io` |
| Linea | 59144 | ❌ | ✅ | ❌ | ❌ | ❌ | `https://rpc.linea.build` |
| opBNB | 204 | ❌ | ✅ | ❌ | ❌ | ❌ | `https://opbnb-mainnet-rpc.bnbchain.org` |
> **For testing**: Use **BSC Testnet (chain ID 97)**. Get free testnet BNB from <https://testnet.bnbchain.org/faucet-smart>.
> The Smart Router SDK does not index testnet pools — use **Method 3 (Direct V2 Router)** on testnet.
## Key Token Addresses
### BSC Mainnet (Chain ID: 56)
| Token | Address |
| ----- | -------------------------------------------- |
| WBNB | `0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c` |
| BUSD | `0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56` |
| USDT | `0x55d398326f99059fF775485246999027B3197955` |
| USDC | `0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d` |
| CAKE | `0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82` |
| ETH | `0x2170Ed0880ac9A755fd29B2688956BD959F933F8` |
| BTCB | `0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c` |
### BSC Testnet (Chain ID: 97)
| Token | Address | Notes |
| -------- | -------------------------------------------- | ------------------- |
| WBNB | `0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd` | |
| CAKE | `0xFa60D973f7642b748046464E165A65B7323b0C73` | |
| BUSD | `0xeD24FC36d5Ee211Ea25A80239Fb8C4Cfd80f12Ee` | |
| V2Router | `0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3` | PancakeSwap testnet |
### Universal Router Addresses
| Chain | Chain ID | Universal Router Address |
| --------------- | -------- | -------------------------------------------- |
| BNB Smart Chain | 56 | `0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD` |
| Ethereum | 1 | `0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD` |
| Arbitrum | 42161 | `0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD` |
| Base | 8453 | `0x198EF79F1F515F02dFE9e3115eD9fC07183f02fC` |
| Polygon | 137 | `0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD` |
| zkSync Era | 324 | `0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD` |
| Linea | 59144 | `0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD` |
| opBNB | 204 | `0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD` |
---
## Method 1: PancakeSwap Routing API (Simplest)
Best for: Quick quotes, prototypes, and situations where you don't want to manage on-chain pool data yourself. No SDK installation required.
**Base URL**: `https://router.pancakeswap.finance/v0/quote`
### Get a Quote
```bash
# Exact input: 1 BNB → CAKE on BSC
curl -s "https://router.pancakeswap.finance/v0/quote?\
tokenInAddress=BNB\
&tokenInChainId=56\
&tokenOutAddress=0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82\
&tokenOutChainId=56\
&amount=1000000000000000000\
&type=exactIn\
&maxHops=3\
&maxSplits=4" | jq '{
amountOut: .trade.outputAmount,
priceImpact: .trade.priceImpact,
route: [.trade.routes[].type]
}'
```
### API Parameters
| Parameter | Type | Description |
| ----------------- | ------ | --------------------------------------------------- |
| `tokenInAddress` | string | Input token address or `"BNB"` / `"ETH"` for native |
| `tokenInChainId` | number | Input chain ID |
| `tokenOutAddress` | string | Output token address |
| `tokenOutChainId` | number | Output chain ID |
| `amount` | string | Amount in raw units (wei for 18-decimal tokens) |
| `type` | string | `"exactIn"` or `"exactOut"` |
| `maxHops` | number | Max hops per route (default: 3) |
| `maxSplits` | number | Max route splits (default: 4) |
> **Infinity (v4) support**: The Routing API automaticaRelated in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.