Skip to main content
Every peg-monitoring system eventually faces the same problem: a noisy signal that crosses a threshold a dozen times in a single minute. The first alert is useful. The next ninety-nine are spam — and the user mutes the channel within an hour. The fix is hysteresis. Hysteresis means a state machine remembers where it came from. Going up needs a higher threshold than coming back down. It’s the same logic a household thermostat uses: heat turns on at 19°C, but won’t turn off until the room reaches 21°C. Without that gap, the heater clicks on and off every few seconds.

The state ladder, explicitly

Pegana has five peg states for every monitored asset:
  • PEGGED — spread inside the calm band; no alert.
  • DRIFT — spread crossed the per-asset drift threshold; subscribers are notified.
  • DEPEG — spread crossed depeg; more urgent alert framing.
  • CRITICAL — spread crossed critical; the system explicitly tags the asset as actively breaking.
  • BLACK_SWAN — spread beyond any historically-observed level; treated as terminal until governance / human review.
Plus one orthogonal state — UNKNOWN — for when the input signal is stale or low-confidence. UNKNOWN is sticky: a feed must recover for 60+ seconds before re-entering the live ladder.

Asymmetric enter and exit

For an LST with a drift threshold at 30 bps:
  • PEGGED → DRIFT: the smoothed spread must cross 30 bps and stay there for 30s.
  • DRIFT → PEGGED: the smoothed spread must fall to 20 bps AND stay there for 60s.
  • DRIFT → DEPEG: the smoothed spread must cross 100 bps and stay there for 30s.
  • DEPEG → DRIFT: the smoothed spread must fall to 80 bps AND stay there for 60s.
Notice the asymmetry. The exit threshold is 33–34% closer to neutral than the entry threshold. Combined with the 60-second exit dwell, this means a signal noisily oscillating in the 25–35 bps range stays in DRIFT for the entire duration — one alert at entry, none in the middle, one transition back when the underlying actually heals.

Why the exit dwell is longer than the entry dwell

Entering a stressed state is something subscribers want fast — a 30-second confirmation is plenty. Exiting back to PEGGED is something subscribers want to trust — a single tick at 29 bps after a 200 bps spike is not the same as a sustained recovery. Doubling the exit dwell to 60s is a small cost (one extra minute of alert state) and a big honesty win. The same logic applies at every state boundary. CRITICAL → DEPEG requires 60s below the critical exit threshold. BLACK_SWAN never auto-exits — it requires a manual review acknowledging the recovery.

EWMA smoothing on top of the FSM

Even with asymmetric thresholds, raw ticks are too noisy. Pegana smooths the raw spread with an EWMA (exponentially-weighted moving average) using α = 0.3 by default. That means each new tick contributes 30% to the displayed spread; the prior smoothed value carries 70%. α matters. A higher α (say 0.6) is more responsive but lets transient spikes flip state. A lower α (0.1) is laggy and misses real depegs. 0.3 is calibrated against 24h p99 noise per asset class — it’s tight enough to catch a real depeg inside 15 seconds and loose enough that a single bad Jupiter quote doesn’t trip the alert.

What this means for downstream consumers

If you’re consuming Pegana’s WebSocket stream as an event source — webhook trigger, prediction-market settlement, insurance payout — you want hysteresis. Without it, you’d see a 1-second DRIFT → PEGGED → DRIFT roundtrip as two separate transitions, and your downstream automation would react twice. Pegana’s published transitions are guaranteed to be sticky for at least the exit dwell window (30–60s depending on direction). A transition emitted at 12:34:05 means the state held for that long. You can act on the transition immediately and trust it won’t reverse in the next breath.

Reading the parameters

Every threshold and dwell timer lives in assets.toml and is exposed via /v1/assets/<symbol>/extra. The /thresholds <symbol> command in @PeganaWatchBot returns the same numbers in chat. Reproduce the FSM yourself from raw discount ticks if you want — the parameters are open.

Methodology

Full FSM parameters, formulas, exit thresholds per asset class.

State machine

Higher-level overview of the five states.

Sources