Sablier

Sablier
DeFiFoundry
53,440 USDC
View results
Submission Details
Severity: low
Invalid

`helpers#calculateSegmentTimestamps` can directly return when `segmentCount` is 0 or 1

Summary

helpers#calculateSegmentTimestamps can directly return when segmentCount is 0 or 1

Vulnerability Details

Function helpers#calculateSegmentTimestamps:

function calculateSegmentTimestamps(LockupDynamic.SegmentWithDuration[] memory segments) {
uint256 segmentCount = segments.length;
segmentsWithTimestamps = new LockupDynamic.Segment[](segmentCount);
...
segmentsWithTimestamps[0] = LockupDynamic.Segment({
amount: segments[0].amount,
exponent: segments[0].exponent,
timestamp: startTime + segments[0].duration
});
// Copy the segment amounts and exponents, and calculate the segment timestamps.
for (uint256 i = 1; i < segmentCount; ++i) {
segmentsWithTimestamps[i] = LockupDynamic.Segment({
amount: segments[i].amount,
exponent: segments[i].exponent,
timestamp: segmentsWithTimestamps[i - 1].timestamp + segments[i].duration
});
}
...
}

When segmentCount is 0 or 1, the function can directly return instead of subsequently calling the for loop.

Impact

Cost more gas.

Tools Used

vscode, Manual Review

Recommendations

The function can directly return when segmentCount is 0 or 1.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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