# Towards Optimal Liquidity Provision on AMMs ## Introduction Decentralized exchanges (DEXs) and Automated Market Makers (AMMs) have revolutionized digital asset trading. Uniswap V3, with its concentrated liquidity mechanism, allows Liquidity Providers (LPs) to concentrate capital within specific price ranges for greater efficiency. However, this flexibility brings new challenges in managing liquidity and optimizing returns. This research aims to develop optimal liquidity provision strategies on Uniswap V3. By combining data analysis, forecasting, optimization, and control techniques, we seek to provide LPs with data-driven insights and tools to maximize returns while mitigating risks. ### Key research problems: * **Analyzing Uniswap V3 dynamics:** Understanding the impact of concentrated liquidity on market behavior and LP profitability. * **Forecasting key market variables:** Developing accurate forecasting models for price volatility and trading volume. * **Optimizing liquidity allocation:** Determining the optimal allocation of liquidity across different * **Developing dynamic control strategies:** Exploring Model Predictive Control (MPC) and Reinforcement Learning (RL) for adaptive liquidity provision. ## Stage 0: DeFi/AMM Foundations * [DeFi Navigator](https://ccaf.io/defi/ecosystem-map/visualisation/graph) * [Uniswap University](https://uniswap.university/) * Emmanuel Gobet, Anastasia Melachrinos. Decentralized Finance & Blockchain Technology. SIAM Financial Mathematics and Engineering 2023, Jun 2023, Philadelphia, United States. ⟨hal-04131680⟩ [link](https://hal.science/hal-04131680) * https://www.machow.ski/posts/an_introduction_to_automated_market_makers/ * https://0x.org/post/market-making-in-defi ## Stage 1: Data Analysis * **Data Sources:** TBD * **Exploratory Data Analysis (EDA):** * Analyze historical price data, trading volume, liquidity depth, and pool composition for selected pools. * Chap 3 & 4 of [CJP] * Chap 4 of [BBDG] * Visualize key metrics and identify patterns and trends. * https://www.geeksforgeeks.org/what-is-exploratory-data-analysis/ * https://towardsdatascience.com/techniques-for-exploratory-data-analysis-and-interpretation-of-statistical-graphs-383ce57a6d0a * https://towardsdatascience.com/time-series-forecasting-a-practical-guide-to-exploratory-data-analysis-a101dc5f85b1 * Calculate key metrics such as impermanent loss and Loss-Versus-Rebalancing (LVR). * https://panoptic.xyz/research/panoptic-solves-lvr * https://ethresear.ch/t/cex-dex-arbitrage-transaction-fees-block-times-and-lp-profits/19444 * https://mirror.xyz/0xbdA5bCe76bF62d97D9C9dF0425CC10079Df1aD75/bWOCccjVC7eoYKOzgmjXFdhWDc8rrUL6Yei-eugF52s * https://youtu.be/ArILIuH7G2U?si=dR2p-g32Tju0zTqt * Robin Fritsch and Andrea Canidio. 2024. Measuring Arbitrage Losses and Profitability of AMM Liquidity. In Companion Proceedings of the ACM Web Conference 2024 (WWW '24). Association for Computing Machinery, New York, NY, USA, 1761–1767. https://doi.org/10.1145/3589335.3651961 * **Empirical Properties of Uniswap V3:** * Review literature on the mechanics and dynamics of Uniswap V3. * Angeris, G., Kao, H.-T., Chiang, R., & Noyes, C. (2019). An analysis of Uniswap markets. arXiv preprint arXiv:1911.03380. * Angeris, G., & Chitra, T. (2020). Improved price oracles: Constant function market makers. In Proceedings of the 2nd ACM Conference on Advances in Financial Technologies (AFT '20) (pp. 80–91). Association for Computing Machinery, New York, NY, USA. https://doi.org/10.1145/3419614.3423251 * Urusov, A., Berezovskiy, R., & Yanovich, Y. (2024). Backtesting Framework for Concentrated Liquidity Market Makers on Uniswap V3 Decentralized Exchange. arXiv preprint arXiv:2410.09983. * Analyze the impact of concentrated liquidity on market efficiency and LP returns. * https://panoptic.xyz/research/from-centralized-to-decentralized-exchanges-options-pricing * https://panoptic.xyz/research/new-formulation-implied-volatility * https://panoptic.xyz/research/comparing-uniswap-deribit-implied-volatilities ## Stage 2: Forecasting * **Target Variables:** Volume, Volatility, Fees, LP Return (normalized by liquidity and across different time scales) * **Feature Engineering:** * Extract relevant features (e.g., price volatility, moving averages, order book data, on-chain metrics). * Justify feature selection based on potential predictive power. * **Model Selection:** * Choose appropriate forecasting models from `statsmodels`, `sktime`, and `NIXTLA` libraries. * [statsmodels](https://www.statsmodels.org/stable/index.html) * [sktime](https://www.sktime.net/en/stable/) * [NIXTLA](https://www.nixtla.io/) * [Kats](https://facebookresearch.github.io/Kats/) * Explain the rationale behind model choices. * **Backtesting:** * Evaluate forecasting model performance on historical data using appropriate accuracy metrics. * **Reading** * [HA] * Luxenberg, E., & Boyd, S. (2024). Exponentially weighted moving models. arXiv preprint arXiv:2404.08136. [link](https://web.stanford.edu/~boyd/papers/ewmm.html) * Ogut, G., Meyers, B., & Boyd, S. (2023). Interpretable net load forecasting using smooth multiperiodic features. arXiv preprint arXiv:2304.11376. [link](https://web.stanford.edu/~boyd/papers/multiperiodic_forecasting.html) * Johansson, K., Ogut, M., Pelger, M., Schmelzer, T., & Boyd, S. (2023). A simple method for predicting covariance matrices of financial returns. Foundations and Trends® in Econometrics, 12(4), 324–407. [link](https://web.stanford.edu/~boyd/papers/cov_pred_finance.html) * Dong, Y., Qin, S. J., & Boyd, S. (2022). Extracting a low-dimensional predictable time series. Optimization and Engineering, 23(2), 1189–1214. [link](https://web.stanford.edu/~boyd/papers/low_dim_pred_time_series.html) * Barratt, S., Dong, Y., & Boyd, S. (2021). Low rank forecasting. arXiv preprint arXiv:2101.12414. [link](https://web.stanford.edu/~boyd/papers/low_rank_forecasting.html) * Barratt, S., & Boyd, S. (2020). Fitting a Kalman smoother to data. In Proceedings of the American Control Conference (pp. 1526–1531). [link](https://web.stanford.edu/~boyd/papers/auto_ks.html) ## Stage 3: Optimization * **Objective Function:** Define the objective (e.g., maximize risk-adjusted LP returns). * LP return = $\Delta$ position value + Fees * Model the RHS as functions/distributions of features. * **Constraints:** Specify constraints on the optimization problem (e.g., capital limits, risk tolerance, maximum position size). * **Optimization Techniques:** * Explore single-period and multi-period portfolio optimization techniques. * Apply convex optimization methods to find optimal liquidity allocation strategies. * Boyd, S., Johansson, K., & Schiele, P. (2024, June). Convex optimization in quantitative finance [link](https://web.stanford.edu/~boyd/papers/cvx-finance.html). * Boyd, S., Johansson, K., Kahn, R., Schiele, P., & Schmelzer, T. (2024). Markowitz portfolio construction at seventy. The Journal of Portfolio Management, 50(8), 117–160. [link](https://web.stanford.edu/~boyd/papers/markowitz.html) * Boyd, S., Busseti, E., Diamond, S., Kahn, R., Koh, K., Nystrup, P., & Speth, J. (2017). Multi-period trading via convex optimization. Foundations and Trends® 1 in Optimization, 3(1), 1–76. [link](https://web.stanford.edu/~boyd/papers/cvx_portfolio.html) ## Stage 4: Control * **Model Predictive Control (MPC)** * Implement MPC algorithms to dynamically adjust liquidity provision based on forecasts and market conditions. * Investigate different MPC variants and their performance. * Boyd, S., Agrawal, A., & Barratt, S. (2020, December 14). Embedded convex optimization for control [Plenary lecture]. Proceedings 59th IEEE Conference on Decision and Control, Jeju Island. [link](https://web.stanford.edu/~boyd/papers/cdc_20.html) * Agrawal, A., Barratt, S., Boyd, S., & Stellato, B. (2020). Learning convex optimization control policies. Proceedings of Machine Learning Research, 120, 361–373. [link](https://web.stanford.edu/~boyd/papers/learning_cocps.html) * Shen, X., & Boyd, S. (2021). Incremental proximal multi-forecast model predictive control (Working draft). [link](https://web.stanford.edu/~boyd/papers/ip_mf_mpc.html) * **Reinforcement Learning (RL)** * Train RL agents to learn optimal liquidity provision strategies in a simulated Uniswap V3 environment. * Compare the performance of RL agents with MPC-based strategies. * [KWW] * https://github.com/JJJerome/mbt_gym * https://github.com/leandro-sbetancourt/amm_gym * https://github.com/google-deepmind/rlax * **Online Learning** * Explore online learning algorithms for adaptive market making: * Abernethy, J., & Kale, S. (2013). Adaptive market making via online learning. In Proceedings of the 26th International Conference on Neural Information Processing Systems - Volume 2 (NIPS'13) (pp. 2058–2066). Curran Associates Inc. [link](https://papers.nips.cc/paper_files/paper/2013/hash/995e1fda4a2b5f55ef0df50868bf2a8f-Abstract.html) * Cesa-Bianchi, N., Cesari, T., Colomboni, R., Foscari, L., & Pathak, V. (2024). Market Making without Regret. arXiv preprint arXiv:2411.13993. * Bar-On, Yogev & Mansour, Yishay. (2023). Uniswap Liquidity Provision: An Online Learning Approach. 10.1007/978-3-031-48806-1_16. ## References * [BBDG]Bouchaud, J.-P., Bonart, J., Donier, J., & Gould, M. (2018). Trades, quotes and prices: Financial markets under the microscope. Cambridge University Press. * [CJP]Cartea, Á., Jaimungal, S., & Penalva, J. (2015). Algorithmic and high-frequency trading. Cambridge University Press. * [HA]Hyndman, R. J., & Athanasopoulos, G. (2021). Forecasting: Principles and practice (3rd ed.). OTexts. https://otexts.com/fpp3/ * [KWW]Kochenderfer, M. J., Wheeler, T. A., & Wray, K. H. (2022). Algorithms for decision making. MIT Press. [link](https://algorithmsbook.com/decisionmaking/)