TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: medium
Invalid

Auction startTime is calculated wrong in some scenarios

Summary

When calculation auction startTime, the period between the last auction endTime and current block.timestamp is not taken into account.

Vulnerability Details

https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol/contracts/templegold/DaiGoldAuction.sol#L122

In the DaiGoldAuction::startAuction when calculation the startTime, the time between prevoius action endTime and current block.timestamp is not taken into account and cooldown period is applied anyway.


```solidity
function startAuction() external override {

if (auctionStarter != address(0) && msg.sender != auctionStarter) { revert CommonEventsAndErrors.InvalidAccess(); }

EpochInfo storage prevAuctionInfo = epochs[_currentEpochId];

if (!prevAuctionInfo.hasEnded()) { revert CannotStartAuction(); }

AuctionConfig storage config = auctionConfig;

/// @notice last auction end time plus wait period

if (_currentEpochId > 0 && (prevAuctionInfo.endTime + config.auctionsTimeDiff > block.timestamp)) {

revert CannotStartAuction();

}

_distributeGold();

uint256 totalGoldAmount = nextAuctionGoldAmount;

nextAuctionGoldAmount = 0;

uint256 epochId = _currentEpochId = _currentEpochId + 1;

if (totalGoldAmount < config.auctionMinimumDistributedGold) { revert LowGoldDistributed(totalGoldAmount); }

EpochInfo storage info = epochs[epochId];

info.totalAuctionTokenAmount = totalGoldAmount;

uint128 startTime = info.startTime = uint128(block.timestamp) + config.auctionStartCooldown;

uint128 endTime = info.endTime = startTime + AUCTION_DURATION;

emit AuctionStarted(epochId, msg.sender, startTime, endTime, totalGoldAmount);

}
```

This is incorrect because the cooldown period may have passed long time ago from the previous auction endTime.

Impact

Increased waiting period before auction start.

Tools Used

Manual review

Recommendations

Check if previous auction.endtime + cooldown duration >= block.timestamp

Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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