Swap / DEX·EVM
KyberSwap
DEX aggregator across 25+ EVM chains plus its own Dynamic Market Maker (DMM / Elastic) AMM. Routes across hundreds of liquidity sources and supports RFQ liquidity in the v1 API.
- 01EVM swap aggregation
- 02RFQ + AMM hybrid routing
- 03wide L2 / sidechain coverage
- 04DMM concentrated-liquidity pools
- # KyberSwap is REST-first — no official JS SDK.
- pnpm add axios viem
| Variable | Scope | Description |
|---|---|---|
| KYBERSWAP_CLIENT_ID | Server | Optional `x-client-id` header value used by KyberSwap to identify the integrator and apply higher rate limits. Send on every request. |
Use the KyberSwap Aggregator v1 REST API for EVM swaps. Two-step flow: (1) `GET https://aggregator-api.kyberswap.com/{chain}/api/v1/routes?tokenIn=&tokenOut=&amountIn=&saveGas=false` returns `routeSummary`. (2) `POST https://aggregator-api.kyberswap.com/{chain}/api/v1/route/build` with `{ routeSummary, sender, recipient, slippageTolerance, deadline, source: '<your-app-id>' }` to get encoded calldata. Send `x-client-id: ${KYBERSWAP_CLIENT_ID}` on both calls. `chain` is a slug like `ethereum`, `arbitrum`, `base`, `polygon`, `bsc`, `optimism`, `avalanche`. Always use `/api/v1/*` — the unversioned endpoints are deprecated and do not include RFQ liquidity.
- ⚑Use the v1 API path (`/api/v1/routes` and `/api/v1/route/build`) — only v1 will continue to receive updates and only v1 includes RFQ liquidity sources.
- ⚑`slippageTolerance` is in basis points (e.g. `50` = 0.5%) on `route/build`, and must be high enough to cover RFQ requote drift if the route includes RFQ legs.
- ⚑Pass the entire `routeSummary` object back to `route/build` unmodified — the API rejects mutated summaries and the contract verifies route integrity.
- ⚑Chain identifier in the URL is a slug, not a `chainId` integer — `ethereum` not `1`. Mixing the two is the most common 404.
- ⚑Token approvals target the KyberSwap MetaAggregationRouterV2 (different address per chain); read it from the `route/build` response (`data.routerAddress`) rather than hardcoding.
- ⚑DMM Elastic pools and the aggregator are separate products — the aggregator already routes through DMM when optimal; do not call DMM contracts directly unless adding/removing liquidity.