Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Invalid

Precision loss in `Auction.sol` while calculating the price.

Summary

The Auction::getPrice() function suffers from precision loss due to the use of 6-decimal values for startingPrice and reservePrice. As a result, price calculations may round down to zero in certain cases, leading to incorrect auction pricing behavior.

Vulnerability Details

The getPrice() function determines the auction price over time using linear interpolation:

function getPrice() public view returns (uint256) {
if (block.timestamp < state.startTime) return state.startingPrice;
if (block.timestamp >= state.endTime) return state.reservePrice;
return state.startingPrice - (
(state.startingPrice - state.reservePrice) *
(block.timestamp - state.startTime) /
(state.endTime - state.startTime)
);
}

Issue:

  • startingPrice and reservePrice are defined with 6 decimals (e.g., 10e6 and 5e6 for USDC-like tokens).

  • The division (block.timestamp - state.startTime) / (state.endTime - state.startTime) results in a fraction that, when multiplied with startingPrice - reservePrice, often rounds down to zero.

Example Calculation:

Assume the following values:

  • state.startTime = 234

  • state.endTime = 1,037,034 (234 + 12 days)

  • state.startingPrice = 10e6

  • state.reservePrice = 5e6

  • block.timestamp = 236

The price calculation:

price = 10e6 - ((10e6 - 5e6) * (236 - 234) / 1036800)
price = 10e6 - ((5e6) * 2 / 1036800)

Since (5e6 * 2) / 1036800 rounds to 0, the price remains 10e6, causing no effective price drop in early timestamps.

This issue persists throughout the auction, preventing proper price adjustments and potentially leading to unfair purchases at incorrect prices.

Impact

  • Auction price does not update correctly due to rounding errors.

Tools Used

  • Manual code review

  • Solidity debugging

  • Hardhat/Foundry tests

Recommendations

  1. Increase precision by using higher decimal values (e.g., 18 decimals) for startingPrice and reservePrice to reduce rounding errors.

Updates

Lead Judging Commences

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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