ManagedLeveragedVault::getAvailableDebt() used in ManagedLeveragedVault::increaseLeverage() is incorrect
Summary
ManagedLeveragedVault::increaseLeverage() allows borrowing until the maxSystemDebt limit, but the check doesn't account for the borrowing fee triggered.
Vulnerability Detail
This is the ManagedLeveragedVault::getAvailableDebt() function:
function getAvailableDebt() internal view returns (uint256) {
BoycoVaultStorage storage b$ = _getBoycoVaultStorage();
IDenManager denManager = IDenManager(b$.denManager);
uint256 borrowCap = denManager.maxSystemDebt();
uint256 totalActiveDebt = denManager.getTotalActiveDebt();
uint256 defaultedDebt = denManager.defaultedDebt();
return borrowCap - totalActiveDebt - defaultedDebt;
}It doesn't account for the borrowing fee triggered, which means the max debt will be overestimated.
Impact
This function would be used most likely offchain to calculate the max debt to leverage up, which would revert.
Code Snippet
Tool Used
Manual Review
Recommendation
This function should return the debt multiplied by (1 - borrowingFee).