Hello
I am testing the functionality getAmountsOut of Pancakeswap but I am not sure what to use if I switch the token on UI form. If I use again getAmountsOut just with another token then I am getting different values, e.g. 1BNB -> 400 USDT then 400 USDT -> 0.4BNB
I tried to use another function like getAmountsIn and getting 400 USDT -> 0.999BNB but if I increase the value (e.g. 1000 USDT) then getting EVM revert.
Therefore, what are Pancakeswap and Uniswap using on their UI?
_getTokenAmountOut = async (_amount: BigNumber, token0: any, token1: any) => {
console.log('_getTokenAmountOut..');
try {
const res = await this.state.router
.connect(this.state.signer)
.getAmountsOut(_amount, [token0, token1]);
return res;
} catch (err: any) {
console.log('---------------');
console.log(`_getTokenAmountOut ${err}`);
this.setState({
priceImpact: '100',
});
console.log('---------------');
}
};