Core Contracts

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

Incorrect Return Value in ReserveLibrary.withdraw() Affects Liquidity and Accounting

Summary

The withdraw() function in the provided contract relies on ReserveLibrary.withdraw() to handle withdrawals. However, due to an incorrect return value in ReserveLibrary.withdraw(), the function misrepresents the actual amount of RTokens burned. This leads to:

Incorrect event logging

Potential liquidity mismanagement

Possible errors in external integrations relying on withdrawal events

Vulnerability Details

function withdraw(uint256 amount) external nonReentrant whenNotPaused onlyValidAmount(amount) {
if (withdrawalsPaused) revert WithdrawalsArePaused();
// Update the reserve state before the withdrawal
ReserveLibrary.updateReserveState(reserve, rateData);
// Ensure sufficient liquidity is available
_ensureLiquidity(amount);
// Perform the withdrawal through ReserveLibrary
(uint256 amountWithdrawn, uint256 amountScaled, uint256 amountUnderlying) = ReserveLibrary.withdraw(
reserve, // ReserveData storage
rateData, // ReserveRateData storage
amount, // Amount to withdraw
msg.sender // Recipient
);
// Rebalance liquidity after withdrawal
_rebalanceLiquidity();
emit Withdraw(msg.sender, amountWithdrawn);
}

Root Cause (Incorrect Return Value in ReserveLibrary.withdraw())

Inside ReserveLibrary.withdraw(), the function incorrectly assigns amountUnderlying to amountWithdrawn:

return (amountUnderlying, burnedScaledAmount, amountUnderlying);

Instead of:

return (burnedScaledAmount, burnedScaledAmount, amountUnderlying);

Impact

Incorrect Event Emission (Withdraw Event Logs Wrong Data)

emit Withdraw(msg.sender, amountWithdrawn);

amountWithdrawn should represent burned RTokens, but instead, it represents amountUnderlying (the actual transferred asset amount).

Any external systems (indexers, analytics tools, or smart contracts) relying on this event will receive incorrect withdrawal data.

This could lead to mispriced rewards, incorrect accounting, or faulty tracking of burned RTokens.

Tools Used

Recommendations

Update the return values in ReserveLibrary.withdraw():

return (burnedScaledAmount, burnedScaledAmount, amountUnderlying);

Updates

Lead Judging Commences

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

ReserveLibrary::withdraw returns amountUnderlying instead of amountWithdrawn, causing incorrect event emissions and potential calculation errors in LendingPool

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

ReserveLibrary::withdraw returns amountUnderlying instead of amountWithdrawn, causing incorrect event emissions and potential calculation errors in LendingPool

Support

FAQs

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