Submitted by Ruhum, also found by IllIllI, berndartmueller, eccentricexit, blackscale, and hansfriese
The swapEntireBalance() function allows the user to pass a buy_amt_min value which is the minimum number of tokens they should receive from the swap. But, the function doesnt pass the value to the underlying swap() function. Thus, the users min value will be ignored. Since that will result in unexpected outcomes where user funds might be lost, I rate this issue as HIGH.
swapEntireBalance():
The second parameter of the _swap() call should be the min out value. Instead maxAmount.sub(buy_amt_min.mul(expectedMarketFeeBPS).div(10000)) is used.
Example:
So instead of using 99 the function uses 95.05 which could result in the user receiving fewer tokens than they expected.
Pass buy_amt_min directly to _swap().
bghughes (Rubicon) marked as duplicate:
HickupHH3 (judge) commented:
