Accountant.sol
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. |