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": "10",
"srcTokenBlockchain": "TON"
"dstTokenAddress": "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs",
"dstTokenBlockchain": "TON",
"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": "59.859216",
// "destinationTokenMinAmount": "59.260624",
//
// "destinationUsdAmount": 59.86,
// "destinationUsdMinAmount": 59.26,
//
// "destinationWeiAmount": "59859216",
// "destinationWeiMinAmount": "59260624",
//
// "durationInMinutes": 5,
// "priceImpact": 0.21,
// "slippage": 0.01
// }
console.log(id);
// This is the swap ID. It will be needed later for swap request.
return data;
}