The calculateBonus function in the StakingBonus contract redundantly calculates the bonus amount, leading to inefficient gas usage. The redundant calculation occurs when returning the bonus value after checking the contract's token balance.
once to assign the value to the bonus variable and again before returning the value. This redundant calculation consumes unnecessary gas and increases execution time.
https://github.com/zerolend/governance/blob/a30d8bb825306dfae1ec5a5a47658df57fd1189b/contracts/vesting/StakingBonus.sol#L92C5-L95C42
function calculateBonus( uint256 amount ) public view override returns (uint256) { uint256 bonus = (amount * bonusBps) / 100; // if we don't have enough funds to pay out bonuses, then return 0 if (zero.balanceOf(address(this)) < bonus) return 0; return (amount * bonusBps) / 100; } }
@deadshotryker @M3gA-Mind
The calculateBonus function in the StakingBonus contract redundantly calculates the bonus amount, leading to inefficient gas usage. The redundant calculation occurs when returning the bonus value after checking the contract's token balance.
once to assign the value to the bonus variable and again before returning the value. This redundant calculation consumes unnecessary gas and increases execution time.
https://github.com/zerolend/governance/blob/a30d8bb825306dfae1ec5a5a47658df57fd1189b/contracts/vesting/StakingBonus.sol#L92C5-L95C42
function calculateBonus( uint256 amount ) public view override returns (uint256) { uint256 bonus = (amount * bonusBps) / 100; // if we don't have enough funds to pay out bonuses, then return 0 if (zero.balanceOf(address(this)) < bonus) return 0; return (amount * bonusBps) / 100; } }
@deadshotryker @M3gA-Mind