Skip to content

Commit

Permalink
feat: accountant fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Jan 17, 2024
1 parent 14115d2 commit f49de39
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
42 changes: 35 additions & 7 deletions contracts/accountants/HealthCheckAccountant.sol
Original file line number Diff line number Diff line change
Expand Up @@ -440,19 +440,47 @@ contract HealthCheckAccountant {
}

/**
* @notice Function to withdraw the underlying asset from a vault.
* @param vault The vault to withdraw from.
* @param amount The amount in the underlying to withdraw.
* @notice Get the full config used for a specific `strategy` and `vault` combo.
* @param vault Address of the vault.
* @param strategy Address of the strategy.
* @return fee The config that would be used during the report.
*/
function withdrawUnderlying(
function getStrategyConfig(
address vault,
address strategy
) external view returns (Fee memory fee) {
// Check if custom config is set.
if (_useCustomConfig[vault][strategy] != 0) {
fee = customConfig[vault][strategy];
} else {
// Otherwise use the default.
fee = defaultConfig;
}
}

/**
* @notice Function to redeem the underlying asset from a vault.
* @dev Will default to using the full balance of the vault.
* @param vault The vault to redeem from.
*/
function redeemUnderlying(address vault) external virtual {
redeemUnderlying(vault, IVault(vault).balanceOf(address(this)));
}

/**
* @notice Function to redeem the underlying asset from a vault.
* @param vault The vault to redeem from.
* @param amount The amount in vault shares to redeem.
*/
function redeemUnderlying(
address vault,
uint256 amount
) external virtual onlyFeeManager {
IVault(vault).withdraw(amount, address(this), address(this), maxLoss);
) public virtual onlyFeeManager {
IVault(vault).redeem(amount, address(this), address(this), maxLoss);
}

/**
* @notice Sets the `maxLoss` parameter to be used on withdraws.
* @notice Sets the `maxLoss` parameter to be used on redeems.
* @param _maxLoss The amount in basis points to set as the maximum loss.
*/
function setMaxLoss(uint256 _maxLoss) external virtual onlyFeeManager {
Expand Down
6 changes: 3 additions & 3 deletions tests/accountants/test_healthcheck_accountant.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ def test_distribute(
assert vault.balanceOf(fee_recipient.address) == amount


def test_withdraw_underlying(
def test_redeem_underlying(
healthcheck_accountant, daddy, user, vault, asset, deposit_into_vault, amount
):
accountant = healthcheck_accountant
Expand All @@ -675,9 +675,9 @@ def test_withdraw_underlying(
assert asset.balanceOf(accountant.address) == 0

with ape.reverts("!fee manager"):
accountant.withdrawUnderlying(vault.address, amount, sender=user)
accountant.redeemUnderlying(vault.address, amount, sender=user)

tx = accountant.withdrawUnderlying(vault.address, amount, sender=daddy)
tx = accountant.redeemUnderlying(vault.address, amount, sender=daddy)

assert vault.balanceOf(user) == 0
assert vault.balanceOf(accountant.address) == 0
Expand Down
6 changes: 3 additions & 3 deletions tests/accountants/test_refund_accountant.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ def test_distribute(
assert vault.balanceOf(fee_recipient.address) == amount


def test_withdraw_underlying(
def test_redeem_underlying(
refund_accountant, daddy, user, vault, asset, deposit_into_vault, amount
):
accountant = refund_accountant
Expand All @@ -695,9 +695,9 @@ def test_withdraw_underlying(
assert asset.balanceOf(accountant.address) == 0

with ape.reverts("!fee manager"):
accountant.withdrawUnderlying(vault.address, amount, sender=user)
accountant.redeemUnderlying(vault.address, amount, sender=user)

tx = accountant.withdrawUnderlying(vault.address, amount, sender=daddy)
tx = accountant.redeemUnderlying(vault.address, amount, sender=daddy)

assert vault.balanceOf(user) == 0
assert vault.balanceOf(accountant.address) == 0
Expand Down

0 comments on commit f49de39

Please sign in to comment.