SablierFlow performs continuous token streaming calculations requiring multiple conversions between token decimals and fixed-point math (18 decimals). These conversions happen during debt calculations (_totalDebtOf
), ongoing debt tracking (_ongoingDebtScaledOf
), and withdrawal operations, each involving scaling and descaling operations. The protocol's core accounting relies on precise debt to balance comparisons for solvency checks, making the rounding behavior in these numerical operations critical for maintaining accurate stream states and token flow accounting.
The issue revolves around inconsistent and potentially unsafe rounding in debt calculations. Here's where it manifests:
The protocol performs multiple scaling and descaling operations, each potentially rounding in different directions. For debt calculations, rounding down could understate debt, while for balance comparisons, these rounded values affect solvency determinations. This becomes particularly problematic when dealing with tokens of different decimals or when amounts approach rounding boundaries, potentially allowing streams to appear solvent when they should be insolvent due to accumulated rounding effects.
The inconsistent rounding behavior across SablierFlow's debt calculations creates subtle arithmetic discrepancies that compound through the protocol's accounting system. Each scaling operation between token decimals and fixed-point math introduces potential precision loss, with debt calculations typically rounding down while comparisons use these imprecise values for critical solvency determinations.
This asymmetric rounding propagates through stream operations, gradually eroding the protocol's accounting accuracy and potentially allowing streams to operate in technically insolvent states. The cumulative effect of these rounding inconsistencies becomes particularly acute with high-precision tokens or high-frequency operations, where the accumulated error can materialize as real financial discrepancies between expected and actual token flows, undermining the protocol's core promise of precise token streaming.
The fix implements consistent, conservative rounding that always rounds up for debt calculations and maintains a safety margin, ensuring the protocol remains solvent even under worst-case rounding scenarios.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.