Discussion of
Decentralized Exchanges

Paper by Alfred Lehar & Christine Parlour
Discussion by
Andreas Park


 

AFA 2022
 

By now everyone knows what Bitcoin is ...

What is Decentralized Finance?

decentralized finance =
provision of financial services without the necessary involvement of a traditional financial intermediary at extremely low costs

key ingredient =
blockchain technology =

a common infrastructure for decentralized code execution

  • for UniSwap, $0 go to anyone!
  • fees = transfers between LP and LD

How should one organize DEX trading?

How do you set the price?

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\) zero profits to LP
    • 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
     
  • 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)

Small observation

  • It's expensive to adjust the "midprice" in UniSwap for LPs (must withdraw or add liquidity)
  • As per authors: this happens rarely.
  • Yet prices track LOB prices remarkably well!
  • Although somewhat static, some dynamics must hold!

Source: Peter O'Neill "Can Markets be Fully Automated? Evidence From an ‘Automated Market Maker", Nov 2021

We can see that price impact on Binance almost always exceeds that on Uniswap.

Theoretical Framework: some suggestions

  • Being monopolist LP comes at a cost. Maybe relate to arm's race?
     
  • AMM has trade reversal by arbitrageur after liquditiy trade - why not the LOB?
     
  • (Simpler) comparison result when LOB is guaranteed perfectly competitive?
     
  • How robust is the constant product pricing liquidity provision choice (in terms of adequate risk compensation)?
    (Below: interesting empirical fact)

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
  • Regression \(\to\) price impact on Binance almost always exceeds that on Uniswap.

"We find that as Uniswap liquidity provision becomes larger, the Uniswap price undertakes a larger weight in determining the equilibrium cryptocurrency valuation than the Binance price." Trust in DeFi: An Empirical Study of the Decentralized Exchange by Jianlei Han, Shiyang Huang, and Zhuo Zhong

between .5 and 1 bps

Small suggestions: maybe compure implicit spread measure for AMM for comparison

Summary

  • Formal comparison between constant product pricing and limit order book
  • Nice:
    • endogenous liquidity provision choice in UniSwap
    • comparison in trading costs
  • Still some room to strengthen the link between the data analytics and theory. 

@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 DEX Lehar & Parlour AFA 2022

By Andreas Park

Discussion of DEX Lehar & Parlour AFA 2022

  • 605