D3VaultFunding#checkBadDebtAfterAccrue is inaccurate and can lead to further damage to both LP's and MM
D3VaultFunding#checkBadDebtAfterAccrue makes the incorrect assumption that a collateral ratio of less than 1e18 means that the pool has bad debt. Due to how collateral and debt weight affect the collateral ratio calculation a pool can have a collateral ratio less than 1e18 will still maintaining debt that is profitable to liquidate. The result of this is that the after this threshold has been passed, a pool can no longer be liquidate by anyone which can lead to continued losses that harm both the LPs and the MM being liquidated.\\nD3VaultFunding.sol#L382-L386\\n```\\n        if (balance >= borrows) {\\n            collateral += min(balance - borrows, info.maxCollateralAmount).mul(info.collateralWeight).mul(price);\\n        } else {\\n            debt += (borrows - balance).mul(info.debtWeight).mul(price);\\n        }\\n```\\n\\nWhen calculating the collateral and debt values, the value of the collateral is adjusted by the collateralWeight and debtWeight respectively. This can lead to a position in which the collateral ratio is less than 1e18, which incorrectly signals the pool has bad debt via the checkBadDebtAfterAccrue check.\\nExample:\\n```\\nAssume a pool has the following balances and debts:\\n\\nToken A - 100 borrows 125 balance\\nToken B - 100 borrows 80 balance\\n\\nPrice A = 1\\ncollateralWeightA = 0.8\\n\\nPrice B = 1\\ndebtWeightB = 1.2\\n\\ncollateral = 25 * 1 * 0.8 = 20\\ndebt = 20 * 1 * 1.2 = 24\\n\\ncollateralRatio = 20/24 = 0.83\\n```\\n\\nThe problem here is that there is no bad debt at all and it is still profitable to liquidate this pool, even with a discount:\\n```\\nExcessCollateral = 125 - 100 = 25\\n\\n25 * 1 * 0.95 [DISCOUNT] = 23.75\\n\\nExcessDebt = 100 - 80 = 20\\n\\n20 * 1 = 20\\n```\\n\\nThe issue with this is that once this check has been triggered, no other market participants besides DODO can liquidate this position. This creates a significant inefficiency in the market that can easily to real bad debt being created for the pool. This bad debt is harmful to both the pool MM, who could have been liquidated with remaining collateral, and also the vault LPs who directly pay for the bad debt.
The methodology of the bad debt check should be changed to remove collateral and debt weights to accurately indicate the presence of bad debt.
Unnecessary loss of funds to LPs and MMs
```\\n        if (balance >= borrows) {\\n            collateral += min(balance - borrows, info.maxCollateralAmount).mul(info.collateralWeight).mul(price);\\n        } else {\\n            debt += (borrows - balance).mul(info.debtWeight).mul(price);\\n        }\\n```\\n