Skip to main content

Constant Function Market Makers: Multi-asset Trades via Convex Optimization

  • Chapter
  • First Online:
Handbook on Blockchain

Part of the book series: Springer Optimization and Its Applications ((SOIA,volume 194))

Abstract

The rise of Ethereum and other blockchains that support smart contracts has led to the creation of decentralized exchanges (DEXs), such as Uniswap, Balancer, Curve, mStable, and SushiSwap, which enable agents to trade cryptocurrencies without trusting a centralized authority. While traditional exchanges use order books to match and execute trades, DEXs are typically organized as constant function market makers (CFMMs). CFMMs accept and reject proposed trades based on the evaluation of a function that depends on the proposed trade and the current reserves of the DEX. For trades that involve only two assets, CFMMs are easy to understand, via two functions that give the quantity of one asset that must be tendered to receive a given quantity of the other, and vice versa. When more than two assets are being exchanged, it is harder to understand the landscape of possible trades. We observe that various problems of choosing a multi-asset trade can be formulated as convex optimization problems and can therefore be reliably and efficiently solved.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 149.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 199.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 199.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Aave. https://aave.com, 2021

    Google Scholar 

  2. Akshay Agrawal, Stephen Boyd, Deepak Narayanan, Fiodar Kazhamiaka, and Matei Zaharia. Allocation of fungible resources via a fast, scalable price discovery method. arXiv preprintarXiv:2104.00282, 2021

  3. Guillermo Angeris and Tarun Chitra. Improved price oracles: Constant function market makers. In Proceedings of the 2nd ACM Conference on Advances in Financial Technologies, pages 80–91, New York NY USA, October 2020. ACM

    Google Scholar 

  4. Guillermo Angeris, Alex Evans, and Tarun Chitra. When does the tail wag the dog? Curvature and market making. arXiv preprint arXiv:2012.08040, 2020

  5. Guillermo Angeris, Alex Evans, and Tarun Chitra. A note on privacy in constant function market makers. arXiv preprint arXiv:2103.01193, 2021

  6. Guillermo Angeris, Alex Evans, and Tarun Chitra. Replicating market makers. arXiv preprint arXiv:2103.14769, 2021

  7. Jun Aoyagi and Yuki Ito. Liquidity implications of constant product market makers. Available at SSRN 3808755, 2021

    Google Scholar 

  8. Guillermo Angeris, Hsien-Tang Kao, Rei Chiang, Charlie Noyes, and Tarun Chitra. An analysis of Uniswap markets. Cryptoeconomic Systems, November 2020

    Google Scholar 

  9. Jun Aoyagi. Liquidity provision by automated market makers. Available at SSRN 3674178, 2020

    Google Scholar 

  10. MOSEK ApS. MOSEK Optimizer API for Python 9.1.5. https://docs.mosek.com/9.1/pythonapi/index.html, 2019

    Google Scholar 

  11. Angeris, G., Vučković, J., Boyd, S.: Heuristic methods and performance bounds for photonic design. Optics Express 29(2), 2827 (2021)

    Article  Google Scholar 

  12. Agrawal, A., Verschueren, R., Diamond, S., Boyd, S.: A rewriting system for convex optimization problems. Journal of Control and Decision 5(1), 42–60 (2018)

    Article  MathSciNet  Google Scholar 

  13. Hayden Adams, Noah Zinsmeister, Moody Salem, River Keefer, and Dan Robinson. Uniswap v3 core. Technical report, 2021

    Google Scholar 

  14. Boyd, S., Busseti, E., Diamond, S., Kahn, R., Koh, K., Nystrup, P., Speth, J.: Multi-period trading via convex optimization. Foundations and Trends in Optimization 3(1), 1–76 (2017)

    Article  Google Scholar 

  15. Stephen Boyd, Seung-Jean Kim, Dinesh Patil, and Mark Horowitz. Digital circuit optimization via geometric programming. Operations Research, 53(6), 2005

    Google Scholar 

  16. Lars Blackmore. Autonomous precision landing of space rockets. The BRIDGE, 26(4), 2016

    Google Scholar 

  17. Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein. Distributed optimization and statistical learning via the alternating direction method of multipliers. Foundations and Trends® in Machine learning, 3(1):1–122, 2011

    Google Scholar 

  18. Goran Banjac, Bartolomeo Stellato, Nicholas Moehle, Paul Goulart, Alberto Bemporad, and Stephen Boyd. Embedded code generation using the OSQP solver. In IEEE Conference on Decision and Control, 2017

    Google Scholar 

  19. Vitalik Buterin. Ethereum: A next-generation smart contract and decentralized application platform, 2013

    Google Scholar 

  20. Vitalik Buterin. On path independence (2017). https://vitalik.ca/general/2017/06/22/marketmakers.html

  21. Boyd, S., Vandenberghe, L.: Convex Optimization. Cambridge University Press, Cambridge, UK; New York (2004)

    Book  MATH  Google Scholar 

  22. Tarun Chitra, Guillermo Angeris, Alex Evans, and Hsien-Tang Kao. A note on borrowing constant function market maker shares. 2021

    Google Scholar 

  23. Yiling Chen, Lance Fortnow, Nicolas Lambert, David Pennock, and Jennifer Wortman. Complexity of combinatorial market makers. In Proceedings of the 9th ACM Conference on Electronic Commerce, pages 190–199, 2008

    Google Scholar 

  24. Compound. https://compound.finance, 2021

    Google Scholar 

  25. Eric Chu, Neal Parikh, Alexander Domahidi, and Stephen Boyd. Code generation for embedded second-order cone programming. In European Control Conference, pages 1547–1552. IEEE, 2013

    Google Scholar 

  26. Gerard Cornuejols and Reha Tütüncü. Optimization Methods in Finance. Cambridge University Press, 2006

    Google Scholar 

  27. Diamond, S., Boyd, S.: CVXPY: A Python-embedded modeling language for convex optimization. Journal of Machine Learning Research 17(83), 1–5 (2016)

    MathSciNet  MATH  Google Scholar 

  28. Alexander Domahidi, Eric Chu, and Stephen Boyd. ECOS: An SOCP solver for embedded systems. In 2013 European Control Conference (ECC), pages 3071–3076, Zurich, July 2013. IEEE

    Google Scholar 

  29. Dunning, I., Huchette, J., Lubin, M.: JuMP: A modeling language for mathematical optimization. SIAM review 59(2), 295–320 (2017)

    Article  MathSciNet  MATH  Google Scholar 

  30. dydx. https://dydx.exchange, 2021

    Google Scholar 

  31. Alex Evans, Guillermo Angeris, and Tarun Chitra. Optimal fees for geometric mean market makers. arXiv preprint arXiv:2104.00446, 2021

  32. Michael Egorov. StableSwap - efficient mechanism for Stablecoin liquidity. page 6, 2019

    Google Scholar 

  33. Alex Evans. Liquidity provider returns in geometric mean markets. arXiv preprint arXiv:2006.08806, 2020

  34. Jerome Friedman, Trevor Hastie, and Robert Tibshirani. The Elements of Statistical Learning, volume 1. Springer Series in Statistics, 2001

    Google Scholar 

  35. Michael Garstka, Mark Cannon, and Paul Goulart. COSMO: A conic operator splitting method for large convex problems. In 2019 18th European Control Conference (ECC), pages 1951–1956, Naples, Italy, June 2019. IEEE

    Google Scholar 

  36. Hanson, R.: Combinatorial information market design. Information Systems Frontiers 5(1), 107–119 (2003)

    Article  MathSciNet  Google Scholar 

  37. Hershenson, M., Boyd, S., Lee, T.: Optimal design of a CMOS op-amp via geometric programming. IEEE Transactions on Computer-aided design of integrated circuits and systems 20(1), 1–21 (2001)

    Article  Google Scholar 

  38. Lipp, T., Boyd, S.: Minimum-time speed optimisation over a fixed path. International Journal of Control 87(6), 1297–1311 (2014)

    Article  MathSciNet  MATH  Google Scholar 

  39. Alan Lu. Building a decentralized exchange in Ethereum. https://blog.gnosis.pm/building-a-decentralized-exchange-in-ethereum-eea4e7452d6e, 2017

    Google Scholar 

  40. Markowitz, H.: Portfolio selection. The. Journal of Finance 7(1), 77–91 (1952)

    Google Scholar 

  41. Mattingley, J., Boyd, S.: CVXGEN: A code generator for embedded convex optimization. Optimization and Engineering 13(1), 1–27 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  42. Nicholas Moehle, Enzo Busseti, Stephen Boyd, and Matt Wytock. Dynamic energy management. arXiv preprint arXiv:1903.06230, 2019

  43. Fernando Martinelli and Nikolai Mushegian. Balancer: A non-custodial portfolio manager, liquidity provider, and price sensor. 2019

    Google Scholar 

  44. Satoshi Nakamoto. Bitcoin: A peer-to-peer electronic cash system, 2008

    Google Scholar 

  45. O’Donoghue, B., Chu, E., Parikh, N., Boyd, S.: Conic optimization via operator splitting and homogeneous self-dual embedding. Journal of Optimization Theory and Applications 169(3), 1042–1068 (2016)

    Article  MathSciNet  MATH  Google Scholar 

  46. Press, W., Teukolsky, S., Flannery, B.: and William Vetterling. The Art of Scientific Computing. Cambridge University Press, Numerical Recipes (1992)

    Google Scholar 

  47. Ernest Ryu and Stephen Boyd. A primer on monotone operator methods. Applied Computational Math, 2016

    Google Scholar 

  48. Gregory Stewart and Francesco Borrelli. A predictive control framework for industrial turbodiesel engine control. In IEEE Conference on Decision and Control (CDC), pages 5704–5711, 2008

    Google Scholar 

  49. Bartolomeo Stellato, Goran Banjac, Paul Goulart, Alberto Bemporad, and Stephen Boyd. OSQP: An operator splitting solver for quadratic programs. Mathematical Programming Computation, February 2020

    Google Scholar 

  50. Sushi. The SushiSwap project, 2020

    Google Scholar 

  51. Nick Szabo. Smart contracts. Extropy: Journal of Transhumanist Thought, 16, 1995

    Google Scholar 

  52. Martin Tassy and David White. Growth rate of a liquidity provider’s wealth in \(xy= c\) automated market makers, 2020

    Google Scholar 

  53. UMA project. https://umaproject.org, 2021

    Google Scholar 

  54. Wang, Y., Boyd, S.: Fast evaluation of quadratic control-Lyapunov policy. IEEE Transactions on Control Systems Technology 19(4), 939–946 (2010)

    Article  Google Scholar 

  55. Ye Wang, Yan Chen, Shuiguang Deng, and Roger Wattenhofer. Cyclic arbitrage in decentralized exchange markets. Available at SSRN 3834535, 2021

    Google Scholar 

  56. Winkler, R.: Scoring rules and the evaluation of probability assessors. Journal of the American Statistical Association 64(327), 1073–1078 (1969)

    Article  Google Scholar 

  57. Gavin Wood. Ethereum: A secure decentralised generalised transaction ledger, 2014

    Google Scholar 

  58. Gavin Wood. Polkadot: Vision for a heterogeneous multi-chain framework, 2016

    Google Scholar 

  59. Anatoly Yakovenko. Solana: A new architecture for a high performance blockchain, 2018

    Google Scholar 

  60. Yi Zhang, Xiaohong Chen, and Daejun Park. Formal specification of constant product (\(xy=k\)) market maker model and implementation. 2018

    Google Scholar 

Download references

Acknowledgements

The authors would like to acknowledge Shane Barratt for useful discussions. Guillermo Angeris is supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-1656518. Akshay Agrawal is supported by a Stanford Graduate Fellowship.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Guillermo Angeris .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2022 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Angeris, G., Agrawal, A., Evans, A., Chitra, T., Boyd, S. (2022). Constant Function Market Makers: Multi-asset Trades via Convex Optimization. In: Tran, D.A., Thai, M.T., Krishnamachari, B. (eds) Handbook on Blockchain. Springer Optimization and Its Applications, vol 194. Springer, Cham. https://doi.org/10.1007/978-3-031-07535-3_13

Download citation

Publish with us

Policies and ethics