Lending And Borrowing In DEFI Explained - Aave, Compound

Finematics
16 Nov 202013:32

Summary

TLDRThe video explains decentralized finance (DeFi) lending and borrowing protocols like Aave and Compound. It covers how lenders supply assets to earn interest while borrowers lock collateral to take loans, with interest rates set algorithmically based on supply and demand. It details the risks and incentives around overcollateralized loans. Finally, it compares the variable rate models of Compound and Aave, noting Aave's added stable rate option, and advises users to monitor rapid rate changes that could trigger liquidations.

Takeaways

  • ๐Ÿ’ป Lending and borrowing in decentralized finance (DeFi) is facilitated through smart contracts, allowing users to lend or borrow assets without a central authority.
  • ๐Ÿ”‘ DeFi lending platforms like Aave and Compound create money markets for various tokens, enabling users to supply tokens to earn interest or borrow against their holdings.
  • ๐Ÿ’ฐ Interest rates in DeFi lending are determined by the supply and demand dynamics within each platform's ecosystem, with rates being variable and calculated per Ethereum block.
  • ๐Ÿงฑ Most DeFi loans are over-collateralized, requiring borrowers to provide more value in tokens as collateral than the amount they are borrowing, to mitigate the risk of default.
  • ๐Ÿ’ธ Compound and Aave offer unique features; Compound uses cTokens for interest accrual, while Aave offers stable borrow rates and flash loans, highlighting the diversity in DeFi lending solutions.
  • ๐Ÿ“ˆ The collateral factor in DeFi lending dictates how much a user can borrow based on the value of their collateral, affecting the borrowing limits and the risk of liquidation.
  • ๐Ÿ’ณ Centralized finance (CeFi) platforms like BlockFi operate similarly to traditional banks but are prone to the same risks, such as hacking or mismanagement of funds.
  • ๐Ÿ’ต DeFi lending platforms aim to offer an alternative to traditional and centralized finance by providing transparency, security, and accessibility without requiring personal information.
  • ๐Ÿ›  Smart contract risks and rapidly changing interest rates pose significant challenges in DeFi, requiring users to stay informed to avoid potential liquidations or losses.
  • ๐Ÿ’น Aave's introduction of stable APYs and flash loans, alongside Compound's dynamic interest accrual mechanism, showcases the innovation and user-centric features available in DeFi lending.

Q & A

  • What are the two main elements of any financial system that lending and borrowing enables?

    -Lending and borrowing enables the two main elements of any financial system - lenders providing funds to borrowers in return for interest on their deposit.

  • How does decentralized finance (DeFi) lending allow users to participate in lending and borrowing?

    -DeFi lending allows users to become lenders or borrowers in a completely decentralized and permissionless way, while maintaining full custody over their coins through smart contracts.

  • What are the two main DeFi lending protocols mentioned in the script?

    -The two main lending protocols available in DeFi mentioned are Aave and Compound. Both create money markets for tokens like ETH, stablecoins, and other cryptos.

  • Why would a user want to take a loan by supplying collateral worth more than the loan amount?

    -Reasons include not wanting to sell their tokens but needing funds for expenses, avoiding/delaying capital gains taxes, or using the borrowed funds to increase leverage on a position.

  • How are interest rates determined in DeFi lending protocols?

    -Interest rates are determined by the ratio between supplied and borrowed tokens in a market. Rates can change dramatically depending on lending/borrowing demand.

  • What is the main difference between Compound and Aave when it comes to interest rates?

    -The main difference is that Aave offers stable interest rates in addition to variable rates like Compound. Stable rates are fixed short-term.

  • How does supplying and borrowing assets on Compound work?

    -Users deposit tokens to Compound and get cTokens which accumulate interest. cTokens can be used as collateral to borrow other tokens. Borrowed assets accrue interest paid to lenders.

  • What risk comes with the concept of overcollateralized loans in DeFi?

    -If asset prices drop, borrowers can get liquidated by having to repay more than expected as their collateral value falls below the loan amount.

  • How does Compound determine how much a user can borrow?

    -Compound uses a smart contract that calculates borrowable amount based on collateral across a user's account without risking immediate liquidation.

  • What are the main risks of decentralized finance lending?

    -Risks include smart contract risks and quickly changing interest rates potentially causing liquidations.

Outlines

00:00

๐Ÿ˜Š Introducing decentralized lending and borrowing

The paragraph introduces the concepts of lending and borrowing, explaining how they work traditionally through financial institutions and how decentralized finance protocols like Aave and Compound enable lending and borrowing while maintaining custody of assets. It compares centralized crypto lending by companies like BlockFi to decentralized alternatives, highlighting the risks of centralized services and the permissionless, transparent nature of DeFi lending powered by smart contracts.

05:00

๐Ÿ˜ฎ How borrowing limits and interest rates are determined

This paragraph explains how borrowing limits and interest rates are calculated in DeFi lending. Borrowing power depends on the collateral factor of supplied assets and available liquidity in each market. Interest rates for lenders and borrowers are variable based on supply and demand dynamics. Aave offers stable rate lending to reduce rate volatility. Reasons for borrowing despite overcollateralization are also discussed.

10:01

๐Ÿ‘จโ€๐Ÿซ An example explaining Compound cTokens

An example is provided to demonstrate how Compound's cTokens work. A user supplies 10 ETH and receives cETH representing claim on the ETH plus accumulated interest. As the cToken exchange rate increases with each block, users can redeem cTokens for more ETH than they initially supplied, earning interest. The example shows how a 0.16% APY on ETH supply could be achieved over 1 month as cETH exchange rate rises.

Mindmap

Keywords

๐Ÿ’กLending and borrowing

The main financial activity focused on in decentralized finance (DeFi). It allows users to lend out their crypto assets to earn interest or borrow assets from pooled liquidity. This is done through smart contracts without centralized intermediaries. Key platforms mentioned are Compound and Aave.

๐Ÿ’กMoney market

A part of the traditional financial system that enables short-term lending and borrowing of assets. Similar functionality is replicated in DeFi through lending protocols like Compound and Aave which create money markets for crypto assets.

๐Ÿ’กSupply APY

The annual percentage yield earned by suppliers of crypto assets to DeFi lending platforms. Determined algorithmically based on the ratio between supplied and borrowed assets in each market.

๐Ÿ’กBorrow APY

The annual percentage yield that borrowers must pay when borrowing assets from DeFi lending platforms. Tends to be higher than Supply APY.

๐Ÿ’กCollateral factor

The percentage of a supplied crypto asset's value that can be borrowed against it. Important for calculating how much users can borrow while avoiding liquidation.

๐Ÿ’กExchange rate

The rate at which supplied crypto assets can be redeemed for interest-bearing tokens like cTokens in Compound. Increases automatically with each new block to account for accrued interest.

๐Ÿ’กLiquidation

When a user's collateral drops below a minimum threshold required to back their borrowed amount, resulting in the automatic seizure and sale of their assets to repay debts.

๐Ÿ’กSmart contract risks

Despite removing counterparty risks, DeFi still carries risks inherent to the smart contract code that governs lending protocols. Bugs or flaws could compromise user funds.

๐Ÿ’กAPY volatility

Due to algorithmic determination of rates, lending/borrowing yields in DeFi can fluctuate wildly based on changes in supply/demand dynamics. Unexpected rate spikes could liquidate overleveraged positions.

๐Ÿ’กTrustless

A key ethos in DeFi - requiring no trusted intermediaries or centralized parties to facilitate financial activities. Enabled by smart contracts running transparently on blockchain.

Highlights

Introduction to lending and borrowing in DeFi, highlighting its importance in financial systems.

Explanation of traditional lending and borrowing through financial institutions versus DeFi platforms.

Comparison between centralized finance (CeFi) companies like BlockFi and Celsius, and DeFi protocols like Aave and Compound.

Discussion on the risks associated with centralized lending such as hacks and negligence.

Advantages of DeFi lending including decentralization, permissionless access, and self-custody of assets.

Detailed overview of how Aave and Compound function as leading DeFi lending protocols.

Explanation of over-collateralization in DeFi lending and the rationale behind it.

Factors determining how much can be borrowed in DeFi, including available funds and collateral factor.

The mechanism of interest rates in DeFi lending, highlighting the variable interest rates determined by supply and demand.

The unique features of Aave, such as stable borrow interest rates and flash loans.

In-depth example of how Compound's cTokens work, demonstrating the process of earning interest on deposited assets.

Comparison of Aave's aTokens to Compound's cTokens and their respective interest accumulation models.

The procedure for borrowing in DeFi using collateralized tokens and the implications of liquidation.

How DeFi platforms manage price feeds and assess collateral value to ensure loan security.

Discussion on the risks of DeFi lending, including smart contract vulnerabilities and fluctuating interest rates.

Transcripts

play00:00

so have you ever been wondering how

play00:01

landing and borrowing works in d5

play00:04

how are the supply and borrow rates

play00:06

determined and what is the main

play00:08

difference between the most popular

play00:09

lending protocols

play00:11

such as compound and other we'll answer

play00:14

all of these questions in this video

play00:17

before we begin if you want to learn

play00:18

more about decentralized finance

play00:20

and the technology behind it make sure

play00:23

you subscribe to my channel

play00:24

you can also check out our free guide to

play00:26

defy that i will link in the description

play00:28

box below

play00:30

let's start with what lending and

play00:31

borrowing is lending and borrowing

play00:34

is one of the most important elements of

play00:36

any financial system

play00:38

most people at some point in their life

play00:40

are exposed to borrowing

play00:42

usually by taking a student loan a car

play00:45

loan

play00:45

or a mortgage the whole concept is quite

play00:48

simple

play00:49

lenders aka depositors provide funds to

play00:52

borrowers

play00:53

in return for interest on their deposit

play00:56

borrowers

play00:57

or loan takers are willing to pay

play00:59

interest

play01:00

on the amount they borrowed in exchange

play01:03

for having a lump sum of money

play01:05

available immediately traditionally

play01:07

lending and borrowing is facilitated by

play01:09

a financial institution

play01:11

such as a bank or a peer-to-peer lender

play01:15

when it comes to short-term lending and

play01:16

borrowing the area of traditional

play01:19

finance

play01:19

that specializes in it is called the

play01:22

money market

play01:23

the money market provides access to

play01:25

multiple instruments

play01:27

such as cds reapers

play01:30

treasury bills and others in the

play01:33

cryptocurrency space

play01:34

landing and borrowing is accessible

play01:36

either through dsi protocols

play01:38

such as ave or compound or by c5

play01:42

companies

play01:42

for instance blockfi or celsius

play01:46

c5 or centralized finance operates in a

play01:49

very similar way to how banks operate

play01:51

this is also why sometimes we call these

play01:54

companies

play01:55

crypto banks blockfy for example

play01:58

takes custody over deposited assets and

play02:01

lends them out

play02:02

to either institutional players such as

play02:05

market makers or hedge funds

play02:07

or to the other users of their platform

play02:10

although the centralized lending model

play02:11

works just fine

play02:13

it is susceptible to the same problems

play02:15

as centralized crypto exchanges

play02:17

mainly losing customer deposits by

play02:20

either

play02:21

being hacked or other forms of

play02:23

negligence

play02:24

you can also argue that the cifi model

play02:27

basically goes against one of the main

play02:29

value propositions of cryptocurrencies

play02:32

self-custody of your assets this is also

play02:35

where defile landing comes into play

play02:38

defy lending

play02:39

allows users to become lenders or

play02:41

borrowers

play02:42

in a completely decentralized and

play02:44

permissionless way

play02:46

while maintaining full custody over

play02:48

their coins

play02:50

define lending is based on smart

play02:51

contracts that run

play02:53

on open blockchains predominantly

play02:55

ethereum

play02:57

this is also why defile landing in

play02:59

contrast to c5 landing

play03:01

is accessible to everyone without a need

play03:04

of providing your personal details

play03:06

or trusting someone else to hold your

play03:08

funds

play03:10

ava and compound are two main lending

play03:12

protocols available in d5

play03:14

both of the protocols work by creating

play03:17

money markets

play03:18

for particular tokens such as eth

play03:22

stable coins like dye and usdc or other

play03:25

tokens

play03:26

like ling or wrapped btc users

play03:30

who want to become lenders supply their

play03:32

tokens to a particular money market

play03:34

and start receiving interest on their

play03:36

tokens according to their current supply

play03:39

api

play03:40

the supply tokens are sent to a smart

play03:42

contract and become

play03:44

available for other users to borrow in

play03:47

exchange for supply tokens

play03:49

the smart contract issues other tokens

play03:52

that represents the supply tokens plus

play03:54

interest

play03:55

these tokens are called c tokens in

play03:58

compound

play03:59

and a tokens in ava and they can be

play04:01

redeemed for the underlying tokens

play04:04

we'll dive deeper into their mechanics

play04:06

later in this video

play04:08

it's also worth mentioning that in d5 at

play04:11

the moment

play04:12

pretty much all of the loans are over

play04:14

collateralized

play04:15

this means that the user who wants to

play04:17

borrow funds

play04:18

has to supply tokens in the form of

play04:21

collateral

play04:22

that is worth more than the actual loan

play04:24

that they want to take

play04:26

at this point you may ask the question

play04:28

what's the point of taking a loan

play04:30

if you have to supply tokens that are

play04:32

worth more than the actual amount of the

play04:34

loan taken

play04:36

why wouldn't someone just sell their

play04:37

tokens in the first place

play04:39

there are quite a few reasons for this

play04:41

mainly the users don't want to sell

play04:44

their tokens

play04:44

but they need funds to cover unexpected

play04:47

expenses

play04:48

other reasons include avoiding or

play04:51

delaying paying

play04:52

capital gain taxes on their tokens or

play04:55

using borrowed funds

play04:57

to increase their leverage in a certain

play04:59

position

play05:00

so is there a limit on how much can be

play05:02

borrowed

play05:03

yes the amount that can be borrowed

play05:05

depends on two main factors

play05:07

the first one how much funds are

play05:09

available to be borrowed in a particular

play05:11

market

play05:12

this is usually not a problem in active

play05:14

markets unless

play05:16

someone is trying to borrow a really big

play05:18

amount of tokens

play05:20

the second one what is the collateral

play05:22

factor of supply tokens

play05:24

collateral factor determines how much

play05:26

can be borrowed based on the quality of

play05:29

the collateral

play05:30

dai and eth for example have a

play05:32

collateral factor of 75 percent on

play05:35

compound

play05:36

this means that up to 75 percent of the

play05:39

value of the supply die or

play05:41

heat can be used to borrow other tokens

play05:44

if a user decides to borrow funds the

play05:47

value of the borrowed amount

play05:49

must always stay lower than the value of

play05:51

their collateral

play05:53

times its collateral factor if this

play05:55

condition holds

play05:56

there is no limit on how long a user can

play05:59

borrow funds for

play06:01

if the value of the collateral falls

play06:03

below the required collateral level the

play06:06

user

play06:06

would have their collateral liquidated

play06:09

in order for the protocol

play06:10

to repay the borrowed amount the

play06:13

interest

play06:14

that lenders receive and the interest

play06:16

that borrowers have to pay

play06:18

are determined by the ratio between

play06:20

supplied and borrowed tokens

play06:22

in a particular market the interest that

play06:25

is paid by borrowers

play06:26

is the interest earned by lenders so the

play06:29

borrow api

play06:30

is higher than the supply api in a

play06:33

particular market

play06:34

the interest apis are calculated per

play06:37

ethereum block

play06:39

calculating apys per block means

play06:42

that define lending provides variable

play06:45

interest rates

play06:46

that can change quite dramatically

play06:48

depending on the landing and borrowing

play06:50

demand for particular tokens

play06:52

this is also where one of the biggest

play06:54

differences between compound and other

play06:56

comes in

play06:57

although both protocols offer variable

play07:00

supply and borrow apis

play07:02

ave also offers stable borrow api

play07:05

stable apy is fixed in a short term but

play07:08

it can change in the long term

play07:10

to accommodate changes in the supply

play07:12

demand ratio

play07:13

between tokens on top of stable apy

play07:17

ave also offers flash loans where users

play07:20

can borrow funds with no upfront

play07:22

collateral

play07:23

for a very short period of time one

play07:26

ethereum transaction

play07:28

more on the flash loans here to better

play07:31

understand

play07:32

how the defile lending protocols work

play07:34

let's dive into an example

play07:36

but before we do that if you made it

play07:38

this far and you enjoy the video

play07:40

hit the like and subscribe buttons so

play07:42

this kind of content can

play07:44

reach a wider audience let's dive deeper

play07:46

into the mechanics of compound

play07:48

and c tokens in our example a user

play07:52

deposits 10 heath into compound in

play07:54

exchange for 10eth

play07:56

compound issues c tokens in this case

play08:00

c if how many c tokens will the user

play08:04

receive

play08:05

this depends on the current exchange

play08:07

rate for a particular market

play08:09

in this case ether when a new market is

play08:12

created

play08:13

the exchange rate between c tokens and

play08:16

underlying tokens

play08:17

is set to 0.02 this is an

play08:20

arbitrary number but we can assume that

play08:23

each market starts at 0.02

play08:26

we can also assume that this exchange

play08:29

rate can only increase

play08:31

with each ethereum block if the user

play08:34

supplies 10 eth

play08:35

when the market was just created they

play08:38

would have received

play08:39

10 divided by 0.02 equals

play08:42

500 ces because the ether market

play08:46

has been operating for a while we can

play08:49

assume that the exchange rate is already

play08:51

higher

play08:52

let's say it's 0.021

play08:55

this means that the user would receive

play08:58

around

play09:01

476.19

play09:02

ces if the user decided to immediately

play09:06

redeem their ease

play09:07

they should receive roughly the same

play09:09

amount as it was deposited

play09:11

which is around 10 eat now here is when

play09:14

the magic happens

play09:16

the user holds their ces this is just

play09:19

another erc20 token

play09:21

that can be sent anywhere the main

play09:23

difference

play09:24

is that ces is necessary to redeem the

play09:27

underlying heath from compound

play09:30

on top of that seat keeps accumulating

play09:33

interest even if it's sent from the

play09:36

original wallet

play09:37

that initiated the deposit to another

play09:40

wallet

play09:41

with each ethereum block the exchange

play09:43

rate would increase

play09:44

the rate of the increase depends on the

play09:47

supply apy

play09:48

which is determined by the ratio of

play09:51

supplied borrowed capital

play09:53

in our example let's say that the

play09:55

exchange rate from c

play09:57

to 8 increases by this amount with each

play10:00

block

play10:02

assuming that the rate of increase stays

play10:04

the same

play10:05

for a month we can easily calculate the

play10:08

interest

play10:09

that can be made during that time let's

play10:11

say on average we have four blocks per

play10:13

minute

play10:14

this gives us the following numbers

play10:18

now we can add this number to the

play10:21

previous exchange rate

play10:22

and get the following number that is

play10:24

slightly higher than the previous

play10:26

exchange rate

play10:27

if the user decides to redeem their ease

play10:30

they would receive

play10:31

around 10.0165 each

play10:34

so the user just made 0.0165

play10:38

each in a month which is around 0.16

play10:41

return on their eath it's worth noting

play10:44

that the original amount of ces that the

play10:47

user received

play10:48

hasn't changed at all and only the

play10:51

change in the exchange rate

play10:53

allowed the user to redeem more eth than

play10:56

was initially deposited

play10:58

ave uses a similar model with interest

play11:01

being accumulated

play11:02

every single block the main difference

play11:05

is that

play11:05

a token's value is packed to the value

play11:08

of the underlying tokens

play11:10

at the one-to-one ratio the interest is

play11:13

distributed to a token holders

play11:16

directly by continuously increasing

play11:18

their wallet balance

play11:20

a token holders can also decide to

play11:23

redirect their stream of interest

play11:25

payments

play11:26

to another ethereum address when it

play11:29

comes to borrowing

play11:30

users lock their c tokens or a tokens

play11:33

as collateral and borrow other tokens

play11:36

collateral earns interest but users

play11:39

cannot redeem or transfer assets

play11:42

while they are being used as collateral

play11:45

as we mentioned earlier

play11:46

the amount that can be borrowed is

play11:48

determined by the collateral factor

play11:50

of the supplied assets there is also a

play11:53

smart contract

play11:54

that looks at all the collateral across

play11:56

user's account

play11:58

and calculates how much can be safely

play12:00

borrowed

play12:01

without getting liquidated immediately

play12:04

to determine the value of collateral

play12:06

compound uses its own price feed that

play12:09

takes prices

play12:10

from several highly liquid exchanges

play12:13

other

play12:13

on the other hand relies on channeling

play12:16

and falls back to their own price feed

play12:18

if necessary if a user decides to repay

play12:22

the borrowed amount

play12:23

and unlock their collateral they also

play12:25

have to repay

play12:26

the accrued interest on their borrowed

play12:29

assets

play12:30

the amount of accrued interest is

play12:32

determined by the borrow

play12:33

api and is also increased automatically

play12:37

with each ethereum block different

play12:39

lending although reducing a lot of risks

play12:42

associated with centralized finance

play12:44

comes with its own risks mainly the

play12:47

ever-present

play12:48

smart contract risks but also quickly

play12:51

changing apis

play12:52

for example during the last yield

play12:54

farming craze

play12:56

the pro apy on the bat token went up to

play12:59

over 40 percent

play13:01

this could cause unaware users who are

play13:03

not tracking compound interest rates

play13:06

daily

play13:06

to get liquidated by having to repay

play13:09

more than

play13:10

expected in the same period of time so

play13:13

what do you think about landing and

play13:14

borrowing in detail

play13:16

and what is your favorite platform

play13:18

comment down below

play13:19

and as always if you enjoyed this video

play13:22

smash the like button

play13:23

subscribe to my channel and check out

play13:25

the cinematics on patreon

play13:26

to join our defy community thanks for

play13:30

watching