Skip to main content

DEX API

Endpoints for DEX trading, cross-chain swaps, liquidity management, and pool analytics.

Solana support

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:

FieldTypeRequiredDescription
chainIdnumberYesChain ID
tokenInstringYesInput token address
tokenOutstringYesOutput token address
amountInstringYesAmount of input tokens
slippagenumberNoSlippage tolerance (default: 0.5%)
walletAddressstringYesUser wallet address

Get Swap Quote

POST /dex/quote

Get a swap quote without executing the trade.

Request Body:

FieldTypeRequiredDescription
chainIdnumberYesChain ID
tokenInstringYesInput token address
tokenOutstringYesOutput token address
amountInstringYesAmount 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:

FieldTypeRequiredDescription
dexstringYesMust be "cowswap"
originChainIdnumberYesSource chain ID (must differ from destination)
destinationChainIdnumberYesDestination chain ID
tokenInstringYesSource token address
tokenOutstringYesDestination token address
amountstringYesInput amount in smallest units (base-10 integer string)
userAddressstringYesSender wallet address
recipientstringNoDestination recipient (defaults to userAddress)
maxSlippagenumberNoSlippage as a fraction, 0.01 = 1% (default 1%, max 0.5)
intermediateTokenstringNoForce a specific intermediate token
includeBridgesstring[]NoRestrict Bungee bridges: across, cctp, gnosis-native-bridge
providerstringNoPin 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:

FieldTypeRequiredDescription
chainIdnumberYesChain ID
protocolstringYesDEX protocol (uniswap, pancakeswap, sushiswap)
token0stringYesFirst token address
token1stringYesSecond token address
feenumberYesFee tier (e.g., 3000 for 0.3%)
amount0stringYesAmount of token 0
amount1stringYesAmount of token 1
tickLowernumberYesLower price tick
tickUppernumberYesUpper 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:

ParameterTypeRequiredDescription
chainIdnumberYesChain ID
dexstringYesDEX protocol name
typestringNoPool list type (top, new, general)
pagenumberNoPagination 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:

ParameterTypeRequiredDescription
poolAddressstringYesPool contract address
chainIdnumberYesChain ID
dexstringYesDEX protocol
intervalstringNoTime 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.