A swap is a transaction that exchanges one token for another, enabling automated trading, arbitrage opportunities, and sophisticated DeFi front-end applications.
The Swap API provides real-time price discovery across multiple DEXes, enabling traders to access deep liquidity pools and execute at the best available prices. For the smoothest developer experience, use CDP Swap API with our Wallets - supporting both regular accounts (EOAs) and Smart Accounts with gas sponsorship.
We also support the use of external wallet libraries like viem and web3.py for building with your own infrastructure.
The Swap API supports two main approaches for executing swaps, both compatible with regular accounts (EOAs) and Smart Accounts:
Approach | Features | Account Types | Best For |
---|---|---|---|
CDP Wallet | • Managed infrastructure • Automatic signing • Built-in security • USDC rewards • Gas sponsorship | • EOAs • Smart Accounts | Most use cases |
External Library | • Full control • Custom wallet infrastructure • BYO account | • EOAs • Smart Accounts (with setup) | Advanced needs |
Both options include slippage protection and optimized gas fees. Smart Accounts additionally support optional gas sponsorship through paymasters.
The Swap API provides unmatched advantages for building trading applications and automated strategies over existing aggregator solutions:
Feature | Swap API | Traditional Solutions |
---|---|---|
Infrastructure | ✅ Zero setup required | ❌ Complex self-hosting |
Execution Speed | ✅ Sub-500ms latency | ❌ 1-3 second delays |
Bot Development | ✅ Native wallet integration | ❌ Manual key management |
Multi-strategy Support | ✅ Concurrent execution | ❌ Sequential only |
Gas Management | ✅ Automatic optimization | ❌ Manual configuration |
Slippage Protection | ✅ MEV-aware routing | ❌ Manual implementation |
More on swap aggregators
Performing a token swap involves finding a place to execute the trade (also known as a liquidity pool). These liquidity pools are inside decentralized exchanges (DEXes).
An aggregator powers swap routing through various DEXes (Uniswap, SushiSwap, Curve, Balancer, etc.) to get the best possible price. Instead of interacting with a single DEX, an aggregator will optimize the swap by comparing and splitting trades across DEXes, securing the most favorable exchange rate.
Swap API aggregation is powered by 0x. See the 0x media kit to add a badge to your application.