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

mapping(address vault => address accountant) public vaultAccountant;

Functions

onlyVaultAccountant

Modifier that checks the caller is the accountant assigned to the specified vault

modifier onlyVaultAccountant(address vault);

Parameters

Name
Type
Description

vault

address

The address of the vault

constructor

constructor(address initialOwner, Authority initialAuthority) Auth2Step(initialOwner, initialAuthority);

setProtocolFeeRecipient

Set the protocol fee recipient

function setProtocolFeeRecipient(address feeRecipient) external requiresAuth;

Parameters

Name
Type
Description

feeRecipient

address

The address of the protocol fee recipient

setProtocolFees

Set the protocol fee rates

function setProtocolFees(uint16 tvl, uint16 performance) external requiresAuth;

Parameters

Name
Type
Description

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

function setVaultAccountant(address vault, address accountant) external requiresVaultAuth(vault);

Parameters

Name
Type
Description

vault

address

The address of the vault

accountant

address

The address of the new accountant

registerVault

Register a new vault with the fee calculator

function registerVault() external virtual;

setVaultFees

Set the vault-specific fee rates

function setVaultFees(address vault, uint16 tvl, uint16 performance) external requiresVaultAuth(vault);

Parameters

Name
Type
Description

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

function claimFees(uint256 feeTokenBalance) external virtual returns (uint256, uint256, address);

Parameters

Name
Type
Description

feeTokenBalance

uint256

Available fee token balance to distribute

Returns

Name
Type
Description

<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

function claimProtocolFees(uint256 feeTokenBalance) external virtual returns (uint256, address);

Parameters

Name
Type
Description

feeTokenBalance

uint256

Available fee token balance to distribute

Returns

Name
Type
Description

<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

function previewFees(address vault, uint256 feeTokenBalance) external view virtual returns (uint256, uint256);

Parameters

Name
Type
Description

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

Name
Type
Description

<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

function _beforeClaimFees() internal virtual;

_beforeClaimProtocolFees

Hook called before claiming protocol fees

Can be overridden by child contracts to add custom logic

function _beforeClaimProtocolFees() internal virtual;

_calculateTvlFee

Calculates the TVL fee for a given period

Fee is annualized and prorated for the time period

function _calculateTvlFee(uint256 averageValue, uint256 tvlFee, uint256 timeDelta) internal pure returns (uint256);

Parameters

Name
Type
Description

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

Name
Type
Description

<none>

uint256

The earned TVL fee

_calculatePerformanceFee

Calculates the performance fee for a given period

function _calculatePerformanceFee(uint256 profit, uint256 feeRate) internal pure returns (uint256);

Parameters

Name
Type
Description

profit

uint256

The profit during the period

feeRate

uint256

The performance fee rate in basis points

Returns

Name
Type
Description

<none>

uint256

The earned performance fee

Last updated