async function quoteBest() {
const response = await fetch("https://api-v2.rubic.exchange/api/routes/quoteBest", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: {
"srcTokenAddress": "So11111111111111111111111111111111111111111",
"srcTokenAmount": "1.05",
"srcTokenBlockchain": "SOL"
"dstTokenAddress": "0x0000000000000000000000000000000000000000",
"dstTokenBlockchain": "POLYGON",
"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": "451.4591",
// "destinationTokenMinAmount": "437.915327",
//
// "destinationUsdAmount": 233.63,
// "destinationUsdMinAmount": 226.63,
//
// "destinationWeiAmount": "451459000000",
// "destinationWeiMinAmount": "437915327000",
//
// "durationInMinutes": 5,
// "priceImpact": 0.23,
// "slippage": 0.03
// }
console.log(id);
// This is the swap ID. It will be needed later for swap request.
return data;
}