DeFi 101. Part 1 — Lending and Borrowing

A 3-part series on decentralized lending, margin trading, and spot trading

Introduction

The term “DeFi” (short for decentralized finance) has become increasingly popular among crypto enthusiast and developers in 2019. While DeFi is purposely quite broad in scope, currently there are three areas of DeFi that form a large portion of economic development:

Lending / Borrowing

Spot Trading

Margin Trading

It’s not surprising that these functions have dominated much of the DeFi conversation to this point: together they form the fundamental building blocks of thriving economies.

In this three part series, I’ll go over how each of these functions work in the decentralized world, how they are interrelated, and why they are so powerful.

Part 1 — Decentralized Lending and Borrowing

Let’s start with decentralized lending, as it is perhaps the easiest to understand of all of these. The lending and borrowing premise is pretty straightforward:

Crypto assets sitting in a normal wallet do not earn any interest

(like a basic bank checking account)

(like a basic bank checking account) One way to earn interest is to loan your assets out to others

(like a bank savings account)

Most of us have engaged in some sort of lending or borrowing outside of crypto. Whether you loaned a friend some cash, or you took out student loans, or you mortgaged a house: all of these are basic forms of lending and borrowing. The main difference in DeFi is that this must all be done without requiring any information about who is on either end of the loan.

While there are multiple ways that one can lend crypto assets to others, the most popular style of lending in DeFi is done through decentralized lending pools.

Decentralized Lending Pools

With lending pools, all lenders for a given market deposit their assets into a smart contract. Borrowers can then take loans from this pool of assets, rather than an individual lender. The interest paid by the borrowers is split up between all of the lenders, based upon the amount they deposited into the lending pool. The interest rates paid by the borrower are typically algorithmic based on supply and demand (more borrowing demand = higher interest rates, more supply = lower interest rates).

There are several decentralized lending products currently seeing use, such as Compound, dydx, and Fulcrum. Websites have even been created to track the varying interest rates between some of these platforms: https://loanlist.io/asset/dai.

Trustless Lending and Borrowing

For those that are not familiar with these systems, the natural question here is:

“If these loans are decentralized, how can I be sure that the borrower will pay my loan back? What stops them from walking away with my money?”

Before a user is allowed to borrow from these lending pools, they must first deposit some form of collateral into the smart contract. Collateral is what the lenders hold onto to make sure that the borrower doesn’t sneak away with their funds. In a mortgage, your collateral is the house itself. If you don’t pay your mortgage fees, your house can be seized by the bank.

Trustless loans only work if the loan is over-collateralized. That is, the collateral is worth more than the loan itself. Here’s a quick example in the decentralized world:

Bob wants to do something with DAI, but he only has ETH in his personal wallet. Bob decides to deposit 2 ETH as collateral into a lending pool (currently priced at ~260 DAI each), and takes out a 260 DAI loan with 10% APR interest. A couple months later, Bob is finished with his DAI and now owes 5 DAI of interest. He repays his 260 DAI loan + the 5 DAI interest, and walks off with his 2 ETH. Success!

In the example above, the lending pool is happy because Bob had 2 ETH (worth ~520 DAI) of collateral deposited, and they only lent him 260 DAI. Even if he walked away and never repaid the 260 DAI, his collateral at the time was worth more than the loan so the lending pool feels secure. In this example, he did repay his loan to receive his collateral back, and the pool earned 5 DAI of interest, to be split among the pool. Bob is happy because he didn’t have to sell his ETH, but was still able to use borrowed DAI. This interaction was completely trustless: even without knowing Bob personally, this system works.

There is a slight complication here to consider however: what if the price of ETH-DAI changes drastically?

Liquidations!

A comical twitter handle that tracks liquidations on Maker’s CDPs.

If the value of your collateral declines significantly with respect to your borrowed assets, you could find yourself in a situation where your loan is worth more than your collateral. This is not a good situation for the lenders: if the collateral can no longer cover the loan, there’s no reason for the borrower to return the loan, and the lenders will lose money. Because lending platforms must guarantee that their lenders won’t lose money, they have a method to prevent this from happening: liquidation.

If your collateral starts to get too close to the value of your borrowed assets, these platforms will sell (liquidate) your collateral to repay the loan in full.

Typically these platforms have a safety margin built into their contracts for extra security, typically around 15%-20% depending on the assets.

So let’s revisit Bob’s example again with a slightly darker twist :)

So once again, Bob deposited 2 ETH of collateral to borrow 260 DAI. At the time, 1 ETH was worth 260 DAI, so Bob had about 520 DAI of collateral to borrow 260 DAI of assets (a collateral rate of 200%). All looked fine for our grand hero, until ETH took a sudden dive in value!

As the value of 1 ETH hit 140 DAI, Bob’s collateral was now only worth 280 DAI: very close to his 260 DAI loan (a collateral rate of 117%). The lending pool’s safety margin was 20%, and thus it began to liquidate Bob’s 2 ETH of collateral before it dropped below the point where the pool would lose value on the loan. As soon as the liquidation is triggered, Bob loses access to his collateral. He keeps his 260 DAI loan, but his 2 ETH is lost!

How the lending pool handles this collateral varies a bit by platform. Some auction it off at various levels of discount, others have built in reserve pools that do it internally for a discount, others take it straight to a decentralized exchange. These pools try to do this in such a way that if the collateral price drops quickly, they can still sell it off to completely cover the loan.

Note — many people watch closely for these liquidations as it can form a lucrative arbitrage opportunity.

Motivations

But let’s back up for a second… Why would someone even want to borrow money instead of just using a decentralized exchange to trade for it? There’s a lot of future speculations for use cases here, but the primary use case currently for borrowing crypto assets is to take a position on a market (margin trading).

For example, if I strongly believe ETH will increase in value I am LONG ETH. If I strongly believe ETH will decrease in value I am SHORT ETH*. Using loans you can leverage these positions with margin trading to effectively multiply your gains or losses when an asset’s price changes.

*This delta value is market dependent: it’s the value with respect to the quote token. Being LONG on ETH-DAI is different than being LONG on ETH-BTC.

Lenders enable margin traders to increase their purchasing power beyond what is in their bankroll, or to bet that the price of an asset will decrease. Without lenders, margin traders cannot exist!

Lenders want others to engage in margin trading to boost their interest rates. Margin traders want more people to lend so that they can take borrow at a cheaper interest rate.

Next up, Margin Trading

In part 2 of this series, I cover how to use a loan to take a position on a market, and the pros/cons of Margin Trading with DeFi.

Part 2 is up! https://medium.com/hydro-protocol/defi-101-part-2-margin-trading-2b50d076deab

As always, please let me know if you have any questions, comments/feedback.