Submitted by ZanyBonzy, also found by Q7, Tigerfrake, and DadeKuma
In swap_2_internal, if the first pool doesnt have enough liquidity, amount_in could be less than original_amount, and as expected, amount_in is taken from swapper. But the function still refunds original_amount - amount_in to the user if original_amount is more than amount_in.
From the function, we can see than amount_in is taken from swapper. Then the function checks if original_amount is more than amount_in, before which the difference is transferred back to the sender.
An unnecessary refund is processed leading to loss of funds for the protocol. Malicious users can take advantage of this to rob the protocol of funds through the refunds.
No need to process refunds since amount_in is already taken.
Context
af-afk (Superposition) confirmed
0xsomeone (judge) commented:
af-afk (Superposition) commented:
0xsomeone (judge) commented:
af-afk (Superposition) commented:
0xsomeone (judge) commented:
af-afk (Superposition) commented:
