Tarun Chitra Profile picture
ヽ(⌐■_■)ノ♪♬ @gauntlet_xyz/@robotventures/@aerafinance/@thelatestindefi/@_choppingblock/@zeroknowledgefm // main: @guilleangeris

Jul 22, 2021, 13 tweets

⚠️ It’s 📰💧 time of the month again 🚨

Don’t want to read 100s of pages of CFMM literature? 

You’re in luck! We review the known theory of CFMMs (plus some new goodies!) for an upcoming *textbook* chapter on crypto + DeFi w/ two new authors:

(Paper: stanford.edu/~guillean/pape…)

First: Who are they?

Stephen Boyd is a renowned @Stanford researcher known for his oft cited textbook, multitude of INFORMS/IEEE awards, and advising BlackRock on convex analysis for manage trillions of dollars

He’s also @guilleangeris’s PhD advisor!

en.wikipedia.org/wiki/Stephen_P…

. @akshaykagarwal just defended his PhD under Boyd and is known for his work on visualizations of embeddings via his open-source package PyMDE (minimal distortion embedding)

He’s also a core developer of cvxpy (quant traders ♥️ him) and previously worked on TensorFlow 2

Unlike our other papers, which assume knowledge of crypto, DeFi, + convex analysis, this book chapter is pedagogical + from first principles 

Goal: Quant-y undergrads who know Multivariable Calc and Linear Algebra (with proofs, like Lang) *should* be able to pick up CFMM theory

We also show a few new nifty features of CFMMs

1/ Simplified proofs

a. Round-trip trades always lose (path deficiency)
b. Liquidity Provider (LP) share value ∝ ∇ϕ(R)’R [= ϕ(R) for 1-homogeneous functions; surprisingly simple!]
c. Input + output portfolios disjoint

2/ Explicit formulas for add/remove liquidity

Previous papers assumed reserves were constant

We provide a connection between the trading function gradient and the change to liquidity ▶️ helps improve concentrated liquidity formulas (e.g. @Uniswap V3)

e.g. result below:

3/ Exchange Functions

Our curvature paper only showed properties of liquidity (e.g. curvature at fixed reserve) are too state dependent

We elucidate some properties of changes to liquidity via _exchange functions_ which turn out to be concave/convex (*w/o* metric properties)

Their metric properties, which do depend on a particular parametrization and reserve, are shown to be easily computed numerically

This, again, is very useful for measuring impact to concentrated liquidity (e.g. you can extend by linearity exchange functions to piecewise convex)

Finally, exchange functions generalize the invariant calculation done by @CurveFinance to general CFMM curves

There's a simple Newton iteration (gradient descent) for computing trade size from exch. functions

[Remember when @samczsun found a bug in curve's Newton iteration?]

4/ Expected Utility Portfolio

We provide some LP strategies for different utility functions

If we view an LP’s contribution to a CFMM pool as a portfolio allocation, we explicitly find both linear and Markowitz convex programs for how to optimize LP allocation

These are *easily* solved on a laptop and we numerically show how LP allocations change as a function of risk-aversion (cvxpy code included!)

This should hopefully lead to more principled LP allocation (e.g. useful for @CharmFinance, @mellowprotocol, @sommfinance)

We hope that a clean presentation of these results can make the field more assessable to folks in theoretical CS, ML, statistics, and other quantitative fields

But what’s next? You’ll have to wait until next month ✌🏾

Paper: stanford.edu/~guillean/pape…

Oops wrong tag: I meant @akshaykagrawal 🙈🙈🙈

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling