Core Contracts

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

increase lock will revert even when the voting power is legitimately increased.

Summary

increase lock will revert even when the voting power is legitimately increased.

Vulnerability Details

Following is increase function

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
);
// Update checkpoints
uint256 newPower = uint256(uint128(newBias));
_checkpointState.writeCheckpoint(msg.sender, newPower);
// Transfer additional tokens and mint veTokens
raacToken.safeTransferFrom(msg.sender, address(this), amount);
_mint(msg.sender, newPower - balanceOf(msg.sender));
emit LockIncreased(msg.sender, amount);
}

Suppose initially the user had voting power = 100 therefore 100 tokens minted to the user.

Now suppose 3/4th of the locking period has passed and the voting power left = 25 tokens i,e current voting power. Now the user wants to increase the voting power by adding some tokens and his current power becomes 50 ve raac tokens.

So as of now his current voting power has increased from 25 to 50. Now what happens is when _mint is called following happens

_mint(msg.sender, newPower - balanceOf(msg.sender));

Here new power = 50 tokens and balanceof(msg.sender) = 100 tokens initially minted. therefore this will revert even tough the current voting power of the user increased to 50 he wouldn't be able to mint those tokens.

Impact

Unnecessary revert will happen

Tools Used

Manual

Recommendations

Do check if new power is greater than balance of msg.sender or not

Updates

Lead Judging Commences

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

veRAACToken::increase underflows on newPower - balanceOf(msg.sender)

Support

FAQs

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

Give us feedback!