Welcome to the third course in the learning experience, DeFi in the future of finance. In this course, we're going to take a deep dive into the most popular protocols that are available today and will be available in the DeFi space. This is the third course. Actually I recommend that you do the first two before this course. This course is going to seem very confusing because we've already gone through and established the basic infrastructure of DeFi. We spent a lot of time on the primitives that are fundamental to DeFi. Now we're going to put it all together and talk about the particular protocols that are the leading forces in the DeFi space. Let's get to it. What I will do, we've got four modules today; credit and lending. I will talk about three protocols that are important. MakerDAO, compound, and Aave. Then the second module is decentralized finance, the third is derivatives, and then the fourth is tokenization. Let's start with MakerDAO, which is pioneering DeFi application. Let's start with the creation of DAI. MakerDAO, and we've actually already gone through the definition of what a DAO is. DAO is decentralized autonomous organization. It's no surprise that MakerDAO is a decentralized autonomous organization. The key in terms of the value-add here is to introduce a crypto- collateralized stablecoin. We've talked about stablecoins before. Remember, the stablecoin is only as stable as what it's pegged to. If you're pegged to gold, that stablecoin is going to be more volatile than, let's say, pegged to the US dollar. A stablecoin, there's various different ways to do it that we've discussed. One is to collateralize with, let's say fiat currency, like the US dollar. That is the model of USDC, which is a ERC-20 token. But it's centralized because there's an organization that basically manages the collateral, and provides vaulting, and audit all functions. It is a centralized stablecoin. DAI was one of the first decentralized stablecoins. One big advantage of a decentralized stablecoin that uses crypto is that the crypto-collateral, you don't need to vault, you don't need to audit. It is available to view by anybody in the network. You can exactly see the collateralization in real-time. Because there's a lot of advantages to actually using a crypto, but there are some disadvantages too. That is that the crypto is going to be volatile that's used for collateral. For example, Ethereum is much more volatile than for example, the US dollar. This is a protocol model that has two tokens. DAI is the stablecoin, and Maker MKR will be the governance token. I'm going to talk about both of these. That's the background. Let's talk about the mechanics of DAI. This is essentially the way that it happens. A user can deposit some ETH, and it doesn't have to be ETH, it can be another ERC-20 token that is approved in the governance of the protocol. Deposit it into a vault, which is just a smart contract. That vault will escrow the collateral. It will basically, in doing that escrow, anybody can see it and anybody can figure out what the value of that escrow is. When the user actually does this, they can mint some DAI up to a certain collateralization ratio. This creates debt. The debt is in DAI and that debt needs to be paid back to the vault. That's the basic model of what's going to happen. You deposit some ether and then there'll be some lateralization ratio that we'll go through in considerable detail, and there'll be some debt that is denominated in DAI. The user can take that DAI, and basically do whatever they want with that. You could sell the DAI for cash and use that cash to buy whatever you want to buy, say a car. But there's also another possibility that's interesting. You can take the DAI and buy some more Ether and then do this process again. When you do that, you create a leveraged, position in Ether. Effectively you're borrowing to buy more Ether. Ether, of course, is much more volatile than, let's say US dollar. The collateralization needs to be more than a 100 percent. If it's a 100 percent, it easily could drop below a 100 percent, and then that will affect the value of DAI. What we want to do is to keep DAI as close as possible to the value of the US dollar. A typical collateralization ratio, if we're using a volatile crypto, like Ether, would be 150-200 percent range. The whole setup here if you're familiar with centralized finance, is actually nothing new except we're doing it within the DeFi space. This is just a collateralized debt position or CDP. It's analogous to a mortgage. Think of the homeowner. The homeowner needs some cash for whatever purpose. One thing they could do would be just to sell their house and take the cash, then use that cash for whatever purpose. But maybe they don't need that much cash number 1. Number 2, maybe they don't want to sell their house because they believe the house is going to appreciate in value. What do you do? You go to a centralized bank, commercial bank and get a mortgage. To get the cash and the mortgage, you need to pledge as collateral your house. The house is worth more than the mortgage. It is over-collateralized. The price of Ether is way more volatile than a price of a house. It makes sense that the collateralization ratios for Ether need to be much higher than, let's say, a typical mortgage. There's obviously other differences. This happens algorithmically. There's no overhead, no back-office, no credit check, no lawyers, no brick and mortar. This is extremely efficient in terms of how this is actually executed and is executed quickly. I recently refinanced my home mortgage and it was a nightmare in terms of the number of steps, the cost. All of these things that were in my opinion, unnecessary, had to happen and it took weeks to get done. This happens very quickly. Within a few minutes. This is just a collateralized debt position. In this course, we've got lots of examples and I think the best way to really understand what's going on is with examples. I've got many and let's start. You've got an owner of ETH and they need some liquidity. But they don't want to sell the ETH because for the same reason as the homeowner, they actually believe it's going to appreciate in value. We're going to use the maker DAO structure and essentially, deposits some ETH and withdraw some DAO, which is analogous to cash. Very straightforward, and let's go through and actually do that. Suppose an investor has five ETH and the market price is 200. That means the total amount of value in the five ETH is a $1000. If the collateralization ratio is 150 percent then the investor can mint. After depositing the 5 ETH, they can mint 667 DAI. That's just calculated as 1,000 divided by the collateralization ration ratio which is 1.5 and throughout this course, there'll be rounding. I won't use the decimal places. Again, this ratio is set fairly high because we know that the value of ETH is much more volatile than the value of DAI, which is linked to the US dollar. It doesn't really make any sense. If you were allowed, for example, to mint $1,000 worth of DAI because just a daily fluctuation in the price of ETH would mean that the loan would be under collateralized. This again would damage the stability of the DAI. The peg is credible only if you've got the reserves. That's true in centralized finance too. If a country has pegged their currency to another currency, that peg is only credible if they've got the reserves and if they run out of reserves then the peg is broken. We've got plenty of situations historically where that happened. That's the basic background. Let's continue this example. We've got collateralization of 1.5. It's going to be unwise to mint the maximum, which is 667. Because again, if you fall below, then you are under collateralized and subject to liquidation, which we'll go through in considerable detail. When you go and become under collateralized, in traditional finance, your broker calls you and you get a so-called margin call. You're asked to post more collateral. The DeFi space, there's nothing like that. If you go and become under collateralized then a position's going to be closed out. It's up to you to actually watch to make sure that you are not liquidated. Therefore, we're not going to mint 667, we're going to mint less. Let's actually go through an example here. In this graphic, we review that we've got 5 ETH and we deposit those into the vault, which is just a smart contract. What we're going to do is not mInt 667, but we're going to mint 500. This is a situation where we've got a buffer. There is the over-collateralization which is 333 and we've got this buffer of 167 and we will mint 500. You can see that this works out, so the loan is 500 based upon the deposit of 5 ETH. Let's look at a couple of scenarios and the first scenario is that the ETHER appreciates and it goes up by 50 percent. In this situation, we go from $200 per ether to 300. Let's go through the mechanics. Now the collateral will be worth not $1,000 but $1,500. With this collateralization ratio of 1.5, we can actually increase the value of our loan. Originally we took out 500, and that means we minted 500 DAI. But given that the collateral is increased in value, we can basically do an additional loan of 250 so the total amount loan would be 750 based upon this new value and that would maintain the collateralization. We'll be done our collateralization ratio that we've actually imposed for ourselves is not 1.5, but two and this is to allow some buffer, if it does drop, we won't be immediately liquidated. Now let's talk about liquidation.