sherlock-audit / 2022-11-telcoin-judging

0 stars 0 forks source link

Met - [gas] not using the return variable #55

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

Met

informational

[gas] not using the return variable

Summary

Local variable is returned, wasting gas.

Vulnerability Detail

In StakingModule::totalSupply() the return variable is not used and a local variable is returned instead, which wastes gas.

Note: This applies to multiple methods in the StakingModule and other places too.

Impact

Code Snippet

https://github.com/sherlock-audit/2022-11-telcoin/blob/main/contracts/StakingModule.sol#L79-L89

Tool used

Manual Review

Recommendation

Change to

    function totalSupply() external view returns (uint256 total) {
        // loop over all plugins and sum up totalClaimable
        for (uint256 i = 0; i < nPlugins; i++) {
            total += IPlugin(plugins[i]).totalClaimable();
        }

        // totalSupply is the total claimable from all plugins plus the total amount staked
        total + _totalStaked;
    }

And do the same update in other similar functions in the StakingModule and other places.