TempleGold

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

The Checks `rewardAmount < rewardDuration` in `distributeRewards()` could be problematic

Summary

Vulnerability Details

The Checks rewardAmount < rewardDuration in distributeRewards() could be problematic towards the ending of TampleGoldminting when it reach near its limits.

In minting contract of Temple Gold there is strict requirement that MINIMUM_MINT = 10000 etherbut this could be adjusted towards ending

function _canDistribute(uint256 mintAmount) private view returns (bool) {
return mintAmount != 0 && _totalDistributed + mintAmount == MAX_SUPPLY ? true : mintAmount >= MINIMUM_MINT;

And this minting amount split in 3 parts with predefined ratio and 1part comes to Staking contract as Reward

In this staking contract in distributeReward()it has check that

function distributeRewards() updateReward(address(0), 0) external {
...
...
uint256 rewardAmount = nextRewardAmount;
// revert if next reward is 0 or less than reward duration (final dust amounts)
if (rewardAmount < rewardDuration ) { revert CommonEventsAndErrors.ExpectedNonZero(); } // @audit at ending this could be problamatic as L-4
...
}

where rewardDuration should be always > WEEK

function setRewardDuration(uint256 _duration) external override onlyElevatedAccess {
// minimum reward duration
if (_duration < WEEK_LENGTH) { revert CommonEventsAndErrors.InvalidParam(); }
// only change after reward epoch ends
if (rewardData.periodFinish >= block.timestamp) { revert InvalidOperation(); }
rewardDuration = _duration;
emit RewardDurationSet(_duration);
}

So at end This distributeReward()could always revert if Reward amount decreased from WEEK value

https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol/contracts/templegold/TempleGoldStaking.sol#L107-L114

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

Impact

Tools Used

Manual review

Recommendations

Should reconsider this

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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