Skip to main content
Type: DEX Aggregator | Docs: docs.kyberswap.com

Overview

KyberSwap is a DEX aggregator that routes trades through the optimal path across multiple liquidity sources. On Monad, it aggregates liquidity from native AMMs and orderbooks to provide best-execution pricing. The SDK uses the KyberSwap API for routing - no on-chain calls are required for quotes.

Functions

getKyberSwapQuote()

Returns an optimized swap quote via the KyberSwap routing API. Parameters
NameTypeDescription
tokenInAddressInput token address
tokenOutAddressOutput token address
amountInbigintExact input amount
Returns
FieldTypeDescription
amountOutbigintExpected output amount
amountOutUsdnumberOutput value in USD
gasnumberEstimated gas cost
routeRouteStep[]Array of routing steps { exchange, tokenIn, tokenOut, swapAmount }
priceImpactnumberPrice impact percentage
encodedSwapDataHexCalldata for executing the swap
import { getKyberSwapQuote } from 'rampart-monad'

const quote = await getKyberSwapQuote(
  '0x...', // tokenIn (MON)
  '0x...', // tokenOut (USDC)
  1_000_000_000_000_000_000n // 1 MON
)

console.log(`Amount out: ${quote.amountOut}`)
console.log(`Value: $${quote.amountOutUsd}`)
console.log(`Route: ${quote.route.map(s => s.exchange).join(' → ')}`)

getKyberSwapPrice()

Returns the current spot price for a token pair using KyberSwap routing. Parameters
NameTypeDescription
tokenInAddressInput token address
tokenOutAddressOutput token address
Returns number. price of tokenIn in units of tokenOut.
import { getKyberSwapPrice } from 'rampart-monad'

const price = await getKyberSwapPrice(
  '0x...', // MON
  '0x...'  // USDC
)
console.log(`KyberSwap price: ${price} USDC per MON`)
import { getKyberSwapQuote, getOpenOceanQuote } from 'rampart-monad'

const tokenIn = '0x...'
const tokenOut = '0x...'
const amount = 1_000_000_000_000_000_000n

const [kyber, openocean] = await Promise.all([
  getKyberSwapQuote(tokenIn, tokenOut, amount),
  getOpenOceanQuote(tokenIn, tokenOut, amount)
])

const bestOut = kyber.amountOut > openocean.amountOut ? kyber : openocean
const source = kyber.amountOut > openocean.amountOut ? 'KyberSwap' : 'OpenOcean'
console.log(`Best: ${source} - ${bestOut.amountOut}`)

Contract Addresses

ContractAddress
MetaAggregationRouterV20x6131B5fae19EA4f9D964eAc0408E4408b66337b5