Vault#swap() swaps amountIn: _amount - fees but expects amountOutMinimum equal to _amount converted to the other token without fees subtracted, hence swapping less and expecting more.
When performing a swap() in a SmartVault itself, in the call to the swap router, it can be observed the following:
minimumAmountOut - the amount we expect to get out of the swap is either 0 or is calculated by converting _amount amount of _inToken to _outToken:
It doesn't take the swap fee by no means, meaning the swaps are prone to fail in the case when collateralValueMinusSwapValue < requiredCollateralValue (in calculateMinimumAmountOut()) as when otherwise, minimumAmountOut will be 0.
Swaps within a vault between two tokens are guaranteed to fail as the contract is swapping less tokens (_amount - swapFee) while expecting more (_amount of _inToken converted to _outToken without swap fees subtracted).
Manual review
When calculating minimumAmountOut subtract swapFee from _amount passing the value: calculateMinimumAmountOut(_inToken, _outToken, _amount - swapFee)
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.