The Liquidity Depth Risk Pool project is an advanced automated market maker (AMM) design built on Uniswap v4. It uses Hooks to create a "self-aware" pool that monitors its own health and adjusts fees in real-time to protect liquidity providers (LPs).
Standard liquidity pools are passive and often vulnerable to "toxic flow"—sophisticated traders who drain value from a pool when its liquidity is low or prices are volatile. This project introduces an Automated Risk Manager (the hook) that acts as a "surge pricing" algorithm. It calculates the "Risk Premium" of a trade based on the tick from the previous transaction and automatically increases swap fees to compensate LPs for the higher risk of being a counterparty to an informed trader.
| Feature | Description |
|---|---|
| Depth-Dependent Fees | The pool automatically raises swap fees when liquidity (depth) falls below a safe threshold. |
| LVR Mitigation | Protects LPs from "Loss-Versus-Rebalancing" (LVR) by making it too expensive for arbitrageurs to exploit the pool during volatile moments. |
| `beforeSwap` Logic | The risk assessment runs before every trade, ensuring the fee is always current and relevant to the immediate state of the pool. |
| Dynamic Fee Override | Uses v4’s dynamic fee capability to bypass static tiers (like v3's 0.3%) in favor of a calculated risk-based rate. |
Here are the commands on how to interact with hook smart contract:
forge script script/01_CreatePoolAndAddLiquidity.s.sol \
--rpc-url [your-rpc-url] \
--private-key [your-private-key] \
--broadcast
forge script script/02_AddLiquidity.s.sol \
--rpc-url [your-rpc-url] \
--private-key [private-key] \
--broadcast
forge script script/03_Swap.s.sol \
--rpc-url [your-rpc-url] \
--private-key [private-key] \
--broadcast \