Defi LEnding and Borrowing

 

Instructors:           Andreas Park & Zissis Poulos
 

 

2021

MakerDAO

Prerequistes

Key Components for Defi

borrowing/lending

on-chain ability to exchange arbitrary value

(last class)

Borrowing/Lending & Unit of Account creation

Idea:

  • create fiat money on chain with borrowing
  • mechanism
    • a collateralized loan with ETH in escrow
    • DAO-managed monetary policy (=creation or destruction of tokens)

Sidebar: what is a DAO?

  • DAO=decentralized autonomous organization
  • \(\to\) entity without management
  • governance decided by token holders essentially by vote
  • We'll devote a class to DAO governance

user perspective

4 ETH
(1 ETH = $375)
(Oct 15, 2020)
\(\approx\) $1,500

\(\vdots\)

1,500 DAI
(1 DAI = $1)

formally: this smart contract is a collateralized debt position (CDP)

user perspective

fractional collateral \(\to\) collateralization factor \(=\) 150%

\begin{array}{rcl} &&\textsf{maximal amount of DAI in \$}\\\\ &=&\frac{\textsf{\$ equivalent of ETH in escrow}}{\textsf{collateralization factor}}\\\\ &=&\frac{1,500}{150\%}=\$1,000 \end{array}

total collateral = $1,500

maximum loan = $1000

overcollateralization = $500

actual loan (example) = $500

buffer = $500

user perspective: what happens if the price of ETH rises?

ETH \(\nearrow\) $500

value of ETH collateral = $2,000

maximum loan = $2,000/150%=$1,333

total collateral = $2,000

maximum loan = $1,333

overcollateralization = $667

actual loan (example) = $500

buffer = $500

overcollateralization = $667

new loan capacity= $333

user perspective: what happens if the price of ETH falls?

ETH \(\searrow\) $187.5

value of ETH collateral = $750

maximum loan = $750/150%=$500

total collateral = $750

maximum loan = $500

overcollateralization = $250

actual loan (example) = $500

buffer = $0

for reference: former value of collateral

user perspective: what happens if the price falls & max loan is exceeded?

Maker DAO

ETH \(\searrow\) $150

value of ETH collateral = $600

maximum loan = $600/150%=$400

total collateral = $600

maximum loan = $400

required overcollateralization = $200

actual loan (example) = $500

buffer = -$100

for reference: former value of collateral

\(\Rightarrow\) triggering of liquidation auction by "keeper"

sell 3.33 ETH=$500=500 DAI

repay $500=500 DAI loan

retain incentive

return  remainding ETH to vault owner

Maintaining the Peg: monetary policy

Maker DAO

  • How works:
    • 1 USDC=1.01 DAI
      • use USDC to mint new DAI
        • supply (DAI) \(\nearrow\)
        • price (DAI) \(\searrow\)
    • 1 USDC=0.99 DAI
      • Swap Dai for USDC (more below)
      • demand (DAI) \(\nearrow\)
      • price (DAI) \(\nearrow\)

\(\Rightarrow\) all relies on behavioral assumptions

\(\Rightarrow\) But: there are also real incentives & mechanisms

Maintaining the Peg: monetary policy

Maker DAO

  1. stability fee
     
  2. DAI savings rate (DSR)
     
  3. debt ceiling

borrowers of DAI need to pay interest \(\to\) stability fee

  • if too much minting (=too much DAI) then
  • \(\to\) interest \(\nearrow\) \(\to\) cost of DAI \(\nearrow\)
  • \(\to\) minting \(\searrow\) \(\to\) supply DAI \(\searrow\)

DSR paid on "locked" DAI

  • DAI deposited to specific contract (demand \(\nearrow\))
  • funded by stability fees
  • \(\to\) SF>DSR

total amount of debt (or DAI) outstanding is limited

Sidebar: how is this decided?
\(\to\) special "governance" token MKR

Value locked Oct 27, 2021

Maker DAO

Source: daistats.com (Oct 27, 2021)

Source: daistats.com (Oct 26, 2022)

The March 12, 2020 "BlAck Thursday" Drama

Maker DAO

  • some crypto prices dropped more than 50%
  • cascading liquidations in leveraging platforms
  • network congestion: some liquidations done at near-zero prices
  • collateral shortfall in DAI
  • MakerDAO sold new DAO tokens to collect collateral
  • odd: DAI became riskier but high demand for DAI to trigger liquidations!

PEG stability module (PSM)

Maker DAO

The Problem:

  • in extreme bull/bear runs, the peg may no longer work
  • example: March 2020
    • ETH dropped significantly and suddenly
    • a rush occurred to (a) get out of ETH into save assets and (b) to collect DAI to get keeper fee
    • upward pressure on price of DAI

The Solution:

  • Peg stability module
  •  swap a given collateral type directly for DAI at a fixed rate (no minting/borrowing)
  • like regular vault type with a zero stability fee and a liquidation ratio of 100%
  • accessed through a user-facing smart contract containing the relevant swap functions (no ownership, just straight swap)

Note: In May 2021, ETH prices dropped again by >30% but no drama in DAI

MakerDao's Peg Stability Module as an AMM

categories and assessment for defi

assessment of makerdao

Interest rates influenced by the FED, access to loan products controlled by regulation and institutional policies

MakerDAO platform is openly controlled by the MKR holders.

Difficulty of obtaining loans for large majority of population

Open ability to take out DAI liquidity against an overcollateralized position in any supported ERC20 token. Access to a competitive USD denominated return in DSR.

Costs of time and money to acquire a loan

Instant liquidity with minimal transaction costs.

Can't seamlessly use the same USD across many platforms

Issuance of DAI, a permissionless USD-tracking stablecoin backed by cryptocurrency. DAI can be used in any smart contract or DeFi application.

interoperability

inefficiency

centralized control

limited access

opacity

Unclear collateralization of lending institutions.

Transparent collateralization ratios of vaults visible to entire ecosystem

legacy finance

MakerDAO

The frontier: DAI loans for real-world assets

Maker DAO

Pool-based lending principles

collateral

compound Finance

  • Collateral ratio \(\in[0,90]\)
  • =0 \(\to\) not usable
  • =90 \(\to\) stablecoin
  • post 100 DAI 
  • factor 90
  • \(\to\) for each $1 borrow, deposit $100/90=$1.11
  • can borrow up to $90
  • post 1 ETH=$300 
  • factor 60
  • \(\to\) for each $1 borrowed, deposit $100/60=$1.67
  • can borrow up to $180

Example 1

Example 2

Example 3

  • post 1 ETH=$300 and 100 DAI \(\to\) $400
  • factor 60 and 90
  • \(\to\) for each $1 borrowed, deposit
    $100/(.75\(\cdot\)60+.25\(\cdot\) 90)=$1.48
  • can borrow up to $270

borrowing and lending rates compounded per block

Token Accounting:
tracking ownership

Compound

AAVE

Token Accounting: TWO Types

  • track ownership of pool holdings with receipt tokens
  • continuous updating of wallet balances

How does compound finance work?

Lending

Fundamentally, what does a bank do?

  • size intermediation
  • term intermediation
  • risk intermediation

And how is this done?

  • pooling deposits
  • issuing loans based on deposits
  • loan rates based on collateral or credit rating

on blockchain

  • short-term loans
  • pseudo-anonymous

how are the rates determined? - a function

compound Finance

100%

fraction of supplied that's been borrowed

base rate

borrow rate

\textsf{borrow rate}=\textsf{base rate}+\textsf{slope coefficient}\times\textsf{\% borrowed}
\textsf{supply rate}=\textsf{borrow rate}\times\textsf{\% (borrowed}-\textsf{reserve)}

token accounting

Compound

  • deposit: add \(q_0\) units of \(A\)-tokens into a  pool that contains \(Q_0$\)
  • assume:  \(Q^c_0\)  units of the  $cA$-receipt tokens outstanding already
  • User receives  \(q^c\) receipt \[  \frac{q^c}{Q_0^c+q^c}=\frac{q_0}{Q_0+q_0}.\]
  • Exchange rate: \(z_t=\frac{Q_t}{Q_t^c}\)  of \(A\) to \(cA\)-tokens.
  • Interest accrues so that pool contains \(Q_T>Q_t\) of the \(A\) token after time \(T\)
  • When withdrawing, users sends \(q^c\) tokens to the contract
  • Receives \(q_T>q_0\) of the \(A\)-token at exchange rate \(z_t>z_0\) where \[q_{T}=Q^c \times z_{T}\]

compound Finance

  • Compound escrows tokens
  • must account for % ownership
  • \(\to\) tokenized user share
  • \(\to\) use the c-token
    • cDAI
    • cETH
  • minted/burned based on funds added/removed from underlying
  • seamless movement of these shares (reduced transactions costs!)
  • ability to use the ctokens in other protocols

Tracking ownership - How do you reclaim a deposit?

Tracking ownership - Example

compound Finance

In Compound

translated

new deposit

1,000 DAI

100 cDAI

500 DAI

add 50 new cDAI

Tracking ownership - Example

compound Finance

In Compound

translated

new deposit

1,000 DAI

150 cDAI

500 DAI

1 year later: 10% interest on compound

150 DAI

(same cDAI, ownership shares don't change, just each cDAI is worth more)

(accrues per block per deposit)

AAVE

Differences to Compound

Aave

  • Aave is the second-largest lending protocol to date
  • has many features that are similar to Compound
  • offers more assets
  • offers flash loans (rate ~7bs)
  • token accounting done by continuous updating of token balance

token accounting

Aave

  • User makes a deposit continuously receives "a-tokens"
  • Supply:
    • \(Q_0\) units of an asset \(A\) token to the Aave pool obtains  
    • \(Q_0\) units of \(aA\)-tokens
  • balance updates continuously (\to\) claim on more \(aA\) tokens
  • To withdraw after \(T\) interest periods: sends  her \(Q_T\) \(aA\)-tokens to the contract, where
    \[Q_T= Q_0\prod_{t=1}^{T}{(1+r_t)}\]
  • \(t\) measured in blocks
  • \(r_t=\) interest allocated per block \(t\)

Liquidity Mining

Flash Loans

common theme in DeFi: jumping between dApps

  • Assume 
    • 1 ETH = 200 DAI
    • supplied 100 ETH in Compound
    • borrowed 10,000 DAI to lever up and purchase an additional 50 ETH
    • \(\to\) also supplied to Compound
    • Borrow interest rate in DAI
      • Compound: 15%
      • Aave: 5%.
  • ​Can you refinance your borrowing?

dapp-linking

Defi is like real "high" finance

Source: Harvey, Ramachandran, and Santoro (2020)

Dapp composability & Flash loans

1. flash-borrow DAI

5. repay DAI

3. receive ETH

4. convert ETH to DAI

2. liquidate ETH loan with DAI

Loan liquidation opportunity

Commercial Paper/T-Bill like securities

YIELD Protocol

  • basic idea: zero-coupon loans
  • You have:
    • target asset
    • collateral
    • y-token trading at discount price 
  • examples: yDAI
  • expires in 1 year
  • price: $.92
  • backed by ETH
  • buying = you earn 8/92 cents=8.7% RoR

YIELD example

1 ETH = 150 DAI
collateralization ratio 125%

seller

buyer

Assumptions

supplies 1 ETH collateral today

mints (=borrows) 100 yDAI to be repaid in 1 year

y

receives 92 DAI today

pays 92 DAI today

y

receives 100 yDAI

repays loan with 100 DAI

deposits yDAI and receives 100 DAI

YIELD example: scenarios

seller

buyer

Scenario 1: ETH \(\ge\)125 DAI

deposits 100 yDAI

withdraws 100 DAI

receives balance of 1 ETH - 100 DAI

What does the seller own (ignore keeper fee)?

  • 92 Dai (the loan)
  • 0.2 ETH x price(ETH)=25 DAI (assume price=125)

seller

buyer

Scenario 2: ETH falls to <125 DAI

keeper

closes undercollateralized position \(\to\) sells 0.8 ETH for 100 DAI

receives 100 DAI early

receives balance
of 0.2 ETH

categories of finance

What do banks/financial institutions do?

disclaimer: an incomplete list

Bitcoin, 

stablecoins, etc.

"higher layer"

lending
 

payments processing

financial
advice

trading
services

funding
services

prop trading to manage risks

too early, but projects are underway

as it turns out, these items are often directly related

what could defi do?

Five key problems in finance

Defi vs Legacy finance

interoperability

inefficiency

centralized control

limited access

opacity

interchange (=VISA) fees, settlement times, microtransactions, physical infrastructure

between-institution or transfers, reconciliation process, international remittances, various securities custody and trading systems

information for users, health of deposit taker, what-happens-behind-the-scenes, counterparty risk

local monopolies/switching costs, central banking, deposit concentration, control vs. competition

1.7B unbanked in the world, 24M in the US, many services or products not available based on location etc, lack of SME support, inability to collateralize

Source: Wendy Rotenberg's Payments lecture

payments pieces

simplified view

CDS

ACSS

LVTS

Cheques
 

Debit at POS
 

e-transfer
 

Credit Card/
open loop

ATMs
 

Wire
 

Interac
 

Credit
Card

deposit based retail

Interac standard

credit card network

SWIFT

CSN

Settlement

Clearing process

Underlying network

Type of payment

Financial market infrastructure purpose

Securities Trading

why blockchain?

a common resource

e-transfer
 

Wire
 

deposit based retail

CDS

Securities Trading

derivatives
swaps

property registry

interoperability

inefficiency

centralized control

limited access

opacity

siloed legacy system

is interoperable by design

reduces frictions and separates service from "commodity" 

decentralized control and common operation

fewer barriers\(\to\) broad access 

is/can be highly transparent

common infrastructure system

categories and assessment for defi

Our focus

interoperability

inefficiency

centralized control

limited access

opacity

  • What do the projects do?
     
  • How do these projects improve on legacy limitations?

payments
 

lending
 

trading
services

funding
services

prop trading  
manage risks

@financeUTM

andreas.park@rotman.utoronto.ca

slides.com/ap248

sites.google.com/site/parkandreas/

youtube.com/user/andreaspark2812/

Blockchain 2: DeFi Lending 2023

By Andreas Park

Blockchain 2: DeFi Lending 2023

This slide deck provides an overview of DeFi protocols. It draws insights from Harvey, Ramachandran, and Santoro (2020) "DeFi and the Future of Finance"

  • 322