Before swapping. you should obtain the estimated amount of the other token and ths swap routes.
There are two functions for this preperation.
const currencyAAmount = Math.pow(10,7)
const { amountOut: currencyBAmount, path: poolRoute} = await sdk.Swap.estToAmount({
amount: currencyAAmount,
from: "0xa",
to: "0xc5bcdea4d8a9f5809c5c945a3ff5698a347afb982c7389a335100e1b0043d115"
})
/*
{
"amountOut": "10000000", // This is for toAmount
"amountIn": "1279371", // This is for fromAmount
// swap path route
"path": [
"0x0d21c2f5628db619957703e90ab07bcb2b13ad6983da2b5d721f24523cae29ff"
]
}
*/
const params = {
// here must be fa type
currencyA: '0xa',
currencyB:
"0xc5bcdea4d8a9f5809c5c945a3ff5698a347afb982c7389a335100e1b0043d115",
currencyAAmount,
currencyBAmount,
slippage: 0.1,
poolRoute,
recipient: '',
}
const payload = await sdk.Swap.swapTransactionPayload(params)
console.log(payload)