Flow

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

SablierFlow::pause() Updates snapshotTime Which is not Supposed to Happen (Unintended State Modification + Gas Inefficiency)

Description

The SablierFlow::pause() function currently updates the snapshotTime in SablierFlow::_adjustRatePerSecond(). According to ISablierFlow::pause() doc, the snapshotTime should not be updated when the SablierFlow::pause() is called. In SablierFlow::_adjustRatePerSecond(), setting snapshotTime to the current timestamp when newRatePerSecond is zero introduces unnecessary gas costs.

Impact

  1. Gas Inefficiency

Recommended Mitigation

Update the SablierFlow::_adjustRatePerSecond() function as follows:

function _adjustRatePerSecond(uint256 streamId, UD21x18 newRatePerSecond) internal {
// Check: the new rate per second is different from the current rate per second.
if (newRatePerSecond.unwrap() == _streams[streamId].ratePerSecond.unwrap()) {
revert Errors.SablierFlow_RatePerSecondNotDifferent(streamId, newRatePerSecond);
}
uint256 ongoingDebtScaled = _ongoingDebtScaledOf(streamId);
// Update the snapshot debt only if the stream has ongoing debt.
if (ongoingDebtScaled > 0) {
// Effect: update the snapshot debt.
_streams[streamId].snapshotDebtScaled += ongoingDebtScaled;
}
// Effect: update the snapshot time.
- _streams[streamId].snapshotTime = uint40(block.timestamp);
+ if(newRatePerSecond.unwrap() != 0) {
+ _streams[streamId].snapshotTime = uint40(block.timestamp);
+ }
// Effect: set the new rate per second.
_streams[streamId].ratePerSecond = newRatePerSecond;
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
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.