Expand description
Chain-agnostic WAD math primitives for vault share calculations.
Provides Wad (18-decimal fixed-point) type for precise fee and share calculations.
Structs§
- Wad
- An 18-decimal fixed-point value (1e18 = 100%), backed by U256.
Constants§
- MAX_
FEE_ WAD - Backwards-compatible alias for
MAX_PERFORMANCE_FEE_WAD. - MAX_
MANAGEMENT_ FEE_ WAD - Maximum annualized management fee rate: 5%.
- MAX_
PERFORMANCE_ FEE_ WAD - Maximum performance fee rate on profits: 50%.
- YEAR_NS
- Nanoseconds in a standard year (365 days).
Functions§
- compute_
fee_ shares - Computes fee shares to mint given:
- compute_
fee_ shares_ from_ assets - Computes fee shares to mint from a raw
fee_assetsamount, given current total assets and supply. Returns 0 when fee is zero, supply is zero, or fee consumes all assets. - compute_
management_ fee_ shares - Compute management fee shares (time-based fee pro-rated over elapsed time).
- mul_
div_ ceil - Multiplies and divides with ceiling: ceil(x * y / denom). Uses 512-bit intermediate (U512) to avoid overflow; returns 0 if denom is 0. Implemented via quotient/remainder to avoid relying on addition overflow behavior.
- mul_
div_ floor - Multiplies and divides with flooring: floor(x * y / denom). Uses 512-bit intermediate (U512) to avoid overflow; returns 0 if denom is 0.
- mul_
wad_ floor - Multiplies x by
y/Wad::SCALEand floors: floor(x * y / 1e18). y is a WAD-scaled fraction (1e18 = 100%), and x is an unscaled amount. - total_
assets_ for_ fee_ accrual - Compute the effective total_assets for fee accrual, clamping growth to the max rate if configured.