The router queries Kuru, Uniswap V3, PancakeSwap V3, PancakeSwap V2, Uniswap V2, and OpenOcean in parallel via
Promise.allSettled, returning the best available output amount. OpenOcean is queried via REST API and is silently skipped if unavailable.Overview
The Multi-DEX Router is a DEX aggregator that fans out quote requests to all 6 supported sources simultaneously and surfaces the route with the highestamountOut. Price impact is included where the underlying DEX exposes it.
Supported DEXes:
- Kuru (native orderbook AMM, MON pairs)
- Uniswap V3
- PancakeSwap V3
- PancakeSwap V2
- Uniswap V2
- OpenOcean (REST API)
Types
Functions
getBestSwapRoute
Queries all 6 DEXes in parallel and returns the route with the highest amountOut.
| Parameter | Type | Description |
|---|---|---|
tokenIn | string | Input token address (use 0x000...000 for native MON) |
tokenOut | string | Output token address |
amountIn | string | Amount in wei (as string to avoid BigInt overflow) |
RouterResult with bestDex, amountOut, allRoutes sorted by output descending, and timestamp.
getAllSwapQuotes
Returns all available quotes sorted by amountOut descending. Useful when you want to display a comparison UI or inspect every route.
detectDexArbitrage
Detects price discrepancies greater than 0.5% between any two DEXes for a given token pair. Returns null if no profitable spread is found.
Usage
Arbitrage Detection
Notes
amountInmust be a string in wei to avoid JavaScriptBigIntprecision loss.- Routes from DEXes that return an error or timeout are excluded from
allRoutes- the result always reflects only successful responses. - OpenOcean quotes are fetched via their public REST API. If the endpoint is unavailable the router continues with the remaining 5 sources.
- Kuru is a native orderbook AMM optimised for MON pairs and often returns the best rate for MON/USDC.