Core Contracts

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

LendingPool does not rebalance liquidity on repayment

Summary

The LendingPool does not call liquidity rebalancing when users repay their debts, causing excess liquidity to remain in the contract instead of being transferred to the Curve vault

Vulnerability Details

LendingPool has a function _rebalanceLiquidtiy() which gets called after every liquidity movement actions in the contract (i.e., deposit, withdraw, borrow) in order not to keep excess liquidity in the contract but to transfer it to the Curve vault (where it might earn yield) and in such way maintain their desired buffer ratio. The function is defined as follows:

function _rebalanceLiquidity() internal {
// if curve vault is not set, do nothing
if (address(curveVault) == address(0)) {
return;
}
uint256 totalDeposits = reserve.totalLiquidity; // Total liquidity in the system
uint256 desiredBuffer = totalDeposits.percentMul(liquidityBufferRatio);
uint256 currentBuffer = IERC20(reserve.reserveAssetAddress).balanceOf(reserve.reserveRTokenAddress);
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);
}

However, during the repayment process—when users repay their debt by transferring back the tokens—this function is not called, even though the contract's balance changes, which is incorrect. Therefore, it is necessary to call _rebalanceLiquidity() upon debt repayment as well, ensuring that the excess liquidity is properly deposited into the Curve vault and the desired buffer ratio is maintained.

Impact

Low

Tools Used

Manual Review

Recommendations

Call _rebalanceLiquidity() at the end of the _repay() function

Updates

Lead Judging Commences

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

LendingPool::finalizeLiquidation or repay doesn't call _rebalanceLiquidity, leaving excess funds idle instead of depositing them in Curve vault for yield

Support

FAQs

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

Give us feedback!