Flow

Sablier
FoundryDeFi
20,000 USDC
View results
Submission Details
Severity: low
Invalid

Discrepancy between Condition and comment in `_coveredDebtOf` Function of `SablierFlow` Contract

Description

A discrepancy exists between the comment and the implemented condition in the _coveredDebtOf function within the SablierFlow contract. Specifically, the comment suggests that the function should return the balance when the balance is "less than or equal to" the total debt. However, the actual implementation checks for a strictly "less than" condition. This inconsistency can lead to unintended behavior if the balance is exactly equal to the total debt.

// If the stream balance is less than or equal to the total debt, return the stream balance.
if (balance < totalDebt) {
return balance;
}

The current condition only checks if balance is strictly less than totalDebt (using <), not considering the scenario where balance is equal to totalDebt. This discrepancy can cause the function to proceed and return totalDebt.toUint128() in cases where balance == totalDebt, potentially causing unexpected outcomes.

Impact

If the balance is equal to the totalDebt, the function does not behave as expected based on the comment, which suggests that balance should be returned. Instead, it proceeds to the next statement, returning totalDebt.toUint128(). This could lead to confusion for developers and auditors reviewing the code and potentially impact functionality if any dependent code expects balance to be returned in cases where balance == totalDebt.

Tools Used

Manual Review

Recommendations

Ensure that comments reflect the function's actual implementation and purpose. If the function logic is ever modified, corresponding comments should be reviewed and updated to prevent inconsistencies.

Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

[INVALID]`_coveredDebtOf` discrepancy between condition and comment `balance < totalDebt`

Support

FAQs

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