Defi 101: A Guide To Master Decentralized Finance

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

DeFi 101

A Guide to Master Decentralized Finance

A quick guide to master Decentralized Finance (DeFi)


Summary
1. What is DeFi
4. What are Decentralized Exchanges
7. What are Automated Market Makers (AMM)
9. What is a Liquidity Pool
9. What are Liquidity Providers
9. What are Liquidity Pool Tokens
10. What is Yield Farming
10. What is Total Value Locked (TVL)
11. How are Yield Farming Returns Calculated (What is APY, APR)
12. What is Auto-Compound Yield Farming (Auto-Compound Pools)
12. What is a Single Sided Pool
13. What is Impermanent Loss

1
Decentralized Finance (DeFi)

What is Decentralized Finance (DeFi)?


Decentralized Finance (or simply DeFi) refers to an ecosystem of financial applications
that are built on top of blockchain networks.

More specifically, the term Decentralized Finance may refer to a movement that aims
to create an open-source, permissionless, and transparent financial service ecosystem
that is available to everyone and operates without any central authority. The users
would maintain full control over their assets and interact with this ecosystem through
decentralized applications (dapps).

So, what is a Dapp? A Dapp, or decentralized application, is a software application that


runs on a distributed network (a blockchain). It's not hosted on a centralized server,
but instead on a peer-to-peer decentralized network, they are outside the purview and
control of a single authority for its decentralized nature.

DeFi Benefits.

So, let’s talk about its benefits. The core benefit of DeFi is easy access to financial
services, especially for those who are isolated from the current financial system.
Another potential advantage of DeFi is its interoperable nature, which makes DeFi
applications on public blockchains create entirely new financial markets, products, and
services.

Accessibility, Autonomy, Transparency, and Ownership.

Decentralized finance allows for instant or near-instant transfers at reduced costs and
fees, with only an internet connection, users can trade and transact at anytime from
anywhere.
There are fewer intermediaries between the interactions so fewer parties are taking a
slice of the pie. This is an advantage that those who use traditional finance methods do
not see.

There is also no single point of failure with financial services that use DeFi. That is
because these services are deployed on top of blockchains. It takes the data recorded
on the blockchain and spreads it to thousands of nodes. This makes it difficult to
censor and minimizes the possibility of a shutdown of the service.

2
DeFi use cases:

Open Lending Platforms:

These are simple decentralized applications (DApps) that allow you to either lend your
digital assets out to other users to earn interest or borrow digital assets from other
users — paying interest on top. Borrowers typically need to deposit collateral worth
substantially more than the loan amount and maintain this collateral above a certain
value threshold to protect the borrower. The Collateral is an asset that a lender
accepts as security for a loan. The collateral acts as a form of protection for the lender.
Those is, if the borrower defaults on their loan payments, the lender can seize
the collateral and sell it to recoup some or all of its losses.

Stablecoins:

Stablecoins are a type of digital asset that have their value pegged to another asset in
order to reduce volatility and keep the price as stable as possible. These can be pegged
to fiat currencies like the US dollar (USD) or Euro (EUR), or to other assets like gold or a
mixed basket of assets. Stablecoins are intimately weaved into the DeFi space and are
popular among lenders, borrowers, liquidity providers, and traders due to their
stability. Looking to avoid volatility as best as possible while still remaining liquid?
Stablecoins are generally the way to go.

Decentralized Exchanges:

Decentralized exchanges, or DEXs, are digital asset trading platforms that operate
without a centralized authority. These may take the form of automatic market makers
(AMMs) DeFi marketplaces like OpenSea are similar to decentralized exchanges, but
instead, allow users to trade digital goods or non-fungible tokens (NFTs) in a trustless
manner — usually using a smart contract-based escrow system.

Decentralized Insurance:

Just like how you can take out insurance against practically any unfortunate or
unforeseen event using traditional insurance brokers, there is now a range of DeFi
platforms that offer similar functionality. These can be used to hedge against rare or
potentially devastating events like a market crash, hack, smart contract failure, or
almost anything else. Unlike with traditional insurers, decentralized insurance allows a
pool of investors (known as underwriters) to share the risk among themselves in return
for the insurance premium. These platforms are built using publicly visible smart
contracts, which means the terms of payout are available for all to see — no more
getting stung by some obscure fine print!

3
Synthetic Asset Issuance:

Synthetic asset issuance is one of the more complex DeFi use-cases. This is essentially
the process of creating a digital asset token that mimics the properties of something
else, similar to how a stablecoin closely matches the value of the currency or asset it is
pegged to. These synthetic assets can represent almost anything, including simple
assets like precious metals and other commodities, digital assets, or more complex
financial instruments, like stocks and derivatives. These synthetics can generally be
bought, traded, and sold, allowing holders to gain exposure to previously illiquid or
difficult to obtain assets, for example.

Yield Farming:

Yield farming (also known as liquidity mining) is one of the more recent DeFi use-cases.
This is the practice of locking up digital assets in return for rewards which are usually
automatically delivered by a smart contract. In many cases, yield farming projects will
require that you stake liquidity provider (LP) tokens that are received after providing
liquidity at certain decentralized exchanges, like Uniswap or Pangolin.

Staking:

Staking is one of the simpler DeFi use-cases and is often one of the first ways many
digital asset holders gain exposure to decentralized finance. This is the process of
helping to participate in the network governance of Proof-of-Stake (POS) blockchains,
by delegating digital assets to a validator node or having one. When you help to secure
the blockchain by staking assets, you earn rewards that are automatically delivered by
the network.

4
What Is a Decentralized Exchange (DEX)?
A decentralized exchange (DEX) is a digital currency exchange that allows users to buy
crypto through direct peer-to-peer cryptocurrency transactions over a secure online
platform without an intermediary. This is a departure from traditional centralized
exchanges, where in a typical transaction a third-party entity (e.g. bank, trading
platform, government institution, etc.) takes custody of user funds and oversees the
security and transfer of assets between two parties.

With a decentralized exchange, a blockchain takes the place of the third party. By
moving critical operations onto a blockchain, the underlying cryptocurrency
technology eliminates single points of failure, allows users to retain control of their
assets, and enables safer and more transparent trading. DEXs use smart contracts to
execute market transactions by allocating transactions to autonomous code, but there
are multiple variations of order fulfillment with differing degrees of decentralization.

Like digital currencies, decentralized exchanges were created in response to flawed


and archaic financial systems that passed along risks of a centralized system to its
users, including insufficient security, technical issues, and a lack of transparency.

Different Types of Decentralized Exchanges

There are 3 types of Decentralized Exchanges:

On-Chain Order Books:


For some decentralized exchanges, everything is processed on chain including
modifying and canceling orders. Philosophically, this is the most decentralized and
transparent process because it circumvents trusting a third party to handle any orders
at any time. However, this approach is not very practical in execution.

By placing all stages of an order onto the blockchain, DEXs go through a time-
consuming process of asking every node on the network to permanently store the
order via miners, as well as pay a fee.

Off-Chain Order Books

DEXs with off-chain order books are still decentralized to some degree, but are
somewhat more centralized than their on-chain counterparts. As opposed to orders

5
being stored on the blockchain, off-chain orders are posted elsewhere such as a
centralized entity that governs the order book. Such an entity could exploit access to
the order books to front-run or misrepresent orders, however, users’ funds would still
be protected from the DEXs non-custodial model.

Automated Market Makers (AMM)

An automated marker maker (AMM) reinvents order books with pricing algorithms
that automatically price any asset pairing in real-time (e.g. Bitcoin-US dollar).

Unlike traditional market-making, whereby firms provide an accurate price and a tight
spread on an order book, AMMs decentralize this process and allow users to create a
market on a blockchain. No counterparty is needed to make a trade—the AMM simply
interacts with a blockchain to “create” a market. Instead of transacting directly with
another person, exchange, or market-maker, users trade with smart contracts and
provide liquidity. Unfortunately, there are no order types on an AMM because prices
are algorithmically determined, resulting in a sort of market order.

As with other DEX models, an on-chain transaction must occur to settle any trade. As
opposed to some DEXs, AMMs tend to be relatively user-friendly and integrate with
popular cryptocurrency wallets.

Pros and Cons of Decentralized Exchanges

Pros:

 No KYC/AML or ID Verification: DEXs are trustless, meaning user’s funds,


privacy, and personal data are well preserved.
 No Counterparty Risks: Because users don’t have to transfer their assets to an
exchange, decentralized exchanges can reduce risks of theft and loss of funds
due to hacks. DEXs can also prevent price manipulation or fake trading volume
as everything in public available.
 Any Token Can be Traded: With a DEX, users can trade new cryptocurrencies
that previously were difficult to exchange elsewhere.

Cons:

 No Recovery Ability: DEXs don’t have any underlying authority to recover lost,
stolen or misplaced funds, neither loss of private keys, since all transactions are
processed and stored in smart contracts on the blockchain without any owners
or overseers, which makes users totally responsible for their funds and keys.

6
 Limited Trading Functionality: Decentralized exchanges are a new thing, so they
tend to focus on executing simple buy and sell orders. Users may find advanced
trading functions such as stop losses, margin trading, and lending are
unavailable on most DEXs.

What are Automated Market Makers (AMMs)?


Automated market makers (AMMs) are part of the decentralized finance (DeFi)
ecosystem. They allow digital assets to be traded in a permissionless and automatic
way by using liquidity pools rather than a traditional market of buyers and sellers.

On a traditional exchange platform, buyers and sellers offer up different prices for an
asset. When other users find a listed price to be acceptable, they execute a trade and
that price becomes the asset’s market price. Stocks, gold, real estate, and most other
assets rely on this traditional market structure for trading. However, AMMs have a
different approach to trading assets.

Liquidity refers to how easily one asset can be converted into another asset, often a
fiat currency, without affecting its market price. Before AMMs came into play, liquidity
was a challenge for decentralized exchanges (DEXs). As a new technology with a
complicated interface, the number of buyers and sellers was small, which meant it was
difficult to find enough people willing to trade on a regular basis. AMMs fix this
problem of limited liquidity by creating liquidity pools and offering liquidity providers
the incentive to supply these pools with assets. The more assets in a pool and the
more liquidity the pool has, the easier trading becomes on decentralized exchanges.

On AMM platforms, instead of trading between buyers and sellers, users trade against
a pool of tokens — a liquidity pool. At its core, a liquidity pool is a shared pot of tokens.
Users supply liquidity pools with tokens and the price of the tokens in the pool is
determined by a mathematical formula. By tweaking the formula, liquidity pools can
be optimized for different purposes.

Anyone with an internet connection and in possession of any type of tokens can
become a liquidity provider by supplying tokens to an AMM liquidity pool. Liquidity
providers normally earn a fee for providing tokens to the pool. This fee is paid by
traders who interact with the liquidity pool contract. Recently, liquidity providers have
also been able to earn yield in the form of project tokens through what is known as
“Yield Farming” which we will see later on.

Constant Product Formula

AMMs have become a primary way to trade assets in the DeFi ecosystem, and it all
began with a blog post about “on-chain market makers” by Ethereum founder Vitalik

7
Buterin. The secret ingredient of AMMs is a simple mathematical formula that can take
many forms. The most common one was proposed by Vitalik as:

tokenA_balance(p) * tokenB_balance(p) = k

and popularized by Uniswap as:

x*y=k

The constant, represented by “k” means there is a constant balance of assets that
determines the price of tokens in a liquidity pool. For example, if an AMM has ether
(ETH) and bitcoin (BTC), two volatile assets, every time ETH is bought, the price of ETH
goes up as there is less ETH in the pool than before the purchase. Conversely, the price
of BTC goes down as there is more BTC in the pool. The pool stays in constant balance,
where the total value of ETH in the pool will always equal the total value of BTC in the
pool. Only when new liquidity providers join in will the pool expand in size. Visually,
the prices of tokens in an AMM pool follow a curve determined by the formula.

In this constant state of balance, buying one ETH brings the price of ETH up slightly
along the curve, and selling one ETH brings the price of ETH down slightly along the
curve. The opposite happens to the price of BTC in an ETH-BTC pool. It doesn’t matter
how volatile the price gets, there will eventually be a return to a state of balance that
reflects a relatively accurate market price. If the AMM price ventures too far from
market prices on other exchanges, the model incentivizes traders to take advantage of
the price differences between the AMM and outside crypto exchanges until it is
balanced once again.

The constant formula is a unique component of AMMs and it determines how the
different AMMs function.

Automated Market Maker Variations

In Vitalik Buterin’s original post calling for automated or on-chain money markets, he
emphasized that AMMs should not be the only available option for decentralized
trading. Instead, there needed to be many ways to trade tokens, since non-AMM
exchanges were vital to keeping AMM prices accurate. What he didn’t foresee,
however, was the development of various approaches to AMMs.

The DeFi ecosystem evolves quickly, but three dominant AMM models have emerged:
Uniswap, Curve, and Balancer.

 Uniswap’s pioneering technology allows users to create a liquidity pool with any
pair of ERC-20 tokens with a 50/50 ratio, and has become the most enduring AMM
model on Ethereum.

8
 Curve specializes in creating liquidity pools of similar assets such as stablecoins,
and as a result, offers some of the lowest rates and most efficient trades in the
industry while solving the problem of limited liquidity.
 Balancer stretches the limits of Uniswap by allowing users to create dynamic
liquidity pools of up to eight different assets in any ratio, thus expanding AMMs’
flexibility.

Although Automated Market Makers harness a new technology, iterations of it have already
proven an essential financial instrument in the fast-evolving DeFi ecosystem and a sign of a
maturing industry.

What is a Liquidity Pool


A liquidity pool is a crowdsourced pool of cryptocurrencies or tokens locked in a smart
contract that is used to facilitate trades between those assets on a decentralized
exchange. Liquidity pools are the backbone of many decentralized exchanges (DEX),
such as Uniswap or Pangolin. As anyone can be a liquidity provider, AMMs have made
“market making” more accessible.

How do liquidity pools work?

Liquidity providers (LP) add an equal value of two tokens in order to join an existing
pool or to create a new one. In exchange for providing their funds, they earn trading
fees from the trades that happen in their pool, proportional to their share of the total
liquidity.

What are Liquidity Providers?


A liquidity provider is a user who deposits tokens into a liquidity pool. In return for
supplying liquidity, users are typically awarded liquidity provider (LP) tokens that
represent the share of the liquidity pool the user owns.

Liquidity providers are rewarded in proportion to the amount of liquidity they supply
to the Liquidity Pool. The earnings coming from the transaction fees and are
proportionally distributed among all the Liquidity Providers.

What are Liquidity Provider Tokens?


Liquidity provider tokens or LP tokens are tokens issued to liquidity providers on a
decentralized exchange (DEX) that run on an automated market maker (AMM)
protocol.

9
What are Liquidity Provider Tokens used for?

LP tokens are used to track individual contributions to the overall liquidity pool, as LP
tokens correspond proportionally to the share of liquidity in the overall pool.

At the most basic level, LP tokens work on the following formula:

Total Value of Liquidity Pool / Circulating Supply of LP Tokens = Value of 1 LP Token

The relationship between LP tokens and the proportional share of a liquidity pool is
used most commonly in these cases:

1. To determine the liquidity provider’s share of transaction fees accumulated


during the duration of liquidity provision.
2. To determine how much liquidity is returned to liquidity providers from the
liquidity pools when Liquidity providers decide to redeem their LP tokens.
3. Staking LP tokens to earn further rewards as a way to incentivize Liquidity
providers to lock their liquidity into pools. Sometimes, this is called “farming.”
4. Using LP tokens values as a qualifying factor to access initial DEX offering
(IDOs), i.e., to participate in certain IDOs, one must hold a certain value of LP
tokens.

What is yield farming?


Yield farming, also referred to as liquidity mining, is a way to generate rewards with
cryptocurrency holdings. In simple terms, it means locking up cryptocurrencies in
liquidity pools in order to get rewards.

In some sense, yield farming can be paralleled with staking. However, there’s a lot of
complexity going on in the background. In many cases, it works with users called
liquidity providers (LP) that add funds to liquidity pools.

Yield farmers or liquidity miner will typically move their funds around quite a lot
between different protocols in search of high yields. As a result, DeFi platforms may
also provide other economic incentives to attract more capital to their platform. Just
like on centralized exchanges, liquidity tends to attract more liquidity.

What is Total Value Locked (TVL)?


A good way to measure the overall health of the DeFi yield farming scene is the Total
Value Locked (TVL). It measures the amount of capital locked in the DeFi yield farm
smart contracts. To put it simply, total value locked represents the number of assets

10
that are currently being staked in a specific protocol. This value represents the total
amount of underlying supply that is being secured by a specific DeFi application.

There are three main factors that are taken into consideration when calculating and
looking at decentralized financial service's market cap TVL ratio: calculating the supply,
the maximum supply as well as the current price.

In order to get the current market cap, you need to multiply the circulating supply by
the current price. In order to get to the TVL ratio, you would need to take that market
cap number and divide it by the TVL of the service.

From a theoretical standpoint, the higher the TVL ratio is, the lower the value of an
asset needs to be; however, this is not always the case when we look at reality. One of
the easiest ways to implement the TVL ratio is to help determine if a DeFi asset is
undervalued or overvalued, and this can be done by looking at the ratio. If it is under 1,
it is undervalued in most cases.

How does Yield Farming works?


Yield farming is directly related to automated market makers (AMMs). It typically
involves liquidity providers (LPs) and liquidity pools. Let’s see how it works.

Liquidity providers deposit funds into a liquidity pool. Liquidity providers receive their
share of the pool as Liquidity Provider Tokens, which they can deposit and lock into
Staking Pools, where they can generate staking rewards. By using LP tokens, your
liquidity works double-time — earning fees and farming yields.

How are yield farming returns calculated?


Typically, the estimated yield farming returns are calculated annualized. This estimates
the returns that you could expect over the course of a year.

Some commonly used metrics are Annual Percentage Rate (APR) and Annual
Percentage Yield (APY). The Annual Percentage Rate (APR) represents the annual rate
charged for earning or borrowing money. The Annual Percentage Yield (APY) refers to
the rate of return earned on a deposit over one year. APY takes into account
compounding interest. Compounding, in this case, means directly reinvesting profits to
generate more returns.

How Is APY Calculated?

APY standardizes the rate of return. It does this by stating the real percentage of
growth that will be earned in compound interest assuming that the money is
deposited for one year. The formula for calculating APY is:
11
APY = (1+r/n)n - 1 {r = period rate; n = number of compounding periods}

For example, if you deposited $100 for one year at 5% interest and your deposit was
compounded quarterly, then the APY would be (1 + .05/4)4 - 1 = .05095 = 5.095%.

It’s also worth keeping in mind that these are only estimations and projections. Even
short-terms rewards are quite difficult to estimate accurately. Why? Yield farming is a
highly competitive and fast-paced market, and the rewards can fluctuate rapidly. If a
yield farming strategy works for a while, many farmers will jump on the opportunity,
and it may stop yielding high returns.

As APR and APY come from the legacy markets, DeFi may need to find its own metrics
for calculating returns. Due to the fast pace of DeFi, weekly or even daily estimated
returns may make more sense.

What is Auto-Compound Yield Farming? (Auto-Compound Pools)


Auto-Compound Yield Farms (or Auto-Compound Pools) are Yield Farms where users
can stake their funds and the rewards they earn can be automatically compounded
(reinvested) for them for a minus small fee.

How does Auto- Compound Yield Farming Works?

The “automatic” compounding function is triggered by other users who get a small
bounty for triggering it by paying the other users fees to Compound their Rewards, in
exchange the users who trigger this function will receive a small bounty for triggering
it.

What is a Single Sided Pool?


Single-sided staking is the opposite of the commonly utilized pair-based staking that
AMMs usually implement. In most AMMs currently deployed, liquidity provision has to
be done by providing an equal value of liquidity on both sides. The requirement to
stake both tokens in a pair increases exposure for the liquidity provider, who now has
to manage two different assets. This also doubles the capital requirement or halves the
position for a single token.

There is a new structure where pools can represent individual assets and would enable
liquidity providers to stake their assets without requiring a counter-balance of
equivalent value: Single Sided Pools, where users can provide liquidity to a pool with a
single token and maintain 100% exposure to the token. Liquidity Providers can stay in
the pool with a single asset and collect rewards, while earning trade fees and Yield
Farming rewards.

12
What is Impermanent Loss
Impermanent loss is the temporary loss of funds occasionally experienced by liquidity
providers because of volatility in a trading pair, produced by the fluctuating value of
one or both of the assets that take part of the pool.

Impermanent loss happens when you provide liquidity to a liquidity pool, and the price
of one or both of your deposited assets changes compared to when you deposited
them. This fluctuaction is, the more you are exposed to Impermanent Loss (IL).

Let’s go through an example of how impermanent loss may look like for a liquidity
provider:

 Alice stakes 1 ETH and 100 USDT in their respective pool (ETH-USDT) in a AMM
(This means that the price of ETH is 100 USDT at the time of deposit)
 After a week, 1 ETH is equal to 200 USDT
 If Alice held her initial 1 ETH and 100 USDT, Alice would have gained +50%
(The 100 USDT stays at the same value, but Alice’s ETH is now worth 200 USDT)
 Being a Liquidity Provider in an AMM pool, Alice gain is less than the +50% she
would have made if she simply held the assets, since the amount of ETH she
has in the pool needs to be balanced with the amount of USDT she has.

This difference between holding two assets and staking them in a pool is called
impermanent loss. It is called like that because the loss is not realized unless the stake
is withdrawn. If ETH goes back to 100 USDT, and Alice withdraw her funds then, there
wouldn’t be any impermanent loss. Otherwise, the Staking Rewards and Trading Fees
you earn may be able to compensate those losses.

As a simple rule, the more volatile the assets are in the pool, the more likely it is that
you can be exposed to impermanent loss.

If you want to play around to see how the Impermanent Loss works in practice you can
use this calculator by putting the initial price of tokens when you enter a pool and the
future price, so you can see how it works:

https://dailydefi.org/tools/impermanent-loss-calculator/

If you want to reinforce the definition about Impermanent Loss you can watch the next
video:

https://www.youtube.com/watch?v=8XJ1MSTEuU0

13

You might also like