What does getAmountsOut/getAmountOut and getAmountsIn/getAmountIn exactly do? There isn't an explanation in the Pancakeswap docs, so I'm not sure how could I use it. What's the difference between the two and with the 's' or none?
The difference is that the one with the "s" return the series of outputs resulting from a path
of swaps. Whereas the ones without the "s" return the output for a single swap.
So if I swap along the path ["ETHUSDT", "USDTUSDC"]
then getAmountsOut
will return the USDT output amount from the ETHUSDT swap and the USDC output amount from the "USDTUSDC" swap. The returned value will look like: [usdtAmount, usdcAmount]
.
If I swap "ETHUSDT" then getAmountOut will return usdtAmount
.
The inverse is true for getAmountsIn/getAmountIn.
It's defined here: https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/libraries/PancakeLibrary.sol#L63