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.
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.
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.
Manual Review
Introduce a check in the claimRewards function to determine if the user has any non-zero rewards across all tokens.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.