1. Decentralized Finance (DeFi) Infrastructure

01_the-history-of-decentralized-finance

01_what-is-decentralized-finance-DeFi

02_about-this-specialization.en

DeFi in the future finance is a set of four courses that I’m offering that focus on decentralized finance. Let me set the stage. This course is about a forthcoming revolution in finance. It’s remarkable that are centralized financial system has not substantially changed over the past century, while there’s digitization with the same banks, brokers, exchanges, insurance companies, and central monetary authorities. I will argue that the current system is failing, why does it cost 300 basis points every time a credit card is swiped? Why are savings rate zero or negative? Why are barring rates so high? Why is the transfer of money expensive, slow, and insecure? How is it possible in the age of the Internet that it can take two days to transfer the ownership after I buy shares in a company? Why during the global financial crisis that we have to bailout the very institutions that caused the crisis? Why are there 1.7 billion people in the world that are unbanked and many more under banked? Decentralized finance, or DeFi, is an emerging disruption. In decentralized finance we interact amongst peers via smart contracts. These algorithms do not carry the baggage of traditional finance. There are no layers of bureaucracy and back-office staff. When peers interact, there’s no middle person making a large spread or commission. Furthermore decentralized apps are interoperable, for example, in centralized finance it might take days to send money from your broker to your bank or vice versa, no such delay exists in DeFi. Finally the current system is very opaque. We rely upon government regulators to watch for trouble in our financial sector and history suggests a dubious track record of monitoring. In DeFi everything is transparent a key characteristic, a block chain technology. Let me describe what we cover in this learning experience. In the first course, DeFi Infrastructure we begin by exploring the origins of DeFi and take a broad historical view from the earliest barter economies to the present day. We then focus on the key infrastructure components; blockchain, cryptocurrency, smart contracts, oracles, stable coins, and decentralized applications or dApps. Next, we focused on the specific problems that DeFi is designed to solve; inefficiency, limited access, opacity, centralized control, and lack of interoperability. The second course is called DeFi Primitives. Here we talk about transaction mechanics, fungible and non-fungible tokens or NFTs, custody, supply adjustment, incentives, swaps, collateralized loans, and flash loans. The third course is called DeFi Deep Dive. It is the longest of the four courses and focuses on some of the leading protocols in the DeFi space. We will look at credit and lending and feature makerDAO, compounds and Aave, decentralized exchange with an analysis of how protocols like Uniswap work, derivatives, featuring yield protocol dy, dx and synthetics and tokenization with an analysis of the set protocol as well as wrapped Bitcoin. The final course is called DeFi Risks. Any analysis of a new technology must clearly gauge the risks and challenges. The topics include; smart contract risk, governance risk, oracle risk, scaling risk, decentralized exchange or DEX risk, custodial risk, environmental risk as well as regulatory risk. Let me also tell you what this series is not. This set of courses does not teach you how to trade Bitcoin, this is a course about understanding the foundation of a new financial system, it is a system of inclusion of financial democracy where all peers are treated equally. Importantly the current way of a fintech largely uses the current centralized financial architecture. I believe many of these firms are fleeting and they in turn will be replaced by decentralized protocols. To be clear I’m not talking about a renovation of our current financial system I’m talking about a complete rebuild from the bottom-up. The course is largely based upon my new book, DeFi and the Future of Finance, written with Ashwin Ramachandran and Joe Santorum. If you want to be part of this revolution in finance, a good starting point is this course.

02_the-value-of-money

01_evolution.en

Let’s start the first course at DeFi Infrastructure. Well, we’ll do actually four different modules. The first module is the history of decentralized finance. It’s got a number of components. It’s actually interesting that decentralized finance has got rather a long history. It’s not just the last few years. We’ll explore the nature of money, and this idea that money can have tangible and intangible value. We will give a brief overview of the problems that are endemic and centralized finance or CeFi. We’ll go into much more detail on that later. We’ll talk about early CeDeFi, so that’s centralized decentralized finance, and I’ll let you know what I mean by that at the point, and of course, the crypto origins. The second module is DeFi foundations. The third addresses in much greater detail the problems that DeFi solves. The fourth module has to do with the popular myths about decentralized finance. I’ll try to go through and explore each of these myths and keep you a better understanding of what actually is happening within the space. Let’s start with the first module, the history of decentralized finance. Evolution. How I really mean evolution? It’s been quite a while in terms of decentralized finance. If you go back in time, think about the earliest method of market transaction. It was barter. Interestingly, barter is a peer-to-peer technology. This is essentially the first decentralized finance where we’ve got peers interacting with each other. But the early barter was very, very inefficient. You want a cow and you’ve got two goats, you need to find somebody that’s got the cow and wants the two goats. So very, very difficult. Indeed, what actually happened was that a system of credit evolved or gifts, it was called, where you give somebody something and then they would give in return at some other point a surplus of what they actually had. Again, this type of market economy, very inefficient. The main inefficiency was the matching problem. You had to have an exchange that made sense to both peers. Money was introduced and it largely solved the matching a problem. Let’s go through the purposes of money, and I put them into two groups. One is a unit of account. This is a way to compare the value of different goods and services. Number 2, which is the most important quality, is a medium of exchange. This allows us to get around the barter that we can use money. I put this secondary, but many people put this primary a store of value. This is the idea that you could sell your good for money and effectively store that value. If you kept your good, it might spoil. It allowed for some savings and insurance. The fourth attribute is a transfer of value. It actually makes it very easy with money to transfer a value or to defer a value. What about the characteristics of money? Number 1, it needs to be durable. Ideally, you can use it multiple times. Coins, for example, are very durable. Paper money or a plastic money as we have learned actually today, that is not as durable, but there’s a system of recycling so that the old paper is replaced with new paper. Portability. You need to be able to carry it around. There’s some exceptions here that I’ll talk about, but a very important attribute is just the ease of use. The third attribute is divisibility. We all know that a dollar can be divided into 100 cents, so fractional units are important also. Uniformity is also an important attribute. Basically, one dollar that was printed last year has the same value as one dollar that’s printed this year. The next one is limited supply. I think, I have a good intuition as to what happens if supply becomes unlimited or near unlimited. We all know the stories of severe hyperinflations, whether it’s in Weimar, Germany or Brazil. Where when the supply gets out of control, then the value or the usability of the currency is greatly diminished. Another attribute is acceptability. The US dollar within the US is legal tender for all debts, public and private. That means that you need to be able to accept the US dollar by law. Because that’s a very powerful characteristic for US currency. The last one is stability. This is a subtle, a characteristic which we will address in this course. Because cryptocurrencies are, in general, not stable. But the idea here is if the currency is very unstable, then people will look for alternatives. These are the basic characteristics of money. This is an example of the portability characteristic, and people talk about returning to the gold standard, or some people talk about that. Gold is not very portable. This actually shows to move, a lot of gold is extremely difficult just because of the weight of the gold. A little on the security that’s involved in moving it from one vault to another vault. Let’s do a very quick history of money. We’ll start about 9000 BCE with a barter economy. We know a fair bit about this. It’s even portrayed in various pictures that have survived to this day. As I mentioned, this was very inefficient. It took a long time but gold coins were introduced about 600 BCE in Lydia. This solved many problems that were caused by the inefficiency of the barter system. These coins actually have value, so They have tangible value because gold, even back in 600 BCE, was used for other things. It was used in the arts as it is today. Indeed, 70 percent of the gold that is used today is used in things like jewelry. Gold actually has a tangible value, whether it’s for jewelry or technology or dental work, It’s got other uses. Banknotes came from China and Marco Polo indeed introduced the idea to Europe. They, again, have a long history. But this was the first paper currency. This is a special one for me. 1871 is the date of the very first wire transfer by Western Union. This is an example of what it looked like, so that actual paper has been preserved. What I’d like you to notice is the amount, $300. But there’s also something else that’s interesting in his transfer and that is the fee. Notice the fee is nine dollars, three percent. This is 150 years ago. Even today, we’ve got essentially the same situation. You swipe your credit card, three percent, you send a wire transfer, three percent or more. It’s remarkable to me that we’ve gone 150 years without greatly reducing our cost. This again motivates where we’re going in terms of decentralized finance. Credit cards introduced in 1950 with the Diners Club Card. They’ve been around for a while. 1967 is the first ATM and that was introduced by Barclays Bank in London. Telephone banking, which is routine today reaches back to 1983 with the Bank of Scotland. Internet banking, not surprising, came from California. The Stanford Federal Credit Union offered for the first time a way to do banking via the Internet. Contactless payment, this was introduced by Mobil in the form of its speed pass. It’s interesting application because swiping a credit card at a gasoline station actually is very risky for the credit card company because often when a credit card is stolen, the first place that’s tried is the gas station, and the fees associated with a credit card swipe at a gas station traditionally much higher than, let’s say a restaurant, like five percent. Mobil realizing that they could basically give you cash back and still be far better off than if the customer swiped with a credit card. Chip and PIN was introduced in 2005. It’s interesting to me given the insecurity of credit cards that the PIN part is largely not implemented in the United States. 2008 is a big year. This was in the depths of the financial crisis, and we will talk about this in much more detail in the course. But in 2008, a famous white paper was put on the Internet by Satoshi Nakamoto. We don’t really know who he, or she, or whether it’s a group of people that authored this paper, nobody knows for sure, but we do know that this paper was transformational, a highly impactful paper in finance. We will go through some of the details in that paper. To be clear, this course is about decentralized finance and mainly focuses on Ethereum and applications of the Ethereum blockchain rather than Bitcoin. But nevertheless, we will talk in some detail about Bitcoin. It is the first cryptocurrency and a bellwether, and indeed its market capitalization is roughly 1/2 of the value of all cryptocurrencies. This was an important innovation, and we know in 2014, Apple Pay was introduced, a much more secure way to do a credit card because using facial recognition, or a PIN directly, whereas in the US at least people aren’t required to use a PIN. The deal that Apple got with the credit card companies was a very good deal because any payment with Apple Pay is much lower probability of a fraudulent payment. The world of blockchain really exploded in 2020 and 2021. Essentially, all leading banks have blockchain initiatives. They know now that this is not a niche product. This is something really serious. It is a serious threat to their business model. Indeed, the CEO of Goldman Sachs said, “Assume that all major financial institutions around the world are looking at the potential of tokenization, stablecoins, and frictionless payments.” They’re not just looking at it. They have teams of people trying to figure out what they can do. They realized that they have to reduce costs. It’s unacceptable what the costs are, and the competition via the decentralized finance space is after them. There’s also, and we’ll talk about in the course, a lot of regulatory risk. But in general, regulators that are at least economists realized that reducing frictions, reducing transactions costs, making transactions more efficient, that’s a good thing. There’s a lot of things, well, actually almost everything in economics, you can get one side versus the other side. There’s very few things that economists agree upon. But one thing that they agree upon is that if you reduce transactions costs or frictions, that’s a good thing for the economy in general, for everybody in general. There have been many positive initiatives and indeed, the OCC has granted permission to use stablecoins as a more efficient way of doing transfer, and we will talk in detail about what stablecoins actually are.

02_can-money-have-intangible-value.en

One issue that comes up a lot is, where does the value actually come from in terms of the cryptocurrency? For example, Bitcoin. Many people believe that the value is zero. The idea is that bitcoin doesn’t pay any dividends, it’s got no cash flows. It’s not backed by anything. It’s a computer program. How can it have value? I think that it’s really important to distinguish between tangible value and intangible value. Let me explore this. The story that I like to tell my students is the story of the Iraqi Swiss dinar. Maybe you don’t know this particular tale, and I will explore it for you. The Iraqi dinar was the currency of Iraq until the first Gulf War in 1990. Now, it turns out that Iraq and Saddam Hussein had outsourced the printing of the dinar. It’s called the Iraqi Swiss dinar because the printing plates were manufactured in Switzerland, and the actual production or the printing of the currency was done in the UK. In 1991, at the end of the war, Iraq was split into two pieces. In the South, Saddam Hussein controlled Iraq, in the North the Kurds. Then a number of sanctions were imposed on Iraq. One issue with the sanction was that it was impossible for the UK to export the freshly printed dinars to Iraq. Saddam Hussein had to scramble and develop his own printing facility in Iraq to print a new currency. That actually happened. The idea was that an edict went out from the Central Bank of Iraq, and citizens were given three weeks to exchange the old dinars, which I’ll call the Iraqi Swiss dinar, for the new dinar which I will sometimes called the Saddam dinar. This was pretty important, that citizens had to transfer to go to the bank to exchange for the new dinar because if they didn’t do this in three weeks, the old dinar would not be legal tender. It would be worthless. Some people basically did this in the South, but this didn’t apply to the North. The North was basically separate. There was no Central Bank of Iraq that had any influence there. Basically, what happened was the Kurds in the North just decided to continue using the Iraqi Swiss dinar. To be clear, that dinar, it’s got no value, according to the Central Bank of Iraq. But it was used as if it did had value. Now, this is especially interesting that Saddam Hussein in the South, was desperate for money to pay for various things, and they decided to inflate. They kept on printing the new dinars. At some point, the exchange rate was 300 of the Saddam dinars for one of the old unbacked Iraqi Swiss dinars. The point I’m making here is that it is possible to have value even though the currency isn’t necessarily backed by anything. This is a recent example, but it’s not the only example in history. The Iraqi Swiss dinar continued to be used and it had value, even though technically, it was unbacked by the Central Bank of Iraq. There’s many other examples in history. Perhaps the most famous one are stone currency from the Island of Yap in the South Pacific. Indeed, these failed on the portability that I mentioned in terms of the characteristic of currency. But again, these stones really didn’t have any fundamental value. But they were used and that economy thrived in its time. The message here is that we need to recognize the difference between tangible and intangible value. Gold, as I mentioned, a gold coin has got tangible value. The US currency, even though it’s not backed by gold since 1971, it’s got some value in that the government can tax you and you need to pay in US dollars. It’s got tangible value because it’s legal tender and must be accepted. It’s got tangible value because if you violate not accepting the dollar or something like that, then you could be incarcerated. But it’s also important to think about intangible value. Indeed, our economy today is built upon intangible value. We used to be a manufacturing economy, we’re no longer a manufacturing economy in the US. Much of the value that’s created is intangible. Given that we’re more than willing to assign value to companies that have no IP research and development, patents, specialized software, trademarks, customer lists. People are willing to assign value there for these intangibles, and I think it makes it easier to make the case that intangible value is very important for crypto space in general. Let me come to today, decentralized finance is going to enable efficient peer to peer transactions without the centralized institution. We will deal with an idea throughout the four courses of tokenization of almost anything. This goes well beyond Bitcoin and Ethereum. Hint the possibility of an efficient barter mechanism. Again, remember this, that one of the themes in this course is that decentralized finance actually opens up the possibility of returning to barter, but in a much more efficient way. Next, we’ll talk about some of the problems with decentralized finance.

03_centralized-finance-and-centralized-decentralized-finance

01_brief-overview-of-cefi-problems.en

Now what I want to do is to give a very brief overview of some of the problems with centralized finance or CeFi. It’s very brief because we will go through in much greater detail later in the course these problems one by one. But I want to introduce the problems. What’s the reason for this? You’ve got a new technology. The new technology to be viable has to solve problems. It’s not particularly useful to solve a problem that doesn’t exist or a problem that might exist in the future. It’s much more credible to actually address the problems that we deal with right now. Let me go through some of these problems. There are five that I focus on. There are more, but these are five that are important. Centralized control, limited access, inefficiency, lack of interoperability, and opacity. Again, I just want to do an overview and we will get back to each of these in much greater detail. To centralize control, our banking system is highly concentrated. It’s interesting that it’s not as concentrated as, let’s say, in Europe or Canada, but it is concentrated. Our large banks have significant influence. Central national banks, like the Federal Reserve or the Bank of England, also have control over the fiat currencies. There’s concentration in other areas too. There’s non-financial centralization that you could argue is linked to finance. Amazon and retail, Facebook, Google, and digital advertising. These are firms with enormous market power. These are firms that are, at least we know for one of them, Facebook, very interested in investigating cryptocurrency. It makes sense for them. Given the amount of business that they actually do, that it comes down to a credit card to save that three percent is a big deal. Limited access, again I’ll talk in more detail about this. But there are 1.7 billion people that are unbanked. There’s probably more than that are underbanked. Our financial system, even though it’s been operating in its current form for a little over a 100 years, a lot of people are left out. As I’ll go through a little later, this means that many entrepreneurs are forced to use a credit card to get financing for their business. We know what those credit card rates are. Like 20 percent or more. That can’t be a good thing. Number three is inefficiency and we’ve talked already about the three percent swipe. Look, don’t fool yourself by saying, well, I don’t pay the three percent, it’s the retailer that does. Well, that’s pretty naive because that three percent makes its way into the price that you’re actually paying or part of the three percent. I talked about the inefficiency of a wire transfer or the two day settlement when you buy a stock, that just seems unacceptable in the age of the Internet. Transfer is slow, it’s fraud. Credit card companies might say, “Well, we have to charge three percent because we need to spend that money on security. We will guarantee if somebody steals your card and uses it, we’ll pay you back. You’re not affected, there’ll be a chargeback.” Essentially you’re paying that three percent because they’ve got a flawed technology, you’re subsidizing a flawed technology. It’s also no possibility of microtransactions, which I’ll talk about also. It’s interesting in this space. It’s also difficult to get paid. We take a paying on the Internet with a credit card its much more difficult to receive funds. There are some Fintech technologies that are allowing people to do this, but those technologies largely use the centralized finance backbone. Lack of interoperability. Our institutions are highly siloed. To do something really simple, like move some money from my bank to my Robinhood account, that’s going to take two or three days. Let’s say I want to buy something like a stock on Robinhood or some other broker platform and I want to do it quickly. Well, it’s really difficult to do quickly because I have to transfer the money using decentralized system and it’s going take two or three days. Again, it is frustrating in the age of the Internet that it would take so long to do this. Some of these companies recognize that this is a problem and there had been efforts, for example, visa attempted to acquire Plaid. Plaid is a fintech platform that links to make things more interoperable. But interestingly enough, that transaction was blocked by the regulators. The last thing is opacity. There’s very little transparency. You go to the bank, you see one bank advertising a savings rate or a CD rate that is much higher than the other bank. Well, maybe they’re doing that because they’re in distress, that they’re just risky, and it’s really hard for customers to figure out the risk of the actual bank. Indeed, what we have to do is to rely upon regulation. Thousands of people that are inspecting the banks. So it’s not out in the open and that’s what DeFi actually does. I’m going to argue that these frictions, these problems cause missed growth opportunities. This is very much related to some of my academic research. The idea is really simple. The entrepreneur goes to the bank with a great idea and it might be 25 percent return on investment. Very exciting idea. They need a loan, but the bank’s not interested because the bank would rather deal with a very large customer, rather than dealing with many small customers. The entrepreneur might have a relationship with the bank and the bank says, well, we will boost your credit limit on your credit card and you can borrow the money on the credit card. That rate could be 24 percent. When you think about it, the return on investment,25, the cost of capital, 24 percent. What happens? The project is not pursued. That is really damaging for the economy. All economies need economic growth. Indeed, many economies are greatly indebted. The amount of government debt divided by, let’s say, GDP for many countries is at an all-time high, or at least an all-time non wartime high. That debt needs to be paid back. There are three ways to do that. One way is to raise taxes and we know that raising taxes is not going to be particularly stimulative for economic growth. Another way is just to print money and we know how that turns out with inflation, which is a tax on everybody, but there’s a third way. The third way is increased economic growth. We’ve been stuck in the US with a two percent growth rate. Europe is one percent. Japan is less than that, effectively zero. But if you have increased growth, then it’s much more likely that you can pay back your debt without raising tax rates. Just the economic growth, the increased revenues are generating more tax inflow for the government to pay down debt. This is really important in that the current economic system is basically locking us in to a low growth environment that the project that the entrepreneur has got that delivers 25 percent. That is the project that we can boost GDP growth to five percent, six percent, seven percent. But those projects just aren’t profitable given the financial system that we’ve got. The basic idea is that there should be equality of opportunity. Right now, we’ve got inequality of opportunity. Certain powerful firms get the best possible deals. That just doesn’t seem right on multiple dimensions, including the economic dimension. That project should be financed based upon the quality of the idea and the soundness of the execution plan. There are many other issues that are under this rubric of inequality of opportunities. Many in the world have no access to the Internet to do commerce, whether it’s the buy or sell. Many of the unbanked. This is also a big loss for economic growth. Where we’re going is to establish a technology that is inclusive, that allows for equality of opportunity.

02_early-cedefi.en

Let me tell you a true story about early centralized decentralized finance. It’s a good story because it’s got some aspects a peer to peer. And it really presages the rise of decentralized finance. So this comes under the category of Fintech and this is a project that I was involved with in 2001. So this is the problem that considered the foreign exchange market. So we’ve got one company or person Alice who needs to buy €100 million euros at the end of September to pay for a machine. So Alice goes to her bank and the bank quotes a rate in terms of the exchange of dollars for euros for the end of September. Now there’s somebody else that’s also a customer with the bank Carol and she needs to actually sell €100 million and translate them into dollars at the end of September. So carol goes to her bank and the bank quotes her rate and it’s a different rate, even though this happens at the same time. The rate this quoted Alice and Carol are different and the difference in the rate is called the spread and this is the bank’s profit and it can be very substantial. So 20 years ago a simple idea was formed. So Carol and Alice use the same back. So why not just put them together? This is very powerful because if you put them together, you eliminate the spread. So Carol is better off and Alice is better off. And indeed, if you think about the network implications, many people have banking relationships with different banks. So it might be that we could actually have this work across many different banks and to make it worthwhile for the bank. They will handle the credit quality evaluation and we’ll give them a small fee, but the spread is gone, and this fee is nowhere near as much as the spread. Okay, so to be clear, this is really good for Carol, it’s really good for Alice, but the bank is going to take a hit as a result. So this is the story of this project. Indeed, on the front cover of Euro money magazine, it was one of the very first decentralized finance applications. And you can see the network diagram and how this actually worked to match customers of a bank or all participating banks. So now, what I’d like you to think about is going to the senior management of the bank or the board of directors and making a pitch for this new technology. So we’re basically asking you to spend money on this new technology to match your customers and it will, when you do that, you’ll get paid a small fee, but your spread is gone, okay? So the pitch is effectively pay us the money to implement this strategy and it will greatly reduce your profit. So you’re spending money to effectively lose money. So you can imagine that is a pretty difficult pitch. But even at this time, 20 years ago, the banks realize that this just is not sustainable. The customers are upset that they have to pay the spread when it’s really clear that there is technology that exists today to match the customers. So we even though a very tough kind of cell or spend some money to reduce your profits. The banks realized that they had to make innovations like this or customers would seek non bank solutions within the context of Fintech. So this is not the only early application of peer to peer sort of transactions. So the previous application was peer to peer within a bank. This idea of dark pool trading actually began in 1979. So it used to be for a particular stock, you had to trade on a particular exchange where it was designated, so effectively imposing monopolistic power by that exchange. But the emergence of dark pools allowed in particular large kind of asset managers to trade amongst peers in an off exchange sort of method. And today, interestingly about half of all stock trading doesn’t occur on the traditional exchanges, like the New York Stock Exchange. There of course are other sort of players that have emerged in the Fintech space. So PayPal was founded in 2000 as a way to speed up payments. A number of banks have have implemented Zell, which is the payment mechanism, but this is really important to understand, I’m going to emphasize this multiple times in the course. These payment initiatives, well, they improve the user experience and are good and that they improve the user experience. They can only go so far, they can only go so far because they are using the legacy banking structure and that banking structure will be disrupted with decentralized our finance.

04_introduction-to-cryptocurrency

01_crypto-origins.en

So now let me talk about the origins of crypto. So the key innovation was this idea of Blockchain technology and that innovation actually happened well before Bitcoin was introduced. So Haber and Star Netta published a paper in the journal Cryptology In 1991 outlining the idea of Blockchain and the application in their paper was the time stamping of documents. So that paper kind of sat around for quite a while, nothing really happened. But there was another idea that arose and Adam back in 2002 essentially invents this idea a proof of work and we’ll go into considerable detail as to what that is. So the idea is that at the time there was a lot of junk email it was a real play and the internet being a free good basically encouraged certain people to do spamming. And the idea was that what about if we have a different system we have to do a little bit of work. So you run a computer program before you send the email. And for most of us this would be just no big deal. It would so instead of the email going in one second, it takes two seconds, take two seconds. So this of course had different implications if you’re sending millions of emails. So instead of just pushing them out, you have to invest in all of this work. And this work basically would make it infeasible to doh the spamming. So a number of people were working on this, Dwork and Naor also in 1992 this was like a big problem. So these two ideas of doing some work before you actually send the email. So effectively the email becomes costly, a very low cost for one but a high cost for millions. And this idea of a Blockchain which will explore in some detail in a few minutes. These ideas were joined and this famous white paper by Satoshi Nakamoto in 2008 and Bitcoin was introduced and it’s introduced as a peer-to-peer electronic cash system. And it’s interesting, we will talk again about those throughout the course that the original vision of Satoshi Nakamoto was that this would be a transaction a mechanism. Indeed, the very first retail transaction with Bitcoin was that somebody spent, it was 10,000 Bitcoin for two Pizzas. Okay, so so that was the original vision that vision has not obtained. Bitcoin has been very successful but it’s been more successful as a store of value or something that’s useful for very large scale transactions. Nevertheless, the idea is a great idea and many people got energized with this idea and decided that this was the foundation that they could actually build upon. So what about the basic attributes here? So there were plenty of digital currency ideas in the 1980s. So it seemed inevitable that we would have a digital currency but there was a big problem and there are maybe 100 of these companies and almost all of them failed. And the reason was really simple that a digital currency is not that much different than let’s say a digital photo. A digital video digital Music, you can make a perfect copy so you can spend more than once. So the idea that Satoshi Nakamoto had eliminated the possibility of spending more than once using Blockchain technology. This is the so called double spend problem with Blockchain technologies will see there’s a record of all transactions, it’s completely open. So if somebody is spending you can check the Blockchain record to see if they had the coin to actually spend. Okay so it’s easily verified it’s completely transparent and very very fast. So this information is kept in this ledger and the ledger or Blockchain is immutable. And that’s really important to because you don’t want a adversary going and changing history. So mutability means that once it goes into this ledger it’s there forever. It’s also distributed amongst many different computers. And I’ll show you in a few minutes what that actually looks like. So it is a redundant technology where the same ledger that shows who’s got what. And all of the transactions that is basically replicated on many different computers or as we call them in a network notes. And the original idea in the Bitcoin paper was algorithmic scarcity. So the total production of Bitcoin was capped at 20 one million. Today we have approximately 18 million. And the last Bitcoins will be produced in the year 2140. So it’s also the case that this technology has got user ssovereignty,which means that you decide you’re the person that decides if you spend nobody else can do it for you. And the last aspect was portability and we talked earlier about how difficult it is to let’s say carry around gold in any size. It’s also difficult to do a wire transfer. It goes from bank the bank, the bank especially international transfer. So this is a completely different idea, there’s no physical transfer in crypto. A transaction basically goes onto this Blockchain record and it is propagated throughout the entire network. Everybody’s got the same ledger and that’s just how it works. There’s no physical transfer of anything. The record, this immutable record says that you own the coin and it doesn’t matter where you are and it’s very fast and secure. So this is a great idea, so let’s think about this versus fiat currency. So and I kind of mentioned this already that the US currency has got a number of attributes like the government’s ability to tax you and you have to pay in US dollars. The legal tender as well as as I mentioned incarceration if you don’t pay your taxes and US dollars. Okay, so it’s also the case that economic conditions impact the value of the dollar. And of course it’s also possible that the Federal reserve could choose to inflate by printing excessive amount of currency. Okay, so this is a completely fiat and crypto very very different. So you’ve got scarcity that is hard coded into the algorithm. So it’s unthinkable to even speculate about some agreement to raise the cap on the number of Bitcoin. So why would people vote for that that own Bitcoin? Because as soon as that happens, the value of what they’re holding would go down. So there is no link with economic activity but let’s be careful about that. So it’s really clear that the main fiat currencies are linked to the state of the economy. And if you’ve got an algorithm like Bitcoin or ethereum, it’s just not clear that there’s theoretically any link. But nevertheless, given that Bitcoin is now a risky a store of value, it is sensitive, too risky events. So for example, in March 2020 when the stock market plunged because of the covid 19 scare Bitcoin dropped by 55%. When people became a little more comfortable that we’d emerge from the crisis, the stock market went up, and so did Bitcoin and other cryptocurrencies. So Bitcoin is important, it is the flagship. We will talk about Bitcoin in this course via something that’s known as wrapped Bitcoin. That is something that is traded in the decentralized finance space in the ethereum Blockchain. So ethereum is founded by Metallic in 2015, it is a different technology than Bitcoin. So Bitcoin essentially allows you to transfer from one account to another account. The ethereum can do something else. It can run a small computer program and this is known as a smart contract. So you can think of ethereum has a distributed computational platform. Remember, I said that in Bitcoin, all of the transactions are preserved in every single copy of the Bitcoin Blockchain on every single note. This is also true for the smart contracts. When that program runs on one node it will run on all of the notes. So again this is redundant but this is a very important feature of this network. Okay, so essentially with Bitcoin you can interact with other, let’s say, accounts other people or institutions with transfers. But in ethereum you can actually interact with a smart contract, so that’s really special. And ethereum is the backbone of decentralized finance because most of decentralized finance uses the smart contract method. So we’ll talk about decentralized applications which short form are adapts. So what is the adapt so you’re probably most familiar with just a regular app on your smartphone. And those apps are basically you interacting with a centralized party, and that centralized party has got an incentive for to provide the service to you. And it might be they push advertising to learn about you, and other things. So a decentralized app is an app that puts people together as peers. So you interact through a smart contract. But there is no centralized institutions, it’s just an algorithm. Okay, so think of the smart contract as the algorithm, there’s no board of directors, there’s no headquarters necessarily. So it’s a very powerful idea that allows for peer to peer. So, as I mentioned at the beginning, this is a technology that creates a competitive marketplace for financial depths. And we will talk about the primitives in the second course that includes exchange lending, tokenization as well as other things. The other thing that’s interesting with these depths is the network effect. Okay, so there is a way that is very natural and decentralized finance of combining and recombining different DeFi products. And there’s also in a way to offer incentives to get people to actually use a particular protocol that’s much different than what we’re used to in traditional finance. Okay, so this is the end of the first module. And the next thing that I want to do is to talk about the foundations of DeFi. I’ve talked briefly about Blockchain go into much more detail, cryptocurrency smart contracts, oracle stable coins and decentralized applications

02_defi-foundations

01_blockchain-and-hashing

01_intro-blockchain.en

The second module in DeFi Infrastructure takes a much more detailed look at the foundations of decentralized of finance. We’ll talk about blockchain, which I’ve just introduced. Cryptographic hashing, cryptocurrency in a little more detail. Smart contracts, oracles, stable coins, and little more on decentralized applications. That’s where we’re heading. Let’s start with blockchain, and let me give a basic introduction. Blockchain, again invented by Haber and Stornetta in1991, is basically a software protocol. That’s like one way to think about it. There’s no one blockchain. This an idea that is a very general idea. Bitcoin’s blockchain is different than the Ethereum blockchain. Potentially there’s thousands of different blockchains, but they do have commonalities in terms of basic items, like allowing multiple parties operate under shared assumptions and data. This is key without trusting each other. That’s much different than centralized finance. There needs to be some level of trust. The trust here is within the technology, not the different parties. The data that we’re talking about for blockchain could be anything. It could be a transaction where I transfer some in Ethereum to somebody else, but it could be location, destination, and information. Could be supply chain details. This is a very general technology. The idea is you’ve got this record, it’s tamper-proof, and it’s open and people can see it. I give an example in my course. You go into the grocery store, you see some lettuce that supposedly organic, has got a QR on it, you scan it, check a blockchain construct that tells you when it was packed, where it was packed, were the farm is organic, every single hop on the supply chain, and how long has been on the shelf at the grocery store. Again, this is a very general idea. Part of the basic structure is the blocks and the chain that links the blocks. I’ll have to go through in some detail as to what that means. But in the bottom line, it’s just really easy to do an audit. That means you can trace all of the transactions. You can figure out the balance of any address. It’s very, very straightforward technology. Here is the article that I mentioned, Haber and Stornetta in 1991. There is a lot of misunderstandings that people think that blockchain was invented by Satoshi Nakamoto. It’s just not the case. The idea was invented by Haber and Stornetta. Let me try to describe what’s going on with a blockchain. It’s a ledger. Think of it as a spreadsheet. Indeed, sometimes I pitched the idea in the following way. Excel is a spreadsheet, unless you get 200 rows in the spreadsheet. Well, anybody could go edit, let’s say, row 100 and change the spreadsheet. In a blockchain technology, you can add but you can’t edit. You can add row 201, but you can’t go and change row 100. But it’s different. It’s not just a single spreadsheet that I’ve got on my desktop. This is a distributed ledger. This is what a distributed network looks like. Notice that there’s no single point of failure, that if some of the nodes in the network go offline or are corrupted, it doesn’t really impact the network because there’s so many copies of this ledger. There is extreme redundancy. The other attributes are transparency which we’ve talked about and immutability. Again, you can add that. Think of the row 201 in to the ledger but you can’t go and edit the history. Now I say you can’t do it, but I need to prove to you that you actually can’t do it. This is what it looks like. These are some blocks and the cryptographic security is quite elegant. We’ve got transactions in these blocks. Basically, look at the arrows connecting the last line of one block to the next line of the next block. Last line of the block to the far left is connected to the first line of the block in the middle. That is going to be important for us. Basically, that last line of the block, think of it as a fingerprint that’s unique to all of the content of the block. The block has got many transactions in it. Then there’s a fingerprint that we call a cryptographic hash that’s unique to all of that data. What I mean to be clear, if I alter even in the most subtle way, the data, the fingerprint changes. The key thing here is the fingerprint for that first block on the far left is repeated as the first line of the next block. The record, the fingerprint, or cryptographic hash of the block on the far left is repeated in the first line of the middle block. Then when the middle block is filled up with transactions, similar thing happens. We get a new fingerprint that takes all of the data, all of their transactions, including that fingerprint at the very top. Again, that’s unique to the second block and it is repeated at the very top of the block on the right. This is why it’s called a blockchain. There are blocks and the chain is the link between the last line and the first line. There’s commonality that puts them all together. Hopefully, you can see already the beauty of this idea. For example, if it was the case that the block on the left somehow got corrupted, well, if it’s corrupted, then the fingerprint at the bottom is going to change. Then it won’t match the first line of the next block. The network seizes as about the chain is broken, let’s replace that block on the left with a copy that actually does work. This is really important property that gives this technology its immutability. If we need to add to the blockchain, we add a new block, we don’t go and edit the past. You can see all of these blocks for Bitcoin going back to the very first block which is called the Genesis Block, same thing for Ethereum. Everything is wide open on the Internet. Anybody can download a complete copy of the blockchains. What about security? The key idea here is the cryptographic hash or the fingerprint as I’ve called it. If there is any alterations, so I say that you can’t edit a blockchain, but let’s suppose that I actually do. Remember I said that anybody can download, let’s say the Bitcoin blockchain. Let’s say I do that. Let’s say that I change a block. I can do that, just edit it. But again, the same problem will occur. That when I edit the block, the cryptographic hash at the bottom will change. When that changes, the network sees that the block has been corrupted and there will be a search to find the block that actually fits. It’s futile. It’s futile to actually try to change because if there’s any corruption, it’s immediately seen. Because the chain is broken and the block will be replaced and there’s plenty of copies of the uncorrupted blockchain across all of the nodes in the network.

02_hashing.en

So I’ve talked about hashing and this is really important for both Bitcoin and ethereum and decentralized finance in general. So I think it’s important for you to have a deeper understanding about what is actually going on with hashing. So let me give you an example. Really simple example. It’s a simple hashing algorithm. So I want to send an email to Daniel but a little worried because there could be a problem with the transmission and somebody potentially corrupting are the email so there needs to be some mechanism to verify that what I sent her is exactly it’s not been corrupted so this is the way that we’re going to do it. So I sent an email to Daniel but then and the email is really simple, it’s a single word Hello? And then I’ve got a coding scheme where each word is going to be encoded as a number so as one B is two dot dot dot Z is 26. So hello would be 85 12 12 15. And then I’m going to multiply those numbers together And I get 86,400. So I post that number on my website and people looking at that number have no idea what it is. So Danielle gets my email and she uses the same coding system And she comes up with 8000 Our 86,400 she checks my website it matches. Therefore the message is secure. So if there was some corruption like instead of hello H A L L O was sent then when Danielle does the hashing, Should we get 17,280. She looks on my website And she’s 86,400 and she knows that there’s been corruption and we need to try again. But this simple hashing algorithm is unsatisfactory. It’s way too simple and it is subject to what’s known in the hashing literature as a collision and that is the two different inputs. Two different words give the same hash and I’ll give you an example here that suppose an adversary intercepted the message and changed it from Hello. There’s something that’s got a very different meaning. Hell well when Daniel gets that message and does the cryptographic hash that we’ve got, It’s 86,400 and she has no idea that message has been corrupted. So we need to do better than this but it’s the basic idea of hashing. So what is used in Bitcoin is a hash called secure hashing algorithm to 56 or SHA 2 56 and I’ve got a link here. If you’re interested, I’ll show you some output in a few minutes. This is a one way function importantly this is not encryption. So when you encrypt something, there’s a key to decrypt to get back the original message. This is not how it works. Okay. And I’ll give you some intuition the hash, the 256 hash the 256 is the number of bits 256 bets. And often we represent this in hexi decimal form. So hexi decimal is based 16 which is the Numbers 0-9 plus the first six letters Of the Alphabet. So total is 16 characters. And when you do that you can represent instead of the hash is 256 zeros and ones. It’s much more compact. So it’s 64 hexi decimal characters. Okay, so again this is not encryption. So it doesn’t matter the size of the input, whether it’s the word hello or whether it is a book or anything digital, it could be a picture, it could be a movie. The output Is 64 hex to decimal characters. So let me just push this a little harder because I know some people are confused by this. So again, the cryptographic hash is not encryption because there’s no way to reverse. And intuitively think about you’ve got a movie, it’s eight gigabytes. You feed it into A shot to 56 program and it Delivers 64 characters. Doesn’t make any sense to you That you could take those 64 characters and somehow unraveled them into an eight gigabyte movie. I don’t think so. So this is a one way function. And let me show you how it works with this website. I’ve got some screenshots. I’m going to do something really simple. Hello world exclamation mark. Then I’ll put a number after the actual word. So that’s what it looks like. Hello world. And notice at the very bottom Is the 64 characters in terms of hexi decimal and when I make a change, So instead of Hello World Zero, Hello World one notice the hash is completely different. So it’s not like you use the old hash and then just change one character at the end. It is completely different. Hello World 2, completely different. If I went back and did the one I would get back what I just showed you for one. So it is unique. So when you’ve got an input it’s got a unique output in terms of this hash and then the last one I’ll show you is kind of interesting. Hello world exclamation Mark, 40 to 50 notice The hash that’s returned has got four leading Zeros. So that’s a little bit rare To have four leading Zeros. So think about the probability I’ve actually getting four zeros in a row. So we had 16 characters. So it’s one of the 16 to the power of four. Indeed that’s the reason that the number is 4250 that I had to try lot of numbers to get those four leading zero. So think of me have my computer doing hello world zero. Hello 01 234 dot dot dot dot. And finally when I get 4250, it’s a lot of hashes, But I get the four leading Zeros. So This is the shot to 256, ethereum Uses the K cock to 56 which is a different algorithm And I will show you what the hello world 450 looks like. And it is a completely different hash. So it’s a different algorithm. So that means when you put the same input into a shot to 56 as a cake octu 56, you’re going to get different hashes. So again, the Peacock to 56 is used in Ethereum. The Shaw to 56 is used in Bitcoin. So that’s essentially how it works. So the modern kind of example of my email Is that I send the email to Danielle but then post their shot to 56 hash of the email on my website. And when she gets the email she does the shot 56 sees that it matches the hash on our website and we know we’re secure. So this sort of hash does not suffer from the problem of a collision at least with the current computing and it is widely used. So this is used outside of decentralized finance. What I’ve described in an email is how emails actually work. This happens all the time to make sure there was no corruption of the email in the different hops it takes over the internet. Okay, so there’s a little bit more here and it is what the miners do and I need to explain mining to you, mining is very important for this proof of work which we introduced as Adam backs idea to do a little work before you send that email. Well we’re going to have to do some work here also. And the basic intuition is the following. Well we don’t want to happen is for an adversary to go and corrupt block and then we know when that happens that the last line will not match the first line unless the adversary actually goes and changes all of the future blocks so that the hashes actually do match after the block is corrupted. And when I say corrupted it could be that the adversary takes a pile of Cryptocurrency and sends it to themselves even though they don’t own it. They will own it if the corrupted block propagates. So we need to make it very difficult to do that. And this is where the mining actually comes in. So what the minor is doing here is the following. The minor gathers the candidate transactions that are sitting in something called the memory pool. So these are transactions that are not confirmed yet. They’re not yet on a Blockchain. And the first thing the minor does is to verify the transactions and verification is very easy. They just basically check to see if the person spending actually has the token dispense. So once they verified they put a group of transactions together. And the way I initially described as you just run a hash and and then basically post that to a Blockchain, it’s not exactly how it happens. So what the miners are actually doing is looking for a special hash, that’s got a lot of leading zeros. There’s a reason I showed you for leading zeros and now I’m going to explain why. So the miners are cycling through numbers just like I was cycling through 123 Up to 4250, but they go well beyond so they’ve got their transactions and that they’re just adding a little bit of data with this number, just like I added to Hello World 4 250. And the number that they’re adding is called the nuts And that short farm for number only once. And the miners are actually going through cycling through trillions of different non cysts to try to find a hash that’s got lot of leading zeros. Okay, so a lot of computing power is actually used for this and is so much computing power that it makes it infeasible for an adversary to go change a block and then change the future blocks to make sure that everything works. So it makes it computationally infeasible and that’s what the miners are doing, their verifying, they’re doing this work so that it gives the ethereum Blockchain or the Bitcoin Blockchain, unprecedented security, It makes the block chains immutable. And it the cost is so enormous to take over the mining power of the network. It can’t be done by any one person and it’s really infeasible to even think about doing it by let’s say a nation state. So it’s unprecedented computational power that’s used for these block chains and it makes them very secure. So it is not just the money that you would have to spend on computing power. The computing power itself is specialist. This is not like buying a desktop computer. The mining rigs as they’re called Are highly specialized. They do one thing in the Bitcoin world. A shot of the sex in the theory of world. Kay Kok 2 56. Okay so these just to think about ordering the equipment To basically take over 51% of the network is really really infeasible. So this is how proof of work block chains operate. We’ll talk later in the learning experience about different alternatives to proof of work. Including proof of stake. And at the very end we talk about some of the risks including environmental risk and have some comments on the extreme amount of energy and most of it fossil fuel based that’s used in mining and what that means for the future of Cryptocurrency

03_technology-advantages-and-disadvantages.en

Let me talk about some of the advantages and disadvantages of this technology. Blockchain actually adds a lot. It provides something that we didn’t have before. It allows us to verify ownership. You can quickly check this immutable ledger to see if somebody actually owns what they claim to own. Again, this ledger is immutable. It gives this verification of ownership. It also allows for the efficient exchange of ownership. This is an exchange without a middle person, or perhaps you could think of the algorithm as the middle person, but it’s just allowing for a peer to peer transfer. It’s also interesting that this technology doesn’t differentiate, doesn’t put labels on people. In traditional finance, or a customer, or a retailer, a banker, there’s nothing like this in this technology. This is a much different situation than we’ve had in the past where you’re a peer and there’s no other label. That’s irrelevant. These blockchains are special. Again, blockchain is a general technology. There’s many different implementations of it. When I talk about a consensus protocol, what I mean by that is essentially a set of rules that determine what kind of blocks can become part of the chain and are eligible to be the truth. There’s different consensus mechanism that we’ll talk about in the course. Importantly, once the block is in the chain, it’s there forever. If you make a mistake and send some token to the wrong person, it’s too bad. It’s there. Maybe that person might decide to return it, but it’s completely up to them. These protocols are all designed to be resistant to tampering with up to a certain bound. Different protocols for consensus, and we’ve really only focused on proof of work at the stage. They all have their limitations including a proof of work. Bitcoin and Ethereum use proof of work as their consensus protocol. What’s happening is, as I said, the miners are going through these numbers trying to find a very special hash that it’s got this property with a lot of leading zeros. It is possible, however, in proof of work that an attacker could theoretically come up with 51% of the network power and cause some damage presents a limitation of proof of work even though I’ve already argued that it’s just really unlikely that an attacker could afford to do that. Indeed, it’s not clear what the motive would be because if you do that attack and, let’s say steal some token, given that people know that there’s an attack the confidence and the network basically plummets as with the value of the crypto. The power of the network is a big benefit because it makes it just extremely unlikely that a successful attack could be carried out. Now, as I said, there’s many cryptocurrencies out there, and many of them are nowhere near as strong in terms of proof of work as Bitcoin or Ethereum, and that is a risk for these smaller cryptocurrencies because somebody could actually go, perhaps even rent computing power to attack that network. But for the main cryptos, they are very strong in terms of the computing power. Again, I introduced this idea of mining. The miners are cycling through the nonces, try to find that special hash. This is very intensive in terms of computation. Basically, it’s a lottery. What I mean by that is that there are many different miners that are cycling through the hashes trying to find that special hash. The first one that discovers the correct number of leading zeros wins. What do they win? Well, they get some newly minted cryptocurrency. They also get the transaction fees that might be associated with the individual transaction, the big incentive to actually do this. But it is computationally very burdensome to actually do this. Remember, they are verifying transactions, then they basically do this work by putting a nonce attached to the transactions, and then the one that wins a lottery gets paid and it’s a very generous reward. That reward, interesting, but every three years is halved in Bitcoin and that’s why in 2140, the supply of new Bitcoin goes to zero. How difficult is it to find that winning hash? This is an example I use in my class, thought experiment. Suppose you’ve got 13 decks of cards and you’ve got a shuffling machine, and basically, what you’re going to do is to look for something really special. You turn over the first 13 cards, the shuffling of 13 decks and you are looking for the following, the two of clubs, the first 13 cards. It’s just incredibly right. Just imagine how many times you have to shuffle those 13 decks to be lucky enough to come up with 13 two of clubs in the first 13 cards. This is the sword of computing power that’s necessary. It’s a huge amount of hashing or shuffling that’s going on amongst the miners. We have, at Duke University, a Blockchain Lab for students that has some demonstration machines that the miners actually would use. We actually have a mining operation with an Antminer S17, and that’s what it looks like on the right. It does 53 trillion hashes per second. It’s a very powerful machine. Again, the winner gets a reward of a new Bitcoin. If you are just mining on your own, it would be just infeasible. You have to wait centuries before winning even one. Our machine, even though it seems very powerful at 53 trillion hashes per second, it’s actually only 0.002 percent of the networks power. We also have an Ethereum mining machine. Again, it’s a different algorithm. Again, this machine, the S17 does one thing, the SHA-256. The Ethereum machine does one thing, the Keccak-256. This is what our dashboard looks like in terms of the number of hashes we’re doing per second. Then you can see the vertical lines are when the pool that we’re in actually wins the lottery. What do I mean by pool? Remember, I said that if we’re operating alone, it would take centuries to win. What people do is they pool, so you become part of a mining pool. Let’s say you’ve got 10 percent of the hashing power of the pool, when the pool wins, then you would get 10 percent of the winnings. Doing it this way, it means if you’re in a larger pool, you’re getting some payout perhaps multiple times during the day. For Bitcoin, the blocks are every 10 minutes. This is an actual picture that I took the other day of our mining Briggs. The one on the left is the S17 that does the SHA-256, and the E3 on the right does the Keccak-256. In proof of work, you need to do mining. It is both a strength and a weakness of the technology. The strength is because of the unprecedented security. It really seems infeasible for any one or a group to attack the Ethereum or Bitcoin network. But it’s also, as I mentioned earlier, a weakness because of the electricity cost of the mining is enormous. Ethereum will migrate to a different less energy, inefficient technology for their consensus. Ethereum will move from proof of work to a proof of stick mechanism. That will likely happen in 2022. That will solve the environmental problem for Ethereum, but Bitcoin is a different story. It’s likely stuck in the proof of work mode and I have more to talk about in terms of this risk to Bitcoin in future modules.

02_cryptocurrency-smart-contracts-stablecoins-dapps

01_cryptocurrency.en

Let me talk now about crypto currency. I’ve mentioned it a number of times, but I want to go into a little more detail. So Cryptocurrency is a digital token. That’s not a physical token, It’s digital. And it’s cryptographically secured, and you’re able to transfer it. So one important aspect of the Cryptocurrency is something known as asymmetric key cryptography. So the owner of Cryptocurrency actually starts out with a private key. Which is just a long random number. That’s one part of the key, and that’s secret. There’s also a public part of the key. So what happens is, that long random number is passed through a mathematical algorithm. And what comes out is a public key. So the private key is not for sharing. But the public key is basically used to determine an address. So this is important, it’s easy to go from the private key to the public key. But with current technology, it’s not feasible to go from the public key to the private key. So you can’t derive somebody’s private key today from the public information. So it’s asymmetric key cryptography, means that there are two different keys that are really important for what you do. So, again the public key is used to derive an address. And I’ll show you how that’s actually done. And then when we actually transact in Cryptocurrency? If I want to receive, then I will basically set up an address. How do I do that. Well I generate a random number, that’s my private key. Then I pass that through an algorithm. It gives me a public key, then I derive an address. And then somebody basically signs over their crypto to me. So how does that happen? Well in signing over the crypto, you basically use the digital signature algorithm. And that algorithm once signed proves that you’re the owner of the actual currency. And when that happens it’s transferred to me. Now that currency is associated with my private key. And of course I can do the same thing. I want to send you the Cryptocurrency. You generate a random number. You pass that through an algorithm, and you get a public key. You turn that into an address, I see your address. And then I sign over my crypto to you. And when I sign it, I sign it in a way with this Digitorial signature. That anybody in the network that sees my signature, and knows my public address. Can verify for sure that I must be the one that has the private key. As soon as that’s done, then it is effectively transferred to you. And transfer, notice we’re not transferring the private keys. We’re actually creating a new private key every time this is done. So this is the way that transactions actually occur. Private keys, remember I said are secret. Well this is something we will deal with in the fourth course. When we talk about risks, but let me just give you a little preview. If you lose your private key, then somebody’s got the right to spend what was your coin. Indeed there was a good example early in the space on some TV talk show. Somebody was brought on to kind of explain what was going on in the crypto space. And the interviewer said, well what does the private key actually look like? And the person pulled their wallet out, and showed, well it’s just like a QR, like this. But everybody on TV saw the QR. So somebody actually took the QR, and spent the crypto this person had. So in showing your private key, it was foolish, because you lose your crypto. It turns out that this was a good lesson. Because the person that grabbed the crypto sent it back, saying don’t show your private key again. So it’s important to keep your private key secret. And there are many different ways to do that. One way that is highly recommended is to keep it unconnected to the internet. So in a USB key, or even a hard copy. You should not have it linked to the internet. There was an interesting story in the New York times this year. About somebody that basically decided to store their private keys in a special hardware wallet, that was password protected. But then the person forgot the password. And it turns out that the crypto in the wallet are worth about $120 million. And this device, you can try the password up to 10 times. And on the 10th if you get it incorrect, then the hardware physically destroys itself. This person has tried eight times, got two more to go. And if they fail 120 million gone. So again this is an issue, right? It’s kind of analogous, you’re walking down the street in New York, and some cash falls out of your pocket. And somebody picks it up is gone. It’s the same thing, you lose your private key it’s gone. Okay, so what do these cryptos actually look like? And this is from coin market cap, which is a website that attracts thousands of cryptos. And you can kind of see here the top cryptos. Bitcoin at the top, Ethereum, there’s different types of cryptos here. So there’s some stable coins that are in this list. So we’ll talk about the stable coins later, and these are tied to the dollar. So tether, and US dollar coin are on this list. And the list goes on, and many of these have different Blockchain technologies, that we will talk about later in the learning experience. So I’ll show you only the top 20 here. But again there’s many, many cryptos. And even these top 20, even like number 19, it’s got substantial value. And this is all value that’s recently been created. So within the space of crypto, we’re talking about Approximately $1.5 trillion of value that’s been created. All right, over a very short period of time. So this is small compared to, for example, Apple, it’s got two trillion of market cap. But nevertheless, Apple is an important company, and people notice it. And people are noticing what’s happening in the Crypto space, and in particular, the device base.

02_smart-contracts-gas-oracles.en

So there’s a lot of differences between ethereum and Bitcoin. And as I’ve already mentioned, one of the key innovations in ethereum is the possibility of having a smart contract. So a small computer program that actually runs within the blockchain. Indeed, ethereum is sometimes called the virtual ethereum machine. So think of Bitcoin as a payment technology and think of Ethereum as a smart contracting platform. You can do payments in Ethereum just like you can do in Bitcoin but there’s enhanced capability. So a smart contract is code that can create and transform arbitrary data or tokens on top of the blockchain that it’s actually part of, okay? This allows us to trustlesly encode rules for any type of transaction and even create assets from this smart contract. So this is very interesting in terms of what Ethereum has actually done. So there are many tokens that are associated with Ethereum. So it’s not just the value of a theory when you look at the number of tokens times whatever its trading for. You need to look at all of the associated tokens with Ethereum. Okay, so this is very very deep. So you might see that, well, Bitcoin is worth more than Ethereum. Well that that’s not the whole story here because it doesn’t count all of the tokens that are associated with Ethereum. Okay, so I mentioned that these are trustless. So many of the standard contracts that we deal with in business for example an option contract or call options and put options. Those are really easy to algorithm and code and a smart contract can do that. So for simple contracts, these smart contracts are just ideal. And again, when you run the smart contract, it runs on every node in the ethereum network. So it is redundant, just like every transaction is recorded in the Ethereum network on every single copy of the Ethereum blockchain. And the same thing for Bitcoin in terms of transactions, okay? So I’ve already mentioned that this idea is a very general idea. So this is a course that’s focused on decentralized finance, but there could be another course that uses much of the same material, but talks about supply chain mechanics, okay? So this is a very general idea. The low hanging fruit in my opinion, is finance, and that’s where we’re seeing most of the innovation today, but this is much more general and there are many other applications. So an important concept on Ethereum is the idea of gas. So you actually pay a gas fee for a transaction and this is analogous to, let’s say you’re running a computer program on a cloud platform, then you need to actually pay for it, okay? So gas is a very important part of this, but there’s like another reason to have the gas and this is the problem of the infinite loop of code and sometimes known as the halting problem. So think of a car and let’s say we’ve got a car that’s a self driving car and it’s stuck on autopilot, nobody is in the car and it just goes, so what is the limiting factor? Gas, so when it runs out of gas, the car stops, okay? It’s the same thing in a smart contract that once you run out of gas than the contract stops, okay? So if there was some flaw in the code that caused it, the loop and loop and loop, it would only go for so long. An infinite loop would be a disaster for the network because every single computer is doing the same thing and it would take the computing power of the network. So this is something that’s special to Ethereum. It is a turing complete protocol and Bitcoin is not, of course Bitcoin doesn’t run a smart contracts. So gas is important, it’s also for an attacker, somebody wanted to attack the network, it would be very expensive because it to run up a lot of computations, then they have to pay for it in terms of the gas. So let me give you a little more detail in terms of how gas works because it is important for decentralized finance. So there are two things that are important, first, the amount of gas and second, the price of gas, okay? So if you’re trying to think about driving a car from point A to B. Well, you need to figure out how much gas you actually need to do that, but the actual cost will be the amount of gas times the gas price. So very simple transactions on the Ethereum network, they are done with a relatively low gas B. But as the transactions become more complicated, so perhaps the there’s multiple steps in the actual transaction. When that happens, the price becomes higher because the amount of gas that you need is much more, okay? So the gas is usually measured in terms of the unit called a gwei. So wei is the smallest unit in Ethereum and a gwei is a billion thing of one ETH, okay? So the prices are quoted and the prices are actually determined by effectively in auction. So again, there are two things here, how much gas do I need? That’s fairly straightforward because we can figure out the computing steps that are necessary for the candidate transaction. So you can figure out how much gas is needed, but then you actually need to go purchase that gas and the price of gas can vary depending upon the particular network congestion. So if a lot of people are using the network, the price of gas actually goes up and it could become very expensive, okay? So I’ve actually got some calculations here as to how this could work in terms of the number of cost and the way that it works is the following. That you’ve got an estimation of how much gas is actually needed to do the transaction and this is all kind of automatic and suppose that you actually send more gas than is needed. So when you do that, whatever residual is left over is refunded to you, okay? And who gets the gas fee, the miners, It’s another incentive for them to do the work. And if you send not enough gas and the transaction gets let’s say halfway through and then runs out of gas, then you lose that gas and the associated value that it cost you. So to run half a computer program too bad, you’re not getting any refund because it’s already been run but if their surplus, it actually goes back to you. So this has been a significant issue in terms of the price of gas. The price has been, the gas prices have varied this year between 50 and 700 gwei. So simple transactions were becoming really very expensive and when these transactions become expensive. Then you kind of decrease the efficiency of these markets and the problems that they’re supposedly solving they’re not really solving because the cost of transaction is so large. So this is an ongoing problem but there are solutions in the future to basically make sure that these gas fees are lower. So one thing is the Ethereum Improvement Protocol 1599, which will change the Ethereum blockchain and in a way that has got a number of advantages. It will allow more transactions and importantly the base fee for the gas is going to be burned. So burning, we haven’t talked about yet but we will. And basically what that does is it takes the Ethereum out of circulation so it destroys it. So currently it just goes to the miners. So in taking this out of the circulation and it actually works for the miners but it actually serves to decrease the rate of increase in Ethereum, potentially making Ethereum more valuable. The miners still get some money for doing this because users can send them a tip to actually do their transactions so the idea is pretty straightforward. If you want your transaction dealt with quickly then you need to pay a premium, you do that in Bitcoin, you do that in a theory. So again this will make we believe the cost of gas go down and also make Ethereum more valuable. So I talked about the Ethereum Improvement Protocol. There’s also ERC, so ERC is the theory request for comment and this is very important because it essentially allows new things to be created within the Ethereum architecture. So the most popular is the ERC 20 which delivers a token interface. It allows you to create a token that resides in the Ethereum blockchain, okay? So this is a great innovation, the ERC 20. In my teaching, we create our own tokens and the the uses are very, very interesting. So ERC 20 which will go into more detail later in the course is a fungible token. So that means that every ERC token is identical in value. So think of a like a $1 bill and a fiat currency, every $1 dollar bill has the same value and indeed 10 $1 bills equals a $10 bill, this is what fungability actually means. There’s another ERC Called ERC 721 and this is a non fungible token and sometimes known as an NFT. So with this token the value he is unique to that token so the token is representing something. Sometimes we call them deeds and recently they’ve become quite popular in terms of representing pieces of art or videos even tweets. So the benefit of these ERCs is that the developers can create code for one interface that they’re working on but given that you’re compliant with the ERC 20, the token can be used in many different applications. So this is the idea of interoperability which will spend a fair bit of time talking. So oracles are something that is also really important to understand. So we know what the word oracle means but within a defy space it’s got a special meaning. So a blockchain is self contained, so a blockchain doesn’t use information from outside the blockchain unless there’s an agreement upon an oracle. And an oracle is the way to bring information from outside a blockchain construct to the blockchain, okay? So this could be a data source, it could be the price of gold, it might be the price of Apple stock, that that information doesn’t reside on the Ethereum blockchain. So how can we get that information in? And we actually have to build it into our smart contract and it goes outside of the blockchain to collect that information. And it’s important that that information is reliable because if it’s unreliable, that will create a problem for the smart contract, okay? So essentially this is a big problem and decentralized finance is a challenge to get a credible oracle. And there’s many different companies that are working on this. And Chainlink is one company that is basically got a decentralized solution to the oracle problem. But again, this is a challenge to get data from outside of blockchain into a blockchain

03_stablecoins-dapps.en

Let me now talk about two important parts of the foundations of DeFi, stablecoins and decentralized applications. Bitcoin and Ethereum are incredibly volatile, the price of bitcoin is approximately five times the volatility of the stock market, or five times the volatility of gold. Gold and the stock market, about the same volatility. It is subject to large swings, Ethereum, about the same. The idea of a stablecoin is that it’s intended to maintain a price parody with some target asset, the most popular stablecoins are linked to the US dollar. But it doesn’t have to be the dollar, could be something else, it could be gold, for example. When we say stablecoin, the coin is only as stable as the underlying asset. Even the US dollar can fluctuate in value, it’s volatility is not that high versus other currencies, but nevertheless it is not completely stable. Basically, this is a great idea that allows people to get into the crypto space with a coin that is actually not as volatile as something like Bitcoin. If you’re looking as a speculator for appreciation, there’s no real upside here in terms of a stablecoin because let’s say it’s linked to the dollar, but it does provide an important aspect of stability which is used in many different applications. The basic idea of stablecoin is not a new idea, it turns out before the Federal Reserve, it was common for banks to issue their own currency. This is a photo of a 20 dollar bill from Merchants Bank of Augusta, Georgia from 1856. This is one from Boone County bank, again, $20. If you look at the fine print at the bottom, you’ll see that this is actually backed by something. There’s collateral and the collateral is a portfolio of public stocks. These banks would issue their own currency and they would have to have some collateral. The collateral could be gold, it could be silver, could be public stocks, or it might even be government bonds that were issued. Essentially this is just a way with some collateral to have something that is linked to a dollar. More modern example of course is Eurodollars. It’s a massive market and your donors, and effectively a Eurodollar is a US dollar account that’s offshore from the US. It began in Europe, that’s why they call it Eurodollar. But as soon as that dollar account is offshore, then it’s no longer subject to Federal Reserve regulations. Effectively, these tokens that are linked to the dollar have created the equivalent of a euro token. Let’s talk about the different types of stablecoins. The most popular or the fiat collateralized stablecoins. This is a centralized mechanism, and let me explain why. The idea is that you present a company with $100, they put it in a vault and mint 100 of their stablecoin. That stablecoin is as good as the collateral in the vault and the ult needs to have the $100. They’ve it doesn’t have the $100 than the value of the stablecoin is questionable. Now, it’s interesting that the most popular stablecoin is tether high and that is a stablecoin with a very complicated history, has got a very large market capitalization and daily trading volume that exceeds things like Bitcoin, it’s often the case that if you’re training bitcoin is quoted in terms of tether rather than US dollar. It’s got a complicated history because there’s no regular audit of the reserves. In contrast, USDC, US dollar coin, that is backed by Coinbase and Circle, it’s smaller but a very important player in the DeFi space. It resides on the Ethereum blockchain, there’s version of Tether that also resides on Ethereum blockchain. Again, both of these coins are centralized. Again, the intuition is really clear. You need to trust somebody that the collateral is actually there. Again, Tether has got a complicated history. They were forced to provide some accounting of what actually is backed, has collateral. It’s not all a short-term deposits that revealed that they even hold a highly volatile cryptos has collateral. Again, this is a technology that’s got, in my opinion, much more risk than let’s say, US dollar coin, but people use it, and many people believed that the risk is small because they’re using it very quickly. You don’t need to hold it for a long period of time. There are also crypto, collateralized stable coins. We’re going to considerable detail in the third course, which is called defy deep dive. On the first collateralized crypto, stable coin, where you’ve got a crypto as collateral and that’s MakerDAO’s Dai. Dai is the stable coin and it is very closely linked to the US dollar. The collateral being crypto is quite volatile. As a result, you need to over collateralize. You can’t have just 100 percent. You need to have much more like 150 percent of collateral when you issue these Dai. In the third course, we’ll also talk about synthetic tokens from synthetics and talk about how they deal with stable coins also. There are also non-collateralized stable coins and these are not backed by an underlying asset, but they use an algorithmic expansion and contraction of the money supply or the token supply to try to maintain a peg. These are complicated and there’s not a great track record when there’s no collateral whatsoever. To be clear, just to look at this, US DC is a centralized collateralized stable coin with safe assets like US dollars. Dai is a stable coin that is also collateralized, but is collateralized with crypto and therefore, it is truly decentralized, so anybody can see what’s going on. Then the third class are these non-collateralized stable coins. Again, it is complicated to make it work with a money supply policy of expansion and contraction. It is still frankly a open problem here on many aspects of stable coins, including the scalability of these stable coins. To basically become a viable mechanism for transfers, it might be that the space needs to become much larger than it is today. Let me talk briefly about a decentralized applications. I’ve introduced them already. But again, these they look and feel like the regular apps that we use on our mobile phones or our desktops or laptops, but they live on a decentralized smart contract platform. The key thing here is that there isn’t some central server that is collecting your information and trying to sell you stuff. These are being operated out of a spark contract platform where you’re actually putting peers together directly. There’s no middle layer, I hear. These applications are permissionless, anybody can use them, and because of the nature of the Ethereum blockchain, nobody can censor you. It’s not like you can be banned. That just doesn’t exist in this space. Of course, there’s positives and negatives to that, but it’s just a fact that this is censorship-resistant. I need to also introduce this idea of DAO. DAO is D-A-O, and it stands for decentralized autonomous organization. This is a very special idea that is basically, it’s an organization that is an algorithm. If you think about Bitcoin, it’s like that. It’s just a program. There are many people that make their livelihood from the computer program. Think of the minors being employed by Bitcoin. But for Bitcoin, there’s no company. There’s no board of directors, no CEO at Bitcoin. There’s no financial statements, there’s no tax. It’s just a program. Smart contracts make it possible to have many companies like this. If we want to call them companies that are effectively algorithms. What has been done in the past where you start a company and you launch an app? Can be done much differently. You put a smart contract out that enables a decentralized application. Again, we’ll go into more detail. Next, I want to talk about the problems that DeFi solves. I’ve gone through some of the problems. I’ve given you an overview, but we need to go a little deeper into these problems so you fully appreciate the power of this disruptive technology.

03_problems-DeFi-solves

01_inefficiency-limited-access-and-opacity

01_inefficiency.en

In the third module, we’re going to talk about in some detail, the problems that centralized finance actually solves. I’ve already given you an overview of these problems. But I want to go into more detail. Because in understanding the problems, you see the potential of this space. I’ll talk about inefficiency, limited access, opacity, centralized control, and lack of interoperability. Let’s take a look. We begin by inefficiency. Think about DeFi in terms of what it can accomplish. DeFi accomplish basically, very high volumes of transactions with very low frictions, which would be an organizational burden. As I’ve said previously, that to transfer the equivalent of a $100 or a $100 million, that is basically the same thing in terms of ease of actual execution of that transaction. But it goes deeper than that. That the Spark contracts that are designed can be reused. It’s not like you’re building something and then you have to rebuild it, or have to specialize it for every single application. These can be reused in the form of these decentralized applications. It gives a lot of leeway in terms of what you do. The size of the transaction is pretty well irrelevant. I will qualify this a little bit. I end that given that the gas fees are so high right now, that does provide a barrier to some smaller transactions. But my opinion, that is a problem that will be solved in the future. There’s no organizational overhead. There is no brick and mortar. There’s no layers of middle people. A user can operate within the parameters of the smart contract, and the contract on whatever a block chain it resides. I’m mainly talking about a theorem. But there are other blockchains, not the Bitcoin blockchain, that also can host decentralized applications. Basically, this is open to anybody. There’s no interview that’s necessary, there is no checks. This is can be used by anyone. This is a technology of inclusion. It’s a technology of financial democracy. Once that contract is deployed, it lives forever. On the Ethereum blockchain, for example. It’s there, there’s no organizational overhead. This is another attribute of efficiency. Keepers are something that we should understand. Keepers are external participants that are incentivized to maintain a service for decentralized finance protocols. For example, they might monitor the collateral that you posted for a transaction. If the collateral dips in value below a certain point, then they will liquidate your position. They’re providing a service and they get paid for it. This isn’t automatic. These are our actual agents that are essentially providing the service to a decentralized finance application to keep it running the way it should be running, and to reduce the risk, and they get rewarded for that. The actual payment that these keepers get is market-based. Think about it as an auction that happens. They are an integral part of this network. This is a general point that within DeFi, it’s structured in a way that the users are essentially paying market prices for the services they need. This is a lot different than centralized finance, where you’re not paying market prices for the services. I did a wire transfer dollars to euros the other week and I was quoted a rate and I was told I’m such a good customer of the bank that they would waive the fee. Well, the rate I was quoted was not a market rate, indeed it was three percent off the market rate. Again, this is just an example in centralized finance of a bank making a fee on a fairly straight forward transfer of dollars to euros. This doesn’t exist in the same way in terms of decentralized finance. There is another aspect that’s fascinating, and it’s the idea of forking. Let’s say that there’s a smart contract out there and you’ve got an idea to improve it. Well, what you can do is copy the code that’s public access. All the smart contracts, the code is publicly available and you can make that improvement or upgrade, and launch it. Potentially take business away from the old smart contract that you effectively or copied and improved upon. Think about that it’s a deep idea that instead of reinventing the wheel, having to do all of the steps of designing the contract and then improving it, you can actually start with the existing contract, you can make the changes and you’ve got something better. It is so easy to fork. This basically makes everything much more efficient. Think about a small change that is important, but maybe not as important to invest all the time of building something from the bottom-up. Well, you don’t need to build from the bottom-up, you can actually take what is there, improve upon it, and redeploy another smart contract. This is a very powerful idea within decentralized finance. It’s also the true that this is a general thing for not just the average smart contract, but decentralized apps also. Again, if you’ve got an idea for improvement, it’s easy to create a new dApp. All of these dApps are forkable. Again, this really helps with the efficiency of the technology. There’s a term in my work cloud called vampirism. Because of the open nature of decentralized finance, anybody can just go copy the current technology. Technology might be working fine, but you copy it and perhaps you provide an incentive mechanism for people to switch from the contract that you basically grabbed to your protocol. It’s really intense competition because then if there’s enough people using the new platform, then the old platform might need to change its incentives. In the end, the users get the best deal. There’s also risks that are associated with vampirism. It could be that, and we’ll talk about this in much more detail in the fourth course, that some of these rewards are flawed. It could create a situation where people lose a lot of money. It’s also possible that the code is effectively hijacked and modified in a way that leads to additional risks. We’ll talk about specific examples of that where a smart contract was taken and modified in a way that led to a vulnerability. This happens, so you need to be aware if somebody is doing this. These protocols are not without risk, and that’s an important part of this course.

02_limited-access.en

The second issue or problem with centralized finance is limited access. What do I mean by that? Decentralized finance, I’ve said this and I’ll say many more times, is financial democracy. It gives underserved groups, such as the unbanked and the underbanked, the ability to actually operate in the Internet of value. You might think even within the US that, well, everybody’s banked. But they’re 18 million people in the US that are unbanked. This is a very significant problem, and the impact for the global economy is very significant. Essentially, DeFi gives consumers access to things that they might not have access to before. It’s only a very small fraction of the global population has access to things like credit or debit cards. The products are restricted in centralized finance, and indeed, the decentralized financial institutions, it’s their incentive to go for the most profitable slice of the population. They don’t want to deal with the small entrepreneurs, they don’t want to deal with the small customer. They’ll increase fees or just not be welcoming of them. In DeFi, it doesn’t matter who you are. There’s no check. Remember I said that in centralized finance, there’s the customer, the retailer, the banker, the regulator. There’s no labels like that. Everybody is the same. They are peers. It’s true that some peers might have more wealth than other peers, but it doesn’t matter. Their transactions are treated identically to the transactions for those that don’t have as much wealth. There’s other things that are interesting and this is very recent in the space of DeFi. Suppose you do have a bank account, and you want to put your money to work and earn some interest. You want to at least cover the rate of inflation, and that’s usually how it works. However, in most of the world right now, interest rates don’t cover the rate of inflation. When you deposit your money at a bank, you get zero or trivial interest rate that is way below the inflation rate. That means that you’re losing real wealth. DeFi offers the following possibility. Well, the question is, why are the rates so low for deposits and why are the borrowing rates so high? A lot of this has to do with all of the fixed costs of centralized finance. If you get rid of the fixed costs, then it’s possible to increase the savings rate and decrease the actual lending rate. This is exactly what’s happening in decentralized finance. If you, let’s say, have a stablecoin like USDC, you can deposit that into a liquidity pool, and we’ll go into a lot of detail as to how this works in the third course, DeFi, a deep dive. But you get a reward for actually doing that. A savings rate, and these savings rates are much higher than the bank savings rates are today. Indeed, if you think about what happens in traditional banking, you put your money as a deposit, and you get paid very little interest. But the bank takes that deposit and lends it out. Then the person that gets the loan might deposit some of that in another bank. The cycle just continues and it’s called a money multiplier. Well, the same thing can happen in decentralized finance, where I deposit some money with liquidity pool in one particular protocol, and then I get effectively a token from that, that represents my share, my ownership of that pool. Well, I can deposit that token somewhere else and earn interest on it too. Again, we are disintermediating the bank, and it’s essentially doing the same thing that a bank is doing, having a money multiplier but within this space. The bottom line here is that you’re able to get a rate of return on your deposit that is not as risky as investing in Bitcoin or Ethereum, and have a chance at a rate of return that meets or exceeds the rate of inflation. Again, this is open to anybody. You don’t need to be a big player to actually do this. This is a very simple technology. There are many benefits to so-called yield farming. However, you also need to be careful because many are making promises that seem unrealistic and it’s always best to go with the protocols that have been out there a while and tested. There’s always a risk to take care of. There’s another idea in terms of limited access and it’s called an initial DeFi offering. We know what initial public offerings are. Initial public offerings are when a private company goes public on a stock exchange. The stock might have been privately traded, and those that able to trade that stock are usually very high net worth individuals. There’s a long process that you need to go after to actually be listed on a centralized stock exchange. That is really not available to most companies. Very small number of companies are listed on stock exchanges compared to the number of companies in general. The reason is limited access. Why would you want to be listed? Well, it’s a way to raise equity. It’s funding. You can go to the bank, you can go and maybe sell somebody a bond, or you can offer equity. This is fairly straightforward to do in DeFi. Equity has a different meaning. We’ve got equity, we’ve got tokens, and we’ll go through all the details of this. But the idea with an initial DeFi offering is that we can actually launch a token in a very straightforward way in a smart contract and essentially set an exchange rate or a floor rate on that token if we’re the first liquidity provider. This is very straightforward to actually do. Let’s go through the mechanics of how this actually works. Let’s say we’ve got a token, we’ll call it DFT and it’s got an initial supply of two million. What we can do is we can make the initial DFT token worth 10 cents. We’ll quote things in terms of USDC, which is linked and guaranteed by Coinbase in terms of its peg to one dollar. Basically, what you could do is to create an initial market where you’ve got a million DFT in a liquidity pool with 100,000 US dollar tokens. Basically, here’s a situation where people are purchasing the DFT that will drive up the price, and you immediately set the price given what you’ve contributed to the liquidity pool. This is a very straightforward mechanism and quite popular today. It allows for a startup to instantly come to market. If you think of coming to market with a product, it’s so complicated, this is all done virtually. It’s all within the smart contract. There are some disadvantages and let me be up front. One disadvantage is that the floor that’s set is somewhat artificial. There could be price discovery that suggests this token is not worth 10 cents, it really should be worth five cents. This is not perfect, but it just allows people to innovate very quickly. Again, this is part of the democratization of access and IDOs are one of the components of that democracy. This is a way to deliver user access to have an entrepreneur launch something very quickly, very cheaply, without the traditional baggage of hiring an investment bank and lawyers and all of the fees that are associated with that.

03_opacity.en

So the third problem of centralized finance is opacity. So let me talk in some detail about this. So traditional finance is transparent to only certain people in particular the regulator. So effectively, what we need to do is to trust that the regulator has got the information that it needs and that the company is actually providing accurate information and that the regulator is very diligent and checking all the time. So decentralized finance, everything is transparent. So the smart contract anybody can look at. So you know exactly what the balances are, of all of the contracts, the players, this is completely open. Okay, so this is a much different situation than centralized finance where we can’t really see this. So when you’ve got a smart contract and that smart contract might actually hold a balance. So I gave an example of the DFT token and some USDC, anybody can check the ballots. So think of this as you know in terms of your counter parties exactly how much they have. Okay, so even in centralized finance, the bank doesn’t really know how much capital their client might have. They can ask but they’re not sure, within decentralized finance, it’s immediate, So the collateral very, very clear. It’s also possible to read the contract. It’s there, his contracts are are usually fairly simple so you can determine if the terms are agreeable to you. Okay, so this is very transparent. So this also kind of eases the threat of kind of legal Obertan’s because it is transparent, it’s there, right? There’s no fine print, it is an algorithm and every single line of the algorithm is the same font size. So I think that this is something that in traditional finance, especially the small clients, they get taken advantage of all the time legally by the fine print. And the contract will be very complicated potentially many, many pages and it just seems like too much for a small user to go through and essentially figure out all the details of that contract. This new space is much different. However, there’s one thing to read a 25 page contract and centralised finance, but another to read a couple of pages of solidity code, so that’s one of the languages that’s used for smart contracts. So the average consumer probably doesn’t understand that code, but again, this is one of the beauties of decentralized finance, it’s open source. And there is a sense of the wisdom of the crowd that if there is a flaw in that smart contract, if there’s a condition that’s not very favorable to the users, then it will be forked, so somebody will take it and improve it. Okay, so I think that this idea of forking and the transparency reduces the risks of a complicated set of computer code. There is still risk, but it is mitigated. So another thing is that these contracts are designed in a way to ensure the behavior of the people that are interacting with the contracts, behave in an appropriate way. Okay, so it might be that somebody has to put a stake up or an escrow and if there’s a problem then you lose some of your stake. So it’s incentive compatible. So this is a built in mechanism to make sure that the contract is basically doing what it promises to do. So staking is a very important thing that we talk about in this course in considerable detail. It is the easiest way to basically punish inappropriate behavior because if you behave inappropriately, the stake is slashed. Okay, so, and this is again, all built in to the actual contract. It also works the other way where there’s incentives to do things that are consistent with the contract. Okay, so it works actually both ways in terms of both incentives and penalties. So token contracts are really important, and again, there are 100s if not 1000s of tokens that are out there that are linked to the Ethereum Blockchain. And the token contract again is extremely transparent. So it tells you what the money supply rule is. So when we create a token and in my course I created it and the money supply is one billion tokens and that’s it, we’re done. I can’t change it to 2 billion because once it’s in the Ethereum Blockchain, it’s there forever. So think of this, compare that to our centralized financial system or our central banks, who knows what they’ll do to the money supply, we can’t look it up, they have a meeting and decide what to do and who knows what that would be. So, these token contracts really clear what the money supply rule is, how many tokens are in the system right now, there might be a money supply rule in terms of inflation or deflation but it’s all built into the contract and anybody can see it. So it’s a much different money system than we’re used to.

02_centralized-control-and-lack-of-interoperability

01_centralized-control.en

The fourth problem in centralized finance is centralized control. How does DeFi deal with that? There is centralized control in almost all of traditional finance. At the very highest level, it is a central bank or a government that controls the money supply. Then if you go down a few levels, you’ve got these giant firms that are exerting basically a market power over things like banking, insurance, and the exchange of assets. But when we start with the centralized government institutions, they hold effective monopoly power over things like inflation. I know that the link to inflation and central banks is somewhat controversial, but I don’t think there’s any controversy for those countries that have had to experience a hyperinflation, that central banks can create inflation if there’s excessive printing of money. Decentralized finance is obviously decentralized, that’s the name, decentralized. The control is not by centralized players, but by essentially open protocols that are transparent and people understand them, and they also understand that they’re immutable. Again, the stakeholders get to interact with these algorithms. There could be a parameter that controls the inflation or the deflation, as I mentioned earlier, and this is built into the decentralized finance dApp. It’s also the case that some of these apps are less decentralized than we might want. It might be that the applications got some special privileges for an administrator. I guess that that means that it’s not completely decentralized, but, and this is important, anybody can see that. We know that that administrator has got that privilege, and any user can basically take that smart contract and redo it, fork it, to a situation where you don’t have that centralized data control. It often is the case very early on, the administrators or the developers retain control for a short period of time, and then they transition to a fully decentralized application and that’s very common. But what I’m talking about is something that’s been out there a while, there’s no plan to go decentralized. If it’s a good idea, then we can just take it, fork it, and make it decentralized. This idea of forking, again, is a very powerful idea. If there’s a problem, if we don’t like the centralized control, if there is some flaw or if there’s just something that could be done better, it’s easy to grab the code, fix the code, and relaunch and it would be a new application that solves the actual problem. Again, this is really difficult to have an analogy in centralized finance. You’re using some interface, you’re using the bank’s interface and you think, “Well, this would be much better if we could do X, Y, and Z.” Think about how difficult that actually is to do for the bank, there are probably tens of thousands of lines of code, ancient code, that is really difficult to change. Whereas in this space, it’s really easy. Again, you don’t have to reinvent the wheel. You take what’s there and improve upon it, and this is the beauty of decentralized finance. With the bank, it’s centralized. There’s a long bureaucracy that you need the check the box off to get that improvement and the bank offered software, whereas in decentralized finance, anybody can do it and there’s a lot opportunity when you do that. What about the trade-offs? This set of courses, is not just about the opportunities, it’s about the risks. For example, in centralized finance or anything centralized, if there is a crisis, you can act very quickly. You don’t need to go and get consensus amongst the stakeholders. However, the disadvantage of this it might be an overreaction. Again, we’ll talk about this later on. A lot of this has to do with what the optimal governance is for a decentralized application, and we don’t really know, and different protocols or different governance mechanisms. The way I see it, we’ll figure out what the best mechanism is and then other protocols will adopt it; it is early on. But the key thing is that we’ve got security, we’ve got transparency and it’s very easy to do these changes. Again, let me go back to this idea of decentralized autonomous organization. It’s really what we’re talking about here. We’ve got, essentially, think of a protocol as it’s got a number of stakeholders. Not in a traditional sense, not in the board of director sense or the management sense, it’s got people that are invested in the governance and this is a decentralized organization. They don’t need to reside in the same location, but they provide some mechanism whereby if a change needs to be made, it needs to go through the governance protocol. Governance is very important, and we will deal with that later in this learning experience.

02_lack-of-interoperability.en

The final problem with decentralized finance is the lack of interoperability. What do I really mean here? In traditional finance it’s really difficult to integrate products. Indeed, even within my own bank, it is not straightforward to transfer funds from my bank account to the brokerage that the bank owns 100 percent. Even within a particular company it is difficult to do. We have to deal in general with wire transfers that are not secure and are slow and are costly to actually do. There are so many solutions that DeFi offers that go beyond what we could ever imagine doing in traditional finance. I want to introduce a concept called DeFi Legos. The idea here is just like a Lego block. You build a protocol that’s based upon, lets say, the Ethereum blockchain and somebody else builds a protocol based on the Ethereum blockchain. Maybe it’s really simple that it could be a token, so two different tokens. It turns out that’s really easy to put those tokens into another smart contract together because they follow the same rules. They’re both, for example, ERC-20, so they are compliant. We can put these together and move them around across the different protocols. Even your protocol might have its own token, it is able to house other tokens. This is the idea of interoperability. This is completely different than the pain and the cost and the time that it takes to do simple things, like a wire transfer from US dollars to Euros. This is so different, it happens near instantly and all of these tokens can interact with each other. The idea here is that you can build something and then other people can build on top of what you’re doing and you become part of the structure. Think of it as a Lego Castle. You put a brick in and instantly you’re connected with all of the other bricks. Is a very powerful idea and completely different than anything that we’ve experienced in centralized finance. Essentially, we are able to combine existing protocols with other protocols. Indeed, we can create a new protocol by just combining a number of existing protocols. Again, you can’t do this in a centralized finance. Tokenization, I’ve mentioned a number of times already. This is really important. There’s so many different layers to it that we’re going to explore in the later courses, such as tokens, you can place these tokens in liquidity pools. You can have another token that represents your share of the liquidity pool. You can have a token that wraps another token, so there’s many possibilities here. But the key thing in decentralized finance is that all of these tokens can interact with each other because they’re based upon the same general protocol. Tokenization is a really big thing. It’s one of the most exciting things in this course, because I’m going to argue in the course that we soon will be able to tokenize almost anything. Think of illiquid assets that are not traded because they are illiquid, and maybe it’d be very costly to trade them, but you can actually tokenize them and easily trade them. It might be a piece of art that you tokenize, and many people can invest in that piece of art so you’ll have a share of the piece of art, and if it goes up in value, you will profit off from that. It could be another asset. It could be land or something like that, where it’s very illiquid, but you can tokenize that. You can tokenize services. There’s so many different things that are possible that it opens up the possibility of a number of new assets. Any time you bring in new assets, that’s good because it reduces the frictions in the market, it allows people to diversify portfolios in a way that they couldn’t diversify before, and essentially it unlocks value. It unlocks value in traditionally illiquid assets. There’s a lot of possibility here. It’s also possible to bundle the tokens together. The tokens could represent a share of stock. Well, you could bundle the tokens together into a DeFi equivalent of an ETF, or exchange-traded fund. Just think about the way that we progress, went from mutual funds, very costly. We go to exchange-traded funds, which are lower-cost but still are costly. Then the next wave is a bundle in DeFi, that is really super cheap to transact in. There are many, many possibilities here in terms of tokenization, and again, it can be tokenized in terms of a virtual asset, like Ethereum, or it can be tokenized in terms of a physical asset. There’s many possibilities. It could even be tokenization of an intangible asset. It can be tokenization of a service. There are so many possibilities here, but of course there are challenges, and let’s be upfront. To tokenize a virtual asset is very straightforward because everybody can see it. Everything resides on the Ethereum blockchain, for example. But once we start tokenizing hard assets, then you have to have some trust. We tokenize gold, and the gold needs to be held in a vault somewhere. That gold actually needs to be audited, and there’s a cost associated with the audit, and the vault. Some things are more difficult to tokenize than others. There’s also potential legal restrictions. If you tokenize with Ethereum, then that doesn’t exist anywhere. It exists only in blockchain notes. But if you’ve got your collateral in a vault in, let’s say, London, then you’re potentially subject to the political risk that might unfold in the UK. Again, we need to look at this in a balanced way, that there are advantages and disadvantages. My read is that advantages greatly outweigh the disadvantages. There’s this other idea of pluggable derivative assets. This is essentially an asset is created with a smart contract that’s linked to another asset potentially on another platform. This is again portable through the tokenization. We’ll talk about compound in some detail and the DeFi deep dive. We’ll go into much more detail as to what pluggable derivative asset is. But I don’t want to wait until the third course, I want to give you a little bit of a preview. Let me just talk a little bit about compound. Compound is basically allows for lending, and if you put liquidity in you can actually accrue a variable interest rate. The position is a token in itself, so for example, if the base asset is Ethereum, and you deposit some in Ethereum you get, as a result, a share of that pool, and that share is a new token. It’s called a cETH, so small case c with the ETH. That can be used in place of a base asset like Ethereum in another protocol, it’s a very, very powerful idea. Essentially, if you think of Ethereum as a token, then this is a token on the token. Again, you deposit your Ethereum, you can earn some interest on that, you get your share of that pool, then you can use that share to do other things. It’s collateral in itself. Very, very powerful idea. This is basically what we can do is have effectively, and this is in the true sense, a derivative asset. The cETH is a derivative of the Ethereum. Again, this can be deployed and used to create collateral or earn interest on itself. Again, this is a totally new world where you can actually issue a new token so easily based upon an existing token. There’s also this idea of networked liquidity, this is the idea that it’s pretty difficult in traditional finance to share liquidity. In traditional exchanges it’s not possible unless you’re a hedge fund and you’ve got a thing that’s called a prime broker, so this is very very limited. But within the space, it’s really easy to share liquidity and there’s an incentive for doing that. You put your token in, you get a rate of return. You’re thinking that Ethereum will go up in value in the future, you don’t want to sell it. But you don’t want to not have it go to work. The equivalent with paper cash is to put it under the mattress versus putting it in the bank. You put it in the bank supposedly to earn some interest. You do the same thing with your Ethereum and it allows you to create liquidity in the same way as deposits create liquidity for lending for the centralized financial institutions that traditional banks do today. This network liquidity is important in that it allows us to basically harvest liquidity from the crowd rather than the financial institution that is centralized, that is opaque and a central’s got to pay for all of the middle layers that we don’t need to pay for in decentralized finance.

04_defi-myths-and-facts

01_misunderstandings

01_misunderstandings.en

The final module in the first course has to do with DeFi myths and facts. I will focus on a number of misunderstandings that are very common in the space, and I will close with the vision for the future of DeFi as well as some conclusions on this first course and a preview of what we’ll do in the second course, which is called DeFi primitives. Let’s start with the misunderstandings, and there’s lots of them. Some of these misunderstandings, I think you’ll see there’s some truth to them, but it’s more complicated. For example, DeFi is a small part of the market compared to CeFi and will never overcome CeFi. Well, the first part of the statement is definitely true because we’re really small, we’re less than one percent into this disruption. But I think it’s really important to look at the vector, look at where we came from to where we are today in DeFi, and that vector is very positive. It’s not as much where we are today compared to centralized finance, it’s what if we continue on that vector, how long will it take for DeFi to replace centralized finance? Of course, there’s many hurdles here, and one hurdle is the strength of the entrenched players. So the banks, the stock exchanges, the insurance companies. They’re very strong players and it’s in their interest to delay, postpone, or excessively regulate. Number 2, DeFi is difficult to use and we’ll never have widespread adoption. Well, the first part is also true. Again, this is early on and the user experience today is not very good. But the question is, is that experience going to be the same in the future? It doesn’t make any sense. You should not rule out a transformation of the user experience so that using DeFi applications are just so easy. It’s like using the apps on your phone that we’re used to using that deal with centralized institutions. It’ll be just seamless. Indeed, I think of my own experience with the Internet in the 1980s. Emails, credibly difficult to use. It’s clunky. The interface for email and file transfer was terrible and it was a real barrier to entry. But then the World Wide Web was launched in the mid 1990s and the experience improved and continues to improve. Number 3, cryptocurrency is mainly used for illegal activity. It is true that early on in the life of Bitcoin, it was used for illegal activity and maybe that actually contributed to its profile, and this is just a screenshot from the Silk Road website, on the dark web that you could buy drugs and other things, and everything you can see is priced in Bitcoin. Very expensive compared to the price of Bitcoin today. It is important to understand that, number 1, these cryptos are not totally anonymous and I’ll explore this in some detail. There are cryptos that are anonymous, and that actually is a reason not to use cryptos like Bitcoin or Ethereum in illegal transaction. If you want something that’s anonymous, you have to use cash because cash is ultimately anonymous. Indeed, it’s interesting to me that 79 percent of the value of US currency is in $100 bills, yet people don’t carry $100 bills. Indeed, to go pay for something at a retail outlet, there’s often a sign that says, “We do not accept $100 bills.” Why is 79 percent of the value of the US currency in $100 bills? That’s pretty simple. To me, this is what’s used for illegal activity. The large denomination bills are just the ideal choice. [inaudible] was interesting when El Chapo, the Mexican drug lord was captured, they seized $200 million in cash. Almost all of it was $100 bills, but also there was a good chunk of 500 Euro notes and things like that. You want illegal activity to be anonymous, then you use cash. Next one is government central bank digital currencies will put cryptocurrency out of business. The CBDCs, as they’re known, face many hurdles but importantly, governments are strongly incented to actually have a central bank digital currency. The reason is simple. It makes it almost impossible to evade taxes because they see everything, and also you have instant monetary policy. But one of the hurdles is, I think it’s going to be a very tough sell. That maybe, this can work in China where the citizens don’t really have a choice, but are you comfortable with the central bank seeing every single transaction? Probably not. It’s also the case that with the central bank digital currency, you can create, but you can also destroy, which means you could be censored. What does that mean? That whatever money you’ve got in the central bank digital currency could disappear. Next one, blockchains are not secure. For example, the government hack the hackers to get back the colonial pipeline ransom. Like I said, this one’s totally false. The colonial pipeline ransom was in Bitcoin, and the Bitcoin blockchain has not been hacked. I’ve already gone through that this is technologically infeasible to hack. What happened was that the hackers weren’t very smart, and they kept their private keys for the Bitcoin that was sent to them on a computer that was hooked up to the Internet. That’s a basic mistake. Then the government hacked into their computer, stole their private keys, and moved the Bitcoin to their own account. This has nothing to do with block chain. This has to do with somebody or some group of people being careless in terms of the private keys. There’s also many other stories of centralized exchanges being hacked and again, this has nothing to do with blockchain technology. It has to do with the careless security measures that are implemented in protecting the private keys. You want to really protect your private keys. You keep them basically in a cold wallet, which means something that’s not connected to the Internet, and many mistakes are made and lessons learned. Here’s one, all cryptos are bubbles. There’s no fundamental value. Well, we’ve actually already gone through this that it is possible to have, for example, the Iraqi Swiss Dinar that didn’t have any fundamental value, but it had value. The key thing to realize is that if you’ve got something that’s collateralized, well, that’s got tangible value that’s true. The second thing is that there’s many different types of cryptos. We’ve talked about Bitcoin, we’ve talked about Ethereum, but we’ve also talked about tokens that are linked to gold or stocks. Those definitely; the gold and the stocks have tangible value. There are other cryptos that provide services, utility. You can’t lump them all together, number 1, and number 2, I think I’ve emphasized that value also comes from intangible value, not just tangible value. Mining is a waste of energy. We’re going to deal with this in extensive detail in the fourth course, where I will actually go through and calculate how much it would cost in terms of carbon offsets to produce one Bitcoin. I’ll go through the calculations. Proof-of-work which Bitcoin and Ethereum use right now, is both a strength and a weakness. It’s a strength and it provides unprecedented security, but it’s also environmentally reckless. We have to deal with that. That is what I call environmental risk. I’m not worried about Ethereum. Ethereum will transition in 2022 to a different consensus protocol that is very friendly in terms of the environment, but Bitcoin is a different story and again, in the fourth course, we will deal with that. Here’s one, cryptos are two volatile to be useful. Again, this very sloppy because it depends on what crypto you’re talking about. If you’re talking about Bitcoin, yes, of course, it’s five times more volatile than stocks. There are individual stocks that are five times more volatile than, let’s say the S&P 500. But things like stable coins are not volatile. Or a token that’s tied to a particular utility, like computing time or storage, disk Storage. They’ve got value that is not volatile. It’s market does add value. Nevertheless, it is true that the cryptos are volatile. There’s probably two leading factors driving that volatility. Number 1, is the uncertainty over what the value actually is. Some people believe Bitcoins worth zero, some people believe it’s worth $400,000 a coin. That’s a pretty big gap. Think about a stock, people might disagree upon the value of the stock, but it’s nothing like that. That’s the first thing. I guess the other thing is that there’s relative illiquidity. Yes, this market is $1.5 trillion as of this recording, but it’s still small. I’ll compare it to other asset markets. That means that a large sale could drive the price down and a large buy could drive the price up temporarily, creating volatility. Will volatility decrease in the future? Probably. But again, it’s difficult because there is no tangible value here, there’s intangible value and with intangible value, it’s always difficult to actually figure out how much that is worth. Quantum computing will render the whole space irrelevant. Well, it turns out quantum computing is irrelevant for cryptographic hashing. The machine in the basement that we do our theorem hashing or Bitcoin hashing, that’s not going to be replaced by quantum computer. It’s a misunderstanding of quantum computing technology. That’s one of the things that I teach in my tech driven transformation, a business course is quantum computing. Also, a theorem transitioning to proof of stake makes it even less relevant to talk about quantum computing for hashing. However, there is one issue, and that is the way that we generate our public keys and the way that we sign the transactions. Right now, and I think I said this earlier, it’s really easy to generate a random number which is your private key, and then put it through a computer program to derive the public key. But it’s really hard to go the other way. It’s not feasible actually today. Quantum computing holds the promise of going the other way. But the solutions relatively straightforward. You just use a different signature, use a different algorithm. Then the current algorithm, and these algorithms already exist today and they’re called quantum resistant signatures. Transactions are too expensive and too slow, so DeFi is going nowhere. Well, that’s again one of these statements that is true right now. But in the future, it’s not obvious. It is a big mistake to assume the technology remains stagnant and prudence will definitely happen. There is the possibility that we go to a world where transactions costs are near zero. That opens up many, many possibilities. You need a smartphone and Internet to make this work and billions do not have either. Well, that is also true for today. But currently you can get a smartphone for $20. In luck, in a couple of years, almost everyone will have a smart phone no matter where you are in the world. Indeed, it’s interesting, in some parts of Africa, you can buy smartphone and it comes with a small solar panel with a light bulb also, so you can charge your phone even if you don’t have electricity. This will happen. The Internet itself, it will be commoditized, it will be worldwide, will cover the entire globe, essentially for free and we’re seeing that happen already. Again, you need to think of the future. There are pump and dump and Ponzi schemes and DeFi making it unattractive for investors. Well, let me tell you that throughout the history of business, there’s been pump-and-dump schemes and Ponzi schemes. Pump and dump is where you really say things positive about your product. You might even go buy some of the product to drive the price up. A product might be a stock price. Then you dump it. All of those that went along for the ride, they saw the price going up, they get wiped out. Any technology like this, it’s got a risk of people trying to take advantage. What you need to have is a discipline. Fundamentally, if you’re investing in deeper, you need to understand the protocol. You should not invest if you do not understand the protocol. The same thing with any other investment. Some of the discipline that I teach in my courses are the following, ask the following questions; does the DeFi idea solve a problem? It’s not useful to solve a problem that doesn’t exist yet. Number two, is the problem an important problem? There’s plenty of small problems but value is not going to be created unless you’re solving big problems. Is DeFi the best way to solve the problem? There might be other ways to do it with a regular database, a centralized database that solves the problem. Of course, you need to look at the competitive landscape. You need to figure out how easy it is for a competitor to enter so-called moting. A very important question is, does the idea scale? Often we start with one particular application and the technology can be used to either horizontally scale, which means to go into different markets, maybe globally, or vertically scaled to use the same technology in a different application. To repurpose the basic idea for a different application, so these are very important things. Before you do the investing, you need to go through this list. DeFi is too hard to understand. Well, you’re taking this course, and I think at the end of this course you’re going to be in good shape. I congratulate you for taking the courses. It is definitely true that it is hard to understand and some of the concepts that I’ve gone through so far in this first course, we’re going to loop back and return to them and go into more detail. It’s definitely hard to understand, plus it’s changing, so even though you do this course, there will be innovations that happen shortly after the course, however, this is really important with the new technology that’s complicated. If you’ve got a reasonable understanding of the technology that opens opportunities, so the ones that are informed have a really big upside and I want to make you one of the informed. Another one is DeFi to proceed. But every new technology is risky. If you want risk-free, then you hold treasury bills which don’t even make the inflation rate so you lose value, but you’re safe. DeFi is risky, definitely true but it’s also anti-fragile. What I mean by that is that you can attack a DeFi protocol, you can find a vulnerability and then we just forkit and improve upon it and make it stronger. That’s very unique and it can be done very quickly. DeFi is too early in development. I will wait. Well, I doubt you’re waiting given that you’re enrolled in my sequence of four courses, but that’s a typical of response. Yes, we are early. But for me, that is the advantage. You always want to be in early. By the time it’s so developed, there won’t be any upside or not the same upside. That is not a good reason. You should not wait. You need to get in now. DeFi, this is the last one, requires a degree in computer science, which I don’t have hence I’ll avoid it. Well, I don’t have a degree in computer science. Many of the most prominent people in the DeFi space don’t have a degree in computer science. The most important quality in DeFi is the same most important quality in almost anything. In business or the arts, it’s creativity. It’s important for you to understand the potential of DeFi and its risks. You don’t need a CS degree for that. You can generate ideas. You might not be able to execute on the idea, you need a developer to do that. In execution, very important, so you need a partner. But if you’re creative, the upside is virtually unlimited in this space. I think there’s a lot of misunderstanding in the space and hopefully, I’ve cleared up some of the myths.

02_conclusion

01_conclusion.en

Okay, so let me finish up this course and let me talk about vision and a few concluding remarks. So vision in DeFi is a secure, efficient, immutable, and indisputable transactions and functionality via smart contracts. This is what it offers, something that we haven’t had before. We remove the middle people and make this a much better experience for users. It’s not true that everybody is better off. The users are definitely better off. So if you’re depositing money, you’re better off, you’re borrowing money, you’re better off. But the middle layer, they’re definitely worse off because they’ve been disrupted. But overall for the economy, it is better to redeploy the middle people from traditional finance into more productive jobs. So there’s definitely the removal of middle people and the replacement with this algorithmic interface between peers. I want you to think a little bit throughout this learning experience about what the world actually looks like with near zero transactions costs and the possibility of creating new assets. So we’re so used to paying the monthly bill, what have we paid in real time? What if we tokenize something as simple as a cell phone tower, and you bought a share of that tower and anybody who passes by the tower makes an instant payment to the tower and you get paid an instant dividend based upon your share? So again, new assets are possible here and it’s very exciting. The trust is shifted from our central banks or our traditional commercial banks, insurance companies, brokerages. Basically trust the network now, and the network is constructed in a way that is compatible for the proper use of the network. Some people are rewarded, and if there’s any bad behavior, it’s punished. We’re talking about a world where everything is tokenized. That is an interesting thing to think about that. Your wallet, your digital wallet has gotten various different assets in it and it really speaks to what does it really mean to be a reserve currency or a numeraire currency. And of course, last but not least is the financial inclusion for the unbanked. And it is a great tragedy of our current system that there’s no room in traditional finance for the unbanked. They basically don’t generate a profit and we perpetuate inequality as a result of this. So DeFi offers the opportunity for everybody to be treated as peers and all peers are equal. So last is a word cloud that I put up and we made some progress in this first course. You can see that there’s a lot of check marks and let me tell you that even though I put some check marks on the word cloud, we will look back and go deeper into some of these particular words. So we’ve scratched the surface in this first course and we’ve got much more to do in the next course, DeFi primitives. We’ll talk about in much more detail, fungible tokens and transaction mechanics, NFTs, supply adjustments, swaps, collateralized loans, and an incredibly interesting concept called a flash loan alone that requires no collateral. It could be hundreds of millions of dollars, no collateral. It’s got no duration. It happens instantly and is paid back instantly. There’s no credit rating necessary, but it’s a really important part of decentralized finance. So stay tuned and I will see you in the second course DeFi primitives.

05_Resources

01_module-1-slides-from-video-lectures

02_module-2-slides-from-video-lecture

03_module-3-slides-from-video-lecture

04_module-4-slides-from-video-lecture

2. Decentralized Finance (DeFi) Primitives

01_mechanics

01_introduction-and-transaction-mechanics

02_transaction-mechanics.en

Welcome to the second course in the learning experience, DeFi and the future of finance. The second course we’re going to talk about DeFi primitives. These are the fundamental building blocks of DeFi, and it’s really important to understand them to fully appreciate the potential of decentralized finance. We’ve already gone through in the first course, DeFi Infrastructure, and that introduced some of the key concepts that are important for, not just DeFi, but blockchain technology in general. In this course, we will talk about the mechanics in the first module , of decentralized finance. The idea of supply and how supply is varied in terms of an increase in supply and decrease in supply. Ownership. We’ll talk about loans, in particular, collateralized loans, and swaps, which is basically exchange. Then at the end, I’ve got a module that talks about joining the world of DeFi, and we’ll set up a wallet using MetaMask. Then near the end, what we’ll do is review the blockchain tech big picture, to go through the key general concepts, so we’re all on the same page. In the third course, which comes next, we’ll do a deep dive into the existing protocols that are very popular in terms of DeFi today. The final course, course number 4, focuses on the risks and the opportunities of decentralized finance. Let’s start with the mechanics. We’ll talk about transaction mechanics, we’ll talk about fungible tokens. We’ve already introduced fungible tokens in terms of the ERC20 in the first course. But remember, I said in the first course that there’ll be a number of opportunities to revisit some of the concepts that I introduced in the first course, and this is one of the opportunities. Of course, we will also talk about NFTs or non-fungible tokens. Let’s get started with the mechanics. Transactions in Bitcoin and Ethereum are different because Ethereum offers something extra. I mentioned this in the first course but really want to emphasize that here. There are two types of accounts or addresses in Ethereum. One is an Externally Owned Account or an EOA, and that’s basically what you’re going to set up at the end of this course using a MetaMask wallet. You will have an address. I’ve got an address also, I will share my public address with you. Indeed, we will talk about how that address is actually derived today in considerable detail. With this externally owned account, it is very straightforward for me to send some Ethereum or any token that’s associated with the Ethereum blockchain from one address to another address. It might be that I’m sending to you, but it might be I’m sending to myself because I can have an arbitrary number of addresses. Indeed, think of it as a physical wallet, where you’ve got two physical wallets and you can take some paper currency out of one wallet and put it into the other wallet, and that’s same thing happens in the world of decentralized finance, but obviously it’s all virtual. However, Ethereum, and this is where we depart from the Bitcoin world, there’s more, so it’s not just externally owned accounts. There is a possibility of a contract account. This is a smart contract that lives on every node in the Ethereum blockchain. In that account you can actually send funds to, and that account can disperse funds. It is an algorithm that’s running that is very important. This is a key distinction between Bitcoin and Ethereum. There’s nothing like this in Bitcoin. All we can do is to use Bitcoin as a transaction mechanism to transfer fund. That’s basically it for the implementation of Bitcoin that exists today. Ethereum is much richer. This is a different level, and this level is going to be really important. Basically, it’s also possible that when you send a transaction to a smart contract, it potentially can go from that smart contract and interact with many other smart contracts. Is going to be important for us? It’s not just you send something to the contract and maybe the contract sends something back to you. No. It’s possible with this idea that I introduced in the previous course of DeFi Legos, that this contract is there, and when you send a transaction to it, it might have many different steps. You start by interacting with one contract, so that’s the genesis. But then it’s possible from that point to interact with many other contracts. This is going to be important, in particular for trading and arbitrage and refinancing of loans and things like that. Disability to interact with multiple contracts even though you start with one. Another property that is going to be crucial and very important to understand is the idea of atomicity. What do I mean by that? These contracts are atomic. This is what actually happens. Let’s say I’ve got a transaction that has multiple steps in it. There’s multiple different components, so I’m going to be interacting with many different smart contracts, so it’s got many different layers to it. Let’s say I’ve got 10 steps, and I go through the first eight steps, no problem, but there is a problem with the ninth step, so the contract fails, and the transaction fails. That means that we actually revert to the original state. Think about the difference here between traditional finance and decentralized finance. Maybe you’ve got a wire that’s going to the UK and then it’s going to, let’s say France, and then it’s going to hop to Hong Kong. Suppose is no problem that the wire goes to the UK, and there’s no problem of going to France, but then something happens. There’s a problem with the last step going from France to Hong Kong. Well, your funds are stuck in France again, and you need to get them back somehow, and that’s going to be a time costly effort, and who knows exactly what happens. In decentralized finance. No. If you’re transactions got 10 steps and something fails on the ninth step, then you revert to the initial state. This is going to be particularly important and it will preview a concept that I introduced in the first course, this idea of a flash loan. It’s going to be very important. Think about taking a loan out in the first step that you’re going to pay back in the last step. I will argue that loan is pretty well risk-free. It’s risk-free because if there is any problem with any of the intermediate steps, you revert to the initial state before you took the loan. Having this atomic property is really crucial for the functioning of decentralized finance, so think of it as funds moving between many different contracts, exchanging hands. You know when this is happening, that if anything goes wrong, then you’ve revert back to where you began. This is again, a very powerful idea and crucial to defy. In the first course on defy infrastructure, we did introduce this idea of gas. Gas is an important concept. The cheapest in terms of the amount of gas that you need, is just a simple transaction between two externally owned accounts, just a simple peer-to-peer transfer, let’s say of Ethereum. Again, it’s really simple. It doesn’t take much computing power to do that. That computing power is directly quantified into the amount of gas that you need. All computing power that’s used on Ethereum blockchain has got a calculation in terms of the amount of gas that’s necessary to actually do it. This is why Ethereum is a distributed computational platform. You’re actually running some code. That code might be really simple, and it wouldn’t take much gas, or it might be more complex. You can imagine a transaction going to a smart contract that has got multiple components to it, where you interact with many different smart contracts. That’s a much more complicated transaction. It will take more gas. Of course, the cost of running this is the amount of gas, which equals the amount of computing power multiplied by the price of gas. The price is set competitively in an auction. As I said in the first course, that if the network is very congested, a lot of people are active, then the price of gas will be bid up, making it more expensive to do any transaction, and especially a very complicated transaction. Just let me review a few important things that if you calculate the amount of gas and send more gas than is needed to do the transaction, then the residual is transferred back to you, the user. You get a refund effectively if not all the gas that you budgeted was used. However, if you don’t send enough gas and let’s say you’ve got this transaction with 10 different steps, it gets through the first eight steps, but then runs out of gas. Well, that’s what I was talking about in terms of something failed. Something fails in that transaction, and what happens given that this is atomic, we revert back to the initial state before number 1 through eight were actually executed. In this case, there’s no refund, and there’s no refund for a simple reason. You actually use the computing power of the network to get through steps 1 through eight. It doesn’t make any sense to refund something that you’ve actually already used. That is an important subtlety of how gas actually works. Again, the gas fee is set competitively in an auction. Gas is an issue, and we have already talked about this in some detail that if the gas price is too high, then it discourages people from doing smaller transactions. Ideally, we want a world of defy where the cost of transacting is really low. Ethereum developers totally understand this and think of this as a short-term problem that they are actively working to solve. Because for Ethereum to really take off as the premier decentralized finance platform, the cost of transacting must be reasonable. There are other competitor platforms currently today that are not using proof of work, or the cost of transacting is far less than Ethereum. There’s direct competition and many defy platforms are available on these alternative block chains too. This is something that obviously the force of competition will effectively push Ethereum to the point where these transactions’ fees are greatly reduced. Interestingly, for Bitcoin there’s no gas fee but say there is a transaction fee, but there is no initiative like the second version of Ethereum going to proof of stake. Bitcoin is stuck in the world of proof of work. Let me talk about something else, which is the memory pool. When a transaction is proposed, it goes into a holding area. This makes sense because we need to verify. Think of a simple transaction where you’re sending Ethereum from one party to another party. Well, what does a validation of that transaction look like? Well, the first thing is that a miner needs to gather it into their list of transactions. The first thing they’re going to do is to look at the fee that they could actually make in terms of like the gas fee. That’s the first thing they’ll look at, so gather the transactions. The second thing, they’re going to make sure that the transaction is valid before they go ahead and mine a block. If you put an invalid transactions into a block, even if you win the lottery of the hashing, the block won’t be recognized because it’s got an invalid transaction in it. You need to make sure everything is valid. You pull this stuff out of the memory pool. The memory pool is completely public, everybody can actually see these. This is basically the way that the miners gather the transactions and validate. But there’s something else here that’s interesting and it is a result of proof of work. The miners actually see all of the pending transactions. Think about that in centralized finance. Suppose that you had insight information that there was going to be a really big buy order for Ethereum. Wow. That’s something that you might want to get ahead of it but in decentralized finance, all of these pending transactions are public and what we’re really talking about is front running. Again, in traditional finance, you can’t do this. This is the illegal. You’ve got inside information that for example, somebody has got a huge order for IBM stock and then you go buy the stock before that order goes through. That’s called front-running. Then when the order goes through, it boosts the price because of the price impact and you make some money. That is the illegal, you’re using inside information to front run. What we’re talking about here in the world of decentralized finance is legal, front-running. It’s legal because it is completely open, anybody can see it. A miner might actually choose to exclude a transaction or put their own transaction ahead of a transaction and front run. Now, interestingly, this only works if you win the blocks, there’s some risk to it. But if enough miners are actually doing this, then there’s another source of revenue for the miners. It’s called minor extractable value. The miner extractable value is the amount of money that they can make by legally front running some transactions. Again, this is something that is sharply different from the world of centralized finance and this is an issue with proof of work. This is one of the drawbacks of proof of work. When we transition to proof of stake for Ethereum, this is much less of an issue. Think of this as another reason to move to proof-of-stake, to mitigate essentially the miners front running the users and when that happens, obviously it makes the user experience a less favorable experience. You can see, and this is a graph that shows that the amount of miner extractable value, or MEV has been increasing through time. These are the basics of transaction mechanics, both the positives and some other negatives with the current technology.

02_fungible-and-non-fungible-tokens

01_fungible-tokens.en

For the second part of the mechanics. Let me reintroduce fungible tokens. They are a crucial component of decentralized finance. So let me review the main protocols. So the most popular protocol is the ERC 20 and ERC represents a theory request for comment. So this is a protocol that can be used by anybody to create a token. As I mentioned in the course that I teach called innovation and crypto ventures as part of what we do in that course is to create a token. It’s very straightforward to do. The amount of code that you need is maybe 20 lines and it is generally available to do that. So you don’t need to be a solidity programmer to actually launch a token. It’s very straightforward. You just need to set basic parameters like the number of tokens and the visibility of the token and you are done. So it is remarkable that you could launch a token so easily. So ERC is a fungible token and as we kind of went through in terms of what that means. That means that every single token is identical in value, just like every single $1 bill is identical and value and ten $1 bills is identical to a $10 bill. So these this is the basic idea of fund ability. And the great thing with the ERC 20 protocol is that the tokens that are created with this protocol can interact with each other very easily. So any ERC token that’s created on the ethereum block chain can interact with any smart contract that’s created. So it’s not siloed basically it’s interoperable, a very powerful feature. So the integration is a big advantage for ERC 20. And again within a program to create ERC 20 certain key aspects that have already mentioned things like you need to set the total supply you need to be able to read the balance of a particular user, there’s transfer approval. All this stuff is kind of basic stuff that’s layered into the smart contract for it to operate efficiently. So this is very straight forward to actually pull off. So let me introduced the idea of a fungible token that is an equity token and I don’t want you to confuse this with another type of token that might actually represent a share of equity. So we’ve already talked about the possibility of widespread tokenization where you can have a token that represents an ounce of gold or a gram of gold. You can have a token that represents a share of apple and maybe it’s divisible by a million. So you can buy a millionth of a share of apple. This is not what I’m talking about when I talk about equity token and equity token has got a particular meaning that’s going to be important. So basically dis token is going to represent your ownership or your equity in a pool or some particular underlying asset, okay? So think of a pool and you’ve got a share of that pool and what we’ll do is to issue an equity token that represents your share of the pool. So let me go through and give a simple example. So we’ll have a token which was called TKN. And it’s got a fixed supply of 10,000, okay? And this token is corresponding to an ethereum pool that has got one 100 ethereum in it, okay? In the smart contract they’re basically it’s holding some ethereum, okay? And there’s a token that corresponds to that pool, okay? So what does that mean? Well that means that if we’ve got 10, 000 of these tokens and they represent a share of this pool with 100 ethereum in it. Well that means that the exchange rate is 100 token per either, okay? So this is basically just showing what the the ownership is of the pool, so token is away and it will be an ERC 20 to represent ownership in the pool. So it’s also possible that token can appreciate in value. So we’ve got a pool of ethereum that’s increasing at 5% per year. So then are our 100 of the TKN token, they represent one ethereum but there’s also the possibility of this 5% and again possible perpetual cash flow from it, okay? So this basically allows us, given this structure we can instantly see what the value of the TKN actually is. We know what’s in the liquidity pool it represents a share of the liquidity pool and we can instantly figure out what the value is in terms of the base asset in the liquidity pool which is either and this particular example, okay? So it turns out that this could be even richer in terms of the possibilities. And in the third course defy deep dive we will talk about variable interest rate mechanics that is used in a compound protocol which will spend a fair bit of time on because it’s a very important protocol. It’s possible that the contract or liquidity pool has got more than one thing. So I give you the example where there’s 10,000 token issued as equity token on 100 ethereum pool. Well what if there’s other things in the pool? So there might be a theory in the pool there might be USDC. The stable coin based on the US dollar or die or many other things that reside upon the ethereum block chain, okay? So it could be much more general in terms of the ownership. And indeed this could be dynamic. So what’s in the pool could be dynamically changing with a set of rules and we’ll talk about this when we talk about set protocol in the third course. Where you can literally have an algorithmic trading strategy that’s hard coded into the contract that is swapping in and out of let’s say ethereum and USDC. And you can own a share of that with an equity token. So very powerful idea. So there are at least three different types of tokens. So we just talked about an equity token. There are also utility tokens. So this means that this token is required to utilize a functionality of a particular contract, okay? So it’s providing utility that you needed to actually run the contract, okay? So the value is determined by how useful that contract actually is, okay? So there’s many different types of utility tokens. So utility token could be used for collateral, it could be used for reputation or sticking. It might be a stable coin. So I mentioned USDC. The decentralized version of a stable coin would be something like die, which we’ll talk about in great detail in the third course. So all stable coins are utility tokens in terms of decentralized finance. And it’s also possible that it is being used to pay fees for a particular application. So all these are just examples of what utility tokens can actually be used for. So it’s kind of interesting I guess the last example I want to spend a little bit of time on in terms of the stable coin utility a coin. So stable coins there’s many different types of stable coins and we will go into some detail on this. There are physically collateralized stable coins like USDC. So there are dollars that are sits in some vault somewhere. There are crypto collateralized like die. So would die it’s over collateralized with either or any a list of ERC 20 compliant tokens or it could even be algorithmic, okay? So the idea here is that there’s different ways to think about the value. So for something like USDC. You rely upon institutions that are centralist like coin base the guarantees that the USDC is worth $1. But there’s other methods. So for the crypto collateralized you rely upon a transparent system where you can see that the currency is backed by collateral and anybody can see it at any time. And it is backed by more than enough collateral. And if that collateralization ratio gets too low then that might impact the value. It might impact the peg to the stable coin. So it’s a big incentive to keep that collateralization high. So again there’s a different approach. One is more centralized than the other and we’ll have much more to say about this. So the third type of token is a governance token. So this is the third type of fungible token. So and I want to distinguished because it is a little confusing because we think in in terms of centralist finance. So you buy some shares of IBM and we call that equity. And actually you have voting rights at the annual general meeting or for special resolutions. So that is both a share of the equity of IBM as well as governance. So in decentralized finance, the equity tokens are basically representing the share of the assets in the pool or in the smart contract. There is another level of governance of that smart contract. So the protocol might have a governance token and those that own the token are able to vote on changes. Some parameters might be variable in that smart contract, okay? So for example, we’ll talk about collateralization. So if your collateralizing a stable coin with a very risky and volatile cryptocurrency, then you have to have more than 100% collateral. And you can imagine that if that cryptocurrency became even more volatile, then what we want to do is to increase the collateralization ratio. And that’s the sort of thing that the governance would vote on, okay? So basically these contracts often have again, completely transparent certain parameters that can be changed by governance. And again, I want to loop back to a very interesting aspect of this, that if the governance change is one of those parameters and that led to people having a bad experience and what’s going to happen? Well, if the basic idea was good, somebody is going to grab the code which is completely open source and change the parameter back or have a different system implemented so that they attract the people that left the old platform, okay? So you need to be really careful in terms of the governance that you don’t do something that causes your protocol to lose value. So the incentives are exactly aligned. So governance tokens are very important. And let me mention another item that’s really important. Often when a new idea is launched, the developers know that there’s going to need to be a certain number of changes that potentially need to happen very quickly. So basically there’ll be some bumps in the road. So often the developers are debs, will retain like the majority control of the governance token, okay? So this has happened with the number of popular protocols but and this is important. They say that will retain control in the short term. But we’ve got a schedule whereby we will go and essentially make this truly decentralized and that means that the developers lose their majority control. And this is again happened with a number of important defy protocols. And indeed it’s very interesting that and some of them the governance tokens were just distributed so called air dropped to those that were using the protocol. So if you’re using it in terms of putting liquidity into the protocol, then you’ve got a reward of the government’s token. If you’re using it to borrow then you’re going to reward, okay? So the governance token essentially was used as an incentive, okay? But this idea again you’re really only truly decentralized finance if you are decentralized, which means that there’s no one group that has control. But again think of the short term and the long term. So again there’s many different ways to implement governance token. So it might be that there is a fixed supply. And then when that supply runs out that’s it’s also possible to have a governance token that has got some sort of inflationary rule. So the token can the total number of token can increase. So maker, which we’ll talk about and that’s the governance token for die. That has got a static supply a comp which is the government’s token for compound that has got an inflationary supply and again they use it as an incentive. So to use the platform and think about this that if you deposit your money into a liquidity pool you get some sort of interest rate a savings rate. But you’re also being rewarded with the governance token which makes the rate of return even higher. Or think about borrowing so you’re paying a rate on the loan which is most of the time far less than let’s say a bank loan but you’re also being paid the governance token. It’s basically it’s an incentive to do what you’re doing. So that reduces the effective rate that you’re paying on the loan even more. So very powerful idea.

02_non-fungible-tokens.en

Okay so next let’s talk about non-fungible tokens. So we’ve talked about the ERC-20 and how it could be an equity token, it could be a governance token, it could be a utility token. So NFTS are different. So they are created via Ethereum’s protocol. It’s called an ERC-721, rather than the ERC-20, and this is the non-fungible token standard. So the difference between a fungible and non-fungible token is that every token is different. Okay, so it’s not the case that any two NFTs are equal in value. And you don’t do the addition sort of thing that we do in fungible tokens either. Everything is unique, a unique ID. And interestingly, when they first came out people talked about NFTs as deeds and I think that’s a good intuition. So think of it as a deed that essentially gives you ownership of something that’s very specific. So you think of a deed to a house for example, well that’s very specific to the house. So one deed for one house is not necessarily equal to a deed for another house. So more generally, it could be a bond or a loan contract or something like that that has got a unique ID and a token associated with it. So remember I’m very much of the opinion that everything will be tokenized in the future. So some things it kind of makes sense to use an ERC. So for example gold. So if you’ve got a token that represents one gram of gold, then it needs to be fungible. So two tokens, both of them representing one gram of gold should have equal value. However, there’s many other applications where the asset is unique, and it might be as simple as a lottery. So it doesn’t make any sense to have lottery tickets that are ERC-20, because everything is the same. How can you figure out the winner? But if you had ERC-721 then one is drawn. So idea of lottery, I’m not sure I talked about it in the course but I should. You can run a fair lottery in terms of decentralized finance. Today if you put all of the lottery tickets you’re guaranteed to win, but when you win maybe you get 50% of your money back. So the expected rate of return on a lottery is basically -50% on a traditional lottery. And we know that the money supposedly goes to good cause many times, but that’s beside the point. The point is, within this system we can run a fair lottery where the money is put into a smart contract, there’s one winner that’s drawn by random and all of that money is transferred to the winner. So again this is a good example of an NFT application. However, in the news there’s many other uses and indeed NFTs can represent collectibles, so it’s not just deeds. So deeds are important in finance. As I said a loan contract is like a deed but it could be something that’s collectible, for example, ownership of a piece of art. So in the first course I actually mentioned art also and in a different application. So it might be that you’ve got some art and then you issue ERC-20 tokens where many people can own a piece of that art and potentially for investment purposes. So you think the art is going to go up in value. So you can’t afford the fine art on your own, but you can’t afford a share, and this would be like an equity share of that art. So for NFT it’s different. So in NFT you actually would own the art, ao one owner of the ERC-20. And indeed people made a lot of press where basically one piece of art, the NFT sold for 69.3 million. But it’s not just this, so there are so many other applications of NFT. So people are selling NFT on certain video clips, it could be Music, it could be even a tweet that’s sold as an NFT. So anything collectible is a possibility here. Indeed I believe that a very interesting application of all of this is in the gaming world, and there’s a lot of untapped value, and a lot of people that are using games or that are gamers are very sophisticated also in terms of technology and it just seems a natural area to go. There is also something called ERC-1155. So one thing with the ERC-20 and the 721 they require an individual contract to be deployed on a blockchain. So if you’ve got many tokens this can be cumbersome, and ERC-1155 allows you to have a mixture of fungible and non-fungible token types. So this is important also for another reason and that is that there is a possibility of a multi-token model. So this is going to be important a little later on where we’re thinking of investment, and investment pools, and liquidity pools, and this innovation is a good innovation.

02_supply-and-ownership

01_custody-and-supply-adjustment

01_custody.en

The second module, we’re going to explore supply in ownership. I’ll talk about custody, how we adjust supply and incentives. Let’s dig into it. Let’s start with custody. The first concept that’s of critical importance and DeFi is this idea of escrow. It is a basic primitive within decentralized finance so that we can actually put funds somewhere in escrow or essentially custody the funds directly in a smart contract. I guess so this is again different. We’re always thinking in terms of centralized finance. But you would have in centralized finance and escrow agent. It might be a bank that is basically holding your money and you need to trust that bank or that escrow agent. This completely different. This is the ability to escrow within a contract. Basically there is an approval, it goes into the pool and you retain your share of that pool. You’ve got an equity token think of that in terms of your share. This is an important concept that we’ll talk about, a fair bit in the course. This ability to escrow opens up so many possibilities. It gives the possibility of, we can retain fees within the contract, we can disperse incentives, we can facilitate token swaps. Again, think of this as you’ve got a contract that’s got something in it already and you’re swapping within that contract. We will talk in some detail today and in this course about bonding curves and what that actually means. We can do collateralized loans, we can run auctions, we can even do insurance. Custody in terms of escrow, opens up so many possibilities. It’s also the case that you need to be careful. If you put your money at the bank, if the bank fails and if it’s not too much money, the government will essentially bail you out. It’s called deposit insurance. If you’re above the amount that they covered, then you’re a loser. There’s nothing like that in the world of DeFi. There is a growing interest in the equivalent of deposit insurance called DeFi insurance, but that’s really early on. Remember, we’re at less than 1 percent into this disruption. You need to be careful that you don’t send your escrow to a contract where you can’t get it out. The contract needs to have mechanism for you to actually release the funds. This is under the heading of smart contract risk, which we explore in considerable detail in the fourth course. DeFi risks and opportunities.

02_supply-adjustment.en

The second subpart is supply adjustment. This is very important also to understand. Let’s get started. In the word cloud, you probably remember the word burn. We know what burning is, but what is burning in DeFi? Well, it’s simple. It’s reducing supply. You remove it from circulation. It’s actually similar to what actually happens with physical currency when it wears out. The worn dollar bills are actually burned and new ones are printed. There’s different ways to do burning. You could basically send the token to an unowned Ethereum address. That’s an address that nobody’s got the private key for. A better way to do it is to send to a contract that is incapable of actually spending the token. There’s no way to spend it, so it just sits there forever. I say it’s a better way because I mentioned the possibility in the future of potentially going the other way from a public key to a private key. The unowned address potentially in the future could become owned. It’s much better to send to a contract that is incapable of spending, and there’s no way to modify that contract. The contracts there. It’s got no mechanism to change the very important property of no spending and is there forever. In the Ethereum blockchain, it is immutable. Basically what happens here? Obviously, when you burn, that token does not become usable. Maybe it’s a little curious to think about. We understand in centralized finance why you do this. Well, the cash currency just gets worn out, it’s torn, tattered, and then we replace it. This is different. We’re just burning. What would you want to do that for? We’ll explore that. There’s also burning mistakes. It might be that you think you’re sending to somebody some Ethereum, but you sent to the wrong address. That address might be unowned, and that Ethereum is gone. That’s basically what I call a burning mistake, where you basically burned your own Ethereum. There are various different mechanisms to reduce the possibility that this happens. There’s the EIP-55 which you can look up. EIP is Ethereum improvement protocol number 55. It’s actually suggested by Vitalik, and it’s very elegant. It’s basically a checksum. When you put your address in that you’re sending to, there’ll be a check that’s run. It will flag most of the time if that address is invalid because it would not pass the checksum, and that means that the transaction fails. This happens before. Think of this as the checksum is done. If it fails, then there is no transaction. Remember, all transactions are atomic. If it fails, you resort to the original state like nothing has happened. This is something that Ethereum’s got, that Bitcoin’s got. Most cryptos have a checksum capability. Nevertheless, you can still make mistakes, and many have lost their token due to a mistake in burn. Why would we burn? It turns out it’s pretty simple. Think of an equity token. You represent, let’s say 10 percent of a pool. There’s a pool that has got 100 ether in it and you’ve actually contributed 10. You’ve got 10 percent of the ownership of that pool, and there’s a token that’s issued to you that basically represents 10 percent of that pool. Well, suppose you want to redeem the 10 ether. Well, no problem, you send in your token that’s worth 10 percent of the pool and 10 ether transferred to you and the token that you send is burned. You no longer own 10 percent of the pool, it’s gone, it’s burned. This is one application in terms of redemption of a pool. We talked about in this first course this change in the Ethereum that will likely happen where the base gas fee will be burned. Instead of going to the mining or the miners, the gas in ether will be burned and that will serve to reduce the inflation and ether and potentially make it more valuable. There’s other possibilities here. Burning is used and some protocols to increase value. The idea here is if there’s fewer tokens out there then the value should actually increase. Then another logical application is to penalize bad acting. You do something, you prove a transaction that was a bad transaction, then your stake will be at least in part burned. This is quite a common thing in terms of supply adjustment. Of course the other side is minting. Again, we think about minting in terms of centralized finance. It’s the same idea. That is that you’re going to increase the supply of tokens in circulation. In Bitcoin every 10 minutes there is some minting. That goes on until 2140 when there’s no more minting. DeFi protocols are much more general. Minting is different than burning and that there’s no right way to think about accidentally minting. You can accidentally burn by sending to the wrong address, but this is just not possible to do so the minting would be part of the actual smart contract, so you’d be able to see the rules. This is also very important. Even though the supply might not be fixed, like Bitcoin, you actually know it’s very transparent from the contract what the actual rules are in terms of the inflation. These rules can be directly encoded into the smart contract. Minting, we’ll talk about in another sense in that it could be very useful in terms of incentivizing a range of user behavior. There’s one thing that’s really different about DeFi, that you can start a new idea and then you can easily incent people to actually use your idea. Download the DAP and will give you a 100 of the token. Basically for something as simple as downloading an app, you’re paid directly. Then if you use the app, you get paid. This idea of minting for incentives is very important and it just makes it a lot easier to startup. Or is much more difficult to do this in just the regular world of traditional finance? Where the idea of paying somebody to download your app would literally have to go through the banking system and it would be a nightmare how to actually do that. On top of that, you’d have to raise a lot of money to actually pay people in dollars. Whereas a new protocol is minting their own coin. It’s really easy and there’s far fewer barriers to entry to come in and do something interesting. Again, there’s a number of examples here. I’ve already given you the key example of if you enter a pool there would be a minting of a token that is an equity token to represent your share. If you exit that pool, then that token when you send it to the contract would be burned. That is the most tangible idea of minting and burning and we’ll explore that in a number of applications in the course. Let me return to this idea of how minting can actually lead to another type of incentive mechanism. Minting is again very common in the world of DeFi. Indeed, there is essentially a competition amongst the DeFi apps. Everybody is basically looking for the best app to use. One thing you would look for is the best possible rate for savings, for example, and that might be an interest rate plus an incentive. There’s a competitive market whereby these incentives change to try to attract users to the particular protocol. We mentioned briefly in the first course this idea of yield farming. This is basically a situation where you engage in actions to get the highest possible of reward. You’ve got money in a liquidity pool that’s earning some savings rate. You have a utility token. Then you deploy that utility token because this is valuable. It’s basically representing, let’s say 10 percent of that pool. You can deploy that to another DeFi protocol and earn another level of interest. The very popular thing today, you do need to be careful because some of these protocols are riskier than others and some people are being taken advantage of. But nevertheless, this is one advantage of having a mechanism like this where you can very easily mint an equity token and then just redeploy it. It is ERC20, which means it could be redeployed in another context. Next, we need to talk about bonding curves. A bonding curve is basically an algorithmic representation of a pricing relationship. You can buy off the curve and sell to the curve. This is just a mathematical function, and I’m going to go through plenty of examples. This is important stuff in terms of how supply actually works. Let’s start with a very simple bonding curve, and it’s going to be a linear curve. Again, we’ll use our hypothetical token, TKN, or token. That is going to denominate a price or token that is denominated in ether. It could be any Anethum, I’m just choosing ether for a simple example. S is going to represent the supply. The simplest bonding curve would be token equals 1 or any constant. This means that the value of token is pegged to ethereum, one for one. It’s very, very simple. Idea is that algorithmically said that token represents one Ethereum. If you had Ethereum in this pool with this rule, if you send one token, then you get one Ether and vice versa. Very simple. It’s not a very good one. It’s not a great rule because you can imagine that in some other market, and we’ll talk about these other markets, in some other market that the value of token goes actually well below the price of Ether. What people would do is just go to some other market, let’s say Coinbase, buy token, and then exchange the token which they bought for, let’s say half an Ether for a full Ether. So it’s not a great model at all. Let’s do this a little more generally to a linear bonding curve. A linear bonding curve, a linear equation has got a slope and an intercept. The slope is m and the intercept is b. Let’s consider a very simple linear bonding curve where the slope is one and the intercept is zero. Again, this is a function of the supply, so it’s one times a supply. The first token would cost you one Ether. The second one would cost you two, the third one, three. This is a very simple linear bonding curve and it is constructed in a way that the people that are buying token early on are getting a really good deal. If you’re the first in, you’re only paying one Ether but if you’re the third one in, you’re paying three. It is a way to incent people to get in early. This is an example of a linear bonding curve with the equation that I suggested. Here, Alice is going to buy five token. We already went through the cost of the first and the second and the third, but if we just add it up, the five tokens are going to cost 1, 2, 3, 4, 5 and the total amount that Alice is going to pay is 15. Alice is the first one in, and Carol is the second one, and then Carol is going to buy five token. The cost for Carol, that sixth token is going to cost six, and then 7, 8, 9, 10. To get the next five, it’s going to cost 40 Ether. Now, suppose that Alice, as the first one in, decides to sell. After Carol buys and there’s a total of 10 outstanding, then Alice decides to sell her five token. The revenue that she’s going to get off the sale is 10, 9, 8, 7, and 6, a total of 40. Think about what’s happened to Alice as she is the first one in. She actually paid 15 for the five and was able to sell. Again, this is completely algorithmic, so there’s no broker or anything like that here. It’s completely algorithmic. The revenue from the sale is 40, and what she paid was 15. Given that she was the early investor, she actually makes a profit here of 25 Ether. This is just an example of a linear bonding curve. Just to be clear here, this is a smart contract. This isn’t trading with a broker. This isn’t trading on Coinbase. We’re essentially doing an exchange here, so buying a token. We’re actually swapping. We’re swapping Ethereum for the token and the token for Ether. This is basically an example of decentralized exchange. This is again, a very significant innovation because we’re actually doing this without a broker, without a middle person at all. This is a very simple bonding curve. Essentially what’s happening here as traders or users are purchasing the token, the binding curve is escrowing the funding. When Alice and Carol were buying the contract, is escrowing the Ether. Then that Ether is deployed to actually pay back a little later on. This is a powerful contract and idea in general. We could actually think of a different way of doing this. We’ve looked at a linear curve. We could do it like a super linear curve or non-linear curve. This is a quadratic curve. Let’s go through the mechanics of this. In this particular equation, we’ve got, instead of the equation that we had with the intercept of zero and a slope of one, times S, now we’ve got again no intercept, but M is also one, but S is squared. You can see the dynamics. For example, Alice buys two token. This is minting. Two token are actually created. What is the cost? The first one is one, the second one is four. Two squared is four. The total cost for Alice is five. Then Carol jumps in and she wants to buy another two token. Into the contract, Carol puts nine for the third and 16 for the fourth. Total cost at 25 Ether, and the contract prints two token. Now the total supply is four token. Now, just like the previous example, Alice decides to sell her two token. This would be burning. Those two token go back to the contract. The two Token are destroyed and Alice is able to essentially come up with the revenue and that burning. The revenue essentially is going to be 16. That’s the fourth token. Then nine is the third, so total of 25. The profit for the early buyer, which is Alice, is going to be that revenue from selling, which is 25 minus the initial cost, which is five, so the total profit is 20. Of course. I’ve shown you two really simple examples, and this is a much more general idea. This is an example of a logistic curve. The idea here is that there are strong incentives early on. Early on it looks superlinear. You want to get in early because the price is really cheap in terms of token. However, the curve flattens out at some point. That’s what a logistic or sigmoid bonding curve actually looks like. It’s much more common to have a function like this where essentially a lot happens within a narrow range, but the same idea applies as the previous examples. It’s also possible to have a different bonding curve for buying and selling. Again, this is very general, is just an algorithm within a contract. If it happens like this, there’s actually a spread. Where does that spread go? Spread is kept by the contract. It basically adds to the escrow. As many different possibilities in terms of using these bonding curves.

02_incentives

01_incentives.en

I’ve talked about incentives somewhat, but I want to go into a little more detail because incentives are so important for decentralized finance. There are two general types of incentive. One is called a staked incentive. Think of this as you’re staking or contributing liquidity to a pool. You get an incentive for actually doing that. Very analogous to some reward for providing liquidity. Then there are direct incentives. This applies to users within the system that might not be having an escrow balance, so to get people to actually use the system. These are the two general categories. A staking reward, again, is something where you put some money into a pool and you receive a bonus, think of it that way, based upon the stake that you’ve actually got in the system. There’s various different ways to implement this. You might need a minimum balance to actually receive some reward. The reward might be a fixed payout, it might be pro-rata payout. It might be that the staking reward is the same token as the liquidity pole, or it might be a different token. It might be a governance token. There’s many different ways to actually do this in the DeFi world. An example of a firm that is a leading firm that we talk about in considerable detail in the third course, a DeFi deep dive, is compound, so compound protocol is a leading protocol. They have rewards based upon their COMP token. Essentially, the COMP token is going to fix supply. There is a reward for stake balances on a pro-rata basis. Synthetics, which we also talk about in DeFi, a deep dive, they’ve got a SNX token. In contrast, the COMP has got technically unlimited supply. The rewards are paid out as inflation on the token, and it has got a minimum threshold requirement. There’s many different ways to actually do these incentives. We explore these in much more detail in DeFi deep dive. The other side is slashing. Slashing is the removal of a portion of the staked balance. It might be that that occurs as a result of some undesirable event, and that might be you violate your collateralization ratio, something like that. Then there would be some slashing. The slashing condition, so again, think of the word cloud that I showed you at the beginning and the end of the first course. This is something that is up there. Slashing, again, we know what it means, but within the world of DeFi, a slashing condition is a mechanism that triggers a slashing. There’s many different ways to do slashing. There could be a complete slash, which means that everything that you’ve got is gone, or it could be a partial slash. For example, if you fell below a collateralization ratio, I’ve got plenty of examples on this, then it could be a partial slash. There are many different conditions that would trigger a slash. I’ve mentioned undercollateralization, but there could be malicious behavior or basically changes in market conditions in terms of volatility or price movements that are basically the causal influence in terms of the slashing of potential not just one user, but many user’s balances. So we will talk about collateralization a lot, especially in the third course. But let me give a tangible example here about what I mean here. So if you’ve got a situation where you are borrowing and you are essentially over collateralized, so the collateral is crypto, crypto is volatile, so it has to be that you put up more collateral than you’re actually borrowing. Why would you do that? Well, you need some money, but you don’t want to sell the crypto. You think it’s going to go up in value, right? This is just like a mortgage. With a mortgage, your house is worth far more than the mortgage. So it’s kind of the same idea. But there’s a mechanism whereby if you drop below your collateralization ratio, so if you had to pledge a 150 percent of your loan and the collateral, but the value of the collateral drops below that, then there’s a mechanism to liquidate your loan. Okay? Basically there would be a slashing that’s involved when that actually happens. There will be somebody that actually does that, called the keeper, which we mentioned in the first course, and there’d be a fee that actually goes to that keeper. So slashing happens. It’s not necessarily a result of doing something nefarious. It’s just part of how the system works. So direct rewards, and again, keepers, we’ve talked about already. So direct and more rewards are incentives to basically have the protocol work as it should. You want people involved. If nobody is involved, then it really isn’t working. You want all of the rules followed very carefully, like the collateralization, and you need some help in doing that. This is important that the triggering of a liquidation due to undercollateralization, that doesn’t happen within the smart contract. That happens externally. So it’s initiated from an externally owned address and a keeper would actually do that. So people are using algorithms to check to see if there’s something does undercollateralized and soon as they see that they liquidate and collect their fee. It happens quickly, but everything is initiated from an externally owned contract. Nothing happens automatically here. But once it is triggered by an externally owned account, it happens very quickly and very efficiently. There is a number of applications here in terms of what keepers actually do to rewards that they get, and again, this is all triggered externally. So what about these keepers? We’ve talked about them a little bit. The keeper can receive a reward in many different ways. It could be a flat fee for doing the job. It could be a percentage of the actual action. It just completely depends upon how the protocol has actually developed. Okay, so it’s also possible that there’s literally like an auction where the keepers are bidding on the work. So it’s very market-based and very competitive. Again, it’s all incentive compatible because this basically keeps the system running as it should be running. We reward people, we effectively pay people to maintain the system, and those are called the keepers. There’s some downside, of course. If gas prices are really high, then it might not make sense for the keeper to actually do the work for smaller balances. That poses some risk. As the gas fee is reduced, as I believe it will be reduced, then the system becomes more and more efficient. This is a very important distinction here. That high gas fee actually discourages the type of behavior that makes the system efficient. It is important that that fee is reduced so even if it’s a small balance and it’s under collateralized, it’s taken care of and if the gas fee is too high, then it isn’t. There are some downside. You think about fees, these are basically funding mechanisms. Again, they can be flat or percentage based and basically, this is a way, for example, for stake balance, you get rewarded for directly. It’s an incentive to actually provide liquidity. One thing that is important here is that the fees are multi-dimensional. We talk about a concept like fees, but fees mean many different things. One thing to take into account is that, well, Ethereum and Bitcoin are not really anonymous protocols, they’re pretty close to it so you actually don’t know who is getting the fee. Basically, this is a bit of a challenge in terms of how this operates. The contract is open to anybody. Given that there’s algorithmic on the Ethereum blockchain, everything has to be backed by collateral at this point. There’s no credit, so to speak, that’s uncollateralized with the exception of flash loans, but we’ll talk about later. Again, we use these systems in terms of fees, penalties also to enforce the proper behavior to incent people on an economic basis. We don’t have other mechanisms. We don’t have the mechanisms of centralized finance in terms of reputation and things like that in the same way in decentralized finance. Again, it is a challenge, it is a new space and I expect that there are challenges. Again, this is important for us to understand that this space allows us to do things very quickly and easily to incent and to punish without the rule of law or lawsuits and lawyers and things like that. It’s algorithmic. There’s so many choices in terms of the way that you actually do it, but the key thing is that given the transparency of the smart contract, you get to see everything. It’s there, you know the rules of the game. It’s clear. If you go below the collateralization ratio, there’ll be some slash, there will liquidation, you get something back, but not everything. It’s codified. There’s no dispute. It’s there. There is no last minute changing of the rules because the rules are encoded in an algorithm.

03_loans-and-swaps

01_swaps

01_centralized-exchange.en

The third module has to do with swaps and loans. A swap is just an exchange of one token for another token. We’ll talk about collateralized loans, which we’ve already talked about a little bit. Then my favorite, the flash loans, which I’ve mentioned a number of times and it must be a little mysterious to you, but we’ll cover it in this module as the third part. Let’s, start with swaps and begin with centralized exchange. This is a course in the centralized finance. But nevertheless, there’s a lot of stuff going on and centralized finance that we need to be aware of. When I talk about centralized exchange, I’m talking about centralized exchange of decentralized tokens. The so-called CeDeFi, C-E-D-E-F-I. Swap. What is a swap? Basically an exchange, one token for another. There’s many different ways to do this. But the most popular today to do this is with a centralized exchange, for example, Coinbase or Coinbase Pro. There’s many other exchanges. There’s hundreds of exchanges. What’s interesting with these centralized exchanges and contrast to the usual centralized exchange, where the New York Stock Exchange you decide to list on that exchange, that’s where you would trade IBM, for example. But within this world of decentralized tokens, the same token can be traded on hundreds of different exchanges. Again, one option is centralized and this is just an example of some of the more popular tokens, and this is just the regular Coinbase screen that you could actually buy using Coinbase. But for those that are trading, you would use something like Coinbase Pro. Coinbase is a US fully regulated exchange. Indeed Coinbase is a public company now, so stock is traded and exchanged on centralized exchange for Coinbase. This is what it actually looks like in terms of Coinbase Pro. You can see on the far right, you’ve got the previous transactions, and then you’ve got basically the bed and the mass. There are people that are willing to buy and those are in green on the left and obviously want to buy at a low price. This actually shows all of the different amounts that people are willing to buy at the cheapest price. Then on the right, those that are willing to sell and they want a higher price. That’s why they’re on the right-hand side and in red, and then there’s a matching in the middle and there’s often a spread between the two. The exchange actually makes money. The centralized exchange makes money in that they earn a spread. There’s also a trading fee that they would earn and that depends upon the particular exchange. But this is just an example of centralized exchange. One issue here is that there’s so many exchanges that you need to be careful. Many of you will join the world of DeFi. You will potentially use decentralized exchange as we will go through in the stores. But many of you will also use a centralized exchange to deal with the DeFi. One issue is that there could be a much different price for a crypto depending upon the exchange that you actually look at. This is a screenshot from last year where you could see a very large difference between different exchanges for buying, let’s say Bitcoin. Again, this is something that is different than what we’re used to because if you go to the NYSE, there’s one price for a share of IBM. Here we’ve got hundreds of prices. There are many incentives for some of these centralized exchanges to exaggerate volume. If they seem like they’re big, then people will basically think, well this is a popular exchange, I should go there. They might attract initial coin offerings or initial exchange offerings, and the more business you do, the more money that you would actually make. It turns out that you need to be aware because on most of these exchanges the volume is fake. It turns out it’s really easy to fake volume in the space. Indeed, think of it as, and I’ve already mentioned this, that I could easily transfer my coin from one wallet to another wallet that I own, and then go back and forth and back and forth, I still have the same amount of token, but I’ve created a lot of volume. You need to be aware, and there certain things that you should look for. This is just the same shot that I showed you before with the previous traits on the right. We’ve got the order book. That is the amounts and the prices that people are willing to buy and sell at. That graph in the middle, where the green and the red meet, that is where the trading actually takes place. What are we looking for in terms of an exchange that’s a real exchange? Well, an obvious thing is if you use something that’s fully regulated by the US government, the odds are that it is not a fake exchange. I think that’s fairly clear, but there’s various things that you can look for. I will actually go through some slides to show you some red flags in terms of what the order book looks like, what the spreads look like, simple things like round numbers. For example, people put orders in for, let’s say one ether, two ether. It’s unusual you put an order in to buy like 2.05647 ether. Again, there’s some basic things that you can do in terms of forensics to figure out if an exchange is real or not. There’s again, many different things that you could look at in terms of what did the previous trades look like, what is the correlation amongst the changes that you’ve got a strong prior belief are real exchanges. I’ve already mentioned the round numbers. The history, again, is going to be really important in terms of, what does the trading volume look like? We’ll take a look at that and forensics and what about some examples here. This is an example of an exchange that is likely a fake exchange. If you look at the actual trades, you can see that they’re almost immediately offsetting, because it’s a buy and a sell of the same amount and just keeps on going like that, and it doesn’t make any sense. The spread on this exchange is way higher than an exchange like Coinbase. This is an interesting one because this exchange claims to have five times the volume of Coinbase Pro or even more. But when you actually look at the history, it looks very suspicious. This is another exchange, and notice that the trading only occurs during a certain period and that doesn’t make any sense. Again, this is the hours of zero trading, that’s got to be a red flag. You can compare that to other exchanges where it doesn’t look like that. Again, this is another exchange, it’s got roughly the same volume as Coinbase Pro. The volume is constant, which doesn’t make any sense. Volume does have some seasonality within the day or the week, but this is all basically the same volume. You look at that and you’d say, no, this can’t be real. It’s likely fake. Trade sizes. On the top, it looks very reasonable. Notice that most of the volume is with a smaller numbers, so smaller trades, which is exactly what we’d expect. The volume should be greater for smaller trades, and then for the bigger trades, it gets lower. Now, notice those spikes on the top two where we’ve got Coinbase and Kraken. Well, those spikes are things like 1, 2, 3, so they’re round numbers. Then the two exchanges on the bottom, which have very large volume, it looks completely different. Again, you need to be careful here that these are red flags, that this volume just doesn’t make any sense. The top two are very intuitive of good economic foundation, the bottom doesn’t make any sense. This is just volume over an extended period of time. Notice the top two are actually pretty correlated. If you’re looking at the correlation of the volume, it make sense. Then look at the bottom two, it doesn’t make any sense. It has no correlation with the exchanges like Kraken or Coinbase or whoever you want to look at. There’s essentially no correlation. Then the spreads. If you look at the spreads here on the top, you’ve got a couple of exchanges that seem quite reasonable in terms of the spreads. It does vary through time. But then look at the bottom two. The one on the left at the bottom especially, just doesn’t make any sense. Notice where I’m pointing to like the zero is. Basically these are volatile high spreads that don’t make any sense. It’s pretty easy to do the forensics here, so you don’t need to hire a forensics firm to identify a problem. Some people have estimated that if you look at the total volume of trading that’s reported in the world across all these exchanges, that less than five percent of the volume is real. Again, this is something to be aware of. This is a way to get people to use your centralized exchange. Running an exchange is incredibly profitable. We saw from the IPO of Coinbase that this is extremely profitable business. I want to emphasize again that this is centralized finance. What these exchanges like Coinbase or Kraken, they’re buynets. They’re no different than the exchange like the New York Stock Exchange or Nasdaq. It’s the same basic mechanism. The same screens you’ve seen, the same structure of an auto book is available. They are profitable. What does that mean when they’re profitable? Well, they’re making money because you as a user are basically paying them. Some of the value, your value, is being transferred to the centralized exchange. It’s really important here to put that in context and this is the reason that I’m going through the centralized exchanges to put into context what decentralized exchange actually does. Decentralized exchange is going to be different because we’re not trading with the broker, we’re trading with an algorithm, and the algorithm doesn’t care if you’re buying or selling.

02_decentralized-exchange.en

Now, let’s talk about decentralized exchange. It’s all under the category of Swap, which is basically exchange, swap one token for another token. Basically, what we’re going to do in DeFi is something atomic. Within a decentralized exchange, it will be atomic and that if there’s a problem with the transaction, then we revert to the original state. There’s nothing that can happen. The middle person, for example, a centralized exchange might actually cause some issues. We’ve certainly seen issues where centralized exchanges basically had to say, no, you can’t trade. This happened with Robin Hood recently. We’re given the volume that they experienced. They said that you can’t sell. This is something that doesn’t happen in decentralized finance. That happens in centralized finance. Again, we’ve got the use of smart contracts, the custody funds for what we actually want to do in the swap. Again, when we do an exchange, it is only going to execute if everything, all the conditions are met in the transaction. You could even put the equivalent of a limit order into the actual transaction that if the price is above X, then I’m not going to buy and that is straightforward to do and the contract, again, would recognize as and the transaction basically reverse the original state, which means you’re not buying anything. When we talk about decentralized exchange, we will use the word DEX, so D-E-X. That’s the lingo. That’s on the Word Cloud and decentralized exchange. As I said, is that you’re basically dealing with an algorithm, a smart contract. There is no other mechanism. We’ll talk about two different categories of how this works. The first category is order matching and the second one is an automated market maker. We’ll spend a fair bit of time on the automated market maker, not as much time on the order matching, which today is awkward to do. Let me tell you why. Order matching, it’s what we saw with the Coinbase screen, where you’ve got certain people that are willing to sell at certain prices and certain people willing to buy at certain prices and then there is some middle portion where there is a match. This is possible to do in decentralized exchange. Effectively, these are basically think of them as if the price gets to X, then I’m willing to sell or buy. This is like a reasonable thing to actually have within potential contract. Kyber is an example of this. It’s very interesting if you go to their Platform. Usual way that it happens is that let’s say I want to use Coinbase to buy device in Ethereum. I just have set up my account. With Coinbase, you need to actually transfer some dollars to Coinbase to get started. I don’t have any crypto, but I want to buy some Ethereum. I need to link my bank account to Coinbase and the transfer takes 2-3 days. Then I would have a dollar balance at Coinbase, and then I could use that dollar balance to buy, let’s say some Ethereum. The Ethereum would be held by Coinbase, so Coinbase would have the private keys. I could at some point repatriate the Ethereum and they would give me the private keys. But most people just have Coinbase custody at the keys. With Kyber, it’s very interesting because there’s no transfer of dollars or anything like that, you just link your MetaMask wallet for example, which we’ll set up in Module 4 of this course and you’re ready to go immediately. My MetaMask wallet might have USDC in it, so US dollar equivalent, but you’re ready to go. There’s no sense of transferring. Again, this is just one of the protocols that is basically on chain and that is one of the disadvantages right now, because doing stuff on chain is expensive. To have a transaction on chain that is necessary, but to have all of these potential transactions on chain that could be really expensive to pull off in terms of the current gas fees. This is again, exactly what it looks like, similar to the Coinbase screen. But this is what Kyber actually offers. But again, this is a good idea right now, given the cost of doing things on chain, other firms have got some off chain solutions, but if you go off chain, there’s issues involved with that also. Again, this is expensive to do with the current technology. In the future, this could be much more viable. But in my opinion, probably the automated market-makers have got some advantage here. That’s what we’re going to do next.

03_automated-market-makers.en

Okay, so now let’s talk about Automated Market Makers. They are very important feature of the DeFi landscape. This is a smart contract, and it deals with both sides of a trading pair. It quotes prices automatically and executes within the contract according to a rule. The rule could be simple, and we’ll talk about a very simple constant product rule to start with or it could be much more elaborate. This is something that you could use to buy or sell at any point in time. This is constantly operational. The Automated Market Maker doesn’t really care if you’re buying or selling, it’s just an algorithm. Let’s talk about Automatic Market Makers, and I’ll go through various different levels of complexity. One would be a fixed price ratio between two assets. This is very, I call it naive, and the reason is that if you have a fixed price, and we talked about this a little earlier, where we had just a fixed price between token and ether that, if it was the case that there was a decrease in the value of token in other markets, then token basically would be bought in another market and then deployed to the Automated Market Maker and all of the Ethereum would be drained from the contract. People effectively buying token cheap and then using that cheap token to get Ethereum. That is pretty naive because it’s going to lead to the drain of the actual contract. The contract would have token in it, it would have Ethereum in it, and in the end, it would just have token in it. There’s usually a pricing function that’s used, and we’ll go through a number of examples of pricing functions. Again, this is, I think a beautiful idea and that it is a technology that time is irrelevant. It doesn’t matter when you want to trade. This is really important for DeFi protocols in general. For DeFi to work, it can’t work on a 9:00 to 5:00 basis. It needs to work 24/7. All these contracts. Think of all these contracts that are interacting, and the decentralized exchange is just another example of a contract that we can interact with. It is interesting also, you don’t have to give up custody of your funds. I would be transferring money to Coinbase, wait three days and then the transaction actually takes place. In this situation, I hold the funds until the transaction actually occurs, and is very, very efficient. Again, there’s another idea here that’s important, and this idea that I’ve mentioned a few times of composable liquidity. We will be taking liquidity like I gave this example of token and ether and actually working with that. We’re able to create these trading systems, whereby we take these different tokens that are available on the Ethereum blockchain and easily put them together. This is like a fundamental component of the idea of DeFi Legos. There’s advantages, obviously. The trade against the algorithm is great 24/7 is great, but it’s important, and especially in these courses, I emphasize the downsides also. What are the risks here? One risk is the idea of impermanent loss. Again, another word for the word cloud of the learning experience, the four courses, impermanent loss. This is the idea of Opportunity Cost, and I want to go through some examples because this is such an important concept. As prices deviate from the beginning when you seed a trading pool or a liquidity pool, there will be some impermanent loss or some opportunity lost. Let’s go through an example here. This is an example, we’ve got two tokens, token A and token B. They’re both worth the same, one Ether. We set up a pool that has got A and B in it. It turns out the automated market maker has an exchange rate of one-to-one. We’ve got 100 A in the contract and 100 B. Notice the value of A and B are identical in the contract, so the total value of all of the escrow in the contract is 200 Ether. That’s the starting point. Now, the world changes and it turns out that A and B both go up in value. That’s great news. A, doubles in value. Now, on the open market for trading, so this is outside of the automated market maker, it might be on Coinbase or Kraken or Binance that A doubles in value. Now to buy A, it costs two Ether. B also increases in value. It actually quadruples. It goes from one to four, and so all of this is very good news. The AMM has got an exchange rate of one-to-one. Let’s think about that. For a trader, they see the one-to-one and they go outside and buy A on the open market, which let’s say is Coinbase. Then exchange the A for B and drain all of the B under the contract. That’s basically what would happen here. This is interesting that we’ve got a contract that we’ve got 200 A and zero B. The B is gone, remember the B went up by four times. But given that it was offered at parity, then people buy the A in the open market and then send the A to the contract and withdraw all of the B. This is your ended, you provided liquidity and think of the value. In the end, you’ve got 200 A and the value of that is 400. What is impermanent loss? If you actually made money, you started out when you put the money in the pool, the value was 200 and now it’s 400. Well, that seems good. But the idea of impermanent loss is, what if you didn’t put the money in the pool? What if you just held the A and the B? Well, if you just held the A and the B, then the value is going to be much greater. Remember, you’ve got 200 A and the value is 400. This is basically doubling your money. You started with 200, you go to 400. Given that you did the pool. Now, consider the situation if you didn’t put the money in the pool, you just held your A and your B. Well, what happens there? We know that A has doubled in value, so it’s worth 200. We know that B has quadrupled in value, so it goes from a value of 100-400. If you did nothing, it would have been 600. The idea of the impermanent loss is, I put my money in the pool, and the end value was 400, but if I didn’t do anything, the value would have been 600. The impermanent loss here is 200. One thing that’s important, the price did deviate from par. This impermanent loss actually become smaller if the price of A increases and gets closer to the price of B. In this example, the impermanent loss is 200. This is an important concept of Opportunity Cost. This is a very simple example. We’re going to go through a Uniswap example in a few minutes that has a different mechanism, it’s not a one-to-one exchange. In any situation where you’ve got a one-to-one, this is a naive AMM, and if there’s any deviation from par, then the contract will be drained. That’s exactly what happened in this example, where all of the B is stripped out of the contract. Now I want to talk about something a little more general, and talk about impermanent loss with the Uniswap version 2, automated market maker. Actually version 3 exists today, it was recently released. But version 2 is still operational. I think it’s important to understand what’s going on with version 2 to fully appreciate version 3, which I deal with in some detail in the third course, the DeFi deep dive. Let’s start out. This is fairly simple. We’ve got market prices, one Ether equals 100 DAI. For the purpose of this course, I’m using simplified numbers. Obviously, the price of Ether is much more than 100 DAI, which is linked to a dollar, which is like $100. But I’m just going to keep it simple and assume the base point is one Ether is $100. Alicia is going to make a contribution to liquidity pool, the automated market maker, and she will put in one Ether and 100 DAI. Notice those are equal in value. She will earn a fee for providing liquidity. Again, an equal amount is deposited. Alicia is not the only one in the pool. Indeed, there are others. The total pool is got 10 Ether and 1,000 DAI. The total liquidity is calculated as the product of the total number of coins and the pairs, so 10 Ether times 1,000 equals 10,000. That’s what we’ll call the total liquidity. It seems a little strange to do the multiplication, but you’ll see that it becomes very useful. Alicia has got 10 percent of the pool, so 10 Ether, she’s contributed one, 1,000 DAI, she’s contributed 100. Let’s go with this. Now, suppose in the open market, the price of Ethereum goes up. It goes up from $100-400. Arbitrageurs see an opportunity. They see the automated market maker is offering one for one. There’s an incentive to go into the open market to buy DAI, and then deploy those DAI, send those DAI to the AMM and withdraw Ether and make a profit off of that. This is not going to be like the previous example. The previous example, all the Ethereum were drained from the contract, and I call that a naive AMM. This one is going to be different. It turns out that the arbitrageurs will do what they’re supposed to do; they will add DAI to the contract, they will withdraw Ethereum, but at a point they stop. The point that they stop is when there are five Ether left in the contract. The contract will end up with five ETH and 2,000 DAI because there’s a formula. The formula in the smart contract says that the product of the total supply must be 10,000. In this example, when we go to five ETH with 2,000 DAI, the product is 10,000. Notice that the ratio is exactly the market price, the 400 DAI for one ETH. Essentially, this automated market maker has adjusted to actually pick up on the market price. Here’s a little more detail, and this is what the constant product automated market maker looks like, where you multiply the supply of the DAI times the supply of the ETH, you get that 10,000, and that 10,000 is constant, and this is called a constant product automated market maker. Notice the first line here where we’ve got in the pool, what we start with, 10 ETH, I’ve got 1,000 DAI, product, 10,000. You can see the price of ETH in terms of DAI is 100. As DAI are contributed to the contract, the price changes. You can see that what happens is that the product remains 10,000 no matter what. You can see on the far right column that the price of ETH in terms of DAI increases until it gets to 400, which is the market price. This is where we stop, and again, the product of 5 times 2,000 is 10,000. This is how this particular automated market maker actually works. Let’s think about what Alicia is doing. She owns 10 percent of the pool and she withdraws all her funds from the pool. When she withdraws everything, she’s going to end up with a half of an ETH and 200 DAI. The US dollar value is 400, so that means the value of the ETH is 200, and then she’s got 200 DAI, which is 200. So the total value is 400. Her original investment was 200, so she’s doubled money, which is good, but let’s again think of the impermanent loss. If she didn’t put her funds, if she didn’t put her ETH and the DAI into this automated market maker, what would it be worth? Well, she had one ETH and that is worth $400, she had 100 DAI, that’s worth $100, so that’s 500. The impermanent loss here is 100, so 500 minus the 400. We’re simplifying here because we’re not accounting for any fees in this particular example, but you get the idea that this is a more sophisticated, automated market maker. There’s still impermanent loss that happens, and this is a disadvantage of this particular technology. For any shift in price, there will be some permanent loss. It is path-independent, so it doesn’t matter if there’s one trader or 100 traders. It’s completely irrelevant. The impermanent loss is calculated the same if there’s one or 100 different traders. It turns out that the most attractive pairs to have for AMM are pairs that have correlated prices, so you don’t see a lot of deviation , so-called mean-reverting pairs. You don’t get one token greatly deviating from the other token. For example, stablecoin pairs are very attractive for AMMs because the impermanent loss is really small.

02_collateralized-and-flash-loans

01_collateralized-loans.en

Now let’s talk about collateralized loans. I’ve mentioned these loans a number of times and I want to go into a little more detail. Collateralized loans are really important for decentralized finance. We will talk in some detail in the third course about the mechanics, in particular, how MakerDAO operates, but this is a really important building block for decentralized finance. Basically, we will talk about different types of loans, including a little later on, we’ll talk about a flash loan that has zero duration, and that’s a loan that doesn’t require collateral, which is interesting. The idea is that we don’t know who the users actually are and there’s no credit check. There’s got to be at this stage of DeFi, some collateral. It is possible to do and there are uncollateralized non-flash loan lending, but it involves another mechanism of chain where some trust actually is involved. Again, in the Ethereum world, everybody is up here and people don’t necessarily know who you are. Your credit score is not something that’s relevant, but your collateral actually is. There is something called foreclosure risk or the risk that a loan goes under collateralized. That will happen especially if you’ve got very volatile collateral. Then decentralized finance, you could have volatile collateral. If you use Ethereum, that is volatile. If you use USDC, that’s not volatile, but it’s not obvious why you would use the USDC. The collateral is going to be very important. If there is volatility and if there is a situation where there’s undercollateralization, then there will be liquidation. It is very important to maintain the integrity of the loan or whatever you’re creating, that you don’t violate the collateralization rules. We’ve already talked about the role of keepers to enforce this. They will trigger liquidation if something is undercollateralized. Liquidation is very straightforward, that happens, and the collateral is liquidated, potentially in an auction or directly sold on a decentralized exchange. The trigger is basically set by the governance, and as I mentioned earlier, this is not automatically done that a keeper is involved. This is a user that basically sees that there is a loan that’s undercollateralized and they go and foreclose it. They will get a reward for actually doing that. As I mentioned earlier, the reward varies across different protocols. It might be a straight fee, or it might be that the keeper gets to keep the residual, if there’s anything left over. There are penalties for liquidation, and if you’re undercollateralized, this is far different than centralized finance where you get a call from your broker saying, “Oh, well, you’re close to your margin, you need to put some more collateral in.” There’s nothing like that. There’s no broker calling you asking you to do this. You need to do this on your own, monitoring your particular situation. If more collateral needs to be posted, then you better do it or you’ll be liquidated. So this is an important part. It’s also interesting, and we’ll talk about this in detail in the third course, that the collateralization can actually back a token. This is what happens with DAI, this is what happens with other synthetic tokens. You can say that this token is worth X. To keep it worth X, we’ve got this collateral and it’s overcollateralized. People actually believe, well, it must be worth X because there’s lots of collateral there to keep it. Basically people have faith in it and the faith is based on data that it’s completely transparent. It’s not just talk. Talk is cheap. It’s the data. You can actually see what the collateralization is, exactly what it is. It’s possible that you can have this collateralization to back a token. We’ll talk about the Synthetix token, the Synth. We’ll talk about Yield Protocols, yToken, we’ll talk about, in some detail, MakerDAOs, DAI, and how that works. Remember DAI is a stable coin that’s collateralized by crypto, not by US dollar. How can they do that given that crypto is so volatile? Well, they do it with overcollateralization and they need to be really careful, because if the value of the collateral drops below the peg at a dollar, then people basically will no longer believe that the peg can be maintained. This is very important for that particular Protocal.

02_flash-loans.en

Okay, so now let’s talk about flash loans. I’ve mentioned them a number of times and this is something that’s very special in the DeFi space. So think about traditional finance. So, It’s really hard to think about a flash loan in traditional finance. So if you think about traditional finance, you’ve got a loan rate and the loan rate depends upon the riskiness of the party that is borrowing. It depends on the maturity of the loan. And the idea is the longer the loan, the higher the loan rate because over a longer period of time, it gives a higher chance that something bad might actually happen. And interest rates are generally higher at longer maturity. So the term structure or the yield curve usually slopes upward, so that’s how a traditional loan works. So the longer the duration of the loan, the higher the rate. So we’re going to talk about something that is much different. A zero-duration loan. So so how does that work? So the idea here is that the shorter the duration of the loan, the less risky the loan should be. So with lower risk, then the rate on the loan will be lower. So the flash loan is instantaneous. So it happens within the same transaction. And don’t confuse this with an overnight loan. Banks do overnight loans all the time because that’s overnight and a lot can happen overnight. So this is different, it happens within a single transaction. So this is important to understand in the context of what we’ve been talking about in terms of the atomic nature of these transactions. And how these transactions are actually structured, potentially using a complex transaction that’s got many steps that interact with many different smart contracts on the Ethereum blockchain. So one thing that is really interesting here is that we’ll start out with a loan, but if anything happens, so that if there’s any issue in the different steps at the beginning, we start with the loan. At the end of the transaction, we pay off that loan. If there’s anything that happens, we revert to the original state as if nothing has happened. So basically we can go and do a flash loan. Indeed, with no collateral because effectively there’s no risk because it’s being paid back immediately. And if there’s any problem that’s encountered in the transaction, It’s as if nothing happened, we revert to the original state. So again, this is a very interesting possibility. So let’s think about the risks there. There’s no counter party risk, And there’s no duration risk. So, and I’ve got plenty of examples on this, we’re going to take advantage of some arbitrage opportunity where you’re buying and selling. We take the loan to start things off, we’re going to be buying on one contract, selling on another contract and then paying off the loan and whatever is left over is going to be our profit. So this could be an arbitrage transaction, this could be somebody just re financing their loan at a cheaper rate. So there’s lots of possibilities here. And it also is something that speaks to the democracy of decentralized finance that this mechanism is available to anybody. I will show later on a transaction and we don’t know who it is. And it might be somebody of modest means, That takes over flash loan of the equivalent $200 million dollars and does a series of transactions and then pays it off. And makes a profit. So think about that in traditional finance, who’s going to be able to do that, a hedge fund? So this is a very, very powerful idea. So I don’t want to give the impression that there is no risk here in the total sense. There is no counter party risk, there’s no duration risk because this happens in a single transaction, but there’s always risk and the risk is a smart contract risk, which I’ll go into great detail in the fourth course in this learning experience.

04_joining-the-world-of-DeFi

01_metamask-wallet

01_metamask-wallet.en

In this fourth module, we’ll talk about joining the world of DeFi. I’ve got two components. Number one is to set up your wallet, and I’ll go through step-by-step how to do that. Then the second part, which is much more involved and longer, is to bring you up to speed with what I call the blockchain tech big picture. I will go through a list of different items that are important to understand within this space. For example, we’re going to show how to set up an address in Ethereum. But where does that address come from? It’s very important in this learning experience that you understand where stuff actually comes from, that’s my job, and we will go into considerable detail. Let’s start with the MetaMask wallet. This is something that is very easy to download, this is a wallet. What is a wallet? Well, a wallet is a place that you store your private keys. This is going to be a mechanism also whereby we can interact with the various different profile in decentralized finance. This is a very important starting point. I will go through how to do this on a mobile phone, but you could also do this on a desktop, so there are different ways to actually do this. Of course, you can have more than one version of this. Just like you can have two passes or two wallets, you can have two MetaMask wallets, I actually have two. Let’s go through, what we’re going to do. The first thing, go to the App Store or the Google Play Store and download, MetaMask. Click Get Started, Create new wallet, and you’re going to create a new account by putting in a password. You choose that, you don’t actually have to give information about you in detail. It’s not like establishing a bank account or a brokerage account where you’ve got to give a lot of private information, no, this is very straightforward to do. One important thing will be a secret backup phrase. You’ll be prompted to actually do that, and I highly recommend that you put that somewhere that is not on a computer. This is something that effectively somebody could use to essentially steal your private keys. That seed phrase is very important to keep that outside of the Internet in particular. You actually put that in and you’re going to see an interface, something like this and I’ll go through a few of these things. number 1, there’s a network and the default is Ethereum Main Network, sometimes called the Main Net. If you’re new to DeFi, you’re going to have zero balance. You just set this wallet up, there is nothing there. We’re going to talk not just about the main network, but we’re also going to talk about a test network called the Ropsten Test Network, and most of the stuff that we do in my course is based upon the test network. The test network is an identical copy of the real main net. Any contract that works on the test network must work on the main network. But it’s a great way to operate on the test net where the Ethereum has no value, and you can basically kick the tires, try to find bugs, and operate in this test net. The main network is where Ethereum, all of the smart contracts that are operational, the world that defy, exist mainly on Ethereum. I’ve emphasized that there are other blockchains that are available today that are operating decentralized finance apps, so that’s clear, but most of them are based upon Ethereum. That’s the network. Again, this test network is extremely useful in terms of what we do. I’d mentioned that I create a token in my course. Well, this token is created on the test network. The token creation code, that smart contract, could be deployed to the mainnet. But the advantage of the testnet is that there’s no gas or no fees, and everybody, as I’ll show you, can get Ether for free. On the testnet, it doesn’t have any value, but you can get it from a faucet, and that’s exactly what we’re going to do in setting you up. Number 2 that is in red, that is basically telling your account. That’s your Ethereum public address. We’ll talk about this in considerable detail in a few minutes where that actually comes from. Balance and just setting up this wallet. The balance here is zero but it might not be zero if you’ve actually put something into your MetaMask wallet. What we can do here is if we want to check the balance, we can do transfers, many different possibilities using this particular wallet. There’s also a possibility here that you’ve got some Ethereum in another wallet that you want to transfer to your MetaMask wallet. The app allows you to do this in a very straightforward way, so you can literally receive. The transaction history is also available in the wallet, and this is where you can see a pending transaction. When you do a transaction, it will be pending. Remember, we talked about the memory pool, so it’ll be pending until it’s approved and goes into the blockchain, which would be the testnet blockchain in this particular example if you’re using the Ropsten testnet. This is what it looks like in terms of an actual transaction. We need to get some test Ethereum into our wallet. You’ll see for any transaction, you’ve got the confirm or reject. You might type something in incorrectly, it would reject it, but if you want to do this, you would hit “Confirm.” It calculates the gas fees. Everything is within this particular wallet, so it’s very nice to do. The next thing is we need to get some test Ether. We’re going to open the MetaMask wallet. We’re going to switch to the testnet, and then basically click on the amount of Ether you have, which is zero, and then we’re going to click “Receive.” You’re going to copy your public address, that’s step number 5. Then we’re going to go to a website , so the faucet.ropsten.be. You’re going to paste your address in and basically send me some Ether. Don’t do this a lot. Do it for a modest amount. If you just keep on doing this, then you’re taking advantage of the system. Indeed, you might be blocked for a while, and you don’t need that much to start things off. Basically, you can close this up once you’re done. Then you can look at the status and will be used as Etherscan. Again, this system is completely transparent. Every single transaction in the entire history of Ethereum, is captured in Etherscan, both what is in the actual system and what is pending in the system. You can see, you can wait until it’s actually confirmed. Then when you go back to your wallet, you will see that your wallet has got these Test ETH in them. This is a great exercise to start things off, to get in to the world of ETH. If you’ve got a friend that’s interested, they should do the same thing, take the same steps. What I would like you to do, is to do a transfer. To send some of your Test ETH to your friend. To do that, you will need their public address. You should share public addresses, then send something to your friend and your friend can send something to you back. This is, again, fairly straightforward, if there’s issues look to YouTube videos on this. But this is your ticket to get into this space. Even though you’re playing on the Testnet, this is 100 percent rock-solid wallet that can be used for real Ethereum transactions and any other ERC-20 Token. My Ethereum MetaMask wallet, it’s got Ethereum in it, it’s got USDC, it’s got [inaudible], it’s got many tokens that I have in my wallet. It’s very general. In terms of troubleshooting, there’s a few things, you would do the entire thing on a desktop or so, or a laptop. Again, I’ve got different accounts or different wallets based upon the machine that I actually have. Indeed, if you do that, if you set up a separate account which you can, on a desktop, then you can do the transfer from your mobile to your desktop and vice versa. That’s a good exercise to do. It’s also possible to import from one wallet to the other. What if you forget your password in MetaMask? The MetaMask password can be a pretty simple password, doesn’t have to be as strong password. But if you forget your password, then you can basically recover everything by importing the seed phrase. That’s why it’s really important not to loose that seed phrase. Then maybe the last thing that I’ll mention is, what happens if you forget your password and forget your seed phrase? Well, that’s very bad news. Because that means you’ve lost whatever it was in your wallet. Now, if you only have an account with ETH in the Testnet, then you’ve lost nothing, because you can just go and do the whole process again. However, if you’ve got real ETH and ERC-20 Tokens, you lose your password, you lose your backup seed phrase, you’ve lost your private key. That gets you into the world of, if I do this, try to do some transfers and this is the only way that you’ll really understand what’s going on, I can push some slides, you can listen to me, you can do the quiz questions, but you need to be actually involved in the space, you need to have a wallet. Before my students get into my course, a pre assignment is to set up a wallet and to load in some Test ETH into that wallet. Because we use that wallet throughout the course. You have to do it. I think it’s very important. This is the way to join the world of ETH.

02_blockchain-tech-big-picture

01_hashes-and-keys.en

Okay, so the second part of joining the world of DeFi is to really understand some of the big picture in terms of the technology, in terms of the crypto space. So I’ll go through a number of concepts and at a fairly high level to give you an idea of what is actually going on. So for example we talked about cryptographic hashes to some degree. We talked about keys, we’ve talked about addresses, I’m going to layer on a little more detail which I think is important for you to understand. So we started very early on to talk about a hash. So I want to make sure that you understand in the first course, we talked about SHA- 256 hash which is used in Bitcoin and that takes an arbitrary size input. And the Output is 256 bits or 64 hexadecimal characters, ethereum used the Keccak-256 and that is a basically in the SHA-3 Family. So it’s a more advanced hashing algorithm. These are cryptographic functions but they’re not encryption, they’re one way functions. Okay, so this is really important if somebody says that a hash is encrypting a document, they don’t understand the basics, and you need to understand the basics. So this is a one way function, it’s not meant to be undone and it plays a very important role and all of these blockchain protocols. So hashing function is number one. So cryptography is important in terms of what we do in particular in terms of the private and public keys. So, this field is actually broken into two branches, so cryptology is the general area, cryptography is what we focus on. And that’s basically the science of making stuff secret, so your private key is secret. Crypt analysis is kind of the reverse, so that is decrypting stuff and we don’t really talk about that in this course. It’s a cryptography that is the most important and it makes the blockchain technology that underlies the theory very powerful. So in terms of cryptography there’s two different types of cryptography at a very high level, and one is symmetric key and the other is asymmetric. So let me tell you briefly what that means. So think about encrypting a document so it might be like an adobe pdf,were your password protect that document. And then you send that document to somebody, and then somehow let them know what the decryption key actually is the password. Okay so that is an example of symmetric key cryptography. So it’s the same key that’s used to encrypt and decript. However most of what we do in blockchain technology has to do with asymmetric key cryptography. Okay so, think of a private key and a public key and the public key is mathematically linked to the private key. The private key is a random number. The public key is derived mathematically but is derived in a way that makes it really difficult to go from the public key to the private key but it’s really easy to go from the private key to the public. Okay so, the methods that we use to do that, are called elliptic curve cryptography or ECC, and when we talk about signatures we’re going to be using elliptic curve cryptography or so. Okay so, let’s kind of give some examples of this, so you get the idea. So, and this is a public and private key with asymmetric keys. So a message needs to go from a sender to a receiver. So think about a receiver gives the center a lock physically, think about it a lock. So the center locks the message and transmits it to the receiver. Only the receiver can open the message because the receiver has got the key to the lock. Okay so, the center can lock the message but there’s no ability to unlock. That’s basic intuition as to how this works and the lock is basically the public key and and we will open it with the receivers private key. This is an example of my business card by the way. And notice at the bottom of my business card is a key, okay? So this allows people to encrypt an email with my public key and only I can decrypt the email because only I have the private key that’s associated with that public key, okay? So this is a very important application and, this is a bit of a digression but it’s important for you. So let me give you an example of PGP email. So this is how it works and it’s interesting it uses both symmetric and asymmetric encryption. So the way it works is the following you start up compressing the message to reduce the size. That’s no big deal, and then a random numbers generated it’s called a session key, and usually based upon most movement so it’s unique. It’s a random number and that is going to be your symmetric key, okay? So that is going to be something that we’re going to use because we’re going to take the message, so the center is going to encrypt the message with that private symmetric key, okay? Then the next step is that, that session key is encrypted with the receiver’s public key, okay? So that’s a symmetric. So then the encrypted message and the encrypted section key are sent by email. The recipient uses their private key, to decrypt the session key, and then the session key is used to decrypt the message and then you un compress. So this uses both symmetric cryptography and asymmetric and very straightforward to do. So again this is a foundational material that we use in Blockchain technology.

02_addresses.en

We’ve talked about addresses. By now hopefully you’ve set up a MetaMask wallet and you’ve got an address. We need to understand where that address is actually coming from and that’s what we’re about to do. Public address is basically derived from your private key. You’ve got a private key that’s a random number. It goes through an elliptic curve algorithm and you derive a public key. The public key is basically manipulated to come up with the public address. Again, the public key can be public. That’s why it’s called public. The address is public also. The idea is with that public address, that is useful because somebody might need to send you something. They use that to send stuff to you. But again at least for today’s technology not computationally feasible to go from the public key to private key. The way this works, again, both Bitcoin and Ethereum use Elliptic Curve digital signature algorithms, particular type, there’s many different types of them. This is part of the details and basically the steps are the first thing is; you generate a private key and the private key is 256 bits, which we’ve talked about. It is represented as 64 hexadecimal characters, or it could be 32 bytes. We’re going to use the Elliptic Curve digital signature algorithm to derive the public key, which is actually 512 bits. The private plus the public is called the key pair. We, in a digital signature algorithm, are going to be able to sign transactions using our private key and when we actually produce that signature, anybody looking at the signature and knowing our public address knows for sure that the person signing actually owns the private key or is in possession of the private key. In both Bitcoin and Ethereum the addresses are linked to the public key. Ethereum is very easy to get the public address. This is the way it happens. Again, you generate a random number that’s going to be your private key. You pass it through the Elliptic Curve algorithm, you get 512 bits, which is a 128 hexadecimal characters. Then you’re going to hash that with the Keccak 256. When you do that hash, you get something that’s 256 bits or 64 hexadecimal characters. What you’re going to do is to take the last 40 hexadecimal characters. There are 64 hexadecimal characters but we’re going to take the last 40. We’re going to ignore the first part. Then all we do is append that with a 0 x. Ethereum, the addresses are all appended with a 0 x. Very straightforward. The actual formula you can see for actually doing this is below and very simple, to go from the public key to the private. This is my MetaMask account. You can actually see my MetaMask public address ends with a CCE. Indeed, you could use that address to send me some coin, a tip. Maybe you can easily do that so it is available and that is definitely my public address and my MetaMask account. This is just showing the mechanics of how we go through a particular example where I generate a private key, a public key, then do the hash and then take the 40 last hexadecimal characters and append with the 0 x. Just putting real hexadecimal notation for Ethereum. Bitcoin is more convoluted, but it’s still fairly straightforward to do. This isn’t a Bitcoin course, but given Bitcoin is so important, I will go through the same steps as an example. You generate a random number, which is going to be our private key. Pass it through the elliptic curve routine and we get a public key. Notice that it’s much longer, and that’s why the fund is much smaller, 512 characters. Then we’re going to perform a SHA-256 on the public key. All of this is identical to what we were doing, except Ethereum was using a different hashing algorithm. Ethereum uses Keccak 256, we’re going to use the SHA-256 in Bitcoin, but then it gets a little more difficult. What we’re going to do is we’re going to use another hashing algorithm, which is a ripe MD. MD stands for message digest or hash 160 on that previous step, the SHA-256. The ripe MD 160 is actually a 160 bits, not 256, so it’s shorter than the 256. Then in step five, we’re going to add the version number in front of that ripe MD 160 and then we’re going to do another hash. We’re going to do a SHA-256 on the extended RIPEMD-160. Again, we’ve got the public-key. We do the 256 SHA, we do the RIPEMD-160, which has a shorter hash. We put the version number in front and then do a 256. Basically in doing this, we end up with 256 characters and step number 6. Then we do another SHA-256 in step 7. Again, we’re still at 64 hexadecimal characters. In step 8, we’re going to take the first four bytes of the second SHA-256 and that’s going to be our checksum in terms of maybe if somebody types this in incorrectly. We’re going to basically add the four checks on bytes to the extended RIPEMD-160 in stage 5. Do that and then convert the whole thing to base58. Base58 is the upper and lowercase letters. So that if you add 26 and 26, the numbers 0 through 9. But then we’re going to exclude some ambiguous characters and we get to base58. That’s what a Bitcoin address actually looks like. It’s basically just a bunch of hashing. Ethereum much more straightforward, where you’ve got the public-key. You do the Keccak 256. Take the last 40 hexadecimal characters, apply the 0 x, you’re done. Bitcoins has got many steps to it, but again, it’s very mechanical, very fast to actually do.

03_signatures-and-transaction-mechanics.en

Okay, so now let me talk about signatures and and some of the transaction mechanics, so digital signature is very important, it’s a way that a transaction is actually organized. So if you’re sending let’s say some ethereum you need to prove that you’ve got the private key and that’s where digital signature actually comes in. So you need to prove it without revealing the actual key, so this is very important and we use an algorithm to actually do this and this is kind of how a digital signature works. So let’s actually go and look at this in some detail, so the private key is called the signing key, SK and it’s completely secret of course. So you don’t want to reveal that the public he is sometimes called the verification key and it’s mathematically linked to the private key as I’ve already mentioned. Okay, so think of the private key, goes into an elliptic curve algorithm and a public key comes out and we’ve already gone through that there’s got 512 bits to it. And there’s actually, the reason is longer, it’s two coordinates X&Y, that’s really easy as I said, to generate the public key with the private key and very difficult to go in the other direction. So the digital signature, what happens is that we’ve got a message and this might be our transaction. And what we’re going to do is the inputs for the signature algorithm are going to be the private key of course and a nonce. Or just think of it as a random number that that is put in and we put those together and within the elliptic curve and you can, if you’re interested in this, go into much more detail. There’s certain ingredients that are very important for this elliptic curve operation including a base point, a module s which tells us the maximum number. That can actually happen in the operation and in order, so these three things and then basically a digital signature comes out of that and it’s got to coordinates, R and S. So to verify the signature, what we’re going to do is, we’ve got the two coordinates that are available R and S, how we got the message and we’ve got the verification key which is the public key. We pass all of that through the elliptic curve operation with of course the base point and the order and we’re going to drive a new point. And then what we’re going to do is to check one of the coordinates, the X coordinate and if it’s checked, then if it’s verified then it is a valid signature. Which means that the person signing must have the private key and that’s how a dig digital signature actually works, so this is what it actually looks like. And we don’t need to go through all of the details of this but you can see what the form of the elliptic curve is, you can see what the base point the order. And the module is actually is these are extremely large numbers, notice that everything is done in hexadecimal here. But these are are very large numbers but this works very quickly and seamlessly, so a few things to notice about this. So when you sign, you basically prove that you have the private key without revealing the private key and everybody can see that instantly verified. Okay, so think of this as, you’ve got the address, we know the address is derived from the private key. But with that address and with the digital signature then you prove that you actually have the private key that’s associated with that address. Remember, anybody can grab an address like you’ve got my address, right, so I showed you my address, that fall, it has got CCE as the last three hex. So you’ve got that address and the problem is that you can’t prove that you’ve got the private key associated with that address. There’s no way you can do that unless you somehow hacked my computer and even if you do that, the private key is not on my computer. It’s off the internet, it’s actually in a hard copy form, so public keys, anybody can see, a private key, that’s different, so that is that is basically hidden. So the digital signature provides that bridge without revealing the private key. You can do this signature where anybody can figure out that you must have the private key that’s associated with that public address or public key. Okay, so this is essentially how this works and this is just an example, there’s plenty of websites that actually do this where you can actually go and choose the elliptic curve algorithm. And actually go and do an exercise of generating a message that signed, so this is again a common technology. It is complicated but it’s important for you to know the basics of this technology and you can see in Bitcoin, this is used in terms of the op checksig and within Bitcoin. This is also used in Ethereum and almost all credible block chains use this particular technique. Okay, so the the last thing in this module is how a transaction actually works and this depends upon the blockchain protocol and let me kind of start with a Bitcoin transaction. And what I like to do is to kind of zoom in on the actual graphic that you see over here, so let’s take a careful look in that bag. There are three things, you can see that there’s a three, there’s a point two and a point 01, those are called unspent transaction outputs, so they represent Bitcoin. So the total balance in this wallet is 3.21, so suppose that you want to do a transaction and you need to send .15 Bitcoin to someone. Okay, so the way to do this is, you’re going to use the unspent transaction output for the .2. That’s going to be the input to the transaction and then the transaction is going to have two outputs. So the first output is the .15 that you’re sending to somebody to, let’s say pay for a good or service but then there’s .05 left. So think of that as the change and what you’re going to do is to send that back to yourself. Okay, so effectively, what we’ve done here, we’ve changed the bag, so that .02 is completely gone and it’s being replaced by another unspent transaction output which is point zero five. So this is the way Bitcoin works but ethereum operates on a different system so while Bitcoin has got these unspent balances and you need to choose which one to use. Indeed, we could have chosen the three, so we could have chosen the three and sent .15 and then had change of 2.85, so it could have done that. But Ethereum’s system in my opinion is much more straightforward and it is a system of account balances, so it’s more intuitive. So the Bitcoin method is extremely interesting, it is a little more intuitive to keep track of balances and we saw this in terms of our supply mechanics, in terms of checking the ballots.

04_consensus.en

Another important concept is consensus. We talked about, in very general terms, something called proof- of-work. Where miners are doing the work to find that rare hash that will be linking one block to another block. Basically, this is a key ingredient for blockchain technology. This is the mechanism whereby all of the nodes in the network agree on the historical blockchain. It’s really fundamental that we have to have some agreement. Again, the two main technologies are proof of work and proof of stake, but as we’ll see, there’s many different versions of this. Even consensus just to define it, is difficult. You could have majority, let’s say 51 percent, you can have super-majority, you can have unanimous. It might be that not all votes are equally weighted depending upon what you’re doing. This is like an ongoing issue to figure out what the ideal consensus mechanism actually is. We need consensus because we don’t have a centralized leader. If you were centralized, somebody would just decide. But that’s not the case in decentralized finance. You have to do this in a way also that we prevent, untrustworthy parties from dominating the consensus. Because if that happens, then the protocol will fail and people will not have any confidence in it. Basically what we’re doing is agreeing upon; think of it as the new blocks. There has to be agreement, and the new block basically is added to a chain that people agree upon. Of course within the block, the transactions have to be valid transactions or the block isn’t credible a block. Somehow consensus has to be achieved, and it’s not achieved with human oversight. There’s no central leader. One way I think it’s good to think about this, is that once this is decided, it’s irreversible. So you come to consensus you can’t change your mind. Given the nature of this technology, that once the transaction makes its way into the block chain, that’s relevant for, let’s say Ethereum, then it’s there forever. You get one shot at this. It’s really important to get this right. This is distributed system consensus, there’s lot of research on this, it is still fairly early on, but, I like the very simple definition here that, consensus is the process by which all nodes agree on the same ledger. It’s got to have certain properties that’s got to be resistant to attacks by malicious actors. Again, there’s many different ways to actually do this. It’s also interesting in the world of decentralized finance that we can have consensus where parties agree, but, you don’t need to trust the other party. Indeed, you don’t even need to know who they are. This is very unique. You think about, for example, a government vote or consensus; you know, exactly who voted for what. You might know that somebody is trustworthy or not trustworthy. This is completely different situation. This is essential that we don’t need to trust other parties to come up with a consensus. We’re going to verify transactions without trust. Indeed, within the system, anybody can be running a node, it doesn’t matter who you are. Indeed, I’ve told you that it is technologically infeasible to go in and mess with the Bitcoin or Ethereum blockchain. A hacker would be much better just setting up a node. The hacker might be somebody that’s completely not trustworthy, but they’re running a node and you don’t care. Because their incentive is not to attack the network, but effectively just to join and to profit from it. Again, there’s various different types of consensus that we will talk about, and this is a key component in terms of what we do. There is, I guess, agreement in terms of consensus right now between Ethereum and Bitcoin’s blockchain but that will change. Again, we’ll take a look at these different technologies. One technology we’ve talked about already is proof-of-work. Again, it doesn’t matter who is doing that work. We don’t need to trust. The miners doing the work. They just needed to produce that really rare cryptographic hash. Those miners are assembling transactions, verifying the transactions, and then searching for the rare cryptographic hash. It is when they find the nonce that delivers out hash, it is very easy for anybody to verify that, that hash has a lot of leading zeros. That’s a rare hash. Verification is really easy to do. Again, the miner is pulling the transactions from the memory pool, picking the most valuable ones first, and then cycling through different nonces to get this really rare hash when they win they get a reward. They get a reward in the Ethereum they get reward in Bitcoin. Of course, part of the funds that they get is from the transaction fees that are within this process. Again, you can have a node that is doing mining, so that’s possible, or you can just have a note that’s not doing any money, but just has a copy of the Ethereum blockchain on it and it providing service to the network. You don’t have to be doing mining if you’re a node. The way it actually works with the proof-of-work is the miner will search for that rare hash. If they find it, they will broadcast it to the network. As people or as the nodes on the network verify that the hash is associated with the nonce and the transactions that actually works, then they add that to their copy. They add that block, that candidate block to their copy of the blockchain, whether it’s a Bitcoin or Ethereum. It propagates through the network. In Bitcoin this happens every 10 minutes, Ethereum is much faster to actually happen. As soon as that new block goes into a blockchain, then we start the process again going through the different transactions. In terms of strengths and weaknesses here, proof-of-work is very straight forward. It’s proven to be extremely reliable. We can have a lot of predictability in terms of the block times. If a lot of computing power comes onto the network and that rare hash is found faster than, let’s say, 10 minutes in Bitcoin, then the difficulty just adjusts to make it more difficult. Or if computing power goes off, for example, China shuts down some mining operations, then it takes a lot longer to find that difficult hash. Then the algorithm just adjust the difficulty, so it makes it easier and we stick to the time for the blocks. Again, this is pretty straightforward. It is of course vulnerable to a 51 percent attack. But I’ve already argued that that just doesn’t make any sense in terms of the money that would have to be spent to amass the computing power. Even if you did that, what are you going to do? Are you going to send some crypto to yourself? Because if you do that, given that you’ve amassed 51 percent, nobody will have any confidence in the crypto and the price will likely go to zero. Even after spending all of the money and amassing all the technology, even if you could pull it off, you’re going to destroy the value of the actual crypto. The only way that makes sense is if there was a national or international actor that wanted to drive the price to zero. It’s vulnerable technically, but for strong blockchains, it’s just not feasible. There are considerable strengths. This is very secure in terms of the amount of computing power it does necessary. But in terms of drawbacks, it’s an enormous waste of resources. Bitcoin, for example, uses the same amount of power as Argentina. Much of the power is by fossil fuel, which is just not a good idea. We’ll talk about this later in Course 4 in terms of environmental risk, where I will go through and show you a calculation of how much carbon offset you would have to buy to offset the carbon created by the money of one Bitcoin. Just one. This is a disadvantage also. The hardware is very specialized. The hardware that I showed you in Course 1, that’s in the basement at Duke University, the S17 minor, it does one thing, [inaudible], it’s hardwired in. That’s what an ASIC is. It’s a specialized chip that does one thing. The E3 minor does one thing and that is the Keccak 256 and it’s designed to do that. The S17 does 53 tear hashes per second. That’s all it does. So it’s specialized and you could think, well, maybe that hardware can be used for better purposes. In a way, the proof of work is, it’s got a lot of strengths, but it does have weaknesses. Indeed, there are other weaknesses. The scalability issue, there’s just not enough transactions per second to be competitive so that is a problem. That’s a reason Ethereum is moving to proof of stake. It’s one of the reasons that we can do far higher throughput. The other thing with proof of work is that the miners really are invested in the system. They win their Bitcoin and Ethereum and usually just dump it immediately. They’re providing a service, but they’re not really a stakeholder in the sense of holding the actual currency. Again, proof-of-work is out there, but there’s also going to be a transition to proof of stake. I put Ethereum 2.0 there, where Ethereum 2.0 means movement to proof of stake. What is proof-of-stake? Proof-of-stake is instead of everybody doing the mining, so think of thousands of machines going through, cycling through and doing the mining, what about just delegating to one minor? Choose somebody at random. Indeed, why not do that in a way where it makes sense for the system? Instead of just a random miner being chosen why not have it based upon the size of either the holdings or a stake. You put up some Ethereum and you stake it, and you look at all of those that have staked, and let’s say that I put up 10 percent of what’s staked, and then probabilistically, I will be tapped on the shoulder designated to mine about 10 percent of the time. This is a very nice idea in that what it does is it eliminates all of this redundant mining so you still go through some of the same steps in terms of hashing, but this is way more energy-friendly to actually do. There are various different aspects to this. One aspect that’s interesting is that there’s not the redundancy, as I’ve mentioned, but there could be this extra incentive in terms of the stake. You actually, given that you’ve got a stake, you’re invested in the currency, that you are incented to do the right thing. For example, suppose you did the wrong thing, that you grab some transactions from the memory pool and one of the transactions is a bogus transaction. Then you propose I block and think of the following. That because you made a mistake and you put an invalid transaction in, then we reduce your stake. You got to pay for it, you got to cover the cost. Okay, again, this makes it very compatible to do the right thing. Because you, of course, you’re being rewarded when you get designated, but you actually are incented to do the right thing because you’ve got a stake. This is proof of stake and it’s got a lot of advantages, no useless mining. Indeed, there’s not really a reason to have this competitive hardware advantage. This could be just a regular computer rather than a specialized ASIC miner. It’s compatible in that those with the biggest stake, they are most probable to be designated to mine, but they also have the most to lose. The incentives are aligned. Good idea. It’s also this idea of the 51 percent attack doesn’t make any sense in terms of proof of stake. It makes sense in proof of work, but not proof of stake. We’ve got a designated miner that will be assigned to add the next block. This is far more efficient than a proof of work. There are many blockchains that exist today that use proof of stake. This is not without risk, and theoretically it encourages centralization. Think of it this way. The miners with the most or the actors within this network that have the most Ethereum, they’re most likely to be chosen to do the mining and most likely to get the reward for it. Effectively, the rich get richer and it’s possible that this could lead to more centralization. That is a well-known drawback. Some people claim that the security of proof of stake is not as good as proof of work. I think some of these claims are by people that have an interest in maintaining a particular or consensus mechanism. For example, a bitcoin miner has no incentive to change to proof of stake because all of their investment and their computing machines would go basically to zero. I don’t think that this is really a drawback. Just to close here, I’ve talked about proof of work. I’ve talked about proof of stake, but there’s many other iterations. For example, delegated proof of stake. It’s a very interesting idea that I might have a small amount of ether, but I can delegate some of that to somebody else so that they actually build up a bigger stake. Then I share in the rewards when they’re designated to do the block a good idea. There’s delegated Byzantine Fault Tolerance very popular in some commercial implementations of blockchain. Proof of capacity, proof of elapsed time, proof of identity, proof of authority, proof of activity. There are so many of these candidate mechanisms. We’ll see what actually happens. Again, this space is very early. We started with proof of work, now we’ve got a number of different candidate consensus mechanisms, even within proof of stake, there’s many different ways to actually do that, but there will be a transition. For almost all of the cryptos, there will be a transition to something like proof of work. To mitigate that problem, which I consider a very serious problem, the environmental problem, bitcoin will stick to proof of work. We’ll talk about that risk a little later on in the fourth course.

05_incentives-latency-data-computing-power.en

Let’s continue on in terms of our big picture, in terms of the technology that you used in decentralized finance. We’ve actually already talked about incentives and we will further talk about incentives in terms of how this ecosystem actually works. Incentives are really key. The miners are incentive to do the work that’s necessary for the security and the validation of transactions. We’ve got the keepers that are incented. We’ve got the possibility of different protocols incentivizing people to interact with the protocol. We’ve got many different levels of incentives, and this is a key thing. It is interesting that just within the network, within the Bitcoin and Ethereum network, there’s no direct reward for running a node. If you’re not mining, there’s no reward for that, and you can maybe understand a company having a node or a university. I guess the point I’m making is that, well, incentives are an important part of this ecosystem. There’s still some gaps. Latency, I’ve talked about already. It’s a big issue. I spend a lot of time in the fourth course talking about different technologies that can address the main issue. Visa routinely can do 24,000 transactions per second and their capacity is up to 75,000 transactions per second. If you look at Bitcoin and Ethereum is trivial. I’ll compare it to that. That’s the reason that Bitcoin cannot be a credible transaction mechanism on a large scale given the current implementation. Ethereum looks like it falls into the same category, but the next version of Ethereum that will be implemented likely in early 2022 will have capacity double rival visa. In my opinion, that’s still not enough, additional work needs to be done. But still it’s a big jump going from 18-75,000. Data. Blockchain contains data. Blockchain is like a database, like a bit as a database, but it’s very special database because it is immutable, so you can only add to it, and it’s also redundant, in that the same database resides on many different nodes. The question is, well, what about putting data into a blockchains? There’s many different things that we talk about. It could be a transaction, I going to move some token from one person to another. It could be a smart contract I put in. But I think I’ve told you already that this is very general technology. We could put things that are relevant for a supply chain in a blockchain, but that takes space. Remember that every node on the Ethereum blockchain has got that entire history. In the future, of course, the price of data continues to decrease at exponential weight. If you look historically at how much it cost for a gigabyte of data, it’s really striking that the prices plummeted. Today it’s about one cent. In the future, I think blockchains will be able to have more data. But right now, the data is quite limited in terms of what we can do. But that doesn’t mean that we can’t have a technology that allows for more data to go into a blockchain. Computing power. You’ve probably seen this graph before, maybe a little different than the usual one you’ve seen, because I actually measure calculations per one dollar in constant dollars. Notice the y-axis is double exponential. There’s a limit to Moore’s Law in terms of the actual depth of a chip. You go to the atomic level, there’s going to be some quantum effects. There’s a limit to Moore’s law, but there’s also another computing revolution going on in terms of quantum computing. Just to be clear here, the quantum computing is irrelevant for cryptographic hashing, but it is relevant, as I mentioned, for the digital signature algorithms. I’ll have a little more to talk about that later. Let me give you an application to end this subsection. This is from an assignment in my course. At Duke University, all the students deploy multiple smart contracts. But the first one that they deploy, they basically send a hash to that contract, so a shot 256, and you send it to that contract. That’s the mechanical part of the assignment, and the deeper part of the assignment is, how could that be useful? Sending a hash doesn’t really take that much space. It’s 256 bits, so it’s fairly cheap to do. Why would you want to send a hash to a contract? This is what they think about. It’s really interesting all of the possible answers that come out of that. For example, let’s say you’ve got an idea. You want to be able to prove that you had the idea at a certain point of time. Maybe it’s an idea for a new business and is contained in a pitch deck. You take that pitch deck and you do a shot 256 of that deck. Then you deploy that to a smart contract. When you do that, we know exactly the time that, that hash was put into the smart contract. The hash is there for anybody to see. Then suppose that a competitor comes up with the same idea. You say, well, no, I had this idea first. Then you send the deck to them. The date on the deck is, let’s say six months ago. The competitor says I don’t believe this because it’s really easy to change the date on a file. Then you tell the competitor said, no, do a cryptographic hash of this file, then go check this particular block on the Ethereum blockchain. You can see that this document existed as it exists exactly today, six months ago, and the exact time is there. This is basically a proof that this existed at a particular point in time. This is so many different ideas. For example, suppose you have a contract and you’ve got electronic versions of the contract, and there’s a dispute. In the dispute, there is a disagreement because the two electronic versions are different and you have to go to court and fight it out. Now, think of a different world were the two parties are trying to put together a contract. They agree upon a contract. You take a cryptographic hash of that contract, you deploy that hash, you send that hash to the Ethereum blockchain. Then in the future if there’s any dispute over the version. Party A says, it’s my version is the true version and party B says no, my version, is the true version, it’s really simple. You take a hash of version A. Does version A’s hash match what’s deployed to the Ethereum blockchain, yes or no. Let’s say it’s no. Then you go to B’s, you do the hash, you check the Ethereum blockchain and matches. Therefore, A’s contract has been tampered with, and the B’s contract is the true contract. Great idea. There’s another assignment I’ll talk about and it’s a lot of fun also. This is a slightly more elaborate on smart contract. I tell the students to send a hash to it. Then the contract has got the ability to reassign that hash to another address. I get them to resend the hash to somebody else, the teaching assistant in the course. That means that when that’s done, the teaching assistant has ownership of that hash. Then of course that’s the mechanical part. The other part is how is this useful? It is very powerful, smart contract. Indeed, I tell my students that this is the single most valuable assignment you will have at Duke University because you can reuse it. This contract allows basically the exchange of anything that can be digitized. That hash could represent your ownership of something. Then you can reassign the ownership to somebody else. Very powerful idea, is similar to an NFT. It’s not as elegant. An NFT has got much more functionality, but it’s the same idea. You’ve got something that you own and that’s proven in that smart contract. Then you’re able to reassign using that digital signature, sign over the ownership to somebody else, and then they are the owner. If they want to transfer it, then they need to sign it over using their digital signature algorithm in the same way. Very cool idea. Lots of applications right here.

06_cross-chain-immutability-oracles-privacy.en

Okay, let’s finish off the Block-chain Tech Big Picture, we have a few more topics to go through. So first is a question. So what will the world look like in the future when there is potentially many different blockchains? Remember a blockchain is a construct that is closed, right? So we can basically go out to the outside world with an oracle, which we’ll talk about in a minute, but it’s closed. So there is great interest in what the world will look like. Will there be a master change and sub chains or side chains? Will there be technologies to bridge change? And some of these technologies are actually emerging so that you can go from one chain to another chain in a very efficient way, but this is an issue. So think of this as the wild west of blockchain where we will have potentially billions of block chains and we need some sort of technology to manage that. So mutability I’ve said is the key component of a Block-chain. There have been many forks and forks are something that anybody can do. So I can create a different version of Ethereum, I can download the Ethereum Blockchain and make a change. Ethereum has been forked before. So we’ve got Ethereum, we’ve got Ehtreum classic, Bitcoin has gone through many different forks. So these forks it’s interesting that forks are something that just don’t exist in centralist finance and it does cause some confusion, but it is on the balance. Something that is really important for this technology that we can very quickly improve the technology and the fork, if it doesn’t work then people are not going to be interested in it and it essentially goes away. So it is basically the survival of the fittest and it’s operationalized in a decentralized finance. We’ve talked about oracle’s already this is a challenge for this technology. Many applications need to reach out and go beyond the Blockchain that they live in and you need a reliable way to do that. We talked about the chain link and other companies that are in this business to make decentralized the oracle of function, but nevertheless this is something that is still a challenge within the space. Governance. So we’ve talked about consensus in this course, but governance is still something that needs to be worked out and for example, some protocols like Bitcoin very challenging to make any changes like simple changes like making the blocks able to have more transactions to kind of speed things up. The Bitcoin community debated for years over that. So something seemingly simple, very difficult to get consensus on. So this is a challenge that exists today and likely will exist in the future. Privacy. This is another issue and certainly this stuff is in the news where Bitcoins used for ransomware, we do have some cryptos that are fully anonymous and there are many issues here, but it’s not just a Blockchain issue? This is not just a crypto issue. This is a general issue that people can communicate with apps that are private and potentially plan nefarious activities with that. So this is a general question but I think that it’s probably good to step back and kind of think about privacy in a different way. So there are many applications of Blockchain and you think that maybe a logical application would be voting. So given the security of this technology we could have a voting mechanism where we could vote electronically. We’ll have the results immediately and they would be verified immediately. But one issue with that is if we did that potentially the government would run a Blockchain so would be centralized and it’s not clear that you want the government knowing how you voted. So there is this idea of zero knowledge proof that I kind of want to end the course on because it’s a powerful idea. So think about it a different way. Go to the store and you want to buy six bottles of beer and they ask you for your ID. So you give your driver’s license and on that license is your name, you’re birth-date which is important but it’s got all this other information, your driver’s license number, your address, why does the store need all of this information? They Just need to know are you 21 and above. Yes or no. So is there a way to do this and this is going to be important for especially Blockchain technology, but this idea of zero knowledge proof. So in the voting context you go and you prove that you have the right to vote and you don’t need to provide any other information. So how does this work? And I’ve got an example that you might like. It’s an example I use in my course and it has to do with two billiard balls. There’s a red ball and a yellow ball. So I’ve got these two billiard balls, but my friend is color blind, so when she looks at these two billiard balls, they are identical. So she can’t tell any difference between them. So my job is to prove to her that those balls are different color and I want to do it in a way where I don’t tell her which one is red and which one is yellow. Okay, so that is the basic setup. So now what I’m going to do is that I will take these two billiard balls and hand them to my friend and tell her this is what we’re going to do. You’re going to take the billiard balls and put them behind your back and then you’ve got a choice, you can switch the balls or keep them the way that they are. Okay, so she’s got the two balls in her hand and I can see that the one in her left hand is read the one in the right hand is yellow and I should be able to tell if she switches if they are really red and yellow. So we go through this and she takes the balls and puts them behind her back and decides not to switch, pulls them out and I say you didn’t switch. She does it again and doesn’t switch, pulls them out and I say you didn’t switch and this time she switches bring some out and I say you switched, okay. She keeps on doing this and every single time I get it right. So we do it ten times and if you think about luck here that well the first time that had happened where I said no switching was 50% likely I could get lucky. In the second time well maybe you get two in a row and that’s like 25% probability. But once we get the 10 and I get 10 out of 10, the probability of this just being a luck that I’m just guessing. Just lucky, that’s 0.009. Okay, so you see where I’m going here. So what I’ve done is that I proved to my friend and she being color blinded, they look the same to her. I proved to her that these two billiard balls were different colors and it’s probabilistic we could do it ten times, we could do it 100 times or 1000 times, it doesn’t matter. This is a mechanism for me to prove that and I proved it in a way where I don’t reveal which billiard ball is red and which one is yellow. So this is a very high level zero knowledge proof but to get the idea that this is something that could be implemented in and is implemented in a number of Blockchain technologies. So we are coming to a situation in our world where we won’t need to reveal unnecessary private information using zero knowledge proofs and literally using Blockchain constructs that have a record of history, record of the truth, a record of who owns what. That is not possible in terms of a central actor to manipulate that. So we get to verify by looking at a Blockchain construct so that I believe is where we’re headed. That is the big picture in terms of technology for this and let us take a look at our word cloud that I’ll show at the end of each course and become actually a long way in terms of all of these sort of words are still some to go and we will deal with the rest of the words actually almost all of the words in the third course which is DeFi Deep Dive. So in Deep Dive we will look at various different applications. It’s the most practical of the four courses where we will look at that protocols that deal with credit lending. We’ll look at decentralized exchange. We return to, you know, swap that was introduced today. We will look at derivatives and tokenization and really get down to some examples of how the mechanisms work for the most popular applications and decentralized finance.

05_Resources

01_module-1-slides-from-video-lectures

02_module-2-slides-from-video-lectures

03_module-3-slides-from-video-lecture

04_module-4-slides-from-video-lecture

3. Decentralized Finance (DeFi) Deep Dive

01_credit-and-lending

01_introduction-and-makerdao

02_introduction.en

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.

03_liquidation.en

Now let’s talk about a different situation, a liquidation situation. We’ve just been through an example where the Ether actually appreciated, went up in value. Now let’s look at a different scenario. In this scenario, Ether depreciates by 25 percent. That means that the Ether goes from $200 to 150. Let’s go through the mechanics of what would happen at 150 value. Now we’ve minted 500, and the total value of what we’ve got here is only 750. The over-collateralization is 250 and that’s rate at the edge, that is exactly a collateralization ratio of 1.5. Very dangerous to be at that point because just like a one percent or even less, further depreciation in ETH means that the contract is going to be closed out. This is a scenario where some action might need to be taken. Let’s assume again that the ETH drops 25 percent from 200 to 150. Vault holder, it’s got a number of possible options. The first option, which is analogous to what we would do with a margin call is just to add some more collateral. You could add, let’s say 1 ETH to the vault, and then you’d be fine to be above the 1.5. The second option is you’ve got the 500 DAI, you could just pay back the loan and retrieve the 5 ETH that you put in originally. The third option is that the loan could be liquidated by a keeper. As soon as you go just a little bit below that 1.5 collateralization ratio, that’s going to happen and it’s going to happen very quickly and that is the job of the keeper that we spent a lot of time talking about in the second course DeFi primitives. The keeper is an external actor that’s incented to actually do a liquidation. Let’s actually go through a liquidation at the 1.5 or think about it as 1.49. But let’s just go through what a liquidation would actually look like. The mechanics are the following: the keeper is actually going into the vault to liquidate 3.33 ETH. Essentially what’s happening here is that those ETH are auctioned off and that will generate enough money to pay off the loan of 500. That’s the first thing that the keeper does. The keeper also gets a fee for actually doing that. The keeper is incented to do this action, to do the liquidation, to keep the protocol strong and efficient, so the keeper is going to keep a 0.2. What about the vault holder? The vault holder ends up with 1.47 ETH, that’s what’s left over after paying off the loan and then the fee for the keeper. They get 1.47 ETH which is worth $220 and of course, they’ve got the original 500 DAI. Overall, what they get is 720. Let’s think about that, is interesting. They’ve got 720, if they didn’t go through any of this, if they just had their 5 ETH, or if they decided to pay back the loan and pull out the 5 ETH then the 5 ETH would be worth 750. This is a situation where the loan is over-collateralized. The loan is paid back, and any residual minus the fee to the keeper goes back to the person that made the original deposit of the 5 ETH. This is how a liquidation actually works. There’s another layer that’s very interesting here in terms of the stabilization of DAI. Why would a DAI be worth a dollar? Well, the most obvious reason is that it is over-collateralized. People believe is worth a dollar because it’s more than a dollar in collateral. We know the collateral is risky. We know it’s over-collateralized. Anybody can see the degree of over-collateralization. Again, on the Ethereum block-chain , everything is transparent. The other thing that’s interesting is there’s another stability force that’s linked to market actions. In the liquidation, what actually happens here? The keeper goes in, and you remembered they sell 3.33 ETH. You’re selling ETH in the market, and DAI are purchased. This actually exerts a positive price pressure on DAI. You can think of the overall scenario here is that the value of the collateral is going down, and people might think, well, maybe if it goes down enough, we’re not going to have as much confidence that DAI is worth a dollar. As that collateral gets lower and lower, people will start to discount the DAI. Maybe it’s 99, maybe it’s 0.98. But with this liquidation, given that you’re selling ETH and buying DAI, that actually acts as a counterbalance. There are two levels that actually build in for the stability. A very interesting mechanism. Of course, the key idea here is to maintain the peg. A stable coin, you want to be as stable as possible with respect to the peg DAI set. Ideally, you’d like it at exactly $1 all the time. There will be some fluctuations, 0.995, 1.01. But ideally, you want to maintain that one-to-one peg. Again, various different mechanisms here that are in play in this protocol, and we’re going to talk about a number of them here. One is a DAI savings rate. We got a debt ceiling. We got a stability fee. These are parameters that are controlled in the smart contract by the governance of MakerDAO. The governance is the Maker token, MKR. It is in the governance’s best interest to keep the DAI as close as possible to the US dollar. The stability fee is basically a variable interest rate that’s paid in DAI by vault holders on any debt that they generate. This is, think of it as, an interest rate. This interest rate can be raised or lowered. This will basically incentivize, for example, the repayment of the DAI. If the rate goes up, then you’re going to repay. This will basically drive the price towards the peg. The stability fees, fund the DAI savings rate, and this is a variable rate that any DAI holder can earn on their DAI deposit. If you’ve got DAI, you can actually deposit and earn this variable rate. This DAI savings rate is compounded on a per-block basis. Would just be interesting also because the block happens every, let’s say 18 seconds. It’s near-continuous compounding. The stability fee is always greater or equal to the savings rate and that is enforced by the smart contract. That is also very important and we’ll talk about this later with some other protocols that this makes a lot of sense that the savings rate has to be less than the revenue coming in to actually fund it. There’s also a DAI debt ceiling. This is again contract enforced. It is a parameter that’s agreed upon that could actually vary through time. Just let me emphasize this. The fundamental nature of the contract, it is set in stone but there are certain parameters that can be buried by the governance and that’s what we’re talking about right now. This is basically the amount of debt has got a ceiling. This basically allows for more or less supply to meet the current level of demand. If you’re at the debt ceiling, then basically it’s not possible to mint some more DAI. You’re at the ceiling for debt, then people cannot go in and deposit more collateral and mint some more DAI. We have to wait until some of the old debt is paid so this is all paid off. This is another mechanism for stability. There’s also liquidation issues. When the position as I showed you goes under the collateralization ratio, there will be a liquidation and there’s a liquidation penalty. That penalty is calculated as a percentage of the debt and is deducted from the collateral. Again, this is just one additional mechanism that we’ll look at. This all makes sense but the collateral is still very risky. Even with a collateralization ratio of 1.5 or 2.0, it is possible that there could be a huge drop in the value of the collateral. We’ve seen this historically. In the crypto space, at the end of 2017, cryptos lost 80 percent of their value, which would challenge the collateralization ratio. What happens if there is a sharp drop in the crypto? Basically, there’s just not enough collateral to pay back the debt. That’s something that we need to worry about. Essentially, what the DAI system has done is to create a second layer of risk management and this has to do with protocol debt. There’s going to be a buffer pool. That is going to be helpful in a situation where there’s an extreme event and we go into a situation of under collateralization. That’s kind of the second layer of risk management is buffer this pool. Ideally, there’s enough funds in this buffer to actually cover the under-collateralization. There’s actually more. There’s a third level. The third level is, well, what happens if you run out of the buffer? You’re undercollateralized and you still need to pay back the debt. The way that that happens is with the governance of the MakerDAO.

04_governance.en

Okay, now let’s talk about the MakerDAO, governance. So, we’ve got a mechanism that we described that makes a lot of sense. You’ve got over collateralization. Is one of the forces that keeps the DAI close to the dollar. We’ve also got basically a stability fund. So, if there was a situation where we go under the collateralization. Then, we could actually use the stability fund to essentially bailout the protocol. But, it’s also possible that we go beyond this. And the stability fund is actually exhausted. So, we need to talk about the governance. So, as I mentioned, the governance token is the MKR. And the token holders have the right to vote on protocol upgrades. And that might be supporting a new type of collateral. For example, when MakerDAO started. The only collateral was ether. Now, there’s a range of different ERC20 tokens that are used as collateral. And the governance also can change parameters. So, it might be the collateralization ratio will change depending upon the volatility. So, that the governance is supposed to make decisions in the best interests of the platform. And, it is definitely within their interest to do the right thing for the platform. Because if they start doing things that are deemed unhealthy for the platform. Then somebody else will create a copy of this protocol with more favorable parameters. Okay, so they’re definitely incented to do the right thing. So, let’s kind of go through what that right thing is. So, Marie said that there was two levels of risk management. And MakerDAO. The first level is the over collateralization. The second level is the stability. But, what happens if something catastrophic happens. And you exhaust the first two and you need a third level. That third level is called global settlement. And what happens here? So, essentially got a situation where we need to pay back the debt. We don’t have enough collateral and we don’t have enough and the stability funds. We need to come up with some more funds. And the way that this is done is with the maker token. So, think of what’s happening here is that maker will basically inflate. So, new maker tokens are minted. And those are used to pay back the debt. Okay, so this kind of fills the gap. So, you might think, well the maker holders, they could just pledge a certain percent of their tokens to actually bailout. But that would be really difficult to do. You can’t really decentralized finance, force people to pay a tax like that. But effectively, the minting of the new token is doing the same thing. So, is deluding the value of maker for the existing holders. So, this is very analogous to, it’s almost like a bankruptcy. Where you have to offer new equity to different equity holders, to get started again. And this is effectively what’s happening here with the maker token. So, the maker token is diluted. And this basically is called the global settlement. So again, there’s lots of interesting things that the maker community actually deals with. Indeed last week, I was invited to talk to the maker community. So, we did a Zoom and I talked about this learning experience. That we’re actually going through. And the focus that I put on Maker. And, so, this is an active community of token holders. That are again strongly incented to do the right thing for the actual protocol. So, makers got value. So, the token is traded, has got considerable value. And, while it’s not equity. It is possible in the future that there could be cash flows associated with this token. So, it definitely has some tangible value in the future. And that’s why it’s valuable. So, overall here, DAI is very attractive. Because you can purchase DAI, utilize it as a stable coin to move very quickly. For example, between different exchanges. So, this is not like you have to wait two days. To transfer some dollars from one exchange to another. So, this is something that lives on the ethereum blockchain. And can be deployed very quickly. So, it’s also the case that you really don’t need to know the underlying mechanics. Like you need to know for this course, right? Because you are raising your level of expertise considerably. But, just an average user, this is just a stable coin, it’s like USDC. It’s like Tether and maybe I should qualify Tether. Because we don’t really know what the collateral is for Tether. At least we do know for USDC. But, this is a completely open protocol. Where you can have instantaneous audit of DAI. So, it is extremely transparent. And you don’t need to be engaging in all of the mechanics. To use it just as a stable coin, as a Cryptocurrency stable coin. So, very attractive. So, it’s also possible to earn a return by holding DAI. So, you hold dollars, put your dollars in the bank and you’re lucky to get anything. But for DAI, you can earn the savings rate. Okay, so, we’ve talked about yield firming and stuff like that. Well, these protocols, if you deposit your DAI, you get a rate of return. And again the DAI is linked to the dollar. So, it’s not really that much different than earning a rate of return on a dollar deposit at a bank. It is different of course, there are a different set of risks. That are involved for DAI than depositing money at a bank. But, this is quite possible to do. And more sophisticated users can can use this protocol for leverage. Looking at cross platform, liquidity. And it’s very easy to buy or sell with this particular protocol. So, this looks very good. It’s very exciting. It’s one of the leaders in the space. But what about the downside? So, one downside that’s pretty immediate. Is that the supply of DAI is constrained by the demand for each collateralized assets. Okay, so, if you think about the maximum amount of supply of DAI. Is going to be linked to the maximum amount of ether. That’s available to be pledged. And the ERC20 tokens that are accepted within MakerDAO. So, that provides a cap on how far you can actually go. In terms of arbitrage, there’s no clear arbitrage loop. So, for example, with USDC. I can get $1 dollar from Coinbase for 1USDC, okay. So, if I’m able to buy it cheaper somewhere, let’s say for 99 cents. I can sell it for the dollar and make a profit. There’s nothing like that within this particular structure. So, that is somewhat of a drawback but DAI track record speaks for itself. In terms of its stability is very impressive with respect to the competitor, centralist stable coins. So, at the end of each of these protocols. I’d like to go through the problems that they’re solving. So, remember I said in the very first course. That is really crucial for a new idea to clearly solve a problem. And that problem needs to be a big problem or it’s not that interesting. So, what I’ll do, is kind of go through the traditional finance problems. And how MakerDAO actually solves some of these problems. So, I’ve got a chart here. Going through the five problems in the course like centralized control. So, this is basically interest rates are controlled by the Federal reserve. But the MakerDAO platform is decentralized. So, there’s no central control for it. The holders of the maker token are the ones that actually decide. So, limited access is the second problem of TradeFi, traditional finance. And obtaining alone is often difficult to actually do. So, again, it could be a mortgage. Where it’s very costly to actually go through and get a mortgage. It’s very costly to do a home equity loan. It’s very costly to do a refi of your mortgage. Whereas with MakerDAO, basically this is open to anyone. Actually pledge some collateral and get a loan. It doesn’t matter who you are and you can pledge with ether or ERC20 token. And I’m sure in the future, the number of ERC tokens that are pleasurable. Will grow very considerably. So, number three is inefficiency. And I’ve actually already mentioned this. That it is incredibly inefficient to get a loan. And, I mentioned a little earlier about a personal experience in refinancing my mortgage. And, I refinanced with the same bank that holds the original mortgage. But that same bank insisted on a title search. To make sure of the ownership of the house. Which to me, didn’t make any sense because they’ve got the title, right. So, I pledged the house as my collateral. So, it’s just an unnecessary cost. The employee of lawyers to do something that doesn’t make any sense. It is pure inefficiency. So, this is for MarkerDAO, we’ve got instant liquidity. I say at the push of button and this is like within a minute. You’ve got this liquidity. Like there’s no process of approval or anything like that. You get your liquidity in terms of the DAI. And then you can use that for whatever you want. So, the fourth is lack of interoperability and it’s difficult, of course. You can’t trustlessly used things like US dollar collateralized tokens. There is some level of trust that you need for USDC. That the collateral is actually there. And tether again remarkably is a very important token. In terms of the crypto space, but it is not audited. It’s not transparent. And of course that’s the last issue here, opacity. And it’s not just the lack of transparency for something like tether. But, think of the lack of transparency for our commercial banks. We were blindsided in the global financial crisis. People didn’t know the risk that these banks were taken to leverage. That they were taken, was so extreme. I have no idea. And right now, we still don’t have an idea. We’ve got our regulators. But as I said in the first course, the regulators are often one step behind. And have to react to a problem, rather than proactively trying to eliminate the problem before it occurs.

02_compound

01_what-is-compound.en

So the second protocol that will talk about in this section on credit and lending is compound and compound is very important apart of the DeFi ecosystem. So what is a compound? So this is a lending market and it offers many different ERC-20 assets for borrowing and lending. And interestingly and we’ll go through the mechanics of this. All of the tokens in a single market are pooled together, so every lender earns the same variable interest rate and every borrower pays the same variable rate. Okay, so that’s different than what we talked about would DAI. So, there’s obviously many similarities. And given that we’re using cryptos, we need to think about overcollateralization again. Okay, so within this space there’s no credit rating. So people are not really identified pseudonymous, so you don’t really know who they are, they don’t have a credit rating and there’s no way to send the the collector if somebody is undercollateralized. Okay, so this idea of rating is irrelevant within the space and this is the reason that we have to have overcollateralized lending. So, this is again much different than the usual situation for everyday lending but it is analogous as I pointed out earlier to a collateralized debt position like a mortgage. So, if the borrower falls below the collateralization ratio, the position is liquidated just like we saw with the MakerDAO. And just like MakerDAO, the liquidation can be done with the keeper and the keeper is incented to actually check. They check for situations where there’s a liquidation opportunity, so where the collateralization ratio is pierced and their incentive is a bonus to actually do that. So let’s go through collateralization ratios and factors. So we’ve talked about this a little bit with MakerDAO, we’ll go into much more detail. It’s going to be a little more complex because we have multiple cryptos to deal with. So it turns out that every crypto within the compound platform has got some collateralization factor. And these factors range from zero to 90. So a factor of zero means that the asset cannot be used as collateral. And as that factor gets higher and higher, the crypto is deemed less risky. So the safest cryptos would have the highest factors. So, the required collateralization ratio is basically 100 divided by the collateral factor. Collateralization ratio is 100 divided by the factor. And we’ll again, go through some examples to show you how this actually works. So, again, the most volatile assets have the lowest collateralization factors. Okay, so, if for example, you’ve got a collateralization factor of 50, then the ratio is going to be 100 divided by 50 is two. And we actually talked about collateralization ratio of two in the context of MakerDAO. So, this is a protocol where you can have multiple different types of collateral. So, the way that we’ll actually calculate the collateralization ratio is to look at a weighted average of these factors. And it makes intuitive sense in terms of calculating across different cryptos which might be of much different risk. So for example, USDC would be very safe with a very high collateralization factor and a very low collateralization ratio. Whereas something like Ether we know that’s much more volatile. So their factor will be lower and the ratio higher. Okay, so we can actually think of this collateralization ratio like a reserve multiplier and this is lingo from traditional centralized commercial banking finance. Okay, so essentially a collateralization ratio is very similar to a reserve multiplier. In traditional banking, of course in traditional banking the banks need to take a certain amount of their deposits and hold that at the Federal Reserve or whatever central bank on reserve. So there’s a limit in terms of how much money can be created in the system. Okay, so this is important in terms of how this system actually works. So let’s go through some examples. The first one is an investor deposits, 100 DAI and DAI, it’s got a very high collateral factor which is 90 reflecting that it is very low risk. So, it’s pegged to the dollar. It’s volatility is small. So the factor is 90. So, to get the collateralization ratio, that’s really easy, we just take 100 divided by 90. And that comes up with the ratio of 111%. So, this is basically saying that if the DAI is worth $1, then if you deposit 100 DAI, then you can borrow up to 90 dollars worth of any other asset in compound. Okay, so again, if you deposit a safe asset then you can actually borrow more as a result because the collateral factor is so high. So, let’s again go through an example here. Suppose the user burrows the maximum and the price of the borrowed asset increases, then we need to be cognizant of all of the components of what’s actually happening. So, we don’t want to be subject to liquidation. So, you would probably never actually go and borrow at the collateralization factor are right at the ratio and it’s very similar. So what we talked about with MakerDAO it’s too risky. A small fluctuation could cause the liquidation. Okay, so so let’s actually look at a different situation where it’s not just 100 DAI that are deposited but an additional deposit of collateral is put in with a two Ether. So Ether in this particular example has got a lower collateral factor and it’s going to be 60 which reflects the risk of either versus DAI. And let’s assume the price of of Ether is $200. Okay, so now we’ve got a total dollar amount of 500. So we’ve got $400 worth of Ether and $100 worth of DAI. Okay, so in terms of the weighted average here, 80% is in Ether and 20% is in DAI. So we can easily calculate the weighted average of the collateralization. And so basically the collateral factor is just 0.8 times 60 plus 0.2 times 90. That’s the factor. And then to get the collateralization ratio, we just take 100 and divide by the factor. And when you do that you get a 151% approximately. Okay, so this is an example of having multiple things that you’re using for a collateral. And I’ve got a graphic that shows this, we’ve got the Ethereum and the value of that is 400, the DAI, we’ve got $100 worth of that. And then I’m actually showing on this graphic the borrow liquidity. So given, so if this was just Ether, so if it was just $400 worth of Ether, then the borrow capacity is $240. Or if this was just DAI, then the borrow capacity is 90. So when you put that together, the borrow liquidity at the maximum and I’m not suggesting you would do this at the maximum, but at the maximum is 330. And again, if you do this, you look at the total collateral divide that by the borrow liquidity of 330, you get the collateralization ratio, which is one 151%. So this is just another way of working out what the collateralization ratio actually is, and a very intuitive way to do it.

02_supply-and-borrow-rates.en

Okay, so the next thing in compound that we need to understand is how supply and borrow rates are actually calculated. So again I’ve got a number of examples of the mechanics and it’s important to go through these details to understand what’s happening. So again if you’re supplying capital you should get a rate of return for that and if you’re borrowing you need to pay something. Okay, so these rates are compounded every 15 seconds 15 to 18 seconds on the Ethereum Blockchain. So it’s interesting that this produces something that we talk about in finance a lot but it’s mainly theoretical, a continuous interest rate. So this is in traditional banking, maybe you’ve got a daily compounded. All right, well this is one step beyond that, we’re compounding every 15-18 seconds. So some terminology that we’ll talk about. And one thing is the utilization, so the utilization has to do with the amount of borrowing relative to the amount of supply. Okay, so you can never have this situation where you’re borrowing more than the supply. So the amount of borrowing is always less than the supply. So the utilization rate, so that is literally the amount borrowed divided by the supply, that is going to be a parameter that’s going to play an important role in this protocol and there are other parameters that are set by the compound governance. So compound again is a decentralized protocol like maker, it has a governance structure that is decentralized. Okay, so let’s go through some formulas here. And the first thing will establish is the the borrow up formula. So the borrow formula is going to be an increasing function and the y intercept is going to be the base rate. And I will make assumptions in terms of what that actually looks like. And that is the rate where there’s zero borrowing a demand and then there will be a slope and that slope represents the rate of change in the rights. So the slope and the intercept these can be different for any ERC- 20 asset that supported in this platform. Okay, so let’s kind of go through and talk about some examples and some generalizations it’s also possible that the formula is more complex than a linear formula. So it might be that there’s a kink in the formula. So think of it as at some point the slope becomes much steeper. And we’ll go through an example of this particular situation, but the idea is that once you get close to capacity, you want to start discouraging borrowing. And one way to do that is to jack up the rate faster than a linear right? So again, we will go through an example like that. So this is very mechanical and very straightforward. So on the other side you’ve got the suppliers of liquidity. So there’s a supplier interest rate. So that rate is going to be the borrower, right? Times the utilization ratio, which kind of makes sense. And we will go through lots of examples here that think of it as suppose nobody is doing any borrowing, there’s no revenue, so there’s nothing to pay out in terms of the supply interest rate. Or if 50 of the money is borrowed, then you collect the interest on that and then you need to distribute it amongst all of the suppliers. Okay, and that’s where the utilization ratio actually comes in to play. There’s also something important called a reserve factor. So this is and amount of the revenue that’s coming from the people borrowing that set aside as a reserve. So the suppliers actually don’t get that. And this reserve pool is important because there could be a situation like we talked about with Mikado where there’s a default. So being a situation where we’ve got under collateralization and this reserve pool is actually used to cover that. And there is also various mechanisms that are designed to mitigate the risk and maintain the confidence in this particular protocol. So let’s go through some examples. So let’s say in the die market, there’s 100 million that supplied and 50 million is borrowed. Okay, so people have put in as a supply 100 million die and within the compound market 50 million is borrowed. And now suppose the base rate is 1% and the slope is 10% or 0.1 so 50 million is borrowed. So the utilization is 50%. So the formula would be the 0.5 which is the 50% times 0.1 plus the base rate which is 0.01 In that equals 0.06 or 6%. Okay so if we ignore the reserve factor then what would be paid out to the suppliers would be the 6% times 0.5. So 3% would be paid out to the suppliers. So again notice that the suppliers are getting less so the borrowers are paying more like I know it’s a bit of a stretch for an analogy. But in a banking situation the rate that you get for supplying your capital in a savings account or certificate of deposit is far less than what the borrowers are actually paying. So it’s a similar idea. Okay so this is also important. The borrower rate is not a marginal rate, it’s the rate for all borrowers. So this rate can be changing through time. So for example suppose we think we know that there’s 50 million that’s borrowed but let’s think of it in two chunks. Suppose somebody comes in and borrows 25 and then the next person comes in and borrows 25. So if you think about that first chunk. Well let’s calculate the rate. Well that’s 25 million. So 25 times 0.1 and then we’ve got the base rate of 1% so we get 3.5%. So if that was the entire amount of borrowing then the borrower rate would be 3.5%. So then somebody else comes in and borrows another 25. So we’ve actually already gone through that calculation. So the rate will increase to 6%. And the key thing here is that rate applies to all borrowers. So if this is done in two stages you would think the first borrowers getting a really good rate but that rate increases. So again there’s not a marginal rate it applies to everyone. So let’s kind of go through this in an example and now we’ll actually talk about the reserve factor. So let’s say we’ve got a reserve factor to set to 10. So that means 10% of the borrow interest is going to be diverted into a dive reserve pool. So that will actually lower the supply interest rate. It doesn’t affect the borrower rate it reflects reflects the supply rate. So it’ll be now 2.7. So think of this as the .5 which is the utilization ratio times that 6% and then 1minus 0.11 is going to equal 0.027 or 2.7%. And again in this graphic can kind of see what’s going on. We gotta borrow rate of 6%. So the total revenue that’s coming in, let’s say over a year is going to be three million. So that’s 6% times the 50 that’s actually utilized the 50 million that’s utilized. We need to set aside 10% of that for the reserve pool and that will be 0.3 or 300,000 will be set aside and then what’s left to distribute to the suppliers is the three million minus what we’re holding in reserve the 300,000. So what’s left for suppliers is 2.7. Okay, so you can see that this reduces the supply rate, but now we’re actually making this more realistic in terms of what it actually looks like in practice with a reserve pool. So another way to think about this and it’s important to understand this is that that this 6% rate like in the diagram just generates not six million in revenue. That would only be six million in revenue if there was 100% utilization only 50 million is being actually used. So it’s Just generating three million. And that’s why the supply rate is less than the borrower, right? And then it’s reduced further because some money is set aside the cover situation where there’s some under collateral ization. So it is different, but it is fairly mechanical and intuitive. So I mentioned the kink and let’s talk about that a little bit. So again, we’ve got 100 million DAI that supplied. And now let’s say that 90 million DAI is borrowed. So that’s a 90 utilization ratio. And now suppose that our formula has got a kink and the kink is that 80% utilization? So before the kink we’ve got the identical situation that we had previously, we’ve got a slope of 10% or 0.1. But after that 80% utilization, the slope gets a lot steeper. So now the slope goes to 40 or 0.4. So the bar rate is going to be much higher if that threshold is actually exceeded and in this example it actually is exceeded. So again let’s kind of go through the mechanics the base rate is 1%. So the borrower rate is going to be the 1% for the base rate and then a combination of the pre kink and the post canker. So we’ve got 0.8 utilization times that slope of 10% or 0.1 and then we’re actually not at 0.8 where at 0.9. So we’ve exceeded the 0.8 by 10%. So we add in another term here. So it’s 0.1 times the new slope which is much steeper of 0.4 and then you see what happens to the borrower, right? The borrower rate is now 13%. So again, we could do a quick calculation, the supply rate and the supply rate in this particular situation and again just to simplify things will ignore the reserve factor 0.9 which is the utilization times the actual borrow interest rate which is 0.13 equals 11.7%. Okay so this is how this actually works. So let’s talk about the advantages of compound. So like make a doubt this is a way to unlock value in an asset without actually selling it. So again it’s like a home equity loan where you pledge your house and you get some cash. It’s also very easy to engineer livered long or short positions with this protocol. Okay so this is quite easy to do. We did an example and when we talked about Negredo about using leverage where you would draw you borrow and then use that borrowing to buy more of the base asset and effectively take a leopard position. So again let me go through an example of how this could work. So suppose you are actually in this case bearish. So the example I gave a maker dow was you thought the price was going to go up. Well suppose you think that the price is going to go down. So you’re bearish unless say the price of either so you deposit a stable coin in the compound and let’s say that’s us dc or die and then you borrow teeth and then you sell it and you sell it for the stable coin. And basically if the price of each falls, then you can use your stable coin to buy the cheap either and then you pay back your debt and you made a profit. Okay so think of this as if you did this, you deposit enough stable coin you get one teeth and I suppose it’s worth $200. You sell it, you get the $200 and then the price drops by 50%. Well you go into the market, you buy for $100 and then repay the loan and there’ll be some interest I’m abstracting from. But you can see that this would leave approximately $100 in profit. So short position very straightforward to deal with in this particular protocol. So leverage, which we talked a little bit about with a mega dow same sort of thing that again you’re let’s say bearish on the price of ether. You deposit a stable coin, you borrow ETH you sell the ETH for the stable coin, you deposit the extra eat are the extra stable coin and borrow more teeth. And then you sell that again for stable coin and deposit even more of the stable coin. And again what you’re doing is getting a lever position and in this case if the price of ETH actually does fall the prophet would be much greater than the previous example. So this is an example of how to do leverage and how to use this protocol for taking bullish or bearish positions.

03_ctokens.en

Okay let’s continue our exploration of compound. And I want now to talk about and equity token. And we talked about equity tokens in the actually the previous course and this is going to be a tangible example and we’ll talk about C tokens so c lower case and then token. So let’s kind of go through and figure out what’s actually going on here. So basically compound when you deposit tokens as a supplier this is a service and you expect a rate of return. But it’s kind of complicated to keep track in terms of all of the depositors, the different tokens and things like that. So we want to do this in a way that’s algorithmic and really straightforward and the logical thing to do is to tokenize the users share of the pool. Okay so you deposit something and then you actually get a token that represents your participation in that pool. And compound does this with their C token. And this is a very important innovation in terms of this protocol and indeed it’s been copied by many other protocols. So a simple way of keeping track is to actually create another ERC token. So think of somebody depositing some ERC 20 token and then getting another token that actually represents their share of that pool. So it is a valuable asset obviously that token because it represents a share of the deposits. So we’ll go through how this actually happens but when you’re a new supplier then new c Tokens are created. And for example if this is di this would be like a C die. And when you withdraw this is basically a situation where the token is burned. So you no longer have, let’s say 10% of the pool, okay. So it’s a very natural way to keep track in an algorithmic way. So it turns out that because these c tokens represent a share of a liquidity pool, they’re valuable. So they’re literally collateralized by the pool. So these tokens have like additional use so they could be used for collateral themselves, okay. And kind of see bourbon going here that this creates a multiplier type of effect. And it also allows compounds token these c tokens to be used in other defy protocol. So it’s possible for example if somebody wants to use less a eth for collateral, they can also use ce three which represents a token that’s linked to a vault that’s got some eth in it. Okay, so very nice idea. And these tokens can be traded, right? So you can have ce eth and eth that are being traded. DAI and C DAI. Okay, so it opens up many possibilities here. So let’s go through a few examples the best way to see what’s actually going on. So in this case here I’ve got 2000 DAI and the compound DAI market and a total of 500 c DAI which represents the ownership in the market. So the ratio of cd to DAI doesn’t really matter that much as I’m going to show you. So on the left we see that there are 2000 died that’s the total supply. The one C DAI equals four DAI. And in this particular example we’ve got to depositors and one has 375. The other 125 and this is basically 500. So in this particular situation you’ve got 2000 DAI. There are two traders in this particular market and their shares are 75 and 25%. Okay so that is kind of where we start. So let’s say that another trader comes in and deposits 1000. So previously we had 2000 DAI remember we had 2000 DAI and trader a represented 75% of that and try to be 25%. So now somebody else comes in and we raised the total supply from 2000 to 3000 DAI. So again one C DAI equals four on four DAI. So the new there will be some more c DAI created. So we started with 500 c DAI. So an additional 2 50 are created and you can see that traders C has 250 and 200 and 50 of 750 is 33%. And again this makes sense. So this is keeping track of the accounting here for the ownership of the supply. Okay so I think if we started with 2000 DAI, somebody else comes in trader c. And increases the supply to 3000. Well the 1000 to 3000 that’s 33%. And that’s exactly what’s happening here. So within the CDAI the trader has 33%. So what’s the next step here? So suppose that there’s interest that’s accruing. So within the supply of 3000 DAI suppose there’s interest occurring at a rate of 10%. And let’s go through a year. And at the end of the year the supply pool will be worth not 3000 DAI but 3300 DAI. So what does that mean for the c token holders? Well the number of c tokens has not Increased. There’s 750 c tokens. But the value of the supply has increased. Okay it’s increased by 10%. So the new exchange rate is not one C DAI. Equals 4.4 DAI but once he di equals four 0.4 DAI. And if you look at the shares so the shares haven’t changed. So you can see that for example trader C. Who has 33 of the pool. Well what is there? 33% worth? Well 33% of 3300 DAI is 1100. So again they put in 1000 DAI. And now after the 10% is paid they get both that supply and the interest and 10% interest is it comes to 1100, okay. So this is a very elegant mechanism to keep track of basically the shares and the value within the pool. So again the C DAI that you get after supplying the DAI. The C DAI can be deployed somewhere else. So it’s no use just sitting on the C DAI when you could potentially deploy it to another protocol and potentially use that to earn an extra rate of return. Or you could use it as collateral for some other protocol. And we’ll talk about dy dx within this course also or swap that there are many different possibilities here to actually use this.

04_compound-governance.en

Okay, let’s talk about governance and we’ve talked about this briefly but within compound there’s a decentralized governments mechanism, there’s many different parameters that the governance controls. So the collateral factor that we talked about in detail, the reserve factor, the base rate, the slope the kink all of these parameters can be fine tuned by the governance. Okay, so again this is a decentralized governance and the governance has the incentive to do things that are the best things for the actual protocol. If they don’t do that, then they will lose out to the competition. So it’s really important to realize that the governance can’t steal funds r block users so you can’t blacklist anybody, this is open to everybody and the parameters that they can control are limited. So for example a parameter, there’s no parameter that says the divert the funds to the governance because people would never use compound if that was the case. Now, it’s interesting that early on and compound the governance was controlled by the developers and this again is kind of common and many tech startups that the debs have a lot of control over the protocol because they anticipate that there could be some issues that need a fine tuning. So this was definitely the case but it was important that the compound realized that this had to be a short term mechanism so all along they planned to go completely decentralized and it is completely decentralized today. So again it’s important within the space of deep I to avoid centralization, which could lead to arbitrary moves the blocking of certain addresses and things like that. So compound implemented their new decentralized governance in May of 2020 with the cob token and implemented it in June of 2020, the so called seventh governance proposal, I mentioned this detail because it is important, it is a model of how decentralization actually happens. So what’s very interesting is the comp token was distributed to the loyal users of the actual platform. So those that were supplying those that were borrowing got basically an airdrop of comp token, and the amount that they got was basically based upon how much volume they were actually doing. So the early users of this platform got a bonus in terms of the comp, so comp is very similar to make her the MK our token, both of them are governance tokens. So this is interesting, it’s analogous to a tech company and kind of traditional economics giving away its own stock to the early users of the company’s goods or services, so very easily done within this particular protocol. It would be difficult to do this in a regular economic system but very easy to do within decentralized finance. So that’s not the end of the story. So the comp token continues to be used to incentivize people to use the platform. So this is distributed to both suppliers and borrowers. And for the borrowers it acts as a subsidization of the loan. So the supplier is getting a supply interest rate and they will also get a bonus in the comp token. So that will just increase the rate of return that they actually get. Indeed some of these claims. Very high rates of return for depositing in defy protocols. Well, it’s not just the savings order deposit rate that you’re getting. You also have to factor in the value of the governance token that you’re also receiving. And it’s also the case that you’ve got borrowers that the rate on borrowing is considerably reduced as a result of this subsidization. So it’s interesting this was done almost instantly the comp the governance token had a market cap of over $2 billion. Okay, so this meant we had this very strange situation that some people that were borrowing the amount of comp that they were getting as a bonus for actually participating in the protocol was sometimes greater then the cost of borrowing. So think about that. So again, this is hard to think about in a regular system where you borrow money from the bank and you have to pay the bank. Let’s say 10%, but then the bank pays you a bonus of 15%. So effectively the bank is paying you 5% at the bar, okay. So again this is something that really incentivize people to use the actual platform. So this is interesting this protocol, it exists within the Ethereum Blockchain. This is not something that can be turned off, it might be that a better platform arises, it might be the compound actually offers something that’s better. But this is a very important mechanism within this space and there’s so many possibilities here. I talk about, yeah, in the previous course, I talked about a fair lottery and this is exactly possibility using A protocol like this. So the usual a lottery 50% at least is taken for overhead and for other purposes you can easily create something very powerful within the system. So let’s finish off and to the usual job that we do, looking at what compound actually does to solve problems. So again, centralized control, this is not decentralize. It is something that is completely decentralized. The rates that are paid. Both the supplier and borrowers are algorithmically determined and the parameters are controlled by the governance token, the comp limited access. Again, this is a common thing that you need to do credit checks and some people are blocked. This is open to anybody, inefficiency. Well, we’ve got rates and traditional finance that are way too high for borrowing and savings rates, you’ve heard me say so many times are way too low. And this actually pools everything together and determines the optimal interest payment. And that means the suppliers get a higher rate than traditional finance and borrowers pay less. I lock up interoperability. Well, these positions within compound are tokenized in themselves with the c tokens. The the share of the collateral is freely traded and can be used in other protocols. So this is exactly what we’re looking for in terms of interoperability. And just think about how impossible that is in traditional finance and opacity. Well, everything in this protocol is transparent so we know anybody can see the collateralization ratios, anybody can see the parameters that are actually being used. This is completely transparent and a very important idea within the DeFi ecosystem.

03_aave

01_what-is-aave.en

The third protocol that we’ll take a look at within credit and lending is called Aave. I’ve got a very nice example of a refinancing in this module so we’ll be able to see the mechanics of how something like this actually works. Aave launched in 2017 so it’s been around a while. I know that doesn’t seem a long time but this is actually a long time within a decentralized finance. It is also a leading protocol and it’s similar to Compound. At this point in time, at least there’s more tokens to supply and borrow within Aave. Aave is also got something that’s interesting in that the rates for borrowing and supplier are more predictable. We’ll talk about that to some degree. For example, we already saw in Compound that it is possible as the utilization ratio increases, so that could greatly increase the rate of interest cost. Aave offers something a little different in terms of this. Think of this as two markets. The first is more conventional ERC-20 tokens, very similar to Compound. We’ve got the main assets, Ether, USDC, the stablecoin that’s guaranteed by Coinbase and DAI, which we’ve talked about in this course in considerable detail. There’s also another market that’s specific to the Uniswap UNI token. Uniswap is next. The next module is on decentralized exchange and we will go through a lot of detail in terms of what Uniswap actually does. The LP token. That’s LP for liquidity provider. This will be something that can be used in terms of the Aave protocol and other DeFi protocols. It’s another way to generate returns. Aave also offers flash loans. The fee for the loan is nine basis points, so that’s 0.09 of a percent. That’s pretty cheap. Remember, we talked about these loans that they’ve got zero duration and there’s no obvious counter-party risk. Nine basis points, it seems cheap. It is cheap. But I predict that these rates will go down. Indeed, by the time you’re actually viewing this, the rate might be lower, and we’ll explore the reasons why. Where does this fee go? The fee goes to an asset pool and provides additional returns to the suppliers. It’s not like dividend it out. This just goes in as an extra rate of return. The flash loan is going to be very useful in terms of giving users the ability to access capital very quickly to do what they have to do. That might be an arbitrage trade or it might be a refinancing. Let’s go through some examples. Suppose the price of ETH is 200 DAI and then a user supplies 100 ETH in Compound and borrows 10,000 DAI. I know we’re talking about Aave, but we’re going to start this example with Compound. There’s a loan right now for 10,000, and it’s possible they can lever up and purchase an additional 50 DAI and then they use that also to supply in Compound. Now, suppose the borrow interest rate in DAI on Compound is 15 percent but in Aave, suppose the borrower rate is only five percent. You’ve already done the loan with compound, and you’re paying 15 percent. There’s a cheaper possibility at five percent. Our goal here will be to refinance the borrowing, to take advantage of the lower rate offered by Aave. This is very analogous to refinancing a mortgage. The rate goes down, you want to refinance. But in traditional finance, as I’ve already described, that takes a long time and it’s awkward to do. Let’s go through some of the mechanics of a refinance. One possibility is just to manually unwind each trade on compound, and then do the trades again on Aave, and reconstruct the levered up position. That’s possibility to do. That’s in two steps. It will take two transactions, at least to do that. Of course, we need to deal with the transaction fees that are associated with that. The other possibility, is to use a flash loan, and to do this all together in one step. Let’s actually go through the mechanics here. I’ve got a diagram for this, but let me just tell you the basic idea what’s going to happen. What we’re going to do, is going to take a flash loan from Aave for 10,000 DAI. We’re going to use that loan to pay down all the debt in compound. We will withdraw the 250 ETH from compound. We will resupply to Aave, and at a five percent annual percentage rate against that collateral to repay the flash loan. We borrow from Aave, and then we’re going to repay the flash loan. The latter approach basically, skips a lot of exchanging, and does this in one step. Let’s take a look in a little more detail with this particular diagram. Before, we’ve got a 150 ETH as collateral, we’ve got a loan of 10,000 and an interest rate on compound of 15 percent. What are we going to do? The first thing we’re going to do at the bottom, number 1, is initiate a flash loan on Aave, and that will be 10,000 DAI. Step number 2, we will repay with the flash loan, the loan that we’ve got at compound. When we do that, we reclaim our collateral. Step number 3, we reclaim the 150 ETH. Number 4, we will deposit the 150 ETH in Aave, and then we will use that as collateral, to borrow 10.000 DAI, against the ETH. Then the final step, is to close the flash loan at 10,000. This is extremely interesting, because this is a single transaction, and what we have done, the transactions got many steps. It shows the possibility of going from one DeFi level, to another. We’re using both compound, and Aave. Essentially, we’re getting a flash loan with no collateral, with no credit check, and the loan has got zero duration, because it actually happens to be taken out and paid back in the same transaction. Again, there’s a small fee that’s associated with this that I’m abstracting from. But this is a way to refinance, to get a lower rate, and it is very elegant. Later in the course, actually in the fourth course, we will talk about a much more elaborate transaction that goes not just between compound and Aave, but has got 63 different steps to it. But this is a simple example, of what actually is possible within this protocol. This is our introduction to the mechanics of a flash loan.

02_stable-loans-and-credit-delegation.en

The second thing I’d like to talk about with Aave is this idea of stable loans and credit delegation. The first thing, let’s be careful. Aave offer something that is more stable than less a compound but it isn’t fixed. You can think of a fixed rate loan that you might get for example, a mortgage might be a fixed rate. You could also have the variable rate mortgage. But we’re not talking about fixed rates, we’re talking about stable rates. The idea is they’re relatively stable, so the word choice is important. This is not a fixed rate. Basically, we can imagine a situation where the borrower has the option to switch between a variable rate and the current stable rate. The supply rate in contrast is not stable. It is always variable. It’s really impossible to imagine a model where the supply rate is a fixed rate. The supplier obviously will earn the revenue that comes in from the stable and variable borrowed interest rates. Of course, there could be fees that are deducted from that and other things. But the basic idea is the same as we’ve seen before. Again, the stable rate is not a fixed rate. There is adjustment and extreme situations. If there’s liquidity crunch then there will be an adjustment in the rate. But the idea is that it’s just a little more stable than something that in other protocols you would experience. There is another idea in Aave and this has to do with credit delegation. The idea here is that users can allocate collateral to potential borrowers who could use it to borrow an asset. Everything we’ve done so far, you’re actually providing the collateral. For instance, in traditional finance I’ve got a house, I pledged the house and I take a home equity loan out, so I’m pledging that collateral. There’s a different type of loan in traditional finance where you don’t necessarily pledge that collateral, a line of credit or something like that. Well, everything that we’ve done in decentralized finance has to do with fully collateralized or over collateralized borrowing. The idea in Aave is that we can retain the idea of over-collateralization but enable a possibility where somebody effectively provides the collateral for the uncollateralized borrower. Maybe this is the case that you know somebody and there is an element of trust here. This happens outside of the Ethereum blockchain but it is a way potentially to earn some extra funding. You can imagine that a delegator because they are basically pledging this collateral for somebody to borrow, there is some risk, of course, that there could be a default and they are not paid. But it’s important to realize that, that default doesn’t impact the protocol itself because the protocol is still going to be over-collateralized. Essentially something is happening outside with some level of trust that enables those that want to delegate their credit to earn an extra rate of return. This is a very interesting idea and one thing that has been lacking in the DeFi space is this idea of having people borrow without having the collateral. The flash loan is an exception here because it happens all within one transaction. It has got zero duration. What we’re talking about here is having people being able to borrow within DeFi that don’t have the actual collateral. This delegation is a way for this to actually happen. Overall Aave it’s pioneered flash loans and this provides extra returns to their liquidity suppliers. It also attracts a lot of business to Aave for those that are doing arbitrage. We talked about a simple arbitrage where you could reduce the loan rate from 15 percent to five percent in our example but there could be other types of arbitrage that are available out there and flash loans are extremely useful in capitalizing upon that type of arbitrage. Aave also offers relatively stable loans in terms of the rate and this idea of delegation. A lot of stuff within this leading protocol. Let’s look at the traditional problems and what Aave is doing here. On centralized control, we’ve got rates that are algorithmically set but had the possibility of being relatively stable. Limited access, now we’ve got the flash loans which are the ultimate democracy in finance where anybody can take one of these loans for arbitrary amount as long as it’s paid back within the same transaction. Inefficiency again, very similar to these other mechanisms where there’s maker or compound that we’re algorithmically pooling the assets and optimizing the interest rates. By that it means that the suppliers are getting a reasonable rate of return and the borrowers are paying a reasonable borrowing rate, much different than centralized finance. Interoperability, a problem obviously in centralized finance. I showed you an example with the flash loan where we just seamlessly within one transaction went from compound to Aave. These are interoperable and of course, transparency. Everything is open, so anybody can see what is happening. The parameters are visible, the balances are visible, the collateral is visible. All of the steps. The flash loan that I showed you, you can literally click on “Etherscan” and you can see all of the steps. It’s very clear. This is a very transparent mechanism as is all of decentralized finance.

02_decentralized-exchange

01_uniswap

01_what-is-uniswap.en

In the second module, we’re going to be talking about decentralized exchange or DEX. Most of the discussion will be focused on the leading DEX, which today is Uniswap. What is Uniswap? We’ve actually been introduced to Uniswap in the previous course in terms of defy preeminence. I gave you an example of a constant product automated market maker. Uniswap is basically the prime example of the automated market maker on the Ethereum Blockchain. We will talk about version 2 of Uniswap. There is a version 3 that I will also talk about and the differences between version 3 and version 2. But I think it’s important to understand version two before actually going to version 3. Again, the example that I used in the previous course used a constant product rule. In the previous course, we had a situation where we had 10 of one coin, 10 Ether, and 1,000 of another coin, let’s say USDC. The key was to multiply those two together, and we got 10,000. That is something that will be fixed. The algorithm, so in this formula, the k is going to be fixed. I showed you examples of how this constant product, an automated market maker actually worked and we’ve got plenty more examples in this module. Again, the product is denoted as k. It’s the lingo and DeepAI. This is called the invariant. It remains fixed. The AMM is risk neutral, and what I mean by that is that it is not aware or doesn’t really care if you’re buying or selling. This is a completely different than traditional finance, where there would be a market maker and that would be a person, and they would definitely care whether you’re buying or selling and they’ll be different prices. This is a very interesting idea, and it’s a very simple idea, and literally just the tip of the iceberg in terms of what can happen in this space. Because we’ve got this constant product, k equals x times y, we also have the exchange rates that are set as basically just the ratio of the x and the y. Let’s go through a number of examples and these are very simple examples, to give you the idea of what’s happening. Let’s think of a Uniswap pool where we’ve got two stable coins, DAI and USDC. As with any Uniswap pool, you put in the same value in terms of the pair. These are both linked to the US dollar. Four DAI equals four USDC. In this situation, the invariant or the product of the supply of DAI and USDC is 16. The exchange rate is just one to one. The invariant, you can see how that’s calculated. This is where we start. Now this is an example of a pool of liquidity that is really sparse. This is just for an example, we’d never have a pool with so few DAI and USDC. It doesn’t make any sense, but for the illustration, let’s actually go through and look at the mechanics. Suppose that you wanted to sell four DAI for USDC. That’s, we’re going to use our DAIs. We’ve got somebody that wants to sell four DAI. We’re going to use the automated market maker. We’re going to deposit the four DAI to the contract, and it turns out that you can only withdraw two USDC. Again, look at the mechanism here. An additional four DAI had gone into the contract, so we’ve got a total of eight. We need to maintain the invariant. The invariant is 16. The only way to maintain the invariant is to have two USDC. Only two USDC are able to come out of the contract when you deposit the four DAI. This is essentially how this works in a very simple way, and you can see that that’s a very considerable decrease in value. Notice that the effect of exchange rate here was two DAI for one USDC. Again, this is, we sometimes call a slippage, but this is really the result of insufficient liquidity in the pool. This is an example of something that really doesn’t work. The mechanics work, but it doesn’t make any sense that it would take two DAI to buy one USDC, certainly not on the open market. Now let’s change the example a bit. Let’s add some additional liquidity. Even this amount of liquidity is too small, but I want you to see how it transforms the situation. Now let’s say we’ve got 100 DAI and 100 USDC. The invariant now is much larger. Previously we had 16, now we’ve got 10,000. Let’s do the same transaction. Somebody wants to sell four DAI for USDC. Again, they deposit four DAI into the contract, and what they’re able to pull out according to the algorithm is 3.85 USDC. You can see the mechanics in the box below, that if you look at the invariant, which is 10,000, we now have 104 DAI, and the only way that we can maintain the invariant is to have 96.15 of the USDC. That’s where the 3.85 actually comes from. You can see that that’s way different than the previous, that the slippage here is effectively going from four DAI to 40 USDC, the slippage goes from four to 3.85 USDC. It’s a smaller amount, but still it’s large. Why I don’t have the example here, you can probably see where we’re going here, that if it was the case that instead of just 100 DAI and like 100 USDC, that we have millions in this pool. The slippage is going to be really, really small. This is really important here, that liquidity is crucial. If there’s deep liquidity, it’s going to minimize the slippage. The slippage is the amount that the exchange rate will actually be changed by the actual trade that you’re executing. It’s important to have these for the success of a decentralized exchange like Uniswap, to have sufficient liquidity. In the big picture here, decentralized exchange is a competitor to the centralized exchanges like Coinbase and Binance and Kraken. For the decentralized exchange to give the user a good experience, it’s important to minimize that slippage or to maximize liquidity in the pool. Indeed what Uniswap does is, incentivizes depositors to supply the capital. You provide capital, you’re incented, there’s lots of capital. There’s minimum slippage and the decks becomes much more competitive or even superior to the centralized exchange. Then notice that the liquidity provider is adding to both sides of the market, when you set this up, you put an equal amount of liquidity at both sides. There’s a number of different layers in terms of the importance of liquidity, basically when additional supply comes in, this will increase the liquidity and decrease the slippage. The higher the invariant is, then the lower the slippage. You can see, you can indeed graph it out to show the amount of slippage as a function of the invariant. The invariant, you can think of it differently, is a direct measure of liquidity and this particular protocol. Within Uniswap there are some fees, there’s a 0.3 percent fee and that fee is paid back into the pool. This is a fee that those that are providing the liquidity, providing the supply, they’re going to earn the fees based upon their contribution to the liquidity pool. You can imagine what’s happening here, there can be lots of trading on both sides, buying and selling, and the more activity the more fees that are being generated, and the more that goes to the suppliers of the liquidity. Ideally, if you’re supplying liquidity, you would like to actually go to a pool that’s got a lot of volume, a lot of turnover. This mechanism is very similar in terms of what Uniswap does to the cToken that we discussed with compound, you’re providing liquidity that needs to be a share of the pool and to see, we’ve got Uniswap own version of this. Think of a DAI, Ethereum pool as having a Uni token that is DAI/ETH. It’s a little different, but the same basic idea, in terms of the Uni token.

02_impermanent-loss.en

We’ve introduced the idea of impermanent loss before and let’s actually go through it again in the context of Uniswap. Again, the idea here is liquidity providers. They supply the capital. Because of the nature of this constant product automated market maker, there will be some impermanent loss as the exchange rate actually changes. We went through some calculations before as to how this works. Even though the liquidity providers are earning, a rate of return based upon the volume of trading within the pool. There’s also a cost associated with this in terms of the impermanent loss. Let’s go through that again we went through it quickly in the previous course. The impermanent loss is an Opportunity Cost. It is the amount of money that the liquidity provider would have made if they didn’t pledge liquidity to the liquidity pool but just sat on it. So it’s an opportunity lost. It will happen anytime there’s a deviation from the initial market price, ratio for the two, and the only way that there’s no impermanent loss is if that ratio stays the same. That’s essentially important for impermanent loss. Again, the fees hopefully will overcome the impermanent loss but nevertheless, this is one of the downsides of any constant product automated market maker. One way to reduce impermanent loss is to look at pairs that are highly correlated. When the pairs are highly correlated are mean reverting, then there’s going to be not that much deviation and exchange rate and the impermanent loss is going to be very small. The examples that I used in the previous course were dramatic examples where something went up by 400 percent and something else went up by 200 percent. It’s a huge gap between the performance. Literally, one of the pairs doubled relative to another pair. If you think of a low volatility or high correlation pair, like DAI and USDC, that’s just not going to happen. The impermanent loss is very low for a very highly correlated pair. Impermanent loss is something that is well-known in the space, so people providing liquidity understand impermanent loss. They understand that they need to take that into account in factoring and what the expected rate of return is. They also understand that high correlation pairs, minimize that and there’s some protocols that just focus on high correlation pairs. But the problem is that people want to trade cryptos well beyond the high correlation pairs. There’s only so much you can do with USDC and DAI. This impermanent loss is just something that we have to deal with. Essentially, almost any ERC-20 pair is possible on Uniswap. This is super interesting that anybody can start a pair, so ERC-20 to ERC-20. You’ve got a new token that you’re introduced, well, you can seed it in a Uniswap pair. It’s instantly available for trade. Think about that in traditional finance. How difficult it is to actually get a stock listing. Only a very small number of companies can actually do this, and they have to go through a very costly process to actually be traded. Well, with Uniswap, it’s immediate. You can actually just create a liquidity pool and it might be that you’ve got a new token, you create many of these pools, and it’s available for trading in terms of this decentralized exchange. One thing that’s interesting is that this is designed for all ERC-20 tokens and Ethereum is not an ERC-20 token. These tokens are based upon the Ethereum Blockchain, but Ethereum isn’t an ERC-20. Is that a problem? No. Because there are wrapped versions of Ethereum, so w-ETH. We’ll talk about wrap versions a little later on, but it’s just a way to tokenize Ethereum. There’s a wrap version of Bitcoin also that operates as an ERC-20 within the Ethereum Blockchain. Indeed, that is the one we’ll talk about a little later. Within Uniswap, the way it works is that if you’ve got the Ether, you can actually use it, but it’s immediately translated into the wrapped version of ETH, which is the ERC-20 tokens. Router contracts, that’s one of the words on the word cloud that we’ll reveal at the end of this course. How is this useful? Well, it might be that you want to trade a pair that isn’t available on Uniswap. You want to do AB, but AB isn’t available, but there is an AC and there’s a BC, so effectively what you can do is to triangulate and find the best route through the different pools to get the exchange that you actually want and this is done with a router contract. Even if the pair isn’t offered, that doesn’t mean you can’t trade it within this decentralized exchange, you just need to employ a router contract that can do this very efficiently. We talked a little bit about front running previously and I want to go back to that. This is an issue with automated market-makers, it is an issue with proof of work in general, in that the miners can see all of the pending transactions. It could be that there’s a pending transaction that takes advantage of an arbitrage opportunity, maybe it involves a flash loan. Well, the miner can literally just copy that transaction and put that into the candidate block that they’re mining and effectively front run. Again, I want to emphasize that this type of front running is not to be confused with the illegal front running in traditional finance. This is not illegal because all of the information is publicly available. This is public and the miners are willing to do this, but they want to do this because this is a way to increase their revenue. Again, this is a downside proof of work that will likely be mitigated in the future when we actually go to a proof of stake type of model. I also want to emphasize that it’s not a sure thing, that the miner might front run, but the miner might not win the block and if they don’t win the block there’s no front running. The problem exists when many miners are doing the same thing, they see the same opportunities. Again, the memory pool of all the candidate transactions is open for anybody to see, is very straightforward, you need a browser you’re in and you can see all of this. This is their game within this particular system. Uniswap also offers something interesting, which is maximum slippage. Essentially within the transaction, you can say that if the rate slips to anything below x, then don’t execute the transaction. This is easily done and essentially it is a check in the contract and if the condition where the slippage is above the maximum, then the transaction remember is atomic and it doesn’t actually do the trade, so we revert to where we were. That’s a nice idea within this idea where you can specify a level of slippage that you’re comfortable with and it provides a degree of risk management that’s important. There’s lots of possibilities here for arbitrageurs because there’s so many of these pools that are available, that you can imagine I told you about a router contract that if you’ve got a pair that isn’t traded, you can find other pairs to triangulate and effectively trade. Instead of just running on one liquidity pool, you have to do multiple. Well, there’s also this possibility of seeking out arbitrage possibilities given the network of all of these exchange rates. This is maybe a drawback, but maybe not because the arbitrageurs are making sure that the prices are what they should be, and they shouldn’t deviate, there shouldn’t be any arbitrage, and just the act of arbitrage is actually making those prices more fair. But nevertheless, this is something that essentially the arbitrageurs are profiting at the expense of the liquidity providers and ideally you want the prices set in a way that minimizes this possibility. Of course, a lot of liquidity is very helpful, but there could be some pools that are illiquid that cause issues and an arbitrage obtains.

03_flash-swaps.en

Next we’re going to talk about a flash swap. We’ve talked about flash loans. What is a flash swap? Basically flash swap is a contract sends tokens before the user actually pays for them. A swap is just an exchange, but this is a little different than a flash loan. There’s a lot of possibilities and terms of deploying this idea where you can essentially deploying liquidity to acquire another asset and get this basically before paying for it. Again, this is going to have zero duration, it’s all going to be within one transaction, but it opens up many possibilities here. It’s swap because we’re going to be operating with not just one asset. The swap is an exchange of one asset for another. A loan is always the same asset. Let’s go through the details and mechanics of a flash swap. Again, this is much different than the flash loan because a loan needs to be repaid in the same asset. I borrow 10,000 DAI, I need to pay back 10,000 DAI. The swap will be with different assets. Again, it’s in a single Ethereum transaction. It’s going to be atomic just like the flash loan, but it’s a very interesting idea that happens on Uniswap. Let’s as usual go through an example. Let’s say we’re talking about the DAI/USDC market that we’ve talked about before. It’s a high correlation market, not that much impermanent loss. We’ve got a supply of a 100,000 each. This is a large K, so the invariant is quite large here. Having a 100,000 each means that the exchange rate is one to one and the invariant is 10 billion. A 100,000 times a 100,000. In this situation we’ve got a trader that has no starting capital, that’s important. It’s like a flash loan. Remember that the flash loan, there was no collateral for it. For this flash swap, the same thing, just no starting capital. But they see that there’s an arbitrage opportunity to buy DAI on another DEX for 0.95 USDC. You see the possibility here, if I can buy for 0.95 USDC, and then sell for one on this very liquid Uniswap market with the invariant of 10 billion, then this is an arbitrage opportunity. Let’s go through the details of how this works. It’s going to involve the flash swap. What we’re going to do, and I’ve got the diagram that explains this, that we’re going to withdraw 950 USDC, a flash liquidity. Indeed this is derived from a flash loan. We’re going to do this from the DAI/USDC market and then purchase 1000 DAI via the arbitrage trade. Then we’re going to repay 963 DAI and end up with a profit. The 963 is going to be calculated as the 960, and I’ve got rounding of course. We need to maintain obviously in the invariant of 10 billion and there is some slippage as a result of that. This is not without slippage. Let’s actually go through the mechanics again. There will be 30 basis point fee that’s going to be paid into the pool and let’s see how it actually goes. So from Uniswap, step number one, we’ll flash swap 950 USDC, and then we’re actually going to trade with that USDC. We’re going to trade with this alternative DEX. Notice the alternative DEX, the exchange rate is 0.95 USDC for one DAI. 950 USDC is going to get me 1,000 DAI. I’ve got the 1,000 DAI I get from the DEX in step number 2. Then I close the flash swap with 963 DAI. The slippage here is 10 DAI. There’s a fee of three DAI, and this means that the swap is done at 963. Think about the profit here, the profit is 1,000 minus 963, which is 37 DAI. This is all done in one transaction and it is arbitrage because you make some money for not taking a lot of risk. Again, this is atomic at any point if something fails, then we return to the original state.

04_governance-and-uniswap.en

Okay, what about the governance, being a swap and I previously mentioned that we were talking about version two, what is version three? So let me talk about that, so Uniswaps basically has a governance token called UNI, and that was launched in September 2020. So the governance token very similar to COMP and that it is actually distributed to users to incentivize liquidity. So this is something that you get for actually supplying liquidity. So think of this, we’ve already talked about that the liquidity providers are making revenue from the trading that actually occurs with that 0.3% fee. They might be losing in terms of impermanent loss, but they are also gaining because they’re being incentivized with the UNI token. Okay, so this is interesting that the UNI governance has some control over its own token distribution. Okay, so 43% of the supply is going to be vested over four years and there’s a treasury that’s controlled by the UNI governance. Okay, so it’s interesting that every Ethereum address that had used Uniswap before the cut off date, and this was like a quarter of a million addresses, was given approximately 400 of these any tokens, so again, an airdrop. So again, this is a really interesting idea that’s really important in decentralized finance, that the early users are being rewarded with effectively something like equity and at least the governance. So you’ve actually participated, and now we want you part of the community to determine the sort of things that are important in terms of the protocol and it’s also a direct incentive mechanism to get people actually involved. So UNI was released, is traded also on centralized exchanges like coin base, and indeed you can see a the governance token for Uniswap here is incredibly valuable. So think of that 400 UNI given the current market price, that’s quite a reward for participating early. And it’s also the case that the AAVE and the Maker Token also are quite valuable. So if you look at the list of the top 25 Cryptos by market capitalization, you’re going to see a number of governance tokens. So what about version 3? And version three is very recent, this was implemented on May 5, 2021. And let me tell you the key idea in version three, and the key idea is that the liquidity providers can allocate funds to their own customized range. Okay, so instead of having the full range when you allocate liquidity, you can actually narrow it. So effectively you’ve got these individualized price curves. So this is a great idea, and it’s a great idea because it’s very similar in traditional finance to this idea of a limit order system. Now, for the user, everything is all grouped together, so the user doesn’t see this, but for the supplier of the capital, you can choose a range that is something that you’re comfortable with. So again very much like a limit order book. So very good idea, as of this production, it’s still the case that the most of the pairs are version two, but the volume on version three is already exceeded of version two, so this is just the next stage and the evolution of decks. So let me summarize, this is a critical component of the DeFi ecosystem, so the ability to trade algorithmically at any time. So it doesn’t matter when you do this, the ability to basically supply liquidity and get paid for it in terms of the trading fees that you get plus the incentives from the governance token. And this idea of a flash swap, which is a very significant innovation. So this is something that allows essentially anybody to do arbitrage. So again think of this and look arbitrage is well known, who does arbitrage, like hedge funds? So it’s just not usually available to the average person. But this is again the democracy of decentralized finance, that if you don’t have any capital, no big deal, you can make that arbitrage profit. And in doing that, in doing this arbitrage, the prices move towards like a fairer price, which is good for everybody. So again, let’s see what, Uniswap actually does in terms of the problems perhaps the most striking thing, at least for me, is that, that anybody can start a trading pair, that’s to me just really amazing. So you’ve got a new token, well, no problem, you can use Uniswap, and you can see the liquidity pool, and you can do it very quickly. Okay, so this is so different than centralized finance. Of course, anybody can be a liquidity provider and earn the fees and the incentives. The automated market maker, or decks, is a very significant innovation in the idea of exchange, you get rid of the human market maker, you get rid of all of the infrastructure associated with that, you get rid of the spread, get rid of the risk, so this is a very powerful idea. And this is pluggable into any application within the Ethereum landscape. Again, and I showed you an example of using an alternative decks, and in a single transaction, taking advantage of a price deviation. And of course, and it’s becoming a little redundant, everything is transparent, so for the pool, you know exactly what’s in it at any point in time

02_balancer-and-rehypothecation

01_balancer.en

So with the in a swab you’ve got a pair and when you supply, you supply the same amount in terms of dollar amount for both sides. So that’s kind of how we went through, you know swap. And it’s a very simple formula in version two where we’ve got X x Y = K. In K C and variant. So X is the number of tokens for assad x and y is the number of tokens for assad Y. So, it’s no surprise that given that this is a very basic sort of system that somebody would come up with an idea to generalize. And that’s what balancer actually does. So balancer is decentralized exchange. Its automated market maker just like a you know swap. And basically what this protocol is able to do is to do more than two assets in a liquidity pool. And at the time of production It was eight assets. So and these can be ERC at 20 tokens or ethereum, okay? So, this is an innovation that generalizes to this initial structure by you know swap. So how does it actually work? And let me show you. So the formula is is basically defines a bonding surface. So the formula that I showed you for, you know swap is a simple bonding curve. This is a this is a bonding surface. And the idea if you can see that formula is that the Bs represent the Balance of the tokens and there can be more than two tokens. But if there were only two tokens it would just be token X and token Y. Basically X x Y. That operator that says V equals that’s a product operator. So you multiply thanks. So in the simple example of a, uni swap you would have X x Y = K. In this situation we’ve got an exponent that represents the weight of the token. So if there was equal weight then it would just be X x Y = K. But the exponent allows for differential weights in terms of the assets that are contributed to the liquidity pool. So again you’ve got the in variant but the in variant is a more complex function. So the surface that I’m showing you here is for three assets in a pool rather than tool. But we can’t do this diagram for eight. But you see the idea. So the idea basically is instead of X x Y, we can have X x Y x Z. And then we kind of differential sizes of supply and that’s going to be determined by exponents on X and Y and C. So this generalizes the formula in uni swap and it allows for a pool to have multiple assets with different sizes. So this is basically a mechanism to get exchange rates but I can figure out the pool value. This all obtains with this fairly simple mathematical formula that is just a little more general. There are some issues here. There are some limits in terms of the amount that you can swap and a balance or a pool and what you can put in, what you can put out. There are some limits that actually doing this. And there are transaction fees and the liquidity pool controllers. So those that kind of see that can can set the fees so the fees might be really, really cheap or they could be pretty expensive. So this is part of that protocol also. And it’s also the case that in permanent loss is an issue. And the it’s interesting in the balance or paper that I’ve got referenced at the bottom. They look at different weightings and determine how these weights contribute to the impermanent loss. So, this is overall like a good idea. Of course there are there slippage as we would have with any automated market maker. We’ve got the order routers, like we’ve got with uni swap all of this is part of this really growing kind of interest and decentralized exchange and making it as efficient as possible. So not surprisingly, balancer also has a governance token the BAL. And there’s a limit to that token. And I’ve actually detailed where the token is allocated, so the founders getting one quarter of the balance. But a substantial amount, 65% is allocated to liquidity holders. So this is also an incentive mechanism. So like all of these D five protocols, you’ve got disability to incent people to use the protocol and balance, or does that with the BAL token.

02_rehypothecation.en

Let’s finish up this second module and I want to talk about something that we’ve talked about indirectly but I want to be much more specific and this is the idea of rehypothecation. This is a concept that is very well known in traditional finance, but it’s important to understand in the context of decentralized finance and it can help but use an example. We’ve talked about having collateral and if you’re borrowing, you need to have collateral and we’ve gone through examples of what happens if you go below your lateralization ratio, the keepers will come in and close you out. I want to contrast that with the high profile situation that happened in 2021, with the large Family’s authors that essentially they went under because they were under collateralized and there was no automatic mechanism. Let me start this with a quote from a description of Archegos situation. It is remarkable because it really shows the difference between centralized finance and decentralized finance so I’m actually going to read this and this is from Matt Levine. ”Once you know the right amount of collateral, and you call up the hedge fund to tell it to post more collateral, and then the hedge fund says, ”I’m busy today, let’s talk tomorrow”, and then you call them tomorrow and they say, ”Hey, this week got away from me, but send me an email”, and you send them an email summarizing your collateral demand and call them next week and they say ”Oh, I haven’t had a chance to look at your email yet, but I will very soon”, and meanwhile, the right amount of collateral keeps ticking up. What do you do about that? There is a theoretical and contractual answer, which is if the client doesn’t post the collateral you want, then you terminate the swamp, but you are the person and the hedge fund does sound really busy, and surely it can’t hurt to talk to them tomorrow? Plus if you terminate the swap you lose their business, and your whole job is about doing more business.” This is a powerful situation where investment banks lost billions of dollars in this particular blow-up. It was clear what the collateral needed to be. It was clear that the hedge fund or Family office was underwater, but there was no mechanism, was it email, phone call delay, delay, delay so that’s much different than decentralized finance. Let’s talk about rehypothecation and what does that actually mean? Hypothecation is simply pledging collateral, so just a fancy word for pledging collateral, for debt so you might pledge your house for mortgage debt. That’s an example, or a factory might pledge their plant for some debt from the bank. Rehypothecation is when the collateral that you post to the bank or the brokerage is actually re-used by the bank. This idea of reusing collateral is called alone history and sometimes this is called re-pledging. Sometimes it’s called re-use of collateral and within centralized funds, there are specific rules that you need to follow regarding this re-use of collateral, in particular, the Fed Regulation T. Of course, in the space of decentralized finance, there are no rules. There’s no centralized authority that’s regulating anything and decentralized finance and you might think, “Oh, well, they’re regulated exchanges in the US like Coinbase or the US branch of finance.” Well, that’s true but remember, they are centralized. They deal in decentralized finance, but they are centralized. What I’m talking about is the theme of this learning experience, which is decentralized finance. The equivalent are the decentralized exchanges. There are some issues that we’ll talk about a little later in terms of risk. But there is no regulation like this everything is algorithmic. I want to talk a bit about a concept in decentralized finance called Total Locked Value. One way to think about that is you put money into a liquidity pool, and that is the value that has been pledged into the system. Equivalent and banking might be the amount of deposits that a bank actually has. We’ve talked about this in terms of MakerDao, Compound, Aave, Uniswap, and other protocols that we’ve dealt with. They call it Lock Value, but it’s really misleading to call it lock value because they’re not really locked. If you want to withdraw, you can withdraw at any point. There’s no barrier to actually doing that. Indeed, it’s much more difficult to do it in, in centralized finance. We need to be careful in terms of how we count that Lock Value. Essentially what I’ll talk about is that if there is this rehypothecation, then you might be counting the collateral multiple times. What do I mean by that? I think the best way to get the intuition as to what this means, is to go back to centralize finance and talk about something called the money multiplier, which maybe you were introduced to in an Introductory Macroeconomics course. Somebody deposits a $100 at a bank. The bank, according to the Federal Reserve regulations, has to have a reserve at the Fed, of let’s say 10 percent. 10 of those dollars is parked at the Fed. But then, the bank can take the other 90 and lend it out. Let’s think about that. Somebody borrows 90 from the bank, and then they take that, and deposit it at another bank. The second bank has to go through the same process. They’ve got $90 deposited. The regulations say that 10 percent needs to sit at the Fed. That means that they’re able to lend out 81 and this process just continues to go and you can see that that initial deposit, of a $100 actually generates a lot of lending. Indeed, at the limit, it actually creates $1000. You just take the initial amount and divide by the reserve requirement which is point one zero. This is the idea of a money multiplier that an initial deposit can actually multiply itself a throughout the system. The same idea applies to decentralized finance. Let’s go through an example of how this might happen. I put some numbers to this example so you can appreciate the actual mechanics. Let’s say in this case, a user deposits $1500 of wrapped WETH into Maker, which we’ve talked about, and gets a loan of 1000 DAIs, which is the equivalent of a $1000. This implies a collateralization ratio of a 150 percent, which is about in the ballpark of what we actually dealt with when we’re talking about a MakerDao. You’ve got the 1000 DAI, and the user then deposits that 1000 DAI along with, 100 USDC into a Uniswap, DAI-USDC pool. Think about what the user has done here. The user has deposited $1,500 and $1,000 of USDC, so the total investment of the user is 2,500, and it’s a combination of wrapped, ETH, and USDC. Then, Uniswap issues their liquidity token that represents $2,000, so the user could actually redeposit, underline the re because this is the whole idea of what I’m talking about here. The user could redeposit the liquidity tokens into Maker and get another loan of 1,960 DAI. Notice, that when you’re depositing the liquidity tokens, given that they’re based upon a stable coin pool of DAI and USDC, the collateralization ratio’s really low, it’s a 102 percent. Let’s actually go through to see what’s happening here. To calculate the total lock value, we’ve got $1,500 of wrapped ETH. We’ve got a $1000 of liquidity added in USDC, we’ve got liquidity added to a Uniswap of 1,000 DAI, and then we’ve got the liquidity tokens that are worth 2,000. If you add all this up, it comes to $5,500. But notice that the amount pledged is only 2,500. Think of this as the first round of the money multiplier that I described in centralized finance. This could continue to go on in terms of re-pledging the collateral and we would come to much more than $5,500 worth of collateral. The formula for the maximum amount is not as simple as in centralized finance. On centralized finance, it’s really straightforward. You take the deposit divide by the required reserve, 0.1 in my example. But notice in the example that we just went through, there were two collateralization ratios. In the risky pool, it was a 150 percent. In the pool that had two stable coins, the ratio was only 102 percent. The formula is not as simple as it is for a bank, but the same idea obtains. This is how it’s possible that indeed the number of DAI in the system could be more than the number of DAI actually issued. The same way that the number of dollars in the system might be more than the number of dollars printed by the Central Bank. This is an important concept of reusing a collateral and is very common in decentralized finance. Indeed, it’s very important in terms of how the system actually works. I do want to emphasize that this is all algorithmic. You’ve got a collateralization ratio. We’re talking about a point in time that is approximately 18 seconds. If you pierce the bound in terms of the collateralization ratio, then you’re going to be closed out by a keeper, and the keepers are incented to actually do that. There’s no, as I said at the beginning, email or telephone call or a appointment next week. This is done rapidly and efficiently. In doing that, it preserves the confidence of the system, and that’s really important in terms of people using it in the future.

03_derivatives

01_yield-protocol

01_what-is-yield-protocol.en

So, the third module DeFi Deep Dive focuses on derivatives. And we’ll talk about a couple of protocols in some detail. But I want to start with yield protocol. So, what is Yield protocol? So, Yield protocol is essentially a way to get a rate that is relatively fixed. We’ve talked about this before. So, think about the Yield protocol is creating a condition like a zero-coupon bonds. And zero-coupon bonds works in the following way and I’ll give you a simple example. Suppose the bond has got one year to maturity and the price at maturity or the principle is worth 100. And the price today to actually buy that bond is $90. So, If you buy that bond at 90, you hold it for a year. There’s no coupon. But at the end of the year you get 100. And in doing that, if you hold to maturity, you’ve locked in a rate. And that rate is 11.1% and you can work that out. Just 100 divided by 90. subtract one. Okay, so within the device space these rates are variable as we’ll see. So, the Yield protocol uses ERC-20 in a very interesting way. And I’m going to take you through the mechanics of an example. It’s a little challenging this example, I must admit. But it’s important for you to basically get it. So, we’re going to use a token. A white token that we’ve kind of talked about these tokens before. We talked about a C token for compound and S token for synthetics. So, we’re going to use a like a white token for this. And we’ll go through how this actually works with collateral in considerable detail. But the key thing is that one of the things that is missing currently in the DeFi space. Is the ability to have some sort of stability in a burrow rate. So, let’s kind of go through some examples here. I suppose you think that ETH is going to appreciate by 10% over the next year. Because that’s your view. So, what you can do is deposit your ETH into let’s say maker. And borrow DAI. And pay 3% in terms of an interest rate. And maybe you actually reinvest and buy some more. Either that’s a possibility. We’ve been through the mechanics as to how to do that. So, if the ETH goes up by 10% you can do the methematics that well. Your assets goes up by 10%. You have borrowed and you need to pay 3%. So, you’ve got a profit of 7%. So that works so well the problem is that that rate that’s 3% is not set in stone. They can change. And if that rate for example went to 10% then even if the maker goes up in value. You have to pay the 10% and you make nothing. So, I’m trying to motivate actually having a rate that is fixed. So, you can kind of lock in at least according to your expectations. Kind of a known, right? So, and this is what a Yield protocol actually does. And I’m just showing here some examples of interest rates dYdX. Which we’re about to talk about. You can see the average interest rate, the 30 day average and the range. Indeed, if we go to a longer horizon and here I’m showing compound dYdX maker. And a job you can see very significant variation in these borrowing rates. Okay, so again, it makes sense that there’s a market for this. So, indeed, again, in centralized finance, we know this pretty well. So, I could take out a fixed rate mortgage and I know what the rate is and I know all of the payments to maturity. Or I could take out a variable rate mortgage. And well that might be cheaper, let’s say today than a fixed rate mortgage. Who knows what’s going to happen to the rate in the future. Okay. So, think of this Yield protocol as completing an important market. Okay. So, basically what we’re going to do here. We’ll have tokens that are secured by collateral assets. So, of course we need collateral, like all of the DeFi our protocols, there’s going to be a maintenance margin. And we’ve talked about this with the makerDAO. And if there’s a situation where we dropped below the collateralization ratio, the keepers are going to come in. And they will liquidate and essentially pay back the debt on the liquidation. So this is very similar to what we’ve seen. But it is a little curious as to how we’re going to get a fixed rate in terms of borrowing. And that’s what we’re going to explore next.

02_mechanics.en

Let’s go through the mechanics of yield protocol. It is intriguing that there’s a possibility of having a fixed rate borrow within this particular protocol. We’ll use this yToken. The yToken, as I said, will effectively allow for a fixed-rate of borrowing and lending. It’s going to act like a zero-coupon bond. The example I gave you of where we buy a bond at 90, hold it for a year, we get a 100 and that rate of return is fixed at 11.1 percent. The same idea is going to happen here. You’ve got a yToken with the target asset of, let’s say 1 DAI, so one dollar, and that’s backed by collateral, which is ether, and the maturity date is one year. The yToken is trading at, let’s say 0.92 DAI, so 92 cents. This we’re going to use and we’ll go through the mechanics so you’ll see what actually happens. That at the end of the year, the 0.92 goes to 1. Think of the 0.92 as the zero-coupon bond. Effectively what we’re locking in is 8.7 percent. Again, that’s calculated in terms of the gain, the eight cents divided by the 92 cents, and that is 8.7 percent. There’s something else that’s interesting that we’ll talk about a little later. That is, if you buy this looking for the 8.7 percent return and something happens under collateralization, actually you get paid your 8.7 percent and that could happen before the full year period. It might be you’re just holding for a month. If there is an event where the collateralization ratio is pierced, then everything is unbound and you get the 8.7 percent. Very interesting the way that this is actually a constructor. Let’s go through the mechanics. I’ve got a diagram here and basically the buyer of the yDAI is basically going to lock in an 8.7 percent return. To start things off, we’ve got ether that equals 200 DAI and there’s a collateralization ratio of 125 percent. The first step is that ether is supplied as collateral. The second step is that, I call the seller, mints 100 yDAI. The next thing is that the buyer is going to purchase that 100 yDAI and pay 92 DAI to the seller. Think about what’s happening here. We’re using this yDAI, but effectively the seller here is basically getting 92 DAI. That’s where we start. Then in one year, the buyer is going to deposit the 100 yDAI, which they’ve got, and they will get 100 DAI. The buyer, remember at the beginning, pays out to the seller 92 DAI and in the end when they deposit the 100 yDAI, they get back 100 DAI. The rate of return, in this particular example, 100 divided by the 92, subtract 1, 8.7 percent. It’s, in my opinion, ingenious idea to actually introduce fixed-rate borrowing and lending into the DeFi space. Let’s continue with the example and look at different scenarios. In the first scenario, in my diagram, we’ve got a situation where the price of ether falls below the maintenance point. The maintenance point was 125. The price of ether drops below that. What happens in this particular case? Step number 1, there’s a keeper that comes in, sees that the position is under collateralized and basically what they do, is they sell 0.8 ether. In selling the 0.8 ether, they effectively pay back the loan of a 100 DAI. What happens here is that as soon as that event occurs, as soon as the keeper comes in, the buyer actually gets the 100 DAI. Remember that the buyer came in and actually paid 92. On the closing, the buyer gets the 100. They were expecting to get the 100 after one year, but this can happen after one day and they get the 8.7 percent. This is a great deal for the buyer. Obviously, for the seller, it isn’t a great deal. Just to be a 100 percent clear here, I’m using buyer just in the same way is if I was buying a zero-coupon bond. I buy a zero coupon bond for 92 and hold it for a year, I get a 100. So it’s 8.7 percent. Think of this, the analogous situation. There’s a liquidation event. The keeper comes in, liquidates and then basically pays the buyer the a 100 early. You get this 8.7 percent return over a short period of time and obviously, if you annualize that rate of return, it’s much greater than 8.7 percent. This works really well. Of course, the borrower would get back 0.2. Remember, only 0.8 of the ether was used to pay back. The seller would get a 0.2 back, but there’s also a keeper reward and that would ETH into whatever refund there was. In the end, the seller, what do they have? They’ve got the 92 DAI and they got the 0.2 ETH. This is just one example of how this works and I call this scenario A. What about Scenario B? Let’s supposed nothing happens to the price of ether, so remains constant at 200 DAI. Basically you’ve got the same steps. The buyer, they deposit the 100 yDAI and then essentially what happens is that they get their 100 DAI. They’ve locked in their 8.7 percent rate of return and the seller well, they can basically withdraw the 0.5 that’s leftover, and essentially what they’ve got is 92 DAI and 0.5 of an eighth. Again, this is the mechanics. One is liquidation, one is no liquidation and of course, what happens to the seller here greatly depends upon the price of ether, because I’ve actually pledged ether as collateral. For the buyer it’s straightforward. The buyer is going to get 8.7 percent and that’s it. It’s extremely interesting type of system here. There are some other aspects to what actually happens here and the important thing to realize is that from the point of view of the buyer, this is a way to lock in a rate of return. What else is going on with yield protocol? One thing that’s also interesting, and again, we haven’t had this yet in DeFi, is this idea of potentially using the YTokens to construct yield curves. Yield curve is the yield depending upon the maturity. In the world of centralized finance, you have a rate for, let’s say treasury bills, which might be 90 days, a one-year bond, a five-year, 10-year, 30-year bond. Each of those yields is different. Usually the yield curve is upward sloping and that tells us something about expected inflation, about expected real activity, the state of the economy. Indeed, my dissertation at the University of Chicago showed that when the yield curve was reversed, where the long-term rates were actually lower than the short-term rates. That contains very important information about the onset of a recession. Yield curves are extremely useful and this protocol actually allows us to construct yield curves also. I just went through a detailed example looking at a one-year horizon for locking in an 8.7 percent return. Well, it doesn’t have to be one year. It could be one month, it might be five years. In doing this, where be take a look at the actual price here, we can figure out what the yields look like for different maturities and that gives us insight into what the market participants are actually thinking about the future. Think of it as a measure of sentiment. Very valuable undeveloped yet. This is very early on, but it gives us something equivalent to what we’ve got in centralized finance which could be useful, but a much more efficient implementation of this. There’s other things that you can do with your protocol. One thing that’s obvious is that you could speculate on interest rates with this protocol. We’ve got lots of protocols we’ve talked about that have variable interest rates. You might have a view on these interest rates. For example you can imagine being a seller of Y dye and then using some of the dye derivative assets as collateral. When you do that essentially the seller is paying a fixed rate on the Y dye, but you’re receiving a variable rate on the collateral. This is a bet that rates will increase. Again, many of you who operate in the world of centralized finance will recognize this trade. Again given that this area of decentralized finance is so early, we are going to to see more and more of these ideas that are popular in centralized finance replicated in decentralized finance. Basically completing all of the missing components. Again this is a very straightforward way to pay fixed and receive floating could be the reverse. You could receive fixed and pay floating that’s a possibility to you and very easy to implement with this protocol. Yield is a very good idea, it supplies something that we haven’t had in DeFi. DeFi is a young space. I can’t say we haven’t had for decades because the space is like four years old. But it gives you an idea of how rapidly the space actually evolves. Just like other DeFi protocols, we’ve got the DeFi Legos. Yield easily integrates with the other DeFi protocols, it’s ERC 20. It means that you can use yield along with these other protocols. Some investors are uncomfortable with variable rate loans now we’ve got the possibility of a fixed rate. Let’s go through our list that we usually go through for these protocols. We’ve got the traditional finance problems, is a decentralized control. This is decentralized and there’s nobody really controlling this protocol other than the governance. Limited access we’ve talked about in centralized finance. Well, yield Solution is that any market participant can actually do the buying or selling to lock in a rate, our example of 8.7 percent is one example of a rate that you can lock in. Inefficiency. This is important. We’ve talked about this that when you go apply for a loan at a bank, the rate that you’re paying is higher than it would be because the bank has got all this infrastructure that they need to pay for. The brick and mortar, the bureaucracy, all of the security issues, all that needs to be paid for. Yield is algorithmic. It is very lean running on a theorem and can be more competitive than centralized finance. Lack of interoperability, well known in terms of fixed income instruments in traditional finance is extremely difficult to think about buying a five-year bond and selling a one-year bond. To swap those two is going to be costly. Whereas yield protocol, this is very straightforward, it interoperable with any a theorem target asset. The last thing, opacity. It is really something that is very typical and decentralized finance. This is completely open. You can see everything and it’s easy. We will go through examples a little later where I will pull up ether scan and you can see the actions step by step. Of course that is not possible in traditional centralized finance.

02_dydx

01_what-is-dydx.en

In the third module, we’re going to study derivatives. The logical place to start is with the protocol and I love the name dYdX. What is dYdX? Basically, this is a company that specializes in trading. It is margin trading and derivatives and we’re going to talk about some of their innovative products. Basically the margin protocols they are supported by USDC, DAI, and ETH. This is within the Ethereum blockchain and there’s a spot exchange and it’s got a lot of similarities in terms of some of the decks that we’ve already studied previously and we’re going to go through and take a look at that. What’s interesting with dYdX is that there’s a hybrid on-chain off-chain approach using layer 2, which we will talk about in some detail. Essentially think about what’s happening is dYdX is storing basically pre-approved orders that are signed and then when the trade actually occurs, then that is submitted to the Ethereum blockchain. This basically saves a lot in terms of fees because you don’t want to be doing everything on chain. Layer 2 is a way to actually get great speed. It’s got security, but at next to no fee. There’s no gas fee for this. The only gas fee that occurs is when we actually go on chain and actually do the trade. Think of this as well, I’m willing to buy ETH at a certain price. Well, you can actually have assign transaction for that, but it’s not actually occurring. It’s that you’re willing to buy at a certain price, but it’s not at that price. But if that price actually is realized, then the order goes through and then there would be a fee associated with that. Very nice idea. This supports limit orders where you can put like a limit or a range in for your order and also the idea of maximum slippage, which we talked about briefly in the second course and that is that if the price moves against you to a certain degree then the order is canceled, so you put a maximum amount of slippage into the contract. This is what it looks like. This is just the spot trading of ETH and DAI and you can see the actual order book on the left. You can see what the leverage factors are to the far left. You can see actually the spread and that is I’ve got a yellow arrow on it and it’s really tiny. This is an exchange that’s got sufficient liquidity that the spreads are really small and these spreads are smaller than we would experience in, for example, trading highly liquid stocks in the US, like Apple stock. This is just an example of what you can actually do, and indeed you can trade on margin. One thing I will mention is that trading cryptocurrencies is a very volatile business. Ethereum is is at least five or six times more volatile than the S&P 500. When you use leverage, you increase the effect of volatility even more. But some people want to do that. That’s fine. There’s great upside potential, but also very significant downside potential. Again, the way that this works is that there’s matching of orders to the buying and the selling and this is done in a way that there’s no middle person. This is decentralized. It’s not like there’s a broker that could go rogue and steal your money. No, this is just an open protocol. Indeed, there’s a history in finance of brokerages that basically go under. Indeed in the global financial crisis, that’s exactly what we had and people lost billions of dollars. Again, when we do have a match, then that match is submitted to the memory pool and eventually goes in to the Ethereum blockchain. With dYdX, as I mentioned, you can do leverage, and the maximum leverage right now is about 10 times. Again, this is possible for long or short positions. Again, you need to be careful when you use leverage like this on an already volatile asset, again, the rewards can be very substantial. We’ve got keepers also, no surprise. Keepers are very important for all these protocols. If the maintenance margin requirement is violated, then the keepers are going to come in. Again, this is not algorithmic. I want everybody to really understand that, that this is not part of a contract. That there are external players, are externally owned accounts that see the opportunity and they trigger the liquidations. Again, the same story and other protocols, these keepers are rewarded for actually doing that because this is a service to the protocol and they actually get paid for it. The incentives are aligned to actually do this. Let’s talk about lending and borrowing. It’s similar to compound and Aave in terms of what dYdX does. DYdX also has flashed loans. We talked about this with Aave. With Aave, the fee for the flash loan is really small. I said at that point that, well, it’s really small because it really isn’t any cost. Again, if you think of a traditional loan, just think about all the paperwork that you have to go through, all the time spent in actually applying for a loan, doing credit check, all of this stuff. But the flash loan is just a transaction with many steps to it. DydX, the flash loans are free. That’s interesting. There’s no fee. I thought that a handful of basis points for Aave was a great deal because it was so cheap. Well, this is free and maybe it’s no surprise that in a system that doesn’t really have traditional costs, there’s always a gas fee. But that applies to anything that the actual fee that the protocol takes is zero. That’s a difference between Aave and dYdX.

02_flash-loans.en

Let’s talk a little more about flash loans. You can tell that I’m very interested in the flash loans because we’ve covered them already once, but I want to talk about them again. It’s such an ingenious idea. So dydx, as I mentioned, it’s got free flash loans. It makes sense that within this particular space, if there’s no particular cost, then the price is basically proven to zero. It’s is like the theoretical world of perfect competition in economics. Your basic economics course we talk about, the conditions whereby supply will equal demand and there’s no monopoly power and things like that. This is that situation and the cost is driven to zero. The lending rates are basically usually defined by the riskiness of the actual loan and the duration. A longer duration loan usually has a higher rate because there’s a longer period for a bad event to actually happen. Your money is locked up longer, so you should have a higher rate of return. With the flash loan, as we talked about earlier, this is something that happens very quickly. It’s within a transaction. There’s really no delay. It’s all within multiple steps on a transaction. There’s a loan that’s taken out at the beginning and then there is payback at the end. It’s instantaneous, there’s no duration. There’s no credit risk. If there’s anything that goes wrong, this is an atomic transaction and we revert the original state. We’ve been through things like this. This is, again, a very innovative idea. Let’s talk about the use of a flash loan. One of the main uses is arbitrage. Arbitrage is in many different forms, it might be prices that are different, and different exchanges. It might be lending and borrowing rates that differ between different protocols. There’s many different ways. Arbitrage is something that is profitable for the arbitrageur. But arbitraries also plays an important role in the financial system in that it drives prices to where they should be. If the price is too high somewhere compared to somewhere else, then arbitrage will equalize those prices. That’s a good thing because the people buying at the price that was too high, well, they’re not getting a very good deal. They’re getting a price that’s inflated. These flashed loans are important within this world of arbitrage. That difference, of course, is that when we think of arbitrage, we think of hedge funds or high net worth investors. In this world, it doesn’t matter who you are because the flash loan doesn’t require collateral. In traditional finance, you need to have the collateral to do the actual borrowing. For an arbitrage opportunity, it’s restricted to the wealthiest. They make the money after that. It’s not available to the average person. I talk about financial democracy a lot in this learning experience. Well, this is just an example. We’ve talked about flash loans with Ave. With Ave, we had an example of refinancing a loan. In the Ave example of the flash loan was a very nice example that you’re locked into our rate for a loan, but then you see the possibility of having the same loan at a much lower rate. We went through the two different possibilities. One would be just to pay back the original loan, take out a new loan. The other possibility was to use a flash loan and do everything in one transaction. Effectively refinance your loan from a higher rate to a lower rate. Again, I want you to think of the bigger picture here, that if enough people are doing that, then the rates tend to equalize. Then that means that everybody gets a fair deal. Again, arbitrage are very important here. I want to use flash loans and a different type of example for dydx. That is an example that capitalizes upon the prices being different on different exchanges. The previous example with Ave was refinancing a loan, which is an arbitrage situation, want to get the lowest possible. Now, we’re actually going to look at a situation where we’ve got two different prices and we want to capitalize upon that. We’ll start things off. We’ve got an exchange rate for a 1,000 DAI. For ETH on Uniswap is six ETH for 1,000 die. That’s just what we observe on Uniswap. Now, suppose on dYdX, we’ve got a spot price of 5 ETH for 1000 DAI. Notice that the ETH are much more expensive on dYdX. How is it more expensive? Well I’ve got 1000 DAI, which is $1000. On dYdX, that 1000 buys me 5 ETH, but on Uniswap, I can get six. Basically it’s more expensive on dYdX. Let’s go through the mechanics of how we can actually make this work. I’ve got a diagram for this, but let me just say it first. What we’re going to do is we’re going to take a flash loan for 1000 DAI. We’re going to exchange it on Uniswap for 6 ETH. We’re going to use five of the six to trade for 1000 DAI on dYdX. We’re going to repay the flash loan with 1000 DAI, and then we got a profit of 1 ETH. All of this in a single transaction. Let’s go through the diagram and the steps so you can see what’s happening. Again we’ve got two different exchanges. We’ve got Uniswap, we got dYdX, the price of ETH is different. Uniswap is cheaper, so 1000 DAI gets you 6 ETH, and on dYdX, it is 5 ETH for 1000. The first thing you do is to take out a free flash loan for 1000 DAI. The next thing we’re going to use those 1000 DAI to purchase the ETH on the cheaper exchange at Uniswap. When we exchanged the 1000 DAI, we’re going to get 6 ETH, that’s step number 3. Then we’re going to take five of the six to settle the flash loan with dYdX, and the profit we’ve got is 1 ETH. Again, in one transaction. Now, of course, this is a stylized example here with a very large price difference, and also it’s a very small transaction using only $1000. I’m going to show you some situations in the fourth course on defined risks where a loan is taken out, again with no collateral, for $200 million to do a complex arbitrage like this. We’ll see flash loans all over the place. Again, this is quite a powerful idea. Dydx just recently on August 3rd, 2021, announced their governance token. We’ve talked about governance in terms of DAI, MakerDAw, which is their Maker token. We’ve talked about the comp, A C-O-M-P token for compound, Uni, and now dYdx has just launched their token, which is also called DYDX, but all in capitals. There’s considerable detail on their website but this was their next step to become fully decentralized. It’s interesting in particular that this is focused on the layer 2 protocol where much of the action is happening with dYdX. I just want to step back a little bit to tell you how this usually works. That a protocol is launched and it has aspirations to be fully decentralized, but when it’s launched it isn’t. The developers retain a lot of control over what’s actually happening, and this is useful because there’s often a lot of fine tuning that has to happen. But it’s also a risk because if the developers are nefarious, they could potentially take advantage of those that are participating in the protocol. But often it’s the case that there is an aspiration to be fully decentralized, and that aspiration is realized not all the time, but for the leading protocols that we’re talking about at least, this is very important. Recently dYdX has launched their governance token. Remember, we’ve got these different types of tokens, The equity token, the C token or the Y token that we just talked about. Those represent a share of a liquidity pool where we’ve got utility tokens like stable coins. The governance token is something different in that the governance actually votes on changes in the protocol. That might be major changes, that might be minor changes of parameters, but that is the mechanism whereby things can change.

03_perpetual-futures.en

Let me continue with dYdX because there’s something else that they do that’s really fascinating. It’s the idea of perpetual futures. What is that? Let’s go through what this actually means. The traditional futures contract has got an expiration. You buy it could be crude oil for delivery in September. There’s various different explorations. But with perpetual futures, there’s no expiration to the contract, effectively it’s reverting every day. With futures, you’re just betting on the price going up or going down. That’s it. If you believe that the price is going to go up, then you go long so you’re buying and usually you’re buying in the future. In my example, if you think the price of oil is going to go up, then you want to actually go by a long contract for, let’s say September, and hopefully, the prices is well above that and you get to buy cheap. Every day the contract is rewritten, if the price goes up. Its re- written, and essentially this is a bet on price appreciation. Of course the other side is a short futures where if the price you believe is going to go down, then you sell. Again, this is a protocol that allows for a futures contract with no particular expiration. This is also something that you could use with leverage, or without leverage. It’s completely your choice. Let’s go through what’s actually happening here. For those of you that are experts on futures and forwards, this is just a swap, and it consists of a portfolio of one day forwards of features. This is effectively what this is. It is intriguing that we don’t have a fixed exploration. There’s another interesting aspect here. That is that if you’ve got a lot of explorations, then there might not be a lot of liquidity for certain expiration dates. You can actually look at this even in centralized finance, where you can pull up, let’s say again, the crude oil futures, which go up many years but many of the expirations, there’s almost no trading and that’s a big market in the world today. Even a very large market like crude oil, there’s issues with illiquidity amongst many contracts. Having just one contract, the perpetual futures seems to get around that problem of illiquidity. Basically what the perpetual futures actually does, you’ve got an index price and again, the index price is defined in terms of, let’s say, an average amongst the major exchanges so you need some benchmark index price. Think of this as the spot price. In terms of the Bitcoin US dollar perpetual futures on dYdX. DYdX uses the MakerDAO Oracle. There is a popular Oracle to actually use and it essentially looks at a number of exchanges that are trusted. In the previous course, we actually went through examples of exchanges that were not real exchanges in that the trading volume didn’t make any sense and other aspects that we went through. In this particular Oracle Binance, Bitfinex, Bitstamp, Bittrex, Coinbase Pro, Gemini and Kraken. These are well-known exchanges. Essentially what we get is a price and average price for the index. Again, that’s going to be used as an input. Let’s go through some of the mechanics of the perpetual futures. We’ve got an investor, they have to deposit some collateral after this, and they need to decide whether to go long or short. The leverage that’s allowed here, interestingly, is up to 25 times. That’s huge. Again if you’re trading something like Bitcoin US dollar, Bitcoins volatility is like 90 percent on an annualized basis. The S&P 500,15 percent, gold is 15 percent. Ethereum is about the same, 90-100 percent. Anytime you add leverage, you increase the effect of volatility. For example, if you’re running at 90, let’s say bitcoin, and then you do 50 percent leverage, then your effective volatility is double than 90, so 180 percent. Now we’re talking 25 times. The contract itself, it could trade as a premium or a discount to the index. Obviously, the index will be changing through time as the price of the underlying is changing through time. But there could be a difference between the actual contract price and the index price, and that’s going to be an important issue in implementing the perpetual futures. There is a funding rate. The way this actually works is that one side is going to pay the other. This depends upon both the index move and this premium in terms of the contract price and the index price. It can be a premium or discount. If there’s a premium, the contract is trading higher than the index then the funding rate is going to be positive. Anybody who’s a buyer or who is long betting on the price to go up is going to pay the short. The funding rate is purely a function of the size of the gap like a premium. On the other side, if the contract is trading below the index price then there’s a discount. In that particular case, the shorts are going to pay the longs. This is a mechanism that happens every day. This is a way to keep the future’s contract price as close as possible to the underlying index. The funding rate effectively creates this incentive and essentially it’s an incentive to take the opposing side. If that premium gets too big, then some of the longs are going to be sellers. When they’re selling, that’s going to drive the contract price closer to the index price. It’s unattractive that the long needs to pay the short. They’ll just get out of their position. This basically drives the contract price very close to the index price. This is again part of the dYdX protocol. This is again completely open and you can see how these things actually trade the various different markets. Again, it’s open to considerable leverage. The funding rate is updated effectively in continuous time but it’s really only applied at the time the user opens, closes, or changes a position. This is part of the mechanics of how this actually works. We need to explore the mechanics in some detail. I mentioned already that dYdX operates in layer 2. This happened actually in August or April 20th of 2021. dYdX moved the perpetual features to layer 2. I want to remind you that we’ll go into much more detail on layer 2 and the mechanic to layer 2 in the next course on [inaudible] risks and opportunities. But it’s effectively something that’s off chain but secure with effectively a multi-signature vault. As already mentioned, the advantage of this, no gas fee. That’s a big deal. Something is going on in the layer 2 actively, but there’s no gas fees. Again, we’ve got a pretty extreme leverage. Margin, of course, we’ve got margins with perpetual features. You need to put some collateral in. There’s leverage that’s allowed. But as with traditional features, we’ve got initial margin and a maintenance margin. That basically means that if the initial margin is 10 percent, there is another threshold that’s a little lower. If you hit that threshold, then you need to repost the margin right up to the 10 percent. So that’s how it works. However, if you don’t post, then you can be liquidated. Again, in traditional finance, you get a margin call about this and decentralized finance is nothing like that. If you’re not watching this carefully, a keeper is going to come in and liquidate your position. Again, given that we’re going to talk about futures, and many have not had a course on futures or options. Just want to make sure that everybody is on board in terms of how this actually works. In a traditional future, if you think the asset is going to go up in price, then you actually enter into a contract to buy that asset in the future at a price that you think in the future is going to be higher than that price. Effectively you’re locking in a lower price if there is appreciation. Of course, if the price goes down, that’s bad news for you. You’re going to be a loser on that. This is again, a way to speculate on the price of an asset without actually putting up 100 percent collateral. It makes sense. Let’s say you think the price of Bitcoin is going to go up. Well, one possibility is that you just go buy a Bitcoin. If it goes up, well, you make some money. If it goes down, you lose some money. Well, another possibility is to agree to buy Bitcoin in the futures market. We do have futures markets in traditional finance for Bitcoin. Bitcoin is traded, the theorem is traded in traditional centralized markets. Those with regular or futures contracts with fixed explorations, and of course, all of the costs that are associated with those centralized institutions. The idea of the futures is, well, maybe I don’t have the money to buy a Bitcoin. I do have, let’s say 10 percent of the money. What I could do is to buy on the futures and essentially pledge the 10 percent as the margin. If the price goes up, that’s great. The price goes down, that could be wiped out. I want you to understand like how the traditional long futures work and short is the same thing that you think that the price of the asset is going to go down. You see the price today and then you agree to sell at some point in the future at a price that you think is actually a very high price compared to where you think the asset is going. Again, as the market falls, anybody who has short is going to get a good deal if they’re buying in traditional futures. Essentially, what you’re doing is that you’ve agreed to sell in the future at a certain price. If the price drops, you go buy at the cheaper price, and then you can sell at the more expensive price. That’s where you make your profit. Again the profit is going to be the difference between the contract price and the market price. Very good idea that has a long history in traditional finance and I will admit that trading costs for futures generally are very small compared to, let’s say, training costs and other things like bonds or equities. Futures are traditional finance market that’s got low on trading costs. But we’re going to move this now to decentralized finance. What about the risks here? Obvious that one source of risk is the other side. Somebody is agreeing to buy, somebody is agreeing to sell. If you’ve got extreme margin, then is possible with a big price move that you can blow through your collateral. The position would be closed, but it might be closed at a loss. In traditional finance, you’ve got a clearinghouse that deals with situations like that and provide some insurance. In decentralized finance, there are also reserved polls for extreme volatility and we’ve talked about that in terms of our lending or protocols to have like a reserved pool or a global settlement in the context of maker. But this is definitely a risk and it’s especially a risk if you’ve got a very high leverage. Because with the higher the leverage, the price move becomes smaller and smaller that wipes out the collateral. The more leveraged, the higher the risk of actually going underwater with a futures situation. The other thing that’s important is that futures are not options. With an option. For example, in my crude oil example, I’ve got a call option where let’s say I agree to buy a 100 barrels of oil at $70 a barrel in September. If the price is 90 in September, then that’s great news because I get to buy at 70 and I can just instantly sell at 90. Indeed, I could just sell the option just before and I don’t need to do anything about delivery. I’m not interested in receiving a 100 barrels of crude oil. If the price isn’t 90 but 60, then I don’t exercise the option so I walk away. Think about it. Why would I exercise the option to buy a 100 barrels at $70 and then sell the oil at 60. I just let the option expire. It’s out of the money. With options, you’ve got upside, but your downside is limited. That’s why they’re called options. But with futures, there’s nothing like that. For options, to get that just one-sided payoff, you actually pay a premium for it. Having the one side, you actually pay for. Whether it’s a call option or a put option. But with futures, there’s nothing like that. If the price goes up, if you’re long, you make money. If the price goes down, you lose money. If the price continues to go down, you might actually go through all of your collateral and at that point, you’re closed out. The important thing here is futures are obligations. There’s no optionality right here. Given that these are obligations, we need some mechanism to make sure that there isn’t a big price move. That basically you go through all the collateral and somebody’s going to lose some money. It’s really important to actually enforce. Let’s go back to our margins because it’s going to be important in terms of how this works. We said a maintenance margin. Remember there’s an initial margin, maintenance margin. Let’s say it’s five percent. If the price of the asset drops, if you’re long and you’re actually paying out because it’s actually dropping. If we get close to that five, or if we hit the five, then we need to repost margin to go back up to the initial margin, which is 10 percent. If you don’t do that, the exchange is going to liquidate your position. I’m talking about a traditional exchange. You’ll get a margin call and if you don’t post additional collateral, then your position is closed out. Let’s say drops from five percent to four percent, you’re closed out. But there’s still some collateral left over so you’ve got that four percent, that collateral back. Again, the maintenance margin it’s going to be very important and I want to draw the distinction between what happens on dY dX in a traditional exchange. Some of this, you can probably guess what I’m about to say. But if you fall below that five percent, then there’s going to be a keeper that comes in and closes your position out. Now this is different than a traditional exchange. Remember I said that, well, suppose that five percent you go to four percent, you’re closed out, and then you would get the four percent back. Not here. The keeper gets to keep what’s left over as a reward. Again, a strong incentive to watch that maintenance margin. Liquidation is effectively instantaneous. This happens really quickly. Of course, there’s no centralized exchange. There’s no clearinghouse. This happens again very quickly. There’s no trading hours. These are contracts that are perpetual. It’s not the third Friday of the month where there’re settlement of the actual futures. Futures settle every day but there’s an expiration date in traditional finance. These have no maturity dates. Very interesting concept and very important innovation in Debye.

04_perpetual-futures-example.en

So now let’s actually do an example of how this works. And we talked kind of theoretically. I’ve got a stylized example that will go through and look at the mechanics of how perpetual futures actually works. So let’s start with an example. The Bitcoin is worth 10,000 USDC, which means $10,000. So an investor is going to initiate a long position by putting 1,000 USDC as collateral. So this is a lever bet. So if it was unlettered, then the investor would deposit 10,000 USDC. But they’re only depositing 10%. So let’s actually go through what happens if the price moves. So suppose the price goes up by 5%. So this means that the Bitcoin goes from 10,000 to $10,500. Well the profit is going to be 500. So let’s think about this in terms of an investor that simply bought the Bitcoin, if you bought the Bitcoin, which means you’re fully collateralized. You put $10,000 out It goes to 10,500. Well, you paid 5%. Now let’s look at the example of the futures where we’ve got an investor puts up only $1,000 but actually makes the same amount of money, 500. So notice the rate of return here is 50%. Okay and you can probably see where I’m going here. So if you’re 100% collateralized, your return is 5%. The leverage that you’ve got in terms of putting only $1,000 down, but you’re controlling 10,000 is 10 times. Because you’re controlling the value of 10,000 with only $1,000. So 10 times 5% is 50%. So you can see this is how this works, if the price moved in your direction. So I want to think about this in a different way, and I’ve got some diagrams to show you. So we could think about that, this particular investor is taking a long position at 10,000. So effectively there committing to purchase or to buy a 10,000. So there’s an obligation of 10,000. So you can take this obligation to pay the 10,000 is a negative balance, because according to the contract you have agreed to buy at 10,000. So the investors already committed collateral of 1,000. So what’s actually owed is 9,000, and this is sometimes called the short or long balance. On the other side, the investors committed and this is the other side of the ledger for this investor. The investor has committed to buy one Bitcoin. So that’s valuable. So you can think of the investor as having a positive balance of 10,000 at the current price. The collateralization ratio is 10,000 divided by 9,000, which is 111%. And that’s very close to the allowed leverage with the 10% margin. So in terms of the diagram here, we see this investor, we’ve got initial margin of 10%. We’ve got a maintenance margin of 5%. And the long balance is kind of the value of what you’re going to get, and that is 10,000. The short balance is what you owe and that’s the 10,000, but you’ve already paid 1,000. So you’ve got basically the short balance of $9,000. And again you can see how to calculate the margin here. And the margin is 10,000 divided by 9,000 -1 which is 11%. And this is for a long position. Now let’s consider what happens if the price goes up by 10%. We previously did an example where the price goes up by 5% but let’s look at 10%. So 10%, the price of Bitcoin goes from 10,000 to 11,000. So now the long balance is basically again the value of what you’re going to get, that’s now 11,000. So it’s gone up in value. But you’re short balance is the same because you committed to buy a 10,000, you’ve already put 1,000 in. So the short balance is identical at 9,000. So again, you’re effective margin here is 11,000 divided by 9,000 -1, 22.2%. So that’s well above the initial margin and the trader could actually withdraw some money here. Close the position if you want to close the position you can close it, you’re going to have a profit of 1,000 USDC. Which is a return on investment of 100%. And again let’s kind of go through that math that I kind of suggested. So we’re putting up only 10%. So you gotta leverage of 10 times here. The price of the asset goes up by 10%. Our profit we make $1,000, we invested $1,000. So the profit is effect that we’ve doubled the amount, so we get that $1,000 a margin back plus the appreciation of 1,000. So the total positions 2,000 divided by 1,000, 100% rate of return. Notice the relation 10% appreciation times 10 times the margin is 100% rate of return. Okay, so this is just an example of a long position. So I also want to go through the mechanics of a short position, the long position where the price actually goes down. If you’re short this would be ideal, but unfortunately you are long. So again anytime you’re long you want the price to go up, sometimes the price goes down, and this is an example of the price going down. So let’s go through the mechanics, let’s say the price of Bitcoin goes down by 7.5%. So it goes from 10,000 to 9,250. So the value of what you’re going to get is 9,250. The short balance again is unaffected. So we have an obligation of 10,000, we’ve already put in 1,000. So our short balance is 9,000. So calculating the margin here would be 9,250 divided by 9,000 subtract 1, 2.8%. This is below the 5% margin requirement. So what’s going to happen here? The keeper is going to come in and they will essentially sell the Bitcoin payback $9,000, whatever is left over is 250 USDC that goes to the keeper. So again this is different than traditional finance and that the keeper is collecting the extra margin. So this is an example of a long position with different price moves with a liquidation involved here. So the short position obviously works in a very similar way. So let’s go through the short position also. Here the investors committed to sell a Bitcoin at 10,000, and that’s a positive balance. And you’re going to supplement that with a margin deposit of 1,000. So the total positive balance is 11,000. And the investors negative balance is the obligation to buy that one Bitcoin at 10,000. So the collateralization ratio is 11,000 divided by 10,000 which is a margin of 10%. So suppose that the underlying asset goes up by 5% and value, so it Bitcoin increases by 5%, then we go to 10,500. And then the margin percentage becomes 11,000, which is unchanged divided by the 10,500 which has changed. And when we calculate that margin, it is 4.76%. And this position will be subject to liquidation. Again, if you’re short, you want the price to go down, but the price has gone up. And it hasn’t gone up by that much, only 5%, but that 5% is going to trigger liquidation. So again, the difference here at the net balance of 500 is the incentive for the keeper to actually come in and close that position. So let’s talk beyond perpetual futures. There’s interesting work that I reference, that has talked about these concepts in the past but there’s the possibility of also doing perpetual options. This has been proposed but not implemented yet, perhaps by the time that you’re watching this course, we will have perpetual options. So again, there’s a history of this idea in the traditional finance literature, but nobody’s really implemented it in traditional centralized finance. It’s interesting to me in particular that some of these ideas become possible in decentralized finance that were not feasible in centralized finance. So let me kind of summarize here, perpetual futures, a great idea. It allows people and again it doesn’t matter who you are to participate in the appreciation or depreciation of crypto assets without having to make a large investment. So without having to buy the entire amount, you can use some leverage and participate in the upside or the downside. This is something that’s use for speculation. It can also be used for hedging. Okay, so futures are not just for speculation, it might be that you want to protect the value of your position over the short term, so you might have a portfolio of Kryptos. But you think in the short term, there is going to be some price depreciation, but you don’t want to sell your portfolio. So the easy way to deal with that is to actually do a short position and the futures. And then if the price actually goes down well, you protect it because you’re profiting on the perpetual and the value of your underlying portfolios going down. That’s true, but that’s offset by the gains on your short position, so provides a very natural hedge, of course this works both ways. So if you’re wrong and you take that short position well, you’re going to lose money on your futures, but your portfolio is actually going up in value. So again, it’s a hedge, the hedges two sided in that you’re protecting your downside, but you’re also eliminating the upside if you get it wrong. And that is what a futures hedge actually does. So again, our table of the solutions that that dydx offers, they’re very substantial. This is a decentralized protocol, as I mentioned, they’ve got their decentralized governance token capital dydx. This is open to anybody. If you’re trading derivatives and centralized finance, you need to be qualified to actually do that. So you have to go through the process at your broker to become qualified. This is open to anybody. We’ve got free flash loans that are available, so arbitrage is now democratized. So anybody can do it, not just hedge funds or high net worth investors. This is all algorithmically done, we’ve got optimized interest rates, free flash loans. So this is much more efficient than centralist finance, and of course we’ve got interoperability and again, everything is open. It’s kind of obvious that everything is open. Think of the keepers, they see everything. They see when that collateralization ratio drops below 5% and then they act. So this is something that is open for everybody. Whereas in traditional finance, in terms of what happens in a traditional, for example futures or options market, we get minimal information. And in terms of the actual traders, well, maybe the exchange knows the traders, but anybody from the outside, very difficult to tell.

03_synthetix

01_what-is-synthetix.en

So next I want to talk about synthetics which is a really cool idea and again is a derivative but it’s going to be different than what we talked about with Dy Dx. So this is something that I believe is purely a result of the DeFi innovation. So this is the type of asset that is hard to think about in traditional finance. So effectively what we’re going to do is we’re going to create a derivative and the value is going to be based upon an underlying asset that is not owned or s crowd. How is that possible? Okay. So this is what synthetics is doing. And again this is very interesting idea. And of course I’ve got examples of this. So the idea here is that the company is going to issue since which I’ll talk about a lot these are tokens and these tokens are pegged to an underlying price feed and they’re backed by a collateral. So if you really think about this, that kind of should remind you of maker DAO’s DAI. So again the DAI is pegged to the dollar are very close to a dollar. And to get that you’ve got this over collateralization of DAI. Okay so we’re going to have something similar but different. So the price feeds are going to come from an oracle and in particular will use chain links decentralized oracle. And theoretically these synths could track any asset. Okay so again in the stable coin space you’ve got coins that could track let’s say U S dollar but it doesn’t have to be the U S dollar. You can set up that mechanism with let’s say make DAO to create something that is pegged to something else. Okay so what are we going to track here? And it turns out that synthetics has got wide range and I’m just showing you a few of the assets that they’re tracking. So it could be the Kryptos like Btc. Bitcoin Ethereum X R P. Is ripple. And notice the S. Before. That’s the synthetic versions of Bitcoin. So it could be traditional currencies. Fiat currencies. So S, U S D. That’s going to be something very similar to US D C. Or DAI. But we’ve got other countries heroes, the yen. Australian dollar, swiss frank. And again I’m just showing you some of these and it could be that you track to a stock index for example the FTSE, the NIKKEI. Or a stock. There’s TSLA, google, apple, Facebook. So again these are are tokenized ways to basically participate in the price appreciation or depreciation of certain assets. So why stop there? We’ve got commodities to so XAU is gold X A G Is silver. We’ve got OIL which I mentioned a little earlier and notice the last one is also OIL. But as I OIL. So what does that mean? Well I stands for inverse. So the S tokens are participating on the upside. And the I is you buy something where you think it’s actually going to go down. Okay. So it’s so basically you’ve got these tokens and a long position in a synth is called an sToken. And I showed you lots of them and a short position is called an iToken. So I’m sure do I OIL but it could be iETH. All of these are synthetic because they depend upon a price feed. And you’re probably thinking right now, okay, why even stop at the assets? We’ve already talked about so many other things that you could tokenize based upon a price feed that you decide upon and you need to have a reliable oracle of course for this to work. They use the chain link oracle. Okay. So there’s also a platform token and the platform token. Let’s not confuse the SNX token for a governance token. It’s more of a utility token. So it’s used within the network. So remember there’s three different types of tokens. All right. So we’ve got our utility token and this is the SNX. We’ve also got our equity tokens which represents shares of a liquidity pool and a governance token like maker or comp. So SNX is utility token and it is of course traded. You can see the market capitalization of SNX is almost at the time of of doing this video, a billion dollars and it’s actively traded. So how does this work? So when a user mints synth against the platform token? SNX they incur a debt that’s proportional to the total outstanding debt and everything denominated in US dollars. And they become responsible for a percentage of the debt in the sense that it unlocks their SNX collateral if they need to return it to US dollars. And this is interesting. The debt is global. So it’s across all of the sense so it’s shared collectively by all of the holders and it’s based upon their percentage of the debt that they own when they opened their position. Okay I’m going to go through some mechanics as to what is actually going on in the background. But again this is like really a different idea and fascinating. So it turns out that the outstanding U S dollar denominated debt is going to change anytime the price level of the synths actually change. And what’s crucial is that each holder remains responsible for the same percentage of the global debt that they were responsible for when they minted their sense. Okay so basically if the things that you buy outperform the other sense that are available then you’re going to be a winner in this particular type of platform. And again I want to go through some examples this is again a different type of mechanism. So with like a center position. The trader is as long and your long against the entire pools portfolio. So you will make a profit relative to the pool. So you’re your bet relative to other things in the pool. So the goal, of course, is to have a return that is greater than the pool are returned. Okay, so what I really want to do is to go through the mechanics of how this actually works, and we’re going to do that next.

02_mechanics.en

Okay, promise mechanics. Let’s go through the mechanics of this kind of mysterious type of protocol. It’s mysterious in many different ways. Number one, it’s a derivative based upon a price feed rather than something that is collateralized. It is also unusual in that this idea of outperforming the pool of all of the sense. And again we need to look at the mechanics to understand us, so I got some diagrams hopefully will be helpful for you. So let’s go through a couple of detailed examples here. So let’s start, we’ve got three traders and each have $20,000, so the total debt is $60,000. So, trader one has got 2 sBTC, so 2 Bitcoin synths that are $10,000 each, so that’s $20,000 worth. And one holds 100 sETH, so the synth linked ETH and the price is $200 each, so again that’s $20,000. And the third holds $20,000 of sUSD which is priced at $1, so that’s also $20,000. So every single trader here has got $20,000 and their share is 33 percent each, the total debt in US Dollars is 60,000 dollars. So again I’ve got the assumptions you can see and you can see the holdings on the far right 2 sBTC ,100 of the ETH synth and the 20,000 US Dollars per synth. Okay so that’s kind of where we start. So now suppose the price of Bitcoin doubles to 20,000 and the price of Ethereum goes up five times from 200 to 1000. So now let’s think of the total debt here, so the total debt becomes higher. So the Bitcoin is doubled in value, so it goes from 20,000 to 40,000. The ETH has gone up by a factor of five so it goes from 20,000 to 100,000 and nothing’s happened to the value of the dollar. So you put this together and you get $160,000. So each trader is responsible for 1/3 and around a bit but that means $53,300. And it turns out that only the holder of the synthetix Ether is going to be profitable in this particular situation. So again think about the Bitcoin holder, yeah it’s great the Bitcoin is doubled but Ethereum did much better. So the value of their position is $40,000 but the value of their debt is 53,300, so it’s a negative balance of 13,300. The holder of Ethereum has done really well because their Ethereum has gone from 20,000 to 100,000, the obligation is 53,300 and there’s a positive balance of 46,700. And the US Dollar holder where there is no change in value, they have 1/3 of the debt here. So they’ve done the worst because that means that they’ve gone and now I have got this negative balance of 33,300. So you can see that what’s really important here is how you do relative to the pool. So even though Bitcoin did really well, you’re going to be a loser on this because Ethereum did better than Bitcoin. So let’s go back and take another example. And now what we’re going to do is to have the price of Bitcoin falling, the price of Bitcoin falls to $5,000. And let’s say the price of ETH also falls to $100. Okay so basically both Bitcoin and Ethereum have dropped by 50% and we’ll assume the dollar, there is no change for the dollar. So if we go through and figure out what the obligation is now, well we used to have 20,000 for the Bitcoin but now it’s only 10,000. We used to have 20,000 for the Ethereum and now it’s only 10,000 and we’ve got 20,000 of US Dollars, so the debt is now $40,000. And it turns out that when we divide that by three that’s 13,300. And in this particular case only the US Dollar investor is profitable. So you can see that both of the the holder of the sBTC and the sETH are losers here in terms of net balance of negative 3,300. But the US Dollar investor has done really well ,so they’re up 6,600. So hopefully you can see here what’s going on that if you believe the prices are actually going down, there’s different ways you can actually implement this. But one way to implement is to actually go in and buy the sUSD, okay? So notice it profited when the US Dollar effectively did better than what happened with the other synxs/g1 I hear. So synthetix has got a platform decentralized exchange and there is a way a mechanism whereby trading actually happens. And basically the contracts are enforcing so that the users can only redeem their fees if they maintain a sufficient collateralization ratio. So no surprise that collateralization is going to be crucial in this protocol as well as other protocols, so this is again a very innovative idea. However, this is something that could be extremely volatile. The example that I gave you, you could see what happens in terms of the negative balances. So it turns out that the collateralization ratio currently to mint these synths and participate in the staking rewards is very high, so collateralization currently is 800%. So this is way higher than what we talked about previously for example and make her dow, we talked about pledging Ethereum and borrowing die minting die. That was like 150%, this is 800%. So it’s also the case that some of these SNX tokens are inflationary. So they’re also used not just as utility in terms of trading on the platform, but they’re also used to reward those that participate. And we’ve seen this before and defy that you can create incentives by allocating some tokens to those that actually participate. And we talked in detail about how compound actually does this. Well many of these defy protocols actually do this. So basically this is used as a way to get people to add liquidity to actually put up some of these large margins. So it’s a way to increase activity and the popularity of the platform. So it’s very interesting again that when this was originally launched, it was pretty narrow, but I’ve already shown you that they’ve expanded into different assets like stocks and stock indices and who knows where this actually ends. There will be options and again this idea of using the price feed is in my opinion, a very powerful idea. So back to our solution and problem sheet so we can create a synthetix asset that can track any real world asset, that’s like a powerful idea. So you’ve effectively tokenized, all you need is a reliable price feed and it doesn’t even need to be traded, you just need like a feed of data. Anyone can access and this is something that is efficient in terms of all you need is the price feed, you don’t need a trading floor or anything like that. And effectively because you’re backed by the price feed, there’s no slippage, which again is unique. So of course as all of these protocols the synthetics protocol is interoperable with others as we will see a little later on. And the fourth course in particular will go through some examples where we go from protocol to protocol.

04_tokenization

01_set-protocol-and-wrapped-bitcoin

01_set-protocol.en

So the fourth module in DeFi Deep Dive has to do with tokenization. And indeed we’re going to talk about not just tokenization but tokenization of tokenization. So this is it’s really interesting that there is a protocol called set and for a person that’s involved in asset management and this is like really attractive and innovative. So I’m excited about this protocol and let’s dive in. So, tokenization in general refers to taking an asset or a bundle of assets or portfolio. And this could be on chain, so it could be something that’s purely virtual, it could be off chain also. So it might be gold, which needs to be physically a stored but you can tokenize it and it has been tokenized already with the ERC-20 tokens. Okay, so the idea, one of the visions that I have is almost everything in the future will be tokenized. We’re just seeing the very beginning of this. So again these tokens could represent an asset and the asset beyond chain or off chain, it could be fractional ownership. And it’s also possible to have a compass a token that holds a number of other tokens. Okay, so a token of tokens somewhat analogous and traditional finance, where you can buy individual stocks or you could buy a mutual fund or an ETF that holds a portfolio of those stocks. Okay, so somewhat similar idea. So again, bring a look at ERC-20 tokens and I will talk a little later on in terms of all of the different ERC protocols but for now we’ll talk about the ERC 20. And most of the tokens that we’ve talked about our ERC-20. Okay so tokenization very important concept. We’ve talked about the 20 which is kind of the standard of fungible token. So one year ERC-20 is exactly so one di equals another die. They’re fungible. The 721 we’ve also talked about to some degree that is the nonfungible token sometimes called the deed because it gives you ownership of something. And those are our unique and nonfungible and many different applications we talked previously about. It could be fine art, it could be something in a game, it could be Music, it could be a video, there’s just no limit to this. So DeFi obviously takes advantage of these ERCs. And there’s a long list of the ERCs but the key thing is that it’s so easy for them to enter operate. So that said on tokenization, what is set going to do? So this is a protocol that establishes a standard for tokenized baskets. Okay so this is a protocol that establishes think of it as a composite token and you can decide what the composite actually is. So we’re going to use Ethereum based tokens. So ERC-20 tokens and effectively have a protocol to put them together and you can think of it roughly as in traditional finance an exchange traded fund. Okay, so the Set Protocol combines them and they’re actually called Sets. So the Set of tokens is also an ERC-20 token and basically it is going to be fully collateralized which is easy to do. In terms of using assets that are ERC-20 or Ethereum and again we’re creating something that is a composite. So there are at least two types of Sets. And the first Set is kind of like a mutual fund are passive mutual fund. So a Static Set is is basically a fixed bundle of tokens. Okay, so it might be that you create a portfolio of ERC-20 tokens and then somebody basically does that they’ve got a composite token that represents that portfolio and then you can invest in that. Much like there could be an ETF that buys all of the stocks or the S and p 500 stocks and just holds those stocks. And then you could buy that ETF and then buying that ETF you don’t need to go and buy the 500 stocks. So indeed you might not have enough money to actually buy round lots of those stocks. Okay, so you buy the ETF and you pay the fees that are associated with that ETF. Well with the Static Set, it’s kind of the same idea, you’re buying a composite token and the composite depending upon the Set has got a number of components that are static. So the best way to think about this is like the passive ETF. There’s nothing active going on here, it’s passive. So again this is a a number of these are offered and I’ve just got an example here of DeFi Pulse Index. And this is a Static Set of DeFi tokens. And it’s actually got 14 tokens in this DeFi index. And I show you here the top two are UNI which is the the token for the governance token for uniswap and AAVE which is both above 20%. And they’ve got 12 more tokens and you can see the maker right there. That M so the full list is available but you can see that the capitalization of this index is 143 million. Okay, so this is a compass a token that if you want to buy a diversified portfolio of DeFi tokens, you can buy this particular Static Set. Very nice idea. Rather than worrying about the portfolio of 14. Okay, what about a dynamic set? So this is particularly interesting to me, given my interest in active as a management. So a dynamic set defines a trading strategy. And there’s a number of ways to actually do this. But it could be a very simple rule, like a moving average. So the set defines the investment to be either 100% ETH or 100% USDC. Whenever the moving average crosses the X-day, simple or exponentially weighted moving average. So it’s a trading rule that’s implemented in this set. Okay, so this is very interesting. It’s the first product that I’ve seen anything like in the defy space. So it is analogous to an active hedge fund or a mutual fund. It is a little different in that the actual rule is visible, right? So you’re buying this moving average rule, so you’re buying into this particular trading strategy. The other thing is kind of interesting is that you can set this up and earn a fee. Okay, so very much like an asset manager is paid a fee. And for mutual funds and ETF, so it’s usually just a fixed fee that you pay, but in the hedge fund space there’s often performance fees. So in addition to the fixed fee, which who knows what it is, it could be 10 basis points, it could be 100 basis points. But the performance fee that depends on how much you actually make. So it might be if the return is let’s say 10%, then you might take 25% of that 10 or 2.5%. So again, that’s just a choice and you could set this up and people see exactly what the rules are, and they make a decision as to whether they want to participate. So it might be that I’ve got a protocol that says that there is going to be a fee of 100 basis points a year, that’s fixed. And there might be a performance fee and somebody else has got something that’s cheaper and the market decides. If I’m too expensive, then I’m not going to get any business. So, again, it’s a really fascinating idea. So again, I’ve just sketched the outline of the possibilities here. So like mutual funds, you can have a front end load or a fee to get in. You can have this fixed fee, that’s the parlance of traditional finance, but it’s more in defy a streaming fee. So because if it was just done once a year, people would just dump it the day before the end of the year. So it’s a streaming fee and also a performance fee. It’s interesting the protocol isn’t really taking fees at this time, but maybe in the future it will. So the protocol, so if you actually set up a set, so if I set up a trading strategy, I can determine whatever fee that I get. Okay so that is just completely up to me and it’s up to people participating. If they believe that I’ve got some skill or maybe they’ve seen my track record, maybe they’ve read my book and they want to allocate towards what I’m actually doing. So this is quite a powerful idea, and this is just an example of, this is called The Quant. It is a dynamic set that uses machine learning techniques, and it’s balancing between Bitcoin and a Stablecoin. And you can see the allocation at this particular point in time is 95% in Bitcoin and only roughly 5% in in the Stablecoin. But this is an active program that could actually switch from Bitcoin to the Stablecoin based upon the machine learning signals. So notice when I say Bitcoin that might be a little confusing because this is all on Ethereum and Bitcoin is not listed on Ethereum. But take a look and you can see that it says USDC for the US Dollar, but it says WBTC, which is wrapped Bitcoin, which is available on Ethereum. And we’re going to talk about that. So this is just an example of an active set. So of course there is an oracle that is necessary for the price feeds for this. Okay, so there needs to be some information that comes in to determine the trades. It is interesting also that you’ve got public view of the actual trading strategies. If it is algorithmic, it doesn’t necessarily have to be visible. So if you’ve got a dynamic set, people for example and what I just showed, don’t necessarily have access to the machine learning tools. So there is some discretionary nature to the dynamic sets. So set has also got the possibility of something called social trading. So basically a user can purchase a set portfolio that’s restricted to certain assets controlled by single trader. So I like a particular trader and I buy like a set that effectively follows that trader. And here it is kind of different than what we’ve talked about before because the trader is just doing what they’re doing. Right, so it’s not visible, they’ve got their own model, but you can actually buy in to what they’re doing. And that’s just an incredible idea in my opinion. So this allows us to Kind of invest in these potentially very sophisticated strategies that are only available today to certain hedge funds. But you can actually participate, anybody can participate. You can essentially follow that portfolio manager and profit when that portfolio manager does well. So it’s very interesting idea. So, let me give you an example and it’s a simple example, but I just want to emphasize the power of this particular protocol. So, we’ve got a portfolio manager for Set and basically the usual thing that we want to do in finance, want to buy low and sell high, okay? So that’s the key idea. And there are only two assets ETH and USDC. And there’s only two allocations that are allowed 100% or 0%. So it’s a very simple example, but it shows you kind of the idea, that I described the possibility of having a moving average rule that’s visible to anybody. And if you cross the moving average, then you’re 100% ETH, and if you’re below then you’re 100% USDC. This is different. So, this portfolio manager for a Set, they can do what they want as long as it’s 100% ETH or 100% USDC. So it’s up to their discretion. So maybe they’ve got much more sophisticated model than the moving average, and they’re not going to reveal it. But you’ve got a chance to actually participate, and indeed when you do that you’re injecting capital, injecting liquidity to support that particular trader, okay? So this is again, has got very strong restrictions as to what you can do that are visible to everybody, but the actual allocation is a discretionary allocation that isn’t necessarily visible in the particular a Set. So again, it’s very interesting for asset management. So let’s continue this example, suppose our Set portfolio manager, she starts with 1000 USDC and the price of ETH drops to 100, and she decides to buy. Okay, so a rebalance is triggered in the protocol. So this is something that the trader has got control over. And then the 1,000 USDC become 10 ETH. Okay, remember the rule that is either 100% USDC or 100% ETH. So now suppose that the price of ETH doubles to 200, the portfolio that started being worth 1,000 is now worth 2,000. So if you own 10% of that Set, then you could redeem for either one ETH or 200 USDC, okay? And you’ve doubled your money also. Now this abstracts from all the fees, but you get the idea of how this could actually work. Okay, so, I’m particularly excited about this protocol because it effectively democratizes wealth management, and wealth management is very undemocratic right now. So, I don’t have access to hedge fund investments, most of us don’t have access. So if you’re a high net worth individual, you’ve got access. If you’re a large pension plan or something like that, sovereign wealth fund, you’ve got access. But most of us don’t have access to these very attractive investments. But with this protocol in the future I see the possibility that very sophisticated investment products can be offered on Set and they are available to anybody. Now, of course, and we’ll talk about this in the fourth course, there’s regulatory risk here. So these are like securities. So that is an issue that is a particularly important issue in the US. Even though I talk about the US a lot, I’m based in the US on a Green Card, but this course is not just about the United States. So DeFi is not a United States phenomena, it’s a world phenomenon. So, again, this protocol extremely interesting because the sort of assets, we’ve talked about ETH and USDC. But we could use all of these other tokens that we’ve talked about, like the compound tokens, that ERC20 were ready to go. Okay, so there’s many possibilities here. And this is again, another good example of the DeFi Legos. So in terms of overall here, I think the main thing here is access for Set protocol, that now it’s possible for anybody to become a fund manager, okay? So I could become a fund manager with a Set protocol set. So it’s also possible for anyone to invest in a strategy that in the past was limited to high net worth individuals. Everything is tokenized, everything is interoperable. And for the Sets that are static, you see everything. For some of the Sets that are dynamic you also see everything, because it could be an algorithmic trading role. But there’s also the possibility that you’re just investing in somebody. So that’s this idea of social investing, that somebody with a reputation and Set allows us to do that.

02_wrapped-bitcoin.en

Let’s finish this module, and actually the course, by talking about something that we’ve seen already, this idea of wrapped Bitcoin. I showed you a screenshot of something that said Bitcoin, but actually this was operating in a DeFi protocol. There’s no DeFi protocol for Bitcoin. That’s really important. Bitcoin’s blockchain doesn’t allow, at this time, for any smart contracting. Bitcoin can be used in decentralized finance, and it can be used in the Ethereum blockchain by creating a wrapped version of Bitcoin, that is ERC 20. There are other DeFi blockchains that are available where you can do the same thing. But most of the focus in DeFi, perhaps 90 percent of the focus, is on Ethereum. This learning experience is really focused on the Ethereum blockchain. Let’s take a look. This is WBTC. Effectively, we’ve got off-chain assets which are Bitcoin that are wrapped. You can see the amount in terms of the wrapped Bitcoin. This is something that I showed you and set protocol where we’ve got the WBTC. We just saw this in the previous module. This WBTC allows bitcoin to be used in a DeFi. Given the size of Bitcoin, and it’s the largest crypto in terms of capitalization, it’s important to have it available in terms of a DeFi and wrapped Bitcoin is the way to actually do this. It’s actually interesting that within the crypto space, wrap Bitcoin or Bitcoin in general is considered a relatively stable asset. I know that seems almost comical because Bitcoin is not a stable asset, it’s a very volatile asset. But nevertheless, compared to some of the other tokens, Bitcoin is relatively low volatility. I’m not talking about stable coins here, I’m talking about other tokens, even Ethereum. There is some demand for using the wrapped Bitcoin within a DeFi. I point also to the white paper, which is something that you should take a look at, it’s quite a nice paper. What about the stakeholders here? Wrapped Bitcoin, think of it as an ecosystem. There’s three key stakeholders. We’ve got users, merchants, and custodians. Another way to think about this is Bitcoin is just not practical for smaller transactions. It just cost too much and slow. You can imagine something on the Ethereum blockchain that’s much more efficient and much lower cost. When Ethereum moves to their version 2, you can imagine a world where Bitcoin is actually used as the original vision of Satoshi Nakamoto as a transaction mechanism. But it’s used via a wrapped Bitcoin on the Ethereum blockchain. You can think of users as traders. That’s really where we are right now because we don’t have that the gas fees are too high for this to be practical for everyday transactions like buying your groceries. But in the future, it’s going to be different. Again, we can think of the current users as traders. You can purchase this WBT wrap Bitcoin per merchants and you can do that by transferring Bitcoin to them. You get the WBTC by actually transferring that Bitcoin and the merchant can go through, all of the requisite, know your customer, and anti-money laundering, all protocols, all of this is available to them. The merchants in this ecosystem, you can think of, are responsible for transferring the rapid coin to custodians. When that happens, at that point of transfer, there’s an on chain Ethereum action. This is basically a smart contract and it takes into account the custody of the Bitcoin. When that Bitcoin comes in, then you can actually mint the wrapped bitcoin. It’s very much analogous to a centralized stable coin. As US dollars are deposited in USDC, then the USDC is minted. Very analogous except there’s no physical storage but we do have this issue of Bitcoin being on another blockchain, so it’s not on the Ethereum blockchain. It’s not as clean as, let’s say, collateralized Dai with Ether. The custodians in this ecospace use industry-standard security mechanisms. Again, we can mint and we can also the possibility of redeeming, so it goes both ways here. Basically, the merchant is able to transfer the wrap Bitcoin to the users. This is a very interesting idea to get Bitcoin into the DeFi ecosystem. Again, as you would expect, there’s minting when new Bitcoin come in, it’s also possible that there’s burning. When does burning occur? Well, that occurs when there’s a withdrawal, so I want the Bitcoin back. One Bitcoin that’s wrapped goes in, it’s burned, and the actual Bitcoin comes back. This is crucial in the system. There’s no inflation or anything like that, there’s a one-for-one backing. But again, this is a little more complex because you’ve got two blockchains going on and Bitcoin doesn’t work in the Ethereum blockchain, but a wrapped Bitcoin can be created to work in the Ethereum blockchain. Another way to think about this, think of gold. Gold, you can create a token based upon that and the gold is warehoused. This is much more efficient because Bitcoin is a virtual asset, but setting up the security protocol that makes sure that everything is custody is really important for the success of this. There’s governance for wrapped Bitcoin. This is the mechanism where the merchants and custodians can enter and leave the network. It is a multi-signature wallet that’s controlled by the WBTC DAO, the decentralized autonomous organization. There’s a decentralized, but that mechanism is controlled by the DAO. There’s no governance token at this time, but there is a fairly large, but not too large set of owners that can add and remove owners. This is a little different in terms of the decentralized governance mechanisms that we’ve seen before because there’s no token, but it is constructed in a way that appears to be pretty careful and safe. I said that there’s a number of owners, but not too many. Well, right now the maximum is 50, which is a good group and the minimum is 11. The idea here, you don’t want too many owners and this is true with many of the DeFi protocols that anybody can own a governance token, but many of the protocols say, well, the people that are voting, we want the people to really invested in this, so you need like 100,000 tokens so your incentives are really aligned. If you have one or two tokens, you don’t really care that much about your investment. It’s the same idea. You’ve got a smaller group. The number of 50 or 11 can be changed by vote, but It is just a different way to think about the decentralization. I guess what I’m saying is that this is a little more centralized than the other protocols that we’ve talked about, but it’s still, in my opinion, decentralized. At the bottom here, I’ve got a price quote for the Bitcoin, and notice the market capitalization is very substantial. It’s like 3.7 billion. Of course that’s very small compared to Bitcoin, but nevertheless, that is a lot for what we’re talking about so early into this DeFi innovation. This is just a little more here, this is from Etherscan, which we’re going to see a lot of in the fourth course where I will go to Etherscan to show you particular contracts. This is just an example, how easy it is to actually see the contract that controls the wrapped Bitcoin. It’s got all sorts of information, the contract address, and the site and details in terms of the supply that’s available. Well, we talked about wrapped bitcoin, we’ve also, I think, talked a little bit about wrapped Ether. That is, why would you want to wrap Ether in Ethereum? It seems a little puzzling and I’ve mentioned this a little bit and we’ve seen the WETH in previous exhibits. It’s a fact that Ether is not an ERC-20 token. For these protocols that are using ERC-20 token, you need something that is an ERC-20, and that’s where wrapped Ethereum comes in. The wrapped Ethereum is really straightforward because it’s all within the same chain. The custody, the minting and burning, all visible, all in the same chain, all very straightforward. As a result, the wrapped Ethereum is completely decentralized. We don’t have the group of 50 or 11 that are deciding on this, this is completely a decentralized, is pegged to Ether. It is very straightforward to mint and burn. New Ether comes in, there’s minting. If the wrapped Ether goes back in or sold, then there’s burning. This is very straight forward within the same chain. It turns out that the wrapped Ethereum is going to disappear. People realized that it’s basically an oversight when they did the ERC-20 standard to not include the base currency Ethereum in the ERC-20. There are protocols that already exists today, for example, ERC-223, so that allows you to avoid the wrapped Ethereum and just use Ethereum. Some tokens actually use the 223. It’s been around for about four years, but there’s a lot of action here in terms of improvement of the ERC-20. ERC-20 is by far the dominant token standard, but there’s much more going on here. Just an example. The 223 is used by link. Link is the key token for chain link. Like I said, it’s not a small token, it has a very substantial token. But we’ve talked about the 721, which is the NFT standard. I mentioned briefly the 1155, which is a multi token standard and there’s just so many of these, you go to the ERC-20 site and you’ll see maybe 75 different ERCs and there’s also EIP, which is Ethereum improvement proposal. There’s many of these out there, and I’m just highlighting the main ones. Let me end off this course the usual way that I end off by looking at the word cloud. We made a lot of progress on the word cloud, and each time we’ve got more check marks. We’re getting there. There’s one more course, and there’s a number of words that are still left, six of them. These are very important words that we will deal with when we talk about DeFi, risks and opportunities. With any new technology there’s going to be risk. If there’s no risk, we don’t move forward. Again, this is very early in the life of DeFi. As I’ve mentioned many times, less than one percent. But to be successful in this space, you need to understand the risks and the potential ways that we can mitigate those risks and there’s a lot of them and that’s what we’re going to focus on in the next course.

05_Resources

01_module-1-video-slides

02_module-2-video-slides

03_module-3-video-slides

04_module-4-video-slides

4. Decentralized Finance (DeFi) Opportunities and Risks

01_smart-contract-risk

01_introduction-and-types-of-exploits

02_introduction-to-course.en

Welcome to the fourth course in this learning experience called DeFi and the Future of Finance. The fourth course will deal with the risks as well as the opportunities of the space. This is a new technology and there’s a large number of risks. Within this course, we’ll talk about many different sources of risk. We start with smart contract risk, we’ll talk about governance risk, DNS, exploit, Oracle risk, decentralized exchange risk, custodial risk. We talk about the important problem of scaling. By that, I mean that we need much more throughput in terms of transactions per second than we’ve got right now. We’ll talk about regulatory risk, including the threat or opportunity of central bank and digital currencies. We’ll also talk about the environmental impact of this particular space. I’ll do some calculations in terms of the amount of carbon that’s being used and we’ll have some commentary on the future. I’ll also talk about my vision for this space. You’ve got bits and pieces of that throughout these four courses. But what I’d like to do is to put it all together in the end and talk about where I see the space going and the challenges that it faces, and who will be the winners, and who will be the losers. I can’t tell you exactly who the winner and losers are going to be. I cannot see the future perfectly. I do have some ideas and it’s my job to give you those ideas. To start with, it’s important to realize that the types of risks that we’re dealing with in decentralized finance are different than the type of risks that we face in centralized finance. This is a new technology. Already you’ve seen that some types of risks appear to disappear. For example, counterparty risk, which is a big deal in centralized finance. You’re doing business with somebody and you expect them to pay, but they might not pay. Or maybe the collateralization goes underwater and there’s a delay in getting a margin, a posted, and there is loss as expected in a situation like that. It’s true that some of these risks are mitigated or eliminated with decentralized finance. But on the other hand, there is a new list of risks and it’s really important to understand those risks. What we’ll talk about largely in this course are the limitations. Many of you will actually get involved in the DeFi space. It’s crucial for you to understand the risks as well as the opportunities. A lot of what this course actually does is to arm you with the questions that need to ask. Often when you’re deciding whether to accept a job with a particular company or if you’re evaluating a pitch from a new company, you need to know the questions to ask. It’s not just about the opportunity. It is easy to sell the opportunity. But what I’m talking about is the management of the risk and there are many risks. For this technology to fully realize its potential, we need to provide a structure whereby the protocols are robust, they’re resilient to attack. We’re not there yet. This is another important lesson that given that we are so little into this disruption, so less than one percent, that these risks exist right now. It’s not as if this long list of risk that I’ll go through that half of them have been taken care of. That’s just not the case. That is maybe no surprise given that we’re maybe four years into DeFi. There’s a lot of work to do. Again, in joining in company or investing in a company, you need to hear from the company as to how they will deal with these risks and their opinion in terms of how this space will actually play out. Again, I will arm you with the right questions to ask and I will also speculate in terms of how this will play out in the future.

03_types-of-exploits.en

So let’s start off with the most obvious risk and that is smart contract risk. And I’ll spend some time on smart contract risk and I’ve divided it into a number of different sub modules. So the first is the type of exploit. So what are we talking here? We’re talking about a hack and I’m going to be careful in the way that I actually used the hack because sometimes hacks are very nefarious where people actually go in and steal a coin. There’s another type of hack that’s more like an arbitrage. You see an opportunity to take advantage of something and you do. So that’s not in the same category, in my opinion as the sort of hack that comes from an adversary that actually wants to steal something. So the sort of hacks that we are familiar with and I’ll talk about this to some degree, but not a lot are the hacks of these centralized exchanges. So there’s been a long list of them and people make the mistake of thinking, well these are Blockchain hacks. And it really has nothing to do with Blockchain and nothing to do with smart contracts. These are just centralized exchange. They’re like brokers and the security practices are poor and somebody comes in and exploits them. And I’ll go through some details, but that’s not really what we’re talking about here. So we’re talking in the DeFi space in terms of a smart contract. And the risks that are associated with having a contract that is not very well thought out or not very secure. So this is a new type of risk. Okay, so just to be clear and I said already that DeFi solve some problems are risk situations that we have in centralized finance, like counter party risk. But you introduce a new class of risks. And the key component in DeFi is a smart contract. So if there are issues with that smart contract, then that opens the door to an exploit. So let’s think about this risk. I think fascinating in that it’s just so different. So think about a hacker wanting to do some damage to, let’s say a centralized let’s say commercial bank. Well, the first thing that they need to do is to get into the bank systems and that might not be easy to do. But let’s they get in, then the second thing they need to do is to look at all the code, which could be hundreds of thousands of lines of code and to figure out where to attack and then they attack. Okay, so that is in the usual kind of centralized finance world and it’s not just centralized finance, its is basically the business world as we know it. Now contrast that with decentralized finance, so with decentralized finance, the code is public. You don’t need to hack in to see the code, it’s for anybody to look at and download. Okay, so it’s very interesting, as I said, that this is a new attack vector with the code is available to anyone. Okay, so that means you need to be like really, really careful. So for example, and in centralized finance, if you’ve got really good security and nobody can get in to your website. Even if your code has got some flaws, given that nobody can get in, you’re pretty well protected. So in decentralized finance, it is wide open for anybody to take a look and if there’s any flaw in that code, it’s going to be exploited. Okay so this is definitely what I call a new attack vector and it’s something that is basically unknown in traditional finance. And it points to the importance of having very high quality smart contracts. These smart contracts are not hundreds of thousands of lines, they’re actually pretty short and concise and you need to get it right. And part of what we’ll do in this course is highlight a number of situations where you don’t get it right. So what do you do to mitigate that risk? And it’s interesting in the DeFi ecosystem that there are a number of companies that have been founded that are doing quite well. And their single job is to do an audit of the smart contract code. Okay, so this is standard practice now where you develop, you’re smart contract and before for example, people transfer liquidity to that contract. You want to make sure that there are no mistakes. So we’ve got a history of smart contract compromises and again, I’ll go through some them like de force. We’ll talk about the history of these and to reduce the chance that there’s an exploit companies will employ a third party auditor to go through and to basically stress test the smart contract. Indeed, the stakes might be very high. So this could be a contract that effectively billions of dollars go to, it’s got to be really secure. So it’s sometimes the case that you employ not one auditor but two auditors just to make sure that everything is exactly right. So again, this is different from centralized finance because the code is available for anybody to see. So we’ll talk also about the sources of risk in terms of an exploit of a smart contract. So one obvious source of risk is. Like a logic error and in the code, okay? So, that is one category. There’s many categories, but there could be an economic exploit also, that will go through considerable detail that might involve an oracle, that could be manipulated. So, but the logic error is kind of the easiest to deal with, because that’s within the actual code. So it’s something that you definitely want to make sure there’s nothing, that is like that in the contract. So let me give you an example of a logic error. So, you might have a contract that basically, you hold tokens in that contract and it basically serves as an escrow. And let’s say we set this contract up so that it is a lottery and we’ve talked about lotteries before, that you can have a fair lottery. So people put their token into the contract, there’s going to be one winner that’s drawn. So let’s say that happens, and the contract is keeping track of how many tokens and fractions of tokens that it actually has. And then let’s say there’s some rounding somewhere, okay, so if that happens, then this could be devastating for the contract, because it might be that you round up a little bit. So let’s say the contract has got the equivalent of 999.99 of of the token. And let’s say the payout Is rounded up to one million for the lottery winner. So within the contract, it goes to transfer the one million to the winner. But, there’s insufficient funds because we’re short by one cent. It doesn’t sound like a big deal, but given that this is algorithmic and it might not be one cent, it might be a fraction of a cent. That that means that every time the contract tries to transfer the one million, the transfer fails. Okay, so again this is a devastating logic error because it means that $1 million minus one cent is going to be locked in that contract forever, okay? So things that don’t really seem like a big deal, could become devastating and and rounding is just an example, is actually a common example of something that you definitely want to avoid. And the worst possible scenario is where all of the funds are, we call it bricked in the smart contract they’re there, but there’s no way to get them out, it’s locked. Okay, so that’s an example of a logic error. Economic exploits are more subtle. And again, often it’s involving something outside of the smart contract that could be manipulated. So there’s no logic error in the code. But it could be that the contract is exchanging tokens and that it looks for a price through an oracle. And so in looking for that price, it’s possible to go to the oracle and potentially manipulate the oracle and cause an opportunity for an exploit. And this is actually a fairly common thing to do, to take advantage of illiquid decentralized exchange mechanisms and to manipulate the oracle price to get a better deal. This again is something that you might call it a hack, you might call it something else, that you see an opportunity, there’s nothing illegal that goes on here. This is basically everything is transparent, so anybody could actually do this. Okay, so this is just an economic exploit. So to be a little more specific here, the way that this would happen is you’ve got this oracle feed from another exchange, let’s say it’s a just a single feed and that exchange is not that liquid. And we’ve talked about this situation as to what happens when you’ve got illiquidity in the context of our constant function automated market makers. So given that there is not much liquidity, on the oracle exchange you sell heavily and when you do that, it reduces the price of the target token. And if it’s a liquid, it could very substantially reduce the price. And then you go to the more liquid contract that is using that illiquid contract as the price, the oracle price. And then you do the reverse you buy and you’re buying at a really cheap price. Okay, so you manipulate one feed to reduce the price and then you buy and you’re buying at a cheaper price and then eventually that will go up in value. So this is just an example and we’ll go through other examples like this, but this is an example of an economic exploit. So again, there’s a long list of exploits like this, but some of them are known as flash attacks. So we actually did a number of examples of using flash loans in the previous course. So we talked about a flash loan to refinance a loan. We also talked about a flash loan to take advantage of an arbitrage opportunity. So, So basically the situation here is, and I tried to make this clear in the previous class, that anybody can take a flash loan. Okay, so this is not restricted to the high network individuals. Okay, so these attacks can happen very quickly with very considerable size. So we’ll go through a few of them in this course and one of them will go through in great detail where you can see all of the transfers. So, I guess what I’m saying here is that in traditional finance, you might think of there being different markets for the same commodity, for instance. So oil is an example where there’s markets for oil, even within the US at different locations. And you might think of a strategy where at one location, maybe you can buy the oil cheap and then you could sell at another location where it’s more expensive. And even after the cost of transportation, but it’s way more complicated. First, I’ve already mentioned you have to actually transport all the commodity to the other exchange. And second is the time lag and actually doing that. So by the time you transport, maybe that higher price has decreased. And what seemed to be an arbitrage really isn’t. Okay, so in centralized finance, there’s a lot of risk and actually doing this. Whereas in decentralized finance, this happens near instantly at very low cost and anybody is welcome in these protocols to take out a flash loan to make this not a small exploit, but a large exploit. Okay, so flash loans play a very important role here. So again, it’s very very important to get this right. So it’s a bad idea in a smart contract to have an oracle that goes out to a single illiquid, decentralized exchange. You’re just asking for problems if that’s the case. So often that’s mitigated by using a number, not just one, but a number of liquid exchanges. But this is again, really important for this particular technology. There have been many of these flash attacks or exploits. And again, I just want to be careful here because I’m not using the word hack, though some people we’ll use the word hack, especially in the media. So, bZx is an example of one that was based on the flash attack. And basically the attacker took a flash loan, diverted funds to purchase a lever short position, and then manipulated the price of the oracle that the short position was based upon. And they closed the shop with the profit $300,000. It’s a small amount in the big picture of things, but it’s a good exploit to show you what the vulnerability is. So there’s a good example of an economic exploit and we’ve got plenty of examples like that. So this is in a little more detail what this attack actually looked like. And let me actually go through it. So the first thing is a flash loan on dYdX, which we just talked about for 10,000 Ether. Okay, so this is not a small flash loan if you think about the price of Ether at $2,000. And then 5500 Ether sent a compound to collateralize a loan of 112 wrapped Bitcoin which we talked about at the end of the third course. And then 1300 ETH sent to Fulcrum’s pToken and five times leverage short position is opened against the ETHBTC ratio. And then we get 5637 ETH borrowed and swapped to 51WBTC through Kyber which we also talked about Uniswap reserve, and that is exactly where the slippage occurred. So that was basically manipulating the price there. And then the attacker swapped 112 wBTC borrowed from compound to 6871 ETH on Uniswap and there you see the profit and the flash loan is paid back in the end. It’s all in one transaction, you can actually go through this,see the math and the profit was 1193 ETH. So again, this is like a key thing is that manipulation of the ETH liquid price that was based on like the oracle and this generated a profit for the attacker. So I’ve also got a screenshot from Etherscan. So Etherscan is a website where you can see everything that’s ever happened on the Ethereum Blockchain. So everything is there. So every block, every transaction is there. And I’ve highlighted the transaction hash of this particular exploit. And you can see the block number, you can see the address where it came from. And that address is an Ethereum address but the zero X on it, and notice that it’s labeled the bZx Exploiter number 1. So that is basically the address of the exploiter that went through did all of this, and generated a $300,000 profit. Some of the profits again are going to be much greater. And Etherscan also shows you the basics of the transaction. So it’s a little less detailed here, from what I just showed you. But you can see the borrow of Ether on the flash loan from dYdX. And remember when we talked about dYdX, that those flash loans come without a fee. There’s no fee associated with that to take a loan of that size, and no collateral. And notice in this transaction that you borrow, the first thing you do is borrow and then we’re supplying Ether to compound and that Collateral is used to borrow 112 WBTC. Then there’s a swamp on Kyber, and then the last line we repay the flash loan. So again, if anything happened that failed and the intermediate steps, then we return to the original state where there’s actually no flash loan. Okay, so this is an important property of this transaction with multiple steps that it is atomic. And that’s the reason that the flash loan is basically got no counter party risk, even though the person taking it out has got no collateral whatsoever. So this is a fairly simple exploit. I can represent the exploit in like five lines. We’re going to look at later on, much more complex exploits. But they add the same flavor. Where you’re borrowing something and then you use that borrowed fund as collateral, and you meant something else and then you use it and then you pay everything back on the final step. So this is the basic idea of an economic exploit, very important risk in the defib space.

02_the-doa-dforce-and-yearn-finance

01_the-doa.en

To talk about smart contract risk, you really have to start with the classic exploit, and that’s called the DAO. This is ancient history. But this is a very important episode. Again, many of you will work in this space. Maybe you’re not working in this space right now, but I predict that you will, especially given that you’re taking these four courses, so you need to know a little bit of history. This is a very good starting point. Again, this is going to be a type of exploit that is on the side of a logic error. There’s other issues with this contract that we will explore but let’s go and dive in to the DAO. DAO, that is Decentralized Autonomous Organization. It was set up shortly after Ethereum was launched with a really interesting idea. This was the first of its kind. Essentially the idea was that people would send Ethereum to a smart contract called the DAO, and they would get DAO tokens. Those tokens basically gave you the right to vote on essentially a venture capital fund. Think of the DAO, the purpose would be to allocate token to various startups, and then if the startup is successful, then basically the DAO would profit from that, and those that held the token would have like a rate of return. Just think of it as a venture capital fund. In traditional finance, investors give the venture capitalists some funds and those funds are usually locked up for awhile, and it could be actually multiple years. Then the venture capitalist deploys those funds to invest in various different ventures, and then if they work out, then the original investors, they actually make a profit. Again, there’s a lockup and this is essentially analogous but in the DeFi space. This is a smart contract and designed by slock.it. But at the time it was such a shocking idea that you’ve got a company if you even want to call it, that. It’s a contract. There’s no CEO, there’s no board of directors. There’s no headquarters or anything like that. It’s just a contract and the DAO holders are voting as to what to invest in. It’s really a fascinating idea for the next type of business, if you want to call that in the world. It’s very, very exciting. On the Ethereum blockchain, it is code that is available for anybody to take a look at. This open source nature, again, as I’ve emphasized, creates an opportunity so many people can scrutinize the smart contract and basically potentially find a vulnerability. This was launched on April 4th. Actually, between April 4th and April 30th in 2016. Again, you can take a look at it, so you can go to Etherscan and go to the particular block and you can see this. At the time, a huge amount of ether was allocated to this particular contract. Fourteen percent of all of the ether at the time was dumped into the DAO and the DAO was actively traded on exchanges. This is an early example of a tokenization in 2016. Let’s take a look, again, I’ll be going to Etherscan a number times. You can do this with the information and you can see all of the details for that particular block. The gas, the contract hash, the timestamp, all of this stuff is available including the actual source code. That’s what it looks like on Etherscan, and coin market cap in 2016 was just a startup on its own. It’s interesting to look at this in its own right. Check that out. The price of Bitcoin, $731, which is much different than today, Ethereum 18.85. Notice that the number five token here, we’ve got Litecoin, we’ve got Ripple, and then the number five token is the DAO and you can see the available supply of DAO, you see the trading volume and you see the price at about 17 cents. The total capitalization is $200 million, which again is a large chunk of Ethereum. This is what happened: in June 9, basically, some developers reported that there is a bug and the bug is called reentrancy and it’s fairly well-known, it’s especially well-known now after the DAO, but this is basically a bug that makes it possible to empty funds from a contract. Interestingly, just a few days later, the founder of Slock.it, said the Dao code was not vulnerable to this type of exploit. Let me give you a basic intuition as to what this exploit actually does. Effectively, two lines are out-of-order. So the code’s fine, except for two lines that are flipped. Essentially it allows the attacker to continue to withdraw from the contract without a check of the balance. Think of this in centralized finance or commercial banking in the following way, I go to the teller physically at the bank and withdraw a $100 and I got the a $100 and then I had another slip and ask for another $100, but the account isn’t checked to see if I’ve got that $100. So this just keeps on going on time and time again until the bank runs out of money. This bug is extremely serious, but Slock.it said, “not a big deal for the Dao, it’s immune to this problem.” But the Dao is attacked on June 17th, 2016. An attacker goes in and drains 50 million of Ether, which is again 30 percent of the Ether in the account. Remember, if we’re thinking of the price of Ether today, this is a multi billion dollar attack. This is not a small attack. So 30 percent is drained, and this is very interesting. Another group called the Robinhood group uses the same exploit and drains the other 70 percent, so the contract’s completely drained. The difference with the Robinhood group and the DAO attacker is the Robinhood group actually pledges to give back everything that they’ve drained to the original people that put the Ether into the contract. I guess, appropriately named Robinhood, and not to be confused with Robinhood, the Fintech app, it has nothing to do with them. So basically June 17th, the contract is drained, 30 percent is gone, and 70 percent could be returned to the users. Remember I told you with the venture capital fund that there’s usually a lock-up period. So you put your money in and then there is a certain period before you can withdraw. But turns out that the DAO smart contract had something similar to that, but it wasn’t multiple years, it was 28 days. Effectively, I say that the contract is drained. It will be in 28 days, so it’s a hold on, but it’s going to happen. If nothing changes, then it will be drained. When I say they drain everything, it’s a sure thing. In 28 days, 30 percent will go to the attacker, 70 percent to Robinhood, and people are faced with a loss of 30 percent of their token. Again, there’s many layers to the story, which is fascinating. The Ethereum community, started to debate as to what to do about this. Just a couple of different possibilities. This contract was flawed, well, this is what happens with a flawed contract. Somebody will exploit it and you pay the price and next time maybe you learn. The other possibility, given the 28 days, is that the community might actually consider the possibility of rewriting history, and going back and fixing the contract. That’s a big debate. In the meantime, take a look at what happened to market value. Notice that the number 5 is the DAO still, but it loses 56 percent of its value. Ethereum also loses some value because it is linked to the DAO. Remember, that I told you one of the key properties of blockchain technology is that the ledger is immutable. That means that once something is there it’s there forever in theory. We also talked about the sort of situations that make that fragile. We talked about 51 percent attack, where you’ve got the majority can basically go and change history, if there is agreement amongst the majority. Well, it turns out, in the case of Ethereum, there was agreement to go back and to fork the Ethereum or blockchain and to basically undo that contract, so that would mean that nobody lost any either, and that’s exactly what happened. Again, very contentious decision. Many people were split on us, especially the Bitcoin people. It’s just really hard to imagine anything like that could happen in the Bitcoin space because no smart contract to begin with, but to actually rewrite history, very contentious. With a fork, the idea is you’ve got a shared history and then the protocol changes. It also turns out that the older version still lives. The old version that includes the flawed smart contract, the DAO, is called Ethereum Classic. It is a token that is traded today. It’s actually not a small token. In that particular space, 30 percent of the Ethereum Classic tokens were lost to the attacker and Robinhood group gave back the 70 percent. We’ll talk more about these forks. I’ll come back to this particular example. If you’re holding Ethereum, when you fork, your wallet is automatically populated with a new token. You have the old token, Ethereum, but you’ve got a new token called Ethereum Classic. There’s another layer to the story that we’ll talk about later on in the course when we talk about regulatory risk. It turned out that after all this has happened, the US Securities and Exchange Commission decided that the DAO token was a security. Actually, we’ll go through the framework that you use to determine if something is a security or not. But it’s obvious that the DAO token, in hindsight at least, was a security. It is like investing in a venture capital fund. That would be a security. You expect a profit on your actual investment. That basically is the end of the DAO. If it is a security, then there’s a lot of regulations that will go through later on in the course that apply to it in the US. Again, there’s so many different layers to this particular story. Given that I’ve already talked about a fork, let me just give you a little more information on forks. There are different types of forks. There’s a hard fork and a soft fork. Soft fork is a minor software upgrade and it means that everything is backward compatible. Even if you didn’t upgrade, your program that you’re running is going to work fine. Think of Ethereum as having two pieces to it. There’s some code that runs a program on a node. Then there’s a database, which is the Ethereum block-chain, which everybody has on their computer, that is a node. A soft fork. They happened fairly regularly. If you upgrade, fine, if you don’t upgrade, you don’t have to, but most people do these upgrades, and they’re not contentious, and there’s no consensus mechanism that’s necessary for that. That’s a soft fork. Hard forks are major changes. When we’re talking about the DAO and basically the forking of Ethereum to change history, that’s a big deal. That is a hard fork and the hard fork is not backward compatible with previous versions. With a hard fork, all of the nodes need to follow the new rules. In terms of the type of hard forks, there are basically two types. One is something that’s planned. The idea is floated as an improvement proposal, and it’s vetted, and there’s widespread agreement, we have a date and a target block where the upgrade or the fork is going to happen. That’s a planned and there’s been many of those, but there’s also contentious. I put ETC in parenths because ETC, or Ethereum Classic, that was a big deal. There was a lot of disagreement over that particular fork. Bitcoin also as forked many times. There’s many different versions of Bitcoin that are out there and these are hard forks also. Remember, we talked about forking, and forking is something that applies to software in general. It is, in a way, an advantage of the DeFi space that you can do an improvement very quickly and create something that’s better. The Ethereum fork that created Ethereum Classic, and I say created, but a theorem classic is just a continuation of the original protocol. That was subject to a big debate. Let me give you some examples, other examples of a hard fork. We’re actually just going through this right now in terms of Ethereum. By the time you see this course, London Hard Fork will be deployed. It basically there’s a number of improvements in that fork, but there’s bigger things. Like a really big change would be to move, for example, from proof of work to proof of stake. Change the consensus mechanism. That is a huge change. There’s other things that, especially in Bitcoin and a lot of debate over block size, it’s really difficult to get agreement in the Bitcoin community. They’ve debated years over whether they should increase the block size, which would give them more transactions per second and potentially reduce the cost of transacting. But it was very contentious because the miners and Bitcoin are very powerful. They liked the small block because that means their fee is already high to get into the Bitcoin block chain. They get paid by a fee and they also get paid by the reward of newly minted Bitcoin. Another example is changing the hashing algorithm. We know that bitcoin uses a SHA-256. Ethereum uses Keccak 256. Those are completely different. A theory of miner is useless in mining Bitcoin and vice versa. But you can imagine it would be very contentious to change the hashing algorithm because that means that all of the hardware and the proof of workspace would be obsolete. Again, this would be an example of a hard fork that would be contentious. This is what a fork look like. You’ve got a shared history on the left and then you’ve got your updated software, but the original software remains. The first three boxes are the shared history that Ethereum Classic and the Ethereum both recognize and then when the fork occurs, the original software is the Ethereum Classic and the green boxes denote the forked version of Ethereum that the community agreed upon. Again, the wallets are identical. If you had a 1,000 Ethereum before the fork, then your wallet would have a 1,000 Ethereum after the fork and a 1,000 Ethereum Classic. This just comes into your wallet. Again, I’ve got some recent data from coin market cap and you can see that Ethereum has much larger market capitalization than Ethereum Classic. Most people stuck with the agreed upon change and Ethereum, but nevertheless, that fork is still valuable. If you had, let’s say 10 Ether into your wallet, all of the sudden comes 10 Ethereum Classic. You can see that that’s actually valuable. You get something. It’s kind of interesting, this whole a process of forking where something just comes into your wallet. It’s like the old version or a new version, another fork. Again, you share the history, but you’ve got a new set of transactions that happen going forward. There are two different chains. In the basement here, we’ve got a miner that used to mine Ethereum, but then basically didn’t have enough memory to actually continue to mine Ethereum. We actually switched over and we’re mining Ethereum Classic. Again, it’s the same hashing algorithm, the Keccak 256 for Ethereum Classic. Given the right machine, you could mine on either of them, but we’re constrained in terms of the memory of our machine and that’s why we’re forced to do the Ethereum Classic. Again, this is a contentious. Take a look at the history here. I’m showing you the hash rate and on the y-axis, it is the number of tera hashes per second. A billion hashes per second. The scale is a log scale, so don’t be misled by the scale. But what I wanted to show you is what happened at the point of the fork. You can see before the fork, we’ve got a shared Hashrate, and then after the fork, not that much happens with the Hashrate for a theorem because the community agreed to support the fork, but you can see that it’s a rough start for Ethereum Classic, while the Hashrate drops very dramatically immediately. But then some miners see the opportunity that the Ethereum Classic would be supported and you can see that the Hashrate jumps up and stabilizes. It tracks the Ethereum Hashrate. But notice that the Ethereum Hashrate is 22 times greater than the Hashrate for Ethereum Classic. I mentioned the London upgrade that was originally proposed by Vitalik, a number of years ago. That is basically scheduled for August 4th or 5th, 2021. I’ve talked about this briefly, but there’s a number of improvement protocols within this fork. This is agreed upon by the community. Some of them were more contentious than others. But I’ve mentioned the 1159 before and let me mention it again because it’s very important for this protocol. All of these improvements make it a little more friendly to interact as a user with Ethereum. I mentioned previously the problem with the gas fees in Ethereum. This improvement, 1159, what it does is, it simplifies. The user is going to pay a gas fee that is automatically calculated by the wallet. With MetaMask, it would immediately calculate the base fee and that would be enough to get that transaction through another process. This is really important. The base fee doesn’t go to the miner. The base fee, once it goes in, is burned. The idea here is that the miner will be compensated with a tip. If you want your transaction in as soon as possible, then you attach a tip. The tip will put you to the front of the queue and you’ll get in much faster than somebody who doesn’t put a tip in or has a very small tip. In the past, the miners got everything. Because of the tip and you think about equivalent of the base fee is all in the gas fee. This is different and it’s important. It’s important because the Ethereum is going to be burned. There is no hard limit on Ethereum, actually, most don’t know that. They know that Bitcoin has got 21 million as a limit and some people know that we’ll stop mining Bitcoin in the year 2140. But Ethereum doesn’t have anything like that. It is inflationary. The other good thing about the burning of the base fee is that it acts as a deflationary force. Ethereum are being created on every block and there’s a reward for the miners in doing that. But this is a way to actually counteract that to some degree by burning and actually indeed, some believe that that will make Ethereum more valuable. This is an important one. Let’s not confuse this London main net when this is deployed, let’s not confuse that with Ethereum 2.0. That is way bigger than this particular hard fork. Ethereum 2.0 changes the consensus mechanism. We go from proof of work to proof of stake, because that’s a really big one. That is going to take longer but will likely happen in 2022.

02_dforce-yearn-finance.en

Spending a lot of time on smart contract recipe is so important. I want to go through a couple of exploits to show you the steps and indeed, I’m doing this on purpose because it reinforces some of the concepts that we’ve covered in the first three courses, so you see this in action. To actually go through an exploit reinforces the material that I’ve been going through. This is a hackers. Again, this gets a lot of attention in the media. Basically, hackers attack China’s dForce for 25 million in Ethereum. It’s using a vulnerability in ERC777. Let’s go through what actually happened. Here I’m actually quoting the press. This is DForce. It’s a Chinese decentralized finance protocol, lost 25 million of cryptocurrency with a well-known exploit of an Ethereum token. Money was drained this morning from the contracts of Lendf.Me, a lending protocol that’s part of dForce. A collection of DeFi protocols. The site for Lendf.Me is now offline. Basically the funds were sent to DeFi lending protocols, Compound and Aave, and about 10 million of the funds were sent to Aave. That’s Stani who’s basically making this statement. This is, again, a well-known type of exploit. We’ve talked about these exploits before. Basically, what I like to do is go into a little more detail as to what actually happened here. There’s a Uniswap attack and it took advantage of this 777. The way that this was set up, that the hacker was continually withdrawing the 777 funds from Uniswap before the balance updated. Remember that? Sets exactly what we were talking about before. Gradually draining the contracts. There’s dForce, even though this sounds really similar to what we talked about earlier in the course, it is similar. Take a look at what happened to dForce, that you can see the total locked value, Total locked value, remember, that is the liquidity that is pledged and it goes to ERO. What’s interesting, maybe funny, but the hackers actually sent some money back to Lendf.Me and attached a note. You can put metadata into these transactions. You can put a message in if you want. The message was better luck next time. Interesting, but this is the most interesting part. I want you to really appreciate this because I think it is a very deep comment. This is from Robert Leshner, who’s the CEO of Compound. Compound, we’ve gone through in considerable detail. Lendf.Me basically took that code. They can take the code because it’s open source. But there was a report in The Block, which I think I’ve mentioned is a very high-quality source of information that I get every day, and what the researchers at The Block actually did was to take a very careful look at the Lendf.Me code, and they were surprised to see four different references to the word Compound. What’s going on here? I want to read this quote by Robert Leshner. “If a project doesn’t have the expertise to develop its own smart contracts, and instead steals and redeploys someone else’s copyrighted code, it’s a sign that they don’t have the capacity or intention to consider security.” Let’s unpack that. The first thing is that he mentions copyrighted code. Well, it’s really hard. This is open source. People copy this code all the time. Maybe you can apply for copyright in the US, but this is a global situation. Let’s delete the word copyright, but everything else he says is spot on in my opinion. You’ve got a group that likely is unable to put a smart contract together from scratch. They grab the contract, make some minor changes to it , and they’re often running. Robert Leshner’s point here is a good point, that you need to have the internal capability. I’m okay with working and to some degree, the vampirism where you actually go and grab some code that’s out there already and make an improvement upon that. That is a strength of the defy space. But when you’ve got a situation where somebody grabs the code and basically can’t even be bothered to look at it and take the references out to compound. These are like comments in the code. They can’t even be bothered to take out the references to compound. That’s got to be a red flag, and the risk is realized. Let’s talk about another one. This is one of my favorites. Again, this is an exploit. I’m not calling this a hack. This is a very elegant exploit. Yearn is a yield aggregator. We’ve talked about this a number of times in the course. In the third course, we talked about this in a second. This idea that there’s various different protocols where you can earn a savings rate. You can basically deploy your asset and earn a rate of return, but you also get an equity token, which represents your share of that liquidity. Then you can redeploy that equity token and essentially create extra return. Then we’ve also talked about the possibility of arbitrage amongst different protocols using flash loans in terms of rates of return. The example I gave was refinancing a loan. That was the first example of the flash loan, where we had a rate that was high, another protocol, it was low. We could use the flash loan to actually refinance at the lower right. Well, it goes the other way too in terms of when you’re actually depositing the money. You want to actually get the highest possible rate of return. There’s a number of companies that are optimizing and making it easier for the user. The user doesn’t need to worry about writing a transaction that has multiple steps with the flash loan and all the stuff. Let’s give that task to somebody else and they can find the best possible rate of return and Yearn is in that category. It’s a nice business idea. I want to go through what actually happen. This is a situation where about 2.8 million stolen by the attacker out of a total loss of 11 million. This is a complex exploit. I’ve shown you a few exploits that are basically five steps. This exploit is 161 steps. It is a great example of what is possible in terms of both decentralized finance, arbitrage and exploit. This is what it looks like. I want you to notice the timestamp line where it says one day, 49 minutes ago. When I actually did this, this exploit happened while I was teaching in person. I had to talk about it in my class. It happened before the class, a day before the class. This is just the screen grab from Etherscan, where you can see the transaction hash. You can see the address at the very bottom, where that is the Ethereum address of the Yearn yDai Exploiter. This is the transaction. If we go to the actual details of this transaction, you’re going to see that many of the names are familiar to you. I’m showing the first 10 lines here. Look at the very first thing that happens. We’re going to borrow 116,000 Ether from dYdX. This is not a small borrow. This is a major borrow. This is like $200 million flash loan with no collateral whatsoever. I’m not going to go through all the steps, but you can see that it follows the same thing that we’re going to take some Ether and supply it to compound, and then from compound we’re going to borrow Dai, and then we’re going to borrow somewhere else. We’re going to repay. Then just keep on multiple steps. Look at the players here, dYdX we talked about. Compound, we talked about in great detail. Dai, USDC, Aave is at the bottom, Uniswap, all of these companies are protocols we’ve actually talked about in the course. Again, this is the first 10 steps of this actual transaction. You can see 161 token transfers, and I’m just showing a small amount. You can see there’s other stuff that goes on. We see some wrapped Ether, and in other things we see some Tether. We haven’t talked a lot about Tether, but even Tether is in play here. This is, again, enormously complex, very unusual with a 161 different transfers to basically do arbitrage amongst different protocols, and the exploit very successful. Again, this one, I don’t call a hack. For me, this is somebody that is spent some time to figure out the complexities of this space, and has taken advantage, using the tools that are available to anybody. Again, it is to me that this could be anybody. This could be somebody in high school that has no capital or whatsoever, that starts this off with a $200 million loan. It’s very, very powerful. The bottom line here is that we call them smart contracts. Usually I don’t like things that have smart in front of them as an adjective, because often they’re not smart. Smart contracts are just algorithms. With any algorithm, it could be high-quality or it could have a flaw. The key thing is that once you deploy with the flaw, it is set in stone in the Ethereum blockchain or any blockchain. We did talk about this rewriting history. I seriously doubt that will ever happen again. This was very early on in Ethereum. Ethereum was new. They knew that there would be some growing pains, and many people basically gave them a pass in 2016. But the probability of that happening again today is pretty close to zero. We’re almost done with this module. But there’s one more thing that I’ve talked about indirectly, and you might hear this lingo called a rug pull. Let me end with that. This is what a rug pull is. You create a token, and you launch it on a DEX. You launch it, you put in some money, which might be USDC or something like that with equal amount to this brand new token. You start talking up the token, saying it’s a great token. Then you also offer a very high reward for supplying liquidity, like really high. Let’s say that you could get four percent for supplying liquidity, let’s say in MEGA Dow. This new token, you can earn 14 percent or 20 percent. People actually start to put money in, and when the money comes in, the price of the token actually goes up. As people commit, the price goes up. Then at some point the rug is pulled. Basically what happens is that the people behind the token just dump all of their token. That will drive the price to zero. It doesn’t start at zero though. It starts at the high price that these retail investors have actually created by contributing and buying the token. This is something that you need to be aware of. It is another risk of DeFi. Indeed, some of the exploits that we’ve talked about effectively are doing something very similar, that at some point they will get out. I’ve got a few more examples of this. In particular, I have an example with the true USD and a rug pull that happened there that was very dramatic. Again, with a new token, you need to be very, very careful. It’s got to be vetted. Don’t be misled by interest rates that don’t make any sense. Somebody is offering a 20 percent rate of return. You should be very skeptical. In just regular finance, if you offer 20 percent rate of return, there’s probably a good reason for it. It’s because it’s really risky. It’s so risky that the company might fail. Beware here, it is a risk.

02_governance-dns-oracle-dex-and-custodial-risk

01_attacks

01_governance-attack.en

In the second module, we’re going to talk about some other types of risk: governance risk, DNS, Oracle risk, DEX risk, and custodial risk. I’m going to start with governance risk. I’ve already highlighted previously an exploit called the rug pull. Let’s actually go through an example here of governance risk. Indeed, it’s interesting within this space, there were no governance attacks until this year. I’ll highlight one of those attacks. What does governance risk mean? Well, it is a situation where the controllers of the protocol could make some changes that are unfavorable. There’s many mechanisms to prevent that. It might be that the DeFi protocols launched, the developers have control and it’s not fully decentralized. It could be that the developers do some things that basically just profit for themselves. Now, of course, the community could get very upset about that. Indeed, it is possible that a fork could be created in terms of like another protocol launched to undo some of these changes. It would be new protocol, but having the advantage that it didn’t have these negative changes. There is some riskier. We’ve gone through different types of risk already in terms of smart contract risk. But even like MakerDAO, when we’re talking about that, that’s a decentralized credit facility. There is governance with the Maker token. It’s a decentralized governance. Is it possible that a group of people could gain control of the governance token and do things that undermine the actual protocol? That’s a type of governance risk. This is an area of DeFi that people really haven’t figured out the perfect solution here. There’s many different ideas as to how to do governance. There are many different ideas as to how to do consensus. Different protocols have different approaches. I mentioned one protocol that had a committee of up to 50 people and no fewer than 11. Another protocol might have a governance token that’s available for anybody to vote. Another protocol might have governance token, but you need a sufficient number of token to be qualified to vote. Another protocol might have a rule that’s different than 51 percent. It might be that there’s a quorum that’s necessary. Once you’ve got the quorum, then 51 percent of the quorum, I guess so, maybe the quorum is 50 percent, effectively, 26 percent of the holders could actually control a change. There’s many different choices that go on here. All of this is under this idea of governance risk. In deep, we’ve talked about this idea of a 51 percent attack. In Bitcoin, if there is a minor that has got 51 percent, then probabilistically, they can do what they want. Of course, if they do what they want and try to drain funds, then people completely lose their faith in the protocol. But nevertheless, 51 percent in Bitcoin is enough and 51 percent and most of these profile protocols is enough to create problem. Again, I’ve mentioned this. I’ll mention again because it’s important. When the DeFi protocol is initially launched, it’s usually not completely decentralized. There’s a time period where the developers have a lot of control, which they need to clean up the protocol, to make changes, to make it more efficient, to fix bugs, and things like that. But to be truly decentralized, then you move to the next level, which would be, for example, issuing a governance token. Let’s actually look at one particular example. This has to do with the protocol that you don’t necessarily need the 51 percent to be successful. It is often the case that you do need to have some financial resources to do this. This is not like a flash attack. You actually have to have some capital behind you to actually be a player in a governance attack. Just think about if you’re buying the governance token, you need some capital to actually do that. This is not a situation where you do a flash loan buy the capital and then the governance token and then pay back the loan, that’s not going to work that way. You need to have some financial means to actually pull this off. You also need to worry about something that I’ve already mentioned. Remember I said that for Bitcoin, if somebody grabbed 51 percent, then people would lose all faith in Bitcoin and it would plunge in value. It doesn’t make any sense even if you had to 51 percent to do anything nefarious because you spent all of the resources to get to that 51 percent and then you control it, but then it’s worth nothing so you need to think of a way to actually monetize. Again, these governance attacks, there hasn’t been anything like it until recently. I’m going to go through the details of an attack on True Seigniorage Dollar, so TSD. I’ve got basically the Twitter thread as to what happened, but I’ve summarized it. The hacker is going to amass governance token. Remember I said that for this type of exploit, you need to be financially equipped. TSD is not a big protocol, so it doesn’t take a massive amount of money to do this, but nevertheless, this is what the hacker actually does. It turns out that the developers held only nine percent of the governance. The hacker got enough to actually put forward a proposal. Given that the hacker had effectively a large proportion of the governance token, the hacker decides to mint, so the vote is to mint him or herself. 11.5 quintillion TSDs, so that’s obviously a direct benefit. Then you need to somehow monetize that. Immediately what happens is the hacker dumps as many of these TSDs as possible on Pancakeswap which is very much like Uniswap, the same idea. It’s a DEX, it’s a constant product automated market maker. Essentially, what’s happening here is that as you sell that TSD, the price is going down and down and down. Even though the hacker has minted him or herself 11.5 quintillion TSD, by the time that they dump 11.8 billion, the price is already extremely close to zero, so it’s no use going any further. You can see what happened in terms of the value, and this is the ride all the way down from about $23 to zero. Again, the price is going down on each sale, but this is how the hacker actually was able to essentially go in, take over the protocol, mint themselves, some of the TSDs, and then dump them quickly on an exchange. They dumped as many as they could. They walk away with the profit, and basically what happens to TSD, it’s destroyed, this is what happens in terms of decentralized finance. This is a known situation that is exactly the way this works. Take a look at the very last sentence of this thread from the True Seigniorage Dollar developers. You can see the official site at Trueseigniorage, the last sentence, let me read it to you. I’ll read the whole thing. In the implementation, the attacker added code to mint for himself 11.8 billion TSD. He then sold all of the tokens to Pancakeswap. That’s sad, but it is an attack but it is how a decentralized DAO works. Actually, just to be clear, the tweet actually says 11.8 was minted, actually way more was minted. It was 11.5 quintillion, so it’s a little inaccurate, but that’s not the point here. The point here is that the people behind this protocol said, “Well, it’s bad for us, but this is how Dev and a DAO actually works. If you lose a control to an adversary, then this is the risk that you actually face.

02_dns-attack.en

Next, let’s talk about a DNS attack. Basically, a DNS attack is nothing that’s special to DeFi. It’s a common threat that if you’re online, it’s possible that some attacker can basically masquerade as your website. This is, I think, the only risk within my list of risks that is a common risk across anything that deals with the Internet. The only reason that I’m talking about a DNS attack is that there is a special lesson to be learned from a particular episode. Basically Cream Finance and PancakeSwap, which we actually just mentioned as a protocol that’s very similar to Unisswap. They were hit with the DNS attacks. Again, this happens. But the lesson, I think is really important, checkout. This is from PancakeSwap and from Cream Finance. They’re confirming the DNS attack, “DO NOT go to Pancakeswap until we confirm it is all clear.” This is the most important thing. “NEVER EVER, input your seed phrase or private keys on a website.” This is exactly what happened. In Cream Finance the same thing that, “We will never ask you to submit any private key or seed phrase.” Private keys, we talked about, seed phrase when you set up your MetaMask wallet, you have the seed phrase, remember I told you to write it down. Don’t have it connected to the Internet. Effectively the way this attack actually worked was that the hackers took over the DNS, people thought they were going to Cream Finance or to PancakeSwap, and then they were asked to give their seed phrase. With the seed phrase, the hackers drained their tokens. Remember, if you give up your private key, if you lose your private key, then you’ve lost your token. It’s gone. That’s exactly what was happening. The lesson here is not as much about a DNS attack, which is a common attack, the lesson here is that if a protocol is asking you for your private key, then it’s got a problem. You just don’t do that.

03_oracle-attack.en

Next let’s talk about an Oracle attack. We’ve actually already talked about some situations where an Oracle is essentially based upon some data feed, and that data feed could be manipulated. We’re already quite familiar with this, but oracles are another on the list of issues in DeFi. We’ve already talked about things like what is the optimal governance? What is the best consensus protocol? Well, oracles are another issue that there’s still a lot of research on as to how to actually do this. Oracles, as I’ve described previously, are a way to get information into a blockchain that doesn’t actually exist on the chain so that information needs to be obtained outside. It might be a market price from, for example, an exchange, it might be some other type of data. But you need to go outside and when you go outside that immediately creates risk. We’ve talked about some of the risk in terms of manipulating the data source, but there’s a host of other issues that are involved here. The key thing is the Oracle needs to be reliable. You need to agree upon up to your Oracle. If you’re entering into a contract, people need to agree what the Oracle actually is. It might be, for example, and this is a completely different application, you put some information into a smart contract like a will and there would be payouts if there is a record of death of the person that provided liquidity to that smart contract. You need an Oracle to figure out if that person is alive or dead, and you need to agree upon that. That Oracle might be, for example, the Social Security Database. The program would go outside of a blockchain and check that database to see if the person was alive or dead. If the person is deceased, then the tokens are deployed to certain addresses. Again, this has got to be very secure and little things like the website to get that information might actually change. You get a 404 going to that particular website and then all of sudden the funds could be bricked in the smart contract. Again, all of this stuff needs to be worked out. The economics are really straightforward here that exploiters are going to figure out what the cost of corruption is and the potential profit from corruption of the Oracle, the simple calculation, if the profits greater then they will attack. There’s different types of oracles, of course. There’s a Schelling point Oracle, and this is where you rely upon a number of voters. There’s a fixed supply of tokens that are actually voted. A good example of this is Auger, which got a number of interesting markets. You should look them up. But the Oracle is really important in terms of the outcomes. Again, even something simple like a sports event, there needs to be a feed that tells you what the final score is. It can be really complicated because there could be a winner declared, but then the next time maybe there’s a disqualification, so you need to work in all of these possibilities. One issue with an Oracle like the Schelling point is it’s not very quick. Often within decentralized finance, we need speed. There’s other types of articles, like API, Oracle, and this what chain link is probably, in my opinion, the leading company at this point in terms of Oracle technology. Basically, the turnaround in terms of getting the information is a lot faster. Application-specific oracles, very popular. We’ve already talked about the Maker Oracle, which is used, Compound also. Compound, for example, relies upon a single data provider. Other protocols might have a portfolio of different data providers. Again, all of these are choices that are really important. There’s so many layers of risk in DeFi that we’re learning. Smart contract risk is way up there. Governance risk is rare, but it’s still a big risk. But Oracle risk is really high on the list of important factors. We know that these unchained oracles could be front-run. Again, let me emphasize, when we talk about front running in DeFi this is not illegal. Everything is open, everything is public. It’s also the case that DeFi relies upon all of these Legos that are inter-operable, that are operating 24/7. There’s no holiday, there’s no downtime. We’ve had situations where there had been outages in chain-link and Maker. When there’s no Oracle, then basically the DeFi protocol stops working; you can’t do anything. You go out for the data that you need and the data doesn’t exist. Basically, the transaction just stops or it reverts to the original state. This is important. It is an ongoing issue. There could be a whole course on oracles and how to construct them, the different types, and the different risks. But this is definitely a top-three risk.

02_risks

01_dex-risk.en

Another category risk is DEX risk or decentralized exchange risk. I put it in the list of risks, but we’ve really already talked about the risks, that are involved with decentralized exchange. We’ve talked about, in great detail the Uniswap of version 2 automated market maker, and you remember with the constant product, and some of the issues that are involved with these automated market makers. We also talked about how to handle the order books in exchange, and whether to have an on-chain order book, or something off-chain, and the risks that we deal with that. We indeed talked about an interesting potential solution, abusing a layer too, to do the limit order book. But again, there are different protocols that use different approaches, some of them are better than others, and we will see. Again in this space, given that is so young, you might try a number of different things. But the one that people go to, must be working to the best. Then others change towards that particular protocol. Again, this idea of how do we store all the information that happens before an exchange actually happens? I’ve shown you the order books before, and I’ve shown you where the buy orders and sell orders meet and the spread between the two. But there’s so much other information that isn’t yet implemented, so it’s not necessarily a transaction, it’s just like a bid and an offer, but all of that needs to be taken care of. This is a challenge with the decentralized exchanges. We’ve talked about the constant function, market maker in terms of Uniswap of version 2. We’ve also talked about the version 3, that is more akin to a limit order book, where you can specify a range for the liquidity that you actually allocate. We’ve talked about some innovations in that space. Where you’re going to have a pool, with multiple assets, with different sizes of the assets, like in Balancer. Again, the way that these protocols work, we notice some of the downsides, like the impermanent loss. We know that if you allocate liquidity, to a DEX, then you’re actually earning a return based upon the transactions. If there’s a transaction, might be 30 basic points, that goes into the pool, and you’re being compensated by that. Liquidity obviously is another issue here, if there’s insufficient liquidity, then that it’s going to lead to potentially very large slippage, and potentially very large impermanent loss. We spent a lot of time going through the details of the impermanent loss. Just to review that, because it is so important, that if you allocate liquidity to, let’s say version 2 Uniswap, and then when you do that, there’s an equal amount of asset 1 and asset 2. Then if there’s a deviation in those prices, then there will be an impermanent loss, and the impairment loss is basically just the Opportunity Cost. If you had held, those two assets rather than deploying them to the automated market maker, then you would be better off. The size of that loss is a direct function of the volatility of the exchange rate between the two assets. Something like USDC and ether, that’s got very large volatility and it will have large and impermanent loss, whereas something like Dai, and USDC both stable coins, give you a very volatility, very low impermanent loss. These are our risks that people face when they’re actually deploy liquidity to something like a constant function automated market maker. We’ve talked a little bit about these ordered books, and I’ve suggested that having an on-chain order-book is something that doesn’t make a lot of sense today. Given the cost of gas, to have something on-chain is just too expensive. When it’s to expense of, there’s just not going to be sufficient liquidity. In the future, when we go to Ethereum 2.0, the on-chain order-book becomes much more reasonable, because the cost of doing on-chain transactions will be a greatly decreased. Off-chain, that it’s got advantages and disadvantages. It really depends on how you do it, so you need to do it, in a very secure fashion. We talked about dYdX, they’ve got a layer 2, so that is a multi signature wallet that’s very secure, and it greatly reduces the number of on-chain transactions. When there is a transaction, so when you actually meet the bid and the ask, the buyer and the seller. When the transaction actually occurs, then that goes on-chain. But all of the bids and the ass, are kept in this layer two, where the cost of actually transacting it’s close to zero. There’s different ways to do this, in different advantages. The point here is that again, like other issues in DeFi, there’s many different approaches to decentralized the change. We will see what happens, and those that implement a technique that is too costly or is insecure, they will not succeed, so it’s basically the fittest will survive, in this particular space. It is like a natural selection on steroids.

02_custodial-risk.en

Another type of risk is custodial risk. We’ve mentioned this before also. I’ve said, if you lose your private keys, then there’s no backup. They’re gone. If somebody grabs her private key, then they’re just going to spend your coin. You need to be very careful here. Let’s just review what we’re talking about here. The private key is a long random number. The public key is derived from the private key. It’s mathematically derived in the Ethereum using elliptic curve mathematics. This a one way function. You go from the private key, which is this long random number, to a public key, which is you can show anybody because using current technology, you can’t go the other way. Then your public address, in Ethereum is very simple. It’s like a hash of your public key. A KCAK got 256. Really straightforward. Then there’s also digital signatures. You use your private key for that also. This’s important to understand. That with a dollar bill, it’s got a serial number on it. If I give you that dollar bill, I paid you one dollar, then the serial number doesn’t change, so you’ve got the same serial number. In the space of cryptocurrency, that analogy doesn’t work. If I want to send you some Ether, I’ve got some Ether with the private key. You generate a new private key, a new random number. Then you put that through the elliptic curve algorithm. You get a public key, you hash it, you get an address. Then I send you less a one Ether, and what I do is that I sign that transaction and I sign it in a way with my private key and with other information so that anybody that sees that signature knows that my address is basically got the private key. When I sign it over to you, now the Ether is associated with your private key. That is the way it works, very important. Again, you lose the private key is very, very bad news. This is a type of risk. It’s a different type of risk. In traditional finance, you lose your credit card, somebody finds a credit card and starts to spend. Well, no big deal for you because you call the credit card company and they undo all of the other spending. In this space, there’s nothing like that. You lose the key, then that’s it. Let’s talk about different types of custody. There’s self-custody. This is your own solution to store crypto assets. You’re not involving anybody else. There’s partial custody. This is where you share custody with somebody as a backup. BitGo is an example of this. I’ll talk about this a little bit, but think of dividing the private key into three parts. You keep two and BitGo keeps one. If you lose one of your parts, then any two of the three can reconstruct the key. Very nice idea. Then you can actually just delegate your custody. It might be that you deal with Coinbase, a centralized exchange, and they just keep your keys. But there could be other custodians that you actually use. Retail investors, there’s many different ways you could do this. Again, self custody which could be that you keep your private keys on your computer. I don’t advise that. If the computers hooked up to the Internet, way better to keep them on a USB drive that’s disconnected from the Internet. You can also have a wallet. There’s hardware wallets that exists that are separate from the Internet, but you actually keep them in a very secure location. Lots of possibilities here. Again, decentralized exchanges are more than glad to hold your keys. I showed you this before, but this is an example of a New York Times story by Nathaniel Popper that details this developer that has his keys in a hardware wallet, and that hardware wallet has got a password, that he’s forgotten. There’s about $200 million of Bitcoin in his wallet. He has tried eight passwords. In the hardware wallet, there is a limit on the number of tries, and that limit is 10. If he doesn’t hit the password by the 10th, then the hardware physically destroys itself. It wipes out the information about the private keys. Even if you do self custody like this with specialized Harbor wallet, beware. If you lose your password, then effectively you’ve lost your Bitcoin. Let me talk a little bit because I mentioned this about exchange hacks and there’s been many hacks of exchanges. Mt. Gox, maybe the most famous and there were actually a number of different attacks and these are large hacks, 850,000 Bitcoin. Think about the value of that today. These are very, very substantial. Again this is a situation, it has nothing to do with the Bitcoin or Ethereum blockchain. It has to do with the security at the centralized exchange. An attacker basically gets in to the computers of the centralized exchange, they find out where the private keys are stored and then they take the private keys. What do I mean by take? Well, they just basically copy the information. There’s no deletion or anything like that, they just copy the information and then with that information, with the private keys, they’re able to basically create a situation where they can send that token or coin to somewhere else that they control. By the time that the hack is discovered, and let’s say I’ve made the mistake of trusting my private key with an exchange. The hacker comes in, sees the private key, and then basically spends that coin to send it somewhere else. Well, the private keys still exists. The exchange is good at but it doesn’t have any coin behind it. It’s got a zero balance. That’s this idea that you actually sign over the crypto in with a digital signature algorithm, you sign over to somebody else. These exchanges you can request your private keys. It’s a possibility you can always ask them for the private keys just like in a centralized exchange in the stock market, you can request that the stock which is usually held in your broker’s name, you can request to your broker that the stock is transferred to your name and that will take a couple of days to actually happen. Again, this is fairly common and this is purely a result of inadequate security at these exchanges. It’s remarkable to me that some of these exchanges have had multiple hacks. Again you need to be careful. In terms of delegation and custody, you need to be careful obviously. You delegate to the broker, the broker potentially could be hacked and then he would lose your wealth. Exchanges of kind of decentralized exchanges have smarten up about this. What they will do is have the private keys stored in what’s known as cold storage. Be very careful not to have the keys accessible to a hacker. What this means is that load up a USB drive with multiple backups of the same thing and keep those drives in a vault not connected to the Internet. That’s the cold storage. They also have what’s known as a hot wallet so just to do the daily churn of transactions you need to have some keys available. You can’t be going to the vault, unlocking it and putting the USB key in all the time. There are mechanisms whereby some of the keys are available and those keys in the hot wallet are vulnerable to an attacker coming in. Coinbase is interesting because they’re actually insured. They’ve got an insurance policy that’s written so that if there was a hack then the insurer pays off. But again let’s be a little careful here, because the insurance policy is only secure as the insurance company. The insurance company they use is a very well known company to their credit. But again nothing reduces this risk to zero. In terms of the infrastructure here we’ve talked about wallets, the hot wallet, the cold wallet that exchangers use. We can have software storage mechanism. We can have the hardware wallet that I mentioned with the programmer that is locked out. There’s other technologies here. Indeed, there’s multiparty computation that is growing in popularity that essentially reduces the need or eliminates the need for a private key. I mentioned BitGo and I want to talk about BitGo in a little more detail because it’s an intriguing idea. I’m going to give you the intuition as to how it works, it’s not exactly how it works, but you get the idea. The idea is that two out of three pieces of a private key reconstitute the private key. Let’s say I’ve got one third on my mobile phone, I got one third on a USB and then BitGo has got the other third. Let’s say a hacker attacks BitGo and harvest all of their one-thirds. It’s useless to them, so one third can’t do anything. What we can do is just reconstitute the key with the two that are available and then give BitGo another third. Another scenario is that I lose my mobile phone. Well, I’ve got the USB, and BitGo has got the other third. We can reconstitute the key. This is just a way to mitigate risk. Indeed, you could think of another technology, re-do three out of five if this is really a lot of capital. This is just an evolving space. Again, one of the issues here is latency. I’ve already mentioned that if you’re in cold storage, that’s going to slow things down in terms of transactions because you need to retrieve the information from a cold storage. But there’s many other issues here. In terms of the custodians, this list I’m sure will change but things, like we’ve already talked about BitGo, about Coinbase Trust, Fidelity, is in this list also, along with many other banks, are looking to custody the crypto. There’s many other institutions that are actively researching this idea of custody. Indeed, if you think about a financial institution, they provide custodial services for stocks and bonds and other assets. Given the growth of the crypto space, it makes sense that they expand into custody, into other areas. Another issue here is the regulatory environment and we’ll talk about regulatory risk a little later on, but this is a little different. This is such a new space that a number of large investment funds believed that it would be useful to invest in this space, either for trading or for long-term holding. Certain decentralized finance assets. Whether it’s Ethereum, whether it’s governance tokens, whether it’s even Bitcoin. But the problem is that there’s really no clarity on how to do the custody. A number of companies have not been investing in this space because it’s so difficult to custody. Indeed, for those that are interested in trading, they might go to a regulated exchange like the CME and trade, Bitcoin or Ethereum there. In the future’s market, you don’t need to worry about custody because the futures are cash-settled, so we get around it that way. But that is very restrictive, very special market and really you want to open up the larger space. But that’s really been very difficult. It’s only recently that custodians have been approved so that a company can actually trust somebody with reputation to hold their private keys. You can imagine that an investment fund wouldn’t necessarily want to hold their private keys at the fund. Because if there was a hack and those keys got removed, then the investment fund would be liable for everything that’s lost. It’s far better to use a custodian to take care of that security. Again, this is a space that is just developing, but it is a space where we’ll see a lot of growth in the future. Once we get the custodial issues settled, it’s going to be interesting because it opens the gate for many investment funds to actually participate. There’s been a lot of demand for things like Bitcoin or Ethereum ETFs, but they’re not approved in the US. Why is there demand for those ETFs? Why would you want to hold an ETF that basically all they do is, let’s say some Ethereum ETF, they just buy Ethereum and vault it and then you pay a fee? Why would you want to do that, when you can easily just buy the Ethereum? Again, these large funds have this problem in holding the private keys. They would prefer not to buy the ETF. They would prefer to actually hold the underlying because it’s much more profitable to do that, the lack of fees, but they need somebody to act as the custody or custodial for that particular asset. Again, if you think about the dynamics here, once that happens, then that could significantly increase the demand for many different cryptocurrencies.

03_scaling-risk

01_alternative-consensus-and-vertical-and-horizontal-scaling

01_alternative-consensus.en

In the third module, we’re going to talk about one of the big issues that is an issue right now in the DeFi space but there are a number of initiatives to mitigate this risk and this is called scaling risk. What do I mean by that? There are trade-offs in the blockchain space and Vitalik came up with this idea of the blockchain trilemma. You want something that’s decentralized. You want something that scalable, and you want something that’s secure and there’s some obvious trade-offs here. Decentralized is an advantage because there’s no central point of failure. Scalability, we want very high transactions per second and we want something that’s secure, resilient to attacks. But the more decentralized you are, the slower it is and there’s a lack of scalability. If you’ve got a blockchain that’s more centralized, then you can do a very large number of transactions per second. Think about what actually goes on with proof of work is very costly to actually go and find that really rare hash. The mechanism takes a lot of the time, it is decentralized. This a trade off that everybody considers. It is a a trilemma that we try to address. We try to make changes that have the minimal amount of trade off. But Scaling risk is a really big deal. Both Bitcoin and Ethereum use proof of work right now. This is a very energy intensive technology. It doesn’t scale, so the number of transactions per second is pretty low. We’ve got a mining network that is doing all of this redundant calculation and it is a limitation that we’ve seen in Ethereum space or the gas fees have gone a number times to levels that are really hurting DeFi because if the fee is so high, then people just don’t participate or only those that have very large amounts of wealth are able to participate. It goes against this idea of the financial democracy. Ethereum right now is something like 15 transactions per second. There’s just no way with 15 transactions per second, you have a chance of competing let’s say with Visa. Visa can do 65, 75,000 transactions per second. This is less than 0.1 percent just one credit card or debit card network. This is pretty an existential problem and many have thought about solutions to this particular problem. What can be done to increase the number of transactions per second? Again, this is not a new problem. It’s an old problem. But so far, not a lot of progress has been made in terms of actually implementing stuff. There’s a lot of ideas that are out there. The main idea is a major change to the Ethereum blockchain. This is Ethereum 2.0 and that is to shift to proof of stake. This is a new consensus algorithm, it’s not proof of work. Basically there are certain actors in the network that have staked a certain amount of Ethereum. Depending upon the size you stake, there is like a probabilistic assignment to basically mine a block, so validate the transactions and propose a new block. If there’s any nefarious action, we get the staking mechanism whereby you have to literally pay on your stick if you do something nefarious. This is something that is much more efficient, that deals directly with this main problem in terms of speed. This can handle way more transactions per second potentially on the scale of something like Visa. There’s also some risks. There’s always the possibility of the malicious behavior and especially in a situation where you can potentially profit from the block more than the stake that you’ve actually put in. That has to be made impossible. There’s also this very subtle thing that the more Ethereum you have, the higher the probability that you are asked to mine, which means you’re going to amass even more Ethereum. In a way, what happens here is that it becomes maybe a little more centralized in that the rich get richer in terms of this mechanism. That’s another issue with proof of stake. There’s positives and negatives. But in the end, the proof of work just isn’t feasible. It just can’t work in terms of the vision of DeFi in the future. The main thing that will happen sometime likely in 2022 is the move to Ethereum 2.0 with the proof of stake mechanism.

02_vertical-and-horizontal-scaling.en

Scaling risk is a major risk. It’s got to be fixed. Actually, there’s more than one way to deal with this. We’ve already talked about changing consensus, which is a major step, but there’s other ideas out there. I want to talk about vertical and horizontal scaling. A vertical scaling basically centralizes to some degree the transaction processing. Think of having some super-nodes that are handling the actual key transactions and there’s a number of cryptos out there that have a situation like this. This is exactly the trade-off, the trilemma; a trade-off that I talked about. If you look at the Ethereum network, you’ve got all of these nodes out there and you’ve got miners, and it’s very decentralized. Whereas with this vertical scaling, it is more centralized. There’s some key nodes that are really important and you get from that speed, so Solana can actually do 50,000 transactions per second right now. Another one is Algorand, so again, this is like a really difficult trade-off that you become less decentralized, but you greatly increase the transaction speed. There’s another idea here, and that’s horizontal scaling and it’s sometimes known as sharding. Sharding is a word that you need to know and it’s a word in my word cloud that we’ll see at the end of the course as usual. Think of this as dividing a block chain into different pieces, so there’s multiple chains and then there is a master chain that connects them, so you can go from one shard to another shard and this is actually also part of Ethereum 2.0. Just to be clear here, 75,000 transactions per second is not enough in terms of the future for DPhi. This effort has got multiple components to it and all of these components are focused on increasing the transactions per second and increasing the latency. Again, Ethereum 2 supposedly just with the sharding, we can do 50,000 transactions per second, which is a massive improvement compared to what we have today. The sharding that will occur is 64, that’s the proposal right now, 64 different shards. This has not been settled yet. There’s a lot of detail that hasn’t been worked out, but it’s definitely moving forward. Sharding’s got a lot of risks, of course, one risk is just the way that the shards actually communicate with each other. Often the idea is that certain shards are assigned to do certain things. DPhi might be on one of the shards, but there needs to be communication. It’s also a risk that an adversary potentially could take over one of the shards and cause damage, but I think that’s not a big risk because the proof of work is replaced by proof of stake, and with the proof of stake, what would happen is, given the stake you put up, you would be randomly assigned to propose a block in a randomly chosen shard. This idea of amassing enough computing power to take over a shard, I think is low-probability nevertheless, it is a risk that we need to consider. This is all being worked out. This is something that can be very important. I say that the Ethereum 2 is going to use 64 shards and that’s a proposal, but there’s no reason that you can’t go beyond 64. It is like, in a way, parallel computing.

02_layer-2-and-rollups

01_layer-2.en

Okay. Yet another idea in terms of scaling. We’ve already talked about a little bit in terms of dy/dx, and that’s this idea of Layer 2. In the context of dy/dx, they basically are collecting all of the bids and they asks the people wanting to sell or buy and what they’re willing to pay or sell at, they’re collecting all that information in a Layer 2 system and I’ve described that as a multi-signature wallet. This idea of Layer 2 has been around for a while. Layer 2 is operational and Bitcoin and Ethereum, but it’s not as popular as people had hoped. I’ll go through a detailed example as to how it works. I believe it will become more popular in the future and I think dy/dx is a good example of an implementation that makes a lot of sense. Essentially what’s happening here is that in the Layer 2, you can allow for a lot of small transactions at a very low fee if there’s any fee whatsoever. Then only at certain points you go out to the main chain. It might be an initial transaction to seed a vault, and it might be a terminal transaction where we take funds out of that vault. But everything that happens is basically within this vault, within the context of multi-signature wallet. This is especially useful for these small transactions. It’s useful for things that aren’t transactions yet, like a bid or an offer. Let’s actually go through to see how this happens. In a way I’ve got this example of Coinbase, is providing something similar that if you trade with Coinbase, it’s a centralized exchange. Not all of their transactions are unchained because they’ve got, think of it as a float where they’re matching buyers and sellers. They don’t need to worry about transferring the keys because they have custody over all the keys. If somebody wants to buy a Bitcoin, but somebody who wants to sell a Bitcoin, they just put them together. There’s no need to do in unchain a transaction. If that person that buys eventually once their private key, that’s a different story. But essentially a lot of that stuff just goes on and they don’t need to actually go to the Bitcoin blockchain. Layer 2 provides something similar, but it’s a much more general, much more secure. Let me go through my example of Layer 2 which is not a defy example. It’s me going to Starbucks and getting a coffee. It’s doesn’t make any sense for me to pay for the coffee with an unchained transaction. Because the cost of the unchained transaction is more than the cost of the coffee. What I’m going to do is I’m going to set up a multi-signature address, that is going to be shared between me and Starbucks and this is how it’s going to work. What I will do is we’re going to open this vault and I will deposit 0.05 ETH and Starbucks deposits nothing. We’ve got a ledger where I’ve got 0.05 and Starbucks is got 0.00. This is going to be the payment channel ledger. This is an unchained transaction and it’s really just a one-way transaction for me. I see that I’ve got the 0.05, so it’s completely transparent and Starbucks sees that 0.05. Again, this is one transaction unchain. Now let’s think about me going to Starbucks, I order a coffee and what we do is we just update the ledger that is off chain. But again, multi-signature is very secure. You can see the new balance is that I go from 0.05 to 0.045 and Starbucks gets 0.005. Again, this is very straightforward update of the ledger. I could continue to buy coffee until the balance is exhausted. Indeed, this could go the other way if I don’t like the coffee or Starbucks gave me the wrong one they could actually refund to me the cost of the coffee. But in this ledger, it gets down to 0.015 for my account and 0.035 for Starbucks. Again, we’re doing multiple transactions. All of this is off chain and there’s no gas fee that’s associated with this. At any time, either party can repatriate. I could pull out my 0 015 at any point, and Starbucks can repatriate their 0.035, or any fraction of that, you can’t take out more than you actually have. Starbucks cannot touch my balance and I can’t touch theirs, but we can actually do an unchained transaction to pull money out of the vault. Again, there’s one transaction that is unchained to seed the vault. Then there’s another transaction on-chain to actually pull money out of the vault, but potentially within the vault, there could be thousands of transactions that happen that are off-chain but are very secure. Again, this is really important that there’s no way that Starbucks can touch my coin. I’ve got complete control over my balance and I can’t deal with their coin either and there’s no way that Starbucks could block me from withdrawing my coin. That’s very important. The other thing is that you might think, wow, this is really potentially inefficient. That, I have to set up a wallet or a vault with Starbucks. What if I don’t have a vault with Starbucks? Let me introduce Amber. Amber and I have a payment channel, but Amber doesn’t have a payment channel with Starbucks. Amber wants a coffee at Starbucks, and you know where I’m going here. That there’s actually two transactions that happen. There’s one transaction where Amber sends the money for the coffee to the wallet that we share, Amber and I. Then, I’m able to send from there to Starbucks, so it’s a passthrough. This is a very cool idea because it allows for a network effect. In general, there’s going to be all of these channels, and within the Layer 2 network, you find the most efficient route to get from, let’s say Amber to Starbucks, and there’s many different ways to actually do the root, but you want to have as few hops as possible. Again, what this allows is that not everybody has to have these redundant wallets that you can rely upon the network to get this particular effect. There’s a number of concerns that fall with the Layer 2 that you are pre-funding our future payments. Is that really true because it’s like having a second wallet, maybe a purse is a better example? We’ve got some money in one purse, money and another purse, but both, it’s yours. This isn’t pre-funding. It’s just keeping your funding somewhere else. There’s other concerns like you don’t want to lock up your funds and use them elsewhere. Well, again, that’s evolving also, in that there will be protocols that will allow for some rewards, for some liquidity, and this idea of closing and opening the channel, it’s a real pain to do in terms of replenishing funds or pulling funds out. Again, this completely depends upon the particular application. I’ve given a very simple application in terms of buying coffee at Starbucks. There are other applications like the dYdX Layer 2 applications where this is just completely irrelevant. Again, this is a good idea. You don’t need to have hundreds of channels. You can have a few channels, and if enough people in the network have channels, then we could actually use this technology, and the goal here is really clear. What we’re doing is moving the smaller transactions off-chain. Move small transactions or move things that are quite transactions yet, like in dYdX. Effectively when you do that, it is increasing the number of transactions per second via the Layer 2 technology.

02_rollups.en

There’s a fourth idea. All of these ideas are focused on scaling, but the fourth idea is something called a rollup. What does that mean? It’s actually very related to the layer 2 that we just actually talked about. The idea here is to create a mechanism where transactions are aggregated. There’s a secure area like the layer 2, there potentially is staking that’s involved to ensure that everything is done properly and there’s no nefarious actions. We take all of these transactions and think of taking a hash of all of the transactions, and there could be thousands of them. With this aggregation, that’s what actually goes out and use for an on-chain transaction. Instead of doing every single one of the components with thousands potentially of unchained transactions, we’re able to aggregate and this is called an optimistic rollup. We aggregate and when we do that, we greatly increase the number of transactions per second. This aggregation has been worked out. Cryptography is definitely used here as it is in other components, but the key thing is to make this as secure as possible. But the idea is a great idea and this idea is much easier to implement than, let’s say, sharding or changing from proof of work to proof of stake. It’s much more straightforward to actually post a summary of transactions rather than going transaction by transaction. Again, the theory has been around for awhile, there are still some issues in terms of implementing this, but this is definitely part of the Ethereum 2 schedule. Again, if you think about scaling here, we’ve gone through a lot of detail in terms of scaling, the key thing for me to communicate to you is that there’s a number of different initiatives. This isn’t just one thing like going to proof of stake. No, there are at least four different prongs to scaling. Why is that? Well, it’s because it’s so important, that as I mentioned, DeFi has no chance of achieving the vision of creating basically a revolution in the financial infrastructure if it can only do 15 transactions per second. This is a risk, but is the type of risk that for years we’ve got very positive initiatives and indeed, there is a timetable where we could see that we will get much higher throughput in terms of transactions per second in 2022. Indeed, I talk about this in terms of Ethereum, and this course is heavily oriented towards Ethereum. There are other DeFi protocols that are not Ethereum, that act like Ethereum, they share many properties, smart contracts, but they’ve already implemented proof of stake, so they’re already able to do tens of thousands of transactions per second, so that’s another force. Ethereum, they need to change because they’ve got competitor blockchains that are offering much more efficient transactions. It’s also the case that still more than 90 percent of the developers and 90 percent of the DeFi is focused on Ethereum. That’s basically a vote of confidence that there will be these changes going forward so that the transactions per second become much more competitive with both centralized finance and alternative blockchains in the decentralized finance space.

04_regulatory-and-environmental-risk

01_regulatory-and-environmental-risk-cbdc-competition

01_regulatory-risk.en

Okay, let me talk now about regulatory risk, and this is such a vast topic, that’s very difficult to select what I need to talk about in a short period of time. This is an area that is brand new. So when the laws were developed, for example, for securities, there’s no Blockchain, there’s no Bitcoin, there’s no Ethereum, so it poses a lot of risk. So we think about regulatory risk, we think of KYC, which is Know Your Customer, and AML which is Anti-Money Laundering. So within the US at least, these are important regulations and a merchant that is accepting a payment needs to know who their customer actually is. There are certain things that go on in the DeFi space that we’ll talk about, that are not allowed in the US. So for example, trading securities as tokens, they’re not registered. So some of the centralized exchanges and decentralized need to geo block certain countries like the United States. And this of course applies in general, in business, that we need to worry about who your customer actually is. This is just an example, this is FTX, popular centralized exchange that deals with decentralized finance and you can see actually where they’re trading here. GME and US dollars, GME is GameStop, the meme stock. And you can see the order book on the right and notice at the top FTF services and FTX token, FTT are not available in the United States or other prohibited jurisdictions. So that’s just the way that it is in terms of the regulatory environment. I mentioned earlier in the learning experience, the stable coin basis, which is an algorithmic, stable coin, so it’s not collateralized and they had to close down, they returned the funds that were pledged, and basically, you can see what they said. That unfortunately having to apply US securities regulations to the system had a serious negative impact on our ability to launch Basis, I’m sad to share the news, we have decided to return capital to our investors and the project will be shutting down. So again, we need to know the legal aspects are important. We’ve talked a lot about governance tokens, so, we need to be careful, the protocols that are launching a governor in star tokens, so compound basically launched their governance token, and basically saying that they had no intrinsic value. Well, it certainly has intrinsic value today. So, some of these governance tokens are at risk of being within the context of securities regulation. So right now, they’re okay, the future remains at risk. And of course, this course is about the risk. There’s also money transmitter laws. So, if there is exchange, this is actually in the US extremely complicated, because there’s over 50 regulators that you have to deal with, one for each state and sometimes a territory. So this is a particularly important and the regulations in New York, which is the most important state for centralized finance are the most strict regulations in the US. So I’ll talk about this a little bit later. But you need to be careful here even within the US. If the regulatory environment is really strict in a particular state, then what happens? Well, the protocol relocates to a friendly state like Wyoming. So states need to be careful on this. So tax is another issue and I can’t go through all of the details here. It seems obvious to reasonable people that if you buy a crypto and it goes up in value, that that is a capital gain. One of the problems is that if you’re using your own wallet, that people are not reporting this. So if you’re using a centralized exchange or broker, then that would be reported. So there is some difficulty in actually enforcing. So in terms of the risk here, there’s so many regulators, I know this course is about global, it’s about DeFi and the world, but the fact is that most of the innovation in DeFi to date is actually coming from the US. So, US issues are important and there’s many different regulators. So you have to deal with, whether it’s the SEC, the CFTC, the Treasury, the Internal Revenue Service for Tax and it could be State Tax also, and there’s also the FTC, the Federal Trade Commission. So again, you’ve got all of the state regulations also. So I want to talk a little bit about the SEC because one nugget, great importance is understanding what the law in the US deems a security. So this comes from the SEC, the Securities and Exchange Commission and basically it was established in the wake of the 1929 great Crash. And in that Crash, many uninformed investors got completely wiped out. And the basic idea here is that the SEC put in a number of regulations to reduce the risk that uninformed investors are taken advantage of, to reduce the risk of fraud. So, one key thing is to know when something is a security and if it is a security, it needs to be registered under the Securities Act. Unless an exemption is actually granted. So a digital asset is a security and we can think of securities as stocks or bonds. So those are obviously securities. So if we digitize a stock or a bond, that’s just a security. And the other thing is an investment contract. So let’s actually go to the Howey rule. So you might have heard about this. And if you haven’t, you will. So this is a famous case in the Supreme Court and it is the case of Howey, 1946. So I’ll give you a little more detail than maybe you were expecting. But this is a fascinating case. So Howey and company owned orange groves in Florida. So what they did was the following, an investor could buy the land and then lease it back to Howey who would turn to the land, harvest the oranges and then market the produce. So the court actually determined that this sort of lease back was actually an investment contract. So, this is the key part of the decision and it’s basically makes up the Howey test and I want to go through this. I’m going to read the whole thing and I’ve highlighted in blue some of the key aspects. An investment contract for the purposes of the Securities Act means a contract, transaction or scheme whereby a person invests his money in a common enterprise and has led to expect profits solely from the efforts of the promoter or third party. It being immaterial, whether the shares in the enterprise are evidenced by formal certificates or by nominal interest in physical assets employed in the enterprise. So in blue here, we’ve got somebody that’s investing money in a common enterprise. You need to expect profits and the profits are generated from the efforts of the promoter. So those are the four key aspects of the Howey Test. And you can see almost immediately that there’s certain things that are obviously not securities like Bitcoin or Ethereum. So you don’t expect a dividend or some sort of profit. You might expect the price to go up. But there’s no cash flow that’s associated from it. And it’s certainly not due to the efforts of the promoter. Indeed, there’s no promoter. It’s just a computer program. So there’s certain aspects of this that are very straightforward, but it gets murky. But this is the key thing that I wanted to understand. So the goal here is really to protect the retail investor. So I say retail investor sometimes that refers to a class of investors that are not as informed. And I don’t mean to say that in a negative way, it’s just a fact that a hedge fund has got a huge amount of data and computing resources and access to experts. Whereas a retail investor doesn’t have that access. So they’re relatively less informed. So basically, Howey test is very important if this is a security, you need to register with the SEC. Now we talked previously about the DAO. So this, according to the Howey test, is obviously a security. So we deposit ETH into a smart contract in return for the token. So the ETH is going to be used as venture capital. And the token holders are basically voting on the investments and there’s a clear expectation of making profits. So this is a straightforward application that this is a security and this is what the SEC actually said in their decision and the key thing is that if the DAO token is a security, that’s fine, but you just need to register, you need to go through the process of registering. That process, however, is pretty costly to do. So to go through, you need lawyers, you need to do research. This is not a simple thing to do. And again, the reason there’s so many hopes is to protect that retail investor. There are exemptions that are possible. So it could be a private placement. It might be that you limit to accredited investors. So there’s ways to get around the full registration. You can even offer under regulationares to go in a different for people outside of the US. So there is ways around this, but the way, for example, the DAO was launched, it was available for anybody in the world, in particular the US. So again, this is what has to happen. So let me finish this part of the regulatory risk with a very important insight. And this is something that high quality regulators completely understand. So if the regulation is too onerous, then the innovation is going to be driven offshore. And that’s not necessarily good for the economy. It’s also the case that new technology is complex. This technology of decentralized finance is quite complex as we’ve learned in this course. So it’s difficult for the regulator to actually keep up. So just to get to the level of where we are right now in this course, that’s a considerable investment of time. And as you will find out, that there is a depreciation of that knowledge. So what DeFi looks like today is going to look look much different in three to five years, some of the protocols will remain, but there’ll be a lot of differences. And that means that you need to continually reinvest. This is not your last course on DeFi. You need to continue to invest in your human capital. And the last point is that it’s really difficult to attract the talent that the regulators actually need, the people that really understand this space. And why is it difficult to attract? Because they’ve got many other options that pay a lot more.

02_cbdc-competition.en

So, if we’re talking about regulatory risk, it’s hard not to mention at least central bank digital currencies. So, this is an interesting type of risk because, they actually don’t exist yet. But, given that most banks are central banks are actually researching this and some of them have prototypes already, it’s something that we need to talk about. So just briefly show you that, most of the major central banks have initiatives. There’s not a new idea to have a central bank digital currency, indeed, Nobel laureate, James Tobin proposed the idea in 1987. Okay, so most of these countries are R and D, some countries are more advanced than others, like China and I think we can safely assume, that this will basically happen. There’s many different ways that these can be implemented. And I’m not going to go through a lot of detail but just give you a very high level of you. So, in the current system, cash is a direct claim on the central bank. Okay, so that’s the way our system actually works. However, as we’ve also gone through, ,we’ve talked about the money multiplier. Where the commercial banks actually create money by somebody depositing some money and then there’s a reserve that put at the Fed, but then that money is lent out. And it goes into another bank and the central bank actually, has these reserves, but extra money is created in the system, okay. Indeed, most of the money in the system is like this, especially if you consider reserve ratio of 0.1, that means that the total amount of possible money created is 10 times. What the central bank actually issues. So again, there’s many different ways to actually do this, many different choices in terms of how the central bank will actually implement. And a lot of these choices have to do with the degree of disintermediation of the commercial banks. We’re just kind of interesting. So, think about it this way. In the US that if you deposit money at your commercial bank, then that money is insured up to $100,000, by the central bank, by the Federal Reserve. So there’s another model, where retail investors at least can deposit their funds directly at the central bank. And we get rid of that guarantee, I guarantee is problematic, and we saw in the global financial crisis, what did these banks do? Well, they take your deposit, use that as collateral and borrow a huge amount of money on leverage. They use that supposedly for profit, but if something bad happens. And they get into trouble, the government needs to bail them out. Okay, so the system is very problematic. But again, there’s different ways to actually implement us. So there’s a hybrid model where, there’s interaction between the central bank and the commercial banks. And there’s also interaction between the customers and the commercial banks. There’s a direct model. And the direct model is what I’m talking about earlier. This means that, the central bank can deal directly with the retail holders. So you have an account, at the central bank and you use that to pay for things. So you don’t have the same, you don’t have the bank debit card, you don’t have that checking account or even a savings account that isn’t making any money. So, the central bank can actually do that. And also by the way, the central bank can pay interest. They pay interest on the reserves that are held by, that they hold that the the commercial banks actually put in. So that’s a possibility too. There’s also the indirect sort of model, where we’ve got basically the currency is not a direct claim on the central bank, it is a claim to the basically the wholesale accounts of the commercial bank. So, notice in the diagram that the retail investors and some institutions are basically dealing with banks who deal with the central bank. So, there are many different proposals here as to how this architecture actually works. There would be some sort of ledger, but it’s not going to be a Blockchain ledger, as we know. Because a Blockchain ledger is by construction more decentralized, with the decentralization is going to be lack of control. The whole idea of the central bank is to be central, so they want control. So it will be, perhaps a distributed ledger, let’s call it that and sometimes block chains are called distributed ledgers. So, it will be distributed in that perhaps every regional Federal Reserve Bank ,will have a copy of the ledgers, so there will be some redundancy that’s important. But, the central bank wants central control for obvious reasons. So, the mechanics of how the token transfers work are fairly straightforward, then we can borrow from what we’ve learned from the Blockchain technologies like Ethereum and Bitcoin. All of that’s straightforward. However, everything is maintained and deemed by a centralist party. So, why do we want to do this? Well. Number one, the system is just not very good right now. So, the system of wire transfers, the Fed wire, all this stuff is basically. It’s is technology that was very useful, like 30 years ago, but today it’s really dated. So, the central banks are very interested in this because it makes things more efficient. There are some benefits I will admit, but it allows them to do basically instant monetary policy. So. If they need to increase the money supply no problem. If they need to, for example do something like give out stimulus checks. Well, it can be done very efficiently. Indeed in the COVID-19 crisis, over a billion dollars was sent to deceased people. Okay, so again you’ve got more control here and if you wanted to you could enforce negative interest rates. So, what does that mean? Suppose that the Fed wanted to reduce the interest rate to -3%. I really can’t do that, because everybody would just hold cash currency. Which delivers zero and zero is a lot better than 3%. So there’s a lower bound, in terms of what they do. But if there’s no cash currency, you’re going to have a negative rate. So again this is the monetary economists dream to have control like this. So, there’s also other reasons that central banks are worried about companies like Facebook with their DM, which was libra or the JPM coin. So, they’re kind of worried that these corporations are going to basically take control. And it’s also the case that cash really isn’t used that much, anymore so we use electronics already. So. I think that there’s plenty of reasons here. There’s another subtle reason that we haven’t really seen in a long time, but we definitely saw it in the Great Depression. And that’s the idea of the bank run. Where people are worried about the bank and even though the risk might be not that big for the bank, the bank can be wiped out by a run. Whereas with this technology, the chance of that happening is greatly reduced. There’s some of the reasons, and this makes cross border payments much more efficient. And there’s a lot of stuff that needs to be worked out because the CBDC ledgers across different countries need to be able to interact with each other. And that has something worked out okay. It’s not like the charting of the Ethereum Blockchain, where you’ve got a master chain, the beacon chain that actually handles cross shard capabilities. But maybe something like that, could be useful in terms of implementing for kind of a global central bank digital currency. It’s also the case that central bank digital currency could promote inclusion, you don’t need a bank account. Everybody has got access to the central bank, and that’s where your account is. So it’s not at a commercial bank, it is with the central bank. A very important issue here is illegal transactions. So, I showed you in one of the courses the picture of El Chapo and his stash of 200 million us $100 bills. So cash, is fully anonymous and the ideal medium for illegal activity. And it is by far the most important, well, there’s no cash, it’s going to be much more difficult, to do illegal activity. And the other thing is the efficient collection of value added tax. So in Europe the value added tax is so high, that people will pay in cash to avoid the tax. So if you actually have a CBDC, with a tax mechanism included, ideally the rate of the VAT greatly decreases, because everybody will be paying, there’s no way around. And this is also true for a BAT which is a Border Adjustment Tax. So without an efficient VAT, it’s very difficult to do a border adjustment tax, but this is also possible with this particular technology. So there’s a lot of advantages to actually doing this, but there’s also a lot of downside. So, one downside that I’ve got a question mark on is the disintermediation of commercial banks. Some people think that’s a bad idea, some people think that’s a good idea. But I wanted to put it in the category commercials banks actually do provide some are actually not just some but a lot of financing that keeps the economy going. And just completely disintermediation them is something that could be risky at this point. Number two is privacy. So cash is anonymous, and I’m not talking about illegal transaction but it’s just the point of do you want the government knowing every single transaction that you make. Maybe that could work in some countries, that are more willing to accept that like China but even there I’m not convinced. But in the US I think it’s extremely unlikely. So, some system has to be developed where at least a smaller transactions are dealt with relatively anonymously. And there’s some ideas, that are possible in doing that but again, this needs to be worked out. And the last thing I’ll say, is in my opinion. This idea of central bank digital currency, is a reaction to what’s happened in the crypto space. That. It might be too late. Given all of the advances, that have been made in DeFi and given even some of these more centralist kryptos, whether it is a commercial bank launching a crypto or something like that. The horse as potentially left the bar. So, in the world that I see in the future, it’s just much less need for the central bank digital currency or fiat currency in general. So, I do think that is the major risk, that for the central authorities that is too late, for decentralized finance. The risk is that some governments will basically say you have to use the central bank digital currency and you can’t use a Cryptocurrency. And some countries will try to do that. It’s really difficult to do. It’s very difficult. And they’ll probably fail.

03_environmental-risk.en

Another important type of risk is environmental risk. So let me talk about this and I’ve thought a lot about this type of risk. So both Ethereum and Bitcoin use proof of work and we’ve already gone through that this is very energy intensive. And this amount of computing power is both, these protocols greatest strength because it provides unprecedented security but it’s also in my opinion its greatest weakness because of the amount of carbon that it generates. So this is what proof of work is and this data is from Cambridge University. You can see that they estimate that Bitcoin is using about 79 terawatt hours per year and you can see that that is more than the country of Chile. And this is also an interesting diagram where it shows for example the amount of power that’s used in different industries for example, televisions in the US is 60 terawatt hours Bitcoin is 79. So this is a lot that’s used compared to these other applications. It is interesting nevertheless the people say well Bitcoins the new gold, well actually gold mining worldwide uses much more power than Bitcoin. So this is just to give you some comparison but the fact is that this is a lot of power. This issue of carbon is a general issue and we need to also put this into context that there’s a lot of energy that is basically wasted. And one source that’s very striking is the gas flaring and the recovery potential for that is enormous. Indeed some mining operations have actually tried to harvest some of these flares for the energy and basically this is almost nine times the amount of power that is used in Bitcoin mining. I’m talking Bitcoin of course, but Ethereum is also using the same very energy intensive mining algorithm. So we’ve talked about a very substantial mitigator for Ethereum and that is the move to proof of stake. So once we get a proof of stake, all of this redundant mining ends. So you’ve got somebody that’s randomly assigned to validate and add a block and the amount of computational power that’s necessary for that is trivial compared to the situation today. So in my opinion, Bitcoin is not going to shift to proof of stake, it’s just very unlikely. They spent years trying to get agreement on just increasing the block size, so the shift to proof of stake is extremely unlikely. Indeed the miners, why would they vote for something like that? Because if they shift the proof of stake then it means that all of their mining software and hardware, the mining machines are actually worthless, so extremely unlikely. Ethereum will definitely move, it’s a question of when not if. So I have done some calculations here in terms of the amount of carbon which I will share with you. And the calculations are rough, they assume the energy production is the same mix of source that we see in the US but the numbers are kind of striking and let me go through the spreadsheet. So again, I use the Cambridge university site and this is just for a Bitcoin and what the energy actually the use is and then I calculate the carbon use and that would be like 27 million tons. And then figure out the number of new Bitcoin that are created in 2021. The carbon for Bitcoin, the cost of a carbon offset I assume is $50 but I could change that, and then the marginal cost of the carbon offset for a new Bitcoin is over $4,000. And we can also look at this a different way, we could look at the number of blocks, the number of transactions that actually occur and we could look at the carbon cost per transaction and that carbon cost is about $12. So this is a very large numbers for this in terms of if we’re thinking of making this clean, then you would want to buy a carbon offset and this is the cost. However, we need to be very careful in this analysis. So we can calculate the cost of a carbon off set for a Bitcoin but what if it’s traded, do you pay it every time? I don’t think so. So given that multiple people could be dealing with it, the cost actually would decrease and so trading volume needs to be taken into account. So the other issue is we’ve got 18 million Bitcoin out there but some of them, well actually most of them were mined in a period where it wasn’t computationally that difficult to actually mine the Bitcoin, so not that much energy was being used. So most of the Bitcoin were created when the cost a carbon offset might be just a few cents. So the current ones are much more energy intensive but all of these Bitcoins are fungible, they’re all the same, so how do we actually deal with that? So you need to actually do this historically and figure out when the coins were mined, what the computational power was and work out the carbon offset based upon that. So that’s actually pretty complicated to do but I’m guessing and this is again just my opinion, that if you do that then the average carbon cost maybe it’s $5, there’s certainly not $4,000, okay? So that needs to be taken into account also. And even there you need to take the trading volume into account, okay? So again this is a complex problem, there’s an investment fund out there that offers something like a Bitcoin ETF and they sell it as a clean ETF. And what they do is for every Bitcoin that you buy within that fund, the price includes what they calculate as the carbon offset and earns $55 per coin. And again there’s a range here but obviously 4000 it doesn’t make any sense to apply that to all of the 18 million bitcoins and you need to take the trading volume into account. So why do we care about Bitcoin? Indeed, I haven’t talked that much about Bitcoin in the course. So Bitcoin is not a protocol where we can do smart contracts, we can’t currently do defy on the Bitcoin Blockchain but we do care about Bitcoin because Bitcoin is the largest by market capitalization cryptocurrency. I guess by far the leader and it has been the leader, its share has decreased but nevertheless it is very large, okay? So it doesn’t really fulfill the vision of Satoshi Nakamoto as a transaction mechanism but it is very effective transaction mechanism for very large transfers, okay? So it is not a transaction mechanism right now in general, it’s more store of value but as I’ve mentioned a risky a store of value. Importantly we have talked about Bitcoin on the Ethereum Blockchain. So one thing that’s very important is liquidity and collateral and we talk very specifically about Wrapped Bitcoin, so that is WBDC which is a version of Bitcoin that is active on the Ethereum Blockchain. So Bitcoin is important for decentralized finance, in my opinion, the way this is going to play out is fairly straightforward. Certain countries and China has taken steps to do this, we’re going to say no, there’s no mining of Bitcoin because basically the power that you’re using is largely generated from coal fire plants, which are the worst plants in terms of putting carbon into the atmosphere. So the mining will move to areas that have locked clean energy and the country that I think is poised to do really well here is Iceland. And it’s already a large amount of mining in Iceland, but it’s got the advantage of essentially unlimited geothermal fuel for electricity that steam generated electricity that is clean. It’s cheap and it makes sense given the climate is cold already, you don’t need to spend on cooling mechanisms, it makes sense that there’ll be a large migration of mining in the future to a country like Iceland that’s got locked energy. Iceland is not the only country that’s got geothermal but it is a good example of a solution here. I also think in the future that this won’t be a problem because there just won’t be any dirty energy, so we’re in a transition right now. In the future in my vision, we’ve got lots of power, it’s just a technology problem to harvest the sun and in the future power will be so cheap that the proof of work won’t be a problem, it’ll all be clean. So I see in kind of the short and medium term a migration to mining in places with blocked clean energy and then after that, all of the power will be clean and it just won’t be an issue. So I believe actually some people say well, the proof of work is the downfall of Bitcoin, no, I don’t think so. Bitcoin is going to be around for a long time and Bitcoin is important for decentralized finance.

05_winners-and-losers

01_course-conclusion

01_investing-in-DeFi.en

The final module, the final part of the course, has to do with the winners and losers. Before I do that, I need to talk about investing and DeFi. This is not a course about investing. This is a course about learning about the potential of this space and the mechanics of the space. But nevertheless, investing is important. We need people to invest. Investors might be buying a token and speculating, they might be actually investing in a company that is developing a protocol for the decentralized finance space. Investing is important and it really can’t be ignored. I’ve got a number of points here. The first one is that this is no longer a niche space. This is mainstream asset class. If you think of the overall capitalization of the crypto complex, it is competitive with the largest stocks, like Apple and Microsoft. It’s hard to make the case that in a diversified global portfolio, you wouldn’t have stocks like that in your portfolio. If that’s the case, it’s really hard to make the case that you should ignore investments and crypto, but it is complex. This is a new technology, and let me go through a few insights. I say crypto, but crypto is not just one thing. If I was a speculator, there are very little reason for me to invest in a stablecoin because that’s just linked to the US dollar. Maybe there’s a reason to invest in a stablecoin and to get a savings rate associated with it. That’s more like interest. In terms of gain or appreciation, it doesn’t make as much sense to treat a stablecoin like you would treat a share of Facebook. Number 2, cryptos are difficult to value. We haven’t actually talked about valuation. Stablecoins are easy to value, but how do you value something like Bitcoin or Ethereum? There’s huge disagreement. Some people do this calculation for Bitcoins. Bitcoins is a new gold. Gold exists and if you add it all up, it’s about ten trillion dollars. Twenty one million Bitcoin, has 400,000 a Bitcoin. Other people say, it’s worth zero. It’s a huge amount of disagreement. Ethereum actually, there’s something happening in the Ethereum. You get a service out of Ethereum. You can run a program like AWS. You can run a program, but these are not easy to value. For investing, you need to take that into account, that there’s widespread dispersion and terms of expectation. Number 3, you usually understand what you’re investing in. I buy some Apple shares. I know their products. I’ve got an iPhone, might have a Mac, I know what they’re doing in terms of iTunes and TV. I understand their business or to a large degree, but it’s really challenging to understand in the space. Of course, you are multiple steps ahead of the average, given that you’ve got to this spot in the course. It is challenging. You need to understand. My students, we invest for educational purposes and portfolios of DeFi and no investment can be made unless the students completely understand what they’re investing in. We have a number of funds running. I like this. That’s a good lesson for you too. You need to understand exactly what you’re investing in. Just don’t join the bandwagon. Number 4 is not that much history. With stocks we’ve got data for the S&P from 1871. For gold, we’ve got millennia of data. The quality data in the space is from 2013. If you’re doing quantitative analysis, it’s very challenging because there’s so little data. Number 5, a story is usually told that goes something like this, these cryptos are algorithmic, the money supply is algorithmic so is a reward given for new blocks in Ethereum and in Bitcoin, and that reward has nothing to do with the amount of money in the world or any country, money supply. It has nothing to do with the GDP of any particular country, it is just purely algorithmic. You would think that, well, that opens the possibility that these cryptos could be a great hedge, let’s say for unexpected inflation. Will be where? Even though there’s limited history, we can look back a little bit and look at consequential events. March 2020 there was essentially a panic in financial markets over the COVID-19 crisis. What happened in those markets? The stock market drops by 35 percent. Gold, the supposed safe-haven drops by over 12 percent. What happens to these cryptos that are theoretically just an algorithm not linked to any money, not linked to the stock market, not linked to GDP? Well, crypto is plunged by over 50 percent. What’s happening here? What do I learn from that? It’s just one event, but it’s an important event. This was an event that we call in finance a risk-off event. Which means that you perceive the risk as increasing, you need to reduce the risk of your portfolio. How do you do that? You dump your stocks and you buy the safest thing possible, and that’s a treasury bond. The price is that their treasury bond went up. You also dump other speculative assets like gold and cryptos. The lesson here is I think pretty simple, that it’s naive to think that there’s no correlation between the cryptos and other financial assets. There is a correlation. If you think that you should invest in these purely as a hedge, then you’re likely going to be disappointed. They could be a partial hedge, but nevertheless. Even to play this a little further when the markets shifted after March and thought, well, maybe this COVID-19 isn’t as bad as we thought there’s vaccines on the way, what happened to the markets? Well, the stock market goes to an all-time high. Gold goes to its third-highest level in history. We know what happened to cryptos. Bitcoin rose to its all-time high. Again, the point I’m making is that there is correlation, you need to take that into account. What are the other insights here? I believe that too much attention in the media is paid to Bitcoin. It’s maybe because people just don’t understand the opportunities in the DeFi space. For investors and for people like you who are informed on DeFi, this presents a lot of opportunity. DeFi in particular in my opinion is a growth area and provides opportunities given it’s difficult to understand. For those that understand it, they can figure out what looks good and what doesn’t look good. Another point is something I’ve mentioned a number of times in the course, that this is a new technology and you have to expect that with any new technology, there will be people trying to take advantage of you. I don’t know how many times I was asked to be an advisor to some new coin and when I started to ask them, well, why do you want to launch this coin? What is the usefulness of actually launching this coin? The answer was, “Well, we think it’s going to go up in value.” That’s not a good reason. What is the coin actually doing? It needs to have a story, a narrative, whereby it adds value someway. So there’s going to be a lot of people out there with a new technology, sometimes it’s described as the wild west. Maybe that’s a useful analogy. The buyer needs to be aware. If you think about what happens in terms of investment, you need to think about it in a number of different ways. One is you to speculate on the crypto so you hope it goes up in value. Maybe you take a lever position. If it does, you make a lot of money. If it doesn’t, then you lose everything that you put up. There’s also investment in governance tokens. These tokens we’ve talked a lot about, and these tokens for the main protocols have done really well. That’s another approach where you look at a protocol, you like it, you think that it can expand and then you invest in a governance token. You actually become part of the governance and it’s in your best interest to contribute because when you do and the value of the protocol becomes higher, then you will benefit from that. Another thing is you could go and invest in equity of certain DeFi startups. That might be difficult for a retail investor to actually do. But there’s a number of initiatives to make what we call private equity, more available to the general investor. This is another possibility. Then the last way to invest is something we’ve talked about in terms of yield farming. That is basically, you can actually take a fairly low risk. Change your dollars into a token like USDC and instead of having those dollars sitting at a bank earning nothing or potentially losing, you can deploy the same amount of capital to a trusted, or let’s say a high reputation protocol and earn a return that is much greater than a bank. These are the many different ways that you can think of using the space in terms of investing capital.

02_a-view-of-the-future.en

We have now come to the end of the fourth course and indeed the end of the learning experience DeFi and the future of finance. Let me give you a few thoughts about how I see this technology playing out first perspective is very important. I believe that the model of finance has changed very little over the past century. We have the same commercial banks, the same brokerages, the same insurance companies, and the same central banks. Remember, I showed you one of the first Western Union wire transfers from 150 years ago with a 3% fee, very little has changed. Of course, many tasks have been digitized. However, what I’m talking about is the basic infrastructure. Yes, there’s been some improvements. The current wave of fintech has reduced costs, increased inclusion to some degree, but beware. I believe that the current wave of fintech is likely fleeting. Consider a quote from a highly respected guest speaker in my life course, the current Fintech like plaid and stripe is like putting lipstick on a peg. What does this mean? Well, most of the current fintech uses the traditional centralized architecture. Yes, it usually leads to reduced costs for those that are banked, but it does not fully address the fundamental problems that we detailed in these courses. Inefficiency, lack of inclusion, opacity, centralized control, and limits to interoperability as such. It is likely that the current Fintech will eventually be replaced by decentralized finance, so let’s end where we began with the word cloud. At the very beginning of the learning experience, I showed this cloud and at the end of each course we checked off the terms that we have explored. Indeed we’ve covered all of the words. However, even though you now have an understanding of these words, I want to challenge you. We have scratched the surface of some of these words. There is so much more to learn and it’s really important to know what you don’t know for you going ahead. There are two challenges that you face in the world of DeFi. First you must invest more time to better understand some of the key concepts. Second, the technology is moving at such a pace that you must continually invest time keeping up with the latest advances. Again, perspective is also important DeFi we’ll have plenty of ups and downs. This is no surprise and it is a characteristic of any emerging technology Independent of D five during the down periods. Don’t be discouraged and abandon the technology, indeed, you should view it differently, it is an opportunity to enter. Interestingly when the prices of kryptos plummeted by more than 85% in 2018, venture capital interest and DeFi projects did not win. Let me end the course by paraphrasing one of the endorsements of my book. It goes like this DeFi like the internet will likely make financial services cheaper, faster, secure, personalized, and more. The future has yet to be written. This course provides a peek into it, and you, as a graduate, hold the power to create it. You hold the power to create this future, join the revolution in finance. As with any revolution, it is not without risk, take the risk. I hope this learning experience gives you the confidence to join and please tell others.

06_Resources

01_slides-from-module-1-video-lectures

02_slides-from-module-2-video-lectures

03_slides-from-module-3-video-lectures

04_slides-from-module-4-video-lectures

05_slides-from-module-5-video-lectures