Description
The vulnerability exists within the SmartVaultV3::swap() function. The issue arises when calculating the minimumAmountOut parameter for ISwapRouter.ExactInputSingleParams in the SmartVaultV3::calculateMinimumAmountOut() function. This parameter is crucial, especially in risky swaps, as it influences whether the Smart Vault might become liquidatable. The problem lies in not factoring the swapFee into the calculateMinimumAmountOut() call, whereas it's subtracted from the amountIn parameter in the ISwapRouter.ExactInputSingleParams configuration.
Impact
Failure to include the swapFee when calculating the minimumAmountOut could result in a swap reversion or lead to an unpleasant user experience, especially in highly volatile market conditions.
Proof of Concept
Consider the following scenario:
Bob has 1600 USDC and utilizes the entirety as collateral, reaching the maximum mintable amount.
Bob attempts to swap his USDC for 1 ETH using SmartVaultV3::swap().
The calculated swapFee is 50 USDC.
The calculated minimumAmountOut is 1600 USDC.
The inputted amountIn becomes 1600 - 50 = 1550 USDC.
Due to the higher minimumAmountOut value than amountIn, the swap reverts.
Recommended Mitigation
Include the swapFee in the calculation for minimumAmountOut as follows:
Tools Used
Manual Review
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.