The FjordAuction contracts are used to distribute auction tokens to users who bid their FjordPoints.
At the end of the auction period, auctionEnd() is called and users can start claiming their tokens using claimTokens().
When auctionEnd() is called, a multiplier is calculated based upon the totalTokens (the auction tokens for users to claim) and the totalBids (the fjord points that were deposited in the auction).
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordAuction.sol#L197
During the claim process, claimTokens() will calculate the claimable amount of tokens for the user using the multiplier.
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordAuction.sol#L217
Truncation may occur due to the division by PRECISION_18. This truncated amount will not be distributed to the user and will accumulate for each user.
Here is a PoC that can be pasted in test\unit\auction.t.sol and demonstrates 97 users bidding an amount of fjord points that will result in dust being stuck in the auction contract:
Depending on the amount of tokens that are distributed by the auction, the amount of fjord points deposited by the users and due to the way Solidity rounds integer, after all users have claimed their tokens, a residual amount of tokens will most likely not be distributed to users and be stuck in the contract.
This issue can represent a relatively dramatic financial loss for the protocols (Fjord on one hand AND the protocol that emitted the token on the other hand AS WELL AS the protocol users) depending on the amount stuck in the contract and the actual value of the token.
Manual review
Add a function that will be responsible for retrieving the dust amount after all users have claimed their rewards.
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.