Accountant
Will charge fees, issue refunds, and run health check on any reported gains or losses during a strategy's report.
State Variables
MAX_BPS
Constant defining the maximum basis points.
uint256 internal constant MAX_BPS = 10_000;
SECS_PER_YEAR
Constant defining the number of seconds in a year.
uint256 internal constant SECS_PER_YEAR = 31_556_952;
MANAGEMENT_FEE_THRESHOLD
Constant defining the management fee threshold.
uint16 public constant MANAGEMENT_FEE_THRESHOLD = 200;
PERFORMANCE_FEE_THRESHOLD
Constant defining the performance fee threshold.
uint16 public constant PERFORMANCE_FEE_THRESHOLD = 5_000;
maxLoss
The amount of max loss to use when redeeming from vaults.
uint256 public maxLoss;
feeManager
The address of the fee manager.
address public feeManager;
feeRecipient
The address of the fee recipient.
address public feeRecipient;
vaultManager
An address that can add or remove vaults.
address public vaultManager;
futureFeeManager
The address of the future fee manager.
address public futureFeeManager;
defaultConfig
The default fee configuration.
Fee public defaultConfig;
vaults
Mapping to track added vaults.
mapping(address => bool) public vaults;
customConfig
Mapping vault => custom Fee config if any.
mapping(address => Fee) public customConfig;
skipHealthCheck
Mapping vault => strategy => flag for one time healthcheck skips.
mapping(address => mapping(address => bool)) skipHealthCheck;
Functions
onlyFeeManager
modifier onlyFeeManager();
onlyVaultOrFeeManager
modifier onlyVaultOrFeeManager();
onlyFeeManagerOrRecipient
modifier onlyFeeManagerOrRecipient();
onlyAddedVaults
modifier onlyAddedVaults();
_checkFeeManager
function _checkFeeManager() internal view virtual;
_checkVaultOrFeeManager
function _checkVaultOrFeeManager() internal view virtual;
_checkFeeManagerOrRecipient
function _checkFeeManagerOrRecipient() internal view virtual;
_checkVaultIsAdded
function _checkVaultIsAdded() internal view virtual;
constructor
constructor(
address _feeManager,
address _feeRecipient,
uint16 defaultManagement,
uint16 defaultPerformance,
uint16 defaultRefund,
uint16 defaultMaxFee,
uint16 defaultMaxGain,
uint16 defaultMaxLoss
);
report
Called by a vault when a strategy
is reporting.
The msg.sender must have been added to the vaults
mapping.
function report(address strategy, uint256 gain, uint256 loss)
public
virtual
onlyAddedVaults
returns (uint256 totalFees, uint256 totalRefunds);
Parameters
Name | Type | Description |
---|---|---|
strategy | address | Address of the strategy reporting. |
gain | uint256 | Amount of the gain if any. |
loss | uint256 | Amount of the loss if any. |
Returns
Name | Type | Description |
---|---|---|
totalFees | uint256 | if any to charge. |
totalRefunds | uint256 | if any for the vault to pull. |
addVault
Function to add a new vault for this accountant to charge fees for.
This is not used to set any of the fees for the specific vault or strategy. Each fee will be set separately.
function addVault(address vault) external virtual onlyVaultOrFeeManager;
Parameters
Name | Type | Description |
---|---|---|
vault | address | The address of a vault to allow to use this accountant. |
removeVault
Function to remove a vault from this accountant's fee charging list.
function removeVault(address vault) external virtual onlyVaultOrFeeManager;
Parameters
Name | Type | Description |
---|---|---|
vault | address | The address of the vault to be removed from this accountant. |
updateDefaultConfig
Function to update the default fee configuration used for all strategies that don't have a custom config set.
function updateDefaultConfig(
uint16 defaultManagement,
uint16 defaultPerformance,
uint16 defaultRefund,
uint16 defaultMaxFee,
uint16 defaultMaxGain,
uint16 defaultMaxLoss
) external virtual onlyFeeManager;
Parameters
Name | Type | Description |
---|---|---|
defaultManagement | uint16 | Default annual management fee to charge. |
defaultPerformance | uint16 | Default performance fee to charge. |
defaultRefund | uint16 | Default refund ratio to give back on losses. |
defaultMaxFee | uint16 | Default max fee to allow as a percent of gain. |
defaultMaxGain | uint16 | Default max percent gain a strategy can report. |
defaultMaxLoss | uint16 | Default max percent loss a strategy can report. |
_updateDefaultConfig
Updates the Accountant's default fee config. Is used during deployment and during any future updates.
function _updateDefaultConfig(
uint16 defaultManagement,
uint16 defaultPerformance,
uint16 defaultRefund,
uint16 defaultMaxFee,
uint16 defaultMaxGain,
uint16 defaultMaxLoss
) internal virtual;
setCustomConfig
Function to set a custom fee configuration for a specific vault.
function setCustomConfig(
address vault,
uint16 customManagement,
uint16 customPerformance,
uint16 customRefund,
uint16 customMaxFee,
uint16 customMaxGain,
uint16 customMaxLoss
) external virtual onlyFeeManager;
Parameters
Name | Type | Description |
---|---|---|
vault | address | The vault the strategy is hooked up to. |
customManagement | uint16 | Custom annual management fee to charge. |
customPerformance | uint16 | Custom performance fee to charge. |
customRefund | uint16 | Custom refund ratio to give back on losses. |
customMaxFee | uint16 | Custom max fee to allow as a percent of gain. |
customMaxGain | uint16 | Custom max percent gain a strategy can report. |
customMaxLoss | uint16 | Custom max percent loss a strategy can report. |
removeCustomConfig
Function to remove a previously set custom fee configuration for a vault.
function removeCustomConfig(address vault) external virtual onlyFeeManager;
Parameters
Name | Type | Description |
---|---|---|
vault | address | The vault to remove custom setting for. |
turnOffHealthCheck
Turn off the health check for a specific vault
strategy
combo.
This will only last for one report and get automatically turned back on.
function turnOffHealthCheck(address vault, address strategy) external virtual onlyFeeManager;
Parameters
Name | Type | Description |
---|---|---|
vault | address | Address of the vault. |
strategy | address | Address of the strategy. |
useCustomConfig
Public getter to check for custom setting.
We use uint256 for the flag since its cheaper so this will convert it to a bool for easy view functions.
function useCustomConfig(address vault) external view virtual returns (bool);
Parameters
Name | Type | Description |
---|---|---|
vault | address | Address of the vault. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | If a custom fee config is set. |
getVaultConfig
Get the full config used for a specific vault
.
function getVaultConfig(address vault) external view returns (Fee memory fee);
Parameters
Name | Type | Description |
---|---|---|
vault | address | Address of the vault. |
Returns
Name | Type | Description |
---|---|---|
fee | Fee | The config that would be used during the report. |
redeemUnderlying
Function to redeem the underlying asset from a vault.
Will default to using the full balance of the vault.
function redeemUnderlying(address vault) external virtual;
Parameters
Name | Type | Description |
---|---|---|
vault | address | The vault to redeem from. |
redeemUnderlying
Function to redeem the underlying asset from a vault.
function redeemUnderlying(address vault, uint256 amount) public virtual onlyFeeManager;
Parameters
Name | Type | Description |
---|---|---|
vault | address | The vault to redeem from. |
amount | uint256 | The amount in vault shares to redeem. |
setMaxLoss
Sets the maxLoss
parameter to be used on redeems.
function setMaxLoss(uint256 _maxLoss) external virtual onlyFeeManager;
Parameters
Name | Type | Description |
---|---|---|
_maxLoss | uint256 | The amount in basis points to set as the maximum loss. |
distribute
Function to distribute all accumulated fees to the designated recipient.
function distribute(address token) external virtual;
Parameters
Name | Type | Description |
---|---|---|
token | address | The token to distribute. |
distribute
Function to distribute accumulated fees to the designated recipient.
function distribute(address token, uint256 amount) public virtual onlyFeeManagerOrRecipient;
Parameters
Name | Type | Description |
---|---|---|
token | address | The token to distribute. |
amount | uint256 | amount of token to distribute. |
setFutureFeeManager
Function to set a future fee manager address.
function setFutureFeeManager(address _futureFeeManager) external virtual onlyFeeManager;
Parameters
Name | Type | Description |
---|---|---|
_futureFeeManager | address | The address to set as the future fee manager. |
acceptFeeManager
Function to accept the role change and become the new fee manager.
This function allows the future fee manager to accept the role change and become the new fee manager.
function acceptFeeManager() external virtual;
setVaultManager
Function to set a new vault manager.
function setVaultManager(address newVaultManager) external virtual onlyFeeManager;
Parameters
Name | Type | Description |
---|---|---|
newVaultManager | address | Address to add or remove vaults. |
setFeeRecipient
Function to set a new address to receive distributed rewards.
function setFeeRecipient(address newFeeRecipient) external virtual onlyFeeManager;
Parameters
Name | Type | Description |
---|---|---|
newFeeRecipient | address | Address to receive distributed fees. |
_checkAllowance
Internal safe function to make sure the contract you want to interact with has enough allowance to pull the desired tokens.
function _checkAllowance(address _contract, address _token, uint256 _amount) internal;
Parameters
Name | Type | Description |
---|---|---|
_contract | address | The address of the contract that will move the token. |
_token | address | The ERC-20 token that will be getting spent. |
_amount | uint256 | The amount of _token to be spent. |
Events
VaultChanged
An event emitted when a vault is added or removed.
event VaultChanged(address indexed vault, ChangeType change);
UpdateDefaultFeeConfig
An event emitted when the default fee configuration is updated.
event UpdateDefaultFeeConfig(Fee defaultFeeConfig);
SetFutureFeeManager
An event emitted when the future fee manager is set.
event SetFutureFeeManager(address indexed futureFeeManager);
NewFeeManager
An event emitted when a new fee manager is accepted.
event NewFeeManager(address indexed feeManager);
UpdateVaultManager
An event emitted when a new vault manager is set.
event UpdateVaultManager(address indexed newVaultManager);
UpdateFeeRecipient
An event emitted when the fee recipient is updated.
event UpdateFeeRecipient(address indexed oldFeeRecipient, address indexed newFeeRecipient);
UpdateCustomFeeConfig
An event emitted when a custom fee configuration is updated.
event UpdateCustomFeeConfig(address indexed vault, Fee custom_config);
RemovedCustomFeeConfig
An event emitted when a custom fee configuration is removed.
event RemovedCustomFeeConfig(address indexed vault);
UpdateMaxLoss
An event emitted when the maxLoss
parameter is updated.
event UpdateMaxLoss(uint256 maxLoss);
DistributeRewards
An event emitted when rewards are distributed.
event DistributeRewards(address indexed token, uint256 rewards);
Structs
Fee
Struct representing fee details.
struct Fee {
uint16 managementFee;
uint16 performanceFee;
uint16 refundRatio;
uint16 maxFee;
uint16 maxGain;
uint16 maxLoss;
bool custom;
}
Enums
ChangeType
Enum defining change types (added or removed).
enum ChangeType {
NULL,
ADDED,
REMOVED
}