Swap with Socket
Socket is useful as a swap layer because it can evaluate multiple execution venues and return executable routes through one integration:- Any-token conversion: Route between supported assets without forcing users to visit separate swap or bridge interfaces.
- Best execution options: Compare routes by price, speed, output amount, and provider availability.
- Same-chain simplicity: Route entirely through DEX liquidity when the input and output assets are on the same network.
- Cross-chain composition: Combine swap and bridge execution when the user starts and ends on different chains.
Who this is for
Use swaps when users need to trade into a required token, rebalance wallet assets, enter a market, or complete an app flow without leaving your product experience.How it works
WhenoriginChainId and destinationChainId are identical, Socket routes the swap entirely on-chain through the best available DEX. The API returns a transaction that the user submits directly from their wallet.
Supported DEX providers
| Provider ID | Display name |
|---|---|
bebopPmm | Bebop |
kyberswap | Kyberswap |
openocean | OpenOcean |
zeroxv2 | 0x |
includeProvider and excludeProvider parameters on /v3/swap/quote to control which DEXs are considered for the swap.
Example
Key rules
inputTokenandoutputTokenmust be different for same-chain swaps.userAddressis required for transaction routes.receiverAddressmust be valid on the destination chain (same chain in this case).- All amounts are expressed in the token’s smallest unit (wei for EVM).
- The native token address is
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE.
API Integration Guide
Full guide to integrating the Socket Swap V3 API
Get API Access
Set up your API credentials