pub fn compute_amp_factor(&self) -> Option<Balance> {
        if self.current_ts < self.stop_ramp_ts {
            let time_range = self.stop_ramp_ts.checked_sub(self.start_ramp_ts)?;
            let time_delta = self.current_ts.checked_sub(self.start_ramp_ts)?;

            // Compute amp factor based on ramp time
            if self.target_amp_factor >= self.initial_amp_factor {
                // Ramp up
                let amp_range = self
                    .target_amp_factor
                    .checked_sub(self.initial_amp_factor)?;
                let amp_delta = (amp_range as u128)
                    .checked_mul(time_delta as u128)?
                    .checked_div(time_range as u128)?;
                self.initial_amp_factor
                    .checked_add(amp_delta)
                    .map(|x| x as u128)
            } else {
                // Ramp down
                let amp_range = self
                    .initial_amp_factor
                    .checked_sub(self.target_amp_factor)?;
                let amp_delta = (amp_range as u128)
                    .checked_mul(time_delta as u128)?
                    .checked_div(time_range as u128)?;
                self.initial_amp_factor
                    .checked_sub(amp_delta)
                    .map(|x| x as u128)
            }
        } else {
            // when stop_ramp_ts == 0 or current_ts >= stop_ramp_ts
            Some(self.target_amp_factor as u128)
        }
    }
/// Compute the amplification coefficient (A)
Compute the amplification coefficient (A)
Compute the amplification coefficient ( A )
pub fn compute_amp_factor(&self) -> Option<Balance> {
        if self.current_ts < self.stop_ramp_ts {
            let time_range = self.stop_ramp_ts.checked_sub(self.start_ramp_ts)?;
            let time_delta = self.current_ts.checked_sub(self.start_ramp_ts)?;
            // Compute amp factor based on ramp time
            if self.target_amp_factor >= self.initial_amp_factor {
                // Ramp up
                let amp_range = self
                    .target_amp_factor
                    .checked_sub(self.initial_amp_factor)?;
                let amp_delta = (amp_range as u128)
                    .checked_mul(time_delta as u128)?
                    .checked_div(time_range as u128)?;
                self.initial_amp_factor
                    .checked_add(amp_delta)
                    .map(|x| x as u128)
            } else {
                // Ramp down
                let amp_range = self
                    .initial_amp_factor
                    .checked_sub(self.target_amp_factor)?;
                let amp_delta = (amp_range as u128)
                    .checked_mul(time_delta as u128)?
                    .checked_div(time_range as u128)?;
                self.initial_amp_factor
                    .checked_sub(amp_delta)
                    .map(|x| x as u128)
            }
        } else {
            // when stop_ramp_ts == 0 or current_ts >= stop_ramp_ts
            Some(self.target_amp_factor as u128)
        }
    }
pub fn compute_amp_factor ( & self ) -> Option < Balance > { if self . current_ts < self . stop_ramp_ts { let time_range = self . stop_ramp_ts . checked_sub ( self . start_ramp_ts ) ? ; let time_delta = self . current_ts . checked_sub ( self . start_ramp_ts ) ? ; // Compute amp factor based on ramp time if self . target_amp_factor >= self . initial_amp_factor { // Ramp up let amp_range = self . target_amp_factor . checked_sub ( self . initial_amp_factor ) ? ; let amp_delta = ( amp_range as u128 ) . checked_mul ( time_delta as u128 ) ? . checked_div ( time_range as u128 ) ? ; self . initial_amp_factor . checked_add ( amp_delta ) . map ( | x | x as u128 ) } else { // Ramp down let amp_range = self . initial_amp_factor . checked_sub ( self . target_amp_factor ) ? ; let amp_delta = ( amp_range as u128 ) . checked_mul ( time_delta as u128 ) ? . checked_div ( time_range as u128 ) ? ; self . initial_amp_factor . checked_sub ( amp_delta ) . map ( | x | x as u128 ) } } else { // when stop_ramp_ts == 0 or current_ts >= stop_ramp_ts Some ( self . target_amp_factor as u128 ) } }
Compute the amplification coefficient (A)
Compute the amplification coefficient ( A )
&self
&self