Core Contracts

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

Total amount of raacTokens locked is not updated during withdrawal

Summary

The lock() and increase() functions in the veRAACToken contract correctly increment the _lockState.totalLocked variable when tokens are locked. However, the withdraw() and emergencyWithdraw() functions do not decrement this variable when tokens are withdrawn, leading to an inconsistent state in the contract.

Vulnerability Details

In the lock() and increase() functions, the total amount of tokens locked is tracked by incrementing the _lockState.totalLocked variable. This ensures that the contract maintains an accurate record of the total tokens locked at any given time.

state.totalLocked += amount;

Conversely, in the withdraw() and emergencyWithdraw() functions, while tokens are being removed from the user's lock, the _lockState.totalLocked variable is not decremented.

uint256 amount = userLock.amount;
// @audit-info Clears lock data
delete _lockState.locks[msg.sender];
---SNIP---
// @audit-info transfers tokens to user
raacToken.safeTransfer(msg.sender, amount);
>> // @audit-issue Fails to update totalLocked

This oversight means that the total locked amount does not reflect the actual state of the contract, leading to potential issues in future locking operations or checks against the maximum total locked amount.

Impact

MAX_TOTAL_LOCKED_AMOUNT defines how many tokens can be locked globally. Since the total locked amount is not updated correctly, this limit may be reached preventing further locks when in reality the actual amount of tokens locked is way below it.

Tools Used

Manual Review

Recommendations

Decrement the _lockState.totalLocked variable by the amount being withdrawn.

raacToken.safeTransfer(msg.sender, amount);
+ // @audit update totalLocked
+ _lockState.totalLocked -= amount;
Updates

Lead Judging Commences

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

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

inallhonesty Lead Judge 7 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.

Give us feedback!