Core Contracts

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

In `Burn` function we are burning `amount` but emiting `Scaledamount` in contract DebtToken .sol

Summary

In Burn function we are burning amount but emiting the amountScaled .

Vulnerability Details

In the contract DebtToken.sol , In Burn function we are emiting amountScaled but burning amount .

uint256 amountScaled = amount.rayDiv(index);
if (amountScaled == 0) revert InvalidAmount();
_burn(from, amount.toUint128()); // q why we are downcasting amount not amountScaled
emit Burn(from, amountScaled, index);
function burn(
address from,
uint256 amount,
uint256 index
) external override onlyReservePool returns (uint256, uint256, uint256, uint256) {
if (from == address(0)) revert InvalidAddress();
if (amount == 0) {
return (0, totalSupply(), 0, 0);
}
uint256 userBalance = balanceOf(from);
uint256 balanceIncrease = 0;
if (_userState[from].index != 0 && _userState[from].index < index) {
uint256 borrowIndex = ILendingPool(_reservePool).getNormalizedDebt();
balanceIncrease = userBalance.rayMul(borrowIndex) - userBalance.rayMul(_userState[from].index);
amount = amount;
}
_userState[from].index = index.toUint128(); // q why we are downcasting index not amount ?
if(amount > userBalance){
amount = userBalance;
}
uint256 amountScaled = amount.rayDiv(index);
if (amountScaled == 0) revert InvalidAmount();
_burn(from, amount.toUint128()); // q why we are downcasting amount not amountScaled
emit Burn(from, amountScaled, index);
return (amount, totalSupply(), amountScaled, balanceIncrease);
}

https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/tokens/DebtToken.sol#L211

Impact

  1. It will emit the amountScaled (which is not burned) in place of amount (which is burned) in function .

  2. It will revert the wrong thing .

Tools Used

Manual Review

Recommendations

  1. we should replace the amountScaled with amount .

Updates

Lead Judging Commences

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

RToken::burn emits wrong event info

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

RToken::burn emits wrong event info

Support

FAQs

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