async function quoteBest() {
const response = await fetch("https://api-v2.rubic.exchange/api/routes/quoteBest", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
"srcTokenAddress": "0x0000000000000000000000000000000000000000",
"srcTokenAmount": "1.05",
"srcTokenBlockchain": "ETH",
"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": "8248.453781656313882666",
// "destinationTokenMinAmount": "8001.000168206624466186",
//
// "destinationUsdAmount": 2637.13,
// "destinationUsdMinAmount": 2558.02,
//
// "destinationWeiAmount": "8248453781656313882666",
// "destinationWeiMinAmount": "8001000168206624466186",
//
// "durationInMinutes": 5,
// "priceImpact": 0.14,
// "slippage": 0.03
// }
console.log(transaction.approvalAddress);
// This is the address you need to give approve to spend tokens.
// See next section for details.
// 0x3335733c454805df6a77f825f266e136FB4a3333
console.log(id);
// This is the swap ID. It will be needed later for swap request.
return data;
}