Get Fee State
earn.getFeeState
Gets a vault's active fee configuration, pending fees, and fee baselines.
Usage
import { } from './viem.config'
const = await ..({
: '0x0000000000000000000000000000000000000001',
})
{// config: { excess: { ... }, fixedFees: [...] },// configId: 1n,
// feesActive: true,
// highWaterMark: 1_000_000_000_000_000_000n,
// preview: { totalFeeAssets: 10_000n, totalFeeShares: 9_950n, ... },
// targetBase: 1_000_000_000_000_000_000n,
// }import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Include Claimable Shares
Pass a fee recipient to include its currently claimable Earn shares.
import { } from './viem.config'
const = await ..({
: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
: '0x0000000000000000000000000000000000000001',
})
{ claimableShares: 9_950n, ... }import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Recipes
Value Claimable Fee Revenue in Assets
Combine claimableShares with earn.getRedeemQuote to
report a fee recipient's accrued revenue in asset terms instead of shares.
import { } from './viem.config'
const = '0x0000000000000000000000000000000000000001'
const { } = await ..({
: '0x8ba1f109551bD432803012645Ac136ddd64DBA72',
,
})
const = await ..({
: ?? 0n,
,
})
9_900_000nimport { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Detect Fee Configuration Changes
Compare configId with the value recorded when the vault was approved to catch fee changes before
committing more treasury funds.
import { } from './viem.config'
const = 1n
const = await ..({
: '0x0000000000000000000000000000000000000001',
})
if (. !== )
throw new ('Fee configuration changed since approval.')
const = ...(
(, ) => + .,
0,
)
200import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Fee rates use basis points, so 200 is a 2% fixed rate.
Return Value
type ReturnValue = {
/** Claimable fee shares for `recipient`. */
claimableShares?: bigint | undefined
/** Active fee configuration. */
config: FeeConfig
/** Active fee configuration id. */
configId: bigint
/** Whether fees are active. */
feesActive: boolean
/** Post-fee high-water mark per Earn share. */
highWaterMark: bigint
/** Pending fee amounts. */
preview: FeePreview
/** Excess-return fee target per Earn share. */
targetBase: bigint
}
type FeeConfig = {
excess: {
account: Address
annualTargetRateBps: number
enabled: boolean
excessFeeRateBps: number
}
fixedFees: readonly { account: Address; rateBps: number }[]
}
type FeePreview = {
activeAssets: bigint
allocations: readonly {
account: Address
feeAssets: bigint
feeShares: bigint
}[]
excessFeeAssets: bigint
fixedFeeAssets: bigint
positiveAccrualAssets: bigint
postFeeValuePerShare: bigint
preFeeValuePerShare: bigint
targetValuePerShare: bigint
totalFeeAssets: bigint
totalFeeShares: bigint
}Parameters
recipient (optional)
- Type:
Address
Fee recipient whose claimable Earn shares are included.
vault
- Type:
Address
Vault address.
blockNumber (optional)
- Type:
bigint
Block number to read the state from.
blockOverrides (optional)
- Type:
BlockOverrides
Block overrides to apply to the state.
blockTag (optional)
- Type:
BlockTag
Block tag to read the state from.
stateOverride (optional)
- Type:
StateOverride
State override to apply.