DeFiFoundry
20,000 USDC
View results
Submission Details
Severity: low
Invalid

In FjordAuction.sol the decimals of auction token in not considered

Summary

In FjordAuction.sol the decimals of auction token in not considered in auctionEnd() and claimTokens().

Vulnerability Details

There is no restriction for auction token to be 18 decimals. It can be USDC and can have 6 decimals. Which is not handled in the contract.

https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordAuction.sol#L197
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordAuction.sol#L217

Impact

In case of USDC if the totalTokens:totalBids ratio is 1:1e6 or more then the multiplier will be 0. Which will lead to bidder getting 0 and auctionToken amount getting stuck in the contract.

Tools Used

Vs Code

Recommendations

Normalise the auction token decimals to 18 to avoid precision losses and unwanted flows.

function auctionEnd() external {
if (block.timestamp < auctionEndTime) {
revert AuctionNotYetEnded();
}
if (ended) {
revert AuctionEndAlreadyCalled();
}
ended = true;
emit AuctionEnded(totalBids, totalTokens);
if (totalBids == 0) {
auctionToken.transfer(owner, totalTokens);
return;
}
@> multiplier = (totalTokens.mul(10 ** (18 - auctionToken.decimals()))).mul(PRECISION_18).div(totalBids);
// Burn the FjordPoints held by the contract
uint256 pointsToBurn = fjordPoints.balanceOf(address(this));
fjordPoints.burn(pointsToBurn);
}
function claimTokens() external {
if (!ended) {
revert AuctionNotYetEnded();
}
uint256 userBids = bids[msg.sender];
if (userBids == 0) {
revert NoTokensToClaim();
}
@> uint256 claimable = (userBids.mul(multiplier).div(PRECISION_18)).div(10 ** (18 - auctionToken.decimals()));
bids[msg.sender] = 0;
auctionToken.transfer(msg.sender, claimable);
emit TokensClaimed(msg.sender, claimable);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge
10 months ago
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

Low decimal tokens or super small bids can lead to 0 claims

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.