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

No slippage protection in `sellProfits()`

Summary

sellProfits() is vulnerable to sandwich attacks as it contains no slippage protection.

Vulnerability Details

sellProfits() swaps loan tokens for collateral tokens using a swap router.

function sellProfits(address _profits) 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, //@audit no slippage protection
sqrtPriceLimitX96: 0
});
amount = swapRouter.exactInputSingle(params);
IERC20(WETH).transfer(staking, IERC20(WETH).balanceOf(address(this)));
}

But it uses 0 for amountOutMinimum and it's vulnerable to sandwich attacks which is described here.

Impact

sellProfits() might lose funds due to sandwich attacks.

Tools Used

Manual Review

Recommendations

sellProfits() should use a positive amountOutMinimum.

Support

FAQs

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