Assessment reports>GTE -- Perp>Medium findings>Incorrect ,ZeroCostTrade, revert condition
Category: Coding Mistakes

Incorrect ZeroCostTrade revert condition

Medium Severity
Low Impact
Low Likelihood

Description

The _matchIncomingAsk function in the PerpCLOB contract includes a check designed to prevent zero-cost trades. The intention is to revert if one of totalQuoteTokenReceived or totalBaseTokenSent is zero while the other is nonzero.

if (totalQuoteTokenReceived == 0 && totalBaseTokenSent == 0) {
    if (totalQuoteTokenReceived != totalBaseTokenSent) revert ZeroCostTrade();
}

However, this logic incorrectly uses && instead of || in the primary condition. Thus, the check fails to throw a ZeroCostTrade where one amount is zero and the other is not.

Impact

The check fails to prevent zero-cost trades. Such trades can occur during order settlement when the base amount is a small nonzero value and the quote amount becomes zero due to rounding down in division.

Recommendations

We recommend modifying the condition to use the || operator instead of &&.

- if (totalQuoteTokenReceived == 0 && totalBaseTokenSent == 0) {
+ if (totalQuoteTokenReceived == 0 || totalBaseTokenSent == 0) {

Remediation

This issue has been acknowledged by Liquid Labs, Inc., and a fix was implemented in commit fc41a758.

Zellic © 2025Back to top ↑