The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: low
Invalid

consolidatePendingStakes will skip stakes which were made at the time of the deadline

Summary

There is an off-by-one issue in the if statement.

Vulnerability Details

In the consolidatePendingStakes function, there is an off-by one issue when the if statement is executed.

function consolidatePendingStakes() private {
uint256 deadline = block.timestamp - 1 days;
for (int256 i = 0; uint256(i) < pendingStakes.length; i++) {
PendingStake memory _stake = pendingStakes[uint256(i)];
if (_stake.createdAt < deadline) {
positions[_stake.holder].holder = _stake.holder;
positions[_stake.holder].TST += _stake.TST;
positions[_stake.holder].EUROs += _stake.EUROs;
deletePendingStake(uint256(i));
// pause iterating on loop because there has been a deletion. "next" item has same index
i--;
}
}
}

As you can see, the check will execute only if the stake was created before the deadline, but the deadline should be inclusive as they should not be accepted after the deadline.

Impact

This can leave behind some stakes, which will result in loss of funds

Tools Used

Manual Review

Recommendations

Change the if statement as follows:

if (_stake.createdAt <= deadline)
Updates

Lead Judging Commences

hrishibhat Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

informational/invalid

Support

FAQs

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

Give us feedback!