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
| Field | Meaning |
|---|---|
trend | none · up · down, in market terms (up = price rising) |
level | calm (no evidence) · building (evidence accumulating, or a trend whose spread is gated) · engaged (a side pays now) |
withTrendSide | The side pushing with the trend: buy in an up-trend, sell in a down-trend |
chargedSide | The 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 |
gated | Directional efficiency is under its floor: moves read as chop, nothing is charged |
fee | The 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:
| Event | When |
|---|---|
trend-started | The detector confirms a trend |
trend-ended | The trend's evidence is gone |
trend-flipped | One trend replaced by the opposite one |
evidence-building | Evidence is accumulating toward the threshold |
spread-engaged | A side starts paying the spread |
spread-released | That 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.