# Quickstart

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

```typescript
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:

```json
[
    {
        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.

```typescript
import sdk from "uroboros-sdk";
import ethers from "ethers";

let IERC20 = ethers.utils.Interface([
    "function approve(address spender, uint256 amount)"
]);
let router = sdk.getUrbRouterAddress();
let txData = IERC20.encodeFunction("approve", [
    router,
    routeParams.amountIn
]);
await signer.sendTransaction({ to: routeParams.tokenIn, data: txData });
```

And you can finally swap!

```typescript
txData = sdk.encodeTransactionData(route);
await signer.sendTransaction({ to: router, data: txData });
```

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://uroborosdefi.gitbook.io/docs/routing-protocol/guide/quickstart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
