Reader small image

You're reading from  Data Science for Web3

Product typeBook
Published inDec 2023
PublisherPackt
ISBN-139781837637546
Edition1st Edition
Concepts
Right arrow
Author (1)
Gabriela Castillo Areco
Gabriela Castillo Areco
author image
Gabriela Castillo Areco

Gabriela Castillo Areco holds an M.Sc. in big data science from the TECNUM School of Engineering, University of Navarra. With extensive experience in both the business and data facets of blockchain technology, Gabriela has undertaken roles as a data scientist, machine learning analyst, and blockchain consultant in both large corporations and small ventures. She served as a professor of new crypto businesses at Torcuato di Tella University and is currently a member of the BizOps data team at IOV Labs.
Read more about Gabriela Castillo Areco

Right arrow

Exploring Analytics on DeFi

There are two groups of products that drive the most transactions in the current state of Web3: NFTs, as we discussed in Chapter 4, and decentralized finance (DeFi), which we will explore in this chapter.

DeFi takes its name in opposition to the centralized characteristic of the current financial system. According to the book How to DeFi: Beginner, by CoinGecko, “Decentralized Finance or DeFi is a movement that allows users to utilize financial services such as borrowing, lending, and trading without the need to rely on centralized entities.” DeFi is not a single product but a series of projects trying to address financial demand in the Web3 space.

These projects make use of the concept of composability, which involves building upon parts created by other parties. It is often illustrated as building with Lego blocks, where developers combine various components to construct new infrastructures.

DeFi has introduced products that were...

Technical requirements

The technical requirements listed in Chapter 4 also apply to this chapter. We will be using indexed data available in SQL table services like Dune Analytics, Increment, and Flipside. To follow along, please open an account on any of these platforms by following the links provided in Chapter 2. Transactional data is queried with SQL services, and the syntax varies, depending on the query engines.

You can find Jupyter notebooks containing the examples discussed in this chapter in this book’s GitHub repository at https://github.com/PacktPublishing/Data-Science-for-Web3/tree/main/Chapter05. We recommend reading through the code files in the Chapter05 folder to follow along.

Stablecoins and other tokens

According to Coinbase, “A stablecoin is a digital currency that is pegged to a “stable” reserve asset such as the US dollar or gold.” Given that unpegged cryptocurrencies such as Bitcoin or Ethereum are so volatile, stablecoins have become a reliable medium of exchange. The main stablecoins, according to their market cap at the time of writing, are listed in Figure 5.2:

Figure 5.2 – Crypto panic stablecoins ranking

Figure 5.2 – Crypto panic stablecoins ranking

Stablecoins are a specific category of tokens that are linked to the value of external assets, providing price stability. There are various types of stablecoins, including those whose value follows the value of a government-issued currency such as the US dollar (named fiat currencies), cryptocurrencies, and commodities such as gold. To maintain the “peg,” stablecoin teams have explored many paths. This can be seen in the “Mechanism” column in Figure 5...

Understanding DEX

Cryptocurrencies can be exchanged through various methods, including peer-to-peer (P2P) trading, centralized exchanges (CEXs), and DEXs. Each method has its advantages and characteristics:

  • P2P: In this method, two parties directly buy and sell cryptocurrencies among themselves without intermediaries. It prioritizes privacy and enables a wide range of payment options, making it accessible to users worldwide. However, to ensure the completion of the transfer, certain players have appeared that may act as intermediaries for a small fee, such as escrow services, rating platforms, or dispute resolution services.
  • CEX: This method offers cryptocurrency exchange services to users who have an account on their platform. It primarily matches buyers with sellers using an order book, where market makers and takers place their orders. The CEX’s revenue is generated through transaction fees on each facilitated trade. Major CEXs include Binance, OKX, Coinbase,...

Lending and borrowing services on Web3

The bank receives deposits, saves part of them to be able to repay in case the owner wants the cash back, and offers the other part as a loan in the market at a certain interest rate. The loan can be collateralized or non-collateralized, depending on the risk of the loan taker. The interest rate is set high enough to generate revenue for the bank and the depositor. Certain protocols on-chain reproduce a similar mechanism, as we will describe in this section.

At the time of writing, the main lending and borrowing protocols only work with collateralized loans. The process resembles a mortgage where the user provides the house as collateral as insurance for the loan payment. If the loan is not repaid in full, the bank keeps the house. In this case, if the collateral ratio of the loan is not maintained, the protocol liquidates the collateral.

Let’s imagine that Alice wants to invest in a project in USD stablecoin but her collateral is...

Multichain protocols and cross-chain bridges

A bridge is a structure that facilitates the transfer of funds and information between different chains. The market recognizes three groups of chains:

  • L1 chains are the well-known blockchains, such as Bitcoin and Ethereum. It is called Layer 1 as the core team generates a layer of solutions over the foundation layer to increase scalability. An example of the evolution of L1 is the Ethereum merge, which occurred in September 2022.
  • L2 chains are integrations that run on top of a blockchain to improve specific aspects, often focusing on scalability. These scaling solutions allow the main chain to offload data to a parallel architecture, processing it there and saving only the results on the main chain. Successful L2 chains include Optimism, Arbitrum, and Polygon zkEVM.
  • Sidechains are new blockchains that are connected to a major blockchain. For instance, Rootstock is linked to Bitcoin, enabling EVM smart contract programming...

Summary

In this chapter, we delved into the world of DeFi, exploring its core components and the primary products offered in the sector. Our analysis covered a wide array of areas, including tokens, stablecoins, and DEXs with a focus on pools and DEX aggregation, lending and borrowing protocols, and the significance of bridges in facilitating cross-chain transactions.

In each case, we analyzed the business flow and how it generates revenue, and leveraged some of the data providers to generate aggregated metrics.

While the landscape of DeFi is ever-evolving, with new players emerging and innovative services being introduced, our focus remains on comprehending the underlying business models and mechanisms. Understanding the essence of these protocols enables us to effectively trace transactional details to construct informative metrics for further analysis.

Analytics companies play a vital role in simplifying this domain. Leveraging both on-chain and off-chain data and collaborating...

Further reading

To complement this chapter, the following sources may help:

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Data Science for Web3
Published in: Dec 2023Publisher: PacktISBN-13: 9781837637546
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Gabriela Castillo Areco

Gabriela Castillo Areco holds an M.Sc. in big data science from the TECNUM School of Engineering, University of Navarra. With extensive experience in both the business and data facets of blockchain technology, Gabriela has undertaken roles as a data scientist, machine learning analyst, and blockchain consultant in both large corporations and small ventures. She served as a professor of new crypto businesses at Torcuato di Tella University and is currently a member of the BizOps data team at IOV Labs.
Read more about Gabriela Castillo Areco