In-depth Analysis of the Technical Principles and Application Expansion of DeFi Lending Systems
This article is an original piece by Chain Catcher, authored by Xu Chaoyi.
In the world of DeFi, decentralized lending systems are an extremely important track and serve as the cornerstone of the entire DeFi ecosystem. They can simulate the financial systems of the real world, understand the funding needs of different users, and provide a platform for mutual financing among users;
They can support lending between all crypto assets that meet the homogeneous token standard with zero marginal cost, and can automatically calculate and adjust market lending rates based on supply and demand. They can enhance the efficiency of capital utilization in financial markets by providing deposit receipt tokens, allowing the same asset to be shuttled and reused across different DeFi protocols multiple times; they can also be flexibly combined with other DeFi protocols to achieve automated operations of multi-layered, multi-level, complex, and nested financial transactions.
So, how do DeFi lending protocols actually operate? What are the underlying technical principles? What exciting applications and expansions might we see in the future? In this article, BKFUND founder Xu Chaoyi will explore these questions in detail. 1. Lending Model Based on Liquidity Pool Smart Contracts
Traditional centralized lending systems operate through peer-to-peer matching. For example, users with surplus funds can place their idle capital on the "wealth management" page of some centralized exchanges at their desired interest rates, while users with a shortage of funds can borrow by collateralizing other token assets at specified rates. Like a "trading market," "borrow" orders and "lend" orders correspond one-to-one, with the centralized exchange acting as the intermediary.
Decentralized DeFi lending systems are different. Currently, mainstream projects generally adopt a "liquidity pool" model to solve liquidity issues and achieve rapid matching of lending demands. As shown in the figure below, "depositors" can "deposit" their idle assets into the liquidity pool and "withdraw" them at any time when needed, while "borrowers" can "borrow" funds from the liquidity pool and "repay" at any time. The system will dynamically adjust the "deposit interest rate" and "borrowing interest rate" in real-time based on the inflow and outflow of funds in the liquidity pool.
The lending and borrowing rates are mainly adjusted based on two factors: the first is market supply and demand, meaning that when borrowing demand is strong, interest rates rise, and when borrowing demand is weak, interest rates fall; the second is the utilization rate of the liquidity pool, defined as U = (borrowed amount / deposited amount) * 100%. The income of depositors (deposit interest) comes from the interest paid by borrowers. Therefore, when the utilization rate rises, borrowing rates decrease, and when the utilization rate falls, borrowing rates increase.
Unlike centralized lending systems, in DeFi lending systems, a higher utilization rate U is not always better. When U = 100%, meaning all deposited funds have been borrowed out, if some depositors withdraw funds from the liquidity pool, it creates an extreme situation where the amount of deposits < borrowed amount, significantly increasing the risk of a bank run and liquidity pool liquidation.
Therefore, DeFi lending systems typically design an optimal utilization rate Uoptimal. When the utilization rate exceeds the optimal rate, borrowing rates will rise sharply to suppress further borrowing demand and ensure the safety of the liquidity pool.
Since both "deposit rates" and "borrowing rates" are adjusted in real-time and dynamically, this means uncertainty in returns and risks for users (especially for borrowers). Therefore, some new DeFi lending systems like AAVE also offer a "stable rate" option, where the stable rate generally does not change during a user's borrowing period, making it easier for users to estimate their funding costs.
Thus, users are provided with the option to switch between "floating rates" and "stable rates." Notably, when there are significant fluctuations in market supply and demand, there may also be situations where "stable rates are readjusted."
Due to the extreme volatility of crypto asset market prices, when the value of a borrower's collateral decreases or the value of the borrowed asset increases, leading to insufficient collateralization, liquidation of the borrower's loan must be executed. The essence of liquidation is to sell part of the collateral at a price below the market price to pay back the principal and interest owed by the borrower to the liquidity pool, ensuring the continuous and healthy operation of the liquidity pool.
"Deposit," "Withdraw," "Borrow," "Repay," "Rate Adjustment," and "Liquidation" are the six main events that trigger the DeFi lending system.
Since the DeFi lending system operates based on decentralized smart contracts, there is no centralized database to record the time of user deposits/withdrawals/borrowings/repayments. Therefore, the Ethereum network's block height is typically used as a timestamp to update the interest rate index of a liquidity pool.
When any of the "six events" is triggered, the index of the liquidity pool will be updated accordingly (Indexn = Indexn-1 * r), and the system will calculate the dynamic "deposit rate" and "borrowing rate" based on algorithms and update the relevant user-side interest data.
2. Observing the Operation of the DeFi Lending System from the Perspective of Six Events
1) Deposit
Depositing crypto assets is the first step for users to enter the DeFi lending system. This step transfers the user's crypto assets from their private account into the smart contract's liquidity pool, while the system begins calculating deposit interest for the user based on the real-time deposit rate.
Just like depositing in a bank, when users deposit crypto assets in the DeFi lending system, they will receive a deposit receipt. The DeFi lending system recognizes the user's deposit rights based on the deposit receipt rather than the account.
This means that if the user's deposit receipt is lost or transferred, they will also lose their corresponding deposit rights in the DeFi lending system. Additionally, the deposit receipt also serves as collateral when users borrow from the DeFi system.
Deposit receipts are typically issued to DeFi deposit users in the form of homogeneous tokens. There are two different design schemes here: the DeFi lending system represented by Compound issues receipt tokens (cToken) equivalent to the principal and interest of the deposit, paying interest through the appreciation of the exchange rate between the receipt tokens and the underlying deposit assets.
The other scheme, represented by AAVE, issues receipt tokens (aToken) equivalent to the principal and interest of the deposit, paying interest by increasing the number of receipt tokens.
We believe that both technical solutions have their pros and cons. The scheme that uses receipt tokens (cToken) equivalent to the principal and interest of the deposit can collectively share the losses of the liquidity pool among all depositors by reducing the cToken exchange rate in extreme cases of liquidity pool runs or liquidations, thus reducing the loss amount for individual users.
On the other hand, the scheme that uses receipt tokens (aToken) equivalent to the principal and interest of the deposit is more conducive to building a relatively stable payment token within the application ecosystem, while the principal and interest portions of the deposit receipt can be more flexibly split and distributed, giving rise to more financial application scenarios.
2) Withdraw
The withdrawal operation is the reverse of the deposit operation, meaning that users return the deposit receipt tokens (cToken, aToken, or others) to the contract system and receive their original deposited assets.
It is important to emphasize again that the DeFi lending system recognizes deposit rights based on deposit receipt tokens. Once the deposit receipt tokens are lost, users will be unable to retrieve their assets. In past projects, there have been instances where new users of DeFi lending systems mistakenly treated deposit receipts as a type of system airdrop (AirDrop) and sold them at a very low price in the market, resulting in significant financial losses.
3) Borrow
Users can borrow crypto assets that they urgently need but do not currently possess by collateralizing their deposit receipt tokens. Not all crypto assets can be used as collateral; typically, in the early stages, the administrators of the DeFi lending system configure mainstream, liquid crypto assets as collateral, and as the number of users grows, the types of collateral will gradually be adjusted by the community through voting governance.
Corresponding to each type of collateral are two parameters: maximum collateralization ratio and liquidation threshold. The maximum collateralization ratio indicates the ratio of the value of the collateral to the maximum borrowable crypto asset, while the liquidation threshold indicates the threshold ratio at which the collateral faces liquidation, usually with the liquidation threshold > maximum collateralization ratio.
For example, if a user uses $10,000 worth of DAI as collateral, with a maximum collateralization ratio of 75%, they can borrow up to $7,500 worth of ETH. However, if the price of ETH rises slightly from $7,500 to $8,000, and the liquidation threshold parameter reaches 80%, the user's $10,000 DAI will face liquidation.
We observe that most mainstream DeFi lending systems do not include USDT, the largest trading stablecoin, in the collateral range, possibly due to USDT's excessive centralization and the fact that its parent company, Tether, has been investigated by regulatory authorities.
4) Repay
The repayment process is the reverse of borrowing, where users return the principal and interest to the DeFi lending system, thereby reducing their corresponding debt in the system.
Deposits and borrowings in the DeFi lending system are currently both on-demand, so the repayment mechanism is also relatively flexible. Users can choose to repay in full or partially based on their actual situation.
5) Liquidation
The liquidation process involves an important concept in the DeFi lending system, namely the health factor of an account (also known as the health index). It has been mentioned earlier that the recognition of deposit rights is based on receipts, while the health factor is related to the account's borrowed amount and collateral, specifically expressed by the formula:
Health Factor = ∑(Collateral * Liquidation Threshold) / (Borrowed Amount + Borrowing Interest)
When the health factor < 1, it will trigger the liquidation of the collateral of that user's account by the DeFi lending system. Liquidating individual users is to avoid systemic financial risks, so borrowers will be penalized by the system, while liquidators will receive certain rewards.
There are two common methods of liquidation: one is to directly sell part of the borrower's collateral at a discount through contract orders, allowing any user to repay the debt on behalf of the borrower and immediately resell for arbitrage; the other method is to publicly auction the collateral starting from a base price and gradually increasing the price.
Borrowers may feel dissatisfied with their collateral being liquidated, but in reality, liquidation is a form of protection for the borrower's assets. When liquidation is triggered, the system forcibly disposes of part of the collateral to bring the overall health index of the account back to a normal level, thus avoiding the complete liquidation of the collateral. As shown in the figure below:
6) Stable Rates, Rebalancing, and Rate Switching
As mentioned earlier, whenever the DeFi lending liquidity pool experiences deposits, withdrawals, borrowings, repayments, or liquidations, its interest rate index will change, affecting the corresponding "dynamic rates." To meet the needs of some users who are willing to pay interest premiums to reduce uncertainty in borrowing costs, new DeFi lending systems like AAVE have attempted a "stable rate" mechanism. The "stable rate" mechanism obtains external borrowing rates from oracle systems, combines them with the liquidity pool's dynamic rates, and calculates the current stable borrowing rate, maintaining relative stability for individual users during their borrowing periods, unaffected by changes in dynamic rates.
It should be noted that the current "stable rate" is not absolutely stable and may still undergo a system-enforced adjustment process known as "rebalancing." One reason for "rebalancing" is that the "stable rate" has exceeded the yield on deposits, allowing users to borrow from the system without limits for arbitrage, necessitating an "upward rebalance" of the stable rate. Another reason is when the difference between the "stable rate" and the dynamic rate becomes too large, causing the premium that users need to pay to exceed a certain value, leading to a "downward rebalance."
Borrowing users are allowed to switch between "dynamic rates" and "stable rates" to obtain optimal borrowing conditions, which will also trigger updates to the liquidity pool's interest rate index.
3. Application Expansion of DeFi Lending Systems
The vigorous development of DeFi lending systems centered around liquidity pools indeed meets the borrowing needs of some users. However, compared to traditional financial industries, the functionality still appears insufficient. From the perspective of financial application development, we believe that DeFi lending systems will have several directions for expansion in the future:
1) Fixed-Term Deposits and Loans
Fixed-term deposits and loans help users better plan their funding usage cycles, while liquidity pools can better predict changes in funds. However, the challenge posed by the fixed-term deposit and loan model to the existing interest rate index algorithm is to make fixed-term rates more attractive than on-demand rates while accommodating users' defaults, early withdrawals, or early repayments.
2) Structured Financial Products
Since the deposit rates of DeFi lending systems are themselves floating, when market demand is strong, deposit rates will rise significantly. Therefore, some structured financial products can be developed based on deposit rates, similar to traditional tiered funds, dividing funds into priority, mezzanine, and subordinate levels, with fund managers raising funds from users with different risk preferences and earning management fees and performance rewards.
3) Flash Loans
Flash loans are one of the most exciting native applications in the cryptocurrency field! This technology allows users to access unlimited amounts of liquidity from the pool with no collateral and very low transaction costs (AAVE charges 0.09%), as long as users repay the corresponding amount within the same transaction.
However, the initial technical threshold for developing flash loans is relatively high. With the emergence and development of platforms like FuruCombo, the barriers to flash loan programming will continue to decrease. Traders only need to focus on researching and implementing strategies to gain arbitrage opportunities across various DeFi protocols. Flash loan trading strategies may become the most valuable trading strategies in the crypto economy in the future!
The following is a simple example of using the FuruComb tool:
- The user borrows 200 DAI from the AAVE protocol via a flash loan.
- The user exchanges 200 DAI for 206.4727 yCrv through the 1inch platform.
- The user removes liquidity on the Curve platform, converting 206.4727 yCrv back to 223.25033 DAI.
- The user repays the flash loan and transaction fees totaling 200.18 DAI to the AAVE protocol.
- The trading strategy profits 23.07033 DAI.
4) Private Liquidity Pools Exclusively for Institutions
Most DeFi lending systems only support mutual lending of mainstream crypto assets. However, for some smaller cryptocurrencies, although their liquidity is far weaker than that of mainstream crypto assets, there is still a demand for short-term borrowing among institutional members and community members. A better approach is for institutions to guarantee the development and operation of private lending liquidity pools for borrowing and collateral needs of small tokens, ensuring that even if issues arise due to insufficient liquidity, the safety of public liquidity pools will not be affected.
5) Third-Party User-Guaranteed Loans
This is often touted as an application for "unsecured loans." In reality, this function involves an institutional user or major client of the DeFi lending system using their collateral in the liquidity pool as a guarantee to provide loans to another borrower. Institutional clients usually have offline credit guarantees or physical collateral relationships with borrowers, making them willing to use their collateral to lend to others.
The main issue here is that institutional clients should have the potential to profit from this, meaning that when borrowers repay on time, the interest they pay should be higher than the system interest, with the difference serving as a reward for the institutional client.
6) Third-Party Protocol-Guaranteed Loans
This involves DeFi lending systems extending credit to some mainstream DeFi protocols, allowing their users to engage in leveraged borrowing from lending protocol applications. Cream's Iran Bank is a typical application of third-party protocol-guaranteed loans. However, a few days ago, Iran Bank suffered a hacker attack, and approximately $37.5 million worth of crypto assets were "borrowed" from the liquidity pool, marking the largest loss from a DeFi security breach to date.
7) Account Credit Loans
The true "unsecured loan" scenario should refer to situations similar to those in apps like "Jiebei," where users obtain a certain degree of credit based on the DeFi transaction history accumulated through their account address, allowing them to borrow short-term from DeFi protocols.
A noteworthy discussion point here is that blockchain network account addresses can be generated without limits, and the cost of creation is close to zero. Do frequent DeFi transaction records hold special value?
We believe that with the further prosperity and development of DeFi, the answer should be affirmative. Account addresses with frequent DeFi transactions have owners whose capital volume, DeFi application experience, and risk resistance capabilities far exceed those of ordinary users. In the future, some new DeFi protocols may select high-quality veteran DeFi users for experience testing and airdrop tokens as testing incentives during their internal testing phases, reducing the losses from projects being exploited by bots. If an address fails to repay a loan on time, it will be blacklisted by all DeFi protocols, losing the corresponding testing incentive opportunities.
4. Conclusion
The liquidity pool model of DeFi lending systems and innovations like flash loans have ushered in a new wave of innovation. With the joint efforts of developers and community users, DeFi lending systems and their ecological products will continue to develop and increasingly integrate and innovate with mainstream finance and mainstream assets, opening up a new financial order for the future.