Open code423n4 opened 2 years ago
WatchPug
In Stream#updateStreamInternal(), the result of rewardPerToken() can be cached to avoid unnecessary storage reads.
Stream#updateStreamInternal()
rewardPerToken()
https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/Locke.sol#L216-L222
// accumulate reward per token info cumulativeRewardPerToken = rewardPerToken(); // update user rewards ts.rewards = earned(ts, cumulativeRewardPerToken); // update users last cumulative reward per token ts.lastCumulativeRewardPerToken = cumulativeRewardPerToken;
Can be changed to:
// accumulate reward per token info uint256 _cumulativeRewardPerToken = rewardPerToken(); cumulativeRewardPerToken = _cumulativeRewardPerToken; // update user rewards ts.rewards = earned(ts, _cumulativeRewardPerToken); // update users last cumulative reward per token ts.lastCumulativeRewardPerToken = _cumulativeRewardPerToken;
https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/Locke.sol#L559-L565
Handle
WatchPug
Vulnerability details
In
Stream#updateStreamInternal()
, the result ofrewardPerToken()
can be cached to avoid unnecessary storage reads.https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/Locke.sol#L216-L222
Can be changed to:
https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/Locke.sol#L559-L565
Can be changed to: