The regime

The hook runs a two-sided CUSUM detector on the pool's own price. When it confirms a trend, swaps that push with it pay a spread of up to 5%, which stays with liquidity providers. The other side pays the plain pool price.

How a trend is confirmed

Each block's return feeds two CUSUM statistics, one per direction. A trend is declared when the evidence for one crosses its threshold, a data-dependent moment, never a fixed number of blocks, so nobody can precompute it. The spread also needs the moves to be directional enough (directional efficiency above its floor); random noise keeps that gate shut. The spread then ramps, rate-limited, up to a hard 5% cap.

Fields

FieldMeaning
trendnone · up · down, in market terms (up = price rising)
levelcalm (no evidence) · building (evidence accumulating, or a trend whose spread is gated) · engaged (a side pays now)
withTrendSideThe side pushing with the trend: buy in an up-trend, sell in a down-trend
chargedSideThe side that pays a spread in this block, if any
spread{ buy, sell } as fractions, projected for this block
evidence{ up, down, threshold, progress }: progress 1 means the threshold is crossed
gatedDirectional efficiency is under its floor: moves read as chop, nothing is charged
feeThe volatility-scaled base fee every swap pays

Events to react to

watchRegime in the SDK and wait_for_regime_change in MCP diff consecutive snapshots into:

EventWhen
trend-startedThe detector confirms a trend
trend-endedThe trend's evidence is gone
trend-flippedOne trend replaced by the opposite one
evidence-buildingEvidence is accumulating toward the threshold
spread-engagedA side starts paying the spread
spread-releasedThat side stops paying
Orientation. The hook's internal price is WETH per USDC, so its own "Up" is a falling chart. The SDK, API and MCP all report market terms; you never see the inversion.

Unichain Sepolia · chain 1301 · testnetLaunch app