The FjordAuction::auctionEnd
function calculates the claim multiplier rate at the end of the auction. When a bidder wants to claim their tokens, this multiplier is used to determine the claimable amount. However, if the auction token has fewer decimals (e.g., 6 like USDC or even 2 like Gemini USD), the claimable amount calculation can be flawed. In extreme cases, the multiplier itself can be set to 0 if the totalBids
amount is too large.
When calculating the multiplier, if the totalTokens
amount is less than totalBids / PRECISION_18
, the multiplier will be set to 0. For example, if the auction token has 2 decimals and 10,000 of it is being auctioned, but the totalBids
is higher than 1,000,000 tokens, the multiplier would be 0. Additionally, for claimable amount calculations, if userBids * multiplier
is less than PRECISION_18
, the user will lose their funds. For example, if the auction multiplier is equal to 1_000_000 * 1e18 / 1_000_000e18 = 1
, and a user deposited less than 1e18
, their deposit will result in zero tokens.
If the multiplier faces precision loss and is set to zero, all bidders will lose their points, and the funds will be stuck in the contract forever. The other scenario, where a user's claimable amount is zero due to precision issues, is less severe because it affects only smaller deposits and is less likely to occur.
The proof of concept for the first case is demonstrated using the weird-erc20
repository and the existing auction.t.sol
test suite. Note that the token used here has 2 decimals and showcases the most extreme case, but the issue can also occur with tokens having more decimals.
Manual Review
Adjust the calculation logic to handle tokens with low decimals more gracefully, possibly by increasing precision or using a different approach to prevent the multiplier from becoming zero.
Consider implementing additional checks and safeguards to ensure users' claims are accurately processed even with low-decimal tokens.
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.