StableGuard is a custom Uniswap v4 hook deployed on X Layer that protects uniswap pools from impermanent loss and inventory skew during agent-driven, yield-seeking trading. The dynamic fee curve is th

StableGuard protects uniswap pools from impermanent loss and inventory skew during agent-driven, yield-seeking trading. The dynamic fee curve is the product: fees stay low while the pool is calm, and rise automatically as the hook actively defends it. A circuit breaker blocks trades that would push the pool past a safe skew threshold. A lightweight off-chain API exposes this protection status so other agents can check a pool's live risk before routing a swap through it gated via x402 payment
Why
Agents increasingly compete for yield across stablecoin pools, and that trading pressure can quietly skew a pool's inventory and expose LPs to impermanent loss. StableGuard makes that risk visible and priced in real time, rather than something LPs only discover after the fact.
A Uniswap v4 hook on X Layer that:
Tracks pool skew live, on-chain, per swap.
Moves the swap fee through three tiers as skew rises — calm, elevated, defensive — so the cost of trading against the pool's balance scales automatically with the risk that trade adds.
Hard-blocks trades that would push skew past a safety threshold, via a circuit breaker.
Exposes all of this through a stateless off-chain API, so agents can check a pool's live protection status before they submit a swap — not just discover the cost after the fact.
Lets agents swap in without a separate on-chain approval step, via a Permit2-based router — matching the gasless-approval pattern the Uniswap Trade API itself uses.
The dynamic fee curve is the product: low fee when calm, higher fee when the hook is actively defending the pool.
Skew tracking — the hook maintains a rolling, decayed skew value per pool, updated on every swap.
Dynamic fee tiers — the fee automatically moves between three tiers based on current skew:
Calm — 0.01%
Elevated — 0.05%
Defensive — 0.30%
Circuit breaker — a trade projected to push skew past a hard threshold is reverted before it executes.
Protection status API — agents call GET /protection-status/:poolId to see the current skew, fee tier, whether the circuit breaker is armed, and the maximum additional skew that's still safe — before they submit a swap.
Agent ID: 5849
StableGuard protects Uniswap v4 stable pools from impermanent loss & inventory skew with dynamic fees and protects Uniswap pools during agent-driven, yield-seeking trading & circuit breakers. Trading agents can check risk before they swap via our free API gated via x402 payment.
✅ Health: https://stableguard-r2fz.onrender.com/health
✅ Pool status (default or by ID): https://stableguard-r2fz.onrender.com/protection-status
📦 Registration tx: https://www.oklink.com/x-layer/evm/tx/0xc6d6a6d749a06fd115934f582315479f85146be5e029e52ad63d8751e3985cdf
👛 Hook: 0x0B46218C3FA54CC0f1E058016bc4a1f51DCB40C0
🔗 GitHub: https://github.com/CoderOfPHCity/StableGuard
Built for the agent economy – free, fast, and ready for action.
- **Circuit breaker is revert-based, not in-hook partial-fill.** True partial-fill throttling requires adjusting the returned `BeforeSwapDelta` to clamp `amountSpecified`, with different accounting for exact-in vs. exact-out swaps. StableGuard ships the simpler "advisory max-safe-size + hard revert" version; tightening this is the natural v2 extension.
- **Skew tracking uses a simplified magnitude+direction proxy** rather than exact post-trade reserve math. Good enough for tiering and the breaker; tightenable with `StateLibrary` reads.
- **`StableGuardRouter`'s settlement logic (`_settleDelta`) is the most version-sensitive file in the repo** — it has not been run against a live pool yet. `CurrencySettler`'s exact location/signature moves between v4-core releases; confirm it resolves and add a swap test before trusting this beyond a testnet demo.
- **PoolManager and Permit2 addresses on X Layer testnet are unverified** as of this writing. `scripts/verify-pool-manager.sh` and `scripts/verify-permit2.sh` check both before you deploy anything real against them.
- **x402 payment verification is a structural placeholder**, not real enforcement, until the OKX Payment SDK is installed — see the TODO in `x402.guard.ts`. `/protection-status` works either way since it's free regardless.
non