Skip to main content
Type: DEX Aggregator | Docs: docs.openocean.finance

Overview

OpenOcean is a DEX aggregator that sources liquidity from all major DEXes on Monad to find the optimal swap route. The SDK integrates the OpenOcean REST API (https://open-api.openocean.finance/v4/monad) - no on-chain quote calls are needed. OpenOcean supports both single-path and multi-path split routing.
If the OpenOcean API is unavailable or returns an error, functions gracefully degrade: getOpenOceanQuote returns amountOut: 0 and isOpenOceanAvailable returns false. Always check availability before building swap UIs.

Functions

getOpenOceanQuote()

Returns an optimized swap quote via the OpenOcean routing API. Parameters
NameTypeDescription
tokenInAddressInput token address
tokenOutAddressOutput token address
amountInbigintExact input amount
Returns
FieldTypeDescription
amountOutbigintExpected output amount (0 if unavailable)
amountOutUsdnumberOutput value in USD
pricenumberExecution price
priceImpactnumberPrice impact as a percentage
gasEstimatenumberEstimated gas cost
routeRouteStep[]Array of routing steps with exchange names
callDataHexTransaction calldata for execution
import { getOpenOceanQuote, isOpenOceanAvailable } from 'rampart-monad'

if (await isOpenOceanAvailable()) {
  const quote = await getOpenOceanQuote(
    '0x...', // tokenIn (MON)
    '0x...', // tokenOut (USDC)
    1_000_000_000_000_000_000n // 1 MON
  )
  console.log(`Amount out: ${quote.amountOut}`)
  console.log(`Route: ${quote.route.map(s => s.name).join(' → ')}`)
} else {
  console.log('OpenOcean API unavailable, using fallback')
}

getOpenOceanPrice()

Returns the current spot price for a token pair via OpenOcean. Parameters
NameTypeDescription
tokenInAddressInput token address
tokenOutAddressOutput token address
Returns number. price of tokenIn in units of tokenOut. Returns 0 if API is unavailable.
import { getOpenOceanPrice } from 'rampart-monad'

const price = await getOpenOceanPrice(
  '0x...', // MON
  '0x...'  // USDC
)
if (price > 0) {
  console.log(`OpenOcean: 1 MON = ${price} USDC`)
}

isOpenOceanAvailable()

Checks whether the OpenOcean API is reachable on Monad. Returns boolean. true if the API is live and responding.
import { isOpenOceanAvailable } from 'rampart-monad'

const available = await isOpenOceanAvailable()
console.log(`OpenOcean available: ${available}`)
import {
  getOpenOceanQuote,
  getKyberSwapQuote,
  isOpenOceanAvailable
} from 'rampart-monad'

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

const results = await Promise.allSettled([
  isOpenOceanAvailable().then(ok =>
    ok ? getOpenOceanQuote(tokenIn, tokenOut, amount) : null
  ),
  getKyberSwapQuote(tokenIn, tokenOut, amount)
])

const [openocean, kyber] = results.map(r =>
  r.status === 'fulfilled' ? r.value : null
)

if (openocean && kyber) {
  const best = openocean.amountOut > kyber.amountOut ? 'OpenOcean' : 'KyberSwap'
  console.log(`Best aggregator: ${best}`)
}

API Endpoint

EndpointURL
Monad V4 APIhttps://open-api.openocean.finance/v4/monad

Contract Addresses

ContractAddress
ExchangeProxy0x6352a56caadC4F1E25CD6c75970Fa768A3304e64