Vulnerability: Wrong `accLoanRatePerSeconds` in `repay()` can lead to underflow
Severity: medium

Description:
Because the `repay()` function resets the `dailyRateCollateralBalance` to 0 when the lender call didn't fully close the position. We want to be able to compute the missing collateral again.\\nTo do so we substract the percentage of collateral not paid to the `accLoanRatePerSeconds` so on the next call we will be adding extra second of fees that will allow the contract to compute the missing collateral.\\nThe problem lies in the fact that we compute a percentage using the borrowed amount left instead of the initial borrow amount causing the percentage to be higher. In practice this do allows the contract to recompute the missing collateral.\\nBut in the case of the missing `collateralBalance` or `removedAmt` being very high (ex: multiple days not paid or the loan removed was most of the position's liquidity) we might end up with a percentage higher than the `accLoanRatePerSeconds` which will cause an underflow.\\nIn case of an underflow the call will revert and the lender will not be able to get his tokens back.\\nConsider this POC that can be copied and pasted in the test files (replace all tests and just keep the setup & NFT creation):\\n```\\nit("Updated accRate is incorrect", async () => {\\n        const amountWBTC = ethers.utils.parseUnits("0.05", 8); //token0\\n        let deadline = (await time.latest()) + 60;\\n        const minLeverageDesired = 50;\\n        const maxCollateralWBTC = amountWBTC.div(minLeverageDesired);\\n\\n        const loans = [\\n            {\\n                liquidity: nftpos[3].liquidity,\\n                tokenId: nftpos[3].tokenId,\\n            },\\n            {\\n                liquidity: nftpos[5].liquidity,\\n                tokenId: nftpos[5].tokenId,\\n            },\\n        ];\\n\\n        const swapParams: ApproveSwapAndPay.SwapParamsStruct = {\\n            swapTarget: constants.AddressZero,\\n            swapAmountInDataIndex: 0,\\n            maxGasForCall: 0,\\n            swapData: swapData,\\n        };\\n\\n        const borrowParams = {\\n            internalSwapPoolfee: 500,\\n            saleToken: WETH_ADDRESS,\\n            holdToken: WBTC_ADDRESS,\\n            minHoldTokenOut: amountWBTC,\\n            maxCollateral: maxCollateralWBTC,\\n            externalSwap: swapParams,\\n            loans: loans,\\n        };\\n\\n        //borrow tokens\\n        await borrowingManager.connect(bob).borrow(borrowParams, deadline);\\n\\n        await time.increase(3600 * 72); //72h so 2 days of missing collateral\\n        deadline = (await time.latest()) + 60;\\n\\n        const borrowingKey = await borrowingManager.userBorrowingKeys(bob.address, 0);\\n\\n        let repayParams = {\\n            isEmergency: true,\\n            internalSwapPoolfee: 0,\\n            externalSwap: swapParams,\\n            borrowingKey: borrowingKey,\\n            swapSlippageBP1000: 0,\\n        };\\n\\n        const oldBorrowingInfo = await borrowingManager.borrowingsInfo(borrowingKey);\\n        const dailyRateCollateral = await borrowingManager.checkDailyRateCollateral(borrowingKey);\\n\\n        //Alice emergency repay but it reverts with 2 days of collateral missing\\n        await expect(borrowingManager.connect(alice).repay(repayParams, deadline)).to.be.revertedWithPanic();\\n    });\\n```\\n

Impact:
Medium. Lender might not be able to use `isEmergency` on `repay()` and will have to do a normal liquidation if he want his liquidity back.

Recommended mitigation:
Consider that when a lender do an emergency liquidity restoration they give up on their collateral missing and so use the initial amount in the computation instead of borrowed amount left.\\n```\\nborrowingStorage.accLoanRatePerSeconds =\\n                    holdTokenRateInfo.accLoanRatePerSeconds -\\n                    FullMath.mulDiv(\\n                        uint256(-collateralBalance),\\n                        Constants.BP,\\n                        borrowing.borrowedAmount + removedAmt //old amount\\n                    );\\n```\\n