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.
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.
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:
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.
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.
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.
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.
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.
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.
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.
Our audit report for Compound outlined this risk in details here.
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.
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.