The Standard

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

Slippage protection is ineffective in the `swap()` function

Summary

Slippage protection is ineffective in the swap() function. minimumAmountOut can be zero and this means no slippage protection.

Vulnerability Details

The Swap() function in SmartVaultV3.sol use calculateMinimumAmountOut() function to calculate the minimumAmountOut value:

function calculateMinimumAmountOut(bytes32 _inTokenSymbol, bytes32 _outTokenSymbol, uint256 _amount) private view returns (uint256) {
ISmartVaultManagerV3 _manager = ISmartVaultManagerV3(manager);
uint256 requiredCollateralValue = minted * _manager.collateralRate() / _manager.HUNDRED_PC();
uint256 collateralValueMinusSwapValue = euroCollateral() - calculator.tokenToEur(getToken(_inTokenSymbol), _amount);
return collateralValueMinusSwapValue >= requiredCollateralValue ?
0 : calculator.eurToToken(getToken(_outTokenSymbol), requiredCollateralValue - collateralValueMinusSwapValue);
}

This function calculate the minimum amount of an output token that needs to be received in a token swap operation. The problem is that this function is designed to safeguard the vault's collateralization ratio, not to protect against market slippage. It can return a zero value and so the swap() function remains without slippage protection.

Impact

Without slippage, If the price of the tokens changes significantly during the swap, it could result in a large slippage, causing users to lose a significant amount of funds.

Tools Used

Visual Studio Code

Recommendations

It would be better to pass the minimumAmountOut value as a parameter in the swap() function

Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Slippage-issue

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

Slippage-issue

Support

FAQs

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