The _rebalanceLiquidity function is responsible for balancing liquidity between curveVault and reserveRTokenAddress. However, the function incorrectly assumes that excess liquidity is stored in LendingPool and tries to deposit funds from the LendingPool. Since the actual funds are in reserveRTokenAddress, the deposit attempt will fail. Additionally, the withdrawal logic does not correctly place funds back into reserveRTokenAddress, leading to potential liquidity mismanagement.
Let’s assume:
Total liquidity in the system = 1,000
Liquidity buffer ratio = 10%
Desired buffer (desiredBuffer) = 10% of 1,000 = 100
Current buffer (currentBuffer) = 90
Now, since currentBuffer (90) is less than desiredBuffer (100), the contract will try to withdraw 10 tokens from the Curve Vault using _withdrawFromVault(10).
What goes wrong?
The withdrawn funds stay in the contract itself, instead of being transferred to reserveRTokenAddress.
The whole rebalance is incorect, because the funds stays in the LendingPool.
Manual review
Fix how the funds are transfer in and out of the curveVault.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.