- Demo
- Pitch Deck
- Overview
- Core Functionality
- Architecture
- Key Metrics
- Setup
- Applications
- Extensions & Future Roadmap
- Mathematical Appendix
- License
The Liquidity Oracle is a decentralized analytics system designed to monitor and quantify liquidity behavior in Uniswap v4 pools. By leveraging EigenLayer's AVS infrastructure, it provides real-time metrics and insights into pool dynamics, helping liquidity providers, market makers, and risk managers make data-driven decisions.
The oracle tracks two primary categories of data:
- Spread β Measures the difference between bid and ask prices, which reflects market liquidity and trading costs. A tighter spread indicates better liquidity. Measured using the standard deviation of weighted ticks. Read more
- Depth β Represents the amount of liquidity available at different price levels. It helps estimate how large orders impact the market price. Measured using the weighted mean of liquidities. Read more
- Liquidity Concentration β Determines how evenly liquidity is distributed across price levels. Measured using the Herfindahl-Hirschman Index (HHI), which quantifies concentration. A higher HHI suggests liquidity is concentrated at fewer price points. Read more
- Liquidity Transition β Tracks how liquidity shifts across ticks over time. This metric uses Cosine Similarity (measuring directional similarity of liquidity vectors), Wasserstein Distance (assessing the effort needed to redistribute liquidity), and Hellinger Distance (quantifying differences in probability distributions).
- Time-Based Volatility β Measures fluctuations in liquidity over time. This is assessed using:
- Time-Based Transition β Captures liquidity shifts within a given time frame.
- Entropy β Quantifies the randomness in liquidity changes. Read more
- Temporal Volatility β Measures variations in liquidity values over time.
- Per-Tick Volatility β Smoothed using an Exponential Weighted Moving Average (EWMA) to give more importance to recent changes. Read more
The system employs a hybrid on-chain and off-chain approach:
A Uniswap v4 Hook responsible for maintaining pool metrics and triggering AVS computations based on predefined conditions:
- Liquidity Delta β Detects significant changes in liquidity.
- Time Delta β Ensures periodic updates.
- Price (Tick) Delta β Monitors price movement across ticks.
- Manages task creation for AVS computations.
- Validates AVS operator responses before posting them to the Oracle Hook.
- Integrates with EigenLayer core contracts.
- Analyzes liquidity distribution curves.
- Computes volatility and transition metrics.
- Calculates structural liquidity parameters.
- Signs and submits results on-chain.
The Liquidity Oracle quantifies pool liquidity behavior through several key indicators:
- Effective bid-ask spreads β The smaller the spread, the lower the transaction cost.
- Liquidity density distribution β Examines how liquidity is spread across different price levels.
- Price impact curves β Assesses how price changes with different order sizes.
- Available liquidity at price levels β Measures how much liquidity is available at different price points.
- Slippage projections β Estimates how much price will shift when a trade is executed.
- Market impact estimations β Analyzes how large trades affect market price.
- Tracked using Cosine Similarity, Wasserstein Distance, and Hellinger Distance.
- Measures how liquidity shifts across ticks over time.
- Time-based volatility tracking using:
- Entropy metrics.
- Per-tick volatility (EWMA-based smoothing).
- Temporal volatility assessments.
-
Clone the repository:
git clone https://github.com/Suryansh-23/liquidity-oracle
-
Start Local Chain (Anvil):
make start-anvil
-
Start the Operator in a new terminal window:
make master
-
Test a liquidity modification in another terminal window:
make test-modify-liquidity
-
Start the simulator:
make start-simulator
-
Launch the dashboard:
make start-dashboard
- Real-time liquidity rebalancing based on liquidity transitions.
- Optimized position ranges using historical liquidity data.
- Improved liquidation mechanisms using liquidity depth insights.
- Better volatility forecasting with liquidity transition data.
- Preemptive position adjustments to avoid high-slippage trades.
- Deep insights into market maker behavior across time.
- Predictive modeling using oracle-provided liquidity metrics.
- Detection of abnormal liquidity behaviors (e.g., sandwich attacks).
- Dynamic fee adjustments based on volatility and depth analysis.
- Adaptive liquidity allocation across multiple Uniswap pools.
- Integration with automated market makers (AMMs) for optimizing liquidity distribution.
- Determining optimal staking vs. LP rewards based on volatility.
- Risk-adjusted allocation of liquidity for better yield optimization.
- Cross-protocol liquidity monitoring for better capital efficiency.
- Real-time liquidity transition data to identify profitable arbitrage opportunities.
- Flash loan risk analysis to prevent large slippage in short-term trades.
- Enhanced execution for MEV bots leveraging precise liquidity estimates.
- Borrow/Lend market risk estimation based on liquidity depth.
- Adaptive collateral ratio adjustments based on market volatility.
- Preventing cascading liquidations by integrating liquidity-aware triggers.
- Develop a dynamic threshold model for triggering AVS computations per pool.
- Introduce pool-specific sensitivity settings based on historical liquidity behavior.
- Optimize gas efficiency by reducing unnecessary AVS computations.
- Liquidity Fragmentation β Measures how liquidity is distributed across multiple pools or chains.
- Tick Density Gradient β Analyzes liquidity concentration per tick to detect clustering patterns.
- Liquidity Time-To-Live (LTTL) β Estimates the lifespan of liquidity at different price levels.
- Introduce a stake-slashing protocol for AVS operators submitting incorrect or delayed data.
- Implement on-chain fraud detection to penalize misreporting.
- Use historical accuracy tracking to reward reliable operators and slash malicious ones.
- Use multi-signature threshold schemes to aggregate operator responses.
- Implement BLS or Schnorr signature aggregation for efficient verification.
- Reduce on-chain storage costs by bundling AVS responses into a single proof.
$$SC(A, B)\ =\ \frac{\sum{i=1}^{n} Ai B_i}{\sqrt{\sum{i=1}^{n}Ai^2} \cdot\sqrt{\sum{i=1}^{n}B_i^2}}$$
This project is licensed under LICENSE.