20,000 USDC
View results
Submission Details
Severity: high
Valid

No slippage control on deposit of `Fees.sellProfits`

Summary

There is no slippage control on sellProfits of Fees.sol, which expose user to sandwich attack.

Vulnerability Details

src/Fees.sol:
25 /// @param _profits the token to swap for WETH
26: function sellProfits(address _profits) public {
27: require(_profits != WETH, "not allowed");
28: uint256 amount = IERC20(_profits).balanceOf(address(this));
29:
30: ISwapRouter.ExactInputSingleParams memory params = ISwapRouter
31: .ExactInputSingleParams({
32: tokenIn: _profits,
33: tokenOut: WETH,
34: fee: 3000,
35: recipient: address(this),
36: deadline: block.timestamp,
37: amountIn: amount,
38: amountOutMinimum: 0,
39: sqrtPriceLimitX96: 0
40: });
41:
42: amount = swapRouter.exactInputSingle(params);
43: IERC20(WETH).transfer(staking, IERC20(WETH).balanceOf(address(this)));
44: }
45 }

Impact

The way slippage protection is implemented in decentralized exchanges is by letting user choose how far the actual price is allowed to drop. By default, Uniswap V3 sets slippage tolerance to 0.1%, which means a swap is executed only if the price at the moment of execution is not smaller than 99.9% of the price the user saw in the browser

Tools Used

Manuel Code Review

Recommendations

To protect against slippage, let the user set the slippage value

Support

FAQs

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