it("should allow liquidation of healthy position if debt not fully repaid during grace period", async function () {
await raacHousePrices.setHousePrice(1, ethers.parseEther("60"));
await lendingPool.connect(user2).initiateLiquidation(user1.address);
const partialRepayAmount = ethers.parseEther("50");
await crvusd.connect(user1).approve(rToken.target, partialRepayAmount);
await lendingPool.connect(user1).repay(partialRepayAmount);
const healthFactor = await lendingPool.calculateHealthFactor(user1.address);
expect(healthFactor).to.be.gt(await lendingPool.healthFactorLiquidationThreshold());
await ethers.provider.send("evm\_increaseTime", \[73 \* 60 \* 60]);
await ethers.provider.send("evm\_mine");
await lendingPool.connect(owner).setStabilityPool(owner.address);
await crvusd.connect(owner).mint(owner.address, ethers.parseEther("100"));
await crvusd.connect(owner).approve(lendingPool.target, ethers.parseEther("100"));
await expect(lendingPool.connect(owner).finalizeLiquidation(user1.address))
.to.emit(lendingPool, "LiquidationFinalized");
expect(await raacNFT.ownerOf(1)).to.equal(owner.address);
});
it("should allow liquidation of healthy position if closeLiquidation not called", async function () {
await raacHousePrices.setHousePrice(1, ethers.parseEther("60"));
await lendingPool.connect(user2).initiateLiquidation(user1.address);
const userDebt = await lendingPool.getUserDebt(user1.address);
await crvusd.connect(user1).approve(rToken.target, userDebt);
await lendingPool.connect(user1).repay(userDebt);
const healthFactor = await lendingPool.calculateHealthFactor(user1.address);
expect(healthFactor).to.be.gt(await lendingPool.healthFactorLiquidationThreshold());
await ethers.provider.send("evm\_increaseTime", \[73 \* 60 \* 60]);
await ethers.provider.send("evm\_mine");
await lendingPool.connect(owner).setStabilityPool(owner.address);
await crvusd.connect(owner).mint(owner.address, ethers.parseEther("100"));
await crvusd.connect(owner).approve(lendingPool.target, ethers.parseEther("100"));
await expect(lendingPool.connect(owner).finalizeLiquidation(user1.address))
.to.emit(lendingPool, "LiquidationFinalized");
expect(await raacNFT.ownerOf(1)).to.equal(owner.address);
});
Users can be liquidated even if in a healthy position.