The Auction contract's buy() function fails to handle decimal precision differences between ZENO (18 decimals) and USDC (6 decimals) tokens, leading to incorrect price calculations and potential transaction failures due to arithmetic overflow.
In the Auction contract's buy()
function:
Example:
Buying 5 ZENO at 3 USDC each:
Current implementation:
amount: 5e18 (5 ZENO)
price: 3e6 (3 USDC)
cost: 3e6 * 5e18 = 15e24 (incorrect)
Expected cost: 15e6 (15 USDC)
Most transactions will revert due to exceeding user's USDC balance
If a transaction succeeds, users would be charged astronomical amounts
Manual code review
Normalize the decimal precision before multiplication:
Add decimal safety checks and tests to verify correct price calculations across different decimal combinations
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.