Understanding DeFi Lending Protocols: A Deep Dive into Lending and Borrowing

·

In the world of decentralized finance (DeFi), lending and borrowing have emerged as foundational pillars, enabling users to earn interest on their digital assets or access liquidity without traditional intermediaries. This article explores the core mechanisms behind DeFi lending protocols, focusing on how they manage pools, issue share tokens, and calculate returns.

How DeFi Lending Pools Work

In traditional finance, lending relies on trusted third-party institutions to mediate between borrowers and lenders. These institutions assess creditworthiness, enforce interest payments, and manage risk. DeFi, however, operates in a trustless environment, relying instead on smart contracts to automate these processes.

A lending pool is a smart contract where users can deposit assets—typically ERC-20 tokens—to earn interest or borrow against their holdings. Unlike traditional systems, DeFi pools aggregate funds from all users, creating a large reservoir of liquidity that enables instant loans. Key advantages include:

A common question arises: Why borrow against collateral instead of selling it? The answer lies in leveraged trading. For example, if you’re bullish on WBTC, you can deposit it as collateral, borrow stablecoins like USDC, and use those to buy more WBTC—amplifying your exposure. Conversely, if you’re bearish, you can borrow WBTC, sell it immediately, and repurchase it later at a lower price to repay the loan, pocketing the difference.

The Role of Share Tokens

When users deposit assets into a lending pool, they earn interest over time. To track each user’s share of the pool without inefficient on-chain updates, protocols use share tokens. These ERC-20 tokens represent a user’s proportional claim on the underlying assets and accrued interest.

Share tokens are minted upon deposit and burned upon withdrawal. This system automatically adjusts for dilution when other users enter or exit the pool, ensuring fair distribution of interest. Below, we examine how major protocols implement share tokens.

aToken: Aave’s Share Token

Aave uses aTokens as interest-bearing tokens minted and burned during deposits and withdrawals. Each market in Aave has its own aToken. When a user deposits assets, the protocol mints aTokens based on the current liquidityIndex, which accounts for accrued interest.

The balanceOf function in aToken contracts returns the amount of underlying tokens owed to the user, adjusted for interest. This is calculated by multiplying the user’s aToken balance by the normalized income of the reserve, which compounds interest block-by-block.

The liquidityIndex updates with each transaction, reflecting the cumulative interest earned by the pool. It’s computed using the liquidityRate, which depends on the pool’s utilization rate—the ratio of borrowed funds to total liquidity.

cToken: Compound’s Share Token

Compound uses cTokens to represent deposits. The exchange rate between cTokens and underlying assets determines how many tokens are minted or burned. This rate is derived from:

The exchange rate equals (totalCash + totalBorrows - totalReserves) / totalSupply. When users deposit, they receive cTokens equal to depositedAmount / exchangeRate.

eToken: Euler’s Share Token

Euler follows a similar pattern. Deposits mint eTokens based on an exchange rate calculated as:

exchangeRate = (poolSize + totalBorrows) / totalBalances

Here, poolSize is the underlying tokens in the contract, totalBorrows is the amount lent out, and totalBalances is the total eToken supply. The amount of eTokens minted is depositedAmount / exchangeRate.

Key Takeaways and Protocol Similarities

Despite different terminologies, Aave, Compound, and Euler share core mechanics:

The fundamental equation across protocols is:

shareTokensMinted = depositedAmount / exchangeRate

Where exchangeRate is defined differently per protocol but generally reflects the pool’s total liquidity and accrued interest.

👉 Explore advanced lending strategies

Frequently Asked Questions

What is a lending pool in DeFi?
A lending pool is a smart contract that aggregates user-deposited assets, allowing others to borrow against them. It automates interest distribution and collateral management without intermediaries.

How do share tokens work?
Share tokens, like Aave’s aTokens or Compound’s cTokens, represent a user’s share in a lending pool. They are minted on deposit and burned on withdrawal, automatically adjusting for interest accrual and pool activity.

Why use leverage in DeFi lending?
Leverage allows users to amplify their exposure to assets without selling collateral. For example, borrowing stablecoins against deposited crypto to buy more of that crypto can increase potential gains (and risks).

How is interest calculated in DeFi protocols?
Interest typically compounds block-by-block, based on pool utilization rates. Algorithms like Aave’s liquidityIndex or Compound’s exchange rate continuously adjust to reflect accrued interest.

Are DeFi lending protocols safe?
While smart contracts automate operations, risks include code vulnerabilities, market volatility, and protocol insolvency. Always audit contracts and understand risks before depositing.

Can I lose funds in a lending pool?
Yes, if collateral value drops below borrowing thresholds, positions may be liquidated. Over-collateralization and monitoring are essential to mitigate this risk.


DeFi lending protocols democratize access to financial services but require understanding of underlying mechanics. By leveraging share tokens and pooling liquidity, they offer flexibility and efficiency unmatched in traditional finance.