Quote & Swap
Get the best single-step route for swapping X to Y
Using the quote method, you can get a preview of the best route for this cross-chain swap. It goes through all the possible DEX & bridges to find the best possible single-step route based on user experience, fee amount, and swap output.
Typescript
cURL
const quoteResponse = await rangoClient.quote({
from: {"blockchain": "FANTOM", "symbol": "FTM", "address": null},
to: {"blockchain": "BSC", "symbol": "BNB", "address": null},
amount: "100000000000000000000" // 100 FTM
})
curl 'https://api.rango.exchange/basic/quote?apiKey=YOUR_API_KEY&amount=100000000000000000000&from=FANTOM.FTM&to=BSC.BNB' \
-H 'content-type: application/json;charset=UTF-8' \
-H 'x-rango-id: USER_RANDOM_UUID' \
-H 'origin: https://app.rango.exchange' \
--compressed
Param | Description |
---|---|
from * | The source asset |
to * | The destination asset |
amount * | The big number amount of asset X that is going to be swapped, e.g. 100000000000000000000 for 100 Fantom.FTM |
swappers | List of all accepted swappers, an empty list means no filter is required. |
messagingProtocols | List of all messaging protocols, an empty list means no filter is required. Possible options are cbridge , (and soon: axelar , anyswap and layer0 ) |
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 |
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. d10657ce-b13a-405c-825b-b47f8a5016ad |
resultType | OK , HIGH_IMPACT , INPUT_LIMIT_ISSUE , NO_ROUTE |
route | The quote route object |
It's similar to the quote method but gives the actual transaction data in response.
Typescript
cURL
const swapResponse = await rangoClient.swap({
from: {"blockchain": "FANTOM", "symbol": "FTM", "address": null},
to: {"blockchain": "BSC", "symbol": "BNB", "address": null},
amount: "100000000000000000000", // 100 Fantom.FTM
fromAddress: "0xeb2629a2734e272bcc07bda959863f316f4bd4cf",
toAddress: "0xeb2629a2734e272bcc07bda959863f316f4bd4cf",
disableEstimate: false,
slippage: '1.0',
})
curl 'https://api.rango.exchange/basic/swap?apiKey=YOUR_API_KEY&from=FANTOM.FTM&to=BSC.BNB&amount=100000000000000000000&fromAddress=0xeb2629a2734e272bcc07bda959863f316f4bd4cf&toAddress=0xeb2629a2734e272bcc07bda959863f316f4bd4cf&disableEstimate=false&slippage=1.0' \
-H 'content-type: application/json;charset=UTF-8' \
-H 'x-rango-id: USER_RANDOM_UUID' \
-H 'origin: https://app.rango.exchange' \
--compressed
Param | Description |
---|---|
from * | The source asset |
to * | The destination asset |
amount * | The big number amount of asset X that is going to be swapped, e.g. 100000000000000000000 for 100 Fantom.FTM |
slippage * | User slippage for this swap (e.g. 5.0 which means 5% slippage) |
disableEstimate * | check pre-requests of a swap before creating tx (e.g. check to have enough balance) |
fromAddress * | User source wallet address |
toAddress * | User destination wallet address |
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. |
messagingProtocols | List of all messaging protocols, an empty list means no filter is required. Possible options are cbridge , (and soon: axelar , anyswap and layer0 ) |
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 |
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. d10657ce-b13a-405c-825b-b47f8a5016ad |
resultType | OK , HIGH_IMPACT , INPUT_LIMIT_ISSUE , NO_ROUTE |
route | The quote route object |
error | Error message if there is any problem |
tx | Transaction data |
Check this link to see an example of transaction data:
Last modified 6mo ago