Expand description
Balance-level accessors and initialization utilities.
Provides a field-oriented interface over LazyBalance::Balance,
treating it as a virtual struct composed via discriminants.
§Logical Structure
ⓘ
struct <T as LazyBalance>::Balance {
BalanceAsset.0: T::Asset, // effective
BalanceAsset.1: T::Asset, // issued
BalanceRational: T::Rational, // bias
BalanceTime.0: T::Time, // checkpoint
BalanceTime.1: T::Time, // drainpoint
}- discriminants = field identifiers
.0,.1= multiple values (Many)
ⓘ
BalanceAsset => Many(T::Asset)
BalanceRational => Some(T::Rational)
BalanceTime => Many(T::Time)This is a type projection:
Tdefines the schema- storage is discriminant-keyed and resolved via
VirtualDynField - this decouples logical structure from storage layout.
§Semantics
- Asset:
effective,issued - Rational:
bias - Time:
checkpoint,drainpoint
§Initialization
balance::is_fresh_balance lazily initializes:
effective = 0,issued = 0bias = 1checkpoint = 0,drainpoint = 0
§Context
ShareBalanceContext supplies:
- bounds (
VirtualDynBound) - empty extensions (
empty_virtual_extension!)
Structure stays abstract (but here implemented concretely); layout and limits come from the context.
Functions§
- bias
- Returns the scaling factor (share-price) applied to the balance value.
- checkpoint
- Returns the most recent time at which the balance state was adjusted i.e., reap or mint.
- drainpoint
- Returns the most recent time at which the balance state was drained.
- effective
- Returns the current effective value of the balance.
- init_
balance - Initializes a
LazyBalance::Balanceforcefully. - is_
fresh_ balance - Initializes a
LazyBalance::Balanceonly if not already initialized. - issued
- Returns the base value (total shares) backing the balance.
- set_
bias - Sets the scaling factor (share-price) applied to the balance value.
- set_
checkpoint - Sets the most recent adjusted (reap/mint) time of the balance.
- set_
drainpoint - Sets the most recent drained time of the balance.
- set_
effective - Sets the current effective value of the balance.
- set_
issued - Sets the base value (total shares) of the balance.