Core Contracts

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

increase() function in veRAACToken.sol will always return a higher bias and slope than actual

Summary

In veRAACToken.sol, increase()function will increase the amount of locked RAAC tokens without changing the lock time, calculating the new bias and slope accordingly based on the additional amount. However, the additional amount passed is over-inflated due to incorrect addition.

Vulnerability Details

function increase(uint256 amount) external nonReentrant whenNotPaused {
// Increase lock using LockManager
_lockState.increaseLock(msg.sender, amount);
_updateBoostState(msg.sender, locks[msg.sender].amount);
// Update voting power
LockManager.Lock memory userLock = _lockState.locks[msg.sender];
(int128 newBias, int128 newSlope) = _votingState.calculateAndUpdatePower(
msg.sender,
userLock.amount + amount,
userLock.end
);
  1. In the above code snippet (snippet #1), the function will call _lockState.increaseLock(msg.sender, amount)internally.

  2. In this function, the user's lock amount is updated, adding the additionalAmount, as seen in Line 15 of snippet #2 below.

    function increaseLock(
    LockState storage state,
    address user,
    uint256 additionalAmount
    ) internal {
    Lock storage lock = state.locks[user];
    if (!lock.exists) revert LockNotFound();
    if (lock.end <= block.timestamp) revert LockExpired();
    // Maximum lock amount
    if (lock.amount + additionalAmount > state.maxLockAmount) revert AmountExceedsLimit();
    // Maximum total locked amount
    // if (state.totalLocked + additionalAmount > state.maxTotalLocked) revert AmountExceedsLimit();
    lock.amount += additionalAmount;
  3. Back to the increase()function, it now updates the boost state and then retrieves the msg.sender's lock struct. (See line 7 in code snippet #1). The amount parameter for msg.sender would already have added the additionalAmount

  4. In the next line, _votingState.calculateAndUpdatePower()is called, passing userLock.amount + amountas the amount. This is over-inflating the user's lock amount, adding additionalAmount a second time

  5. In _votingState.calculateAndUpdatePower(), this function calculates the rate at which the user's voting power decays, and the rate is dependent on the amount locked as well as duration of the lock. Since amount passed into this function is more than the actual additionalAmount, this will hence lead to a higher bias and steeper slope. User will experience faster voting decay than actual.

Impact

Users who increased their RAAC token lock amount will have their voting power decay at a faster rate than actual.

Tools Used

Manual

Recommendations

Pass userLock.amountinstead of userLock.amount + amountwhen calling _votingState.calculateAndUpdatePower()function.

Updates

Lead Judging Commences

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

veRAACToken::increase doubles the voting power of users

Support

FAQs

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

Give us feedback!