The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: low
Invalid

Inefficient Gas Usage Due to Lack of Reward Amount Check in claimRewards Function

Summary

The claimRewards function in the smart contract allows users to claim their rewards for various tokens. However, it currently lacks a check to prevent execution when the reward amounts are zero. This oversight can lead to unnecessary gas consumption when users call this function without having any rewards to claim.

Vulnerability Details

The function iterates over an array of accepted tokens, checking and processing rewards for each. If a user has a reward amount greater than zero for a token, the function facilitates the transfer of rewards. However, if a user has no rewards (i.e., all reward amounts are zero), the function will still execute and complete the iteration, consuming gas without performing any meaningful action. This lack of a preliminary check for non-zero rewards allows any user to call the function and incur gas costs even when there are no rewards to be claimed.

Impact

The primary issue here is the inefficient use of gas, which can lead to unnecessary expenses for users. Additionally, it may clutter the blockchain with transactions that have no effect, slightly contributing to network congestion. This inefficiency is against best practices in smart contract development, where minimizing unnecessary gas consumption is a key goal.

Tools Used

Manual Review

Recommendations

Introduce a check in the claimRewards function to determine if the user has any non-zero rewards across all tokens.

Updates

Lead Judging Commences

hrishibhat Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

informational/invalid

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!