Andreas Park
Conceptually, what is a blockchain?
payments
stocks, bonds, and options
swaps, CDS, MBS, CDOs
insurance contracts
payments
stocks, bonds, and options
swaps, CDS, MBS, CDOs
insurance contracts
{
{
features
consequences
Consensus: Proof-of-Stake
Blockchain organization
Slot 1
Slot 2
Slot 32
...
12 seconds
epoch\(_t\)
epoch\(_{t+1}\)
epoch\(_{t-1}\)
Block inclusion
Committee #1 of validators
Slot 1
Slot 2
Slot 32
...
proposer #1 assembles transactions in block and proposes to a committee
attests validity
Block inclusion
Committee #2 of validators
Slot 1
Slot 2
Slot 32
...
proposer #2 assembles transactions in block and proposes to a committee
attests validity
Block inclusion
Committee #32 of validators
Slot 1
Slot 2
Slot 32
...
proposer #32 assembles transactions in block and proposes to a committee
attests validity
Blockchain finality rules
Slot 1
Slot 2
Slot 32
...
12 seconds
epoch\(_t\)
epoch\(_{t+1}\)
epoch\(_{t-1}\)
checkpoint
checkpoint
checkpoint
checkpoint
Blockchain finality rules
...
epoch\(_t\)
epoch\(_{t+1}\)
epoch\(_{t-1}\)
checkpoint
checkpoint
checkpoint
checkpoint
all validators vote on validity
all validators vote on validity
all validators vote on validity
all validators vote on validity
(for clarity: checkpoint voting happens over time, by all validators)
Blockchain finality rules
...
epoch\(_t\)
epoch\(_{t+1}\)
epoch\(_{t-1}\)
checkpoint
checkpoint
checkpoint
checkpoint
valid?
\(\Rightarrow\) "justified"
last justified block becomes "final"
valid?
\(\Rightarrow\) "justified"
last justified block becomes "final"
valid?
\(\Rightarrow\) "justified"
Validators, Committees, Proposers
ETH owners lock up funds (\(\ge32\)ETH) in a special smart contract
validators selected at random based on proportional ownership of total stake
Slot 1
proposer
Slot 2
proposer
Slot 32
proposer
Validators, Committees, Proposers
Slot 1
proposer
Slot 2
proposer
Slot 32
proposer
validation
committee
validation
committee
validation
committee
128 validators per committee (\(\Rightarrow\) 32 x 128) are selected at random based on proportional ownership of total stake
Rewards and Punishments
What do we need from validators?
if "lazy"
misses out on rewards
if dishonest
Concretely they need to
What rewards?
proposer
Committee
What penalties?
offline
misbehavior
Ethereum is "full"
Source: Etherscan w re-scaling
Basic idea of a Rollup
rollup
API
rollup
layer
by a sequencer
The process explained
users lock up funds in a special smart contract
a
b
e
f
g
perform operations or transact
sequencer creates a digest of bundled/rolled-up transactions
sequencer posts digest to mainnet
What's this?
Optimistic roll-up:
ZK-Rollups
Pros
Cons
Pros
Cons
Some things you can do with a rollup
Research questions:
a
b
e
f
g
users lock up funds in a special smart contract
sequencer creates a digest of bundled/rolled-up transactions
perform operations or transact
sequencer posts digest to mainnet
How is a rollup different from a crypto-trading platform?
crypto platform: transactions enabled on a seperate system with no proftable relation to blockchain
rollup: ownership transferred to smart contract; retain control within rules of smart contract
rollups:
More data
What's happening? Is the L2 party already over?
EIP-4844: enabling of data blobs
basic idea:
Research questions:
Challenge: How do you get data onto a blockchain?
The Oracle Problem
<standings: 7,3,8,4,2,1,6,5> + digital signatures
Disagreement?
Majority Vote
The Oracle Problem
1 ETH = $4780
1 ETH = $4789
1 ETH = $4781
The Oracle Problem
Chainlink
Same follow-on challenge for builders: how can you fit staking, rewards, and inevitable speculation into securities law?
The Oracle Problem: tokenomics
Research questions:
Decentralized Trading
Liquidity providers
Liquidity demander
Liquidity Pool
No effect on the marginal price
Research questions:
\(\to\) simply connect with MetaMask (or similar wallet)
How does this look in practice?
Key feature: these "exchanges" are non-custodial
AMM Theory: Price Functions
Basic Requirements for "unconstrained" two-asset liquidity pool
What does an AMM need?
quantity
price
\(q\)
\(p^m(q)\)
\(\Delta c(q)=p(q)^m\times q\)
Traditional pricing: auctions/open outcry/RFQ: uniform price
idea: cost of \(q=\) price\(\times\) quantity
Some Pricing Rules from Traditional Markets: Uniform Price
\(q=2\)
Example: \(\Delta c(q)= q\times p^m(q)=2\times 15.5\)
Main pricing rule in stock exchanges: limit order book
quantity
price
\(q\)
\(p^m(q)\)
\(\Delta c(q)=\int_0^qp^m(s)~ds\)
again note: the marginal pricing function \(p(q)\) does not have to be linear
Some Pricing Rules from Traditional Markets: Limit Order Book
Most Common Pricing Rule in DeFi: Constant Product
Most Common Pricing Rule in DeFi: Constant Product
Insight: AMM pricing function is the same as a limit order book when we require
average prices
Some insights on pricing functions
The Pricing Function
Transaction cost (here: price impact) of buying \(q\)
\[\frac{p(q)-p(0)}{p_0}=\frac{q}{a-q}\]
UniSwap v3
UniSwap v3 has "concentrated liquidity provision"
\(p_d\)
\(p_u\)
\(p_0\)
UniSwap v1/v2: provide liquidity \(a,c\) for all prices
\(p^m\in(0,\infty)\)
UniSwap v3: provide liquidity \(u,\Delta c(d)\) for price interval
\(p^m\in[p_d,p_u]\)
\(u\)
\(d\)
\(\}\)
\(\Delta c(d)\)
the pricing curve for each interval is determined by the constant product rule
UniSwap v3 has "concentrated liquidity provision"
Just a little more institutional details
users submit liquidity positions \((u,d,p_u,p_d)\) and receive an ERC-721 (=NFT) token as a receipt
the code segments liquidity into discrete exponential intervals \([p_k,p_{k+1}]\) with \[p_k=(1+\delta)^k. ~~~(\text{numerically: }p(k)=1.0001^k)\]
it aggregates liquidity over these intervals
the pricing curve for each interval is determined by the constant product rule
intervals may be "empty"
How the price is determined
where \(\tilde{a}\) is the virtual liquidity
quick disclaimer: what follows is not how UniSwap is explained on its website etc. But the resulting maths are the same
\(p_d\)
\(p_u\)
\(p_0\)
UniSwap v3: An Example
\(p_u=15\)
\(p_d=7\)
\(u=2\)
\(p_0=10\) (that's exogenous, not a choice)
marginal price
\[p^m(s)=\frac{\tilde{a}c}{(\tilde{a}-s)^2}.\]
Finding virtual liquidity factor \(\tilde{a}\)
marginal price
\[p^m(s)=\frac{\tilde{a}c}{(\tilde{a}-s)^2}.\]
\(p_u=15\)
\(p_d=7\)
\(u=2\)
\(p_0=10\) (that's exogenous, not a choice)
= find the right curve
= find the right "\(\tilde{a}\)"
such that \[p^m(u|\tilde{a})=p_u\]
Finding the fourth parameter \(\Delta c(d)\)
\(p_u=15\)
\(p_d=7\)
\(u=2\)
\(d=?\)
required cash deposit \(\Delta c(d)=\) the amount that I pay for \(d\)
marginal price
\[p^m(s)=\frac{\tilde{a}c}{(\tilde{a}-s)^2}.\]
Given \(\tilde{a}\) solves \(\gamma(u)=p_u\), we
Solutions
For those in the know: These formulae/solutions are exactly the same as those in the UniSwap v3 whitepaper
Numerical example
Want to read more?
Liquidity Supply and Demand in an Automated Market Maker
Facts about modelling liquidity provision
Key questions:
Two broad approaches for modelling liquidity provision
You worry about the positional loss relative to any income.
You worry whether you can rebalance your liquidity profitably.
(im)permanent loss
"LVR" = loss-vs-rebalancing
Provide-and-Forget Liquidity Provision
Buy and hold
Provided liquidity
in the pool
Provide-and-Forget Liquidity Provision
Basic idea of liquidity provision: earn more on balanced flow than what you lose on price movement
\[\text{fee income} +\underbrace{\text{net change in cash (my income)}-\text{true value of trade}}_{\text{adverse selection loss}} \ge \text{cost of capital} \]
in AMMs:
protocol fee
in tradFi: bid-ask spread
Provide-and-Forget Liquidity Provision
\[\underbrace{F \int DV \mu(DV) }_{\text{fees earned on}\atop \text{balanced flow}}+\int_0^\infty\underbrace{(\Delta c(q^*)-q^*p_t(R)}_{\text{adverse selection loss} \atop \text{when the return is {\it R}}} +\underbrace{F \cdot \Delta c(q^*))}_{\text{fees earned}\atop \text{from arbitrageurs}}~\phi(R)dR \ge r.\]
\(q^* \) is what arbitrageurs trade to move the price to reflect \(R\)
Basic idea of liquidity provision: earn more on balanced flow than what you lose on price movement
\[\text{fee income} +\underbrace{\text{what I sold it for}-\text{value of net position}}_{\text{adverse selection loss}} \ge \text{cost of capital} \]
in AMMs:
protocol fee
in tradFi: bid-ask spread
Sidebar: we can quantify how much a PASSIVE LP loses when the price moves by \(R\)
for orientation:
\[\frac{\text{adverse selection loss when the return is \(R\)}}{\text{initial deposit}}=\sqrt{R}-\frac{1}{2}(R+1)\]
see Barbon & Ranaldo (2022)
adverse selection loss
(or: impermanent loss)
Liquidity Demander's Decision & (optimal) AMM Fees
Result:
competitive liq provision\(\to\) there exists an optimal (min trading costs) fee \(>0\)
Similar to Lehar&Parlour (2023) and Hasbrouck, Riviera, Saleh (2023)
\[F^\pi=\frac{1}{E[|\sqrt{R}-1|/2]+V}\left(-2q\ E[\text{position loss}]+ \sqrt{-2qV\ E[\text{position loss}]}\right).\]
assume: liquidity providers add liquidity until they break even in expectation
Liquidity Provision as Options
Ciamac Moallemi will explain details later!
Loss-vs-Rebalancing
Loss-vs-Rebalancing
\[\text{Liquidity position P\&L}=\text{fee income} +\text{pool value after at \(t\)} -\text{pool value at \(0\)}\]
\[=\text{rebalanced value at \(t\)} -\text{pool value at \(0\)} +\text{fee income}-\text{LVR}.\]
\[=\underbrace{\text{rebalanced value at \(t\)} -\text{pool value at \(0\)}}_{\text{is hedge-able (Delta-hedge type strategy)}} +\text{fee income}-\text{LVR}.\]
\[\text{{\it hedged} Liquidity position P\&L}=\text{fee income}-\text{LVR}.\]
Ciamac Moallemi will later explain how hedging then improves the Sharpe Ratio substantially!
LVR vs IPL
\[\text{{\it hedged} Liquidity position P\&L}=\text{fee income}-\text{LVR}.\]
What's the difference of LVR to ImPermanent Loss?
\(\Rightarrow\) different perspective of market making
\[\text{{\it unhedged} Liquidity Position P\&L}=\text{fee income}-\text{IPL}.\]
Empirical Work
Lehar and Parlour (2021)
Barbon & Ranaldo (2023)
Other notables:
Malinova & Park (2023): AMM applied to equities would reduce trading costs by 30%
The Microstructure is evolving
A brief look under the hood: the workflow
liquidity pool
blockchain
user
website
router
liquidity pool
blockchain
user
A brief look under the hood: the workflow
aggregator protocol
router
pool 1
blockchain
user
pool 2
multiple
pools
A brief look under the hood: the workflow
back to UniSwap
pool 1
blockchain
user
pool 2
A brief look under the hood: the workflow
back to UniSwap
pool 1
blockchain
user
pool 2
just-in-time
liquidity bots
A brief look under the hood: the workflow
back to UniSwap
pool 1
blockchain
user
pool 2
just-in-time
liquidity bots
in the settlement layer ("MEV")
The big insight: this system is getting more and more sophisticated!
Concerns around Automated Market Makers
a
b
c
d
e
f
g
Problem 1: Sandwich (MEV) attacks
related paper: “Maximal Extractable Value and Allocative Inefficiencies in Public Blockchains”. A. Capponi, R. Jia, and Y. Wang (2023)
NB: PBS does not solve the problem
a
b
c
d
e
f
g
Problem 2: Arbitrage Trades that Reduce LVR
PBS creates the problem
builder/searcher
Problem 3a: Just-In-Time Liquidity (single trade cream skimming)
X-Router
Liquidity pool
OTC
Problem 3b: Just-In-Time Liquidity (at the builder/MEV level)
X-Router
Liquidity pool
searcher/builder
balanced orders
add as much liquidity as possible
withdraw liquidity
unbalanced orders
related paper: Capponi, Jia, and Zhu (2024) "The Paradox of Just-in-Time Liquidity in Decentralized Exchanges: More Providers Can Lead to Less Liquidity"
Research questions:
Blockchain: a history
History of Crypto and Blockchain how I'd like you to see it
single-purpose digital money
general purpose platform
DeFi applications
alternative digital money
alternative smart contract platforms
scaling solutions and higher level (d)apps
money applications
An Alternative View of Blockchain
crazy internet money with no value
a vehicle to create unlimited crazy internet money
utility
tokens
DAOs
NFTs
Meme
other crazy
money
alternative vehicles for vaporware
Crypto-Pumpers are getting more honest
?
= Meme Coins!
p'nut
DogWIFHat
Research questions:
The Bigger Picture and Last Words
Last Words
Last Words on Research Questions: The DON'Ts
@financeUTM
andreas.park@rotman.utoronto.ca
slides.com/ap248
sites.google.com/site/parkandreas/
youtube.com/user/andreaspark2812/
From Vitalik Buterin's post on the topic:
https://ethresear.ch/t/improving-front-running-resistance-of-x-y-k-market-makers/1281
Theorem (Park 2023):
Hypothetical example
The Bigger Picture: MEV Extraction
read more at: "Battle of the Bots: Flash Loans, Miner Extractable Value and Efficient Settlement", Lehar & Parlour, 2023
limit order book | periodic auctions | AMM | |
---|---|---|---|
continuous trading |
|||
price discovery with orders | |||
risk sharing |
|||
passive liquidity provision | |||
price continuity |
|||
continuous liquidity | |||
sniping prevented |
Two views
Two views
How the price is determined
Theory Literature on AMM
Traditional Markets
What is Market Microstructure?
Broker
Exchange
Internalizer
Wholeseller
Darkpool
Venue
Settlement
Traditional Institutions
Investors
Trading Arrangements
central limit order book
complexity
price impact of trades
anonymity
price discovery
centralized auction
bilateral
negotiation
Request
for Quote
open
outcry
Who trades?
Key question for liquidity provision
Seminal papers
What's there first? Orders or Liquidity?
Seminal papers
Basics of liquidity provision under value uncertainty
Questions:
every model has some form of structure like
\[\text{trading income (fees, spreads, etc)} +\underbrace{\text{what I sold it for}-\text{value of net position}}_{\text{positional gain/loss}} \ge \text{outside option} \]
Example 1: Grossman/Miller
Example 2: Kyle or Glosten-Milgrom
Example 3: Limit order market (a la Glosten 1994)
Crypto vs TradFi Markets
Key Differences Defi vs TradiFi
Broker
Exchange
Internalizer
Wholeseller
Darkpool
Venue
Settlement
Investor
Centralized Trading
BTC/USD
ask: 7,600
bid: 7,550
BTC/USD
ask: 7,500
bid: 7,450
buy BTC
sell BTC
move BTC to Kraken
Crypto Wash Trading, Lin William Cong, Xi Li, Ke Tang, Yang Yang
What is pump and dump?
arranged via Telegram Channels
August 2016
where do I find these plots? theblock.co/data/
Literature
AMM Literature: a booming field
Lehar and Parlour (2021): for many parametric configurations, investors prefer AMMs over the limit order market.
Aoyagi and Ito (2021): co-existence of a centralized exchange and an automated market maker; informed traders react non-monotonically to changes in the risky asset’s volatility
Capponi and Jia (2021): price volatility \(\to\) welfare of AMM LPs; conditions for a breakdown of liquidity supply in the automated system; more convex pricing \(\to\) lower arbitrage rents & less trading.
Capponi, Jia, and Wang (2022): decision problems of validators, traders, and MEV bots under the Flashbots protocol.
Park (2021): properties and conceptual challenges for AMM pricing functions
Milionis, Moallemi, Roughgarden, and Zhang (2022): dynamic impermanent loss analysis for under constant product pricing.
Hasbrouck, Rivera, and Saleh (2022): higher fee \(\Rightarrow\) higher volume
Empirics:
Lehar and Parlour (2021): price discovery better on AMMs
Barbon and Ranaldo (2022): compare the liquidity CEX and DEX; argue that DEX prices are less efficient.
payments network
Stock Exchange
Clearing House
custodian
custodian
beneficial ownership record
seller
buyer
Broker
Broker
IS BITCOIN REALLY UN-TETHERED? JOHN M. GRIFFIN and AMIN SHAMS
Journal of Finance 2020
Figure 1. Aggregate Flow of Tether between Major Addresses
marginal pricing function
quantity \(q\)
price \(p^m(q)\)
Illustration of pricing
Some Pricing Rules from Traditional Markets: Limit Order Book
\[\Delta c(q)=\int_0^q\rho(s) ds.\]
Returns to Liquidity Provision
For fixed balanced volume \(V\) and fee \(F\)
Competitive liquidity provision
Basics of Liquidity Provision
\[\text{LP payoff}=\text{what I sold it for}-\text{value of net position}+\text{fee income}\]
see Lehar and Parlour (2023), Barbon & Ranaldo (2022).
(incremental) adverse selection loss when the return is \(R\)
fees earned
on informed
fees earned
on balanced flow
for reference:
positional loss
Basics of Liquidity Provision
\[\frac{1}{\text{initial deposit}}\int_0^\infty(\Delta c(q^*)-q^*p_t(R)+F \cdot \Delta c(q^*))~\phi(R)dR +\frac{F p_0 V}{\text{initial deposit}}\ge 0\]
\[\int_0^\infty\left(\frac{\Delta c(q^*)-q^*p_t(R)}{\text{initial deposit}} +F \cdot \frac{\Delta c(q^*)}{\text{initial deposit}}\right)~\phi(R)dR +\frac{F p_0 V}{\text{initial deposit}}\ge 0\]
closed form functions of \(R\) only
(see Barbon & Ranaldo (2022))
\[\underbrace{F \int DV \mu(DV) }_{\text{fees earned on}\atop \text{balanced flow}}+\int_0^\infty\underbrace{(\Delta c(q^*)-q^*p_t(R)}_{\text{adverse selection loss} \atop \text{when the return is {\it R}}} +\underbrace{F \cdot \Delta c(q^*))}_{\text{fees earned}\atop \text{from arbitrageurs}}~\phi(R)dR \ge 0.\]
Basics of Liquidity Provision
\(\Rightarrow\) \(\Delta c(q^*)-q^*p_t(R)\) is also referred to as the "impermanent loss" or "divergence loss"
\(\Delta c(q^*)-q^*p_t(R)=\underbrace{p_t(R)\times(a-q^*) +c+\Delta c(q^*)}_{\text{value of liquidity deposit}}-\underbrace{(p_t(R)a+c)}_{\text{value of buy-} \atop \text{and-hold position}}\)
see Milionis, Moallemi, Roughgarden, and Zhang (2022) for a dynamic analysis of impermanent loss
Basics of Liquidity Provision
Liquidity provision measured as "collective" deposit \(\alpha\) of token's market cap as function of
\[E[\text{DL}(R)]+F\cdot E[\text{another function of }R]+F\cdot \frac{\text{E[dollar volume]}}{\text{initial deposit}}\ge 0.\]
\[\text{what I sold it for}-\text{value of net position}+\text{fee income} \ge 0 \]
The Decision of the Liquidity Demander
\[F^\pi=\frac{1}{E[|\sqrt{R}-1|/2]+E[DV]}\left(-2q\ E[\text{DL}]+ \sqrt{-2qE[DV]\ E[\text{DL}]}\right).\]
this is from Malinova and Park (2023); similar result is in Hasbrouk, Riviera, Saleh (2023)
Model Summary
The Pricing Function
Liquidity Deposit \(\Rightarrow\) slope of the price curve
The Pricing Function (just a little more)
The Pricing Function (almost done, just one more thing)
AMMs continue to evolve: UniSwap v3
Basic idea:
Source:" Uniswap v3 Core," Adams, Zinsmeister, Salem, Keefer, Robinson (2021)
Some UniSwap v3 maths (Barbon & Ranaldo 2023)
Source: Elsts (2021) "Liquidity Math in UniSwap v3"
\(X\)
\(Y\)
normal trade: sell \(x\) \(\to\) get \(y'\)
\(Y-y'\)
\(X+x\)
front-running:
\(Y-y'-y''\)
\(X+2x\)
\(y'>y''~\Rightarrow\)
front-running is intrinsically profitable
Disclaimer:
Problems:
lesser problem because
Common solution: create a reward token! Here's how this works
Step 4: users receive a reward token based on the time that they lock up the "receipt" token
Step 3: users lock up the "receipt" token in a smart contract
Step 2: users contribute liquidity and get a "receipt" token
Step 1: create reward tokens and deposit into a smart contract
borrow
provide collateral
Application: Pool-based borrowing and lending
Same problems as with trading:
But: in contrast to trading, here you need both!
liquidity \(\nearrow\)
volume \(\nearrow\)
protocol fees \(\nearrow\)
token value \(\nearrow\)
Platform economics is tricky:
Without intermediaries:
platform economics!
incentives for both?
What value do these tokens have?
Vampire Attacks and Other Shenanigans
Source: https://finematics.com/vampire-attack-sushiswap-explained/
another common trick: