The Conceptual flaws of Constant Product Automated Market makers
 

by Andreas Park


 

Tokenomics 2021

 

Automated Market Making?

How should one organize DEX trading?

How do you set the price?

  1. Use an oracle
  2. Use a hard-coded function

What features do we need a hard-coded pricing rule to have?

  • NB: Oracles can be manipulated (e.g. $130M CreamFinance exploit)
  1. Liquidity demanders cannot get exploited/get a reasonable indication of the price they trade at
     
  2. Liquidity providers get "fair" risk compensation
     
  3. Blockchain: There is no excessive amount of trading

Current Practice: constant product pricing

Price mechanism:

  • \(X=\) contract balance of asset \(A\)
  • \(Y=\) contract balance of asset \(B\)
  • \(k=\) invariance factor
  • key relation \(k=X\times\ Y\)

Prices

  • sell \(x\le X\) \(\to\) receive amount \(y\)
    that maintains invariance. 
  • implied fundamental value \(V=Y/ X\)
  • maintain constant product post trade: \[k=(X+x)(Y-y)~ \Leftrightarrow~y=\frac{xY}{X+x}.\]

Economist's view:

  • it's ad hoc
  • \(\to\) fundamental questions:
    • exploits of liquidity demanders?
    • adequate risk compensation for liquidity providers?

Exploits of Liquidity Demanders

Problem: MEMPOOL Frontrunning is intrinsically profitable

\(X\)

\(Y\)

normal trade: sell \(x\) \(\to\) get \(y'\)

\(Y-y'\)

\(X+x\)

front-running/sandwich trade:

  1. front-runner: sells \(x\) \(\to\) gets \(y'\)
  2. front-run: sells \(x\) \(\to\) gets \(y''\)
  3. front-runner: buys \(x\) \(\to\) pays \(y''\) 

\(Y-y'-y''\)

\(X+2x\)

\(y'>y''~\Rightarrow\)

front-running is intrinsically profitable

Disclaimer:

  • this problem is well-known
  • fees can mitigate it
  • several protocols such as the latest iteration by Balancer try to combat it

Mempool \(\Rightarrow\) Front-Running!

a

b

c

d

e

f

g

Dark side of DEx trading: Miner extractable value

Source: flashbots.net

Risk Compensation for Liquidity Providers

Market Making with risk compensation: Biais JF 1993

  • Asset with true value \(v\sim N(V,\sigma^2)\)
  • Investor with exogenous demand \(Q\)
  • market makers w. CARA utility
    • maximize utility of terminal wealth
      • cash flow from trade
      • \(+\) value of risky position  
      • \(+\) value of inventory

hard coded pricing function

Two pricing approaches in the economics literature

  • uniform: cash flow = \(p(x)\times x\)
  • discriminatory: cash flow= \(\int_0^x p(t)dt\)

inputs

  • risk & risk aversion
  • position
  • inventory

Does constant product compensate fairly?

  • For apple-apple comparison:
    • \(I=0\) (everyone is at the "desired" risk amount)
    • \(X=N\) (each of \(N\) market markets contributes a unit amount)
    • \(V=Y/X\) (marginal CP price is the expected fundamental value)
  • Price functions coincide for \[x'=0~~~\text{ and }~~~ x^*:=\frac{X}{l}\ (l-2V).\]

Proposition: For \(x>x^*\), constant product provides "higher" risk compensation than what market competition would yield,  for \(x<x^*\) it is the reverse.

Excessive Trading?

Simple question: does it pay to split an order?

  • buy \(2\cdot x\):
    • Option 1: buy \(x+x\) 
    • Option 2: buy \(2x\) in one go
       
  • good news: constant product is invariant

(the papers has some other tests for excessive trading)

Comparison: market vs CPMM

Comparison of pricing

Constant product pricing
 

"Standard" economic model-based pricing

uniform

discriminatory

profitable front-running/sandwich trades

fair risk compensation for LPs

profitable order splitting (excessive trades)

Remedies?

A simple "solution" to front-running

  • Front-running requires two trades
    1. pay transactions fees twice
    2. first fee must exceed original fee
    3. second fee can't be too much lower than original fee
       
  • Front-runner needs to out-bid the original trade

no front-running if:
front-running profit < 2\(\times\) submitted fee

Small hiccup: front-runner often is the miner

\frac{2x^2Y}{(X-x)(X-2x)}<2\times f

What does the data say?

A simple calibration exercise

What does the data say?

  • Data:
    • Goal: flavor/established stylized facts/indication of the real costs
    • Jan 2020 for USDT-USDC, USDT-ETH, USDT-wBTC
  • What is \(\kappa\)?
    • Babcock, Choi, and Eli Feinerman (1993) (Table 1) \(\in(.00001,0.5)\)
    • most values at the small end of the spectrum\(\to\kappa= 0.0005\).
  • Rest?
    • Use crypto to stablecoin (aka "money")
    • \(V\): "average price"
    •  \(\sigma\): price volatility
    • \(X\): $-quantity of crypto in contract
  • And then?
    • Overpayment to LP in CPMM?
    • (Hypothetical) no-front-running fee?

A simple calibration exercise

What does the data say?

What have I done and what have you learned?

Summing up

  • Mempools \(\to\) front-running by transaction reordering is inevitable
    • \(\Rightarrow\) avoid intrinsically profitable design
  • A better way:
    • "linear" (marginal) pricing
    • \(\Rightarrow\) Merit of economic thinking in DeFi
  • Big picture:
    • Constant product has significant issues
    • designing an automated pricing function is hard

@financeUTM

andreas.park@rotman.utoronto.ca

slides.com/ap248

sites.google.com/site/parkandreas/

youtube.com/user/andreaspark2812/

Conceptual Flaws of Constant Product Market Makers Tokenomics 2021

By Andreas Park

Conceptual Flaws of Constant Product Market Makers Tokenomics 2021

  • 496