The reserve library determiens the total liqudity by keeping track of the added liquidity during deposits and withdrawals, however it is not adjusted when the dust amount is transferred by the owner of the pool via LendingPool::transferAccruedDust
or when part of the excess amount is deposited in the vaults.
The pool operates at a lower utilization rate than what it actually has.
Paste this into the lending pool tests.
it("should transfer accrued dust correctly", async function () {
await crvusd.connect(user1).approve(lendingPool.target, ethers.parseEther("100"));
await lendingPool.connect(user1).deposit(ethers.parseEther("100"));
await crvusd.mint(rToken.target, ethers.parseEther("10000000"));
const dustAmount = await rToken.calculateDustAmount();
console.log("Dust amount:", dustAmount);
const dustRecipient = owner.address;
if (dustAmount !== 0n) {
let normalizeIncomeBefore = await lendingPool.getNormalizedIncome();
await lendingPool.connect(owner).transferAccruedDust(dustRecipient, dustAmount);
let normalizeIncomeAfter = await lendingPool.getNormalizedIncome();
expect(normalizeIncomeAfter).to.equal(normalizeIncomeBefore);
await lendingPool.connect(user1).withdraw(ethers.parseEther("100"));
const dustAmountPostWithdraw = await rToken.calculateDustAmount();
console.log({ dustAmountPostWithdraw });
}
});
Manual review.
Use the underlying asset balance held by the reserve.