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.
Quote Request
Param | Description |
---|---|
from * | The source asset |
to * | The destination asset |
amount * | The big number amount (machine readable) of asset X that is going to be swapped, e.g. 100000000000000000000 for 100 Fantom.FTM |
slippage | Amount of user's preferred slippage in percent. if you don't send it, it will assume 0.5% slippage. (It's used to filter the swappers or routes that are not suitable for the given slippage) |
swappers | List of all accepted swappers, an empty list means no filter is required. |
swappersExclude | Defines the provided swappers as the include/exclude list. Default is false (include) |
swapperGroups | The list of all included/excluded swappers based on tag, empty list means no filter is required |
swappersGroupsExclude | Defines the provided swappers' tags as the include/exclude list. Default is false (include) |
contractCall | important: set this parameter to |
sourceContract | Address of your contract on source chain (will be called in case of refund in the source chain) |
destinationContract | Address of your contract on destination chain (will be called in case of success/refund in the destination chain) |
messagingProtocols | Message protocols which will be used to relay message in a cross-chain swap. An empty list means no filter is required. |
imMessage | The message that you want to pass to your contract on the destination chain |
referrerFee | Referrer fee in percent |
Quote Response
Field | Description |
---|---|
requestId | The unique request Id which is generated for this request by the server. It should be passed down to all other endpoints if this swap continues on. e.g. |
resultType | Status of the route:
|
route | The quote route object |
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
.
resultType | Reason |
---|---|
| Best route found. Everything is OK. |
| If the best route has a high price impact, we recommend not proceeding with the next step (swap). The Rango API may give you an error in the next step to prevent potential losses. |
| There is a limit issue for the input amount. You could suggest user increase/decrease the input amount based on |
| No routes found. |
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).
expenseType | Description |
---|---|
| The gas fee. This fee should be available in the user's wallet for the swap to succeed. |
| 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. |
2. Swap (Test)
It's similar to the quote method but gives the actual transaction data in response besides the route.
Swap Request
Param | Description |
---|---|
from * | The asset X that user likes to swap |
to * | The asset Y that user wants to swap X into that |
amount * | The machine-readable amount of asset X that is going to be swapped |
slippage * | User slippage for this swap (e.g. 1.5 which means 1.5% slippage) |
fromAddress * | User source wallet address |
toAddress * | User destination wallet address |
disableEstimate | This field should be false when the client wants to preview the route to the user and true when the user accepts the swap. If it's true, the server will be much slower to respond but will check some prerequisites, including the balance of X and any required fees in the user's wallets. Important: If you are checking the balance and fee amount on your client side, it's recommended to pass this param as true. |
referrerAddress | Referrer wallet address |
referrerFee | Referrer fee in percent, (e.g. 0.3 means: 0.3% fee based on input amount) |
swappers | List of all accepted swappers, an empty list means no filter is required. |
swappersExclude | Defines the provided swappers as the include/exclude list. Default is false (include) |
swapperGroups | The list of all included/excluded swappers based on tag, empty list means no filter is required |
swappersGroupsExclude | Defines the provided swappers' tags as the include/exclude list. Default is false (include) |
messagingProtocols | List of all messaging protocols, an empty list means no filter is required. |
infiniteApprove | Use this parameter if you want infinite approve from user |
contractCall | important: set this parameter to |
sourceContract | Address of your contract on source chain (will be called in case of refund in the source chain) |
destinationContract | Address of your contract on destination chain (will be called in case of success/refund in the destination chain) |
imMessage | The message that you want to pass to your contract on the destination chain |
Swap Response
Field | Description |
---|---|
requestId | The unique request Id which is generated for this request by the server. It should be passed down to all other endpoints if this swap continues on. e.g. |
resultType | Status of the route, possible values are:
|
route | The quote route object. Similar to the quote response. |
error | Error message (raw string) if there is any problem in creating transaction. (error === null <=> tx !== null) |
tx | Transaction data for this route. |
Check this link to see an example of transaction data:
pageSample TransactionsLast updated