DEX API
Endpoints for DEX trading, liquidity management, and pool analytics.
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"
}
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.