DEX API
Endpoints for DEX trading, cross-chain swaps, liquidity management, and pool analytics.
The DEX module supports both EVM chains and Solana (chain ID 999). For Solana, use dex: "raydium", SPL token mint addresses, and a base58 wallet address. Solana swap/liquidity endpoints return a base64-encoded transaction for the client to sign.
Swap Endpoints
Execute Swap
POST /dex/swap
Execute a token swap on a DEX protocol.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID |
tokenIn | string | Yes | Input token address |
tokenOut | string | Yes | Output token address |
amountIn | string | Yes | Amount of input tokens |
slippage | number | No | Slippage tolerance (default: 0.5%) |
walletAddress | string | Yes | User wallet address |
Get Swap Quote
POST /dex/quote
Get a swap quote without executing the trade.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID |
tokenIn | string | Yes | Input token address |
tokenOut | string | Yes | Output token address |
amountIn | string | Yes | Amount to swap |
Response:
{
"amountOut": "1500000000000000000",
"priceImpact": 0.12,
"route": "uniswap",
"gasEstimate": "150000"
}
Cross-Chain Swap
POST /dex/cross-chain-swap
Swap a token on one chain for a token on another chain. Routed through CowSwap plus a bridge provider (Bungee or NEAR Intents). Both providers are quoted in parallel and the one with the higher expected output is returned.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
dex | string | Yes | Must be "cowswap" |
originChainId | number | Yes | Source chain ID (must differ from destination) |
destinationChainId | number | Yes | Destination chain ID |
tokenIn | string | Yes | Source token address |
tokenOut | string | Yes | Destination token address |
amount | string | Yes | Input amount in smallest units (base-10 integer string) |
userAddress | string | Yes | Sender wallet address |
recipient | string | No | Destination recipient (defaults to userAddress) |
maxSlippage | number | No | Slippage as a fraction, 0.01 = 1% (default 1%, max 0.5) |
intermediateToken | string | No | Force a specific intermediate token |
includeBridges | string[] | No | Restrict Bungee bridges: across, cctp, gnosis-native-bridge |
provider | string | No | Pin a provider: bungee or near-intents. Omit to auto-select. |
Supported chains: Ethereum (1), Optimism (10), BNB Chain (56), Gnosis (100), Polygon (137), Base (8453), Arbitrum (42161), Avalanche (43114), and Solana (999, via NEAR Intents).
Response (abridged):
{
"provider": "bungee",
"originChainId": 1,
"destinationChainId": 137,
"amountIn": "1000000000000000000",
"intermediateAmount": "...",
"expectedOutput": "...",
"guaranteedOutput": "...",
"priceImpact": 0.21,
"estimatedTime": 120,
"bridge": "across",
"bridgeFee": { "amount": "...", "tokenAddress": "0x..." }
}
Liquidity Endpoints
Create Liquidity Position
POST /dex/liquidity/create
Add liquidity to a DEX pool and create a new position.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID |
protocol | string | Yes | DEX protocol (uniswap, pancakeswap, sushiswap) |
token0 | string | Yes | First token address |
token1 | string | Yes | Second token address |
fee | number | Yes | Fee tier (e.g., 3000 for 0.3%) |
amount0 | string | Yes | Amount of token 0 |
amount1 | string | Yes | Amount of token 1 |
tickLower | number | Yes | Lower price tick |
tickUpper | number | Yes | Upper price tick |
Increase Liquidity
POST /dex/liquidity/increase
Add more liquidity to an existing position.
Decrease Liquidity
POST /dex/liquidity/decrease
Remove liquidity from an existing position.
Collect Fees
POST /dex/liquidity/collectFees
Collect accumulated trading fees from an LP position.
Burn Position
POST /dex/liquidity/burn
Close and burn an LP position NFT.
Pool Endpoints
Get Pool Info
POST /dex/pool-info
Retrieve detailed information about a specific pool.
Get Pool List
GET /dex/getPoolList
Fetch lists of pools filtered by type.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID |
dex | string | Yes | DEX protocol name |
type | string | No | Pool list type (top, new, general) |
page | number | No | Pagination page |
Get Pool Graph Data
GET /dex/poolgraphdata
Retrieve price chart data for a specific pool.
Get Pool Candlestick
GET /dex/pool-candlestick
Retrieve OHLCV candlestick data for a pool.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
poolAddress | string | Yes | Pool contract address |
chainId | number | Yes | Chain ID |
dex | string | Yes | DEX protocol |
interval | string | No | Time interval (1h, 4h, 1d) |
Get Price Range Graph
GET /dex/pricerangegraphdata
Retrieve liquidity distribution / price range data for a pool.
Simulate LP Position
POST /dex/simulate-lp
Simulate a liquidity position to estimate returns before committing.