Submitted by kenzo, also found by IllIllI, PP1004, blackscale, and hansfriese
When swapping amongst multiple pairs in RubiconRouters _swap, the fee is wrongly accounted for.
Not all of the users funds would be forwarded to RubiconMarket, therefore the user would lose funds.
The _swap function is calculating the pay amount to send to RubiconMarket.sellAllAmount to be:
But this would lead to not all of the funds being pulled by RubiconMarket.
I mathematically show this in this image.
The correct parameter that needs to be sent to sellAllAmount is:
I mathematically prove this in this image.
Change the parameter to the abovementioned one.
bghughes (Rubicon) confirmed
HickupHH3 (judge) commented:
