Skip to main content

spawn_decay_alpha

Function spawn_decay_alpha 

Source
pub fn spawn_decay_alpha(
    now: u64,
    valid_from: u64,
    valid_until: Option<u64>,
    onset_secs: u64,
    decay_secs: u64,
) -> f32
Expand description

Compute the visibility α ∈ [0, 1] for an asset at now given its valid-time interval and optional ramp durations (seconds).

  • Before valid_from - onset: α = 0
  • During onset ramp: linear 0 → 1
  • Between onset end and decay start: α = 1
  • During decay ramp: linear 1 → 0
  • After valid_until + decay: α = 0