Quickstart

Routing protocol integration guide

Suppose you want to swap 1 BNB for USDT and extract some arbitrage opportunities, if any. Then you should start with the api request.

import axios from "axios";

const UROBORUS_API_URL = "https://api.uroboros.co";

let routeParams = {
    // input amount, provided in hex
    amountIn: "0xde0b6b3a7640000",
    tokenIn: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
    tokenOut: "0xe9e7cea3dedca5984780bafc599bd69add087d56",
    // token that is used to count for gas usage
    // (normally it's native chain wrapped token)
    tokenGas: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
    gasPrice: "0x12a05f200",
    // cashback all tokens
    cashbackTokens: null
};
let route = await axios.post(UROBORUS_API_URL + "/route", routeParams);

Returned route may look like this:

[
    {
        tokenIn: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
        tokenOut: "0x55d398326f99059fF775485246999027B3197955",
        amountIn: "0xde0b6b3a7640000",
        // amount receibed by swappin WBNB for USDT
        amountOut: "0xf83e62b82819ce00b",
        // gas units used during a swap
        gasUsed: 58141,
        // protocol specific data, encoded and passed to protocol adaptor on UrbRouter
        swapData: {
            type: "uniswap-v2",
            address: "0xacaac9311b0096e04dfe96b6d87dec867d3883dc",
            swapFee: 20,
            // fee for selling a token
            sellFee: 0,
            // fee for buying a token
            buyFee: 0,
            zeroForOne: true
        }
    }
    // ...
]

Before using it, don't forget to approve tokens for spend on UrbRouter.

And you can finally swap!

In transaction logs you will be able to see resulting price, tokens that are "cash-backed" and your route id (coming soon).

Last updated