DYNAMIC-FEE HOOK · PYTH × REACTIVE

Measured, not guessed.

A dual-mode dynamic-fee hook that charges an IL-insurance premium only on the toxic flow that causes impermanent loss — priced off a de-trended oracle deviation, with every constant calibrated from real on-chain backtests.

92.42%
calm precision
+1.89 bps
net LP, calm
4,511
swaps replayed
52
Foundry tests
DIRECTIONAL FEE CONTROL reads Pyth live
Fair price · Pyth competitor / oracle pool drifts below fair arbitrage corrects pool back to fair + premium
Correcting (arbitrage) leg — base fee + premium, so the LP earns the spread
Aligned leg — base fee only
Hook reads Pyth, sizes the gap, and prices the correcting leg off a de-trended deviation.
α = 0.5
slope · cap 50 bps
01 / DIFFERENTIATOR

Only the toxic leg pays.

Impermanent loss comes from the correcting direction of flow — the leg that pushes the pool back toward fair value. PegGuard charges its IL-insurance premium only on that leg. Benign flow pays the base fee and nothing more.

The premium is priced off a de-trended oracle deviation, and every constant is calibrated from real on-chain backtests — not a hand-picked guess.

directional premium de-trended deviation backtest-calibrated
PegGuardasymmetric
Premium charged only on the correcting leg
Priced off a de-trended deviation (slow basis removed)
Every constant calibrated from 4,511 real swaps
Competing fee hookssymmetric
One symmetric fee on all flow, benign included
Charges raw deviation — slow basis taxed too
Constants are hand-picked
02 / CALIBRATION & PRECISION

The premium lands
where it should.

Of every dollar of premium charged, the share that fell on genuinely toxic flow — precision — was measured by replaying 4,511 real swaps as regression tests against an oracle ground truth.

629
calm swaps
3,882
volatile swaps
16
anchor alignment
CALM WINDOW
92.42 % precision
truth-capture 22.98%
VOLATILE WINDOW
98.86 % precision
truth-capture 25.56%
62%
of the raw gap is slow basis
Why de-trending is the whole game.

Slow basis must not be charged. Failing to de-trend the pool-vs-fair spread inflates apparent capture from the real 17% to a fake 224% — pure measurement artifact. PegGuard removes it with a ±300 s rolling median.

03 / VALUE TO LPs

The premium
captures value.

In the calm window, PegGuard returns net value to LPs across every swap-size bucket — and beats a static-fee pool on the same flow.

+1.89
PegGuard net LP · bps
+0.97
static-fee pool · bps

Honest read: in the volatile window net LP is −0.47 bps at the current 5 bps tier — see the base-fee finding below.

NET LP BY SWAP SIZE calm window · bps
0 0.5 1.0 1.5 2.0 +1.29 <$1k +2.00 $1k–$10k +0.43 $10k–$50k
Every bucket with calm-window flow returns net-positive value to LPs.
04 / THE CORE FINDING

Base fee = measured toxicity.

Profitability isn't a vibe — it's a base-fee-vs-toxicity question. For each window we measured the base fee a pool would need to break even.

At the current 5 bps tier, calm flow clears its bar with room to spare. Volatile flow needs slightly more — exactly the toxicity the premium is built to price.

REQUIRED BASE FEE TO BREAK EVEN
current tier 5.00 bps 3.12 bps Calm window 1.88 bps surplus → net +1.89 5.48 bps Volatile window
Calm clears the tier → profitable Volatile exceeds it → −0.47 bps
05 / CONTROL PLANE

A reactive control plane — not a reactive price.

Two safety systems sit on a minute-scale budget where cross-chain delivery latency is acceptable. Pricing stays on the 2–5 s Pyth hot path; Reactive Network drives the regime changes and breaker signals around it.

GUARD breaker
stable-pair depeg circuit breaker

Normal stable-pair deviation runs 0.000–0.35 bps — below the ~0.2 bps feed noise. There's no directional fuel to harvest, so the hook charges no premium and arms the breaker only.

50 bps
trip threshold
142.9×
over normal max
Volatility sentinel
Reactive cross-chain RSC

A 40 bps / 180 s trigger arms the volatile regime early. Across the calibration fixtures it fired with zero calm false positives and 6 volatile triggers.

0
calm false positives
74 min
lead before heavy bleed
SENTINEL LEAD TIME — VOLATILE EPISODE A looser 60 bps trigger bled $2,399 before firing.
heavy-bleed window sentinel arms +4332s bleed begins +8759s 74 minutes of lead
PRICING PATH · 2–5 s budget

Hot-path premium reads Pyth pull prices. The race clock is the pool's ~14 s update interval; Pyth at 2 s staleness keeps 88% of edge.

CONTROL PLANE · minutes budget

Regime changes, breaker signals and baseline upkeep tolerate latency — so Reactive Network belongs here, never in pricing.

06 / ARCHITECTURE & SAFETY

Invariants, not promises.

The mechanism is bounded by hard rules and locked behind a parity-checked replay pipeline.

52
Foundry tests passing
+ parity-locked replay
Never reverts a swap

On any oracle fault or fee-calc edge, the hook degrades to the base fee. A swap is never blocked.

Slow-basis de-trending

A ±300 s rolling median (τ = 450 s EMA) strips slow basis so only real, fast deviation is priced.

Monotone control plane

Tightening is immediate; loosening waits a 30 min disarm delay. Protection can only ratchet up fast.

Relative confidence gate

Pyth confidence (~10 bps) dwarfs the ~1 bps signal, so a 3× EMA anomaly gate replaces absolute gating.

07 / EVERY CONSTANT, CALIBRATED

No magic numbers. Each constant traces to a sweep in the project's data/ directory.

α0.5
premium slope · capture linear in α
cap50 bps
clamp on extreme oracle-fault fees
τ450 s
basis EMA · ±300 s median equiv.
deadband0.5 bp
the knee in each regime sweep
staleness5 / 2 s
calm / volatile Pyth pull guard
sentinel40/180
bps / s · 0 calm false positives
guard trip50 bps
142.9× over normal stable noise
regime TTL30 min
60 s-late change costs ~0.4% bleed
See full provenance & sweeps →
BUILT WITH
P
Pyth
Hot-path price oracle — pull prices on the 2–5 s pricing budget.
R
Reactive Network
Cross-chain control plane — volatility sentinel & depeg breaker.