Some amount (big or small) of auction token could remain in the contract even if all users claimed their auction tokens if certain conditions are met due to the calculations made for claiming.
The expected behavior is that after all users claim their reward, then the balance of auctionToken for the contract FjordAuction
must be zero.
The method FjordAuction::claimTokens
is responsible for determining the amount of auction tokens a user can claim. It uses the multiplier
state variable and PRECISION_18 with value of 1e18.
The problem is that some amount (big or small) can remain unclaimed by the user due to this calculation.
The amount of unclaimed token depends on the values that were deposited and different cases are analyzed in the table below.
For the sake of simplicity all the cases consist of 3 deposits and an amount of 1000 ether for the supply of the auction token.
Bid 1 (ETH) | Bid 2 (ETH) | Bid 3 (ETH) | Unclaimable Tokens (WEI) |
---|---|---|---|
0.00342333 | 0.0045633333 | 0.005233333 | 1 |
10.003423575968 | 12.004568306787 | 11.005233912676 | 32 |
333 | 333 | 335.14 | 939 |
13334444 | 13344443 | 13354444.14 | 30837575 |
3454242537.333 | 4564534312.33333 | 5234566431325366.3333 | 2600775822962080 |
An amount of auction tokens remain unclaimed.
Manual Review, Foundry
To setup the POC follow these steps:
Add the following method to ERC20BurnableMock
:
Add the following import to auction.t.sol
: import "forge-std/Test.sol";
Add the following method to TestAuction
contract:
Run the command: forge test --mt test_unclaimableAuctionTokens -vvvv
Observe the output - the amount of unreachable auction tokens.
To change the output, modify the values of the variables bidAmount1
, bidAmount2
, bidAmount3
according to the table above.
Consider one of the following or other solutions similar to these:
When the last user makes a claim, send the remainder of the auction token to the owner or burn it.
Consider larger precision value when operating with large bids (larger than the amount of total auction tokens), this will drastically reduce the amount of locked tokens and the rest of them can simply be burned.
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.