Skip to main content

Accountant

Git Source

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

NameTypeDescription
strategyaddressAddress of the strategy reporting.
gainuint256Amount of the gain if any.
lossuint256Amount of the loss if any.

Returns

NameTypeDescription
totalFeesuint256if any to charge.
totalRefundsuint256if 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

NameTypeDescription
vaultaddressThe 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

NameTypeDescription
vaultaddressThe 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

NameTypeDescription
defaultManagementuint16Default annual management fee to charge.
defaultPerformanceuint16Default performance fee to charge.
defaultRefunduint16Default refund ratio to give back on losses.
defaultMaxFeeuint16Default max fee to allow as a percent of gain.
defaultMaxGainuint16Default max percent gain a strategy can report.
defaultMaxLossuint16Default 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

NameTypeDescription
vaultaddressThe vault the strategy is hooked up to.
customManagementuint16Custom annual management fee to charge.
customPerformanceuint16Custom performance fee to charge.
customRefunduint16Custom refund ratio to give back on losses.
customMaxFeeuint16Custom max fee to allow as a percent of gain.
customMaxGainuint16Custom max percent gain a strategy can report.
customMaxLossuint16Custom 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

NameTypeDescription
vaultaddressThe 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

NameTypeDescription
vaultaddressAddress of the vault.
strategyaddressAddress 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

NameTypeDescription
vaultaddressAddress of the vault.

Returns

NameTypeDescription
<none>boolIf 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

NameTypeDescription
vaultaddressAddress of the vault.

Returns

NameTypeDescription
feeFeeThe 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

NameTypeDescription
vaultaddressThe vault to redeem from.

redeemUnderlying

Function to redeem the underlying asset from a vault.

function redeemUnderlying(address vault, uint256 amount) public virtual onlyFeeManager;

Parameters

NameTypeDescription
vaultaddressThe vault to redeem from.
amountuint256The amount in vault shares to redeem.

setMaxLoss

Sets the maxLoss parameter to be used on redeems.

function setMaxLoss(uint256 _maxLoss) external virtual onlyFeeManager;

Parameters

NameTypeDescription
_maxLossuint256The 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

NameTypeDescription
tokenaddressThe token to distribute.

distribute

Function to distribute accumulated fees to the designated recipient.

function distribute(address token, uint256 amount) public virtual onlyFeeManagerOrRecipient;

Parameters

NameTypeDescription
tokenaddressThe token to distribute.
amountuint256amount of token to distribute.

setFutureFeeManager

Function to set a future fee manager address.

function setFutureFeeManager(address _futureFeeManager) external virtual onlyFeeManager;

Parameters

NameTypeDescription
_futureFeeManageraddressThe 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

NameTypeDescription
newVaultManageraddressAddress to add or remove vaults.

setFeeRecipient

Function to set a new address to receive distributed rewards.

function setFeeRecipient(address newFeeRecipient) external virtual onlyFeeManager;

Parameters

NameTypeDescription
newFeeRecipientaddressAddress 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

NameTypeDescription
_contractaddressThe address of the contract that will move the token.
_tokenaddressThe ERC-20 token that will be getting spent.
_amountuint256The 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
}