The LendingPool contract integrates with a Curve crvUSD Vault to manage liquidity. During the withdrawal process, the contract incorrectly subtracts a fixed withdrawal amount from the internal tracking variable (totalVaultDeposits) instead of using the actual number of vault shares burned. This discrepancy in accounting can lead to liquidity mismatches over time, potentially impacting the accurate tracking of deposited funds.
In the _withdrawFromVault function, the contract invokes the vault's withdraw method with a fixed withdrawal amount and immediately subtracts that amount from totalVaultDeposits:
However, the vault's withdraw method returns the actual amount of shares (or tokens) that were burned during the withdrawal. This value may differ from the nominal amount requested due to factors such as share conversion rates, rounding errors, or other internal vault calculations. Not capturing this return value leads to incorrect subtraction from totalVaultDeposits, causing an inaccurate reflection of the actual vault liquidity.
The correct integration—as demonstrated in the reference implementation from Curve's VaultV3—requires capturing the returned value from the withdraw call and using it to update totalVaultDeposits accordingly:
Incorrect updating of totalVaultDeposits can result in an inaccurate representation of the actual liquidity held in the vault.
Manual Code Review
Modify the _withdrawFromVault function to capture and utilize the actual number of shares burned by the vault. This ensures that totalVaultDeposits accurately reflects the current liquidity. For example:
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.