Crypto Trading

 

Instructors:           Andreas Park & Zissis Poulos
 

 

DeFi Overview

Overview of Traditional Trading

A glimpse of overall infrastructure

Sue wants to sell ABX

Bob wants to buy ABX

sell order

buy order

Clearing House

Stock Exchange

Broker

Broker

3rd party tech

custodian

custodian

record beneficial ownership

central bank for payment

Types of traders

Trading in Equity Markets today

Retail

Institutional

Pro-Traders

high volume securities

low volume securities

50%

50-60%

0%

30-40%

40-50%

10-20%

Summary of workflow

Exchange

Traditional

Internalizer

Wholeseller

Darkpool

Investor

Venue

Broker

Settlement

Exchanges

Wholesellers

Dark pools

Broker Internalizations

Where does trading occur?

Trading in Equity Markets today

Exchanges

Wholesellers

Dark pools

Broker Internalizations

How does trading work?

Trading in Equity Markets today

(

(

How to access the market?

Trading in Equity Markets today

Retail

Institutional

Pro-Traders

Retail: Canada

Trading in Equity Markets today

Rule: must send to exchange with best price 

Retail: U.S.A.

Trading in Equity Markets today

Exchange

Wholeseller

market order

limit order

In Europe: no best price obligation

Institutions: U.S.A.

Trading in Equity Markets today

Exchange

Dark pools

Pro Traders

Trading in Equity Markets today

Type 2: "borrow" broker-dealer system

Type 1: licenced broker-dealer

risk control

Big Message

Trading in Equity Markets today

  • You commonly don't access the market directly.

  • Brokers take many decisions but they are bound by regulations.

  • Critical: markets are formally linked by best-price rules.

Crypto Trading Overview

Three Fallacies for Crypto Economics

crypto assets = traditional equities

crypto trading = traditional trading

crypto entities = traditional firms

Types of traders

Trading in Equity Markets today

Retail

Institutional

Pro-Traders

high volume securities

low volume securities

50%

50-60%

0%

30-40%

40-50%

10-20%

Coinbase's recent numbers

Coinbase's recent numbers

Summary of workflow

Crypto

Investor

Venue

Settlement

On chain

Types of traders

Trading in Crypto Markets

Retail, Institutions, and Pro-Traders are indistiguishable

not clear whether and which institutions are active 

Where does trading occur?

Trading in Crypto Markets

Exchanges

Dark pools

Smart On-chain contracts

Exchanges

Smart Contract

How does trading work?

Trading in Crypto Markets

Order Driven

Market Maker

How do you access the market?

Trading in Crypto Markets

Exchanges

Smart On-chain contracts

Within exchange operation

Trading in Crypto Markets

trade

lend

Settlement

Trading in Crypto Markets

trade

Fully decentralized 1.0

... 300 lines of code ...

Some Stylized Facts on Crypto Trading

How many CEXes are there?

(307 CEX, rest DEX)

What are the differences?

What do they trade?

Link to traditional finance?

  • spot trading
  • derivatives
  • crypto-only
  • "fiat" linked
  • regulation
  • cryptos traded
  • accessibility
  • privacy
  • credibility

Concerns with CEX-Trading

Concerns

arbitrage is either not possible  or requires large capital commitment => expensive

exchanges = brokers? => single point of failure

decentralized: totally anonymous => easy price manipulation (e.g. wash trades)

Bitcoin prices in USD, May 25 2018, 17 exchanges

Arbitrage?

Pre-req for Trading on a Crypto Exchange

trade

Settle on the blockchain for digital "assets"

Wire transfer for fiat

Arbitrage on a Crypto Exchange

BTC/USD

ask: 7,600 

bid: 7,550

BTC/USD

ask: 7,500 

bid: 7,450

buy low 

sell high

Arbitrage on a Crypto Exchange

BTC/USD

ask: 7,600 

bid: 7,550

BTC/USD

ask: 7,500 

bid: 7,450

buy BTC

sell BTC

move BTC to Kraken

=> arbitrage = commit capital on multiple exchanges

Arbitrage on a Crypto Exchange

Wire: free*; 1-5 days

Credit card: 3.5%

trading fee: 10-25 bps

flat fee in BTC \(\approx\) $4-8

\(\approx\) 10-60 minutes

trading fee: 0-26 bps

35 USD + 0.125%

($5 if >$50,000)

1-3 business days;

possible other fees/delays

Some exchanges allow short selling

Crypto Wash Trading, Lin William Cong, Xi Li, Ke Tang, Yang Yang

  • systematic tests:
    • robust statistical and behavioral patterns in trading to detect fake transactions on 29 cryptocurrency exchanges.
    • Regulated exchanges are OK
    • unregulated exchanges: rampant manipulations
    • wash trading on each unregulated exchange:  
      • on average over 70% of the reported volume
      • improve exchange ranking
      • temporarily distort prices

Volume Manipulation on Crypto Exchanges

Cryptocurrency Pump-and-Dump Schemes
Tao Li, Donghwa Shin, and Baolian Wang, 2020

What is pump and dump?

arranged via Telegram Channels

Price Manipulation on Crypto Exchanges

  • prices of pumped cryptocurrencies begin rising five minutes before a P&D starts.
  • some pump group organizers offer premium memberships to allow certain investors to receive pump signals before others do (\(\to\) insiders)
  • Average P&D insiders make one Bitcoin (about $10,000) in profit
  • only investors who buy in the first 20 seconds after a P&D begins make a profit

Other Tidbits of Information

IS BITCOIN REALLY UN-TETHERED? JOHN M. GRIFFIN and AMIN SHAMS
Journal of Finance 2020

  • basic idea: USDT is issued unbacked to trade Bitcoin and to inflate its price
  • more on the next slides...

Price Manipulation on Crypto Exchanges

What's the result?

Regulated Exchanges

Derivatives trade mostly offshore! Unregulated(?!)

  • on April 30, 2019: Tether does not have cash reserves equal to 100% of the outstanding Tethers.
  • May 15, 2019 court hearing: Tether did invest in instruments beyond cash, including Bitcoin

Historically: “Tether Platform currencies are 100% backed by actual fiat currency
assets in our reserve account.”

Today: "The Tether Platform is fully reserved when the sum of all tethers in circulation is less than or equal to the value of our reserves."

IS BITCOIN REALLY UN-TETHERED?
JOHN M. GRIFFIN and AMIN SHAMS
Journal of Finance 2020

vs.

Why does that matter?

  • Tether = ‘pushed’
    • print an unbacked digital dollar to purchase Bitcoin.
    • \(\to\) additional supply of Tether creates unwarranted inflation in Bitcoin price

Text

IS BITCOIN REALLY UN-TETHERED?
JOHN M. GRIFFIN and AMIN SHAMS
Journal of Finance 2020

vs.

  • Tether = ‘pulled’
    • driven by legitimate demand from investors who use Tether as a medium of exchange
    • \(\to\) the price impact of Tether reflects natural market demand

Text

IS BITCOIN REALLY UN-TETHERED?
JOHN M. GRIFFIN and AMIN SHAMS
Journal of Finance 2020

Flow of events

  • Tether is authorized
  • moved to Bitfinex 
  • then slowly distributed to other Tether-based exchanges (Poloniex and Bittrex)
  • \(\to\) almost no Tether returns to the Tether issuer to be redeemed
  • Kraken (major exchange for Tether\(\to\) USD) accounts for only a small proportion of transactions

Figure 1. Aggregate Flow of Tether between Major Addresses

Figure 3. Aggregate Flow of Bitcoin between Major Addresses.

Top Accounts Associated with the Flow of Tether from and Bitcoin to Bitfinex

  • three main Tether exchanges, Bitfinex, Poloniex, and Bittrex, have considerable cross-exchange Bitcoin flows
  • cross-exchange Bitcoin flows on Bitcoin closely match Tether flows
  • one large player has >50% of the exchange of Tether for
  • Bitcoin at Bitfinex
  • \(\to\) distribution of Tether into market from ONE large player and not many different investors 

If Tether is printed independently
of demand and pushed onto the market then ...

  • \(\nearrow\) money supply in crypto
  • \(\nearrow\) cryptocurrency prices through artificial demand 
  • if traded strategically, Tether can further impact and manipulate Bitcoin prices

the 1% of hours with the strongest lagged Tether flow are associated with 58.8% of the Bitcoin buy-and-hold return over the period.

Is the Price Effect Economically Important?

the "normal-times" returns

Crypto exchanges are a security risk

August 2016

Crypto exchanges are a security risk

By yours truly, Dec 2017: "What really concerns me about the current craziness is the role of the cryptocurrency exchange platforms, such as Coinbase, Quadriga, or Bitfinex, which most people use to buy Bitcoins. These are like banks that hold deposits. For cryptocurrencies to succeed it is critical that these interfaces with the real world are financially robust. Are they? Do they have all the Bitcoins they sell? Can they always satisfy depositors’ demands?"

Crypto exchanges are a security risk

https://www.forbes.com/sites/jasonbrett/2019/12/19/congress-considers-federal-crypto-regulators-in-new-cryptocurrency-act-of-2020/#7ddcdfd65fcd

Crypto exchanges are a security risk

https://www.osc.ca/en/news-events/news/osc-working-ensure-crypto-asset-trading-platforms-comply-securities-law

SEC denies Bitcoin ETF

How about fully decentralized trading?

Spirit of Blockchain: Fully decentralized

... 300 lines of code ...

standard trading rules practically impossible to enforce

Spirit of Blockchain: Fully decentralized

Actually ...

  • bad idea
  • Why? 
  • Data-intensive, computation intensive, costly, inefficient

 

How do you organize DEX trading?

Liquidity?

  • Laissez-faire: Etherdelta or Kyber
    • people submit contracts (limit orders) on-chain
    • system collects info
    • system offers "tools" to trade against standing contracts
  • Hybrid: 0x
    • "dark liquidity"
    • off-chain/sidechain purchase/sale agreements
    • system matches compatible orders and posts on-chain
  • Automated market maker (AMM) (Uniswap)
    • AMM holds assets on both sides
    • offers two-sided quotes (\(\to\) always liquid)
    • prices adjust continuously to demand/supply shifts

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}.\]

How do you organize DEX trading? EXAMPLE

automated market maker

invariant \(k=4\times4=16\) 

Instantaneous exchange rate:

1             =   1

Contract deposit:

How do you organize DEX trading? EXAMPLE

automated market maker

sell 4 DAI for USDC

what price will therefore be quoted?

\begin{array}{rcl} k&=&\#\text{DAI}\times\#\text{USDC}\\ 16&=&(4+4)\times(4-y)\\ x&=&2 \end{array}

how many USDC?

e=x/y~~\to~~e=2

How do you organize DEX trading? EXAMPLE

automated market maker

Problem: large "slippage" (or price impact)

  • imagine: deposit is 100 DAI & USDC:
    • \(k=100\times100=10,000~\to\) for \(x=4\) need \(y=100-10000/104=3.85\)
       
  • imagine: deposit is 10,000 DAI & USDC:
    • \(k=10,000\times10,000=100,000,000~\to\) for \(x=4\) need \(y=10,000-100,000,000/10,004=3.998\)
       
  • ​\(\to\) the more money is in the contracts, the lower the price impact

How do you organize DEX trading? other mechanisms

automated market maker

  • anyone can become a liquidity provider when supplying both sides of a pair
     
  • trades carry a fee of 30bps \(\to\) paid to liquidity providers (pooled)
     
  • LPs still face opportunity costs relative to all other assets \(\to\) income must be sufficient

supercool feature

automated market maker

  • establish and sell a new token
     

    • create token
    • deposit token and counterasset (e.g., DAI)
    • \(\to\) opening price
    • \(\to\) new purchases will increase price

  •  

superannoying feature

automated market maker

  • front-running

    • transactions enter mem-pool

    • \(\to\) all visible there

    • arbitrageur make instant-swap trade at higher gas price

      • \(\to\) trade instead of original trade

      • \(\to\) reverse to gain slippage from earlier trader

front-running

"mem-pool"

1

2

4

3

5

6

1

2

5

3

6

7

4

So what?

  • front-running is annoying for the front-run - but will it happen?

  • \(\to\) needs to be profitable!
  • Problem: with constant product market makers it always is!
    (modulo fees)

Some math

  • front runner buys \(x\) and pays \(y\) when MM has \(X,Y\)
  • front-run buys \(x\) and pays \(y^*\) when MM has \(X-x,Y+y\)
  • front runner sells \(x\) and receives \(y^{**}\) when MM has \(X-2x,Y+y+y^*\)
y^{**}=\frac{xXY}{(X-x)(X-2x)}
y= \frac{xY}{X-x}
\begin{array}{rcl} y^{**}-y&=&\frac{xXY}{(X-x)(X-2x)}-\frac{xY}{X-x}\\ &=&\frac{2x^2Y}{(X-x)(X-2x)}\\ &>&0 \end{array}

\(\Rightarrow\) profitable!

Convenient feature for arbitrage: Flash loans (Flash swaps)

automated market maker

  • take three pairs (ignore that BTC is not directly on Ethereum)

    • BTC-DAI

    • ETH-BTC

    • ETH-DAI

  • three pairs must satisfy non-arbitrage condition
  • e.g. if ETH:DAI =1:100 and BTC:DAI=1:10000 then BTC:ETH=1:100
  • say BTC:ETH=1:200 then
    • borrow (say) 10,000 DAI
    • use DAI to buy  1 BTC
    • sell 1 BTC for 200 ETH and
    • sell 200 ETH for 20000 DAI
    • of which you use 10,000 DAI to repay loan and pocket 10,000
  • Normally, this is hard!
  • But on blockchain you can do all operations in one go
  • \(\to\) no risk of leg of transaction not going through or non-delivery
  • flash (single-block) loans enable this

How does it look?

automated market maker

\(\to\) simply connect with MetaMask (or similar wallet)

Concerns with DEX Trading

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

Some numbers (rounded to two decimals)

From Vitalik Buterin's post on the topic:

https://ethresear.ch/t/improving-front-running-resistance-of-x-y-k-market-makers/1281

  • Suppose MMs have \((X,Y)=(10,10)\)
  • Sell 1 of the \(A\) tokens; normally get \(.91\) \(B\) tokens.
  • \(\to\) front-runner goes first
    • ​MM holdings: \((11,9.09)\)
  • \(\to\) front-run sells one \(A\( token, gets 0.76 units of \(B\)
    • MM holdings: (12, 8.33)
  • Front-runner buys 1 unit of \(A\) pays 0.76 units of \(B\)
    • ​profit: \(.91-0.76= 0.15\)

Mempool \(\Rightarrow\) Front-Running!

So what's the Problem?

a

b

c

d

e

f

g

Dark side of DEx trading: Miner extractable value

Summary

Summary of workflow

Crypto

Exchange

Traditional

Internalizer

Wholeseller

Darkpool

Investor

Venue

Broker

Settlement

Investor

Venue

Settlement

On chain

Main differences

Trading in Equity vs Crypto

  • regulated environment
  • firm trading rules
  • listing requirements
  • multi-step process
  • complicated settlement
  • many intermediaries




     

Equity Market

Crypto Market

  • unregulated environment
  • no trading rules - manipulation must be assumed
  • single step process
  • use of intermediaries is a choice
  • crypto exchange are closer to brokerages than equity exchanges
  • settlement a choice and straightforward
  • fully decentralized trading is possible and most exiting innovation
  • much work remains to be done

Crypto Trading (MBA) V2

By Andreas Park

Crypto Trading (MBA) V2

  • 213
Loading comments...

More from Andreas Park