Double EMA

New loans are sized on the lower of two moving averages, one of which drops the moment a price falls, and liquidations read only the smoother one.

Updated Nov 11, 2026

A single moving average lags the price it follows, and the lag can be exploited both ways: a borrower can draw against it before it catches a fall, and a manipulator can push it with a spike. Each side of a market therefore keeps two averages of its price and gives them different jobs.

The two averages

AverageHow it movesHalf-life
SymmetricFollows the price both ways at its half-lifeOne minute to twelve hours; one hour in the app's default preset
DirectionalDrops at once to the last observed price on any fall, rises at its half-lifeOne minute to twelve hours; the app sets it equal to the symmetric one

Both fold in xx, the price cached by the previous observation, at most once per 200 ms slot. With Δt\Delta t the time since the last fold and HH the half-life, the new input weighs w=1−2−Δt/Hw = 1 - 2^{-\Delta t / H}:

s′=s+w (x−s)d′=min⁡ ⁣(x, d+w (x−d))\begin{aligned} s' &= s + w\,(x - s) \\ d' &= \min\!\big(x,\ d + w\,(x - d)\big) \end{aligned}

New loans read the pessimistic price, the lower of the two:

p^=min⁡(s, d)\hat p = \min(s,\ d)

Each side keeps its own pair. Collateral in the base token is valued at the base price's p^\hat p, and collateral in the quote token at the quote price's, which matches the higher of the recent base prices. The quote side folds the reciprocal of the base price, rounded down.

The fold always uses the price that stood since the previous observation, then caches the current one. A price set in some slot therefore enters the symmetric average only at an observation in a later slot, weighted by how long it stood. Swaps, liquidity changes and lending and leverage actions all record the market's price after they settle.

A third average follows the curve's depth, its total tail and band liquidity, with its own half-life and the same fold. Borrow admission reads the pessimistic depth min⁡(Dobs,Davg)\min(D_{\text{obs}}, D_{\text{avg}}), the lower of the last observed depth and its average and never more than the current depth, so depth counts at once when it falls and slowly when it grows. Liquidity added just before a loan does not raise that loan's limit until the average has caught up.

Front-running a lagging average

A lone average lags a real fall. If a token drops 30% at once, a one-hour average has followed only about 11% of the drop ten minutes later, so collateral valued at it would still count for about 38% more than it would sell for. A borrower could draw a loan at that stale value and leave the market to absorb the difference once the average caught up.

The directional average closes that window. It drops to the new price at the next observation, so the pessimistic price follows a fall at once, and it climbs back only at its half-life, so a rise reaches borrowing power only after it has held.

  • One-hour average alone
  • Lower of the two averages · new loans
A 30% fall at minute zero, with a one-hour half-life.

The program's own arithmetic gives the same picture. A swap in slot 0 takes the price from 100 to 70, and both averages have a one-hour half-life:

MomentSymmetric ssDirectional ddp^\hat p
A borrow later in slot 0100.000070.000070.0000
3,000 slots later, ten minutes96.727070.000070.0000
Ten minutes after the price returns to 10097.084173.273073.2730

After the recovery the pessimistic price has regained 3.27 of the 30 points, the same 11% share of the move that the symmetric average followed on the way down.

Spikes and wicks

A spike inflates collateral only if the averages follow it, and a false price has to be held against arbitrage on the market's own curve. With a one-minute half-life, ten seconds of it moves an average about 11% of the way; with a one-hour half-life, about 0.2%. A spike that arbitrage removes after a single slot moves them 0.23% and 0.004% of the way. Neither average rises faster than its half-life.

A wick is the same move downward. The directional average reacts to it, which only makes new loans smaller. Liquidation never reads the directional average: a position is judged at the symmetric average alone, against the factor it stored when it borrowed, so a wick has to be held as long as a spike before it can liquidate anyone.

The pessimistic price is slow to rise and quick to fall, which suits sizing new loans. The symmetric average moves halfway only after a full half-life, which suits judging existing ones.

Which price does what

JobPrice and depth used
SwapsThe live curve at current reserves
Leverage entriesThe live curve for the fill; equity must also clear the initial margin at the pessimistic price and at the symmetric EMA
Borrow admission and stored collateral factorsA shadow constant-product tail at p^\hat p, scaled to pessimistic depth
Collateral withdrawalsThe same shadow tail, at the greater of the stored factor and a fresh one
Lending liquidation eligibilityCollateral marked linearly at the symmetric EMA against the stored factor
Leverage liquidation eligibilityEquity at the symmetric EMA against the stored maintenance margin
Ordinary liquidationPayment priced at the symmetric EMA; atomic collateral-for-payment settlement
Emergency liquidationThe market's curve rebuilt at the symmetric EMA and the depth average, never the live reserves
hLP deposits and withdrawalsThe live price and the vaults' current value

Admission is conservative, so a new loan starts inside what a stressed sale of its collateral would cover; see Dynamic collateral factor. Eligibility is a smooth mark, so a wick does not liquidate a healthy position. External recovery is the liquidator's fixed-payment route, and the internal fallback rebuilds the curve from the averages; see Internal unwind.

Cached risk books

Within one slot Δt\Delta t is zero, so a swap placed before a borrow or a liquidation in the same slot cannot move the symmetric average. Only conservative inputs react inside a slot: the directional average can fall to the price an earlier swap left behind, which only shrinks new loans.

Time, rounding and empty states

Time counts slots at a nominal 200 ms, so a one-hour half-life is 18,000 slots. A block leader's timestamp cannot speed an average up, and skipped slots count as elapsed time. The program evaluates 2−Δt/H2^{-\Delta t/H} with a range-reduced five-term series in nine-decimal fixed point and rounds each new average down.

An average whose stored value or input is zero restarts at the input, so a market's first observation sets every average to its opening price and depth. If every LP withdraws and only the locked minimum liquidity is left, the averages reset with the curve and the next deposit starts them again. A refresh with a zero price or zero depth fails with InsufficientLiquidity.

Choosing a half-life

The market creator sets the symmetric half-life from presets: seven minutes, thirty minutes, one hour or two hours, or any value between one minute and twelve hours in advanced mode. The app gives the directional and depth averages the same half-life.

An average catches up with a step change after roughly five to six half-lives. The operator or manager can announce changes later through the EMA half-lives family, subject to the full notice. The family holds four half-lives, for the symmetric price, the directional price, the depth and the sticky centre's own average, each between one minute and twelve hours (InvalidHalfLife), and an update must change at least one of them (ParameterUpdateNotMeaningful). On execution the program first folds the time already elapsed under the old half-lives and only then switches. Execution fails with UtilizationGuardExceeded while either side's utilization is at or above 80%.

  • Spot
  • Symmetric average · liquidations
  • Lower of the two averages · new borrows
Four sample hours of spot price.