The Standard

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

Slippage could be 0

Summary

There is situation, when user will do swap without slippage protection

Vulnerability Details

Function calculateMinimumAmountOut() uses for calculate minimal required amount of collateral tokens on contract balance after users's swap.
But, this function could return zero value, so when user will make swap, amountOutMinimum value will be specified as 0, which provides an opportunity to carry out a MEV attack.

function calculateMinimumAmountOut(bytes32 _inTokenSymbol, bytes32 _outTokenSymbol, uint256 _amount) private view returns (uint256) {
...
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);

As we can see, if collateralValueMinusSwapValue value will be greater on equal to requiredCollateralValue, function return zero value.

Impact

An attack could make MEV attack, and decrease price of token TokenIN in exchange pool, and the user will exchange his tokens unprofitably and the vault will become undercollateralised.

Tools Used

Manual review

Recommendations

In all cases, always specify amountOutMinimum value > 0. Function calculateMinimumAmountOut() always should return

calculator.eurToToken(getToken(_outTokenSymbol), requiredCollateralValue - collateralValueMinusSwapValue);
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.