The Standard

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

Invalid ExactInputSingleParams Parameters Can Cause Reverts

Summary

The amountOutMinimum is calculated using:

uint256 minimumAmountOut = calculateMinimumAmountOut(
_inToken,
_outToken,
_amount
);

However, this may result in a higher minimumAmountOut than intended, as the amountIn used in the ExactInputSingleParams parameters is _amount - swapFee , which is significantly lower depending on the swapFee. This can lead to more reverted calls than anticipated.

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
});

Impact

The number of reverted calls may increase depending on the size of the swapFee.

Tools Used

Hardhat

Recommendations

Calculate minimumAmountOut with the applied fee:

uint256 minimumAmountOut = calculateMinimumAmountOut(
_inToken,
_outToken,
_amount - swapFee
);

By adjusting the calculation to consider the swapFee, the minimumAmountOut will align with the expected value, reducing the likelihood of reverted calls.

Updates

Lead Judging Commences

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

swapfee-incorrect-calc

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

swapfee-incorrect-calc

Support

FAQs

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