Core Contracts

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

Incorrect event emission in `LendingPool::_rebalanceLiquidity`

Summary

The LendingPool::_rebalanceLiquidity function emits an incorrect event parameter.

Vulnerability Details

The LendingPool::_rebalanceLiquidity is called upon borrow, withdraw and deposit to ensure the desired buffer is maintained by either depositing excess to the vault or withdrawing the shortfall from the vault.

function _rebalanceLiquidity() internal {
// . . . Rest of the code ...
if (currentBuffer > desiredBuffer) {
uint256 excess = currentBuffer - desiredBuffer;
// Deposit excess into the Curve vault
_depositIntoVault(excess);
} else if (currentBuffer < desiredBuffer) {
uint256 shortage = desiredBuffer - currentBuffer;
// Withdraw shortage from the Curve vault
_withdrawFromVault(shortage);
}
emit LiquidityRebalanced(currentBuffer, totalVaultDeposits); <<@ - // Incorrect event emitted
}

However, the event emitted at the end can be fairly determined as incorrect, rationale for the same:-

  1. The totalVaultDeposits emitted here is the updated value on the contrast the currentBuffer is the old value and not the actual desiredBuffer.

  2. It is impossible to predict from the event whether the liquidity re-balance involved depositing into the vault or withdrawing from the vault.

These observations conclude that the intended event could have shown desired buffer or the change made to the current buffer or a totalVaultDeposits before update happened.

Impact

  1. The event emitted is incorrect / useless in terms of not being able to draw out any conclusion whether the excess was deposited or shortage was fulfilled or the current desired buffer.

  2. Offchain mechanism would hallucinate with such data.

Tools Used

Manual Review

Recommendations

It is recommended to emit the desired buffer instead:

function _rebalanceLiquidity() internal {
// . . . Rest of the code . . .
emit LiquidityRebalanced(desiredBuffer, totalVaultDeposits);
}
Updates

Lead Judging Commences

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

LendingPool::_rebalanceLiquidity emits an event with stale buffer

Invalidated by appeal in 1090

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

LendingPool::_rebalanceLiquidity emits an event with stale buffer

Invalidated by appeal in 1090

Appeal created

inallhonesty Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

LendingPool::_rebalanceLiquidity emits an event with stale buffer

Invalidated by appeal in 1090

Support

FAQs

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