Module wad

Source
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_assets amount, 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::SCALE and 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.