AbstractRewardMine._handleStakePadding calls totalDeclaredReward and this way balanceOf function twice #128
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
hyh
Vulnerability details
Impact
Gas is overspent on access and function calls.
Proof of Concept
totalDeclaredReward is called by _handleStakePadding twice:
https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/AbstractRewardMine.sol#L180
While totalDeclaredReward does expensive balanceOf call:
https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/AbstractRewardMine.sol#L97
Recommended Mitigation Steps
It is viable to at least remove its double usage:
Now:
To be:
The text was updated successfully, but these errors were encountered: