Paraswap Integration
DEX aggregators solve one problem: find the best token swap route among dozens of liquidity sources. Paraswap covers Uniswap, Curve, Balancer, Aave, DODO and several dozen protocols on 10+ networks. For applications needing swaps—this is ready-made routing infrastructure without needing to implement it yourself.
How Paraswap API works
Paraswap provides two endpoints: /prices to get quote and optimal route, and /transactions to build transaction from quote route. Two-step approach is justified: quote is valid for limited time, transaction is built at execution moment.
// Step 1: get route
const priceRoute = await axios.get(
`https://apiv5.paraswap.io/prices/?srcToken=${srcToken}&destToken=${destToken}&amount=${amount}&network=1`
)
// Step 2: build transaction
const txData = await axios.post(
'https://apiv5.paraswap.io/transactions/1',
{
srcToken, destToken, srcAmount, destAmount,
priceRoute: priceRoute.data.priceRoute,
userAddress: wallet.address,
slippage: 100, // 1% in basis points
}
)
Important nuance: Paraswap v5 API works without API key for basic use, but with high load adds rate limiting. For production integration with frequent requests—partner key via form on website.
Token approvals: frequent mistake
Approve is needed not for Paraswap router contract directly, but for TokenTransferProxy—separate contract managing transfers. Address differs by network. If approve is given to wrong address—each swap will revert with TRANSFER_FROM_FAILED.
TokenTransferProxy addresses available via https://apiv5.paraswap.io/adapters/contracts?network={chainId}. Better to fetch them dynamically on initialization, not hardcode.
Paraswap SDK as API alternative
@paraswap/sdk provides typed client:
import { ParaSwap } from '@paraswap/sdk'
import { ethers } from 'ethers'
const paraswap = new ParaSwap({ chainId: 1, web3Provider: provider })
const priceRoute = await paraswap.getRate({
srcToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
destToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
amount: '1000000000', // 1000 USDC
side: SwapSide.SELL,
})
SDK abstracts contract address management and formatting, but adds dependency. For simple integrations sufficient with direct HTTP requests.
Slippage handling and failed transactions
Paraswap passes minDestAmount to transaction based on slippage parameter. If market moved more—transaction reverts with INSUFFICIENT_DEST_AMOUNT. Normal behavior protecting from MEV.
In application must provide retry logic: on revert from slippage—fetch quote again and recalculate transaction. On gas estimation failure—increase gas by 20% and retry.
Timeline estimates
Basic Paraswap integration (fetch quote + build tx + execute)—2-3 days. With full error handling, retry logic and UI for slippage selection—up to 1 week.
Cost calculated individually.







