sherlock-audit / 2024-06-magicsea-judging

2 stars 0 forks source link

Lone Opaque Mustang - `setLumPerSecond()` will be applied retroactively #700

Closed sherlock-admin4 closed 2 months ago

sherlock-admin4 commented 2 months ago

Lone Opaque Mustang

Low/Info

setLumPerSecond() will be applied retroactively

Summary

setLumPerSecond() will apply the new lumPerSecond immediately from every pool's lastUpdateTimestamp to their next update time, which may increase / decrease unaccounted rewards thus far.

Vulnerability Detail

setLumPerSecond() updates _lumPerSecond, which is the reward rate distribution for all active pools. Should an active pool have lastUpdateTimestamp < block.timestamp, this new rate is applied from lastUpdateTimestamp to block.timestamp, unintentionally increasing / decreasing the accounted rewards thus far.

Impact

Unfair reward distribution rate applied to un-updated active pools.

Code Snippet

https://github.com/sherlock-audit/2024-06-magicsea/blob/7fd1a65b76d50f1bf2555c699ef06cde2b646674/magicsea-staking/src/MasterchefV2.sol#L352-L360

Tool used

Manual Review

Recommendation

There should be a @dev note to ensure updateAll() is called on all active pools prior to the setLumPerSecond() call, like how it's done with Voter.setTopPoolIdsWithWeights().