Precision error in Auction::buy() means buyers will always pay astronomically higher than they should when they want to buy ZENO tokens. Every single time.
P.S. I checked the LightChaser report for this contest. This finding is not reported. So, this cannot be invalidated ๐๐
The ::buy() function calculates the cost a buyer should pay by multiplying the amount of tokens they want to buy, and the current slippage price per token, and then requires that this amount is transferred from the buyer to the businessAddress.
But because both values (amount of tokens to be bought and current slippage price) are in e18, the cost ends up being in e36.
One of three things will happen:
If sufficient approval is given by the buyer to the Auction contract and the buyer has such amount in usdc worth (very unlikely), the buyer pays the astronomical cost
If sufficient approval is given by the buyer to the Auction contract and the buyer does not have such amount in usdc worth (very likely), the transfer reverts with an ERCInsuffientBalance() error
If the buyer doesn't give sufficient approval, the transfer reverts with an ERCInsufficientAllowance() error
P.S. I commented out zeno.mint(msg.sender, amount); because there is a bug related to it, and I want to post the traces of this finding without that bug interfering. I will also report that bug as a separate finding.
Foundry
Run the following test in Foundry:
And we can read the logs for the result:
Refactor the buy() function so that the cost is divided by 1e18 before it is being transferred from the buyer
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.