earnSnow Function Renders Feature IneffectiveNormal Behavior: The earnSnow() function in the Snow.sol contract is intended to allow users to receive a predefined quantity of Snow tokens for free, once per week, during the FARMING_DURATION. This mechanism is designed to encourage user engagement and provide a no-cost entry point to acquiring Snow tokens.
Specific Issue: The earnSnow() function calls _mint(msg.sender, 1). Given that the Snow token uses a PRECISION of 10**18 (standard for 18 decimal ERC20 tokens), this mints only 1 wei of the Snow token (i.e., 1 / 10^18 of a full Snow token). This amount is infinitesimally small and practically valueless, making the "earn for free" feature ineffective and misleading to users. A similar issue exists in the buySnow() function where the amount parameter is also treated as wei instead of full tokens.
Likelihood: High
A user calls the earnSnow() function after the 1-week cooldown period and during the FARMING_DURATION.
A user calls the buySnow() function, intending to purchase a specific number of full Snow tokens.
Impact: Medium
Ineffective Token Distribution Mechanism: The earnSnow() feature, designed as a way to distribute tokens and engage users, fails to achieve its purpose due to the negligible amount minted.
Potential Loss of Funds (for buySnow): While the earnSnow issue is about not receiving value, the similar issue in buySnow means users pay the full fee for X tokens but receive X wei of tokens, which is a direct financial loss relative to their expectation. If s_buyFee is significant, this becomes a more severe loss.
Airdrop Eligibility Issues: If Snow token balances are critical for eligibility in the SnowmanAirdrop (e.g., needing at least 1 full Snow token), users relying on earnSnow() or buySnow() (with its current bug) will never accumulate enough tokens to participate, despite their actions.
The following Foundry test, testEarnSnowMintsNegligibleAmount from TestSnow.t.sol, demonstrates that calling earnSnow() results in the user's balance increasing by only 1 wei, not 1 full token.
The test output will show Ashley's balance after first earnSnow (in wei): 1.
Modify the _mint calls within earnSnow() and buySnow() to use the PRECISION constant to ensure the correct number of full tokens (or their wei equivalent) is minted.
For earnSnow(), if the intention is to mint 1 full Snow token:
For buySnow(), assuming amount parameter is the number of full tokens the user wants to buy:
Note on buySnow mitigation: The buySnow logic for handling ETH vs WETH and exact payment amounts needs careful consideration beyond just fixing the _mint call. The diff above simplifies the payment check for ETH; a more robust implementation would clearly differentiate payment paths and handle msg.value appropriately. The core fix for this specific vulnerability is amount * PRECISION. The s_buyFee should also be clearly defined as the price per full token.
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.