/// Check if tolerance breaches the diff
Check if tolerance breaches the diff
Check if tolerance breaches the diff
pub fn breaches_tolerance(old: u128, new: u128, tolerance: u32) -> bool {
	let delta = if old > new {
		1_000_000_u128.saturating_mul((old - new).saturated_into::<u128>()) / old.saturated_into::<u128>()
	} else {
        1_000_000_u128.saturating_mul((new - old).saturated_into::<u128>()) / old.saturated_into::<u128>()
	};
    // log::info!("##### breaches_tolerance: old: {}, new: {}, delta: {}, tolerance: {}", old, new, delta, tolerance);
	delta > tolerance as u128
}
pub fn breaches_tolerance ( old : u128 , new : u128 , tolerance : u32 ) -> bool { let delta = if old > new { 1_000_000_u128 . saturating_mul ( ( old - new ) . saturated_into :: < u128 > ( ) ) / old . saturated_into :: < u128 > ( ) } else { 1_000_000_u128 . saturating_mul ( ( new - old ) . saturated_into :: < u128 > ( ) ) / old . saturated_into :: < u128 > ( ) } ; // log::info!("##### breaches_tolerance: old: {}, new: {}, delta: {}, tolerance: {}", old, new, delta, tolerance); delta > tolerance as u128 }
Check if tolerance breaches the diff
Check if tolerance breaches the diff
old
u128
new
u128
tolerance
u32