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

Users are forced to swap tokens with no slippage protection

Summary

sellProfits allows users to swap tokens but lacks the capability to specify any slippage values.

Vulnerability Details

The sellProfits function uses Uniswap to swap tokens with amountOutMinimum = 0, leaving users vulnerable to sandwich attacks and potential loss of all their tokens.

Impact

User can be sandwiched, leading to the potential loss of all tokens.

Tools Used

Manual review

Recommendations

To mitigate the risks, allow users to specify a slippage parameter.

-function sellProfits(address _profits) public {
+function sellProfits(address _profits, uint256 _amountOutMinimum) public {
require(_profits != WETH, "not allowed");
uint256 amount = IERC20(_profits).balanceOf(address(this));
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter
.ExactInputSingleParams({
tokenIn: _profits,
tokenOut: WETH,
fee: 3000,
recipient: address(this),
deadline: block.timestamp,
amountIn: amount,
- amountOutMinimum: 0,
+ amountOutMinimum: _amountOutMinimum,
sqrtPriceLimitX96: 0
});
amount = swapRouter.exactInputSingle(params);
IERC20(WETH).transfer(staking, IERC20(WETH).balanceOf(address(this)));
}

Support

FAQs

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