https://medium.com/dydxderivatives/decentralized-lending-an-overview-1e00fdc2d3ee
Antonio Juliano, May 2019
To date, the biggest sector by far for decentralized applications has been lending & borrowing crypto assets. Several high quality products have been built that allow users to borrow and lend directly on the Ethereum blockchain with no intermediaries. Decentralized lending products are available to anyone, anywhere, and require only an Ethereum wallet to use. These products are already seeing real usage today with total USD volumes in the hundreds of millions.
Crypto holders can lend on decentralized lending platforms to earn passive income on their holdings through interest fees paid by borrowers. This is an attractive option to lenders as they can earn relatively low risk interest on their existing holdings without entrusting their private keys to a 3rd party centralized service.
The dominant use case for borrowing crypto is margin trading. Borrowing allows traders to get leverage which multiplies gains and losses while trading, as well as short selling, a trading strategy which makes money when the price of an asset goes down.
Margin trading involves borrowing an asset, and then immediately selling it. For example, you could borrow DAI (a stablecoin) and then buy ETH with it, which would let you buy more ETH than you would otherwise be able to (giving you leverage on ETH). Of the 4 top lending protocols discussed below, all except for dYdX focus on just the borrowing & lending side of margin trading, meaning traders have to go to other exchanges to execute the sell of the borrowed funds.
Currently, all relevant decentralized lending platforms use a form of borrowing called collateralized borrowing. Collateralized borrowing means that borrowers must lock up collateral of greater value than the value of their borrow. The collateral serves to ensure lenders will be repaid even if the borrower never repays the loan.
For example, say you want to borrow $100 worth of ZRX, you would have to lock up more than $100 worth of collateral in another asset. Say you choose to lock up $150 worth of ETH. Now if you default on your loan, the lender who lent you $100 of ZRX can just seize your ETH, which is worth even more.
However, the price of both ZRX and ETH can change over time. Say the price of ETH falls, and now your collateral is only worth $90. Now the lender could not get their money back by seizing your ETH anymore, because it wouldn’t be worth as much as your debt. This is where the concept of a liquidation comes in.
A liquidation is when your borrow is automatically repaid by selling off some of your collateral to buy back the asset you owe to the lender. Liquidations occur when your borrow falls below some required level of collateralization (usually between 115%–150%).
MakerDAO is both the most complex and widely used decentralized lending platform available today. MakerDAO is the creator of DAI, which is a cryptocurrency with a target price of $1 (known as a stablecoin).
On MakerDAO, there are no lenders, and the only asset available to borrow is DAI. Borrowers can borrow a newly created supply of DAI by locking up ETH as collateral, and must maintain a 150% collateralization ratio. The interest rate on DAI is global, and is set through governance by MKR token holders. The interest rate has recently been fairly volatile, increasing from 2.5% to 19.5% in a bit over a month.
MakerDAO has where you can borrow DAI through a margin account known as a CDP (collateralized debt position). Of all the discussed lending platforms, MakerDAO is also the most difficult to use from a UX perspective.
Opening a MakerDAO CDP via cdp.makerdao.com
Assets: DAI (Borrow Only), ETH (Collateral Only) [MakerDAO plans to add more collateral assets with their upcoming release of muli-collateral DAI]
Interest Rates: Variable. Set through governance by MKR token holders
Collateral Requirement: 150% minimum
Liquidation Penalty: 13%
Compound uses a money market based approach, with global pools of capital for each supported asset. Each asset has a global borrow and lend interest rate which all borrowers pay & lenders earn. These interest rates are variable and set algorithmically based on the percent of each pool that is being borrowed.
Compound has which is fairly simple to use, and allows lenders and borrowers to interact directly with the protocol. Lenders can deposit funds into lending pools, and will continuously earn interest. Lenders can withdraw their assets at any time, as there are no fixed loan durations.
Borrowers must collateralize their accounts with 150% of the value being borrowed. For example if you want to borrow 1 ETH from Compound, you could deposit 225 DAI into the Compound DAI pool and then borrow 1 ETH from the ETH pool (assuming 1 ETH = 150 DAI — this would be 150% collateralized). Borrows on compound have unlimited duration.
Borrowing REP & Lending DAI on compound.finance
Assets: DAI, ETH, ZRX, REP, BAT
Interest Rates: Variable. Set algorithmically based on supply & demand
Collateral Requirement: 150% minimum
Liquidation Penalty: 5%
Dharma utilizes peer-to-peer lending to match individual lenders directly with borrowers. On Dharma, borrowers and lenders enter into fixed term / interest rate loans.
Dharma has built a where users can go to borrow and lend, and is the only mentioned product that does not require the use of an Ethereum wallet such as MetaMask. Currently Dharma’s product (though smart contract based) is centralized, but they have solid plans to decentralize over time.
Lenders can use Dharma to offer fixed-term loans of up to 90 days, and start earning interest only after they are matched with a borrower. Lenders’ funds are locked for the duration of the loan.
Borrowers on Dharma lock up collateral equal to 150% the value of the assets being borrowed. Borrows have a maximum 90 day duration, and fixed interest rates for the duration of the loan.
Borrowing DAI on dharma.io
Assets: DAI, ETH
Interest Rates: Fixed. Rates set centrally by Dharma
Collateral Requirement: 150% initial, 125% minimum
Liquidation Penalty: Unclear (?)
The main difference between dYdX and the previously mentioned lending platforms is dYdX natively supports trading in addition to borrowing / lending, meaning that traders can margin trade without leaving the platform for another exchange. dYdX’s product is targeted at margin traders, and is more complex than either Compound or Dharma, while also supporting more functionality.
Under the hood dYdX uses a pooled based lending approach and algorithmic variable interest rates similar to Compound. There are no lockup periods or maximum durations while lending on dYdX.
On dYdX borrowers must lock up 125% collateral, meaning dYdX offers the highest leverage (up to 4x) of any decentralized lending platform. Borrows / positions on dYdX are limited to 28 days.
Opening a Leveraged Long position on trade.dydx.exchange
Assets: DAI, ETH, USDC
Interest Rates: Variable. Set algorithmically based on supply & demand
Collateral Requirement: 125% initial / 115% minimum
Liquidation Penalty: 5%
Within the past year we’ve seen the emergence of quality decentralized lending platforms. The ability to borrow and lend on a completely open platform is a fundamental advancement in financial markets, and is already seeing real volume today.
https://finematics.com/lending-and-borrowing-in-defi-explained/
Jakub, Nov 2020
So have you ever been wondering how lending and borrowing works in DeFi? How are the supply and borrow rates determined? And what is the main difference between the most popular lending protocols such as Compound and Aave? We’ll answer all of these questions in this article.
What is Lending and Borrowing
Let’s start with what lending and borrowing is.
Lending and borrowing is one of the most important element of any financial system. Most people at some point in their life are exposed to borrowing, usually by taking a student loan, a car loan or a mortgage.
The whole concept is quite simple. Lenders a.k.a. depositors provide funds to borrowers in return for interest on their deposit. Borrowers or loan takers are willing to pay interest on the amount they borrowed in exchange for having a lump sum of money available immediately.
Traditionally, lending and borrowing is facilitated by a financial institution such as a bank or a peer-to-peer lender.
When it comes to short term lending & borrowing, the area of traditional finance that specializes in it is called the money market. The money market provides access to multiple instruments such as CDs (certificates of deposits), Repos (repurchase-agreements), Treasury Bills and others.
Lending and Borrowing in Crypto
In the cryptocurrency space, lending and borrowing is accessible either through DeFi protocols such as Aave or Compound or by CeFi companies, for instance, BlockFi or Celsius.
CeFi or centralized finance operates in a very similar way to how banks operate. This is also why sometimes we call these companies “crypto banks”. BlockFi, for example, takes custody over deposited assets and lends them out to either institutional players such as market makers or hedge funds or to the other users of their platform.
Although the centralized lending model works just fine, it is susceptible to the same problems as centralized crypto exchanges – mainly losing customer deposits by either being hacked or other forms of negligence (bad loans, insider job etc.).
You can also argue that the CeFi model basically goes against one of the main value propositions of cryptocurrencies – self-custody of your assets.
This is also where DeFi lending comes into play.
Lending and Borrowing in DeFi
DeFi lending allows users to become lenders or borrowers in a completely decentralized and permissionless way while maintaining full custody over their coins.
DeFi lending is based on smart contracts that run on open blockchains, predominantly Ethereum. This is also why DeFi lending, in contrast to CeFi lending, is accessible to everyone without a need of providing your personal details or trusting someone else to hold your funds.
Aave and Compound are two main lending protocols available in DeFi. Both of the protocols work by creating money markets for particular tokens such as ETH, stable coins like DAI and USDC or other tokens like LINK or wrapped BTC.
Users, who want to become lenders, supply their tokens to a particular money market and start receiving interest on their tokens according to the current supply APY.
The supplied tokens are sent to a smart contract and become available for other users to borrow. In exchange for the supplied tokens, the smart contract issues other tokens that represent the supplied tokens plus interest. These tokens are called cTokens in Compound and aTokens in Aave and they can be redeemed for the underlying tokens. We’ll dive deeper into their mechanics later in this article.
It’s also worth mentioning that in DeFi, at the moment, pretty much all of the loans are overcollateralized. This means that a user who wants to borrow funds has to supply tokens in the form of collateral that is worth more than the actual loan that they want to take.
At this point, you may ask the question – what’s the point of taking a loan if you have to supply tokens that are worth more than the actual amount of the loan taken. Why wouldn’t someone just sell their tokens in the first place?
There are quite a few reasons for this. Mainly, the users don’t want to sell their tokens but they need funds to cover unexpected expenses. Other reasons include avoiding or delaying paying capital gain taxes on their tokens or using borrowed funds to increase their leverage in a certain position.
So, is there a limit on how much can be borrowed?
Yes. The amount that can be borrowed depends on 2 main factors.
The first one – how much funds are available to be borrowed in a particular market. This is usually not a problem in active markets unless someone is trying to borrow a really big amount of tokens.
The second one – what is the collateral factor of supplied tokens. Collateral factor determines how much can be borrowed based on the quality of the collateral. DAI and ETH, for example, have a collateral factor of 75% on Compound. This means that up to 75% of the value of the supplied DAI or ETH can be used to borrow other tokens.
If a user decides to borrow funds, the value of the borrowed amount must always stay lower than the value of their collateral times its collateral factor. If this condition holds there is no limit on how long a user can borrow funds for.
If the value of the collateral falls below the required collateral level, the user would have their collateral liquidated in order for the protocol to repay the borrowed amount.
The interest that lenders receive and the interest, that borrowers have to pay are determined by the ratio between supplied and borrowed tokens in a particular market.
The interest that is paid by borrowers is the interest earned by lenders, so the borrow APY is higher than the supply APY in a particular market.
The interest APYs are calculated per Ethereum block. Calculating APYs per block means that DeFi lending provides variable interest rates that can change quite dramatically depending on the lending and borrowing demand for particular tokens.
This is also where one of the biggest differences between Compound and Aave comes in. Although both protocols offer variable supply and borrow APYs, Aave also offers stable borrow APY. Stable APY is fixed in a short-term, but it can change in the long-term to accommodate changes in the supply/demand ratio between tokens.
On top of stable APY, Aave also offers flash loans where users can borrow funds with no upfront collateral for a very short period of time – one Ethereum transaction. More on the flash loans here.
To better understand how the DeFi lending protocols work, let’s dive into an example.
How Does It Work
Let’s dive deeper into the mechanics of Compound and cTokens.
In our example, a user deposits 10 ETH into Compound. In exchange for 10 ETH, Compound issues cTokens in this case cETH.
How many cETH tokens will the user receive? This depends on the current exchange rate for a particular market, in this case, ETH. When a new market is created the exchange rate between cTokens and underlying tokens is set to 0.02. This is an arbitrary number, but we can assume that each market starts at 0.02. We can also assume that this exchange rate can only increase with each Ethereum block.
If the user supplied 10 ETH when the market was just created they would’ve received 10/0.02=500 cETH. Because the ETH market has been operating for a while we can assume that the exchange rate is already higher. Let’s say it is 0.021.
This means that the user would receive 10/0.021=~476.19 cETH. If the user decided to immediately redeem their ETH, they should receive roughly the same amount as it was deposited, which is around 10 ETH.
Now, here is when the magic happens. The user holds their cETH. This is just another ERC20 token and can be sent anywhere. The main difference is that cETH is necessary to redeem the underlying ETH from Compound. On top of that, cETH keeps accumulating interest, even if it is sent from the original wallet that initiated the deposit to another wallet.
With each Ethereum block, the exchange rate would increase. The rate of the increase depends on the supply APY which is determined by the ratio of supplied/borrowed capital.
In our example, let’s say that the exchange rate from cETH to ETH increases by 0.0000000002 with each block. Assuming that the rate of increase stays the same for a month we can easily calculate the interest that can be made during that time.
Let’s say on average we have 4 blocks per minute. This gives us the following numbers.
0.0000000002*4*60*24*30=0.00003456. Now we can add this number to the previous exchange rate. 0.021+0.00003456=0.02103456.
If the user decides to redeem their ETH they would receive 476.19*0.0213456=~10.0165 ETH. So the user just made 0.0165 ETH in a month which is around 0.16% return on their ETH. It’s worth noting that the original amount of cETH that the user received hasn’t changed at all and only the change in the exchange rate allowed the user to redeem more ETH than was initially deposited.
Aave uses a similar model with interest being accumulated every single block. The main difference is that aTokens’ value is pegged to the value of the underlying token at a 1:1 ratio. The interest is distributed to aToken holders directly by continuously increasing their wallet balance. aToken holders can also decide to redirect their stream of interest payments to another Ethereum address.
When it comes to borrowing, users lock their cTokens or aTokens as collateral and borrow other tokens. Collateral earns interest, but users cannot redeem or transfer assets while they are being used as collateral.
As we mentioned earlier the amount that can be borrowed is determined by the collateral factor of the supplied assets. There is also a smart contract that looks at all the collateral across user’s account and calculates how much can be safely borrowed without getting liquidated immediately. To determine the value of collateral Compound uses its own price feed that takes prices from several highly liquid exchanges. Aave on the other hand relies on Chainlink and falls back to their own price feed if necessary.
If a user decides to repay the borrowed amount and unlock their collateral, they also have to repay the accrued interest on their borrowed assets. The amount of accrued interest is determined by the borrow APY and it is also increased automatically with each Ethereum block.
Risks
DeFi lending, although reducing a lot of risks associated with centralized finance, comes with its own risks.
Mainly the ever-present smart contract risks, but also quickly changing APYs. For example, during the last yield farming craze, the borrow APY on the BAT token went up to over 40%. This could cause unaware users who were not tracking Compound interest rates daily to get liquidated by having to repay more than expected in the same period of time.












