Discussion of
Decentralized Exchanges

Paper by Alfred Lehar & Christine Parlour
Discussion by
Andreas Park


 

SAFE Microstructure August 2021
 

How should one organize DEX trading?

  • "DeFi refers to a fast-growing and highly opaque corner of the cryptocurrency market which allows users to engage in a variety of financial activities – including lending, borrowing, and trading derivatives to take on leverage – without an intermediary like a bank.
     
  • Given that participants and project developers may remain anonymous, DeFi could present particularly severe financial stability risks.
     
  • According to a 2019 Financial Stability Board report, decentralized financial technologies may raise new forms of concentration risks, unclear allocation of liability, and recovery and resolution challenges."

Source: Letter to Janet Yellen, Chair of the Financial Stability Oversight Council (FSOC) https://www.warren.senate.gov/imo/media/doc/FSOC%20Crypto%20Letter%2007.26.2021.pdf 

What is decentralized Finance and why should you care

“[…] the need for a coordinated and cohesive regulatory strategy to mitigate the growing risks that cryptocurrencies pose to the financial system”

How should one organize DEX trading?

How do you set the price?

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

the constant product pricing function

automated market maker

Price mechanism:

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

Prices

  • when you want to sell \(x\le X\) you receive \(y\) that maintains invariance. 
  • implied exchange rate: \(e=\frac{x}{y}\)
  • maintain constant product post trade: \[k=(X+x)(Y-y)~ \Leftrightarrow~y=\frac{xY}{X+x}.\]

Economist's view:

  • ad hoc price rule
  • \(\to\) fundamental question: is this adequate/fair risk compensation for liquidity providers?
  • this paper:
    1. under what conditions will LPs participate
    2. how does this compare to a limit order book
    3. what stylized facts on willingness to provide liquidity can we see in the data

Dark side of DEx trading: Miner extractable value

Theoretical Framework

  • asset that may see a value change
     
  • liquidity providers (two?)
     
  • liquidity trader: trades fixed quantity for reasons outside the model
     
  • arbitrageur who takes advantage when
    • the value changes (picks off wrongly priced liquidity)
    • reverse price dislocations caused by liquidity traders

Theoretical Framework: Limit order book

  • post discriminatory schedule
     
  • benefit from liquidity traders
     
  • lose against informed arbitrageur
     
  • my understanding:
    • competition \(\to\) to have zero profits
    • there may or may not be competition
      (depends on monitoring)

Theoretical Framework: Constant product pricing

  • pricing rule fixed but level of liquidity provision is a choice
     
  • What happens when?
    • Liquidity trade: will get reversed, LP gains 2 \(\times\) fee
    • Informed trade: LP loses from being picked off
       
  • If information: Arbitrageur picks quantity that maximizes profits
     
  • LP problem: balance picking off loss with fee gain
     
  • (as I understand proof: pick level of liquidity such that expected fee gain = expected picking off loss \(\to\) zero profit condition?
     
  • NB: LPs do not directly compete with one another but more liquidity means flatter price curve 

Theoretical Framework: comparison

  • LPs in both cases earn zero profits in expectation
     
  • Arbitrageur's gain comes at the expense of liquidity trader
     
  • \(\to\) How much does the liquidity trader pay for fixed quantity?
    • can be expressed in closed form 
    • clear cut result cannot be obtained but indicative statements based on monitoring costs (high costs \(\to\) AMM better)

Theoretical Framework: some suggestions

  •  cost of market monitoring ("find a profitable market"):  should this be flow cost?
     
  • AMM has trade reversal by arbitrageur after liquditiy trade - why not the LOB?
     
  • (Simpler) comparison result when LOB is guaranteed perfectly competitive?
     
  • Volatility of the price impact: it is testable but isn't the result by design?
     
  • How robust is the constant product pricing liquidity provision choice (in terms of adequate risk compensation)?

EMpirics

  • very nice data collection for UniSwap
    • clear separations of "normal" trades (~80%) and complex trades
      • Not all token pairs are traded directly by one can trade across pairs
      • segment out "attack" trades (exploiting a protocol's vulnerability)
  • Very nice description of UniSwap liquidity pool structure and stylized facts

EMpirics: most important result IMO

  • looks like trading costs on UniSwap are substantially lower
  • more analytics would be good
    • effective spreads Binance vs \(\Delta\) price UniSwap
    • (Tricky: results are for liquidity traders, but empirics measure all)

between .5 and 1 bps

Summary

  • Formal comparison between constant product pricing and limit order book
  • Nice:
    • endogenous liquidity provision choice in UniSwap
    • comparison in trading costs
  • Maybe strengthen the link between the data analytics and theory. For instance, 
    • If UniSwap is cheaper to trader does this mean that informed traders pick limit order book?
    • \(\to\) price discovery should occur on Binance

@financeUTM

andreas.park@rotman.utoronto.ca

slides.com/ap248

sites.google.com/site/parkandreas/

youtube.com/user/andreaspark2812/

Mempool \(\Rightarrow\) Front-Running!

So what's the Problem?

a

b

c

d

e

f

g

However: although front-running is annoying, it is only a concern if it is intrinsically profitable.

My paper:

  • current pricing mechanisms in swap DEXes fundamentally allow arbitrage
  • pricing based on a canonical microstructure model does not
  • \(\to\) there is a way shut down MEV at the source

Problem: MEMPOOL Frontrunning is intrinsically profitable

\(X\)

\(Y\)

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

\(Y-y'\)

\(X+x\)

front-running:

  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

Problem: MEMPOOL Frontrunning is intrinsically profitable

\(X\)

\(Y\)

\(Y-y'\)

\(X+x\)

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

\(X+2x\)

\(y'=y''~\Rightarrow\)

front-running is not intrinsically profitable

What would be desirable?

Hard-Coded Market Making

  1. Time consistent: cannot profitably split orders over time.
     
  2. Front-running is not intrinsically profitable. 
     
  3. Liquidity splitting invariance
     
  4. No Multi-venue arbitrage/ping-pong trading

   

CPAMM

canonical

A simple calibration exercise

What does the data say?

What you will learn if you read my work

  • With mempools, front-running is always a possibility
    • \(\Rightarrow\) must avoid design that makes it intrinsically profitable
    • \(\Rightarrow\) most swap exchanges make it so! (fees are only a band-aid)
  • There is also
    • ping-pong trading
    • rule is ad hoc and nothing says that it has any relationship to demand and supply
  • Empirically, mempool arbitrage and gas auctions push up gas costs to astronomical levels.
  • There is a better way:
    • correctly designed "linear" (marginal) pricing makes front-running and ping-pong trading unprofitable 
    • \(\Rightarrow\) there is merit to traditional economic thinking even in DeFi \(\ldots\)

Discussion of Lehar & Parlour SAFE 2021

By Andreas Park

Discussion of Lehar & Parlour SAFE 2021

  • 501