sherlock-audit / 2024-06-magicsea-judging

2 stars 0 forks source link

dhank - masterChef.sol :: While Updating LumPersec the pools are not updated before hand #693

Closed sherlock-admin3 closed 1 month ago

sherlock-admin3 commented 2 months ago

dhank

High

masterChef.sol :: While Updating LumPersec the pools are not updated before hand

Summary

While Updating LumPersec the pools are not updated before

Vulnerability Detail

_updateAll() is commented out here

    function setLumPerSecond(uint96 lumPerSecond) external override onlyOwner {
        if (lumPerSecond > Constants.MAX_LUM_PER_SECOND) revert MasterChef__InvalidLumPerSecond();

        // _updateAll(_voter.getTopPoolIds()); // todo remove this //.. @audit why commented

        _lumPerSecond = lumPerSecond;

        emit LumPerSecondSet(lumPerSecond);
    }

this results in the pools to be updated using the new lumPersec for the reward calculation for the past deposit too. This will affect the providers in an unexpected way .

Impact

While Updating LumPersec the pools are not updated before

Code Snippet

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

Tool used

Manual Review

Recommendation

Duplicate of #177