Quote & Swap APIs

Get the best single-step route for swapping X to Y

1. Get Quote (Test)

Using the quote method, you can get a preview of the best route for this cross-chain swap. It goes through all the possible DEXs, bridges and aggregators to find the best possible single-step route based on user experience, fee amount, and swap output.

const quoteResponse = await rangoClient.quote({
    from: {"blockchain": "BSC", "symbol": "BNB", "address": null},
    to: {"blockchain": "AVAX_CCHAIN", "symbol": "USDT.E", "address": "0xc7198437980c041c805a1edcba50c1ce5db95118"},
    amount: "100000000000000000" // 0.1 BSC.BNB

Quote Request

Quote Response

Status (Result Type)

Based on resultType field, you could decide if the quote response is valid or need to show a proper message to the user (or retry). Possible values for this field are OK , HIGH_IMPACT , INPUT_LIMIT_ISSUE and NO_ROUTE.

Limits (Amount Restrictions)

The route.amountRestriction field indicates the minimum and maximum possible input amount for this quote. EXCLUSIVE field means that min<input<max and INCLUSIVE means min<=input<=max.

Fee (Expense Types)

These are two possible types of fees (expenseType field in the route.fee array).

2. Swap (Test)

It's similar to the quote method but gives the actual transaction data in response besides the route.

const swapResponse = await rangoClient.swap({
    from: {"blockchain": "BSC", "symbol": "BNB", "address": null},
    to: {"blockchain": "AVAX_CCHAIN", "symbol": "USDT.E", "address": "0xc7198437980c041c805a1edcba50c1ce5db95118"},
    amount: "100000000000000000" // 0.1 BSC.BNB3
    fromAddress: "0xeb2629a2734e272bcc07bda959863f316f4bd4cf",
    toAddress: "0xeb2629a2734e272bcc07bda959863f316f4bd4cf",
    disableEstimate: true,
    slippage: '1.0',

Swap Request

Swap Response

Check this link to see an example of transaction data:

Last updated