Integration Guide

This guide walks through integrating the XOXNO Aggregator API into an application, from fetching quotes to submitting on-chain transactions.

Prerequisites

  • MultiversX wallet integration (xPortal, DeFi Wallet, or Web Wallet)

  • Familiarity with MultiversX transaction structure

  • Node.js or equivalent HTTP client

Overview

The integration flow consists of three main steps:

  1. Validate the pair β€” Check token support and retrieve decimal metadata

  2. Get a quote β€” Fetch optimal routing and transaction data

  3. Build, sign, and submit β€” Construct the transaction and broadcast it


Token Amounts

All amounts in the API are expressed in the token's smallest unit (integer, no decimals).

To convert a human-readable amount to smallest units:

function toSmallestUnits(amount, decimals) {
  // Use BigInt to avoid floating-point precision loss
  return (BigInt(Math.round(amount * 1e9)) * BigInt(10 ** decimals) / BigInt(1e9)).toString();
}

// 1 WEGLD (18 decimals) β†’ "1000000000000000000"
toSmallestUnits(1, 18);

// 100 USDC (6 decimals) β†’ "100000000"
toSmallestUnits(100, 6);

To convert back to a human-readable amount:

circle-exclamation

Step 1: Validate the Pair

Before requesting a quote, verify that the pair is supported and retrieve decimal metadata:


Step 2: Get a Quote


Step 3: Build the Transaction

EGLD / WEGLD Swaps

ESDT Token Swaps

For non-native tokens, wrap the payload in an ESDTTransfer call:


Step 4: Sign and Submit


Gas Estimation

The API provides estimatedBuiltinCalls to assist gas estimation. Use the following formula as a baseline:

Route Type
Estimated Gas

Single-hop (1 pool)

~8M gas

Multi-hop (2–3 pools)

~16–24M gas

Split route (complex)

~50M gas

circle-info

For split routes with maxSplits > 4, add an additional buffer of 10–20M gas. MultiversX charges refunds on unused gas, so over-estimating is safe.


Error Handling

Retry Logic

Apply exponential backoff for transient errors (429, 503):

Error Classification

See Error Referencearrow-up-right for a complete list of error codes, HTTP status codes, and resolution guidance.


Complete Example


Best Practices

Quote Freshness

Quotes reflect pool state at the moment of the request. Re-fetch the quote immediately before constructing the transaction to avoid executing against stale prices:

Slippage Guidelines

Trade size (USD)
Recommended slippage

< $100

0.5%

$100 – $1,000

1%

$1,000 – $10,000

2%

> $10,000

3%

High-Frequency Polling

For applications that poll prices frequently (e.g., price displays):

  • Use includePaths=false to reduce response payload and server-side work

  • Respect the 100 req/s rate limit per IP; implement a local token bucket or queue

  • Handle HTTP 429 with exponential backoff (see Error Handling)


Last updated

Was this helpful?