BaseFeeCalculator
Inherits: IBaseFeeCalculator, IFeeCalculator, Auth2Step, VaultAuth
Module used with FeeVault to allow an off-chain accountant to submit necessary inputs that help compute TVL and performance fees owed to the vault. Serves as a central registry for all vaults and their associated fees
State Variables
protocolFees
The protocol's fee configuration
Fee public protocolFees;protocolFeeRecipient
The address that receives the protocol's fees
address public protocolFeeRecipient;_vaultAccruals
A mapping of vault addresses to their associated state
mapping(address vault => VaultAccruals vaultAccruals) internal _vaultAccruals;vaultAccountant
A mapping of vault addresses to their assigned accountant
Functions
onlyVaultAccountant
Modifier that checks the caller is the accountant assigned to the specified vault
Parameters
vault
address
The address of the vault
constructor
setProtocolFeeRecipient
Set the protocol fee recipient
Parameters
feeRecipient
address
The address of the protocol fee recipient
setProtocolFees
Set the protocol fee rates
Parameters
tvl
uint16
The TVL fee rate in basis points
performance
uint16
The performance fee rate in basis points
setVaultAccountant
Set the accountant for a vault
Parameters
vault
address
The address of the vault
accountant
address
The address of the new accountant
registerVault
Register a new vault with the fee calculator
setVaultFees
Set the vault-specific fee rates
Parameters
vault
address
The address of the vault
tvl
uint16
The TVL fee rate in basis points
performance
uint16
The performance fee rate in basis points
claimFees
Process a fee claim for a specific vault
Expected to be called by the vault only when claiming fees Only accrues fees and updates stored values; does not transfer tokens Caller must perform the actual transfers to avoid permanent fee loss
Parameters
feeTokenBalance
uint256
Available fee token balance to distribute
Returns
<none>
uint256
earnedFees The amount of fees to be claimed by the fee recipient
<none>
uint256
protocolEarnedFees The amount of protocol fees to be claimed by the protocol
<none>
address
protocolFeeRecipient The address of the protocol fee recipient
claimProtocolFees
Process a protocol fee claim for a vault
Expected to be called by the vault only when claiming protocol fees Only accrues protocol fees and updates stored values; does not transfer tokens Caller must perform the actual transfers to avoid permanent protocol fee loss
Parameters
feeTokenBalance
uint256
Available fee token balance to distribute
Returns
<none>
uint256
accruedFees The amount of protocol fees claimed
<none>
address
protocolFeeRecipient The address of the protocol fee recipient
previewFees
Returns the current claimable fees for the given vault, as if a claim was made now
Parameters
vault
address
The address of the vault to preview fees for
feeTokenBalance
uint256
Available fee token balance to distribute If set to type(uint256).max, the function returns all accrued fees If set to an actual balance, the result is capped to that claimable amount
Returns
<none>
uint256
vaultFees The amount of claimable fees for the vault
<none>
uint256
protocolFees The amount of claimable protocol fees
_beforeClaimFees
Hook called before claiming fees
Can be overridden by child contracts to add custom logic
_beforeClaimProtocolFees
Hook called before claiming protocol fees
Can be overridden by child contracts to add custom logic
_calculateTvlFee
Calculates the TVL fee for a given period
Fee is annualized and prorated for the time period
Parameters
averageValue
uint256
The average value during the period
tvlFee
uint256
The TVL fee rate in basis points
timeDelta
uint256
The duration of the fee period in seconds
Returns
<none>
uint256
The earned TVL fee
_calculatePerformanceFee
Calculates the performance fee for a given period
Parameters
profit
uint256
The profit during the period
feeRate
uint256
The performance fee rate in basis points
Returns
<none>
uint256
The earned performance fee
Last updated

