
DepegSentinel
DepegSentinel: Dynamically adjusts fees to punish depegs and reward peg-stabilizing trades.
Demo
About
# DepegSentinel – Dynamic Fee & Depeg Resolver Hook for DEXs ## Overview DepegSentinel is a Uniswap V4 hook designed to automatically safeguard pegged and liquid token pools from depegging events. Whether it’s stablecoins like USDC/USDT, liquid staking tokens like stETH/WETH, or protocol-native assets like kHYPE/HYPE, DepegSentinel ensures pools maintain a healthy peg by dynamically adjusting fees based on real-time market data. Unlike static fee models, DepegSentinel actively monitors price feeds and modifies trading costs to penalize behaviors that worsen a depeg and incentivize trades that help restore the peg. ## Problem It Solves - Pegged assets can diverge from their intended value due to large trades, liquidity shocks, or market stress. - Current DEX pools rely on static fees, which don’t account for real-time risk during depeg events. - Traders that worsen the peg unintentionally or intentionally can cause cascading liquidity issues and losses for LPs. - Protocols need a way to automatically penalize destabilizing trades and reward stabilizing trades without manual intervention. ### Example - **USDC depeg events** in the past have caused temporary losses for LPs. - A recent **Hyperliquid pool (kHYPE/HYPE)** lost ~80% of its peg in one event. - Manual intervention or reactive mechanisms are too slow to protect liquidity. ## Core Functionality DepegSentinel operates as a hook attached to Uniswap V4 pools, performing the following: ### Real-Time Price Monitoring - Integrates with **Pyth Network** to fetch live market prices for pegged assets. - Tracks deviations from the ideal 1:1 peg or expected ratio for liquid staking tokens. ### Dynamic Fee Adjustment - **If a trade worsens the peg:** Fees for the trader increase dynamically, discouraging destabilizing trades. - **If a trade helps restore the peg:** Fees are reduced, incentivizing stabilizing behavior. ### Automatic LP Protection - Reduces **impermanent loss** for liquidity providers during volatile depeg events. - Ensures pool prices remain closer to the target peg without requiring manual intervention. ### Seamless DEX Integration - Fully compatible with **Uniswap V4 hooks**, leveraging `BEFORE_SWAP` and `AFTER_SWAP` triggers. - Supports multi-asset pools, including stablecoin-stablecoin, liquid staking token pools, and protocol-native token pairs. ### Customizable - Thresholds for depeg sensitivity can be configured. - Supports multiple price sources, dynamic fee caps, and hook-specific logic per pool. ## Benefits - **Automatic Depeg Resolution:** Reduces the risk of LP losses due to sudden peg divergence. - **Trader Incentives Aligned:** Encourages actions that stabilize the pool. - **Seamless Integration:** Works natively with Uniswap V4 without major contract rewrites. - **Dynamic Risk Management:** Pool fees adapt in real-time to market conditions. - **Cross-Asset Compatibility:** Works for stablecoins, liquid staking derivatives, and protocol-specific tokens. ## Use Cases - **Stablecoin Pools:** USDC/USDT, DAI/USDC, USDT/DAI - **Liquid Staking Pools:** stETH/WETH, rETH/ETH - **Protocol Asset Pools:** kHYPE/HYPE, other project-specific tokens - **Depeg Protection for Multi-Asset AMMs:** Pools vulnerable to market shocks or liquidity withdrawals ## Why It’s Innovative - Traditional AMMs rely on fixed fees or manual risk management. - DepegSentinel introduces a **feedback loop** that automatically penalizes destabilizing trades and rewards stabilizing trades. - It’s the **first hook** that directly ties trader behavior to peg stability, using reliable on-chain price oracles.
How it's made
## How It Works (Technical Flow) ### Trade Initiation - Trader submits a swap on the pool. ### Before Swap Hook (`BEFORE_SWAP`) - DepegSentinel reads the current pool price and market peg from **Pyth**. - Calculates the expected deviation if the trade executes. ### Fee Computation (`_getFee`) - If trade worsens the peg, fee increases proportionally to deviation. - If trade improves the peg, fee is reduced, rewarding stabilizing behavior. ## Why It’s Innovative - Traditional AMMs rely on fixed fees or manual risk management. - DepegSentinel introduces a **feedback loop** that automatically penalizes destabilizing trades and rewards stabilizing trades. - It’s the **first hook** that directly ties trader behavior to peg stability, using reliable on-chain price oracles.