_isSafe and _isSolidSafe could become unavailable due to DoS
Summary
_isSafe and _isSolidSafe will revert if state.openPositions[trader].length is too big
Vulnerability Detail
Above functions are used when calculating if a position is liquidatable.
Both call getTotalExposure which illiterates over state.openPositions[trader].
Since the array is never decreased, over time or when a user sends multiple 0 value trades (which is not checked), it will get too big and revert when used by getTotalExposure
Delvir0
high
_isSafe and _isSolidSafe could become unavailable due to DoS
Summary
_isSafe
and_isSolidSafe
will revert ifstate.openPositions[trader].length
is too bigVulnerability Detail
Above functions are used when calculating if a position is liquidatable.
Both call
getTotalExposure
which illiterates overstate.openPositions[trader]
. Since the array is never decreased, over time or when a user sends multiple 0 value trades (which is not checked), it will get too big and revert when used bygetTotalExposure
Impact
Liquidations become unavailable
Code Snippet
https://github.com/sherlock-audit/2023-04-jojo/blob/main/smart-contract-EVM/contracts/lib/Liquidation.sol#L53-L79
Tool used
Manual Review
Recommendation
Decrease
state.openPositions[trader]
when a trade is closed and prevent 0 value trades from increasing itDuplicate of #348