Users should be able to purchase Snow tokens using WETH or native ETH. The cost should scale proportionally to the amount of tokens they wish to buy based on the s_buyFee (e.g., if the fee is 1 WETH per token, buying 1 full token should cost 1 WETH).
The contract incorrectly multiplies a standard ERC-20 amount (which inherently has 18 decimals) by s_buyFee (which is also scaled to 18 decimals in the constructor). This double-multiplication results in an astronomical required payment of 1e36 wei to purchase a single full token, making it mathematically and practically impossible for users to buy tokens.
Likelihood:
Occurs 100% of the time a user attempts to purchase a standard, full unit of the Snow token (1e18 wei).
Impact:
Complete failure of the purchasing mechanic.
Users are either completely blocked from participating due to insufficient funds (revert), or if they attempt to buy fractions of a token, they are egregiously overcharged (paying 1 full ETH for 1 single wei of a token).
Narrative Setup: The following Foundry test proves the scaling error. It simulates a user attempting to buy exactly one full Snow token (1e18). We mint the user a massive amount of WETH (1,000,000 WETH) to prove that even a whale cannot afford a single token. The test expects the WETH transferFrom to revert because the required cost evaluates to 1e36 (One quintillion WETH).
Execution Steps:
We simulate a wealthy user (Alice) with 1,000,000 WETH.
Alice approves the Snow contract to spend her WETH.
Alice attempts to buy 1 full Snow token (1 ether / 1e18 wei).
The transaction reverts due to an arithmetic/balance error because the contract tries to pull 1e36 wei.
How to run this test: Place the following code inside the protocol's existing TestSnow.t.sol file and execute: forge test --match-test test_POC_Precision -vvv
Architectural Fix: To fix the double-multiplication, the contract must divide the total calculated cost by the PRECISION constant (which is 1e18). This normalizes the decimal places and ensures that buying 1e18 tokens correctly costs the s_buyFee amount.
This fix maintains the precision required for fractional token purchases without astronomically overcharging the user.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.