constant function market makers - stanford universityguillean/talks/defi-2020.pdfautomated market...

32
Constant Function Market Makers Pushing Uniswap & friends to do more with lower fees Guillermo Angeris and Tarun Chitra May 2, 2020 1

Upload: others

Post on 18-Mar-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Constant Function Market MakersPushing Uniswap & friends to do more with lower fees

Guillermo Angeris and Tarun Chitra

May 2, 2020

1

Page 2: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Outline

History

Examples of CFMMs

The trading set

An analysis of CFMMs

Acknowledgements

History 2

Page 3: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Trading assets

◮ Often, we need a way of trading assets

◮ (Normally) easy: make an offer to buy or sell

◮ In the traditional setting, this led to order books

– Buyers post ‘bids’ of maximum price they are willing to buy for

– Sellers post ‘asks’ of minimum price they are willing to sell for

– Trades occur when a buyer is willing to pay more thanminimum ask price

History 3

Page 4: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Disadvantages

◮ A trusted party keeps a record of outstanding bids and asksLinear space requirement

◮ When the highest bidder bids more than the lowest asker [...]Price may update slowly, esp. with a small number of agents

◮ Exchanges usually add subsidies to ensure there is liquidity

History 4

Page 5: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Alternatives to the tyranny of the order book

◮ Question: can we replace human market makers withalgorithmic market makers?

◮ Yes! — Automated Market Makers (AMMs)

– Bounded loss: can give explicit bounds on the maximum loss

– Liquidity sensitivity: fixed-size trade moves prices less in thickmarkets

– Small storage requirement: accepting or rejecting tradedepends only on the current reserves

History 5

Page 6: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Automated Market Makers

Savage ’71, Hanson ’02

◮ Idea: use a (simple) formula to determine asset price

◮ Liquidity providers pool their assets (say A and B) intoreserves

◮ Price set too low: agents purchase reserves at current price

◮ Price set too high: agents sell to reserves at current price

◮ Using this idea, set price based on assets remaining in reserves

◮ e.g., if too much of asset A remains, compared to asset B ,decrease the price of A

History 6

Page 7: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Automated Market Makers

Savage ’71, Hanson ’02

◮ Idea: use a (simple) formula to determine asset price

◮ Liquidity providers pool their assets (say A and B) intoreserves

◮ Price set too low: agents purchase reserves at current price

◮ Price set too high: agents sell to reserves at current price

◮ Using this idea, set price based on assets remaining in reserves

◮ e.g., if too much of asset A remains, compared to asset B ,decrease the price of A

History 6

Page 8: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Automated Market Maker examples

◮ Simplest example: fixed asset price at all reserve amountsi.e., a flat line

◮ Another example: reported price is ratio of two asset reservesThis curve is Uniswap!

History 7

Page 9: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

A brief history of AMMs

◮ Savage ’71, Hanson ’02: Logarithmic Market Scoring Rulescan be used for AMMs in prediction markets

◮ Chen, Pennock ’07: axiomatic formulations exist for AMMsfor more markets

◮ Othman, Sandholm ’10: liquidity-sensitive AMMs exist thatdon’t have unbounded loss

◮ Othman, Sandholm ’11: constant utility AMMs for predictionmarkets

◮ Buterin, Koppelmann, ’16: extension of AMMs to constantproduct markets, applications in exchanges

History 8

Page 10: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Outline

History

Examples of CFMMs

The trading set

An analysis of CFMMs

Acknowledgements

Examples of CFMMs 9

Page 11: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Uniswap (and constant product markets)

◮ Constant product markets (e.g., Uniswap) is the family ofcurves whose reserves Rα,Rβ must always satisfy:

RαRβ = k ,

for some constant k (no fees), we will call this the tradingfunction

◮ In this case, we will assume that α and β are coins, thoughthey can be any asset

◮ To satisfy this equation, the marginal price of asset β withrespect to α is always

mu =Rβ

Examples of CFMMs 10

Page 12: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Uniswap market function

◮ If we plot the set of reserves that Uniswap can have, we get ahyperbola

0 1 2 30

1

2

3

Examples of CFMMs 11

Page 13: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Uniswap market function

◮ So, traders can exchange coin α and β with the reserves, solong as the resulting reserves remain on the curve

0 1 2 30

1

2

3

Examples of CFMMs 12

Page 14: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Analysis of market functions

◮ Uniswap is easy to analyze: trading function is simple

◮ What about more complicated cases? (e.g., Balancer, Curve,etc.)

◮ While we could work out derivatives for prices, how do LPreturns work? Are they good or bad for arbitrageurs?

◮ Additionally, many trading functions give the same trades!

Examples of CFMMs 13

Page 15: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Outline

History

Examples of CFMMs

The trading set

An analysis of CFMMs

Acknowledgements

The trading set 14

Page 16: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Filling in the graph

◮ Weird idea: what if we ‘fill in’ the graph?

◮ In other words, what if reserves above and to the right of thegraph were also possible?

The trading set 15

Page 17: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Uniswap trading set

◮ The new graph (or set) will look like

0 1 2 30

1

2

3

The trading set 16

Page 18: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Uniswap trading set

◮ Since we’ve only added points, all of the reserves that werefeasible before are still feasible

0 1 2 30

1

2

3

The trading set 17

Page 19: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Uniswap trading set

◮ But, no rational trader will ever pick a point inside of the set!

0 1 2 30

1

2

3

The trading set 18

Page 20: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Uniswap trading set

◮ We will call this set the trading set, T ⊆ R2+, for short

0 1 2 30

1

2

3

The trading set 19

Page 21: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

The trading set

◮ The trading set T is often easier to deal with than the actualtrading function and is the same for rational agents

◮ In particular, many trading functions yield the same set!

◮ Yet, the trading set is convex in practical scenarios (and allknown CFMMs)

◮ Convex =⇒ (a) easy to optimize and (b) easy to analyze

The trading set 20

Page 22: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Outline

History

Examples of CFMMs

The trading set

An analysis of CFMMs

Acknowledgements

An analysis of CFMMs 21

Page 23: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Constant function market makers

◮ Surprisingly, all CFMMs of this form have the same properties

◮ Marginal prices are simple to compute

◮ It is immediate that arbitrage is (computationally) easy,implying that prices match external ones

◮ Can compute liquidity provider returns, often in closed form

◮ All of this follows from basic convex analysis!

An analysis of CFMMs 22

Page 24: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Marginal price

◮ Marginal price of a CFMM at given reserves is proportional tothe supporting hyperplane of the set T at these reserves

0 1 2 30

1

2

3

An analysis of CFMMs 23

Page 25: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Liquidity provider portfolio value

◮ The liquidity provider portfolio value is exactly given by

infr∈T

pT r ,

where p is the vector of prices with pi ≥ 0 the price of coin i

◮ This is the negative of the support function of the set T

◮ Almost always easy to evaluate for convex sets T

◮ First way of analytically computing liquidity provider returnsof complicated CFMMs (e.g., Balancer with n coins)

An analysis of CFMMs 24

Page 26: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Why convexity?

◮ Sure, it’s easy, but why?

0 1 2 30

1

2

3

An analysis of CFMMs 25

Page 27: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Why convexity?

◮ Note that arbitrageurs won’t care! Marginal price is the same

0 1 2 30

1

2

3

An analysis of CFMMs 26

Page 28: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Why convexity?

◮ So we might as well fill it in

0 1 2 30

1

2

3

An analysis of CFMMs 27

Page 29: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Extensions and questions

◮ We can extend this to include fees (path deficiency), but isgenerally more complicated since T changes after each trade

◮ Of course, all of this holds for n coins, not just two

◮ Questions still remain... manipulation price? Lower bounds?

An analysis of CFMMs 28

Page 30: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

CFMM properties (summary)

◮ Main idea: recast all numerical properties of CFMMs asgeometric properties of convex sets

◮ Can use this to talk about marginal prices, the arbitrageproblem, liquidity provider returns, etc

◮ Second implication: it is possible to optimize over the set ofCFMMs!

◮ We can make specific CFMMs for specific applications,including fees, curve shapes, etc.

◮ And many more possibilities

An analysis of CFMMs 29

Page 31: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Outline

History

Examples of CFMMs

The trading set

An analysis of CFMMs

Acknowledgements

Acknowledgements 30

Page 32: Constant Function Market Makers - Stanford Universityguillean/talks/defi-2020.pdfAutomated Market Makers Savage ’71, Hanson ’02 Idea: use a (simple) formula to determine asset

Acknowledgements

◮ Tim Roughgarden (Columbia)

◮ John Morrow (Gauntlet)

◮ Shane Barratt (Stanford)

Acknowledgements 31