Summary
The emitted event will give false data of how many RAACs were minted.
Vulnerability Details
function mintRewards(address to, uint256 amount) external nonReentrant whenNotPaused {
if (msg.sender != address(stabilityPool)) revert OnlyStabilityPool();
uint256 toMint = excessTokens >= amount ? 0 : amount - excessTokens;
excessTokens = excessTokens >= amount ? excessTokens - amount : 0;
if (toMint > 0) {
raacToken.mint(address(this), toMint);
}
raacToken.safeTransfer(to, amount);
emit RAACMinted(amount);
}
It emits with amount
instead of toMint
, which makes it to report false data.
Impact
Off chain applications and Dapps relie on informations given by events, this could lead to several problems in applications, misleading the end user.
Tools Used
Manual
Recommendations
function mintRewards(address to, uint256 amount) external nonReentrant whenNotPaused {
if (msg.sender != address(stabilityPool)) revert OnlyStabilityPool();
uint256 toMint = excessTokens >= amount ? 0 : amount - excessTokens;
excessTokens = excessTokens >= amount ? excessTokens - amount : 0;
if (toMint > 0) {
raacToken.mint(address(this), toMint);
}
raacToken.safeTransfer(to, amount);
// @audit wrong param used, should be toMint
- emit RAACMinted(amount);
+ emit RAACMinted(toMint);
}