In the provided code snippet, the swapFee
is not considered in the calculation of minimumAmountOut
within the SmartVaultV3::swap
function. While it is correctly applied to the amountIn
, this inconsistency can lead to inaccurate calculations of the minimum amount to be received (amountOutMinimum
) for the Uniswap router.
In most cases, minimumAmountOut
will be higher than the actual conversion of amountIn
(as it is equal to _amount - swapFee
) to the _outToken
. This inconsistency will cause the swap to revert because amountOutMinimum
is set too high.
To address this issue, it is recommended to subtract the swapFee
from the amount
in the SmartVaultV3::calculateMinimumAmountOut
function to calculate a more accurate minimumAmountOut
. Additionally, it is advised to rewrite calculateMinimumAmountOut
to only calculate a real value and create a separate function (wontBeUndercollateralised
) to check that the vault will not be undercollateralized.
Below is a possible example:
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.