DeFiHardhat
12,000 USDC
View results
Submission Details
Severity: low
Invalid

Unused return value in `MultiFlowPump::readLastCappedReserves` can lead to incorrect behavior, wasted gas, and can cause severe contract disruption

Description:
In the readLastCappedReserves function of the MultiFlowPump contract, the return value of the readLastReserves() function is not fully utilized. The second return value, which likely represents the last timestamp, is ignored and not assigned to any variable. This can lead to incorrect behavior if the unused return value contains critical information needed for further processing.

Impact:
Ignoring the return value of readLastReserves() has a few consequences:

  1. If the ignored value contains important data, such as the last timestamp, it may lead to incorrect calculations or decisions within the readLastCappedReserves function.

  2. If the readLastReserves() function performs computations or has side effects to generate the unused return value, those operations will be wasted, resulting in unnecessary gas consumption.

  3. The code becomes less readable and maintainable, as it is not clear why the return value is being discarded (include natspec).

Proof of Concept:
The following line of code in the readLastCappedReserves function demonstrates the unused return value:

(uint8 numberOfReserves,, bytes16[] memory lastReserves) = _getSlotForAddress(well).readLastReserves();

The second return value is not assigned to any variable and is effectively ignored.

Recommended Mitigation:
To tackle this problem, it's advisable to manage the unused return value properly. If the value isn't required, assign it to a variable with an underscore prefix to signal that it's intentionally disregarded. For example:

(uint8 numberOfReserves, uint40 _lastTimestamp, bytes16[] memory lastReserves) = _getSlotForAddress(well).readLastReserves();

If the unused return value contains important information, it should be assigned to a properly named variable and used accordingly within the function.

Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational/Invalid

Support

FAQs

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