Closed sherlock-admin2 closed 4 months ago
Low/Info issue submitted by mstpr-brainbot
Unnecessary check in isolated position.
Isolated positions can be liquidated if the following condition has to be correct as its defined in DecreasePositionProcess::decreasePosition() function:
if (cache.settledMargin < 0 && !cache.isLiquidation && !position.isCrossMargin) { revert Errors.PositionShouldBeLiquidation(); }
cache variable is filled in the DecreasePositionProcess::_updateDecreasePosition() internal function
cache
As we can observe in the _updateDecreasePosition internal function cache.isLiquidation value is never assigned which means it is default to false.
cache.isLiquidation
false
no need to check it since its default to "false".
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/8a1a01804a7de7f73a04d794bf6b8104528681ad/elfi-perp-contracts/contracts/process/DecreasePositionProcess.sol#L60-L77
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/8a1a01804a7de7f73a04d794bf6b8104528681ad/elfi-perp-contracts/contracts/process/DecreasePositionProcess.sol#L206-L336
Manual Review
Remove the !cache.isLiquidation
!cache.isLiquidation
Unnecessary check in decrease position
Low/Info issue submitted by mstpr-brainbot
Summary
Unnecessary check in isolated position.
Vulnerability Detail
Isolated positions can be liquidated if the following condition has to be correct as its defined in DecreasePositionProcess::decreasePosition() function:
cache
variable is filled in the DecreasePositionProcess::_updateDecreasePosition() internal functionAs we can observe in the _updateDecreasePosition internal function
cache.isLiquidation
value is never assigned which means it is default tofalse
.no need to check it since its default to "false".
Impact
Code Snippet
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/8a1a01804a7de7f73a04d794bf6b8104528681ad/elfi-perp-contracts/contracts/process/DecreasePositionProcess.sol#L60-L77
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/8a1a01804a7de7f73a04d794bf6b8104528681ad/elfi-perp-contracts/contracts/process/DecreasePositionProcess.sol#L206-L336
Tool used
Manual Review
Recommendation
Remove the
!cache.isLiquidation