Get Quote
Get the best single-step route for swapping X to Y
Last updated
Get the best single-step route for swapping X to Y
Last updated
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.
from
* String
Description: The source asset
Example: BSC.BNB
to
* String
Description: The destination asset
Example: AVAX_CCHAIN--0xc7198437980c041c805a1edcba50c1ce5db95118
amount
* String
Description: The machine readable amount of asset X that is going to be swapped
Example: 100000000000000000000
for 100 Fantom.FTM
slippage
Number
Description: 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.
Example: 1.5
means 1.5% slippage
referrerCode
String
Description: Referrer code
referrerFee
String
Description: Referrer fee in percent
swappers
String
Description: List of all accepted swappers, an empty list means no filter is required.
swappersExclude
Boolean
Description: Defines the provided swappers as the include/exclude list. Default is false (include)
swapperGroups
String
Description: The list of all included/excluded swappers based on tag. Empty list means no filter is required.
swappersGroupsExclude
Boolean
Description: Defines the provided swappers' tags as the include/exclude list. Default is false (include)
contractCall
Boolean
Description: Set this parameter to true
if you want to send transactions through a contract. It will filter swappers that are not possible to be called by another contract.
Caution: If you call Rango contracts using your contract and your contract is not white listed in some underlying protocols like Thorchain, user fund may stuck forever in Thorchain contracts. In this case, you need to exclude these swappers using this flag or ask related protocols to white list your contracts.
sourceContract
String
Description: Address of your contract on source chain (will be called in case of refund in the source chain)
destinationContract
String
Description: Address of your contract on destination chain (will be called in case of success/refund in the destination chain)
imMessage
String
Description: The message that you want to pass to your contract on the destination chain.
messagingProtocols
String
Description: Message protocols which will be used to relay message in a cross-chain swap. An empty list means no filter is required.
avoidNativeFee
Boolean
Description: When this condition is true, swappers that charge fees in native tokens will be excluded. For instance, when called from an AA account.
Caution: Swappers like Stargate charge user fees in native tokens instead of the input amount, causing the transaction value to differ from the user's input amount. Alternatively, the user may need to transfer native tokens in a contract call to cover these protocol fees. Although you can disable these protocols using this flag, we do not recommend it as it reduces the coverage of single-step routes.
enableCentralizedSwappers
Boolean
Description: Pass this flag true if you want to enable routing through the centralized solutions. Default is false.
Caution: To enable these swappers, you must pass the user's IP to the Rango API for compliance checks. Additionally, user funds may be held for KYC if their wallet is flagged as risky by the screening solutions implemented by these protocols.
requestId
Description: 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.
Example: d10657ce-b13a-405c-825b-b47f8a5016ad
resultType
Description: Status of the route.
Possible Values:
OK
=> Best route found. Everything is OK.
HIGH_IMPACT
=> The route has high price impact, we recommend not proceeding with the next step. The Rango API may give you an error in the next step to prevent potential losses.
INPUT_LIMIT_ISSUE
=> There is a limit issue for the input amount. You could suggest user to increase or decrease the input amount based on amountRestrictions
field in response.
NO_ROUTE
=> No routes found.
route
Description: The quote route object
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
.
These are two possible types of fees (expenseType
field in the route.fee
array).
FROM_SOURCE_WALLET
Description: 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/swap
endpoint. You could show the user feeUsd
amount as the total fee he/she should pay for this route.