You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Incorrect Protocol Activity-Time Calculation in Distribution Module Due to Unaccounted Pauses
### Summary:
The distribution module incorrectly computes timePassed by simply subtracting lastOnChainDistributionTimestamp from block.timestamp. This calculation does not account for pauses in the contract, leading to incorrect distribution values upon resumption.
### Finding Description:
The _calculateGamma function calculates time elapsed (timePassed) since the last distribution:
However, the DistributionModule supports pausing and resuming, the time the contract spends in a paused state should not count towards timePassed. Since the function does not account for pauses, the distribution formula treats the entire elapsed time as active distribution time, which can cause incorrect calculations.
The integrity of the distribution mechanism is then compromised.
### Impact Explanation:
This issue directly affects financial calculations, i suppose the impact is Medium.
### Proof of Concept:
Assume the contract is paused for 90 days:
// Last on-chain distribution was 6 months ago
$.lastOnChainDistributionTimestamp =block.timestamp-180days;
// Contract is paused for 90 dayspause();
wait(90 days);
unpause();
// timePassed should be 90 days, but incorrectly calculates as 180 daysuint256 timePassed =block.timestamp- $.lastOnChainDistributionTimestamp;
Expected:timePassed = 90 days Actual:timePassed = 180 days → Incorrect gamma scaling
### Recommendation
Fix: Track Unpaused Time Instead of Using block.timestamp Directly
Modify timePassed to exclude paused durations:
Amateur Banana Fish
Medium
Incorrect Protocol Activity-Time Calculation in Distribution Module Due to Unaccounted Pauses
### Summary:
The distribution module incorrectly computes
timePassed
by simply subtractinglastOnChainDistributionTimestamp
fromblock.timestamp
. This calculation does not account for pauses in the contract, leading to incorrect distribution values upon resumption.### Finding Description:
The _calculateGamma function calculates time elapsed (timePassed) since the last distribution:
However, the
DistributionModule
supports pausing and resuming, the time the contract spends in a paused state should not count towardstimePassed
. Since the function does not account for pauses, the distribution formula treats the entire elapsed time as active distribution time, which can cause incorrect calculations.The integrity of the distribution mechanism is then compromised.
Affected Code: here.
### Impact Explanation:
This issue directly affects financial calculations, i suppose the impact is Medium.
### Proof of Concept:
Expected:
timePassed = 90 days
Actual:
timePassed = 180 days
→ Incorrect gamma scaling### Recommendation
Fix: Track Unpaused Time Instead of Using block.timestamp Directly
Modify timePassed to exclude paused durations:
The text was updated successfully, but these errors were encountered: