The RockPaperScissors contract collects tokens from players in token-based games but never uses these collected tokens. Instead, it mints new tokens for winners and refunds. This leads to tokens being permanently locked in the contract and unnecessary inflation of the token supply, potentially devaluing the token over time.
When players create or join a token-based game, they transfer tokens to the contract:
However, when distributing prizes or refunds, the contract mints new tokens instead of using the ones it collected:
This means that for every token game played:
The contract collects 2 tokens (1 from each player)
It mints 2 new tokens (either both to the winner or 1 to each player in a tie/cancel)
The original 2 tokens remain locked in the contract forever
This token handling mechanism has several severe impacts:
Permanent Token Lock: Tokens transferred to the contract are never used or returned, effectively removing them from circulation permanently.
Token Supply Inflation: For each game played, the total supply of tokens increases by 2, leading to inflation that could devalue the token over time.
Economic Imbalance: As more games are played, the ratio of locked tokens to circulating tokens increases, potentially creating economic instability in the token ecosystem.
Contract Insolvency Risk: If the contract is ever upgraded or replaced, the locked tokens may become permanently inaccessible.
Misaligned Incentives: The current mechanism incentivizes playing more games to mint more tokens, rather than focusing on winning games based on skill.
This is classified as a high severity issue because it directly impacts the economic model of the protocol and could lead to significant devaluation of the token over time.
Manual code review
Static analysis of the contract's token handling mechanisms
Economic analysis of the token supply model
Implement a proper token recycling mechanism that uses the collected tokens instead of minting new ones:
Use transfer instead of mint for prize distribution:
For tie scenarios, return the original tokens:
For cancellations, return the original tokens:
If a fee mechanism is implemented (as suggested in the previous issue), consider burning tokens for the fee rather than keeping them in the contract:
These changes would prevent token inflation and ensure that tokens are properly recycled within the ecosystem, maintaining the token's economic value over time.
Mints new tokens upon game completion or cancellation for token-based games
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.