The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: low
Invalid

`SmartVaultV3.sol` executes swap without slippage protection

Summary

The SmartVaultV3.sol conducts swaps without implementing slippage protection, posing a risk of fund loss due to sandwich attacks.

Vulnerability Details

The SmartVaultV3.sol initiates swaps via the Swaps library, which independently computes slippage parameters, leading to inaccuracies. To ensure correct slippage calculations (min/out), they should be computed externally before the swap transaction. Otherwise, the library relies on modified pool values within the transaction, potentially resulting in incorrect min out values.

function swap(bytes32 _inToken, bytes32 _outToken, uint256 _amount) external onlyOwner {
uint256 swapFee = _amount * ISmartVaultManagerV3(manager).swapFeeRate() / ISmartVaultManagerV3(manager).HUNDRED_PC();
address inToken = getSwapAddressFor(_inToken);
uint256 minimumAmountOut = calculateMinimumAmountOut(_inToken, _outToken, _amount);
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
tokenIn: inToken,
tokenOut: getSwapAddressFor(_outToken),
fee: 3000,
recipient: address(this),
deadline: block.timestamp,
amountIn: _amount - swapFee,
amountOutMinimum: minimumAmountOut,
sqrtPriceLimitX96: 0
});
inToken == ISmartVaultManagerV3(manager).weth() ?
executeNativeSwapAndFee(params, swapFee) :
executeERC20SwapAndFee(params, swapFee);
}

Impact

Users withdrawing their rewards may face a loss of funds due to the vulnerability of swaps being sandwiched.

Tools Used

Manual Review

Recommendations

The transaction's calldata should incorporate slippage parameters, which are then passed to the Swap library. This ensures accurate handling of slippage during the swap operation.

Updates

Lead Judging Commences

hrishibhat Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

informational/invalid

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!