Links
2⃣

Quote

Get the best route to swap X to Y
Using information retrieved from the meta, you could implement your own SwapBox including your blockchain and token selector. The next step is to show the preview of the best route possible when the user selects the source and the destination tokens.
1
// Converting 0.1 BSC BNB to Fantom FUSDT
2
const quote = await rangoClient.quote({
3
from: {
4
"blockchain": "BSC",
5
"symbol": "BNB",
6
"address": null
7
},
8
to: {
9
"blockchain": "FANTOM",
10
"symbol": "FUSDT",
11
"address": "0x049d68029688eabf473097a2fc38ef61633a3c7a"
12
},
13
amount: "100000000000000000"
14
})
You could call this method periodically to get the updated route before the user confirms the swap. Here is a sample quote object you could get.
Please check this doc if you want to get complete details on important fields in the quote response including resultType, fee and amountRestriction.
sample quote
1
{
2
"requestId": "6d9bae3b-227a-4b58-b1e2-63038e20434b",
3
"resultType": "OK",
4
"route": {
5
"outputAmount": "29008340",
6
"swapper": {
7
"id": "AnySwap Aggregator",
8
"title": "Multichain",
9
"logo": "https://api.rango.exchange/swappers/anyswap.png"
10
},
11
"from": {
12
"blockchain": "BSC",
13
"symbol": "BNB",
14
"address": null,
15
"decimals": 18,
16
"image": "https://api.rango.exchange/i/Y3v1KW",
17
"usdPrice": 295.78270570524273
18
},
19
"to": {
20
"blockchain": "FANTOM",
21
"symbol": "FUSDT",
22
"address": "0x049d68029688eabf473097a2fc38ef61633a3c7a",
23
"decimals": 6,
24
"image": "https://api.rango.exchange/i/mqwkaZ",
25
"usdPrice": 1.0002665280371925
26
},
27
"fee": [
28
{
29
"token": {
30
"blockchain": "BSC",
31
"symbol": "BNB",
32
"address": null,
33
"decimals": 18,
34
"image": "https://api.rango.exchange/i/Y3v1KW",
35
"usdPrice": 295.78270570524273
36
},
37
"expenseType": "FROM_SOURCE_WALLET",
38
"amount": "1261820000000000",
39
"name": "Network Fee"
40
}
41
],
42
"amountRestriction": {
43
"min": "40666469010361176",
44
"max": "67777448350601960000000",
45
"type": "INCLUSIVE"
46
},
47
"estimatedTimeInSeconds": 540,
48
"path": [...] // extra information
49
}
50
}