The calculation for the amountOutMinimum
doesn't account for fees that is reduced from the amountIn
. This can result in a constant revert due to slippage and the fact that the amountIn
is insufficient.
In the swap()
function we can see that a swapFee
is charged to the user whenever they are executing a swap. This can be seen from the code snippet below:
We can see that the amountIn
value reflects that a swap fee reduction is factored in. But at the same time the calculation for the amountOutMinimum
does not factor this in, we can see this from the the code below:
Here we see that the function call calculateMinimumAmountOut()
does not factor in the reduction in amount to be swapped due to the fees.
This can result in the swap()
transaction constantly reverting due to the failure in accounting for the swap amount. In times of high volatility this can result in a user being liquidated when they should've been able to swap their funds, but instead losing it all to liquidations.
Manual Review
To solve this issue, the following code change can be made to reflect the change in amount to be swapped due to the value of fees charged to the user.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.