Swaps VIA deposit
Retrieving Token Quotes
async function quoteBest() {
const response = await fetch("https://api-v2.rubic.exchange/api/routes/quoteBest", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: {
"srcTokenAddress": "0x0000000000000000000000000000000000000000",
"srcTokenAmount": "3",
"srcTokenBlockchain": "COSMOS",
"dstTokenAddress": "0x0000000000000000000000000000000000000000",
"dstTokenBlockchain": "TRON",
"referrer": "rubic.exchange"
}
});
const data = await response.json();
const { estimate, transaction, id } = data;
console.log(estimate);
// {
// This is an estimated amount you will get after the swap.
// "destinationTokenAmount": "56.797373",
// "destinationTokenMinAmount": "55.093452",
//
// "destinationUsdAmount": 13.26,
// "destinationUsdMinAmount": 12.86,
//
// "destinationWeiAmount": "56797373",
// "destinationWeiMinAmount": "55093452",
//
// "durationInMinutes": 5,
// "priceImpact": 3.29,
// "slippage": 0.03
// }
console.log(id);
// This is the swap ID. It will be needed later for swap request.
return data;
}Retrieving deposit quotes
Request QuoteRetrieving Data to Execute a Transaction
Request DataRetrieving Deposit Data to Make Transfer
Executing a Transaction with the API Response Data

Last updated