FjordAuction::auctionEnd function has a erraneous calculation , causing it to revert when FjordAuction::totalTokens is a large value , making users unable to claim their rewards , and tokens are forever stuck in the contract
auctionEnd function has the following line:
Even though this line uses the SafeMath library of open-zeppelin , if totalTokens.mul(PRECISION_18) overflows , this will revert .
This will revert only if totalTokens is set to a very large value . That value can be calculated as follows
Any value greater than c will cause the overflow.
If it reverts , ended flag cannot be set true , and hence FjordAuction::claimTokens can never be called due to the following check
Now , this totalTokens value is set in the constructor by whoever is deploying the contract. There is a very low chance the the deployer would be willing to put up so many tokens to be distributed (precisely greater than c as shown above) , but if they do , then the auction can never be completed AND money in the form of 2 tokens , FjordAuction::fjordPoints and FjordAuction::auctionToken , will be stuck in the contract forever.
A bidder bids in the auction
The auction ends
Somebody calls the auctionEnd function , which reverts
In your auction.t.sol , change your totalTokens value to the following
And remember to comment out the following line
And , place the following test into auction.t.sol test suite
You will also notice that if you change your totalTokens variable to c+1 , 3 of your pre-written tests ALSO FAIL .
Bidders cannot claim their rewards , and both FjordAuction::fjordPoints and FjordAuction::auctionToken tokens are forever stuck in the contract
Foundry , Manual Review
Best mitigation is to check beforehand whether `totalTokens.mul(PRECISION_18)` will overflow , and if it will , carry out the division before the multiplication , as shown in the following code
By making this change , you will see that all of your tests in auction.t.sol will pass even with very lage values of totalPoints .
Only one of the tests , auction.t.sol::testAuctionEnd will not pass as it has the same erraneous line , fix it , and then all your tests will pass.
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.