You are on page 1of 59

Summer School, University of Zurich, Switzerland, July 5, 2023

Web3 & Decentralized Finance (DeFi)


Applications

Krzysztof Gogól
Communication Systems Group CSG, Department of Informatics IfI
University of Zürich UZH
gogol@ifi.uzh.ch
About Me

❏ Tech Entrepreneur
❏ PhD Candidate in
Computer Science at
University of Zurich
❏ Research areas
■ Decentralized Finance
■ DeFi on L2
■ Blockchain Interoperability
Agenda

❏ Introduction to Web3
❏ Introduction to DeFi
- Synthetic Tokens
Liquid Staking
Stablecoins
Wrapped Tokens
- Lending Protocols
- AMM DEX
- Aggregators & Yield Farming
❏ Risks & Challenges
Introduction to Web3

Web3

DeFi vs TradFi
TVL

Web3, Blockchain, Crypto


Introduction to Web3
Read-only Read-Write Read-Write-Own
Introduction to Web3

❑ Gavin Wood, the co-founder of Ethereum and founder


of Polkadot created the term “Web3” in 2014 as
– “decentralized online ecosystem based on blockchain.”

❑ Evolution of Web
– The first generation of web applications just allowed to read
content (e.g. Google, Wikipedia)
– The second generation has offered more interaction in
reading and writing (e.g. YouTube, TikTok)
– Web3, as a third generation, allow users to read, write, and
own the content they contribute
Introduction to Web3

Web1 Web2 Web3

Economy Information Platform Ownership

Applications Search, Ecommerce Social Media dApps, NFTs, DeFi

Data (content) Users access Users create and Users own content
information share content they create

Monetization Big Tech monetize user User monetize their data


data

Access Centralized Centralized Permissionless


Transparent

Control Centralized Centralized Autonomous


Code is the law
Open Source

Web3 applications achieve this by leveraging blockchain


networks and smart contracts.
Introduction to Web3

❑ Some argue Web3 is bringing social equality and fair


distribution of value to web applications:
– Web3 applications also allow users to directly interact with
each other, offering the option to sidestep big tech
companies, or other intermediaries.
– Web3 apps are permissionless: anybody can create or use
them.
– By decentralizing the applications, Web3 also decentralizes
control: apps are autonomous and code is the law.
Introduction to DeFi

DeFi

DeFi, CeFi, TradFi


Questions 0

Did you already invested in crypto or DeFi?


❑ Not yet
❑ I bought some crypto-currencies
❑ I have NFT
❑ I do staking
❑ I am a yield farmer (LPing at DEXs)
❑ I am a liquidity miner
❑ I am a degen - all of the above and much more
Degen = DeFi Trader
Questions 0

How do you store your tokens?


– …
– …
Questions 1

Which statement about DeFi is false?


❑ DeFi is politically centralized
❑ DeFi users are in control of their private keys
❑ DeFi is environmentally friendly
❑ DeFi can be incorporated into high-frequency trading
What is DeFi?

TradFi CeFi DeFi

Traditional Finance Centralized Finance Decentralized Finance

BC Business Model ◯ ⬤ ⬤

BC Settlement ◯ ◐ ⬤

Non-custodial ◯ ◯ ⬤

DAO Governance ◯ ◯ ◐

BC=Blockchain

❑ DeFi refers to the financial application


that rely on blockchain for security and integrity Not your key,
not your coin
❑ DeFi users remain in the custody of their tokens
(own their private key to the wallet)
What is the Difference to TradFi

❑ No Intermediaries
– Parties interact directly with smart contracts
❑ Permissionless
– Use of financial application and products
– Creation of financial products
❑ Code is the law
– Smart/financial contract is immutable
– Smart contract decides on state changes
What is the Difference to TradFi

TradFi DeFi

Settlement 2-3 days (-5% fees) Within a block (ca 8s)

Interaction Through financial intermediaries Direct via smart contracts

Efficiency High costs Low costs (L2s), frictional trading

Trust Enforced by regulation Code is the law


(smart contract is immutable)

Transparency No Full, enforced by cryptography

Access Restricted Permissionless


Anyone can create or interact with smart
contract - DeFi protocols and products

-> Investment Banks and Central Banks experiment with


blockchain as settlement layer and DeFi as trading venues
Benefits of DeFi

❑ Accessibility
– Democratization of financial services
❑ Efficiency
– Immediate settlement (few seconds)
– Open 24/7
– Borderless
– Low cost and scalability (L2s)
❑ Transparency
❑ Composability
Total Value Locked (TVL) in DeFi

Terra crash

FTX crash

Source: DeFi Llama


DeFi Protocols Covering 90% TVL
Synthetic Tokens
Liquid Staking
Stablecoins
Wrapped Tokens
Questions 2

Which one is the disadvantage of staking?


❑ it uses high amount of electricity
❑ it is very risky
❑ it requires freezing tokens
Staking

❑ Consensus mechanisms – ensures that all nodes in


the blockchain network has the same copy of ledger

❑ Proof-of-work (PoW) vs Proof-of-stake (PoS)


❑ PoW uses energy to solve the cryptographic puzzle
❑ PoS puts tokens “at stake” to assure BC security
❑ Staking - locking tokens in exchange for staking rewards
❑ Staking rewards come from transaction fees and inflation
Staking

Source: https://www.stakingrewards.com/
Synthetic Tokens

❑ Synthetic tokens maintain a peg to the target value

❑ Wrapped Tokens -> tokens from other blockchains


❑ Stablecoins -> fiat currency
❑ Liquid Staking -> staked tokens + staking rewards

❑ Synthetic token protocols build reserves to ensure


their tokens always have the redemption value
Liquid Staking

❑ Liquid Staking is a token, which value is pegged to


staked tokens
Benefits of Synthetic Tokens

❑ Liquid Staking Tokens


– are freely traded at exchanges
– can be further used in other DeFi to generate more yield
❑ Stablecoins
– allow to escape the volatility of cryptocurrencies
❑ Wrapped Tokens
– Provide interoperability between various blockchains
Risks of Synthetic Tokens

❑ De-peg risk
– risk that the synthetic tokens loses peg to the target value
❑ Examples
– USDC, fiat-backed stablecoin with 10% reserves in SVB (left)
– UST, Terra/Luna was algorithmic stablecoins (right)
Synthetic Tokens are on the Rise

Largest Cryptocurrencies by Market Cap, Source: CoinGecko


Interest Rate (Lending) Protocols

Borrowing
Lending
Questions 3

Which statement about DeFi lending is false?


❑ DeFi users can both borrow and lend tokens
❑ DeFi lending (with exception of flash-loans) is
over-collateralized
❑ Interest rates are decided in a DAO vote
❑ Flash loan can have any size without any collateral
DeFi Lending

TradFi DeFi DeFi

Banks Interest rate Crypto-backed Flash Loan


protocols stablecoin

Lend Yes Yes No No

Borrow Yes Yes Yes Yes

KYC Yes No No No

Collateral Partial Over-collateralized Over-collateralized No collateral

Interest rate Dynamic Smart contract 0-1% 0

Maturity Fixed Unlimited Unlimited 1 block

-> Flash loan is uncollateralized loan that must be returned


within the same block
Interest Rate Protocols

Source Aave
Interest Rate Protocols
❑ Interest Rates Protocols are smart contracts that implement formula for borrowing and
lending: kinked rates (most common)

where
- the utilization rate is the ratio of the total amount borrowed to the liquidity at time t
α is a constant, β describes the interest rate slope up to the optimal utilization rate
and γ >> β the slope for a higher utilization
λ - reserve factor
DeFi Looping (Leverage)
Decentralized Exchanges

DEX AMM
Questions 4

Which statement about AMM-DEX is false?


❑ All swaps are on-chain with no-counterparty risk
❑ You can swap or farm tokens at the AMM liquidity pool
❑ AMM-DEX uses order book to match buyers and
sellers
❑ Transaction costs are known in advance
Introduction: CEX vs DEX

CEX DEX

Traditional Exchange Centralized Exchange Decentralized Exchange

SIX, LSE Binance, Kraken, CoinBase dYdY

NYSE, NASDAQ SwissBorg, Bitcoin Suisse 0x

Central Limit Order Book (CLOB)


Uniswap, Balancer

SushiSwap, Curve
Automated Market Maker (AMM) Pancake Swap, Orca

- mathematical function
that algorithmically determines
the exchange price between tokens
AMM DEX

❑ Constant Sum Market Maker


❑ Constant Product Market Maker
❑ Constant Mean Market Maker

❑ Stableswap Invariant

* If the liquidity pool contains two tokens, the two


reserves are referred to as x and y
DeFi Composability
AMM Example

❑ Price of 1 ETH is 1800 USD


❑ Pool of 100 ETH and 180 000 USDC
– 100 (ETH) * 180 000 (USDC) = 18 000 000
❑ We buy 1 ETH from this pool for y USDC
– 99 (ETH) * y (USDC) = 18 000 000
– y = 181 818
– 99 (ETH) * 181 818 (USDC) = 18 000 000
❑ We paid for 1 ETH: 1 818 (= 181 818 - 180 000)
– Slippage costs: 1 818 - 1 800 = 18
AMM DEX

❑ The traditional order-book trading is not practical


for blockchains due to latency and data costs
❑ Pros of AMMs:
– All swaps are on-chain with no-counterparty risk
– Transaction costs are known in advance
❑ Cons of AMMs:
– Low speed for some traders
– Limits to price discovery to mitigate losses of liquidity
providers
❑ Is it worth to provide liquidity to AMM pools?
AMM Risks

❑ Impermanent Loss (for LPs)


– difference between holding tokens and allocating them to the
liquidity pool
– caused by every swap transaction, as they alter the liquidity
pool’s composition, increasing the value-losing token’s reserve

❑ Slippage Risk (for trader)


– difference between the spot and the realized swap price
– amplified by the larger swaps and smaller liquidity pools
Concentrated Liquidity AMM DEX

First introduced by Uniswap v3 to


increase capital efficiency in the pool

Consider a liquidity range interval


[pa, pb] around the current spot price pc,
then xreal and yreal denotes the
position real reserves

LPs (liquidity providers) choose price range


for which they provide liquidity
Aggregators

DEX Aggregators
Yield Farming
Yield Farming

❑ Yield Farming is a process of providing liquidity to DeFi


protocols, similar to liquidity provision of market makers in
TradFi, in exchange for participation in transaction fees

Yield Farming = Market Making (LPing)

❑ Liquidity Providers (LPs) are referred to as Yield Farmers. Any


blockchain user can become a yield farmer (permissionless).

Yield Farmers = LPs


Yield Farming Strategies

3. Liquidity
Best Provisions 1. Simple lending
execution
2. Leverage lending
DeFi Yield
Yield Farming Risk

Smart Contract-enabled Tokens Blockchain


Native Token

Web3
Synthetic Tokens Tokens

Liquid Wrapper Stablecoins


Staking

Source: Kamino Finance


Risks

DeFi Risks,
MEV attacks
Scalability Challanges
DeFi Risk

– DeFi Risk depends on 1) the protocol, 2) underlying tokens


3) way of using: Service Customer, Liquidity Provider,
Arbitrageur, Governance User
MEV = Maximum/Miner Extractable Value

❑ Profit made by validators/miners by reordering


transaction in the block
Scalability

❑ High Gas Fees


– caused by network congestions of Ethereum
❑ Two scaling strategies
– Layer 1 blockchains
• designing new blockchains (e.g., consensus)
• example: “Ethereum-killers”: Solana, BSC, Cardano, etc
– Layer 2 blockchains
• taking complex calculation off the Ethereum mainnet
• examples:
– Polygon
– Arbitrum, Optimism (optimistic roll-ups),
– zkSync, starkNet, zkEVM (zero knowledge roll-ups)
TVL by Blockchain

Layer-1 Blokchains Layer-2 on Ethereum

Terra crash

FTX crash

Source: The Block


Future Developments

❑ AMM and FX Market


❑ Central Bank Digital Currency (CBDC)
– Project Guardian: Uniswap, Aave for CBDCs
– Project Mariana: Curve for CBDCs
❑ Regenerative Finance (ReFi)
– DeFi for sustainable economic development
– move-to-earn models
❑ GameFi
– fusion of gaming, and DeFi
– play-to-earn models
Thank you

Research areas
❏ Decentralized Finance
❏ DeFi on L2
❏ Blockchain Interoperability

If you would like to continue the discussion, connect with me


Appendix

DeFi Protocol Classification


Token Classification
DeFi Classification
Token Classification
Recommended References
❑ CoinGecko, “How to DeFi, Beginner, Advanced”, 2020
❑ S. M. Werner, D. Perez, L. Gudgeon, A. Klages-Mundt, D. Harz, and W. J.
Knottenbelt, “SoK: Decentralized Finance (DeFi),”, 2020
❑ J. Xu, K. Paruch, S. Cousaert, and Y. Feng, “SoK: Decentralized Exchanges
(DEX) with Automated Market Maker (AMM) Protocols,” 2021
❑ L. Gudgeon, S. Werner, D. Perez, and W. J. Knottenbelt, “DeFi Protocols for
Loanable Funds: Interest Rates, Liquidity and Market Efficiency”, 2020,
❑ S. Cousaert, J. Xu, and T. Matsui, “SoK: Yield Aggregators in DeFi”, 2022
❑ S. Scharnowski and H. Jahanshahloo, “Liquid Staking: Basis Determinants
and Price Discovery,” 2022

You might also like