#42351 [SC-Insight] Yeetback complex rewards system
Submitted on Mar 23rd 2025 at 08:01:58 UTC by @Dimaranti for Audit Comp | Yeet
Report ID: #42351
Report Type: Smart Contract
Report severity: Insight
Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/Reward.sol
Impacts:
Description
Brief/Intro
Yeetback has a reward system where for each round it is remembered how much is going to be paid to winners and how many wins the user has in this round. This also leads to the fact that the user needs to claim his rewards for each round separately
What can be done instead is there could be a mapping mapping(address => uint256) amountWon;
which accumulates all the amounts won by the user. Simplifying the contract logic and easing users who have won in multiple rounds to be able to claim their rewards at once.
Vulnerability Details
Here are the 3 mappings currently responsible for rewards management:
https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeetback.sol#L38-L40
And here is how they are updated first the winnings for the current round are calculated and set into the amountToWinners
mapping.
https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeetback.sol#L77
Then for each time the user is drawn by the rng for the current round the amountOfWins
for the user is increased
https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeetback.sol#L85
And finally when the user claims his reward he provides a round
. And the claimed
mapping for the given round and user is set to true.
https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeetback.sol#L129
And he is being sent amountToWinners[round] * amountOfWins[round][msg.sender]
https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Yeetback.sol#L130
Well this all can be refactored to a single mapping(address => uint256) amountWon;
which accumulates all the rewards won by the user and when the user claims it is set back to 0. See PoC for suggested diff.
Impact Details
References
Proof of Concept
Proof of Concept
Suggested changes
Was this helpful?