Core Contracts

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

_lockState.totalLocked has not been lowered on various of places in veRAACToken.sol

Summary

_lockState.totalLocked has not being decreased when calling withdraw() or emergencyWithdraw().

Vulnerability Details

When the totalLocked doesn't get decreased upon withdraw and emergencyWithdraw, it will mess up the calculations of calculateBoost() and getCurrentBoost() functions, which will further return false data.

Impact

Users will receive inflated boost when calling calculateBoost() and getCurrentBoost() as output data.
Which will return unrealistic information.

Tools Used

Manual

Recommendations

Decrease the totalLocked when calling withdraw and emergencyWithdraw

function withdraw() external nonReentrant {
LockManager.Lock memory userLock = _lockState.locks[msg.sender];
if (userLock.amount == 0) revert LockNotFound();
if (block.timestamp < userLock.end) revert LockNotExpired();
uint256 amount = userLock.amount;
uint256 currentPower = balanceOf(msg.sender);
// Clear lock data
delete _lockState.locks[msg.sender];
delete _votingState.points[msg.sender];
+ _lockState.totalLocked -= amount
...
function emergencyWithdraw() external nonReentrant {
if (emergencyWithdrawDelay == 0 || block.timestamp < emergencyWithdrawDelay)
revert EmergencyWithdrawNotEnabled();
LockManager.Lock memory userLock = _lockState.locks[msg.sender];
if (userLock.amount == 0) revert NoTokensLocked();
uint256 amount = userLock.amount;
uint256 currentPower = balanceOf(msg.sender);
+ _lockState.totalLocked -= amount;
...
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Validated
Assigned finding tags:

veRAACToken::withdraw / emergencyWithdraw doesn't substract the `_lockState.totalLocked`

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Validated
Assigned finding tags:

veRAACToken::withdraw / emergencyWithdraw doesn't substract the `_lockState.totalLocked`

Support

FAQs

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