Skip to content

Commit

Permalink
fix: check min idle
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Feb 5, 2024
1 parent 773f63e commit 8b19296
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions contracts/accountants/HealthCheckAccountant.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 11 additions & 2 deletions contracts/debtAllocators/DebtAllocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8b19296

Please sign in to comment.