Raspy Black Giraffe
High
The incorrect condition in liquidity checks will allow liquidity rule bypass for increasing taker orders
A missing conditional check in liquidityChecks() will cause a bypass of liquidity rules for increasing taker orders as the function improperly applies liquidity checks under unintended scenarios. This inconsistency could lead to systemic risks in market stability
Root Cause
In liquidityChecks() the condition :
return !marketParameter.closed &&
((long(self).isZero() && short(self).isZero()) || increasesTaker(self));
includes increasesTaker(self) as a condition under which liquidity checks apply. This contradicts the intended behavior stated in the comment, which implies liquidity checks should not apply to increasing taker orders.
- The market must be open
- The order must either have no position changes (long(self).isZero() && short(self).isZero() == true) or be an increasing taker order (increasesTaker(self) == true).
No response
- A user submits an increasing taker order.
- The liquidityChecks() function evaluates the order.
- Liquidity checks improperly apply (or fail to bypass) due to the inclusion of increasesTaker(self) in the condition.
The protocol may allow invalid orders to bypass liquidity rules incorrectly. This could lead to:
- Collateral underfunding for increasing taker orders.
- Systemic risk of market destabilization due to insufficient liquidity enforcement.
Potential Loss: This depends on the volume and leverage of increasing taker orders. In a worst-case scenario, it could result in cascading liquidation events or insolvency.
No response
To resolve this issue, revise the condition in liquidityChecks() to ensure increasing taker orders bypass liquidity checks when appropriate. For example:
return !marketParameter.closed &&
((long(self).isZero() && short(self).isZero()) || !increasesTaker(self));