An Introduction to DeFi II
Book Summary: “How to DeFi: Beginner — Part 3 + 4”
Book by: Darren Lau, Daryl Lau, Teh Sze Jin, Kristian Kho, Erina Azmi, Benjamin Hor, Lucius Fang, Khor Win Win
If you haven’t read my article on part 1, you can read it over here!
Chapter 5: Decentralized Stablecoins
Since cryptocurrencies are volatile, stablecoins were created to hedge against price volatility, and allow for a medium of exchange. They’re a big part of DeFi, and the top 5 stable coins occupy $59.8 billion.
There are 3 types of stable coins:
- Fiat-collateralized (Tether)
- Crypto-Collateralized (DAI)
- Algorithmic Stablecoins — Not covered in this book (it’ll be in the advanced book)
Tether, or USDT, reserves $1 per Tether that is minted. Tether is the most popular stable coin, but all these reserves aren’t open — we have to trust that they’re doing their job. Thus Tether is a centralized, fiat-collateralized stable coin.
DAI is different. It’s collateralized through other cryptocurrencies and done through protocols that are created through a DAO → DAI is a decentralized, crypto-collateralized stablecoin.
DAI is managed through MakerDAO — which has 2 tokens! DAI (the currency one, backed by a basket of other cryptocurrencies (ETH, wBTC, USDC, etc)) and MKR (the governance one, where you can vote and make changes to the organization itself).
SAI used to be the token that Maker used — it was a single collateral DAI. But Maker added more forms of collateral, and this became DAI. A Black Thursday crash caused Maker to add USDC to solve the liquidity problem that it had.
Here are 3 components of DAI:
- Collateral Ratio: It’s the ratio of DAI we get versus the collateral we put in. Ex: 150% means we have to put $150 of another cryptocurrency to get $100 of DAI
- Stability Fee: It’s the interest rate you have to pay, along with the original amount. The stability fee is determined by Maker and is based on the internal risks team’s performance risk.
- DAI Savings: It’s the interest rate of holding DAI over time.
Okay, but why would I put $150 worth of ETH or whatever to get $100 of DAI? Well here are 3 motivations:
- You need cash now, but you believe ETH or whatever will go up in the future. Maker is like the pawnshop holding on to your item
- You need cash now, but don’t want to be taxed when converting your money to cash
- Investment leverage because you think your assets will go up in value in the future.
So how do we do it? Go on the Maker Platform and borrow DAI by putting ETH (or whatever other coin) into the Vault. There’s a max amount of DAI you can take out (given the collateral ratio), but you don’t want to take out everything.
That’s because if the price of ETH drops and you go under the collateral ratio, your collateral is liquidated and you’re charged a liquidation penalty. Or you can just trade DAI and we can get DAI that way.
Black Swan event is an unpredictable and extreme event. If this happens, Maker has an Emergency Shutdown where it shut down the system and makes sure DAI holders still get their assets. March 2020 almost triggered it (ETH dropped by 50% in 24 hours). But Maker mitigated that by an automated debt auction + they introduced USDC as a collateral type.
Decentralized Lending And Borrowing:
Lending and Borrowing are some of the biggest services of the financial industry. As of April 1st, 2021, borrowing volume was 9.7 Billion (102 times bigger than before).
In CeFi, you would put up collateral, like a company, house or something else. But we need to trust an intermediary (Banks), and a credit system that ends up becoming a barrier to many to get the benefits of low-risk and high return lending.
DeFi is different. Anyone can take out loans (if you have collateral), or lend money out to get interest! Let’s investigate 2 of the biggest DeFi lending and borrowing protocols: Compound and Aave!
Compound:
It’s an ETH-based open-source protocol! It has lots of different tokens (9 so far). It’s a liquidity pool that’s built on Ethereum. Lenders just pool their money together into the liquidity pool, and borrowers take money out from that liquidity pool. Lenders get interest, and borrowers have to pay that interest.
Interest rates are APY (Annual Percentage Yield), and it’s determined for each asset through algorithms that take into account the supply and demand of the assets. This decreases the friction as lenders and borrowers can just interact with each other directly without needing to negotiate loan terms.
What’s cool is that you don’t even need to set up an account! You can just start lending/borrowing by connecting to your wallet!
Compound also has a Governance token (COMP), where they can make changes to Compound itself! You have to have more than 1% of COMP to start a proposal. 3 days later it must have 4 of the supply that votes for it, and then it’s queued, and then executed!
You can earn COMP by buying it from other people or by yield farming Compound itself to earn COMP tokens.
When you earn interest on Compound you get cTokens (if you supplied DAI you get cDAI, or if you supplied ETH you get cETH). cTokens represents how much you put in and how long you put it there. Let’s walk through an example:
- Let’s say you put down 1000 DAI, and there’s a 10% APY
- You get the cTokens right when you lend money to Compound. Thus you get 1000 cDAI
- The exchange rate for DAI and cDAI is 1:1 right now, but if you waited a year, the exchange rate becomes 1:1.1 → Thus you can exchange your 1000cDAI for 1100 DAI
The exchange ratio increases as a function of time (because that represents the interest), but you can even transfer the cTokens to other people!
When you borrow, you can just supply the collateral to the system and then you can borrow! A portion of the interest will go into the reserve and act as insurance. But what happens when the price of the collateral moves?
- Value goes up: Yay! Nothing happens, but you can take out more money if you want
- Value goes down: Boo! If the value goes below the collateral ratio then a portion will be sold off and have an 8% liquidation fee. This protects the lenders
AAVE:
Aave has more asset types than Compound — it has 24 of them as of April 2021. Aave works in a similar way as Compound, but it’s more complex + more flexible. Here are 8 key features of Aave:
- Supports more assets — 24 of them as of April 2021
- Stable and variable interest rates on loan — you can choose between the 2 interest rates
- Rate Switching — and you can switch between the two interest rates
- Collateral Swap
- Repayment with Collateral
- Flash Loans — You can take out loans with 0 collateral if you repay the loan + interest in the same transaction. Good for arbitrage traders
- Flash Liquidations — Liquidators can use flash loans to in order to get a liquidation bonus
- Native Credit Delegation — You can borrow without collateral, but pay a higher interest rate
APR is determined with algorithms, like Compound. You get aTokens instead of cTokens, which you also have to redeem. When borrowing with Aave, Aave determines the amount you can borrow which is determined with the Loan to Value ratio. If the LTV hits the liquidation threshold, up to 50% of your collateral can be liquidated + a liquidation penalty of 15%.
For governance, anyone can submit an idea on the community forum. The community gives feedback, and then it’s submitted as a proposal, which is then voted on.
Decentralized Exchanges (DEX):
In crypto, there are 2 types of exchanges: Centralized and Decentralized Exchanges. Centralized ones mean you have to trust an intermediary (which can and has been hacked in the past). DEXs use smart contracts so, assets will be held by the user’s wallets instead of the intermediary’s wallet.
There are 2 types of DEXs:
- Order Book-Based DEXs (dYdX, Deversifi). Users can buy or sell orders with limit or market prices.
- Liquidity Pool-Based DEXs (Uniswap, Balancer). Users become the market makers and provide liquidity to the exchange. They get fees on the swaps. But there are flaws here (liquidity providers might suffer from Impermanent Loss)
Limitations of DEX:
- Lower liquidity: Since lots of trades are occurring on CEXs, DEXs don’t get as good prices, have higher slippage and worst price executions. But DEXs are becoming more popular, thus are getting better
- Limited Features: They just don’t have the same features as CEXs (like limit orders, stop-loss orders, trailing stops, etc). But DEXs are implementing them
- Blockchain Interoperability: Right now you can’t trade across chains on DEXs. Ethereum Based DEXs can only trade ERC-20 tokens. Though people are building those cross-chain DEXs
- Costs: Since DeFi is getting more and more popular, you end up with a super loaded Ethereum Network, thus gas fees increase
Though DEXs are still in their infancy and they’re getting more and more popular! Let’s go through Uni-Swap to learn how they work!
Uniswap:
If we were to go through a CEX, you have to deposit your tokens in the exchange, place an order, and then withdraw your tokens. But with Uniswap it’s just 1 step!
You send your tokens to the smart contract, Uniswap algorithmically determines the exchange rate, and then the desired tokens are sent back into your wallet. This is done via liquidity pools and automated market maker mechanisms.
So Uniswap has liquidity pools. Liquidity pools are literally huge vaults of tokens. These liquidity polls are supplied by liquidity providers and are incentivized via transaction fees.
Let’s run through an example. The ETH liquidity pool has 100 ETH, and there are 460,000 DAI (1 ETH = $4600). Let’s just say you wanted to swap 4646 DAI for 1 ETH. The end result of the liquidity pools would be 99 ETH and 104,646 DAI.
The amount inside the pools determines the prices that are set by the Automated Market Maker (AMM) Mechanism.
The AMM works by always keeping a constant product between the 2 liquidity pools. So if they started off with 460,000 DAI and 100 ETH → 100,000 x 100 = 46,000,000 ← That’s the constant product!
Thus, when taking out ETH, we have to supply a proportionate amount of DAI to keep the constant product happy. But we can see that the premium changes as you take out more and more of the ETH. Premium is the additional DAI you have to use to buy 1 ETH. We can see this asymptotic nature in this table:
And you can literally add any token on Uniswap! As long as a liquidity pool exists between the two tokens, you’re free to swap it!
DEX Aggregators:
Now if we’re exchanging a ton of tokens, slippage might kill us. But there are lots DEXs today, each with its own liquidity pools. Thus we could take our trade and split it up among different DEXs to minimize slippage. But doing this manually is cumbersome.
That’s why DEX Aggregators exist! They take all the DEXs into account and give you the best price + they split large trades into smaller ones. Examples are 1inch, Paraswap, and Matcha. Let’s dive into 1inch.
1inch has over 40 sources of liquidity from multiple DEXs. Traders can route their big trades through multiple DEXs with only 1 transaction (saves gas). 1inch has its own routing algorithm (Pathfinder) which goes through all the DEXs + 1inch’s own liquidity pool before finding the optimum path.
You pay the fees of the underlying DEXs + 1inch has a governance token: 1INCH.
Decentralized Derivatives:
Derivatives are contracts whose value comes from other assets. There are many types like futures, options, or swaps. Each with its own purpose. But they’re risky and you need to know what you’re doing before using them.
The DeFi Derivatives has a market cap of $5.82 Billion, which is relatively small compared to lending. This is because of the high gas fees on Ethereum. There are 2 major ones: Synthetix and Opyn.
Synthetix:
Synthetix is a protocol for Synthetic Assets (Synths). Synthetix has its assets (Synths) and its exchange (Synethix.Exchange) to exchange those assets.
Synths are assets that are related to the prices of other assets. Thus you can have exposure to those assets without actually holding them. There are 2 types of synths: Normal Synths (positively correlated with the underlying asset) and Inverse Synths (negatively correlated with the underlying asset).
An example would be Synthetic Gold (sXAU). We can use an oracle (or multiple) to get the real price of gold.
Another Synth is Inverse Bitcoin (iBTC) which has 3 key values: (entry price, lower limit, upper limit). Let’s say the derivative was created when bitcoin was $64,000 — that’s the entry price. If the price drops by $1,000, then iBTC gains $1,000.
Inverse Synths have a range of 50% upper and lower limits. Thus it caps the loss or profit you can make. When the limit is reached, it’s frozen and your position is liquidated. We can then trade it back to Synetix.Exchange.
Why bother with Synths? Well, it’s because we don’t have to hold the actual asset (no need to travel somewhere, deal with a middleman, sign up, then get the gold). Much less hassle. But it’s also frictionless to trade Synth Gold with other assets + anyone in the world can buy real-world assets!
Alright! So how do we create our own Synths? We create them like how we create DAI on Maker! You need to stake SNX tokens (at a 500% collateral ratio since SNX is much more volatile than ETH).
You then mint the synth by taking on debt (but the debt fluctuates as the price of the asset fluctuates). Or we can just buy them from exchanges.
There are 5 major asset classes of Synths:
Index Synths: This allows people to invest in a basket of tokens without needing to buy all of them. This allows for the exposure of many segments + the diversification of risks. sCEX = CEX tokens. sDEFI = DEFI utility tokens. sFTSE = the FTSE 100 Index. NIKKEI255 = the Nikkei 255 Index. (last 2 from oracles)
Synthetic Exchanges: It’s a DEX for trading SNX + Synths. There are no order books or liquidity pools though. You’re just trading with a smart contract that maintains liquidity. The benefit is that there is no slippage since it’s all synthetic assets.
Opyn:
They protect against price volatility on assets + insurance on smart contracts. They do this with financial derivatives (options). What are options though?
There are 2 types of options:
- Call — Has the right to buy an asset at a specific price within a particular period of time
- Put — Has the right to sell an asset at a specific price within a particular period of time
Also: In order to buy the option, someone else has to sell the option to you
Here’s a super awesome analogy to understand Calls:
And there are 2 types of option flavours:
- American — you can execute the option anytime before it expires
- European — you can execute the option only at the strike date
So you can use this strategy as a way of hedging the risk of price fluctuations or insurance. Let’s say you buy a put (right to sell) ETH with a strike price of $2,400. If the price were to fall down to $2,000, we can execute the option and then get $400 back. There is a premium, but this is a way to protect yourself if the price falls.
You can buy an option through oTokens! In version 1 you could buy them wherever, but in version 2 you can buy them through an order book model (although the price of oTokens fluctuates with supply and demand).
The price usually reflects the nature of the option. If there was a put with a strike price of $3,000 but the current price is $1,000, it would be worth at least $2,000. But other factors can discount the option premium. Also since oTokens are determined through supply and demand, it’s a good signaling mechanism to check if options are under or overvalued.
If someone buys the option, someone else must sell it. You would sell it because you earn a yield on your holdings. You first have to supply some collateral to Opyn (140% to 100%). Then you mint oTokens.
You can then be a Liquidity provider on Uniswap, or you can sell the Tokens on Uniswap. And you can earn some nice premiums on this — but you have the risk that an adverse event doesn’t happen (hacks, or financial risks) + you have to maintain the collateralization ratio, else be liquidated.
Opyn has been audited, it’s non-custodial and trustless.
Version 2 has some additional features like:
- European style options
- Margin improvements (put credit + debit spreads)
- Options that automatically exercise when it expires
- Anyone can create options if the asset is whitelisted
- Yield-bearing assets can be collateral
Decentralized Fund Management:
Fund management is all about overseeing your money and investing it so it can make more money for you! But instead of a boring centralized fund manager, we can have decentralized, and automated smart contracts which invest for you! This reduces the fees paid!
TokenSets:
This is a platform where you can buy Strategy Enabled Tokens (SETs). These tokens are automated strats that manage your money. Each set = an ERC20 which holds a basket of cryptocurrencies + rebalances its holdings automatically.
There are 2 types of sets:
- Index Sets: You can get exposure to a ton of different tokens and reduce the gas fees (cause you only have to buy 1 token instead of multiple of them) Most popular = DeFi Pulse Index (DPI)
- Yield Farming Sets: You save on gas because you don’t have to call smart contracts constantly for LP farming. The set will do it all (Claim rewards, sell them, stake them again) for you
Though you have to do your research on each of those, previous performance is not indicative of future performance. The DeFi Pulse Index set is a collection of 14 different assets and it uses the market capitalization weighting strategy.
The overall strategy won’t do as well as some of the individual ones, but it still outperformed 11 of them! Thus, unless you have a competitive advantage, your best bet is to use the strategy.
Decentralized Lottery:
A no-loss lottery! Basically, you can put in $10 and have a 1 in 69,738 chance to win $1,648. But the best part is that everyone who puts money gets refunded back. This is a no-loss lottery?
So where does the money come from? It’s from the interest (earned through Compound) that’s accumulated from the lottery tickets! You literally just purchase the entry tickets (you can buy as many as you want, each ticket increases the probability of winning)
PoolTogether is the protocol for this! You can buy it with 4 different types of currencies (DAI, USDC, UNI, and COMP). Plus sponsors can provide some extra tokens which are called a loot box.
This ain’t new though — CeFi has something called Prize-Linked Savings Account (PSLA) where the money in your account is put into a lotto second. But the major advantage of Decentralization is that there are no middlemen, no lock-up period, we can see the prize distribution is fair and correct.
But CeFi can’t give PSLA to anyone, gambling laws restrict only people from certain geographic areas from participating.
But can’t we just shove our money into Compound? Yup, we can! The opportunity cost is the “fee” that we’re paying to get the potential payout. The probability of winning is proportional to the number of tickets sold (more tickets = more payout too!).
PoolTogether has governance tokens (POOL), and these tokens were given out to those using the platform (airdrop) based on the amount and duration of time their money was in PoolTogether. Only 5% of the total supply was deposited at the airdrop. And 57.54% was put under the treasury which will be diverted by governance.
POOL Governance can vote on: Creating referral programs, setting liquidity mining programs, grant programs, adjusting the number of winners, prize frequencies, new prize strats and new prize pools.
Decentralized Payments:
So a huge part of crypto is all about transactions. But that’s just sending money from one person to another in a decentralized manner. But what if we wanted cheaper, faster, timed transfers, conditional transfers, invoice formats etc! There are a few projects out there, but let’s talk about Sablier.
Sablier allows for payment streaming. So instead of waiting a certain amount of time (weekly, bi-weekly) and then paying (rent, contract work), we could have money be drawn out of the account in real-time.
What’s the deal? For those who are living paycheck to paycheck, this is a big deal. Because if there’s a delay in their income, they end up taking out loans with huge interest rates to get food on the table. This also establishes trust between contract workers and employers, since they’re paid in real-time. Additionally, you can use the money that you’ve earned so far and no need to wait for the monthly or bi-weekly payment.
In the current system, you either pay upfront (have to trust the provider), pay later (have to trust the client) or put it in an escrow (have to trust the escrow). But with Sablier you don’t have to trust anyone. Everything is paid in real-time and managed by immutable code, rather than humans.
Decentralized Insurance:
In DeFi, you always have to lock up money as collateral, which is a potential vector for attack. Even though the code has been audited, millions of dollars have been stolen in hacks. There are some inherent risks in DeFi:
- Technical Risks: Smart contracts are hacked, bugs are exploited
- Liquidity Risks: Lending protocols run out of liquidity
- Admin Key Risks: The master private key of the protocol is compromised
To mitigate these risks we have insurance! We’ll go through Nexus Mutual and Armor.
Nexus Mutual is a decentralized insurance protocol that covers 64 smart contracts and custody cover for centralized ledgers + exchanges. They cover against hacks of smart contracts, but not negligence (loss of private keys).
For custody cover, it’s when a centralized exchange controls your assets. You get money if more than 10% of your funds are lost, or when the withdrawal is halted for more than 90 days.
So how do I get insurance? You first become a member of Nexus Mutual, then you select the Cover Amount (the amount you’re paid out in case the smart contract fails) + the Cover Period (how long this lasts). If a hack occurs then Claim Assessors will evaluate the situation and send the money out.
This costs something of course. the pricing depends on things like the Cover Amount, the Cover Period, and the evaluation by the Risk Assessors.
Nexus has a Token too! It’s called NXM. NXM is used to buy cover, vote on governance, used to participate in Risk and Claims Assessments, and represents Mutual’s capital (As the capital rises, the price of the coin rises too).
The price is determined by a bonding curve that relates to the amount of capital that Nexus Mutual has, and also how much capital Nexus needs to meet claims (weighted by their probabilities).
You can’t buy NXM, it’s an internal token that is obtained through becoming a member of Nexus Mutual (you have to go through KYC and AML). But you can go through Armor and not do the KYC.
There’s also wNXM, which is a wrapped NXM. This can be bought on the open market and transferred. You can then unwrap it and it becomes NXM!
Also, who are these risk assessors? They’re the people who are staking against smart contracts. They’ve done the analysis/trust other people’s analyses and think trust that the smart contract is safe. By doing so they earn NXM rewards.
DeFi is getting more and more complicated, but also able to be integrated with each other like “money legos”. Money legos allow for people to build complex pipelines without needing to create everything from the ground up! But this creates a risk where 1 failure can affect multiple protocols.
Also, Armor is an insurance aggregator for DeFi. You can buy insurance covers without KYC or are restricted by Nexus Mutual’s geographic restrictions.
Another insurance project is Nsure Network where you can trade insurance risks and everything is determined by the free market. It has a governance token and is subject to the free market but tokens are shares in the network!
Cover is a peer-to-peer insurance market. You put down money (ex: 100 DAI) as coverage and insurance is minted with an expiry date. This mints (100) CLAIM and (100) NOCLAIM. People have to buy CLAIM (that’s the insurance premium) from you. If the event happens (100) CLAIM can get access to the collateral (100 DAI). Else the (100) NOCLAIM gets back the collateral (100 DAI).
Insurance is a niche that not many are using, but it’s expected to increase as more people come into the market.
Governance:
Imagine building the next big thing in DeFi, but you have to manage a bunch of people in different timezones, objectives, when you’re limited to social media, and when there’s lots of money involved. Luckily, we can use blockchain to help us!
Decentralized Autonomous Organizations (DAOs) are what emerge! They are organizations governed by smart contracts and align groups of people to work on a common goal!
Governance tokens as voting power aren’t perfect. There are many problems with it (voter apathy, gas fees to vote, non-binding voting results). But crypto is in its infancy and we’ll get better tools. But until then, governance tokens are what we’ve got!
Let’s talk about 2 projects that are governing tools: Aragon and Snapshot!
Aragon was founded to make sure that web3 is free, fair and open to everyone! Thus they created lots of tools to help DAOs. One tool is Aargon Court.
This is like a court where a bunch of jurors vote on the correct outcome between 2 parties. Jurors are compensated when they vote with the majority and punished (stake taken away) when they vote with the minority. Parties can pay a fee to appeal the dispute with more jurors.
Jurors are selected from the juror pool, and they’re able to join the juror pool if they have more than 10,000 Aragon Court Tokens (ANJ) + you can buy them!
So far big DeFi projects like Aave and Curve use Aragon + 1600 other DAOs!
Snapshot is tackling the problem of super-high gas fees to vote. Snapshot takes a snapshot of all the votes off-chain. This makes the voting process basically free.
But the problem is that voting results are not binding on-chain you need people to push the vote on the chain. Thus it’s still a bit centralized but it’s practical and cost-effective.
DeFi Dashboard:
This just aggregates all your DeFi activities in 1 place and then tracks + visualizes all your assets + bins your investments into categories. You can enter your ETH address or ENS domain. 2 dashboards are Zapper and Zerion.
DeFi In Action:
Let’s talk about how people in this world are actually using DeFi to change their lives!
For example, Argentina had an all-time high inflation rate of 53.8% annually — your money is halved every single year. So some people wanted to be paid in USD.
But the Argentinian government made it damn hard to do so. Capital control of $200 USD per month (black market prices of USD rose by 30% higher than the exchange rates), punishing those who went over the limit by leaking their personal information, and forcing USD liquidation for those who worked for foreign companies.
Some turned to Bitcoin, which is volatile, thus they turned to DAI! You withdraw as little as possible to pay all your expenses. The rest is kept in DAI. Using this DAI we can invest it and gain access to other financial instruments.
Additionally, people around the world are all blocked from accessing financial institutions. DeFi allows them to access them though. For example, Uniswap was forced to geo-block people from accessing their website to do exchanges.
But that didn’t stop other sites from popping up and connecting people to Uniswap (since Uniswap is on Ethereum). Anyone can access DeFi financial instruments from everywhere.
DeFi is the Future, and the Future is Now:
DeFi is still nascent, but it’s growing with ferocious power and potential! CeFi is starting to bridge into DeFi and DeFi is becoming the alternative financial ecosystem. DeFi is the future of finance.
The growth has been insane, just look at the numbers of TVL:
- 2018: 5x increase from $50 million to $275 million
- 2019: 2.4x to $667 million
- 2020: 23.5x to $15.7 billion
- 2021: 5.5x to $86.06 billion (as of April 2021). 11x to $172 billion (as of November 2021)
Finally, a recap of the benefits of DeFi:
- Transparency: You can see and audit everything
- Accessibility: You can access DeFi anywhere with no fear of discrimination
- Efficiency: Removing the centralized middleman to make a more efficient financial market
- Convenience: You can send money anywhere, anytime to anyone. Small fee with tiny waiting time
Also the DeFi User Experience! Argent is creating a state-of-the-art wallet experience. Zapper is combining many DeFi products. Gelato Finance created the “if this, then that” of crypto. Nexus Mutual has insurance. 1inch is aggregating DEXs, and Yield optimizers exist!
So many lego blocks, so much potential to change the world!
If you want to find out more: Read the book here!
Thanks for reading! I’m Dickson, an 18-year-old Crypto enthusiast who’s excited to use it to impact billions of people 🌎
If you want to follow along on my journey, you can join my monthly newsletter, check out my website, and connect on LinkedIn or Twitter 😃