Video of my talk "A Theory of DeFi?" (as part of the ACM CCS Workshop on DeFi and Security): youtu.be/esekWF3SyB8 Summary in a thread:
1/30

Nov 28, 2021 · 11:08 PM UTC

6

97

15

459

It's debatable whether DeFi has matured enough to justify building a detailed theory around it. But suppose it has. What might such a theory look like, and how might it contribute to DeFi's future trajectory?
2/30

1

1

1

12

Difficult theorems (FLP impossibility of asynchronous consensus, the PCP theorem, etc.) get the most headlines. No difficult theorems yet in DeFi, and not clear if there will be any in the future.
3/30

1

12

But easy theorems (the type taught in intro courses, e.g. the max-flow/min-cut theorem) aren't merely a prerequisite for difficult ones. They tend to fundamentally shape our mental models of different fields. Interesting easy theorems are starting to pop up in DeFi.
4/30

1

10

And a pre-prerequisite for a rich theory is formal definitions (NP-completeness, partial synchrony, etc.) that clarify the objects of study and introduce the vocabulary in which theorems are phrased. In DeFi, good definitions are mostly lacking and urgently needed.
5/30

1

7

A theory of DeFi should aspire to analyzing (and perhaps justifying) existing solutions to central problems (e.g., through optimality or characterization results). It should also guide us to new (and hopefully better) solutions.
6/30

1

1

10

Optimization provides a tried-and-true strategy for building up a theory. The first step is to define the design space (e.g., in approximation algorithms, the space of polynomial-time algorithms). In DeFi, even this step remains wide open.
7/30

1

1

10

The second step is to propose one or more objective functions that we'd like to optimize over the design space. Never underestimate the focusing effect of a leaderboard for smart (and competitive) researchers!
8/30

1

12

The final step of the optimization approach is to identify (near-)optimal designs and fundamental trade-offs between competing objectives. I expect to see strong results along such lines over the next 1-2 years.
9/30

1

9

A theory of DeFi should develop bottom-up, from bite-sized pieces that allow formalization. Let's zoom in on the DEX (decentralized exchange) part of the DeFi space, and within DEXes on AMMs (automated market makers), and within AMMs on CFMMs (constant-function MMs).
10/30

1

1

9

AMMs predate blockchains, and were developed for prediction markets with low liquidity (@robinhanson's LMSR the most prominent example). Low liquidity can also plague DEXes (e.g., long-tail tokens), but the #1 reason to implement a DEX as an AMM is simplicity/low gas costs.
11/30

1

1

6

Two big ideas by @VitalikButerin Alan Lu @koeppelmann and others in 2016-7: (1) tech transfer of AMMs from PMs to DEXes; (2) the (completely new, AFAIK) x*y=k curve, the first example of a constant-function market maker (CFMM) and the basis of Uniswap.
12/30

2

1

10

In general, a CFMM with t tokens is defined by a trading invariant function f(q1,...,qt); qi's are the pool's current token quantities. A trade is allowed iff the change in quantities leaves f unchanged (ignoring fees for simplicity). (x*y=k corresponds to f(q1,q2)=q1*q2)
13/30

1

6

The spot price (of token type i, denominated in token type j) implied by a trading function f is the ratio of the partial derivatives df/dqi and df/dqj. (E.g., the x*y=k function implies a price of y/x for token A in terms of token B.)
14/30

2

6

Most DEXes are CFMMs and differ only in the choice of the trading function f. E.g., for two-token pools, Balancer (v1) corresponds to f(x,y)=(x**w)*(y**(1-w)) for a parameter w in [0,1], and Curve (v1) corresponds to a weighted average of f(x,y)=x+y and f(x,y)=xy.
15/30

1

7

Let's try to apply the 3-step optimization approach to the space of CFMMs (for two-token pools, say). What's the design space? Following @GuilleAngeris @tarunchitra @alexhevans, let's focus on trading functions f that have qualitatively similar geometry to the x*y=k curve.
16/30

1

11

Formally, for every k, the quantity pairs (x,y) satisfying f(x,y)>=k form a convex set (if two points lie in the set, so does the line segment between them). All the AMMs above satisfy this property, and for good reason (e.g., computational efficiency of optimal arbitrage).
17/30

1

7

For an alternative parameterization of the CFMM design space, define V_f(x,y,p,q) as the post-arbitrage USD value of a portfolio (x,y) deposited in a CFMM with trading function f when token prices (in USD) on the open market are p (for A) and q (for B).
18/30

1

8

Note that V_f(x,y,p,q) depends on the trading function f (in addition to the token quantities and market prices); different choices of f define different strategy spaces for arbitrageurs, and hence different post-arbitrage portfolio values.
19/30

1

7

Every f gives rise to a V_f that is nonnegative (obvious),
nondecreasing in (p,q) (obvious), 1-homogeneous in (p,q) (e.g., doubling prices doubles the value), and concave in (p,q) (related to the inevitability of LP divergence loss).
20/30

1

7

A very cool "easy theorem" of @GuilleAngeris @tarunchitra @alexhevans (see "Replicating Market Makers") states that every function V with these properties can in fact be represented as a portfolio value function V_f for some trading function f.
21/30

1

12

Multiple representations of objects is a signature of a good theory. The most useful representation will depend on what you're trying to accomplish. Working with CFMMs, you can now go back and forth between trading functions and portfolio value functions, as is convenient.
22/30

1

1

6

.@jason_of_cs and I have been exploring yet another representation of CFMMs, in terms of the implied spot price function. E.g., we think Curve (v1) is easiest to understand (and perhaps improve upon) from this perspective.
23/30

1

8

Can we apply this theory to formally justify existing CFMM designs (e.g., if Uniswap is the answer, what is the question?) or even guide us to new and better designs? These questions are almost entirely open.
24/30

2

10

One can characterize the x*y=k curve in terms of an "equal cash split" property. A calculation shows that whatever the current market prices, at equilibrium (post-arbitrage), the USD values of the two sides of such a pool are equal. Do any other CFMMs have this property?
25/30

3

1

10

In fact, one can show that the only trading functions with the equal cash split property have the form f(x,y)=g(x*y) for some invertible function g. Balancer pools can be similarly characterized as those with a "fixed cash split" property.
26/30

1

9

Tons of opportunities for further theoretical work in DeFi. What objective functions should we focus on? Are any of the popular CFMMs (Uniswap, Curve, etc.) optimal for some natural optimization problem, or can they be improved upon in a precise sense?
27/30

1

1

8

Perhaps the ultimate CFMM result would be a general compiler (in the spirit of Myerson's optimal auction theory) that takes as input a model of price movement and outputs a corresponding "optimal" CFMM with respect to that model.
28/30

1

2

1

13

Summary: we don't have a theory of DeFi just yet, but I'm very optimistic that we'll see a lot of interesting work over the next couple of years. Let me know if you make any progress!
29/30

3

22

Thanks to @jason_of_cs for ongoing collaborations, and @HatforceSec @Daeinar @dawnsongtweets and Roger Wattenhofer for the invitation!
30/30

2

19