DelayedFeeCalculator
Inherits: IDelayedFeeCalculator, BaseFeeCalculator
To protect vault owners from inaccurate submissions, the DelayedFeeCalculator uses a dispute period and pending snapshot system that only accepts submitted values after the dispute period has passed. Each vault accrues fees independently but a shared protocol fee recipient accrues protocol level fees from all vaults
All fees are calculated in the numeraire token's decimals
State Variables
DISPUTE_PERIOD
Dispute period for vault snapshot
uint256 public immutable DISPUTE_PERIOD;_vaultSnapshots
A mapping of vault addresses to their associated state
mapping(address vault => VaultSnapshot vaultSnapshot) internal _vaultSnapshots;Functions
constructor
constructor(address owner_, Authority authority_, uint256 disputePeriod) BaseFeeCalculator(owner_, authority_);registerVault
submitSnapshot
Submit a new snapshot for fee calculation
Parameters
vault
address
The address of the vault
averageValue
uint160
The average value during the period since last snapshot to this snapshot timestamp
highestProfit
uint128
The highest profit achieved up to the snapshot timestamp
timestamp
uint32
The timestamp of the snapshot
accrueFees
Process fee accrual for a vault
Parameters
vault
address
The address of the vault
Returns
protocolFeesEarned
uint256
tvlFeesEarned The earned TVL fees for the vault and the protocol
vaultFeesEarned
uint256
performanceFeesEarned The earned performance fees for the vault and the protocol
previewFees
vaultFeeState
Get the fee state for a vault
Parameters
vault
address
The vault address to get fee state for
Returns
<none>
VaultSnapshot
The vault snapshot containing average value and highest profit
<none>
VaultAccruals
The vault accruals containing fees and accrued amounts
_beforeClaimFees
Called before claiming fees
Can be overridden by child contracts to add custom logic
_beforeClaimProtocolFees
Called before claiming protocol fees
Can be overridden by child contracts to add custom logic
_accrueFees
Accrues fees for a vault based on its pending snapshot
Updates the vault's state including lastFeeAccrual, lastHighestProfit, and accruedFees
Deletes pending snapshot if dispute period has passed
Parameters
vaultSnapshot
VaultSnapshot
The storage pointer to the vault's state
vaultAccruals
VaultAccruals
The storage pointer to the vault's accruals
lastFeeAccrualCached
uint256
The last fee accrual timestamp cached to avoid re-reading from storage
Returns
protocolFeesEarned
uint256
The earned protocol fees
vaultFeesEarned
uint256
The earned vault fees
_calculatePerformanceFees
Calculates performance fees for both vault and protocol
Returns zero fees if no new profit has been made
Parameters
vaultPerformanceFeeRate
uint256
The performance fee rate for the vault
newHighestProfit
uint256
The highest profit in the pending snapshot
oldHighestProfit
uint256
The highest profit in the previous snapshot
Returns
<none>
uint256
vaultPerformanceFee The performance fee for the vault
<none>
uint256
protocolPerformanceFee The performance fee for the protocol
_calculateTvlFees
Calculates TVL fees for both vault and protocol
Parameters
vaultTvlFeeRate
uint256
The TVL fee rate for the vault
averageValue
uint256
The average value of the vault
snapshotTimestamp
uint256
The timestamp of the snapshot
lastFeeAccrual
uint256
The timestamp of the last fee accrual
Returns
<none>
uint256
vaultTvlFee The earned TVL fee for the vault
<none>
uint256
protocolTvlFee The earned TVL fee for the protocol
Last updated

