diff --git a/contracts/accountants/HealthCheckAccountant.sol b/contracts/accountants/HealthCheckAccountant.sol index 78952c3..b6afab9 100644 --- a/contracts/accountants/HealthCheckAccountant.sol +++ b/contracts/accountants/HealthCheckAccountant.sol @@ -152,6 +152,9 @@ contract HealthCheckAccountant { require(_feeManager != address(0), "ZERO ADDRESS"); require(_feeRecipient != address(0), "ZERO ADDRESS"); + feeManager = _feeManager; + feeRecipient = _feeRecipient; + _updateDefaultConfig( defaultManagement, defaultPerformance, diff --git a/contracts/debtAllocators/DebtAllocator.sol b/contracts/debtAllocators/DebtAllocator.sol index e0b41ae..7161e85 100644 --- a/contracts/debtAllocators/DebtAllocator.sol +++ b/contracts/debtAllocators/DebtAllocator.sol @@ -281,9 +281,18 @@ contract DebtAllocator { } // If current debt is greater than our max. } else if (maxDebt < params.current_debt) { + uint256 toPull = params.current_debt - targetDebt; + + uint256 currentIdle = _vault.totalIdle(); + uint256 minIdle = _vault.minimum_total_idle(); + if (minIdle > currentIdle) { + // Pull at least the amount needed for minIdle. + toPull = Math.max(toPull, minIdle - currentIdle); + } + // Find out by how much. Aim for the target. - uint256 toPull = Math.min( - params.current_debt - targetDebt, + toPull = Math.min( + toPull, // Account for the current liquidity constraints. // Use max redeem to match vault logic. IVault(_strategy).convertToAssets(