Module hydra_dx_math::ema

source ·

Functions

Calculate a weighted average for the given balances. prev is the previous oracle value, incoming is the new value to integrate. weight is how much weight to give the new value.
Calculate the new oracle values by integrating incoming values with the previous oracle. Uses a weighted average based on the smoothing factor.
Calculate the smoothing factor for a period from a given combination of original smoothing factor and iterations by exponentiating the complement by the iterations.
Calculate the iterated exponential moving average for the given balances. iterations is the number of iterations of the EMA to calculate. prev is the previous oracle value, incoming is the new value to integrate. smoothing is the smoothing factor of the EMA.
Calculate the iterated exponential moving average for the given balances. iterations is the number of iterations of the EMA to calculate. prev is the previous oracle value, incoming is the new value to integrate. smoothing is the smoothing factor of the EMA.
Calculate the iterated exponential moving average for the given prices. iterations is the number of iterations of the EMA to calculate. prev is the previous oracle value, incoming is the new value to integrate. smoothing is the smoothing factor of the EMA.
Calculate the iterated exponential moving average for the givenEmaVolumes. iterations is the number of iterations of the EMA to calculate. prev is the previous oracle value; the incoming value is always zero. smoothing is the smoothing factor of the EMA.
Calculate a weighted average for the givenEmaLiquidity values. prev is the previous oracle value, incoming is the new value to integrate. weight is how much weight to give the new value.
Calculate a weighted average for the given prices. prev is the previous oracle value, incoming is the new value to integrate. weight is how much weight to give the new value.
Calculates smoothing factor alpha for an exponential moving average based on period: alpha = 2 / (period + 1). It leads to the “center of mass” of the EMA corresponding to be the “center of mass” of a period-length SMA.
Calculate the current oracle values from the outdated and update_with values using the smoothing factor with the old values being iterations out of date.
Calculate a weighted average for the givenEmaVolumes. prev is the previous oracle value, incoming is the new value to integrate. weight is how much weight to give the new value.

Type Definitions

EmaPrice is a rational number represented by a u128 for both numerator and denominator.