The _depositIntoVault function in the LendingPool contract approves the Curve vault to spend tokens from the LendingPool contract. However, the LendingPool contract does not hold any assets, as all deposits are held in the RToken contract. This causes the deposit into the Curve vault to always fail and _rebalanceFunction useless.
The current approval in the _depositIntoVault function is:
This line attempts to approve the Curve vault to spend tokens from the LendingPool contract, which does not hold any assets. As a result, the subsequent deposit into the Curve vault fails.
link to the issue: https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/pools/LendingPool/LendingPool.sol#L800
This issue prevents the LendingPool contract from correctly depositing excess liquidity into the Curve vault, potentially leading to liquidity management issues within the protocol.
Manual code review.
There are two possible recommendations to address this issue:
Make Deposits into the LendingPool Contract:
Update the logic to ensure that the LendingPool contract holds the assets before approving and depositing them into the Curve vault.
Relocate the Rebalance Function to the RToken Contract:
Move the _rebalanceLiquidity function to the RToken contract, which holds the assets. This ensures that the approval and deposit operations are performed by the contract that holds the assets.
Example of relocating the rebalance function:
This ensures that the assets held in the RToken contract are correctly approved and deposited into the Curve vault.
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.