Flow

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

It is advisable to Safecast `snapshotTime` from `uint40` to `uint256`

Summary

The depletionTimeOf function in the SablierFlow contract adds the snapshotTime (a uint40) to solvencyPeriod (a uint256) without explicit casting of snapshotTime to uint256. This approach is safe and does not introduce overflow or data loss, as Solidity will automatically promote uint40 to uint256 during arithmetic operations. Additionally, the function's return value will not be affected by whether explicit casting is used. However, implicit casting may obscure the code’s intent, particularly in sensitive calculations.

Vulnerability Details

Lack of complete code clarity.

Impact

None - Informational

Tools Used

Manual review

Recommendations

  1. Explicit Type Casting for Readability:

    1. Recommendation: Although not required for safety, consider explicitly casting snapshotTime to uint256 in the depletionTimeOf function to improve code readability and signal awareness of type differences

    2. Suggested Code Change:

      if (solvencyAmount % ratePerSecond == 0) {
      - depletionTime = _streams[streamId].snapshotTime + solvencyPeriod;
      + depletionTime = uint256(_streams[streamId].snapshotTime) + solvencyPeriod;
      }
      // Otherwise, round up depletion time by one second; ensures smallest timestamp where debt exceeds balance.
      else {
      - depletionTime = _streams[streamId].snapshotTime + solvencyPeriod + 1;
      + depletionTime = uint256(_streams[streamId].snapshotTime) + solvencyPeriod + 1;
      }
      }
    3. Rationale: This will make it clear to future auditors and developers that the type promotion is intentional, increasing confidence in arithmetic involving type differences.

  2. Code Clarity Documentation:

    • Recommendation: Add comments explaining the safe promotion from uint40 to uint256 to ensure transparency and maintainability in type-sensitive calculations.

Updates

Lead Judging Commences

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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