DeFi is an abbreviation of the phrase decentralized finance which generally refers to the digital assets and financial smart contracts, protocols, and decentralized applications (DApps) built on Ethereum. In simpler terms, it’s financial software built on the blockchain that can be pieced together like Money Legos.
To get a feel for the products and services that exist in the Ethereum DeFi ecosystem, you can check out DeFiPulse’s DeFi rankings which tracks the current value locked into popular DeFi smart contracts.
Computers have disrupted nearly every industry over the years. Each innovation builds on the previous one, and digital products and services become more sophisticated. Through technology, we’ve catered the world to fit our needs. From digital assistants to home automation, programs now affect many aspects of your daily life. So why would money be any different?
What is decentralized finance and who is it for?
To better understand DeFi, we should first take a look at how traditional finance came about. Although it sometimes feels like money has always been around, that’s simply not the case.
Humans originally bartered for the goods and services. But as human societies formed and developed, so did our economies. We invented currency to make exchanging things of value easier. Subsequently, currency helped usher in new innovations and higher levels of economic productivity. However, progress didn’t come without its cost.
Historically, central authorities such as governments have issued the currencies that underpin our economies. Central banks and institutions were expected to carefully manage and regulate the supply of currency in circulation. As the size and complexity of our economies grew, these central authorities gained more power as more people placed trust in them.
You trust your government to not print more money overnight. You trust your bank to safely store your money. And, when it comes to investing, you trust your assets to a financial adviser. By handing control of your money over to others, you hope to earn a profit. But the sad truth about our current financial system is that the power that comes along with this trust isn’t always rewarded.
We often have very little say in how corporations handle our investments, or even how our governments manage the economy. And in most cases, investors only receive a fraction of the returns generated from the risks taken by these central authorities.
DeFi is trying to build something different
Decentralized finance aims to create a financial system that’s open to everyone and minimizes one’s need to trust and rely on central authorities. Technologies like the internet, cryptography, and blockchain give us the tools to collectively build and control a financial system without the need for central authorities.
There’s a saying in the blockchain space: “Don’t trust, verify.” Because with a blockchain network, you as an individual can verify any and every transaction that occurs on the blockchain.
DeFi allows everyone to take charge of their financial well-being
Almost all DeFi applications are built on the Ethereum blockchain, the world’s most popular programmable blockchain. Ethereum is a blockchain network that maintains a shared ledger of digital value. Instead of a central authority, the participants that comprise the network control the issuance of ether (ETH), the network’s native cryptocurrency, in a decentralized manner.
Developers can program applications on Ethereum that can create, store, and manage digital assets, also called tokens, on the blockchain. These are called smart contracts or decentralized applications (DApps). They’re contracts or agreements enforced by the Ethereum blockchain. Or rather, applications or scripts that run only as programmed on the Ethereum network. You can build complex irreversible agreements without the need for a middle man.
Decentralized finance has the opportunity to bring about a more resilient and transparent financial system. Anyone with an internet connection is able to access and interact with smart contracts built on the Ethereum blockchain. Many smart contracts are built to be open-source and interoperable with existing smart contracts. So, users can verify the smart contracts’ code and choose which services work best for them.
What are some examples of popular DeFi applications?
There are many different DeFi products and services, some of which you may find familiar to existing financial services but with a decentralized twist.
Arguably, the most popular and fasting growing sector of DeFi is borrowing and lending platforms. Similar to a bank, users deposit money and earn interest from other users borrowing their assets. However, in this case the assets are digital and smart contracts connect the lenders to borrowers, enforce the terms of the loans, and distribute the interest. And it all happens without the need to trust one another or middleman bank. And, by cutting out the middleman, lenders can earn higher returns and more clearly understand the risks thanks to the transparency blockchain provides.
Tokens called stablecoins are also important to the DeFi ecosystem. You may be under the impression that all cryptocurrency is volatile. However, stablecoins are tokens designed to hold a specific value and are typically pegged to fiat currency like the US dollar. For example, DAI is a stablecoin pegged to USD and backed by ether (ETH). For every DAI, there is $1.50 of ETH locked into the MakerDAO smart contract as collateral.
Another type of popular DeFi application is what’s called a decentralized exchange, or DEX for short. DEXes are cryptocurrency exchanges that use smart contracts to enforce the trading rules, execute trades, and securely handle funds when necessary. When you trade on a DEX, there is no exchange operator, no sign-ups, no identity verification, or withdrawal fees.
DeFi is like smart money Legos
With Legos, you start out with a bunch of small bricks. It’s up to you how you piece together the Lego bricks to build something new. The same is true about smart contracts. With each new project, product, or service launched on Ethereum, you have one more money Lego in your collection. And by piecing together existing components of DeFi, you can combine, modify, or create powerful new finance tools out of these money legos.
cDAI is a perfect example of money Legos in action. Compound is a money market or, in other words, a lending service on Ethereum. When you supply DAI to Compound, you receive cDAI tokens which represent both your DAI in Compound and any interest you’ve earned from lending. Since cDAI is a token, you can send, receive, or even use cDAI in other smart contracts. Money Legos in action: ETH into MakerDAO to mint DAI tokens, DAI being supplied to Compound, cDAI tokens can be used in other DApps.
For example, you can swap ETH for cDAI on a DEX and instantly start earning interest for just holding cDAI. And because you choose how you interact with smart contracts on the blockchain, you can use a DEX aggregator like DEX.AG to compare and trade at the best prices across all the popular DEXes, all within seconds.
*Decentralization may vary
There are varying degrees of decentralization when it comes to DeFi services. Because the truth is, not everything can be or needs to be fully decentralized.
As previously mentioned, stablecoins are popular in DeFi. But, not all stablecoins are as decentralized as DAI. Many of them are actually tokens representing fiat currency deposits. For example, for every USDC token, there is 1 USD being held in a bank somewhere. You can theoretically “tokenize” or create a token to represent any real world asset. This is where things become a little less black and white, because while you can trade, send, and receive these tokens on the blockchain, you cannot completely eliminate the need to physically manage or redeem the real world asset.
Take for example, purchasing a home on the blockchain. Say someone tokenizes the deed to their home, places it on a decentralized exchange, and you buy it. Without the proper legal setup and the law on your side, you cannot simply force this person from their home regardless if you own the digital version. As it currently stands, you’d need to fall back on the court system of your home country to settle the dispute.
In short, there are limitations to the technology and sometimes the lines of DeFi begin to blur. In due time, laws will adapt to the changing financial landscape and DeFi’s place in the world will become clearer. That being said, one thing is clear: DeFi is here to stay.
DeFi isn’t stopping anytime soon
If you believe the future has digital money, then come explore what DeFi has to offer. At the time of writing this, the entire decentralized finance market is worth $494.6M. Ethereum has become the blockchain of choice for many companies to build their financial products. And more and more DeFi applications are built every day.
What is DeFi?
Decentralized Finance (DeFi) projects exploded in 2019 and the first half of 2020, with the annual total value locked in DeFi protocols increasing 137.23% in 2019 alone.* More than $1 billion in value (USD) is now locked in DeFi protocols, up from $545 million one year ago.** There are different categories of DeFi protocols such as lending protocols, stablecoins, exchanges, security tokens, insurance platforms, etc. Since lending protocols such as Compound and Aave have arguably received the most attention, we will focus on these platforms to fully understand their concepts, common patterns and the risks involved to use them. Please note that these concepts apply not only to lending protocols but also similar products from other categories such as options protocols like Opyn. We will be discussing these as non-technically as we can to make it friendly for new users.
What are DeFi lending protocols?
Lending protocols are basically platforms to link lenders and borrowers in a decentralized manner. On one hand, it allows borrowers to borrow crypto from the platform or other users for interest. On the other hand, it allows lenders to deposit crypto-assets into the platform to earn interest. The interest that goes to lenders comes from the interest that borrowers pay. DeFi lending protocols can offer much better interest compared to the banks’ savings accounts. At the time of writing for example, Compound is offering 7.58% interest per year for lending Dai to the protocol, while current savings rate from banks are extremely low globally, some of them are even negative.***
On the other hand, borrowers pay an interest to borrow from these lending protocols, at the time of writing, Compound charges 8% per year to borrow Dai from the protocol. This is also a pretty high cost to borrow.
So DeFi is basically P2P lending?
Not really. These DeFi lending protocols usually operate on a pool based structure. For example, when you deposit DAI into Compound, your money goes into a pool instead of to a specific borrower. Borrowers then borrow from the whole pool instead of a specific lender. This design has a few advantages:
- Lenders do not need to wait for a counterpart borrower to be matched in order to participate (e.g. earning interest)
- It allows the protocol to balance supply and demand through different incentives, for example when the borrowing demand is low, it might have an effect on the lending interest.
- It allows the protocol to even out the risk, so a lender is not 100% tied to the specific risk of their borrower.
Why are people paying high interest to borrow assets from lending protocols?
The answer could be for anything, but a common reason is traders leveraging on existing assets for trading purposes. Leverage is a very simple concept, it basically means borrowing money to invest. For example, I have some BAT tokens I believe the value will increase, but I also want to buy some REP because I think REP will also increase in value. But I don’t want to sell my BAT to buy REP. I can then use these lending protocols to borrow some Ether using my BAT as collateral, then I can buy some REP with the Ether I borrowed. In this case, I am basically holding both BAT and REP, all I need is to pay the yearly interest of borrowing Ether. If the price of REP increases, I can sell my REP and get Ether back, then pay back the protocol the Ether I borrowed, hopefully, with a lot of Ether left as profit.
Collateral is a very basic concept in the financial industry, it just means something you put up as a guarantee when borrowing money. If you can’t pay back your loan, your collateral will be used to pay your debt. An easy example is when you take a house loan from a bank, the house you bought will be the collateral; if you can’t pay back your loan, the bank will take your house.
It is exactly the same in DeFi; if you want to borrow assets from the protocol, you will need to give the protocol some other assets as collateral. If you don’t pay back your loan, the protocol will not give you back your collateral. Since we are talking decentralized finance here, the acceptable collateral are usually crypto-assets.
Loan-to-collateral ratio, over collateralized loans and why?
Since crypto value changes often, it is risky to use crypto as a collateral because when the value of collateral drops, it might not be enough to cover the loan value. For example, let’s assume today both BAT and REP are $1 each, I borrowed 1 REP from a lending protocol using my 1 BAT as collateral. Tomorrow, the price of BAT drops to $0.5, but REP is still $1, now if I don’t pay my debt, the protocol will end up losing $0.5 as they try to sell my BAT to cover the 1 REP I borrowed.
That’s why most protocols require an over collateralized loan, basically means you can only borrow up to a percentage (less than 100%) of your collateral’s value. The protocol often describes this as a loan-to-collateral ratio, and it is a common requirement to control the risk exposure to the protocol. Now when you borrow assets, you can only borrow up to maybe 75% of your collateral value, which will leave a 15% buffer for price changes.
Since price volatility is relatively unique to each asset, it is common to set the loan-to-collateral ratio individually for different asset pairs. For example Compound calls the loan-to-collateral ratio the Collateral Factor and it is set differently according to different assets.
Protocol tokens and underlying asset
It is common to see protocols issuing their own tokens to users during the process. For example when you deposit into Compound, you will get cTokens back like cEther, cDAI. These are usually standard ERC20 tokens that play an important part of the protocol’s function. In Compound’s case, it represents the Ether or DAI you deposit which are now called underlying assets. These cTokens works like a receipt, that you can redeem for your deposit back in the future, it also keeps track of the interest you made on your deposit. So if you transfer these cTokens to someone else, you are giving away your deposit receipt to someone, they can then redeem your underlying asset. So be very careful with it.
One thing worth noticing in Compound is, when you use your deposit as collateral to borrow other assets, the cToken you are issued will not be transferable anymore. This is understandable, when used as collateral, your underlying assets are locked down until your debt is paid off. It will be problematic if cTokens are transferrable during this period because the receiver might not even know the underlying asset of these cTokens are used as collateral until the moment they try to redeem it.
Price oracles are a common concept for DeFi protocols. When a protocol is dealing with different assets, it often needs to know the current prices of these assets. A price oracle simply provides the asset prices to the protocol. Price oracles are a key component of the DeFi ecosystem, but often users don’t pay enough attention on how the price oracle operates, which could lead to significant compromise if it is not well designed. After all, if an asset price is hacked, the whole DeFi protocol could fail.
Currently most DeFi protocols use their own price oracle, it is worth looking into these oracles and understanding how they handle prices before heavily investing in these protocols. However, Compound has released an Open Oracle which aims to provide an on-chain solution that sources different prices from trusted reporters and calculates the median price as the asset price. This is a great start for an industry standard solution, it could replace individual price oracles from each DeFi protocol, taking the risks away from operating these price oracles.
How does interest work
When it comes to interest in DeFi, it is the same concept as from your bank. There are generally two types, Simple interest and Compound interest. However, the way interest is calculated is usually a little bit more complicated technically. Because Ethereum transactions rely on external triggers, DeFi protocols usually depend on user actions to calculate the interest. E.g. Compound is supposed to calculate interest every time block, but instead of doing the calculation automatically, it relies on critical user activities like supply, borrow and liquidation to trigger the calculation of the interest. When triggered, the function will take into account of how many blocks has it been since the last interest calculation and apply the latest interest on top of it. In other words, the protocol will not calculate interest if no user actions are taken.
The term “liquidation” describes what happens when your collateral price drops closer to your debt value or is even unable to support your debt value; the protocol will allow someone else to repay your debt in exchange for your collateral. For example, assume the price of 1 REP equals to 1 BAT, you borrowed 1 REP and put 1.5 BAT as collateral because the protocol requires over collateralization. After a while BAT price dropped and now 1.3 BAT = 1 REP. This is risky for the protocol because the protocol might become insolvent if BAT keeps dropping, so the protocol will allow other people to come in and provide 1 REP in exchange for your 1.3 BAT. Often, the protocol will provide a bonus for liquidators to encourage liquidation in a timely manner, this is usually called a liquidation bonus or liquidation incentive. It is within the protocol’s interest to make sure liquidation happens before the price changes too far, otherwise it could cause the protocol to be insolvent. It is worth noting once the collateral price drops below the debt price, it makes no sense for the borrower to repay their loan anymore which will cause the protocol to be insolvent.
Does this mean I can make money liquidating people’s loans?
Yes. DeFi protocols usually offer an incentive to liquidate loans and keep the protocol healthy and collateralized, you will get a better than market deal from the liquidation process, so technically you could make some profit by monitoring the protocol and liquidate people once it’s allowed. However this process does require constant effort of monitoring the protocol and you will be competing with other liquidators and often bots set up by the protocol to make sure liquidation happens in a timely manner. Also be aware that the collateral you end up with is an asset dropping in price which could be a dangerous thing to hold on to anyway.
General risks in DeFi
DeFi has gained a lot of attention because it offers a lot of potential advantages like high returns, flexible entry and exit, and decentralization. However there are risks coming with these perks, here we discuss some of them.
Potential protocol insolvency due to under collateralization when asset price drops
Financial products often have built-in risks. Collateralized debts is a common example – when the value of underlying assets drops below the debt value, it will push the protocol into insolvency. This is particularly risky for DeFi due to the high volatility nature of crypto-assets. Although the protocol can limit risks and cut losses as early as possible with mechanisms like limiting supported asset types, setting loan-to-collateral ratio and enforce close monitoring of the loans with swift liquidation process, it is not possible to completely eliminate these risks.
External dependency failure
DeFi protocols often operate on some external code dependencies. These are very broad concepts, ranging from the ERC20 tokens they support to the price oracle they get their asset price from. The protocols usually have no control of these dependencies, which means if any of these become compromised, it will have a direct impact on the protocol operating with them. For example Opyn relies on Compound Price Oracle to get prices for Compound’s cTokens, if the Compound Price Oracle fails, it will cause Opyn to fail to update these asset prices, which could lead to a risky situation of under collateralization.
Compound has released an Open Oracle aiming to be a decentralized DeFi price oracle, this is a great move for the DeFi industry, however our audit does reveal a few potential issues inside it.
Smart contract vulnerability
The nature of smart contracts means there are always potential undiscovered vulnerabilities inside the code. It is one of the top reasons for major historical hacks within the crypto space. On top of that, technology progress could make originally safe code vulnerable all of a sudden. For example the recent development of Flash Loans opened a brand new attack vector and put a lot of existing projects under risk stress, (see a detailed introduction on Flash Loans by my team mate Austin-Williams).
Financial products always have risks, and this applies to both the traditional finance sector as well as decentralized finance (DeFi). We just need to understand these risks and prepare ourselves. I believe we are just at the beginning of the DeFi explosion, and with the global monetary system uncertainty spiking in recent times, DeFi could offer a great alternative.
* Market Report: 2019 DeFi Year in Review by Lucas Campbell
** DeFi Pulse
*** DAI lending rates have dropped significantly since the original publishing date of this article, with lending rates ranging from 0.85% on Compound to 6.12% on dYdX on June 16th, 2020.