TDLR: the same code that works with UniSwap is capable of returning an infinite "amountOut" when querying PancakeSwap router function "getAmountsOut".
I'm using web3.py to call the PancakeSwap's router contract's getAmountsOut function, and every time I increase the "amountIn" field by 1000 units, I get an amountOut that shows no sign of approaching a maximum amount.
Aka:
1000 BUSD -> 51 CAKE
1,000,000,000,000,000 BUSD -> 51,268,108,544,566 CAKE
1,000,000,000,000,000,000,000 BUSD -> 51,266,437,221,038,640,244 CAKE
There is not 51 quintillion CAKE in the CAKE/BUSD pool, so this function is returning a false value.
When I use the same code for UniSwapV2, and change the tokens to ERC20s, the output amount approaches a maximum, which is the number of "buy" token in the liquidity pool.
My code (python):
buy_amount = router_contract.functions.getAmountsOut(
sell_amount,
[sell_token_contract_address, buy_token_contract_address] # [SELL, BUY]
).call()