Sunday 21 March 2021

DeFi The Ultimate Guide

 Introduction 

First of all we should clarify what is DeFi and why this is important.  DeFi is a general term given to decentralised financial services such as decentralised exchanges (DEXs) , decentralised money markets, and decentralised insurance companies, etc. It aims to replace centralised financial services, such as centralised exchanges (CEXs) with autonomous organisations that allow everyone to participate. This is important because it can help us make profits. 

 Yes but what is DeFi


DeFi is based on a software running on top of a Blockchain, it is as simple as that, but not exactly. DeFi is a financial ecosystem, running in a Blockchain (that supports sophisticate functionality, such as Ethereum blockchain), yes, but not exactly. When a DeFi financial ecosystem runs on top of a  Blockchain, then is characterised as a layer 2 solution, but a DeFi can be a Blockchain it self.

A DeFi ecosystem is visible to the rest of the world, either through DApps or directly (e.g. a user can interact with the smart contract directly or through DApps). A DApp is just like any other software application you use. It could be a website or an app on your phone. What makes a Dapp different than a traditional app is that it's built on a decentralised Blockhain, such as Ethereum.

Below we cans see some Blockchain explorers:


Yes but why DeFi


DeFi or open finance or decentralised finance, refers to the paradigm shift from today’s closed financial system towards an open financial economy based on open protocols that are interoperable, programmable, and composable [1]. 
As the crypto ecosystem expand, the term Open Finance more accurately describes the intended destination, because all modern Blockchains are creating new on-chain economies that integrate with current financial systems. Open finance is not about creating a new system from scratch, it’s about democratising the existing system and making it more equitable using open protocols and transparent data [1].

Below we can see the properties if a DeFi system:
  • Interoperable - Current financial system is comprised of walled gardens with limited access  
  • Programmable - Offers financial instruments and assets that are more customisable
  • Composable - Implement the concept that something can be selected and assembled in combinations
A DeFi ecosystem can offer you the following generic services, by simply using your crypto asset wallet:
  • Borrowing assets 
  • Lending assets
  • Accounts with interest rate
In the following sections we will analyse exactly what a DeFi ecosystem can offer you and how to access it.  

DeFi vs. Centralised Finance

To gain a better understanding of the impact DeFi can have on the economic landscape, it’s critical to outline how it improves upon our current centralised infrastructure, as well as cover the areas in which it falls short [2]. DeFi has the following four properties that Centralised Finance (CeFi) does not have a) Autonomy, b) Accessibility, c) Tradability and d) Transparency [2].

More specifically [2]:
  • Autonomy – In DeFi There is no centralised authority, such as a bank, with the ability to freeze your account, seize your assets, or block your transactions.
  • Accessibility-  You only need Internet to access DeFi.
  • Tradability - DeFi ecosystems are used to trade synthetic tokens.
  • Transparency - DeFi ecosystems run on Blockchains and therefore the code is immutable. DeFi data is publicly available, enabling you to keep service providers honest. For instance, you can easily check the reserves of a DeFi bank, shop around for accurate loan rates, or even track the transactions of public figures.
A DeFi snapshot can be seen through DeFi Pulse [3]:
 

Note: DeFi Pulse is a Website tracking the whole Market cap of the ecosystem. More specifically DeFi Pulse is a site where you can find the latest analytics and rankings of DeFi protocols. It tracks the total value locked into the smart contracts of popular DeFi applications and protocols. Additionally, it curates The DeFi List, a collection of resources in DeFi, and DeFi Pulse Farmer, a newsletter covering the latest news and opportunities in DeFi.


DeFi Now

DeFi and the greater crypto ecosystem are experiencing an explosion in 2020. Total Value Locked (TVL) has grown more than 10x since March, new projects with novel distribution models and incentive mechanisms are launched week after week. The yield farming craze has stress-tested all the major DeFi protocols in the past four months, and the industry as a whole is going through a phase of extraordinary growth [3].

DeFi Security Risks

We have identified the following categories of risks that you should be aware of when thinking about your DeFi investments [4]:
  • Hacks - The code might get hacked
  • Governance - The team managing the DeFi ecosystem, makes a mistake
  • Losing control of your assets - Losing the private key of your wallet
  • Scams - The whole DeFi ecosystem is a scam
But lucky you, there are ways to minimise the risk by following the steps below:
  • Before allocating you assets in the DeFi ecosystem review the team, through social media - 
    • Make sure the team is not anonymous
    • Make sure the project has a significant social media footprint
    • Do your own research in the project
  • Check the source code of the DeFi ecosystem -
    • Make sure the code is open source and available is in github
    • Make sure you read the code, before investing
    • Make sure that a 3rd independent party did a security source code review
    • Make sure you understand what the code does
  • Understand the tokenomics -
    • Run calculations on the offered token inflation
    • Research the circulating and max supply of the coins
    • Understand how you will make profit
  • Do a risk management of your capital - 
    • Do not invest all you assets in one DeFi product   
In case you are not technical and a financial guru, you can use the DeFi score to assess how secure is a DeFi ecosystem. The DeFi Score is a single, consistently comparable value for measuring platform risk, based on factors including smart contract, centralisation and financial risk. The model outputs an easy to understand 0–10 score that can be presented to users or integrated into other systems [5].

Below we can see a screenshot of the related website:



More specifically the DeFi Score is a framework for quantifying risk in permissionless lending pools (permissionless means publicly available). Originally conceived of by a team at ConsenSys, the project is now open source and open for community contribution.

Below we can see an example of the DAI product:


As we can see above the index is taking into considerations factors such as if the project is in a Bug Bounty, the liquidity index and the centralisation index. 

More specifically the index is looking to see if:
  • The project joined a Bug Bounty program such as Hackeron for security reasons
  • The project has audited its source code by an independent 3rd party
  • The project has enough liquidity for you to trade (low liquidity can allocate you assets for longer than the anticipated time)
  • The project is not centralised (e.g. the team is using a permissible Blockchains only)
  • The time index records the time in mainnet (e.g. the longer a project is running in the mainnet without an issues the more secure it is)
The formula break down can be seen below:
  • Smart Contract Risk (45%)
  • Time on Mainnet (11.25%)
  • No Critical Vulnerabilities (9%)
  • Engineering Weeks (4.5%)
  • Recent Audit or no code changes (6.75%)
  • Public Audit (6.75%)
  • Bug Bounty (6.75%)
  • Financial Risk (30%)
  • Collateral Makeup CVaR (10%)
  • Utilization Ratio (10%)
  • Absolute Liquidity (10%)
  • Centralization Risk (25%)
  • Protocol Administration (12.5%)
  • Oracles (12.5%)

Prerequisite Terminology 

Before we dive deep into DeFi trading, borrowing and lending, it would be good to explain some concepts from the traditional finance [6]:
  • Liquidity: Describes the degree to which an asset can be quickly bought or sold in the market at a price reflecting its intrinsic value. Fiat is universally considered the most liquid asset because it can most quickly and easily be converted into other assets. Low liquidity, means limited ability to convert our assets to another type of asset e.g. you entered a DeFi product using Bitcoin to borrow Ethereum and because of  the low liquidity, you know cannot withdraw your funds fast enough (e.g. before the Ethereum or Bitcoin price drops).
  • Yield: Refers to the earnings generated and realised on an investment over a particular period of time (in DeFi products, this can be 1yr or even 7days). It's expressed as a percentage based on the invested amount of digital token, current market value. 
  • Order Book: Refers to an electronic list of buy and sell orders for a specific digital token organised by price level. An order book lists the number of token being bid on or offered at each price point, or market depth.
  • Market Makers (MM): Refers to the traders make the price. aka provide liquidity to the market  e.g. buyers increase the price   
  • Market Takers (MT): Refers to the traders take the price, aka remove liquidity of the market e.g. sellers decrease the price
Now that we took care of the mandatory definitions, taken from the traditional financial system we can progress in analysing the DeFi offered products.  

DeFi Liquidity Pool A Basic Element

A liquidity pool (LPool) is a collection of funds locked in one or more Smart Contracts (SCs). LPools are used to facilitate decentralised trading, lending, and many more functions we’ll explore later [7]. LPools are the backbone of many DEXs, such as Uniswap. Users called liquidity providers (LP) add an equal value of two tokens in a pool to create a market. In exchange for providing their funds, they earn trading fees from the trades that trade in their pool, proportional to their share of the total liquidity [7].

Below we can see a schematic representation of a liquidity pool:  



Someone could say that a DEX LPool is the equivalent of an order book in a CEX. An order book in CEX is essentially, as already explained, the mapping process of a buy request, with sell request e.g. a "Market order" would have to create a sell, buy pair the fastest possible way.  This model is great for facilitating efficient exchange and allowed the creation of complex financial markets, when used on CEXs.

Below we can see a schematic representation of an order book:


DeFi ecosystem trading, however, involves executing trades on-chain, without a centralised party holding the funds. This presents a problem when it comes to order books. Each interaction with the order book requires gas fees, which makes it much more expensive to execute trades (and also time consuming). It also makes the job of MMs, extremely costly. 

Automated Market Makers (AMMs)


AMMs (AMMs is a type of LPool) are designed so that on-chain trading occurs without the need for an order book. No direct counterparty is needed to execute trades, traders can get in and out of positions on token pairs that likely would be highly illiquid on order book exchanges. In other words a CEX is using an order book to achieve an one to one mapping of the seller and the buyer (imagine an order book exchange as P2P transaction). The DEX you’re executing the trade against the liquidity in the liquidity pool as shown above.

Liquidity Pool Usage

So far, we’ve mostly discussed only one type of liquidity pools, the AMMs, which have been the most popular use of liquidity pools. But there also other type of LPools as we can see below:
  • Yield Farming or Liquidity Mining
  • Insurance LPool
  • Minting synthetic assets LPool
There are a gazillion projects out there, feel free with proper risk management to explore multiple DeFi project, for more information see here: defiprime.com  

Impermanent Loss Or Opportunity Cost 

When you deposit assets in a LPool, you become exposed to the following risks [8]:
  • The custodian SCs of your assets might get hacked e.g. hacker gain access to the LPool.
  • By providing liquidity to an AMM, you’re exposed potential impermanent loss 
  • LPool governance mistakes, might cause a loss of your assets e.g. the team losses access to the SC system etc.
Out of all the three issues mentioned, the one that you should be interested the most is the impermanent loss. Impermanent loss happens when you provide liquidity to a LPool, and the price of your deposited assets changes compared to when you deposited them. The bigger this change is, the more you are exposed to impermanent loss. In this case, the loss means less dollar value at the time of withdrawal than at the time of deposit, the volatile tokens you deposited. 

Impermanent loss according to my own opinion is the wrong name to use when referring to dollar value withdrawal loss. Impermanent loss is essentially the opportunity cost loss. That said what I mean is that when we invest in an LPool, we do that by depositing either a stablecoin and a token or two tokens and when withdraw our deposit the withdrawal ratio is fixed.

Below we can see an example that we lose money while providing liquidity:
  • The initial deposit of 100 dollars -> 50 dollars of BTC (assuming 1 BTC is 50 dollars) and 50 dollars of USDT
  • Our withdrawal, is going to be 100 dollars of 0.5 BTC and 50 USDT (assuming now that 0.5 BTC costs 50 dollars) plus the LPool fees, plus the 50 USDT. We can see that if we would have kept the BTC, now we would have gained 50 dollars more minus the LPool  fee.
Below we can see an example that we earn money while providing liquidity:
  • Initial deposit  100 dollars -> 50 dollars of BTC (assuming 1 BTC is 50 dollars) and 50 dollars of USDT
  • Withdrawal of 100 dollars after a Bitcoin price decrease by 50% -> 2 BTC that costs 50 dollars and 50 dollars of USDT, plus the LPool fees. We can see that if we would have kept the BTC, we would have lost 1 BTC minus the LPool  fee (of course this assumes that the BTC is going to go up again).


Liquidity Pools and Volatility 



Impermanent loss can be even bigger when you provide liquidity with high volatility tokens, instead of stablecoins. For example in the picture above the LP used Monero and Ethereum. Both tokens can be characterised as volatile tokens. Lets say now that one thirds of the deposit is ETH, second third is Monero and third third is dollar, when you withdraw the amount you will get back the initial dollar value, in the same ratio, meaning that you would have been better holding the token instead of using them in an LPool if the price ETH and Monero are increased. Usually what determines the price of the assets in the pool is the ratio between them in the pool.  

Below we can see an LPool that the LP provides Etheruem, Monero and USDT tokens:


Note: Before entering a pool consider carefully the potential impermanent loss and identify pools that allow you to become an LP using also stablecoins.

The Staking

 
In Proof of Stake (PoS) services, the user simply allocates a certain amount if money in s taking service for a certain time period and receives the equivalent APY states the Token allocated e.g. a TokenA staking service, requires to stake TokenA to be staked. The PoS consensus mechanism, nodes deposit tokens that are then used to validate transactions on the network. The nodes that are chosen are done so at random and are compensated in tokens in return. 

Staking is an alternative to mining on a proof-of-work network, where rather than expending computational energy, they give up the opportunity cost of capital. There is also risk of incorrectly validating transactions which can result in stake being slashed.  Staking requires a certain level of technical expertise, so individuals who want to earn inflationary rewards can delegate their tokens to a staking-as-a-service platform who will retain a portion of tokens earned [9]. 

Some PoS networks allow the holders of the staked coins to participate in major governance decisions of the network through a voting process. Generally speaking, the more coins that are staked, the more power this individual has on the network. 

Uniswap v3


There are DEXes and there are DEXes, or there is only one DEX or is this maybe a unicorn? Yes, there is only one DEX that we should be looking at and is Uniswap v3. Uniswap v1 was launched in November 2018 as a proof of concept for the 1st ever AMM. On May 2020, Uniswap v2 introduced new features and optimizations, setting the stage for exponential growth in AMM adoption. Less than one year since its launch, v2 has facilitated over $135bn in trading volume, ranking as one of the largest cryptocurrency spot exchanges in the world.

Uniswap is targeting to launch a Layer1 Ethereum mainnet launch on May 5, with a Layer2 (a layer on top of ETH mainet) deployment on Optimism set to follow shortly after.

Uniswap v3 introduces [10]:
  • Concentrated liquidity, giving individual LPs granular control over what price ranges their capital is allocated to. Individual positions are aggregated together into a single pool, forming one combined curve for users to trade against
  • Multiple fee tiers , allowing LPs to be appropriately compensated for taking on varying degrees of risk

Conclusion 

Impermanent loss is one of the fundamental concepts that anyone who wants to provide liquidity to AMMs should understand. In short, if the price of the deposited assets changes since the deposit, the LP may be exposed to impermanent loss. Think carefully before becoming an LP [8]. 

References:


1 comment:

  1. Many men and women followers contemplate packed although script your works. Your individual indicating discretes about the guidance reckoning situation totally will go some sort of wearisome spherical in aiding as a result many people. Treatment method in the well-known prepare! cardano staking pools

    ReplyDelete

Market outlook 04-11-2021

 Bitcoin Status The Bitcoin volume is not here yet, it seems that the retails is not "lured" yet in to the planned big "pump ...