sherlock-audit / 2024-07-exactly-stacking-contracts-judging

6 stars 3 forks source link

Odd Opaque Fox - Redundant `updateIndex` Call in `notifyRewardAmount` Function #114

Closed sherlock-admin3 closed 1 month ago

sherlock-admin3 commented 1 month ago

Odd Opaque Fox

Low/Info

Redundant updateIndex Call in notifyRewardAmount Function

Summary

The notifyRewardAmount function in the contract contains a redundant call to updateIndex.

Vulnerability Detail

The notifyRewardAmount function calls updateIndex(reward) even though updateIndex is already invoked within the internal notifyRewardAmount function.

function notifyRewardAmount(IERC20 reward, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
    updateIndex(reward); // @audit not needed
    notifyRewardAmount(reward, amount, msg.sender);
}

Impact

The redundant call to updateIndex results in unnecessary computation and gas usage. While it does not cause a critical issue, it is an inefficiency that can be optimized to save gas costs and improve the overall performance of the contract.

Code Snippet

function notifyRewardAmount(IERC20 reward, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
    updateIndex(reward); // @audit not needed
    notifyRewardAmount(reward, amount, msg.sender);
}

Tool Used

Manual Review

Recommendation

Remove the redundant call to updateIndex in the notifyRewardAmount function, as it is already being called in the internal notifyRewardAmount function.

function notifyRewardAmount(IERC20 reward, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
    notifyRewardAmount(reward, amount, msg.sender);
}