Quote Response Detail
Quote response detail
Using
resultType
field, you could decide if the quote response is valid or need to show a proper message to the user. Possible values for this field are OK
, HIGH_IMPACT
, INPUT_LIMIT_ISSUE
and NO_ROUTE
.resultType | Reason |
---|---|
OK | Best route found. Everything is OK. |
HIGH_IMPACT | No route meets your slippage criteria. You could suggest user increase the slippage and test again. |
INPUT_LIMIT_ISSUE | There is a limit issue for the input amount. You could suggest user increase/decrease the input amount based on amountRestrictions field. |
NO_ROUTE | No routes found regardless of the input amount. |
The
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
.sample quote, amountRestriction
1
{
2
// other fields ...,
3
"amountRestriction": {
4
"min": "40666469010361176",
5
"max": "67777448350601960000000",
6
"type": "INCLUSIVE"
7
},
8
}
These are two possible types of fees (
expenseType
field in the fee
array). expenseType | Description |
---|---|
FROM_SOURCE_WALLET | The gas fee. This fee should be available in the user's wallet for the swap to succeed. |
DECREASE_FROM_OUTPUT | Some hidden fees in swapper which will be reduced from the user's output amount automatically. This fee is already calculated in the estimated output. |
And this is a sample fee object you get through the
quote
method. sample quote, fee
1
{
2
// other fields ...,
3
"fee": [{
4
"token": {
5
"blockchain": "BSC",
6
"symbol": "BNB",
7
"address": null,
8
"decimals": 18,
9
"image": "https://api.rango.exchange/i/Y3v1KW",
10
"usdPrice": 295.78270570524273
11
},
12
"expenseType": "FROM_SOURCE_WALLET",
13
"amount": "1261820000000000",
14
"name": "Network Fee"
15
}
16
]
As fee of
DECREASE_FROM_OUTPUT
type is already calculated in the estimated output, you could just sum other fees usdPrice
and show it to the user using the code snippet below:1
const totalFeeInUsd: BigNumber = quote.fee?
2
.filter(f => f.expenseType === "FROM_SOURCE_WALLET")
3
.map(f => (new BigNumber(f.amount)).multipliedBy(f.token.usdPrice || 0))
4
.reduce((f1: BigNumber, f2: BigNumber) => f1.plus(f2))
5
Last modified 6mo ago