Skip to content

Commit

Permalink
fix: rename accountant
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Mar 5, 2024
1 parent 613a1c6 commit a7c5898
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 188 deletions.
4 changes: 2 additions & 2 deletions contracts/Managers/RoleManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {IVault} from "@yearn-vaults/interfaces/IVault.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Governance2Step} from "@periphery/utils/Governance2Step.sol";
import {HealthCheckAccountant} from "../accountants/HealthCheckAccountant.sol";
import {Accountant} from "../accountants/Accountant.sol";
import {DebtAllocatorFactory} from "../debtAllocators/DebtAllocatorFactory.sol";

/// @title Yearn V3 Vault Role Manager.
Expand Down Expand Up @@ -410,7 +410,7 @@ contract RoleManager is Governance2Step {
IVault(_vault).remove_role(address(this), Roles.ACCOUNTANT_MANAGER);

// Whitelist the vault in the accountant.
HealthCheckAccountant(accountant).addVault(_vault);
Accountant(accountant).addVault(_vault);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/// @title Health Check Accountant.
/// @title Accountant.
/// @dev Will charge fees, issue refunds, and run health check on any reported
/// gains or losses during a strategy's report.
contract HealthCheckAccountant {
contract Accountant {
using SafeERC20 for ERC20;

/// @notice An event emitted when a vault is added or removed.
Expand Down Expand Up @@ -60,6 +60,7 @@ contract HealthCheckAccountant {
uint16 maxFee; // Max fee allowed as a percent of gain.
uint16 maxGain; // Max percent gain a strategy can report.
uint16 maxLoss; // Max percent loss a strategy can report.
bool custom; // Flag to set for custom configs.
}

modifier onlyFeeManager() {
Expand Down Expand Up @@ -140,9 +141,6 @@ contract HealthCheckAccountant {
/// @notice Mapping vault => custom Fee config if any.
mapping(address => Fee) public customConfig;

/// @notice Mapping vault => flag to use a custom config.
mapping(address => uint256) internal _useCustomConfig;

/// @notice Mapping vault => strategy => flag for one time healthcheck skips.
mapping(address => mapping(address => bool)) skipHealthCheck;

Expand Down Expand Up @@ -191,13 +189,11 @@ contract HealthCheckAccountant {
onlyAddedVaults
returns (uint256 totalFees, uint256 totalRefunds)
{
// Declare the config to use
Fee memory fee;
// Declare the config to use as the custom.
Fee memory fee = customConfig[msg.sender];

// Check if there is a custom config to use.
if (_useCustomConfig[msg.sender] != 0) {
fee = customConfig[msg.sender];
} else {
if (!fee.custom) {
// Otherwise use the default.
fee = defaultConfig;
}
Expand Down Expand Up @@ -367,7 +363,8 @@ contract HealthCheckAccountant {
refundRatio: defaultRefund,
maxFee: defaultMaxFee,
maxGain: defaultMaxGain,
maxLoss: defaultMaxLoss
maxLoss: defaultMaxLoss,
custom: false
});

emit UpdateDefaultFeeConfig(defaultConfig);
Expand Down Expand Up @@ -412,15 +409,13 @@ contract HealthCheckAccountant {
refundRatio: customRefund,
maxFee: customMaxFee,
maxGain: customMaxGain,
maxLoss: customMaxLoss
maxLoss: customMaxLoss,
custom: true
});

// Store the config.
customConfig[vault] = _config;

// Set the custom flag.
_useCustomConfig[vault] = 1;

emit UpdateCustomFeeConfig(vault, _config);
}

Expand All @@ -430,14 +425,11 @@ contract HealthCheckAccountant {
*/
function removeCustomConfig(address vault) external virtual onlyFeeManager {
// Ensure custom fees are set for the specified vault.
require(_useCustomConfig[vault] != 0, "No custom fees set");
require(customConfig[vault].custom, "No custom fees set");

// Set all the vaults's custom fees to 0.
delete customConfig[vault];

// Clear the custom flag.
_useCustomConfig[vault] = 0;

// Emit relevant event.
emit RemovedCustomFeeConfig(vault);
}
Expand Down Expand Up @@ -469,7 +461,7 @@ contract HealthCheckAccountant {
function useCustomConfig(
address vault
) external view virtual returns (bool) {
return _useCustomConfig[vault] != 0;
return customConfig[vault].custom;
}

/**
Expand All @@ -480,10 +472,10 @@ contract HealthCheckAccountant {
function getVaultConfig(
address vault
) external view returns (Fee memory fee) {
// Check if custom config is set.
if (_useCustomConfig[vault] != 0) {
fee = customConfig[vault];
} else {
fee = customConfig[vault];

// Check if there is a custom config to use.
if (!fee.custom) {
// Otherwise use the default.
fee = defaultConfig;
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/accountants/RefundAccountant.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: GNU AGPLv3
pragma solidity 0.8.18;

import {HealthCheckAccountant, ERC20, SafeERC20, IVault} from "./HealthCheckAccountant.sol";
import {Accountant, ERC20, SafeERC20, IVault} from "./Accountant.sol";

/// @title Refund Accountant
/// @dev Allows for configurable refunds to be given to specific strategies for a vault.
/// This can be used to auto compound reward into vault or provide retroactive refunds
/// from a previous loss.
contract RefundAccountant is HealthCheckAccountant {
contract RefundAccountant is Accountant {
using SafeERC20 for ERC20;

/// @notice An event emitted when a refund is added for a strategy.
Expand All @@ -30,7 +30,7 @@ contract RefundAccountant is HealthCheckAccountant {
uint16 defaultMaxGain,
uint16 defaultMaxLoss
)
HealthCheckAccountant(
Accountant(
_feeManager,
_feeRecipient,
defaultManagement,
Expand Down
Loading

0 comments on commit a7c5898

Please sign in to comment.