Module receipt

Source
Expand description

Receipt-level accessors and utilities.

Provides a field-oriented interface over LazyBalance::Receipt, treating it as a virtual struct composed via discriminants.

§Semantics

A receipt represents a claim over deposited value:

deposit -> issue receipt
balance mutation -> affects value
withdraw -> resolve receipt

Captures:

  • principal, shares
  • bias
  • checkpoint

§Logical Structure

struct <T as LazyBalance>::Receipt {
    ReceiptAsset.0: T::Asset,       // principal
    ReceiptAsset.1: T::Asset,       // shares
    ReceiptRational: T::Rational,   // bias
    ReceiptTime: T::Time,           // checkpoint
}
  • discriminants = field identifiers
  • .0, .1 = multiple values (Many)
ReceiptAsset    => Many(T::Asset)
ReceiptRational => Some(T::Rational)
ReceiptTime     => Some(T::Time)

Type projection:

§Context

ShareBalanceContext supplies:

Structure is abstract; layout comes from context.

Functions§

bias
Returns the scaling factor (share-price) associated with the receipt at the time of deposit.
checkpoint
Returns the checkpoint time of the receipt.
principal
Returns the original deposit value of the receipt.
set_bias
Sets the scaling factor (share-price) associated with the receipt at the time of deposit.
set_checkpoint
Sets the checkpoint time of the receipt.
set_principal
Sets the original deposit value of the receipt.
set_shares
Sets the total shares provided for the receipt.
shares
Returns the total shares provided for the receipt.