SlideShare a Scribd company logo

Stabilizing Algorithmic Stablecoins: the TerraLuna case study

The advent of blockchain technology has revolutionized the modern financial sector, ushering in a new era of decentralization and giving rise to the field of decentralized finance (DeFi). In this financial paradigm, stablecoins play a central role. These are digital currencies whose value is pegged to a stable asset, such as fiat currency. This thesis delves into one of the most ambitious categories of stablecoins: algorithmic stablecoins. Focusing on the Terra-Luna ecosystem, which demonstrated significant resilience from 2020 to 2022, the research unveils the mechanisms underlying these assets and analyzes the factors contributing to their stability. In the first part of the thesis, the foundations are laid by exploring the principles of blockchain technology, cryptoeconomics, and key components of DeFi. Subsequently, stablecoins are introduced, emphasizing their importance in digital commerce and DeFi applications. The two types of stablecoins are then outlined: collateralized stablecoins and their algorithmic counterparts. The core of this thesis investigates the Terra-Luna ecosystem, a network of algorithmic stablecoins that once thrived but collapsed dramatically in May 2022. Through a case study of the Terra-Luna collapse, the market dynamics and stability mechanism crucial for the temporary success and subsequent failure of this ecosystem are examined. This analysis extends to a broader exploration of dynamics leading to the collapse of algorithmic stablecoins, highlighting vulnerabilities and unique complexities of this innovative financial instrument. This thesis presents a formal model of algorithmic stablecoins. The model is implemented in a simulation program aiming to replicate the life cycle of algorithmic stablecoins, emphasizing conditions leading to the detachment from the peg value. The model operates at discrete time intervals, with transaction-level granularity allowing observation of emergent system properties. Two improvements to the stability mechanism implemented in the Terra protocol are also presented: the first involves the creation of a hybrid system with a collateral component to defend the peg during crises, while the second proposes the introduction of a new adaptive stability mechanism (i.e., one that can automatically adjust its behavior in crisis scenarios). Using the Dollar as a base, the simulations contextualize both normal market states and high-volatility scenarios, providing a rigorous examination of the system's robustness against fluctuations and speculative attacks. Simulation results highlight equilibrium and disequilibrium states of algorithmic stablecoins under variable conditions. Through this simulated environment, implications of specific parameters on stability, such as market volatility, liquidity pool fundamentals, and recovery periods related to the stability mechanism, are revealed.

1 of 118
Download to read offline
UNIVERSITY OF TRIESTE
Department of Engineering and Architecture
Master’s Degree in
Computer & Electronic Engineering
Stabilizing Algorithmic Stablecoins:
the Terra-Luna case study
December 6, 2023
Candidate Supervisor
Federico Calandra Prof. Francesco Fabris
A.Y. 2023/2024
Abstract
Versione italiana
L’avvento della tecnologia della blockchain ha rivoluzionato il moderno settore
finanziario, aprendo le porte ad una nuova era di decentralizzazione e dando vita
al campo della finanza decentralizzata (DeFi). In questo paradigma finanziario,
le stablecoin sono di assoluta centralità. Queste sono monete digitali il cui val-
ore è ancorato ad un asset stabile, come la valuta fiat. Il lavoro di questa tesi
approfondisce una delle categorie più ambiziose di stablecoin: le stablecoin al-
goritmiche. Concentrandosi sull’ecosistema Terra-Luna, che dal 2020 al 2022 ha
dimostrato grande resilienza, la ricerca svela i meccanismi alla base di questi asset
e analizza i fattori che contribuiscono alla loro stabilità.
Nella prima parte della tesi, vengono gettate le basi esplorando i principi della
blockchain technology, della cryptoeconomics e dei principali componenti della
DeFi. Successivamente, vengono introdotte le stablecoin, sottolineando la loro im-
portanza nel commercio digitale e nelle applicazioni DeFi. Vengono poi delineati
i due tipi di stablecoin: quelle collateralizzate e le loro controparti algoritmiche.
Il nucleo di questa tesi indaga sull’ecosistema Terra-Luna, una rete di stablecoin
algoritmiche che un tempo prosperava ma che nel maggio del 2022 è collassata in
modo drammatico. Attraverso un case study relativo al collasso di Terra-Luna,
vengono quindi indagate ed esaminate le dinamiche di mercato e il meccanismo di
stabilità che sono stati fondamentali per il temporaneo successo e il successivo falli-
mento di questo ecosistema. Questa analisi si estende a un’esplorazione più ampia
delle dinamiche che portano le stablecoin algoritmiche al collasso, evidenziando le
vulnerabilità e le complessità uniche di questo innovativo strumento finanziario.
Con questa tesi viene presentato un modello formale di stablecoin algoritmica. Tale
modello verrà poi implementato in un programma di simulazione che ha l’obiettivo
di replicare il ciclo di vita delle stablecoin algoritmiche, sottolineando le condizioni
che portano al distacco dal valore di peg. Il modello opera a intervalli di tempo
discreti, con una granularità a livello di transazione che ci permette di osservare
alcune proprietà emergenti del sistema. Vengono inoltre presentati due migliora-
menti al meccanismo di stabilità implementato nel protocollo di Terra: il primo è
I
CHAPTER 0. ABSTRACT
relativo alla creazione di un sistema ibrido che comprenda una quota di collaterale
che possa difendere il peg in periodi di crisi, il secondo propone l’introduzione di un
nuovo meccanismo di stabilità adattivo (i.e. che possa adattare automaticamente
il proprio comportamento a scenari di crisi). Utilizzando il Dollaro come base, le
simulazioni contestualizzano sia uno stato normale del mercato che gli scenari ad
alta volatilità, fornendo un’esame rigoroso della robustezza del sistema contro le
fluttuazioni e gli attacchi speculativi. I risultati delle simulazioni evidenziano gli
stati di equilibrio e disequilibrio delle stablecoin algoritmiche in condizioni vari-
abili. Attraverso questo ambiente simulato, riveliamo le implicazioni di specifici
parametri sulla stabilità, come la volatilità di mercato, le basi dei pool di liquidità
e i periodi di recupero relativi al meccanismo di stabilità.
In conclusione, questa tesi presenta un’analisi teorica ed empirica approfondita
delle complessità delle stablecoin algoritmiche. Analizzando il caso di Terra-Luna
e proponendo simulazioni approfondite, questo studio contribuisce con nuove in-
tuizioni alla discussione in corso sulla fattibilità e sicurezza di questi asset digitali,
aprendo la strada a design più resilienti. Le rivelazioni e le metodologie discusse
mirano a sostenere lo sviluppo di sistemi finanziari più sicuri e stabili nell’ambito
della DeFi.
English version
The advent of blockchain technology has revolutionized the modern financial sec-
tor, ushering in a new era of decentralization and giving rise to the field of de-
centralized finance (DeFi). In this financial paradigm, stablecoins play a central
role. These are digital currencies whose value is pegged to a stable asset, such as
fiat currency. This thesis delves into one of the most ambitious categories of sta-
blecoins: algorithmic stablecoins. Focusing on the Terra-Luna ecosystem, which
demonstrated significant resilience from 2020 to 2022, the research unveils the
mechanisms underlying these assets and analyzes the factors contributing to their
stability.
In the first part of the thesis, the foundations are laid by exploring the prin-
ciples of blockchain technology, cryptoeconomics, and key components of DeFi.
Subsequently, stablecoins are introduced, emphasizing their importance in digital
commerce and DeFi applications. The two types of stablecoins are then outlined:
collateralized stablecoins and their algorithmic counterparts. The core of this the-
sis investigates the Terra-Luna ecosystem, a network of algorithmic stablecoins
that once thrived but collapsed dramatically in May 2022. Through a case study
of the Terra-Luna collapse, the market dynamics and stability mechanism crucial
for the temporary success and subsequent failure of this ecosystem are examined.
This analysis extends to a broader exploration of dynamics leading to the collapse
II
CHAPTER 0. ABSTRACT
of algorithmic stablecoins, highlighting vulnerabilities and unique complexities of
this innovative financial instrument.
This thesis presents a formal model of algorithmic stablecoins. The model is im-
plemented in a simulation program aiming to replicate the life cycle of algorithmic
stablecoins, emphasizing conditions leading to the detachment from the peg value.
The model operates at discrete time intervals, with transaction-level granularity
allowing observation of emergent system properties. Two improvements to the sta-
bility mechanism implemented in the Terra protocol are also presented: the first
involves the creation of a hybrid system with a collateral component to defend the
peg during crises, while the second proposes the introduction of a new adaptive
stability mechanism (i.e., one that can automatically adjust its behavior in crisis
scenarios).
Using the Dollar as a base, the simulations contextualize both normal market
states and high-volatility scenarios, providing a rigorous examination of the sys-
tem’s robustness against fluctuations and speculative attacks. Simulation results
highlight equilibrium and disequilibrium states of algorithmic stablecoins under
variable conditions. Through this simulated environment, implications of specific
parameters on stability, such as market volatility, liquidity pool fundamentals, and
recovery periods related to the stability mechanism, are revealed.
In conclusion, this thesis presents a comprehensive theoretical and empirical anal-
ysis of the complexities of algorithmic stablecoins. By examining the case of Terra-
Luna and proposing in-depth simulations, this study contributes new insights to
the ongoing discussion on the feasibility and security of these digital assets, paving
the way for more resilient designs. The revelations and methodologies discussed
aim to support the development of safer and more stable financial systems within
the realm of DeFi.
III
Contents
Abstract I
1 Introduction to Blockchain Technology 1
1.1 Defining Blockchain Technology . . . . . . . . . . . . . . . . . . . . 1
1.2 Historical Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Fundamental Concepts . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.1 Distributed Ledger . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.2 Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3.3 Consensus Mechanisms . . . . . . . . . . . . . . . . . . . . . 5
1.3.4 Immutability . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3.5 Transparency . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4.1 Finance and Digital Currencies . . . . . . . . . . . . . . . . 7
1.4.2 Supply Chain Management . . . . . . . . . . . . . . . . . . . 8
1.4.3 Healthcare and Medical Records . . . . . . . . . . . . . . . . 8
1.4.4 Intellectual Property and Copyright . . . . . . . . . . . . . . 9
1.4.5 Voting and Elections . . . . . . . . . . . . . . . . . . . . . . 9
2 Cryptocurrencies 10
2.1 Overview of the Main Cryptocurrencies . . . . . . . . . . . . . . . . 10
2.2 Cryptocurrency Market Growth . . . . . . . . . . . . . . . . . . . . 11
2.3 Future Trends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.4 Cryptoeconomics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3 Decentralized Finance (DeFi) 16
3.1 Decentralized Exchanges (DEXs) . . . . . . . . . . . . . . . . . . . 19
3.2 Automated Market Makers (AMMs) . . . . . . . . . . . . . . . . . 19
3.3 Uniswap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3.1 Uniswap Protocol: Core Concepts . . . . . . . . . . . . . . . 22
3.3.2 Liquidity Pool . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3.3 Constant Function Market Maker (CFMM) . . . . . . . . . 23
IV
CONTENTS
3.3.4 Swaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.3.5 Fee Structure and Returns . . . . . . . . . . . . . . . . . . . 25
3.3.6 Price Oracles . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4 Stablecoins 27
4.1 The Rise and Role of Stablecoins . . . . . . . . . . . . . . . . . . . 27
4.2 Collateralized Stablecoins . . . . . . . . . . . . . . . . . . . . . . . 30
4.3 USDC Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.4 Algorithmic Stablecoins . . . . . . . . . . . . . . . . . . . . . . . . 32
4.4.1 Seigniorage . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.4.2 Pegging Mechanism of Algorithmic stablecoins . . . . . . . . 34
4.4.3 Advantages and Disadvantages . . . . . . . . . . . . . . . . 35
4.5 The Terra-Luna Ecosystem . . . . . . . . . . . . . . . . . . . . . . . 36
4.5.1 Supply and Demand Mechanism . . . . . . . . . . . . . . . . 37
4.5.2 The Terra Algorithmic Market Module . . . . . . . . . . . . 39
4.5.3 Imposition of Swap Fees . . . . . . . . . . . . . . . . . . . . 41
4.6 The Terra-Luna Collapse . . . . . . . . . . . . . . . . . . . . . . . . 41
4.6.1 The De-Pegging Event . . . . . . . . . . . . . . . . . . . . . 43
4.6.2 The Chronology of Events Leading to Collapse . . . . . . . . 44
4.6.3 Analysis of the Terra Collapse . . . . . . . . . . . . . . . . . 46
4.6.4 Lessons Learned and Implications . . . . . . . . . . . . . . . 48
5 The Model Proposed 49
5.1 The Set-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.2.1 Liquidity Pool . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.2.2 Swap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.2.3 Token Value . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.2.4 Token Price . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.2.5 Peg Loss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.3 Wallets Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.4 Simulated Liquidity Pools . . . . . . . . . . . . . . . . . . . . . . . 53
5.4.1 Stochastic Swaps . . . . . . . . . . . . . . . . . . . . . . . . 55
5.4.2 Total Token Quantity . . . . . . . . . . . . . . . . . . . . . . 56
5.4.3 Stablecoin Price Collapse . . . . . . . . . . . . . . . . . . . . 57
5.5 Stabilization Mechanism . . . . . . . . . . . . . . . . . . . . . . . . 60
5.5.1 Virtual Liquidity Pool . . . . . . . . . . . . . . . . . . . . . 60
5.5.2 Pool Replenishing . . . . . . . . . . . . . . . . . . . . . . . . 60
5.6 The Complete Model . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.7 Optimal Yield Computation . . . . . . . . . . . . . . . . . . . . . . 63
5.8 System Improvement Proposals . . . . . . . . . . . . . . . . . . . . 65
V
Ad

Recommended

A COMPREHENSIVE STUDY OF CRYPTOCURRENCY SYSTEMS
A COMPREHENSIVE STUDY OF CRYPTOCURRENCY SYSTEMSA COMPREHENSIVE STUDY OF CRYPTOCURRENCY SYSTEMS
A COMPREHENSIVE STUDY OF CRYPTOCURRENCY SYSTEMSStephen Faucher
 
The Global Crypto Classification Standard by 21Shares & CoinGecko
The Global Crypto Classification Standard by 21Shares & CoinGeckoThe Global Crypto Classification Standard by 21Shares & CoinGecko
The Global Crypto Classification Standard by 21Shares & CoinGeckoCoinGecko
 
Statistical Arbitrage Pairs Trading, Long-Short Strategy
Statistical Arbitrage Pairs Trading, Long-Short StrategyStatistical Arbitrage Pairs Trading, Long-Short Strategy
Statistical Arbitrage Pairs Trading, Long-Short Strategyz-score
 
Increasing Privacy in Smart Contracts: Exploring Encryption Mechanisms
Increasing Privacy in Smart Contracts: Exploring Encryption MechanismsIncreasing Privacy in Smart Contracts: Exploring Encryption Mechanisms
Increasing Privacy in Smart Contracts: Exploring Encryption MechanismsRadhaKrishna342833
 
Introduction to Bitcoin and ECDSA
Introduction to Bitcoin and ECDSAIntroduction to Bitcoin and ECDSA
Introduction to Bitcoin and ECDSANikesh Mistry
 
Market microstructure simulator. Overview.
Market microstructure simulator. Overview.Market microstructure simulator. Overview.
Market microstructure simulator. Overview.Anton Kolotaev
 
REDACTABLE BLOCKCHAIN .How to change the immutable and the consequences of do...
REDACTABLE BLOCKCHAIN .How to change the immutable and the consequences of do...REDACTABLE BLOCKCHAIN .How to change the immutable and the consequences of do...
REDACTABLE BLOCKCHAIN .How to change the immutable and the consequences of do...eraser Juan José Calderón
 

More Related Content

Similar to Stabilizing Algorithmic Stablecoins: the TerraLuna case study

Nduati Michelle Wanjiku Undergraduate Project
Nduati Michelle Wanjiku Undergraduate ProjectNduati Michelle Wanjiku Undergraduate Project
Nduati Michelle Wanjiku Undergraduate ProjectMichelle Nduati
 
Whitepaper on distributed ledger technology
Whitepaper on distributed ledger technologyWhitepaper on distributed ledger technology
Whitepaper on distributed ledger technologyUnder the sharing mood
 
Data replication (software)
Data replication (software) Data replication (software)
Data replication (software) Masoud Gholami
 
Ssrn id670543
Ssrn id670543Ssrn id670543
Ssrn id670543Aslan60
 
Clustering Financial Time Series and Evidences of Memory E
Clustering Financial Time Series and Evidences of Memory EClustering Financial Time Series and Evidences of Memory E
Clustering Financial Time Series and Evidences of Memory EGabriele Pompa, PhD
 
Affine Term-Structure Models Theory And Implementation
Affine Term-Structure Models  Theory And ImplementationAffine Term-Structure Models  Theory And Implementation
Affine Term-Structure Models Theory And ImplementationAmber Ford
 
LTE_from_Theory_to_Practise.pdf
LTE_from_Theory_to_Practise.pdfLTE_from_Theory_to_Practise.pdf
LTE_from_Theory_to_Practise.pdfATEC3
 
Blockchain analysis of regulation and tech related to distributed ledger-fi...
Blockchain   analysis of regulation and tech related to distributed ledger-fi...Blockchain   analysis of regulation and tech related to distributed ledger-fi...
Blockchain analysis of regulation and tech related to distributed ledger-fi...Ian Beckett
 
0000. the blockchain-revolution-an-analysis-of-regulation-and-technolo
0000. the blockchain-revolution-an-analysis-of-regulation-and-technolo0000. the blockchain-revolution-an-analysis-of-regulation-and-technolo
0000. the blockchain-revolution-an-analysis-of-regulation-and-technoloDr. Bikram Jit Singh
 
comparison_of_scada_protocols_and_implementation_of_iec_104_and_mqtt.pdf
comparison_of_scada_protocols_and_implementation_of_iec_104_and_mqtt.pdfcomparison_of_scada_protocols_and_implementation_of_iec_104_and_mqtt.pdf
comparison_of_scada_protocols_and_implementation_of_iec_104_and_mqtt.pdfteja61850
 
Data mining seminar report
Data mining seminar reportData mining seminar report
Data mining seminar reportmayurik19
 
Cryptocurrencies, Blockchain and Initial Coin Offerings
Cryptocurrencies, Blockchain and Initial Coin OfferingsCryptocurrencies, Blockchain and Initial Coin Offerings
Cryptocurrencies, Blockchain and Initial Coin Offeringssarah marville
 

Similar to Stabilizing Algorithmic Stablecoins: the TerraLuna case study (20)

Nduati Michelle Wanjiku Undergraduate Project
Nduati Michelle Wanjiku Undergraduate ProjectNduati Michelle Wanjiku Undergraduate Project
Nduati Michelle Wanjiku Undergraduate Project
 
Whitepaper on distributed ledger technology
Whitepaper on distributed ledger technologyWhitepaper on distributed ledger technology
Whitepaper on distributed ledger technology
 
Data replication (software)
Data replication (software) Data replication (software)
Data replication (software)
 
vatter_pdm_1.1
vatter_pdm_1.1vatter_pdm_1.1
vatter_pdm_1.1
 
HHT Report
HHT ReportHHT Report
HHT Report
 
thesis
thesisthesis
thesis
 
main
mainmain
main
 
Ssrn id670543
Ssrn id670543Ssrn id670543
Ssrn id670543
 
Block chain
Block chainBlock chain
Block chain
 
Clustering Financial Time Series and Evidences of Memory E
Clustering Financial Time Series and Evidences of Memory EClustering Financial Time Series and Evidences of Memory E
Clustering Financial Time Series and Evidences of Memory E
 
Affine Term-Structure Models Theory And Implementation
Affine Term-Structure Models  Theory And ImplementationAffine Term-Structure Models  Theory And Implementation
Affine Term-Structure Models Theory And Implementation
 
LTE_from_Theory_to_Practise.pdf
LTE_from_Theory_to_Practise.pdfLTE_from_Theory_to_Practise.pdf
LTE_from_Theory_to_Practise.pdf
 
Blockchain analysis of regulation and tech related to distributed ledger-fi...
Blockchain   analysis of regulation and tech related to distributed ledger-fi...Blockchain   analysis of regulation and tech related to distributed ledger-fi...
Blockchain analysis of regulation and tech related to distributed ledger-fi...
 
0000. the blockchain-revolution-an-analysis-of-regulation-and-technolo
0000. the blockchain-revolution-an-analysis-of-regulation-and-technolo0000. the blockchain-revolution-an-analysis-of-regulation-and-technolo
0000. the blockchain-revolution-an-analysis-of-regulation-and-technolo
 
comparison_of_scada_protocols_and_implementation_of_iec_104_and_mqtt.pdf
comparison_of_scada_protocols_and_implementation_of_iec_104_and_mqtt.pdfcomparison_of_scada_protocols_and_implementation_of_iec_104_and_mqtt.pdf
comparison_of_scada_protocols_and_implementation_of_iec_104_and_mqtt.pdf
 
Data mining seminar report
Data mining seminar reportData mining seminar report
Data mining seminar report
 
DM_DanielDias_2020_MEI.pdf
DM_DanielDias_2020_MEI.pdfDM_DanielDias_2020_MEI.pdf
DM_DanielDias_2020_MEI.pdf
 
project report(1)
project report(1)project report(1)
project report(1)
 
Cryptocurrencies, Blockchain and Initial Coin Offerings
Cryptocurrencies, Blockchain and Initial Coin OfferingsCryptocurrencies, Blockchain and Initial Coin Offerings
Cryptocurrencies, Blockchain and Initial Coin Offerings
 
PFC
PFCPFC
PFC
 

Recently uploaded

National Income National Income National Income
National Income National Income National IncomeNational Income National Income National Income
National Income National Income National Income19920606201903202019
 
Q4 2023 Conference Call Presentation FINAL-v4.pdf
Q4 2023 Conference Call Presentation FINAL-v4.pdfQ4 2023 Conference Call Presentation FINAL-v4.pdf
Q4 2023 Conference Call Presentation FINAL-v4.pdfAdnet Communications
 
2024.02-The-radical-option-in-UK-pensions-New-Financial.pdf
2024.02-The-radical-option-in-UK-pensions-New-Financial.pdf2024.02-The-radical-option-in-UK-pensions-New-Financial.pdf
2024.02-The-radical-option-in-UK-pensions-New-Financial.pdfHenry Tapper
 
Stock Market Brief Deck for 2:22 youtube vid.pdf
Stock Market Brief Deck for 2:22 youtube vid.pdfStock Market Brief Deck for 2:22 youtube vid.pdf
Stock Market Brief Deck for 2:22 youtube vid.pdfMichael Silva
 
Stock Market Brief Deck for 2/21/24 .pdf
Stock Market Brief Deck for 2/21/24 .pdfStock Market Brief Deck for 2/21/24 .pdf
Stock Market Brief Deck for 2/21/24 .pdfMichael Silva
 
Indistinguishable from Magic: How the Cybersecurity Market Reached a Trillion...
Indistinguishable from Magic: How the Cybersecurity Market Reached a Trillion...Indistinguishable from Magic: How the Cybersecurity Market Reached a Trillion...
Indistinguishable from Magic: How the Cybersecurity Market Reached a Trillion...Adrian Sanabria
 
20240220 Calibre Q4 and FY 2023 Conference Call Present.pdf
20240220 Calibre Q4 and FY 2023 Conference Call Present.pdf20240220 Calibre Q4 and FY 2023 Conference Call Present.pdf
20240220 Calibre Q4 and FY 2023 Conference Call Present.pdfAdnet Communications
 
Demand and Supply Elasticity in Healthcare
Demand and Supply Elasticity in HealthcareDemand and Supply Elasticity in Healthcare
Demand and Supply Elasticity in HealthcareZulfiquer Ahmed Amin
 
Chartered accountant in delhi (top 10 CA in delhi)
Chartered accountant in delhi (top 10 CA in delhi)Chartered accountant in delhi (top 10 CA in delhi)
Chartered accountant in delhi (top 10 CA in delhi)supriyadmpinstitute
 
letter to the EF and Premiership about pension liabilities
letter to the EF and Premiership about pension liabilitiesletter to the EF and Premiership about pension liabilities
letter to the EF and Premiership about pension liabilitiesHenry Tapper
 
The Case for Commodities as an Asset Class.ppt
The Case for Commodities as an Asset Class.pptThe Case for Commodities as an Asset Class.ppt
The Case for Commodities as an Asset Class.pptJinzhiFeng1
 
99MW Nearshore Wind Farm in Colombia.pdf
99MW Nearshore Wind Farm in Colombia.pdf99MW Nearshore Wind Farm in Colombia.pdf
99MW Nearshore Wind Farm in Colombia.pdfVictoriaGaleano
 
business-model-canvas for collaborative business
business-model-canvas for collaborative businessbusiness-model-canvas for collaborative business
business-model-canvas for collaborative businessramijadpro
 
2023_-_Master_Trust___GPP_Defaults_Report (2).pdf
2023_-_Master_Trust___GPP_Defaults_Report (2).pdf2023_-_Master_Trust___GPP_Defaults_Report (2).pdf
2023_-_Master_Trust___GPP_Defaults_Report (2).pdfHenry Tapper
 
Shrambal_Distributors_February_Newsletter_2024.pdf
Shrambal_Distributors_February_Newsletter_2024.pdfShrambal_Distributors_February_Newsletter_2024.pdf
Shrambal_Distributors_February_Newsletter_2024.pdfvikashdidwania1
 
Slideshare - ONS Economic Forum Slidepack - 19 February 2024.pptx
Slideshare - ONS Economic Forum Slidepack - 19 February 2024.pptxSlideshare - ONS Economic Forum Slidepack - 19 February 2024.pptx
Slideshare - ONS Economic Forum Slidepack - 19 February 2024.pptxOffice for National Statistics
 
TIM GROUP FY '23 Preliminary Results.pdf
TIM GROUP FY '23 Preliminary Results.pdfTIM GROUP FY '23 Preliminary Results.pdf
TIM GROUP FY '23 Preliminary Results.pdfGruppo TIM
 
Cultural background and entrepreneurial spirit in retail - European Business ...
Cultural background and entrepreneurial spirit in retail - European Business ...Cultural background and entrepreneurial spirit in retail - European Business ...
Cultural background and entrepreneurial spirit in retail - European Business ...Antonis Zairis
 

Recently uploaded (19)

National Income National Income National Income
National Income National Income National IncomeNational Income National Income National Income
National Income National Income National Income
 
Q4 2023 Conference Call Presentation FINAL-v4.pdf
Q4 2023 Conference Call Presentation FINAL-v4.pdfQ4 2023 Conference Call Presentation FINAL-v4.pdf
Q4 2023 Conference Call Presentation FINAL-v4.pdf
 
2024.02-The-radical-option-in-UK-pensions-New-Financial.pdf
2024.02-The-radical-option-in-UK-pensions-New-Financial.pdf2024.02-The-radical-option-in-UK-pensions-New-Financial.pdf
2024.02-The-radical-option-in-UK-pensions-New-Financial.pdf
 
Stock Market Brief Deck for 2:22 youtube vid.pdf
Stock Market Brief Deck for 2:22 youtube vid.pdfStock Market Brief Deck for 2:22 youtube vid.pdf
Stock Market Brief Deck for 2:22 youtube vid.pdf
 
Stock Market Brief Deck for 2/21/24 .pdf
Stock Market Brief Deck for 2/21/24 .pdfStock Market Brief Deck for 2/21/24 .pdf
Stock Market Brief Deck for 2/21/24 .pdf
 
Indistinguishable from Magic: How the Cybersecurity Market Reached a Trillion...
Indistinguishable from Magic: How the Cybersecurity Market Reached a Trillion...Indistinguishable from Magic: How the Cybersecurity Market Reached a Trillion...
Indistinguishable from Magic: How the Cybersecurity Market Reached a Trillion...
 
20240220 Calibre Q4 and FY 2023 Conference Call Present.pdf
20240220 Calibre Q4 and FY 2023 Conference Call Present.pdf20240220 Calibre Q4 and FY 2023 Conference Call Present.pdf
20240220 Calibre Q4 and FY 2023 Conference Call Present.pdf
 
Demand and Supply Elasticity in Healthcare
Demand and Supply Elasticity in HealthcareDemand and Supply Elasticity in Healthcare
Demand and Supply Elasticity in Healthcare
 
Chartered accountant in delhi (top 10 CA in delhi)
Chartered accountant in delhi (top 10 CA in delhi)Chartered accountant in delhi (top 10 CA in delhi)
Chartered accountant in delhi (top 10 CA in delhi)
 
letter to the EF and Premiership about pension liabilities
letter to the EF and Premiership about pension liabilitiesletter to the EF and Premiership about pension liabilities
letter to the EF and Premiership about pension liabilities
 
The Case for Commodities as an Asset Class.ppt
The Case for Commodities as an Asset Class.pptThe Case for Commodities as an Asset Class.ppt
The Case for Commodities as an Asset Class.ppt
 
Monthly Economic Monitoring of Ukraine No.229, February 2024
Monthly Economic Monitoring of Ukraine No.229, February 2024Monthly Economic Monitoring of Ukraine No.229, February 2024
Monthly Economic Monitoring of Ukraine No.229, February 2024
 
99MW Nearshore Wind Farm in Colombia.pdf
99MW Nearshore Wind Farm in Colombia.pdf99MW Nearshore Wind Farm in Colombia.pdf
99MW Nearshore Wind Farm in Colombia.pdf
 
business-model-canvas for collaborative business
business-model-canvas for collaborative businessbusiness-model-canvas for collaborative business
business-model-canvas for collaborative business
 
2023_-_Master_Trust___GPP_Defaults_Report (2).pdf
2023_-_Master_Trust___GPP_Defaults_Report (2).pdf2023_-_Master_Trust___GPP_Defaults_Report (2).pdf
2023_-_Master_Trust___GPP_Defaults_Report (2).pdf
 
Shrambal_Distributors_February_Newsletter_2024.pdf
Shrambal_Distributors_February_Newsletter_2024.pdfShrambal_Distributors_February_Newsletter_2024.pdf
Shrambal_Distributors_February_Newsletter_2024.pdf
 
Slideshare - ONS Economic Forum Slidepack - 19 February 2024.pptx
Slideshare - ONS Economic Forum Slidepack - 19 February 2024.pptxSlideshare - ONS Economic Forum Slidepack - 19 February 2024.pptx
Slideshare - ONS Economic Forum Slidepack - 19 February 2024.pptx
 
TIM GROUP FY '23 Preliminary Results.pdf
TIM GROUP FY '23 Preliminary Results.pdfTIM GROUP FY '23 Preliminary Results.pdf
TIM GROUP FY '23 Preliminary Results.pdf
 
Cultural background and entrepreneurial spirit in retail - European Business ...
Cultural background and entrepreneurial spirit in retail - European Business ...Cultural background and entrepreneurial spirit in retail - European Business ...
Cultural background and entrepreneurial spirit in retail - European Business ...
 

Stabilizing Algorithmic Stablecoins: the TerraLuna case study

  • 1. UNIVERSITY OF TRIESTE Department of Engineering and Architecture Master’s Degree in Computer & Electronic Engineering Stabilizing Algorithmic Stablecoins: the Terra-Luna case study December 6, 2023 Candidate Supervisor Federico Calandra Prof. Francesco Fabris A.Y. 2023/2024
  • 2. Abstract Versione italiana L’avvento della tecnologia della blockchain ha rivoluzionato il moderno settore finanziario, aprendo le porte ad una nuova era di decentralizzazione e dando vita al campo della finanza decentralizzata (DeFi). In questo paradigma finanziario, le stablecoin sono di assoluta centralità. Queste sono monete digitali il cui val- ore è ancorato ad un asset stabile, come la valuta fiat. Il lavoro di questa tesi approfondisce una delle categorie più ambiziose di stablecoin: le stablecoin al- goritmiche. Concentrandosi sull’ecosistema Terra-Luna, che dal 2020 al 2022 ha dimostrato grande resilienza, la ricerca svela i meccanismi alla base di questi asset e analizza i fattori che contribuiscono alla loro stabilità. Nella prima parte della tesi, vengono gettate le basi esplorando i principi della blockchain technology, della cryptoeconomics e dei principali componenti della DeFi. Successivamente, vengono introdotte le stablecoin, sottolineando la loro im- portanza nel commercio digitale e nelle applicazioni DeFi. Vengono poi delineati i due tipi di stablecoin: quelle collateralizzate e le loro controparti algoritmiche. Il nucleo di questa tesi indaga sull’ecosistema Terra-Luna, una rete di stablecoin algoritmiche che un tempo prosperava ma che nel maggio del 2022 è collassata in modo drammatico. Attraverso un case study relativo al collasso di Terra-Luna, vengono quindi indagate ed esaminate le dinamiche di mercato e il meccanismo di stabilità che sono stati fondamentali per il temporaneo successo e il successivo falli- mento di questo ecosistema. Questa analisi si estende a un’esplorazione più ampia delle dinamiche che portano le stablecoin algoritmiche al collasso, evidenziando le vulnerabilità e le complessità uniche di questo innovativo strumento finanziario. Con questa tesi viene presentato un modello formale di stablecoin algoritmica. Tale modello verrà poi implementato in un programma di simulazione che ha l’obiettivo di replicare il ciclo di vita delle stablecoin algoritmiche, sottolineando le condizioni che portano al distacco dal valore di peg. Il modello opera a intervalli di tempo discreti, con una granularità a livello di transazione che ci permette di osservare alcune proprietà emergenti del sistema. Vengono inoltre presentati due migliora- menti al meccanismo di stabilità implementato nel protocollo di Terra: il primo è I
  • 3. CHAPTER 0. ABSTRACT relativo alla creazione di un sistema ibrido che comprenda una quota di collaterale che possa difendere il peg in periodi di crisi, il secondo propone l’introduzione di un nuovo meccanismo di stabilità adattivo (i.e. che possa adattare automaticamente il proprio comportamento a scenari di crisi). Utilizzando il Dollaro come base, le simulazioni contestualizzano sia uno stato normale del mercato che gli scenari ad alta volatilità, fornendo un’esame rigoroso della robustezza del sistema contro le fluttuazioni e gli attacchi speculativi. I risultati delle simulazioni evidenziano gli stati di equilibrio e disequilibrio delle stablecoin algoritmiche in condizioni vari- abili. Attraverso questo ambiente simulato, riveliamo le implicazioni di specifici parametri sulla stabilità, come la volatilità di mercato, le basi dei pool di liquidità e i periodi di recupero relativi al meccanismo di stabilità. In conclusione, questa tesi presenta un’analisi teorica ed empirica approfondita delle complessità delle stablecoin algoritmiche. Analizzando il caso di Terra-Luna e proponendo simulazioni approfondite, questo studio contribuisce con nuove in- tuizioni alla discussione in corso sulla fattibilità e sicurezza di questi asset digitali, aprendo la strada a design più resilienti. Le rivelazioni e le metodologie discusse mirano a sostenere lo sviluppo di sistemi finanziari più sicuri e stabili nell’ambito della DeFi. English version The advent of blockchain technology has revolutionized the modern financial sec- tor, ushering in a new era of decentralization and giving rise to the field of de- centralized finance (DeFi). In this financial paradigm, stablecoins play a central role. These are digital currencies whose value is pegged to a stable asset, such as fiat currency. This thesis delves into one of the most ambitious categories of sta- blecoins: algorithmic stablecoins. Focusing on the Terra-Luna ecosystem, which demonstrated significant resilience from 2020 to 2022, the research unveils the mechanisms underlying these assets and analyzes the factors contributing to their stability. In the first part of the thesis, the foundations are laid by exploring the prin- ciples of blockchain technology, cryptoeconomics, and key components of DeFi. Subsequently, stablecoins are introduced, emphasizing their importance in digital commerce and DeFi applications. The two types of stablecoins are then outlined: collateralized stablecoins and their algorithmic counterparts. The core of this the- sis investigates the Terra-Luna ecosystem, a network of algorithmic stablecoins that once thrived but collapsed dramatically in May 2022. Through a case study of the Terra-Luna collapse, the market dynamics and stability mechanism crucial for the temporary success and subsequent failure of this ecosystem are examined. This analysis extends to a broader exploration of dynamics leading to the collapse II
  • 4. CHAPTER 0. ABSTRACT of algorithmic stablecoins, highlighting vulnerabilities and unique complexities of this innovative financial instrument. This thesis presents a formal model of algorithmic stablecoins. The model is im- plemented in a simulation program aiming to replicate the life cycle of algorithmic stablecoins, emphasizing conditions leading to the detachment from the peg value. The model operates at discrete time intervals, with transaction-level granularity allowing observation of emergent system properties. Two improvements to the sta- bility mechanism implemented in the Terra protocol are also presented: the first involves the creation of a hybrid system with a collateral component to defend the peg during crises, while the second proposes the introduction of a new adaptive stability mechanism (i.e., one that can automatically adjust its behavior in crisis scenarios). Using the Dollar as a base, the simulations contextualize both normal market states and high-volatility scenarios, providing a rigorous examination of the sys- tem’s robustness against fluctuations and speculative attacks. Simulation results highlight equilibrium and disequilibrium states of algorithmic stablecoins under variable conditions. Through this simulated environment, implications of specific parameters on stability, such as market volatility, liquidity pool fundamentals, and recovery periods related to the stability mechanism, are revealed. In conclusion, this thesis presents a comprehensive theoretical and empirical anal- ysis of the complexities of algorithmic stablecoins. By examining the case of Terra- Luna and proposing in-depth simulations, this study contributes new insights to the ongoing discussion on the feasibility and security of these digital assets, paving the way for more resilient designs. The revelations and methodologies discussed aim to support the development of safer and more stable financial systems within the realm of DeFi. III
  • 5. Contents Abstract I 1 Introduction to Blockchain Technology 1 1.1 Defining Blockchain Technology . . . . . . . . . . . . . . . . . . . . 1 1.2 Historical Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Fundamental Concepts . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.1 Distributed Ledger . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.2 Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.3.3 Consensus Mechanisms . . . . . . . . . . . . . . . . . . . . . 5 1.3.4 Immutability . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.3.5 Transparency . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.4 Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.4.1 Finance and Digital Currencies . . . . . . . . . . . . . . . . 7 1.4.2 Supply Chain Management . . . . . . . . . . . . . . . . . . . 8 1.4.3 Healthcare and Medical Records . . . . . . . . . . . . . . . . 8 1.4.4 Intellectual Property and Copyright . . . . . . . . . . . . . . 9 1.4.5 Voting and Elections . . . . . . . . . . . . . . . . . . . . . . 9 2 Cryptocurrencies 10 2.1 Overview of the Main Cryptocurrencies . . . . . . . . . . . . . . . . 10 2.2 Cryptocurrency Market Growth . . . . . . . . . . . . . . . . . . . . 11 2.3 Future Trends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.4 Cryptoeconomics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3 Decentralized Finance (DeFi) 16 3.1 Decentralized Exchanges (DEXs) . . . . . . . . . . . . . . . . . . . 19 3.2 Automated Market Makers (AMMs) . . . . . . . . . . . . . . . . . 19 3.3 Uniswap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.3.1 Uniswap Protocol: Core Concepts . . . . . . . . . . . . . . . 22 3.3.2 Liquidity Pool . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.3.3 Constant Function Market Maker (CFMM) . . . . . . . . . 23 IV
  • 6. CONTENTS 3.3.4 Swaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.3.5 Fee Structure and Returns . . . . . . . . . . . . . . . . . . . 25 3.3.6 Price Oracles . . . . . . . . . . . . . . . . . . . . . . . . . . 25 4 Stablecoins 27 4.1 The Rise and Role of Stablecoins . . . . . . . . . . . . . . . . . . . 27 4.2 Collateralized Stablecoins . . . . . . . . . . . . . . . . . . . . . . . 30 4.3 USDC Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.4 Algorithmic Stablecoins . . . . . . . . . . . . . . . . . . . . . . . . 32 4.4.1 Seigniorage . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 4.4.2 Pegging Mechanism of Algorithmic stablecoins . . . . . . . . 34 4.4.3 Advantages and Disadvantages . . . . . . . . . . . . . . . . 35 4.5 The Terra-Luna Ecosystem . . . . . . . . . . . . . . . . . . . . . . . 36 4.5.1 Supply and Demand Mechanism . . . . . . . . . . . . . . . . 37 4.5.2 The Terra Algorithmic Market Module . . . . . . . . . . . . 39 4.5.3 Imposition of Swap Fees . . . . . . . . . . . . . . . . . . . . 41 4.6 The Terra-Luna Collapse . . . . . . . . . . . . . . . . . . . . . . . . 41 4.6.1 The De-Pegging Event . . . . . . . . . . . . . . . . . . . . . 43 4.6.2 The Chronology of Events Leading to Collapse . . . . . . . . 44 4.6.3 Analysis of the Terra Collapse . . . . . . . . . . . . . . . . . 46 4.6.4 Lessons Learned and Implications . . . . . . . . . . . . . . . 48 5 The Model Proposed 49 5.1 The Set-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 5.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 5.2.1 Liquidity Pool . . . . . . . . . . . . . . . . . . . . . . . . . . 50 5.2.2 Swap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 5.2.3 Token Value . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 5.2.4 Token Price . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 5.2.5 Peg Loss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 5.3 Wallets Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . 52 5.4 Simulated Liquidity Pools . . . . . . . . . . . . . . . . . . . . . . . 53 5.4.1 Stochastic Swaps . . . . . . . . . . . . . . . . . . . . . . . . 55 5.4.2 Total Token Quantity . . . . . . . . . . . . . . . . . . . . . . 56 5.4.3 Stablecoin Price Collapse . . . . . . . . . . . . . . . . . . . . 57 5.5 Stabilization Mechanism . . . . . . . . . . . . . . . . . . . . . . . . 60 5.5.1 Virtual Liquidity Pool . . . . . . . . . . . . . . . . . . . . . 60 5.5.2 Pool Replenishing . . . . . . . . . . . . . . . . . . . . . . . . 60 5.6 The Complete Model . . . . . . . . . . . . . . . . . . . . . . . . . . 61 5.7 Optimal Yield Computation . . . . . . . . . . . . . . . . . . . . . . 63 5.8 System Improvement Proposals . . . . . . . . . . . . . . . . . . . . 65 V
  • 7. CONTENTS 5.8.1 Reserve Pool . . . . . . . . . . . . . . . . . . . . . . . . . . 66 5.8.2 Replenishing System Modification . . . . . . . . . . . . . . . 67 6 Simulation Results 68 6.1 Normal Starting Conditions . . . . . . . . . . . . . . . . . . . . . . 68 6.2 Instability Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Conclusion 74 A Simulation Code 76 VI
  • 8. Chapter 1 Introduction to Blockchain Technology In this introductory chapter, we will briefly present the fundamental aspects of blockchain technology, uncovering its core principles and exploring its significant impact on the realms of finance, economics, and decentralized applications. This will be important in comprehending the essential elements behind algorithmic stablecoins and, more broadly, all cryptocurrencies. As we navigate the landscape of cryptocurrency, Decentralized Finance (DeFi), and stablecoins, a foundational understanding of blockchain technology is essential. This chapter is structured to build this foundation. It consists of four sections that progressively unveil the key aspects of blockchain technology: concisely defining what blockchain technology is, tracing its historical evolution, exploring its fundamental concepts, and finally, delving into some of its important real-world applications. 1.1 Defining Blockchain Technology The blockchain is a revolutionary distributed ledger technology that has gained widespread attention and adoption in various domains. At its core, a blockchain is a decentralized, digital ledger that records transactions across a network of computers. What makes blockchain distinctive is its ability to achieve consensus on the state of the ledger among its participants, without relying on a central authority. This key feature is mandatory in the case one wants to send/receive value to/from the network in a peer-to-peer transaction, since consensus on the state of the ledger means consensus on the consistency of the wallets associated with all users. All the transactions are verified and recorded in a transparent, immutable, and tamper-resistant manner, ensuring trust and security within the network. This means that all the wallets are safe and it is not possible to implement 1
  • 9. CHAPTER 1. INTRODUCTION TO BLOCKCHAIN TECHNOLOGY a double-spending action; this corresponds to the situation when a digital string is associated with a form of value, and one uses the same string more times to trigger several different transactions using the same quantity of value. This particular issue is unique to digital currencies and arises from the inherent replicability of digital assets. Unlike physical currency, which cannot be duplicated, digital coins and tokens can be easily copied or spent multiple times. The double-spending problem is, at its core, a threat to the integrity and trustworthiness of any digital currency system. The concept of a blockchain can be understood by breaking down its name: "block" and "chain". A blockchain is composed of a series of blocks, each con- taining a set of transactions. These blocks are cryptographically linked together in chronological order, forming a chain. Once a block is added to the chain, it becomes extremely challenging to alter the information it contains. This immutability and transparency make blockchains highly secure and reliable for various applications. 1.2 Historical Evolution To appreciate the significance of blockchain technology, it is essential to trace its historical roots. Although the term "blockchain" became widely recognized in the last decade, the foundational concepts date back to the early 1990s. A preliminary idea of a cryptographically secured chain of blocks was proposed by Stuart Haber and W. Scott Stornetta in 1991 [1]. Their work focused on the creation of a timestamped and tamper-proof digital document to ensure data integrity. One of the main theoretical challenges in the development of a secure and de- centralized system, without the presence of a trusted and central authority, is rep- resented by the Byzantine Generals’ Problem [2]. This problem revolves around the challenge of achieving consensus among a group of peer nodes in an asyn- chronous network, even in the presence of potentially faulty or malicious actors. It was formalized by Leslie Lamport, Robert Shostak, and Marshall Pease in a paper called the “Byzantine Generals’ Problem” [2], which states that “a reliable computer system must be able to cope with the failure of one or more of its compo- nents. A failed component may exhibit a type of behavior that is often overlooked – namely, sending conflicting information to different parts of the system”. This obstacle plagued the development of trustless systems since it can be shown that the solution to the double-spending problem can be reduced to the solution of the Byzantine Generals’ Problem in an asynchronous network; but, unfortunately, it has been proved a theorem that certifies that no solution is possible [3]. This the- oretical result posed an insurmountable barrier to the development of a trustless network for exchanging value. This was the set-up, at least until the emergence of Bitcoin in 2009 by an in- 2
  • 10. CHAPTER 1. INTRODUCTION TO BLOCKCHAIN TECHNOLOGY dividual (or group) using the pseudonym Satoshi Nakamoto. In this contribution it was proposed a brilliant solution that, without invalidating the negative results of the Byzantine Generals’ Problem, circumvents it by creating a mechanism in which double-spending is theoretically possible, but only under very unlikely con- ditions. The solution is illustrated in the Bitcoin’s whitepaper, entitled "Bitcoin: A Peer-to-Peer Electronic Cash System" [4]. It introduced the concept of a de- centralized, peer-to-peer digital currency that relied on blockchain technology to record transactions and achieve consensus without the need for a central author- ity. This solution, known as the proof-of-work consensus mechanism, has since become a cornerstone of blockchain technology and is widely adopted in various cryptocurrencies and blockchain platforms. It enables nodes in the network to reach consensus and maintain the integrity of the blockchain, even in the pres- ence of malicious actors, providing a robust and secure foundation for the world of cryptocurrencies and decentralized applications. Each actor of the network can freely send or receive the native currency, Bitcoin (BTC), in real-time, 24/7/365, all over the world and with the guarantee that no one can prevent the transaction. And this happens without the necessity of a central authority who acts as a trusted intermediary. To tackle this critical issue, Nakamoto found a solution by introducing the concept of a decentralized ledger, that is the above-mentioned blockchain. This innovation marked a paradigm shift in how digital transactions were recorded and verified. The blockchain functions as a public, distributed, and transparent ledger that records all transactions in a secure and immutable manner. It plays a pivotal role in ensuring that each unit of digital currency can only be spent once. The blockchain achieves this by creating a chronological and unchangeable history of every transaction, making it practically impossible for users to duplicate their digital coins or tokens. This transparent and tamper-resistant ledger provides an effective resolution to the double-spending problem, instilling confidence and trust in the digital currency system. The success of Bitcoin incentivized further innovation in the blockchain space. Other blockchain projects emerged, aiming to extend the technology’s applica- bility beyond digital currencies. In 2015, Ethereum, created by Vitalik Buterin, introduced the concept of smart contracts [5], which are self-executing contracts with the terms of the agreement directly written into software code. Ethereum’s blockchain allowed developers to build decentralized applications (DApps) and ex- ecute smart contracts, opening the door to a wide range of use cases beyond digital currency. Since the inception of Bitcoin and Ethereum, the blockchain landscape has expanded significantly. Numerous cryptocurrencies have been developed, each with its unique features, use cases, and consensus mechanisms; nowadays we count 3
  • 11. CHAPTER 1. INTRODUCTION TO BLOCKCHAIN TECHNOLOGY more than 10000 different projects. The vast majority blockchains are public and open to anyone, while a limited number are private and restricted to a select group of participants. Blockchain technology has also found applications in various industries, includ- ing finance, supply chain management, healthcare, and more. It has the potential to disrupt traditional systems by enhancing transparency, security, and efficiency. As in the following chapters, we delve deeper into the world of DeFi and algo- rithmic stablecoins, it is important to appreciate the underlying blockchain tech- nology that enables these innovations. The subsequent sections will briefly explore the architecture of blockchain, its role in achieving security and trust, and the historical developments that have led to its current state. 1.3 Fundamental Concepts To understand blockchain technology, it’s crucial to look into its basic concepts. These ideas form the basis for how blockchain works, keeps things secure, and builds trust in a decentralized and disintermediated network. In this section, we’ll take a quick look at these fundamental concepts, emphasizing the key elements that shape and power blockchain technology (a more detailed explanation can be found in [6, 7]). 1.3.1 Distributed Ledger At the core of blockchain technology is the concept of a distributed ledger. Un- like traditional centralized systems, where data is stored in a single location and controlled by a central authority, a distributed ledger is a database that exists on multiple computers or nodes across a network. Each node participating in the blockchain network maintains a copy of the entire ledger. This distribution of data ensures that no single entity has complete control over the ledger, and it introduces redundancy and fault tolerance. The benefits of a distributed ledger are a lot. First and foremost, it enhances security. In a centralized system, a single point of failure can compromise the integrity of the entire database. In contrast, a distributed ledger is resistant to such failures, as the data is stored across a vast network of nodes. If one node is compromised or experiences an issue, the data remains intact on other nodes. Furthermore, the decentralized nature of the ledger promotes transparency and accountability. All participants in the network can independently verify the data recorded on the blockchain, as they have access to the same information. This transparency is particularly important in scenarios where trust is essential, such as financial transactions or supply chain management. 4
  • 12. CHAPTER 1. INTRODUCTION TO BLOCKCHAIN TECHNOLOGY Distributed ledgers are also highly resistant to censorship and tampering. Al- tering data on a distributed ledger is exceedingly difficult, as it would require consensus among a majority of the network’s nodes. 1.3.2 Cryptography Cryptography is the foundational element that made the birth of blockchain tech- nology possible, by providing the means to secure transactions and control access to the blockchain. It involves the use of complex mathematical algorithms to en- crypt data, ensuring that only authorized parties can view or modify it. This security is achieved through the use of public and private key pairs, that are used to sign and verify the transactions and to redeem the Bitcoin. Public Keys Public keys are used to generate addresses on the blockchain. These addresses act as identifiers for participants in the network, allowing them to receive cryptocurrency or interact with smart contracts. A (hashed version of the) public key can be shared openly with others, as it only serves as a reference to the owner’s digital identity. Private Keys Private keys are the counterpart to public keys and are kept se- cret by their owners. They are used to digitally sign transactions, proving ownership of the associated assets. The combination of a public key and a private key forms a cryptographic key pair. The private key is the key to accessing and controlling the assets associated with a blockchain address. The cryptographic signatures created by private keys play a crucial role in se- curing blockchain transactions. When a transaction is initiated, it is signed with the sender’s private key. The signature is then verified using the corresponding public key, ensuring that the transaction is legitimate and has not been tampered with. This process guarantees the authenticity and integrity of blockchain trans- actions. Cryptography also safeguards the privacy of blockchain participants. While transactions are recorded on the public ledger, the details of the transacting par- ties remain pseudonymous. This pseudonymity, maintained through the use of cryptographic keys, offers a level of privacy and security that is highly appealing to users. 1.3.3 Consensus Mechanisms The consensus mechanisms are the protocols that enable nodes in a blockchain network to agree on the validity of transactions and the state of the ledger, more 5
  • 13. CHAPTER 1. INTRODUCTION TO BLOCKCHAIN TECHNOLOGY precisely that all nodes in the network reach an agreement on the order and content of transactions, preventing double-spending and other malicious activities. These mechanisms are fundamental for maintaining the integrity and security of the blockchain. Several consensus mechanisms have been developed, each with its own set of rules and advantages. Two of the most prominent consensus mechanisms are Proof of Work (PoW) and Proof of Stake (PoS). Let’s explore these mechanisms in more detail: Proof of Work (PoW) PoW is the consensus mechanism that underpins the security of the Bitcoin blockchain. In a PoW-based blockchain, nodes, known as miners, compete to solve complex mathematical puzzles. The first miner to solve the puzzle is granted the right to add a new block to the blockchain and is rewarded with the native cryptocurrency. This process is resource- intensive and requires miners to invest in powerful hardware and consume a significant amount of energy. PoW is known for its security and resilience but is criticized for its environmental impact. Proof of Stake (PoS) PoS is an alternative consensus mechanism that is more energy-efficient than PoW. In PoS-based blockchains, validators are chosen to create new blocks based on the amount of native cryptocurrency they hold and are willing to "stake" as collateral. PoS introduces economic incentives to maintain the network’s security. Validators are motivated to act honestly, as they have a financial stake in the blockchain. PoS is gaining popularity as a greener and more efficient alternative to PoW. These are just two examples of consensus mechanisms, and various other mech- anisms exist, each with its own set of trade-offs. The choice of consensus mech- anism can significantly impact the performance, security, and scalability of a blockchain network. Understanding the consensus mechanism used by a blockchain is essential for evaluating its strengths and weaknesses. 1.3.4 Immutability Immutability is one of the defining features of blockchain technology. Once a transaction is recorded in a block and added to the chain, it becomes exceedingly challenging to alter or erase. This characteristic is achieved through cryptographic hashing and the decentralized nature of the ledger. Each block in the blockchain contains a reference to the previous block through a cryptographic hash, creating a chain of blocks. If any data in a block is modified, the hash of that block changes. Since each block also includes the previous block’s 6
  • 14. CHAPTER 1. INTRODUCTION TO BLOCKCHAIN TECHNOLOGY hash, a change in one block would necessitate changes in all subsequent blocks, leading to a cascading effect that would require the consensus of the majority of network nodes. However, it’s important to note that while blockchain data is immutable, the information contained within the blockchain is not inherently trustworthy. The ac- curacy and authenticity of the data depend on the reliability of the data inputs and the rules defined by the blockchain’s smart contracts and protocols. Blockchain’s immutability is a double-edged sword; while it safeguards against tampering, it cannot prevent the introduction of incorrect data at the point of origin. 1.3.5 Transparency Transparency is another fundamental principle of blockchain technology. All par- ticipants in the network can view the entire transaction history recorded on the blockchain. This transparency enhances trust and accountability, as anyone can independently verify the data stored on the blockchain. Transactions on a public blockchain are open for inspection by anyone with internet access. This level of transparency is particularly important in scenarios where trust between participants is not inherent, such as in peer-to-peer transac- tions or when dealing with organizations and individuals across the globe. 1.4 Use Cases The transformative power of blockchain technology extends across different sec- tors. Its versatility and trust-building capabilities have led to its adoption in various domains, and in this section, some applications of this technology will be summarized. 1.4.1 Finance and Digital Currencies The most well-known application of blockchain technology is in the realm of fi- nance, where it has given rise to digital currencies, the most prominent of which is Bitcoin. Bitcoin introduced the concept of a decentralized, peer-to-peer digital currency that operates on a public blockchain. This cryptocurrency enables secure, borderless, and transparent value transfer. It has gained recognition as "digital gold" and serves as a store of value, a medium of exchange, and a hedge against inflation. Beyond Bitcoin, blockchain has fostered the development of thousands of al- ternative cryptocurrencies, each with its unique use cases and features. These 7
  • 15. CHAPTER 1. INTRODUCTION TO BLOCKCHAIN TECHNOLOGY cryptocurrencies play a significant role in the decentralized finance (DeFi) ecosys- tem, where users can engage in lending, borrowing, trading, and earning interest without reliance on traditional financial institutions. Blockchain also empowers the creation of stablecoins, digital assets designed to maintain a stable value, often pegged to a fiat currency like the US dollar. Stablecoins play a pivotal role in the cryptocurrency space, offering price stability for users who want to avoid the volatility of other cryptocurrencies. They are especially important in the DeFi sector, where they serve as a fundamental building block for various financial services. 1.4.2 Supply Chain Management The supply chain industry is another sector that has recognized the potential of blockchain technology [8]. Blockchain’s transparency and immutability features are leveraged to track and trace the movement of goods and products from their origin to the end consumer. In a blockchain-based supply chain system, each step of the supply chain, from the manufacturer to distributors, retailers, and consumers, records transactions and product information on a shared ledger. This visibility allows for real-time monitoring, reduces fraud, and enhances the efficiency of the supply chain. It also provides consumers with access to detailed information about the products they purchase, including their origins, quality, and authenticity. 1.4.3 Healthcare and Medical Records Blockchain technology is increasingly establishing a strong presence in the health- care sector, addressing challenges related to patient data management, interop- erability, and privacy [9]. Electronic health records (EHRs) are being migrated to blockchain-based systems to enhance security and streamline data access for healthcare providers. With blockchain, patients can have greater control over their health data. They can grant and revoke access to their medical records, ensuring that their data remains confidential and is only shared with authorized entities. This patient- centric approach to data management is in line with data protection regulations and empowers individuals to participate in their healthcare decisions. Furthermore, clinical trials and research in the healthcare industry can benefit from blockchain’s transparency and data integrity. Researchers can securely access and verify the authenticity of patient data, simplifying the development of new treatments and medical breakthroughs. 8
  • 16. CHAPTER 1. INTRODUCTION TO BLOCKCHAIN TECHNOLOGY 1.4.4 Intellectual Property and Copyright Protecting intellectual property and copyright has been a longstanding challenge in the digital age. Blockchain technology offers a solution by providing a tamper- evident and time-stamped ledger for creative works [10]. Artists, musicians, writ- ers, and content creators can record their intellectual property on a blockchain, establishing an immutable record of ownership and creation. Smart contracts, self-executing contracts with the terms of the agreement di- rectly written into code, can automate royalty payments to creators when their work is used or sold. This automation ensures that creators are fairly compensated without the need for intermediaries. Blockchain-based copyright solutions also enable content creators to track the use of their work and enforce copyright protection. Any unauthorized use or distri- bution can be identified and addressed through the transparency of the blockchain. 1.4.5 Voting and Elections Blockchain technology is going to revolutionize the way we conduct voting and elections. The transparency and security of blockchain can address issues of elec- toral fraud, tampering, and disputes, making the voting process more trustworthy and accessible [11]. Blockchain-based voting systems enable voters to cast their ballots securely from anywhere with an internet connection. Each vote is recorded on the blockchain, and the information is time-stamped, ensuring the integrity of the election process. Voters can independently verify that their vote was counted correctly, enhancing trust in the electoral system. As blockchain-based voting gains traction, it has the potential to streamline the electoral process, reduce the cost of elections, and increase voter participation. In conclusion, blockchain technology represents a pivotal shift in the way data is recorded, shared, and secured. It has evolved from a theoretical concept in the early 1990s to a practical and transformative technology with applications across industries. The introduction of Bitcoin and Ethereum brought blockchain into the mainstream, demonstrating its potential to disrupt traditional financial systems and introduce new paradigms of trust and transparency. Blockchain’s potential is only beginning to be realized, and its continued evo- lution promises to reshape the way we interact with data, assets, and each other in a decentralized and trust-based digital world. 9
  • 17. Chapter 2 Cryptocurrencies This chapter delves into the world of cryptocurrencies, providing a comprehensive understanding of what they are, an overview of the main cryptocurrencies, their market growth, and the future trends that are shaping this ever-evolving market. Cryptocurrencies have emerged as a revolutionary financial innovation in re- cent years, redefining the way we think about money, transactions, and financial systems. A cryptocurrency is a form of digital or virtual currency that employs cryptography for security [12]. Unlike traditional currencies issued by governments and central banks, cryptocurrencies exist purely in digital form and are decentral- ized, which means they are not controlled by any central authority. The core idea behind cryptocurrencies is to enable secure, peer-to-peer transactions without the need for intermediaries like banks. 2.1 Overview of the Main Cryptocurrencies The world of cryptocurrencies is vast and diverse, with thousands of cryptocur- rencies available, each with its unique features and applications. Here, we provide an overview of some of the most prominent cryptocurrencies: • Bitcoin (BTC): Bitcoin was the first cryptocurrency and remains the most well-known. It is often referred to as "digital gold" and is used primarily as a store of value and medium of exchange. Its limited supply of 21 million coins and widespread adoption has cemented its position as a pioneer in the cryptocurrency space. • Ethereum (ETH): Ethereum is more than just a digital currency; it is a decen- tralized platform for creating and running smart contracts and decentralized applications (DApps). It introduced the concept of "smart contracts". 10
  • 18. CHAPTER 2. CRYPTOCURRENCIES • Ripple (XRP): Ripple is designed for facilitating fast and low-cost cross- border payments. Unlike most cryptocurrencies, Ripple is not mined but rather pre-mined, and its primary focus is on serving the banking and finan- cial industry. • Litecoin (LTC): Created as the "silver" to Bitcoin’s "gold", Litecoin offers faster transaction confirmation times and uses a different hashing algorithm. It is often used for smaller, everyday transactions. • Cardano (ADA): Cardano is a blockchain platform known for its research- driven approach and focus on sustainability and scalability. It aims to pro- vide a secure and scalable infrastructure for the development of smart con- tracts and DApps. • Algorand (ALGO): Algorand is a blockchain platform designed to address the scalability and decentralization challenges faced by many existing blockchains. Founded by Silvio Micali, a Turing Award-winning cryptographer, Algorand employs a pure proof-of-stake consensus algorithm, aiming to achieve high transaction throughput and rapid confirmation times without sacrificing se- curity. The platform emphasizes decentralization, security, and efficiency, making it suitable for a wide range of applications, from financial services to decentralized applications. These are just a few examples, and the cryptocurrency space is continually evolving with the introduction of new coins and tokens, each with its own use case and value proposition. 2.2 Cryptocurrency Market Growth The cryptocurrency market has experienced remarkable growth in recent years. According to a report of Grand View Research from 2022 [13], the global cryp- tocurrency market was valued at USD 4.67 billion in that year and is projected to expand at a compound annual growth rate (CAGR) of 12.5% from 2023 to 2030. This growth is significant and highlights the increasing adoption and recognition of cryptocurrencies as a financial asset class. Furthermore, at the time of writing, the global cryptocurrency market capitalization stands at $1.5 Trillion. It’s note- worthy that in the past, this market cap has reached an impressive peak exceeding $3.0 Trillion (figure 2.1). One of the driving factors behind the growth of the cryptocurrency market is the increasing recognition and adoption of digital currencies as viable and de- centralized alternatives to traditional financial systems. Furthermore, the use of 11
  • 19. CHAPTER 2. CRYPTOCURRENCIES Figure 2.1: The global cryptocurrency market capitalization. Copy code The x- axis represents time, providing a temporal dimension, while the y-axis denotes the market capitalization value (source: CoinGeko [14]) cryptocurrencies for cross-border payments has gained popularity due to the re- duction in consumer fees and exchange charges, further fueling market expansion. Moreover, the rise of cryptocurrency as a decentralized asset class has attracted investments by private venture companies. In 2021, the U.S. cryptocurrency mar- ket witnessed investments worth USD 6.1 billion across 106 deals, indicating the increasing interest in this emerging asset class [15]. Cryptocurrencies have become a viable alternative form of tender, particularly in countries plagued by devalued currencies, where they offer stability and financial security. Furthermore, the adoption of cryptocurrencies by major corporations like Tesla Inc., MasterCard Inc., and PayPal has significantly contributed to industry expan- sion. In November 2021, MasterCard Inc. allowed its network partners to enable their customers to purchase, trade, and hold digital currency using a digital wallet and even offered digital currency as a reward for clients participating in loyalty pro- grams. This illustrates the growing acceptance of cryptocurrencies in mainstream financial systems. 2.3 Future Trends The cryptocurrency market’s future is marked by several notable trends and devel- opments. First, the market’s ever-evolving nature presents challenges in estimat- ing its size accurately. With new cryptocurrencies being created every week, the market’s boundaries are continually shifting. Moreover, the presence of numerous 12
  • 20. CHAPTER 2. CRYPTOCURRENCIES global cryptocurrency exchanges, known for their privacy protection features, adds complexity to the market. Another key trend is the extreme price volatility experienced by cryptocur- rencies. The estimated cryptocurrency market capitalization witnessed significant fluctuations during the year 2022, varying from 400 billion USD to 800 billion USD [16]. Such high volatility poses both opportunities and risks for market partici- pants, making it crucial to understand the market dynamics and trends. The adoption of blockchain technology is at a robust and accelerating pace. Enterprises have recognized the value of blockchain beyond cryptocurrencies and are moving towards implementing it in various use cases. Notably, the financial services sector, identity verification, trade, and other markets have witnessed the integration of blockchain technology. However, there is still uncertainty regarding the regulation and operation of this technology, which remains a subject of ongoing debate among policymakers and regulators. Looking ahead, the banking industry is expected to lead global blockchain spending, with an emphasis on cross-border payments, settlements, trade finance, and post-trade settlements. Blockchain solutions are also anticipated to see the highest spending in the United States, followed by Western Europe and China, reflecting the global nature of blockchain adoption. These regions are expected to witness phenomenal growth in blockchain spending, as the technology’s potential benefits become increasingly evident. In conclusion, the cryptocurrency market has exhibited remarkable growth in recent years, driven by factors like the adoption of blockchain technology, private investments, and increased acceptance by major corporations. However, the mar- ket’s inherent complexities, price volatility, and regulatory challenges make it an evolving landscape that requires continuous monitoring and analysis. Addition- ally, the adoption of blockchain technology is on the rise, with significant potential for various industries. Understanding these trends and dynamics is essential for anyone involved in or researching the cryptocurrency and blockchain sectors. 2.4 Cryptoeconomics Cryptoeconomics is, at its core, a field that strives to combine cryptographic tech- niques with economic principles to develop and regulate decentralized systems [17]. The central objective is to motivate participants within these networks to act in ways that support the network’s security, resilience, and functionality. This mo- tivation comes in the form of economic incentives, both positive (rewards) and negative (penalties), that influence the actions of network participants. Cryptoeconomics encompasses various focal areas, including information secu- rity engineering, mechanism design, token engineering, and market design. These 13
  • 21. CHAPTER 2. CRYPTOCURRENCIES domains together form a comprehensive framework that goes beyond the mere amalgamation of cryptography and economics. The term "cryptoeconomics" made its initial appearance in the early days of the Ethereum developer community, around 2014 - 2015. While the term "cryp- toeconomics" was relatively rare in the context of Bitcoin development, it was oc- casionally used in discussions about adversarial scenarios, such as state-sponsored defensive mining and transaction censorship. The fundamental idea of using eco- nomic incentives for network security was prominently illustrated by Bitcoin itself, as its mining system was meticulously designed to incentivize contribution to the network rather than attacking it. Ethereum, as the first successful general-purpose blockchain protocol, propelled the notion of economic incentives beyond the realm of cryptocurrencies. The application of economic incentives for achieving diverse behavioral and information security outcomes in decentralized systems gained significant traction. This trend led to extensive experimentation with cryptographic techniques and incentives across various domains, including finance, markets, and organizations. Cryptoeconomics involves several fundamental concepts, each essential to un- derstanding how economic principles shape the behavior of participants within decentralized systems: Incentive Design The careful design of incentives lies at the heart of cryptoeco- nomic systems. These incentives encourage stakeholders to act in ways that contribute positively to the network’s security and functionality. Economic security in cryptoeconomics refers to the financial incentives that protect a blockchain network from attacks. Participants are rewarded for honest par- ticipation and face financial penalties for malicious behavior, ensuring the entire network’s security. Tokenomics Tokenomics encompasses the study of how tokens are generated, distributed, and used within a blockchain ecosystem. It includes aspects such as token supply, issuance schedules, and governance mechanisms. Governance Cryptoeconomic systems often rely on governance mechanisms to make decisions related to network upgrades, parameter changes, and security measures. Governance tokens grant voting rights to participants, allowing them to shape the network’s trajectory. Decentralized Autonomous Organizations (DAOs) DAOs are organizations governed by code, and they operate based on smart contracts. Participants make collective decisions through voting. Cryptoeconomics extends beyond theory and principles, finding practical ap- plication in the expanding field of decentralized finance (DeFi). In DeFi, economic 14
  • 22. CHAPTER 2. CRYPTOCURRENCIES incentives are central to user engagement and network security. From lending and borrowing to trading and yield farming, DeFi platforms leverage cryptoeconomics designs to drive user participation and liquidity provision. The principles of incen- tive alignment and economic security play a pivotal role in ensuring the stability and growth of the DeFi ecosystem. The principles behind cryptoeconomics, and specifically tokenomics, are in- strumental in the design and operation of algorithmic stablecoins, offering a com- prehensive understanding of their stability and resilience within the decentralized financial landscape. 15
  • 23. Chapter 3 Decentralized Finance (DeFi) Decentralized finance, often referred to as DeFi, is a revolutionary paradigm in the world of finance. DeFi is a system of financial services and applications built on blockchain technology that aims to eliminate traditional intermediaries such as banks, brokerages, and insurance companies. It represents a fundamental shift in how financial services are designed, developed, and delivered. By sidestep- ping banks, payment processors, and other middlemen, DeFi reduces transaction costs and simplifies financial operations. This can lead to more competitive and cost-effective financial solutions for users, ultimately challenging the dominance of traditional institutions. DeFi is powered by smart contracts to create an open, trustless, and permissionless financial ecosystem. DeFi platforms are designed to be inclusive, offering their services to anyone with an internet connection, irrespec- tive of their geographical location, financial status, or identity. This democratizing effect of DeFi has the potential to solve the problem of financial inclusion by pro- viding individuals who are traditionally excluded from the formal financial system with access to an array of financial services. Users can interact with DeFi applications without needing to trust a central au- thority. The trust is placed in the transparent and immutable nature of blockchain technology and, more specifically, in the execution of smart contracts. DeFi platforms and applications enclose a wide range of financial services, including lending, borrowing, trading, synthetic assets, asset management, deriva- tives, and payment solutions without the need for traditional financial intermedi- aries. While DeFi offers numerous advantages, it also introduces new risks and chal- lenges. Smart contract vulnerabilities and Turing-completeness of their languages, regulatory ambiguity, and potential systemic risks are among the concerns that DeFi users must consider. Security measures, robust risk assessments, and regula- tory compliance efforts are imperative to mitigate these challenges and maintain the integrity of the DeFi platforms. 16
  • 24. CHAPTER 3. DECENTRALIZED FINANCE (DEFI) As this realm continues to evolve, it has the potential to not only redefine how individuals access and interact with financial services, but also to challenge the very foundations of traditional finance by introducing innovative products and services, including algorithmic stablecoins, prediction markets, decentralized derivatives, and much more. The emergence of DeFi can be traced back to the launch of Ethereum in 2015, which introduced the concept of smart contracts. This technology provided the foundation for the development of decentralized financial applications. The growth of DeFi has been exponential, with significant milestones and trends in recent years: Initial Experiments The early DeFi projects focused on basic financial opera- tions, such as decentralized exchanges (DEXs) and simple lending platforms. Projects like MakerDAO [18] and EtherDelta [19] prepared the ground for what was to come. Year of Growth The 2017 ICO (Initial Coin Offering) boom provided substan- tial capital and attention to the DeFi space. Several DeFi projects saw rapid development and adoption. Decentralized Exchanges (DEXs) The proliferation of decentralized exchanges like Uniswap [20] and SushiSwap [21] brought liquidity and trading volume to DeFi. They enable users to trade cryptocurrencies without relying on centralized intermediaries. Lending and Borrowing The introduction of lending and borrowing protocols, such as Compound [22] and Aave [23], allowed users to earn interest on their assets or obtain loans by locking up collateral in smart contracts. Yield Farming Yield farming and liquidity provision became popular DeFi strate- gies, with users providing liquidity to automated market makers in exchange for rewards and fees. This trend led to the rapid growth of the DeFi sector. Decentralized Finance has transformed the financial landscape by providing open, trustless, and programmable financial services and constitutes an entirely new paradigm for financial operations. Its recent history showcases rapid growth, innovation, and evolving challenges, as DeFi has the potential to drive advance- ments in the field of finance, including the development and utilization of algorith- mic stablecoins. The best way to measure the impact of DeFi is by evaluating the so-called total value locked, or TVL, which measures the quantity of U.S. Dollars (USD) that are locked in DeFi smart contract protocols; figure 3.1 shows the trend of TVL for 17
  • 25. CHAPTER 3. DECENTRALIZED FINANCE (DEFI) Figure 3.1: Global total value locked in DeFi (source: [24]) the entire sector. Today, the DeFi sector collectively locks more than USD 47.9 billion in value, with an all-time high (ATH) of 180 billion during the bull-trend of the end of 2022 [24]. Note that the site DeFiLlama, which keeps track of all the activity on the DeFi market, counts 35 different DeFi categories; we cite only some of the main important ones, which are: DEXes Lending Borrowing Bridge Derivatives Yield aggregator Synthetics Uncollateralized lending Gaming Prediction market Staking pool Insurance Oracle Decentralized stablecoins Marketplaces Algorithmic stablecoins NFT marketplaces Cross chain Figure 3.2: TVL of some DeFi categories (source: [24]) 18
  • 26. CHAPTER 3. DECENTRALIZED FINANCE (DEFI) Figure 3.2 shows the TVLs of some of them. 3.1 Decentralized Exchanges (DEXs) In recent years, the world of blockchain and cryptocurrency has experienced an explosion in popularity, attracting both the general public and institutional play- ers. This has led to a significant increase in crypto trading activities and the rapid evolution of the decentralized finance space. Among the various elements of DeFi, decentralized exchanges (DEXs) utilizing automated market maker (AMM) protocols have gained importance. Today, these AMM-based DEXs collectively lock almost USD 10 billion in value [24], underscoring their increasing importance within the cryptocurrency ecosystem (figure 3.3). Figure 3.3: Global total value locked in DeFi (source: [24]) Over the past few years, the crypto community has recorded the emergence of numerous protocols, each building upon its predecessor with incremental enhance- ments. These protocols aim to address specific issues or provide diverse use cases within the AMM ecosystem. While these protocols exhibit innovation in their respective aspects, they share common structural elements, primarily differing in parameter choices and mechanism adaptations. 3.2 Automated Market Makers (AMMs) AMMs represent a foundational component within the broader ecosystem of DEXs, which has grown in popularity recently. These new systems have brought about a significant shift in how assets are traded and liquidity is provided using automated, computer-driven processes. While traditional order-book-based exchanges deter- mine asset prices based on the matching of buy and sell orders, AMMs diverge 19
  • 27. CHAPTER 3. DECENTRALIZED FINANCE (DEFI) from this model. Instead, they rely on liquidity pools, where assets are paired and maintained algorithmically. The pivotal concept underlying AMMs is the con- servation function, which governs the pricing of assets. Basically, this function makes sure that the total value of assets in the pool stays the same, preserving a particular aspect of the system. AMMs operate as peer-to-pool systems, involving two primary actors: liquidity providers (LPs) and exchange users, also known as traders. LPs contribute assets to the liquidity pool, while exchange users initiate trades with the pool, specifying input and output assets and quantities. The smart contract governing the AMM automatically calculates exchange rates and trans- action fees based on the conservation function, facilitating efficient asset swaps without the need for traditional counterparties. This innovative model not only ensures immediate liquidity for users but also offers LPs the opportunity to earn transaction fees. The absence of an order book, a distinctive feature of traditional market exchanges, is a cost-saving benefit that AMMs bring to the realm of DeFi. In fact, it will be economically infeasible to maintain an order book on a public blockchain (e.g. Ethereum) due to the transaction cost. Automated Market Makers (AMMs) offer a lot of advantages, including: Simplified Trades AMMs do not require buyers and sellers to match their or- ders. This simplifies the trading process and makes it more accessible to a broader range of users. Continuous Trading AMMs enable continuous trading 24/7, without the need for a centralized intermediary. This accessibility and availability are essential in the global cryptocurrency market. Permissionless Access AMMs are typically permissionless, meaning anyone can participate in providing liquidity or trading without geographical or wealth- based restrictions. This aligns with the core principles of blockchain tech- nology. Diverse Asset Pairs AMMs support a wide range of asset pairs, allowing users to trade and provide liquidity for various tokens. This diversity fosters inno- vation and trading opportunities. Automated Pricing AMMs automatically adjust prices based on supply and demand, ensuring that asset prices reflect market conditions. This trans- parency benefits traders and liquidity providers. Arbitrage Opportunities Price disparities between AMMs and external mar- kets create arbitrage opportunities, encouraging market participants to keep prices aligned across platforms. 20
  • 28. CHAPTER 3. DECENTRALIZED FINANCE (DEFI) However, this convenience does not come without trade-offs. AMMs introduce inherent economic risks, chief among them being slippage and divergence loss, impacting exchange users and LPs, respectively. Slippage, in the context of AMMs, represents the discrepancy between the spot price and the realized price of an asset trade. Unlike traditional exchanges with fixed order books, AMMs operate on a continuous curve, and the exchange rate for any given trade depends on the size of the trade relative to the overall pool’s size. For infinitesimally small trades, the spot price closely aligns with the realized price, but for larger trades, the discrepancy becomes more significant. Smaller liquidity pools are particularly susceptible to high slippage, as each trade significantly affects the relative quantities of assets within the pool. As a result, traders must account for this slippage when executing transactions, a parameter that can be exploited for malicious activities (e.g. sandwich attacks [25]). Divergence loss, on the other hand, refers to the risk LPs face when providing assets to an AMM liquidity pool. This risk stems from the exposure of assets to price volatility and the time value of locked funds. When a trade occurs, it alters the composition of the pool, subsequently impacting the asset prices de- termined by the conservation function. This change in asset prices translates to variations in the value of the entire pool. LPs who contribute assets to the pool in exchange for pool shares can experience less value due to these price fluctuations. This phenomenon is often referred to as "divergence loss" or "impermanent loss". The term "impermanent loss" arises because the loss is not realized until assets are withdrawn from the pool, and the extent of the loss depends on the current proportions of the pool assets. AMMs have also introduced various economic models to incentivize both LPs and exchange users. These models include liquidity rewards, staking rewards, gov- ernance rights, and security rewards. Liquidity rewards compensate LPs for sup- plying assets to the liquidity pool, acknowledging the opportunity costs associated with locking their funds. These rewards are usually derived from the trading fees paid by exchange users. Staking rewards provide an additional incentive for LPs by offering them the opportunity to stake pool shares or other tokens, promoting token holding and liquidity on exchanges. Governance rights are another economic incentive, where AMMs reward participants with protocol tokens that grant vot- ing rights in protocol governance matters. Furthermore, security rewards play a crucial role in ensuring the robustness of AMMs by encouraging the community to audit the code and discover and fix potential vulnerabilities. AMMs, as an integral part of the DeFi ecosystem, offer a transformative ap- proach to liquidity provision and asset trading. Their peer-to-pool model and algorithmic pricing mechanisms provide several advantages, including accessible liquidity, automation, and decentralization. Some of the well-known DEXs in- 21
  • 29. CHAPTER 3. DECENTRALIZED FINANCE (DEFI) clude Uniswap, SushiSwap, Balancer, and Curve Finance, each offering unique features and catering to specific trading needs. However, the economic challenges they introduce, such as slippage and divergence loss, require careful consideration and risk management. As AMMs continue to evolve, they hold the potential to redefine the financial landscape and exploit the development of innovative financial products, including algorithmic stablecoins. 3.3 Uniswap This section explores the core concepts of the Uniswap protocol, analyzing its automated market maker mechanism, comparing it to traditional order book-based exchanges, and diving into the concept of token swaps within the ecosystem. We’ll define Uniswap liquidity pools, understanding how they function, how liquidity is provided, and the strategies employed by liquidity providers. Uniswap’s fee structure and the returns it offers to participants are also examined, shedding light on the financial incentives that drive its ecosystem. Furthermore, this section investigates the critical role of price oracles in the DeFi landscape. 3.3.1 Uniswap Protocol: Core Concepts Uniswap is a decentralized cryptocurrency exchange and automated liquidity pro- tocol built on the Ethereum blockchain. It allows users to swap various Ethereum- based tokens, i.e. based on the ERC-20 standard [26], without the need for a centralized intermediary. Uniswap is the largest decentralized cryptocurrency ex- change, dominating 64.6% of the DEX market (June 2023) [27]. To appreciate Uniswap’s uniqueness, it’s crucial to understand how it differs from conventional order book-based exchanges. In traditional exchanges, buyers and sellers create orders at specific price levels, which are therefore matched according to the dynam- ics of the market. Uniswap, on the other hand, discards the order book entirely and facilitates trading through liquidity pools ruled by a constant function market maker (CFMM) [28]. Buyers and sellers interact directly with these pools, offering a novel approach to token exchange. 3.3.2 Liquidity Pool At the heart of Uniswap’s operation are liquidity pools, which play a pivotal role in the protocol’s success. Uniswap liquidity pools are smart contracts that hold reserves of two unique ERC-20 tokens. As we saw in section 3.2, liquidity pools are integral to any DEX protocol, as they provide the assets required for token swaps. Initially, when a pool contract is created, its token balances are set to zero. 22
  • 30. CHAPTER 3. DECENTRALIZED FINANCE (DEFI) Liquidity is introduced to these pools by liquidity providers (LPs). Any user can become an LP by depositing an equivalent value of both underlying tokens into the pool. This action results in the creation of liquidity tokens that represent the LP’s share of the pool’s reserves. The first LP to seed a pool is responsible for setting its initial price. To avoid arbitrage opportunities, it is incentivized to deposit an equal value of both tokens. If the initial price deviates from the market rate, arbitrageurs will quickly take advantage of the opportunity at the expense of the initial LP. Liquidity provision carries its own set of risks, including impermanent loss, exposure to market volatility, and the need for active management. 3.3.3 Constant Function Market Maker (CFMM) Uniswap employs a unique AMM mechanism, specifically a constant function mar- ket maker, to facilitate token swaps. The CFMM provides that the token balances of the pool remain constant across any trades. This is achieved by the “constant product” formula: x · y = k (3.3.1) where x and y are the token reserve balances of the two tokens, while k is a constant called the invariant of the pool. This formula has the property that larger trades (relative to reserves) execute at polynomially increasing slippage than smaller ones. This mechanism replaces the traditional order book with a liquidity pool of two assets, both valued relative to each other. In a nutshell, Uniswap acts as an autonomous and algorithmic market maker, automatically determining exchange rates and providing a simple and efficient platform for users to trade tokens. 3.3.4 Swaps When a user initiates a swap on Uniswap, s(he) selects an input token and an output token. This will determine the liquidity pool in which the swap will take place. Then, the user specifies the amount s(he) wants to swap, and the protocol calculates the amount of the output token they will receive. Swaps are executed with a single click, making the process intuitive and straightforward. Uniswap’s AMM mechanism determines token exchange rates dynamically. As tokens are traded, the relative prices of the two assets in the liquidity pool shift, leading to a new market rate (see figure 3.4). This approach eliminates the need for matching orders, making Uniswap exceptionally efficient. However, it’s impor- tant to note that larger trades, relative to the pool’s reserves, may experience high slippage since the executed rate deviates from the expected rate. Uniswap’s swap AMM offers several advantages with respect to traditional finance exchanges. It 23
  • 31. CHAPTER 3. DECENTRALIZED FINANCE (DEFI) provides instant liquidity, allows for a wide range of token pairs, and doesn’t re- quire users to rely on centralized intermediaries. Figure 3.4: Swaps in Uniswap. Source: [20] For a more comprehensive understanding of the Uniswap AMM mechanism, particularly the constant product formula and slippage, it is beneficial to walk through a numerical example. Let’s consider a liquidity pool comprising two tokens (figure 3.4), Token A and Token B, with respective token balances denoted as Qa and Qb. Suppose Qa = 1200 and Qb = 400. This implies that the constant product, represented as k, is calculated as the product of these balances, i.e., k = Qa ∗ Qb = 4.8 · 105 . In this equilibrium state, one Token B is valued at 3 Token A. Now, let’s examine two scenarios: 1. When a user wishes to swap 3 Token A, the resulting output amount of Token B received) will be: Output = Qb − Q′ b = k/Qa − k/(Qa + 3) = 400 − 4.8 · 105 /1203.009 ≃ 0.997 This output is slightly less than the current unit value of Token A. 2. Conversely, when the swap involves 30 Token A, the output is determined as follows: Output = Qb − Q′ b = k/Qa − k/(Qa + 30) = 400 − 4.8 · 105 /1230 ≃ 9.756 In this case, the unit value of Token A experiences a decrease of approxi- mately 2.11% from its initial value. 24
  • 32. CHAPTER 3. DECENTRALIZED FINANCE (DEFI) This numerical example helps illustrate the impact of the constant product for- mula and how slippage can affect the outcomes of token swaps within the Uniswap AMM mechanism. 3.3.5 Fee Structure and Returns Uniswap imposes a 0.30% fee on trades that occur within its platform. This fee is applied to each trade and is added to the reserves within the liquidity pool. This means that the “invariant” k slowly increases after each trade. This fee structure derives from the traditional finance world, where centralized intermediaries often charge higher fees. The 0.30% fee is a relatively small cost for users to access de- centralized and censorship-resistant trading, making Uniswap an attractive choice for many. The fees collected from trades are distributed proportionally to liquidity providers in the pool. This means that LPs receive a share of the fees proportional to their contribution to the pool’s liquidity. As a result, liquidity providers earn a return on their assets in the form of trading fees. This fee distribution model incentivizes users to provide liquidity, as they can potentially generate passive income through their LP positions. Liquidity providers have various strategies at their disposal to optimize their returns. They can monitor the pools they participate in and make adjustments based on changing market conditions. For instance, some LPs may focus on pro- viding liquidity for stablecoin pairs to minimize impermanent loss, while others may choose high-volatility pairs for potentially higher fees. Liquidity providers receive liquidity tokens as proof of their contribution to a pool. These tokens are themselves tradable assets, allowing LPs to sell or transfer them at their discre- tion, so injecting in the invested capital a multiplication factor in its potentiality of income. Additionally, liquidity tokens can be used as collateral in other DeFi protocols, opening up possibilities for LPs to leverage their positions and explore new DeFi opportunities. 3.3.6 Price Oracles Price oracles play a critical role in the decentralized finance ecosystem, providing accurate and reliable pricing information for various assets. These oracles are used by lending platforms, decentralized exchanges, and various other DeFi services to determine collateral values, execute liquidations, and maintain market efficiency. In the context of Uniswap, price oracles are instrumental in ensuring that token prices are in line with market rates. This is used to show users the current price before a swap for a specific token. 25
  • 33. CHAPTER 3. DECENTRALIZED FINANCE (DEFI) Uniswap introduced a lot of innovation in the world of decentralized finance. Its core concepts, including automated market making, token swaps, and liquidity pools, have transformed how users trade and provide liquidity. The fee structure and returns offered to liquidity providers incentivize active participation in the ecosystem, while the integration of reliable price oracles ensures the accuracy and security of asset pricing. 26
  • 34. Chapter 4 Stablecoins This chapter provides an in-depth exploration of stablecoins, a distinctive class of cryptocurrencies designed with the primary objective of preserving a stable price of the asset, that keeps him safe from crypto market volatility. Firstly, will be offered a comprehensive definition of stablecoins, highlighting their unique characteristics and the important role they play within the expansive cryp- tocurrency ecosystem. A discussion on the mechanisms governing price stabiliza- tion will follow, and this will be useful for a systematic classification of stablecoins based on their operational frameworks. Furthermore, this chapter will examine the Terra-Luna ecosystem, that brought to the fore the first successful example of a new paradigm in achieving price stability, i.e. the idea of an algorithmic stable- coin, offering a focused analysis of its structure, functions, and the notable events surrounding its unfortunate collapse in May 2022. By examining this specific case study, the objective is to provide a real-world illustration of the challenges and complexities inherent in the algorithmic stablecoin landscape. This chapter will foster a critical understanding of the risks and dynamics that can impact stablecoin ecosystems, thereby contributing to a more informed discourse on the subject. 4.1 The Rise and Role of Stablecoins The proliferation of cryptocurrencies has not been without obstacles; indeed, a se- ries of concerns have emerged, slowing down their widespread adoption as reliable payment methods. The main concern is the dramatic volatility exhibited by promi- nent cryptocurrencies like Bitcoin (BTC) and Ethereum (ETH) [29]. The value of a BTC, for instance, often experiences wide fluctuations, with the potential to rise or fall by as much as 25% in a single day and occasionally exceeding 300% in a month (see figure 4.1). This intense volatility not only reinforces the speculative nature of cryptocurrencies but also prevents their integration into real-world pay- 27
  • 35. CHAPTER 4. STABLECOINS ment systems. Furthermore, the inefficiency of transactions poses a substantial obstacle to the seamless circulation of traditional cryptocurrencies in daily trans- actions. The technical characteristics of a standard blockchain based on a PoW infrastructure require transactions to wait for several blocks to be confirmed after payment completion. As a result, the inefficiency in transaction speed becomes evident, with, for instance, a Bitcoin transaction necessitating confirmation from six blocks and taking approximately an hour to complete. This slowness has a great influence on the number of transactions per second (TPS) the network can handle, i.e. its scalability. Note that while nowadays payment companies can han- dle several thousand TPS, Bitcoin handles transactions at a rate of 4-7 TPS. The scalability issue was the first motivation for numerous alternative projects com- peting with Bitcoin that flourished during the first years of the cryptocurrency era, and now we have several projects that are comparable with the performance of the classical payment companies. But the volatility issue remains. Figure 4.1: Bitcoin price fluctuations (source: TradingView) In response to this challenge, the concept of stablecoin has emerged as a poten- tial solution. Stablecoins are a special category of cryptocurrencies explicitly de- signed to mitigate price volatility and maintain purchasing power stability through specific mechanisms, such as pegging their value to a fiat currency like the United States Dollar (USD) or a basket of assets. This pegging is often maintained through collateralization, where the stablecoin issuer holds a reserve of real assets that can be redeemed to adjust the coin’s supply and stabilize its value. 28
  • 36. CHAPTER 4. STABLECOINS A completely different approach is that used by algorithmic stablecoins, which use smart contracts and algorithms to dynamically manage the coin’s supply in response to market conditions, aiming to keep the value stable by means of seignior- age mechanisms. Unlike their more volatile counterparts, stablecoins aim to pro- vide a reliable medium of exchange by overcoming the limitations of traditional cryptocurrencies. Their development has gained importance, positioning stable- coins as a crucial infrastructure supporting the broader cryptocurrency ecosystem. The market scale of Stablecoin has witnessed rapid growth, with notable ex- amples like Tether (USDT) leading the way. Since 2017, the market capitalization and volume of stablecoins have exhibited a clear upward trend. Figure 4.2: Market capitalization of the main stablecoins (source: [24]) According to data from DeFiLlama, the total market cap of stablecoin has surpassed USD 128 billion, constituting 8.9% of the total market capitalization of cryptocurrencies. Tether (USDT) dominates the Stablecoin market, representing almost 70% of the total market capitalization, with a staggering USD 88 billion. Other significant players include USD Coin (USDC) with a market value of USD 24 billion and Dai with a market value of USD 5 billion. Stablecoins play an important role as a form of insurance in the unpredictable world of cryptocurrencies. Because digital assets can be very unstable and are characterized by elevated volatility, investors frequently swap their cryptocurren- cies for stablecoins as a safe option when they expect the market to decline, or if they need to stay out of the market for a certain time. Being able to quickly change from unpredictable cryptocurrencies to stablecoins helps investors protect their money, acting as a financial safety net when the market is uncertain, and all this is achieved within the disintermediation offered by the cryptocurrency tech- nology, i.e. without relating with a central authority like a bank or a centralized exchange, that would be necessary to obtain back fiat money like USD in a change 29
  • 37. CHAPTER 4. STABLECOINS of the cryptocurrencies. This function of reducing risk makes the cryptocurrency market more robust overall. The utility of stablecoins extends beyond the realm of speculative investments to everyday transactions [30]. Stablecoins, with their relatively stable exchange rates, are increasingly being adopted as a universal payment method. From salary payments to purchasing goods and services, stablecoins offer a practical and effi- cient means of conducting daily transactions within the cryptocurrency ecosystem. This application aligns with the original vision of Satoshi Nakamoto, who envis- aged Bitcoin as a universal currency. In the era of economic globalization, cross-border payments have become a routine part of international transactions. Here, stablecoins could be an optimal choice for cross-border payments. Stablecoins make things simpler by avoiding the usual steps like getting approval from financial authorities, filling out remittance forms, and dealing with long processing times. With the decentralized nature of stablecoins and the help of blockchain technology, cross-border payments become fast and secure. They happen directly between addresses, in a peer-to-peer trans- action between two wallets, cutting out the middlemen and making international transactions quicker and less complicated. Furthermore, stablecoins have evolved into a significant component of decen- tralized finance. As decentralized applications gain traction, stablecoins provide the necessary stability for users engaging in financial activities such as lending, borrowing, and yield farming. Their value pegged to stable fiat currencies makes stablecoins a reliable store of value within the DeFi ecosystem, fostering trust and encouraging broader participation in decentralized financial services. 4.2 Collateralized Stablecoins Collateralized stablecoins represent the starting point of this investigation. These stablecoins derive their stability from a reserve of collateral, providing users with a reliable digital asset pegged to a designated value, often 1 USD. At the core of collateralized stablecoins, there is the concept of collateral, a backing that serves as a guarantee for the stability of the digital asset. This collateral can take various forms, including fiat cash, commodities, bonds, and even other cryptocurrencies. Notable examples of fully-collateralized stablecoins encompass well-known tokens such as USDT, USDC, and DAI. The collateral reserve essentially functions as a safeguard, enabling token holders to redeem their assets for tangible currencies or other assets, fostering trust and legitimacy in the broader cryptocurrency ecosystem. The types of collateral embraced by these stablecoins vary, allowing for flexi- bility and optimization of capital efficiency. In particular, the collateral can serve 30
  • 38. CHAPTER 4. STABLECOINS dual purposes, not only securing the stablecoin but also offering opportunities for further investment. It’s important to note that stablecoins committing their collateral to on-chain assets, such as cryptocurrencies, are often referred to as decentralized stablecoins. This distinction signifies a departure from traditional financial instruments, showcasing the innovative use of blockchain technology to underpin stability. Collateralized stablecoins address some of the limitations associated with their more volatile counterparts. However, they are not without challenges of their own. One significant constraint is the substantial capital required for legitimacy and trust. The stability of collateralized stablecoins is intricately tied to the underlying collateral, necessitating over-collateralization to absorb fluctuations in value. This contrasts with another category of stablecoins, the algorithmic stablecoins, which deploy smart contracts to dynamically respond to supply and demand, thereby maintaining a peg with the USD without requiring a physical asset as backing collateral. There are two types of collateralized stablecoin models. One prevalent model is the asset-backed stablecoin, which relies on physical assets like commodities, pre- cious metals, and fiat currencies to stabilize prices. This approach, while effective, introduces centralization and the risk of financial fraud, requiring a trusted third party to hold the assets. In contrast, collateralized stablecoins backed by cryptocurrencies present a de- centralized alternative. These stablecoins, such as Dai, leverage smart contracts on blockchain platforms like Ethereum to ensure stability. The collateral, usually in the form of cryptocurrencies like ETH, is locked in transparent and tamper- proof smart contracts, eliminating the need for an intermediary and enhancing decentralization. While cryptocurrency-backed stablecoins mitigate trust risks associated with traditional asset-backed models, they introduce a different risk related to currency value fluctuation. The decentralized nature of the collateral brings transparency but also exposes users to the highly volatile cryptocurrency market. The system’s ability to handle collateral liquidation during market downturns remains a critical test for the resilience of cryptocurrency-backed stablecoins. 4.3 USDC Overview USD Coin, abbreviated as USDC, is a fiat-collateralized Stablecoin pegged to the value of the USD on a one-to-one basis [31]. Launched in September 2018 as a collaborative effort between Coinbase and Circle, USDC has rapidly gained traction and become a cornerstone in the world of stablecoins. The fundamental principle guiding USDC’s design is to provide users with a digital representation of 31
  • 39. CHAPTER 4. STABLECOINS the US dollar, combining the benefits of blockchain technology with the stability of a traditional fiat currency. USDC operates on a fully backed and transparent model, maintaining a high standard of accountability and regulatory compliance. The company behind USDC, Circle, maintains reserves of US dollars equivalent to the circulating supply of USDC, ensuring direct and immediate backing for every token issued. This one-to- one collateralization is regularly audited by reputable third-party firms to provide users with the assurance that each USDC in circulation is backed by an actual US dollar held in reserve. The collateralization process involves users depositing US dollars into regulated financial institutions, which are then held as reserves for the issuance of USDC tokens. This meticulous approach not only instills confidence in the stability of USDC but also aligns with regulatory expectations and contributes to the broader adoption of stablecoins in the financial landscape. The transparency of USDC extends to its monthly attestation reports, which provide a detailed breakdown of the reserves backing the stablecoin. These reports, conducted by independent accounting firms, offer a comprehensive view of the assets held in reserve, reinforcing the credibility and reliability of USDC as a stablecoin. USDC has found widespread adoption across various sectors within the cryp- tocurrency space. Its stability and secure peg to the US dollar make it an ideal choice for traders, investors, and businesses seeking a reliable and easily under- standable digital currency. In the realm of DeFi, USDC serves as a cornerstone for various applications, including lending platforms, decentralized exchanges, and yield farming protocols. Moreover, the accessibility and liquidity of USDC con- tribute to its acceptance as a medium of exchange. Merchants, both online and offline, can leverage USDC’s stability to facilitate transactions. This real-world utility positions USDC as not just a speculative asset but a practical tool for financial transactions. 4.4 Algorithmic Stablecoins Algorithmic stablecoins are a unique subset of digital currencies designed to main- tain a stable value through algorithmic mechanisms rather than traditional collat- eralization. Unlike other stablecoins backed by fiat currency or assets, algorithmic stablecoins leverage smart contracts and algorithms to manage the coin’s supply dynamically, aiming to keep its value stable in relation to a reference asset, often a fiat currency like the U.S. dollar. The distinguishing feature of algorithmic stablecoins is the absence of a direct peg to tangible assets in a 1:1 relationship. Instead, these stablecoins deploy var- 32
  • 40. CHAPTER 4. STABLECOINS ious techniques such as minting or burning of coins, rebasing, and arbitrage to control the supply or value. This innovative approach allows algorithmic stable- coins to function without a reserve of fiat assets, making them a capital-efficient and decentralized solution within the crypto ecosystem. The following figure 4.3 shows the market cap of algorithmic stablecoins; it is well evident the effect of the Terra-Luna collapse, which plunged the capitalization of the entire sector from USD 22 billion to 3 billion in a few days. Figure 4.3: Market capitalization of algorithmic stablecoins, December 2020/June 2022 (source: [32]). 4.4.1 Seigniorage Seigniorage refers to the profit or revenue earned by the entity responsible for issuing and managing a currency [33]. It represents the difference between the face value of money (the nominal value) and the cost of producing or acquiring it. Seigniorage has historically been associated with traditional fiat currencies issued by central authorities, where the power to create money results in economic gains for the issuer. The concept of seigniorage has roots dating back to the medieval era when monarchs and rulers held the exclusive right to mint coins. They would extract seigniorage by minting coins with a higher face value than the actual cost of the metal. This practice generated revenue for the rulers and contributed to the fi- nancing of their expenditures. During the Renaissance, seigniorage became a more structured source of income for monarchies. With the establishment of central 33
  • 41. CHAPTER 4. STABLECOINS banks in the 17th century, seigniorage became intricately linked to the issuance of banknotes. Central banks, as the primary issuers of currency, derived seigniorage from the difference between the value of the currency and the cost of production. In the modern era, seigniorage has evolved alongside changes in monetary systems. The shift from metallic currencies to fiat currencies increased the reliance on the central bank’s ability to create money without the need for physical backing. This enhanced the role of seigniorage as a crucial component of monetary policy and government revenue. A straightforward example of seigniorage can be illustrated by a central bank issuing paper currency. Suppose a central bank prints a $100 bill at a cost of $2. The seigniorage generated from this transaction is $98. This profit contributes to covering the operational expenses of the central bank and, in some cases, becomes a source of revenue for the government. In the context of algorithmic stablecoins, seigniorage takes on a novel dimen- sion within the decentralized digital landscape. Unlike traditional fiat currencies, algorithmic stablecoins are not issued or controlled by a central authority. Instead, their seigniorage is generated through algorithmic mechanisms embedded in smart contracts. Algorithmic stablecoins reintroduce seigniorage into the crypto ecosystem by dynamically managing the coin’s supply based on market conditions. For example, when the value of the stablecoin exceeds the peg, the algorithm may trigger the minting of new coins to increase supply and stabilize the value. Conversely, if the value falls below its peg, the algorithm may initiate a burning mechanism to reduce supply, increasing its value. 4.4.2 Pegging Mechanism of Algorithmic stablecoins The pegging mechanism of algorithmic stablecoins revolves around maintaining a fixed exchange rate relative to a reference asset, typically a fiat currency like USD. Unlike traditional stablecoins that rely on reserves, algorithmic stablecoins achieve pegging through the expansion and contraction of the coin’s supply. The specific mechanisms can vary, leading to the emergence of different models in recent years. For example, the collapsed Terra USD (UST) employed a relatively straightfor- ward stability mechanism, that is used today also in other projects. When a user creates UST, an equivalent value of the native LUNA token is burned; and vice- versa, when a user redeemes UST, an equivalent amount of LUNA is minted. This mechanism aims to incentivize arbitrageurs to keep UST’s market price aligned with the US Dollar. However, the vulnerability of this model became evident during periods of market stress, leading to the collapse of the peg. A detailed explanation of the Terra-Luna stability mechanism and an investigation of its collapse will be presented in the 34
  • 42. CHAPTER 4. STABLECOINS next section. Other algorithmic stablecoins, such as USDN, IRON, and USDD, employ sim- ilar pegging mechanisms, emphasizing the dynamic adjustment of supply to main- tain stability. However, the evolving landscape of algorithmic stablecoins under- scores the need for robust stability mechanisms to face market fluctuations and maintain user confidence. 4.4.3 Advantages and Disadvantages Algorithmic stablecoins, with their unique approach to maintaining stability, of- fer distinct advantages that set them apart from other types of stablecoins and traditional fiat currencies. Decentralization and autonomy Algorithmic stablecoins embody the true essence of decentralization. The underlying code defines the rules governing the fi- nancial system, eliminating the need for regulatory oversight of user trans- actions. This autonomy resonates with the core principles of the crypto ecosystem, providing users with greater control over their assets, detaching them completely from the classical financial institutions necessary to handle fiat money. Comparative advantage over traditional fiat In comparison to traditional fiat currencies, algorithmic stablecoins offer advantages such as reduced reliance on central authorities and increased transparency. The decentralized nature of algorithmic stablecoins eliminates the need for intermediaries like central banks, providing users with a more direct and efficient means of engaging in transactions. High flexibility Algorithmic stablecoins maintain stability through the dynamic adjustment of coin supply, responding to market conditions. This flexibility sets them apart from fiat-backed stablecoins, which rely on fixed reserves, and crypto-backed stablecoins, which peg their value to existing cryptocurrencies. The ability to adapt to changing circumstances contributes to the resilience of algorithmic stablecoins in the face of market fluctuations. Despite their advantages, algorithmic stablecoins are not immune to risks and failures. The collapse of the Terra-Luna ecosystem in May 2022 highlighted the vulnerability of algorithmic stability mechanisms during market downturns or tur- moils. The reliance on dynamic supply adjustments exposes these stablecoins to self-fulfilling crises, where a loss of investor confidence can trigger a cascade of selling, leading to a breakdown in the peg [34]. 35
  • 43. CHAPTER 4. STABLECOINS Algorithmic stablecoins represent a dynamic and innovative approach to achiev- ing stability within the crypto ecosystem. However, their journey is marked by challenges, emphasizing the need for continuous research, robust stability mech- anisms, and a comprehensive understanding of the risks involved. As the crypto landscape evolves, algorithmic stablecoins will likely continue to play a significant role, with lessons learned from both successes and failures shaping their trajectory. 4.5 The Terra-Luna Ecosystem As we have seen, in decentralized finance (DeFi), price stability is crucial for the wide adoption and usability of cryptocurrency, especially for stablecoins meant to retain a consistent value. In the past, the Terra-Luna ecosystem has emerged as a groundbreaking solution to address the challenges associated with stability and scalability. At the core of the Terra-Luna ecosystem is the Terra blockchain, designed to provide stability through a unique algorithmic stablecoin called Terra [35]. Unlike traditional stablecoins pegged to external assets, Terra maintains its value through a combination of algorithmic mechanisms and, partially, by a collateralized reserve managed by the Luna Foundation Guard. Within the Terra-Luna ecosystem, the dual-token structure forms the core foundation, consisting of Terra and Luna tokens, each with distinct but comple- mentary roles. Terra stablecoins are designed to mimic and track the value of fiat currencies, offering a digital alternative to traditional money. The primary appeal of Terra stablecoins lies in their stable value proposition. For instance, the Terra USD (UST), is pegged to the US Dollar. Users interact with Terra as they would with fiat currency, with the added benefits of blockchain technology such as immutability, instant transactions, and low transaction costs. Creating new Terra stablecoins involves a deflationary mechanism where Luna, the native staking token of the Terra protocol, is burned (i.e. destroyed). To mint (i.e. create) new Terra, users initiate a burn transaction of Luna. This injects new Terra stablecoins into the system, simultaneously reducing the circulating supply of Luna. As demand for Terra increases, more Luna is burned to mint Terra, which, through the reduction in supply, contributes to an increase in Luna’s value. This interplay creates a reciprocal relationship where the value of Luna correlates directly with Terra’s usage within the ecosystem. Luna’s significance extends beyond just being the token to burn for minting new Terra. It assumes a critical role in the ecosystem by absorbing the price volatility that would otherwise affect Terra stablecoins. Luna holders are rewarded for their contributions to network stability through staking rewards and gaining governance rights within the ecosystem. By staking Luna to validators, who safeguard the network’s integrity, holders participate directly in the security and governance of 36
  • 44. CHAPTER 4. STABLECOINS the Terra blockchain. Consequently, Luna serves not only as a stabilizing force but also as the bedrock for Terra’s decentralized consensus and community-driven governance. 4.5.1 Supply and Demand Mechanism The Terra protocol employs a robust and algorithmically-driven supply and de- mand mechanism to maintain the stability of its native stablecoins, that is the peg with 1 USD. Understanding this mechanism necessitates examining the metaphor- ical pools of Terra and Luna, which are at the heart of the ecosystem’s balance. The pools represent the circulating supplies of each token, and their sizes adapt to maintain Terra’s price peg. The process of adjusting Terra’s supply relative to market conditions, and by this the stabilization of the price to 1 USD is visualized in figure 4.4; it corresponds to a simple dynamic interaction guided by basic economic principles. Figure 4.4: The Terra-Luna stabilization mechanism When Terra’s demand exceeds its current supply, indicating a price above its peg (e.g. $ 1.05 for the UST token, as in the right part of figure 4.4), the protocol encourages users to burn $ 1 of Luna to mint USD 1 of Terra, that can be sold on the free market with a seigniorage action, so as to gain the difference of $ 0.05. This action enlarges the Terra pool, effectively lowering its price by increasing the corresponding supply. Conversely, when the Terra price falls below the peg due to an oversupply, (e.g. $ 0.95 for the UST token, as in the left part of figure 4.4) 37
  • 45. CHAPTER 4. STABLECOINS users are incentivized to burn UST 1 of Terra to mint $ 1 of Luna, that can be sold on the free market with a seigniorage action, so as to gain the difference of $ 0.05. This reduces the Terra pool, introducing scarcity that helps push the price to higher values, that is back toward the peg. In the context of an expansion of the system - when demand for Terra increases - the protocol’s market module furnishes users with the economic incentive to decrease the size of the Luna pool by burning Luna in exchange for Terra. As Terra enters circulation, its increased supply aims to match the heightened demand until equilibrium is achieved at the pegged price. Here, Luna acts as a counterbalance, as its decreased supply inherently amplifies its price, given unchanged demand. Consequently, the mechanism ensures that Luna appreciates as the utility and demand for stablecoins rise. Similarly, during contraction phases - when the Terra supply overweighs de- mand - the protocol incentivizes the burning of Terra to mint Luna. This mech- anism operates in reverse: by reducing Terra’s supply, its price grows, while si- multaneously growing the Luna pool results in a lower Luna price. The aim of this algorithmic action is to entice market participants to engage in arbitrage, exploiting discrepancies between market prices and the peg to stabilize Terra. Underpinning these feedback loops is the seamless interaction between the pro- tocol’s market module and participants who seek arbitrage opportunities. The protocol guarantees that 1 USD worth of Luna can be exchanged for 1 UST and vice versa, which establishes a predictable environment for maintaining Terra’s peg to the fiat currency. Through such design, the Terra protocol remains agile and responsive, adjusting to market sizes, volatility, and demand. Before the Columbus-5 update to the Terra chain, committed in March 2022, a seigniorage mechanism was implemented. As Luna was offered for burning to mint UST, a portion of its value could be retained by the system. Initially, seigniorage was directed to community and oracle rewards, but since the implementation of the Columbus-5 main-net upgrade, it has been burned, thereby applying deflationary pressure to the circulating supply of Luna. The Terra protocol leveraged these advanced economic constructs (algorithmic market operations and arbitrage) to form not merely a digital currency platform but an entire digital economy, that at the time was completed with other two platforms: Anchor Protocol, that was a lending platform able to offer a 20% an- nual percentage yield (APY) by depositing UST; and Mirror Protocol, that was a trading platform for handling synthetic assets, that are cryptocurrencies that mimic the price of real assets - such as AAPL, MSFT and others of the NY stock exchange market, or commodities like gold - by using oracles, that follow in real time the price of the real asset on the exterior market. Through all these interconnected dynamics, Terra and Luna maintained a delicate 38