Skip to main content

ZeroSwap: Data-Driven Optimal Market Making in Decentralized Finance

  • Conference paper
  • First Online:
Financial Cryptography and Data Security (FC 2024)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 14744))

Included in the following conference series:

Abstract

Automated Market Makers (AMMs) are major centers of matching liquidity supply and demand in Decentralized Finance. Their functioning relies primarily on the presence of liquidity providers (LPs) incentivized to invest their assets into a liquidity pool. However, the prices at which a pooled asset is traded is often more stale than the prices on centralized and more liquid exchanges. This leads to the LPs suffering losses to arbitrage. This problem is addressed by adapting market prices to trader behavior, captured via the classical market microstructure model of Glosten and Milgrom. In this paper, we propose the first optimal Bayesian and the first model-free data-driven algorithm to optimally track the external price of the asset. The notion of optimality that we use enforces a zero-profit condition on the prices of the market maker, hence the name ZeroSwap. This ensures that the market maker balances losses to informed traders with profits from noise traders. The key property of our approach is the ability to estimate the external market price without the need for price oracles or loss oracles. Our theoretical guarantees on the performance of both these algorithms, ensuring the stability and convergence of their price recommendations, are of independent interest in the theory of reinforcement learning. We empirically demonstrate the robustness of our algorithms to changing market conditions.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    All code used for simulation in this section can be viewed anonymously at this link.

References

  1. Cowswap docs. https://docs.cow.fi/overview/coincidence-of-wants. Accessed Sep 2023

  2. Discrimination of toxic flow in Uniswap v3. https://crocswap.medium.com/discrimination-of-toxic-flow-in-uniswap-v3-part-1-fb5b6e01398b. Accessed Sep 2023

  3. Dodo integrates chainlink live on mainnet, kickstarts the on-chain liquidity revolution. https://blog.dodoex.io/dodo-integrates-chainlink-live-on-mainnet-kickstarts-the-on-chain-liquidity-revolution-ee27e136e122. Accessed Sep 2023

  4. Eigenlayer whitepaper. https://docs.eigenlayer.xyz/overview/whitepaper. Accessed Sep 2023

  5. Flash loans aren’t the problem, centralized price oracles are. https://www.coindesk.com/tech/2020/11/11/flash-loans-arent-the-problem-centralized-price-oracles-are/. Accessed Sep 2023

  6. Front running, bots, slippage, oracle pricing errors: AMMs are great, but there are problems. https://cointelegraph.com/magazine/trouble-with-crypto-automated-market-makers/. Accessed Sep 2023

  7. Optimism docs. https://community.optimism.io/. Accessed Sep 2023

  8. Optimistic rollups. https://ethereum.org/en/developers/docs/scaling/optimistic-rollups/. Accessed Sep 2023

  9. Order flow toxicity on DEXES. https://ethresear.ch/t/order-flow-toxicity-on-dexes/13177. Accessed Sep 2023

  10. Johnson, P., Nimmagadda, S.: the relentless rise of stablecoins. Brevan Howard Digital. https://digify.com/a/#/f/p/ef09be008ee64ab68bda4f0a558302a2. Accessed Sep 2023

  11. Uniswap v2 core. https://uniswap.org/whitepaper.pdf. Accessed Sep 2023

  12. Uniswap v3 core. https://uniswap.org/whitepaper-v3.pdf. Accessed Sep 2023

  13. Uniswap-v3 TVL comparison for stable coins vs non-stablecoins. https://defillama.com/protocol/uniswap-v3. Accessed Sep 2023

  14. Angeris, G., Agrawal, A., Evans, A., Chitra, T., Boyd, S.: Multi-asset trades via convex optimization, constant function market makers (2021)

    Google Scholar 

  15. Angeris, G., Chitra, T.: Improved price oracles. In: Proceedings of the 2nd ACM Conference on Advances in Financial Technologies. ACM (2020)

    Google Scholar 

  16. Angeris, G., Evans, A., Chitra, T.: When does the tail wag the dog? Curvature and market making (2020)

    Google Scholar 

  17. Aoyagi, J.: Liquidity provision by automated market makers (2020)

    Google Scholar 

  18. Avellaneda, M., Stoikov, S.: High frequency trading in a limit order book. Quant. Financ. 8, 217–224 (2008)

    Google Scholar 

  19. Chan, N., Shelton, C.: An electronic market-maker (2001)

    Google Scholar 

  20. Churiwala, D., Krishnamachari, B.: QLAMMP: a Q-learning agent for optimizing fees on automated market making protocols (2022)

    Google Scholar 

  21. Daian, P., et al.: Flash boys 2.0: frontrunning, transaction reordering, and consensus instability in decentralized exchanges (2019)

    Google Scholar 

  22. Das, S.: A learning market-maker in the Glosten–Milgrom model. Quant. Financ. 5(2), 169–180 (2005)

    Google Scholar 

  23. Das, S., Magdon-Ismail, M.: Adapting to a market shock: optimal sequential market-making. Adv. Neural Inf. Process. Syst. 21 (2008)

    Google Scholar 

  24. Eskandari, S., Salehi, M., Gu, W.C., Clark, J.: SoK. In: Proceedings of the 3rd ACM Conference on Advances in Financial Technologies. ACM (2021)

    Google Scholar 

  25. Evans, A., Angeris, G., Chitra, T.: Optimal fees for geometric mean market makers (2021)

    Google Scholar 

  26. Frongillo, R., Papireddygari, M., Waggoner, B.: An axiomatic characterization of CFMMs and equivalence to prediction markets. arXiv preprint arXiv:2302.00196 (2023)

  27. Glosten, L.R., Milgrom, P.R.: Bid, ask and transaction prices in a specialist market with heterogeneously informed traders. J. Financ. Econ. 14(1), 71–100 (1985)

    Article  MATH  Google Scholar 

  28. Goyal, M., Ramseyer, G., Goel, A., Mazières, D.: Optimal design of constant function market makers, finding the right curve (2023)

    Google Scholar 

  29. Grossman, S.J., Miller, M.H.: Liquidity and market structure. J. Financ. 43(3), 617–633 (1988)

    Google Scholar 

  30. Heimbach, L., Schertenleib, E., Wattenhofer, R.: Risks and returns of Uniswap v3 liquidity providers. In: Proceedings of the 4th ACM Conference on Advances in Financial Technologies. ACM (2022)

    Google Scholar 

  31. Ho, T.S.Y., Stoll, H.R.: The dynamics of dealer markets under competition. J. Financ. 38(4), 1053–1074 (1983)

    Google Scholar 

  32. Kalodner, H., Goldfeder, S., Chen, X., Weinberg, S.M., Felten, E.W. Arbitrum: scalable, private smart contracts. In: 27th USENIX Security Symposium (USENIX Security 18), pp. 1353–1370, Baltimore, MD, August 2018. USENIX Association (2018)

    Google Scholar 

  33. Kyle, A.S.: Continuous auctions and insider trading. Econometrica 53(6), 1315–1335 (1985)

    Article  MATH  Google Scholar 

  34. McMenamin, C., Daza, V., Mazorra, B.: Diamonds are forever, loss-versus-rebalancing is not (2022)

    Google Scholar 

  35. Milionis, J., Moallemi, C.C., Roughgarden, T.: Automated market making and arbitrage profits in the presence of fees (2023)

    Google Scholar 

  36. Milionis, J., Moallemi, C.C., Roughgarden, T.: A Myersonian framework for optimal liquidity provision in automated market makers (2023)

    Google Scholar 

  37. Milionis, J., Moallemi, C.C., Roughgarden, T., Zhang, A.L.: Automated market making and loss-versus-rebalancing (2022)

    Google Scholar 

  38. Mohan, V.: Automated market makers and decentralized exchanges: a DeFi primer (2020)

    Google Scholar 

  39. Nadkarni, V., Jiachen, H., Rana, R., Jin, C., Kulkarni, S., Viswanath, P.: Data-driven optimal market making in DeFi, Zeroswap (2023)

    Google Scholar 

  40. Ramseyer, G., Goyal, M., Goel, A., Mazières, D.: Augmenting batch exchanges with constant function market makers (2023)

    Google Scholar 

  41. Tangri, R., Yatsyshin, P., Duijnstee, E.A., Mandic, D.: Generalizing impermanent loss on decentralized exchanges with constant function market makers (2023)

    Google Scholar 

  42. Watkins, C.J.H.C., Dayan, P.: Q-learning. Mach. Learn. 8, 279–292 (1992)

    Article  MATH  Google Scholar 

  43. Xu, J., Paruch, K., Cousaert, S., Feng, Y.: SoK: decentralized exchanges (DEX) with automated market maker (AMM) protocols. ACM Comput. Surv. 55(11) (2023)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Viraj Nadkarni .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2025 International Financial Cryptography Association

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Nadkarni, V., Hu, J., Rana, R., Jin, C., Kulkarni, S., Viswanath, P. (2025). ZeroSwap: Data-Driven Optimal Market Making in Decentralized Finance. In: Clark, J., Shi, E. (eds) Financial Cryptography and Data Security. FC 2024. Lecture Notes in Computer Science, vol 14744. Springer, Cham. https://doi.org/10.1007/978-3-031-78676-1_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-78676-1_12

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-78675-4

  • Online ISBN: 978-3-031-78676-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics