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

swap don't have slippage protection

Summary

swap should have slippage protection

Vulnerability Details

/// @notice swap loan tokens for collateral tokens from liquidations
/// @param _profits the token to swap for WETH
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,
sqrtPriceLimitX96: 0
});
amount = swapRouter.exactInputSingle(params);
IERC20(WETH).transfer(staking, IERC20(WETH).balanceOf(address(this)));
}
}

amountOutMinimum is minimum value user will receive value for user,if it's set to zero,user could get unexepted small value

Impact

user could get very small swap value,Then while the transaction is in the mempool, it is exploited for example like in https://medium.com/coinmonks/defi-sandwich-attack-explain-776f6f43b2fd

Tools Used

manual

Recommendations

add amountOutMinimum param in sellProfits function

Support

FAQs

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