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": "0.01",
"srcTokenBlockchain": "BITCOIN",
"dstTokenAddress": "0x0000000000000000000000000000000000000000",
"dstTokenBlockchain": "ETH",
"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": "0.42498305",
// "destinationTokenMinAmount": "0.4122335585",
//
// "destinationUsdAmount": 835.39,
// "destinationUsdMinAmount": 810.33,
//
// "destinationWeiAmount": "425207819398076439",
// "destinationWeiMinAmount": "412451584816134146",
//
// "durationInMinutes": 5,
// "priceImpact": 0.61,
// "slippage": 0.03
// }
console.log(id);
// This is the swap ID. It will be needed later for swap request.
return data;
}