Lending and borrowing are the core of decentralized finance (DeFi). For the ecosystem, they provide liquidity to the market, ensure that capital is being used efficiently, and are the springboard for innovative products such as flash loans. For users, lending and borrowing provide them with traditional finance tools such as interest and liquidity, with all the added benefits of decentralization.
Let’s look at the details of how lending and borrowing work in DeFi, the key terms you need to know, and the risks and benefits. By the end, you will have the knowledge to lend and borrow confidently—a solid foundation to set you up for wave 4 of Linea’s DeFi Voyage on Intract.io.
At a high level, lending and borrowing in DeFi work similarly to how they work in traditional finance. Users collateralize their assets, take out loans, earn interest on deposits, and more.
But in DeFi, this is all done with digital assets, and without credit checks, loan approvals, and banks. And it’s done within a transparent and fair blockchain-based system. It is more accessible with a low barrier to entry—anyone with an internet connection and a crypto wallet can participate. It is transparent—anyone can see the transactions on a blockchain, including what wallets were used and the amounts transacted. And it creates new innovative products that can’t exist in traditional finance, such as composable smart contracts and flash loans.
Lending and borrowing in DeFi work through decentralized platforms. This means that no central entity (no bank, no corporation, no government) owns and controls the protocol. Instead, the platform is often governed by token holders, and enforced by smart contracts deployed on a blockchain.
These smart contracts execute the actual mechanics of the DeFi protocol—locking assets, lending assets, controlling interest rates, performing liquidations, and more. The rules are set in code and are transparent for all to see. Typically, the smart contracts (and protocol) are accessed using a crypto wallet on a website or app.
Most DeFi platforms operate under a similar flow: lenders supply money to the market and earn a reward. Borrowers borrow these funds against some collateral and pay interest. In traditional markets, a bank would be in the middle, managing the pool of money, determining interest rates, approving loans, checking credit scores, taking profits, etc. But in DeFi, it’s a decentralized protocol that manages the process using code deployed on a blockchain, publicly available to all, where the rules are known and can’t be changed on a whim—otherwise known as smart contracts.
And, with the advent of L2s such as Linea, borrowing and lending in DeFi are both fast and cheap.
Let us look at some details of how this works in DeFi.
Lenders
Lenders deposit their digital assets (or tokens) into smart contracts that hold the assets. These smart contracts are known as lending pools.
Governance of these lending pools is also done through smart contracts. These contracts determine parameters such as the lending and borrowing terms.
The lenders to these pools earn interest determined by the platform's specifics and once again enforced by smart contracts.
Lenders have liquidity and can withdraw their funds from the pool according to the platform's terms. Sometimes this means you can withdraw anytime, and sometimes your assets are locked for a specified period.
Why would you lend digital assets to a DeFi protocol?
Like traditional finance, you can earn interest on your deposits. Rates in DeFi are not only competitive with traditional finance markets but are often higher. This interest might be paid out in a stablecoin such as USDC, in the token you’ve deposited, or even in the native token of the protocol. Sometimes pools pay interest in multiple ways.
Lenders sometimes move their funds frequently between protocols, chasing higher interest rates. This is referred to as yield farming. L2s like Linea are especially helpful here as they make moving funds fast and cheap.
Borrowers
Borrowers take loans from the lending pools, usually providing collateral.
Often the collateral must have a value that exceeds the value of the loan. This is called an over-collateralized loan.
Borrowers then repay their loan under the terms of their agreement. Again, repayments and terms are governed by smart contracts.
If a borrower breaks the terms of their agreement (for example, they miss a payment or the value of their collateral falls under a certain percentage) their collateral can be liquidated (or seized). There are many variations of what happens with a liquidation. In some cases, the borrower loses all of their collateral. In others, the borrower might lose a percentage of the collateral plus pay a fee. In more complex cases, the collateral might be auctioned off by the protocol with some percentage going back to the borrower.
Protocols often have caps on how much of a particular token can be borrowed to protect the health of the overall protocol.
Why would you borrow assets using a DeFi protocol?
You might want liquidity—funds available to use—without actually selling your assets. For example, if you held 100 ETH, you might borrow 20,000 USDC against that ETH to pay bills, repay a loan, or invest. By borrowing against that ETH, you gain liquidity without actually selling the ETH—you have simply supplied it as collateral. You might believe the price of ETH is going to rise and you don’t want to sell it. You might want to take that 20,000 USDC and buy more ETH, increasing your exposure. Or you might, depending on your local regulations, find tax benefits in not selling.
Lending and borrowing are important because they (as they do in traditional markets) create the foundations of a healthy economy: liquidity, stability, competitive interest rates, credit, ways for investors to earn, and ways for investors to collateralize assets.
However, in DeFi they also create the basis for unique financial instruments that are not available in traditional markets. For example, composable smart contracts and flash loans.
Composable smart contracts allow smart contracts to be stacked like Legos, integrating different protocols. Since smart contracts are public and available to anyone, a second protocol can integrate the smart contracts from a first protocol, creating an entirely new piece of functionality.
As an example, a new DeFi protocol might offer a trading strategy by creating a smart contract that automatically swaps tokens on Uniswap when a price target is met, then uses those tokens to provide liquidity on a lending protocol such as Compound.
Flash loans allow borrowers to take out a loan—without collateral—as long as the loan is paid back in full in the same transaction. If the loan is not paid back at the end of the transaction, the entire transaction is reversed as if it never happened.
This opens up a large number of use cases. As an example, if you identified a price discrepancy for an asset between two exchanges, you could use a flash loan to borrow a large amount of funds (even into the millions of dollars), buy the asset at the lower price, sell it at the higher price, repay the loan, and keep the profit, all in one transaction, without having ever actually had the funds needed.
It’s important to understand the risks of lending and borrowing in DeFi.
Smart contract vulnerabilities - DeFi smart contracts can have flaws in their code that allow them to be exploited. Funds can be drained, and tokens can be lost or locked. Because the smart contracts are public and accessible, they are often a prime target for malicious actors.
Protocol risks - Protocols can fail. Whether from technical issues or governance failures, if a protocol fails, you are at risk of losing your funds.
Liquidations - Pay close attention to your liquidation terms, what they mean, and how they might affect you. One common term is the liquidation threshold—the threshold at which the loan becomes undercollateralized and can be liquidated. For example, if the liquidation threshold is 70%, that means if the value of your collateral drops below 70% of what you owe, your collateral will be liquidated.
While there are some tools available to help you stay aware of current market conditions, crypto prices and markets are volatile—you won’t have a broker call to tell you your loan is about to be liquidated when your asset value suddenly drops 30%. You’ll need to pay attention and be active.
So how can you stay safe against these risks?
Keep a healthy margin ratio to prevent liquidations. A margin ratio, also known as a collateralization ratio, is the ratio of the total value of your collateral against the total value of the loan you take. Having a healthy margin ratio prevents liquidation, and provides a buffer in case of market volatility. Some DeFi protocols also offer you better interest rates if you maintain a healthy margin ratio.
As with all of DeFi, research protocols before you participate. Ask questions in chat groups and read the documentation. Understand how the protocol works, what happens with defaults, where the protocol might fail, etc.
And as with any financial undertaking, understand the terms you are agreeing to. What are the interest rates? What happens if you default? What lines of recourse are available? What will happen with a sudden drop in the price of your asset? Thoroughly understand what you are doing before you do it.
Use reputable chains and protocols. Look for platforms that have been around for a while, were created by known and trusted teams, and have a record of being used and trusted.
And finally, be an active participant. Monitor your collateral value, check in on the protocol often, and watch for upgrades or changes. Be an active participant in your DeFi journey. Unlike with traditional finance such as a 401k, DeFi is not (at least not yet) a set-it-and-forget-it strategy.
Lending and borrowing are core to DeFi. To participate in the protocols, you’ll need to understand how to lend and borrow, the associated risks, and the best practices you need to protect your assets.