Introduction | Liquidity and Bank Run Risks in DeFi

This article uses Compound Finance as a case study to analyze the risks of the emerging DeFi ecosystem.

 

getting Started

 

Blockchain enthusiasts and institutional investors are focusing on open finance (aka decentralized finance or "DeFi") platforms running on the Ethereum blockchain. Given the historically low current interest rates, open financial applications have the potential to provide higher yields than traditional investment products. These open financial platforms provide financial products and services through smart contracts and blockchain technology, and give them emerging characteristics such as transparency, decentralization and deintermediation.

-Figure 0: User relationships between popular DeFi products on Ethereum-

Compound lending platform is a well-known open financial application on the Ethereum blockchain. The platform is the hub of the booming DeFi ecosystem on Ethereum, and its usage and accumulated assets have shown significant growth.

-Figure 1: The amount of ETH pledged in DeFi and the value of ETH (in USD)-

With these increasing popularity and usefulness, Compound has become a key sample of our understanding of the opportunities and risks posed by open finance. Unlike other opaque financial systems, a blockchain with voting and unchangeable history gives us the ability to examine the currency and debt components of a decentralized system. Leading users into this future financial world is based on shared knowledge, which is rooted in empirical analysis.

Compound users should be fully aware of the risks posed by decentralized lending. include:

  1. Smart contract security risks
  2. Management / protocol risk (including risk of administrator key breach)
  3. Liquidity / Bank Run Risk
  4. credit risk
In the article "Several risks to be aware of when depositing interest on Compound", Ameen Aoleimani details the first two risks and hints at the existence of liquidity / banking risks.
In this article, we will focus on the third type of risk, using empirical data to analyze liquidity risks in Compound financial markets.
All " SAIs " in this article refer to tokens called " DAI " in the era of Maker DAO single collateral. The contract address is (0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359).

 

Liquidity risk in open finance

 

The Compound lending platform is a " decentralized protocol, which can establish a currency market through algorithmic setting of interest rates based on supply and demand, so that users can trade the time value of Ethereum assets without friction " (quoted from the Compound white paper).
In short, Compound allows users to:
  • Lending assets on the blockchain to the money market to earn interest rate returns;
  • Borrow on-chain assets from the money market.

-Figure 2: Simplified schematic of the currency market-
In the Compound loan agreement, users can deposit the following types of tokens-BAT, DAI, SAI, ETH, REP, USDC, WBTC, ZRX-into the lending market to earn interest rate returns. These tokens provided by users spontaneously form a liquid currency pool and become a source of funds for other user loans.
Generally speaking, everyone thinks that the fund provider can withdraw the principal and interest invested at any time-that is, Compound will leave sufficient liquidity for the depositors so that they can use their funds at any time. However, just as the lender is subject to the size of the liquidity pool, so is the capital supplier; the sum of the upper limit of the funds that can be borrowed and the upper limit of the funds that can be withdrawn equals the size of the fund pool; and each loan reduces the fund pool Scale.

-Figure 3: In July 2019, the liquidity of the SAI money market was set back. The liquidity has approached 0 points for three times, which means that neither the lender nor the borrower can make corresponding withdrawals and loans.
When liquidity starts to decline, both withdrawal operations and loan operations that exceed the liquidity ceiling will fail. As far as liquidity is concerned, this is not a bad thing. This may be just a sign of rising supply and demand, and it is also a sign of emerging markets. Therefore, in the nascent cryptocurrency industry, the lack of liquidity is expected. The designers of Compound have long expected this to happen, so the agreement will adjust market supply and demand through floating interest rates. The algorithm for calculating floating interest rates is written into smart contracts in the money market. In a currency market,
When liquidity is low:
  • The annualized return on deposits rises, incentivizing users to provide funds
  • The annual interest rate of loans rises, incentivizing users to repay their borrowed tokens
When liquidity is high:
  • The annualized return on deposits has decreased, reducing the incentive for users to deposit
  • The annual interest rate of loans declines, incentivizing users to borrow funds at low interest rates
The agreement's floating interest rates are designed to address the lack of liquidity in a decentralized form. However, the potential risk to users of such open financial applications is bank runs .
When depositors are anxious about market stability and try to withdraw funds that are beyond the platform's tolerance at the same time, bank runs will occur, which will cause more panic and mistrust of the system. In the context of open blockchain financial applications, bank runs mean that powerful forces-whether in the capital market itself or manipulated interests-have broken through decentralized protocols and their automatic feedback mechanisms.

-Figure 4: Simplified Bank Run Model-
Johannes Pfeffer, co-founder of Alethio, points out that "if there is a problem in a part of the system, such as the collapse of DAI or other stablecoins, DeFi is likely to stage a bank run." This is a well-known problem that also caused blockchain Community attention. Maker DAO, the issuer of SAI and DAI stablecoins, has a global clearing mechanism to deal with the possible impact of market crashes. It cannot be denied that Compound uses an incentive mechanism to control serious liquidity shortages (see the appendix for details). However, the following issues are critical to open finance applications:
  1. Has liquidity dried up before?
  2. Does Compound's value change over time?
  3. Has a bank run occurred? Is it possible in the future?
In order to answer these questions, we will use SAI (that is, the token that people previously called DAI), the most active lending asset in the Compound lending market at the time of writing, as the core analysis.

Explanation of liquidity depletion

 

Through the analysis of Compound, we divide the lack of liquidity into three guiding definitions or "stages", and finally give our conclusions:
  1. Quasi-liquidity depletion : Occurs when the liquidity approaches zero. However, due to the small liquidity pool, no withdrawal or loan failure has yet occurred.
  2. Actual liquidity depletion : when withdrawals or loans fail due to insufficient funds in the liquid pool.
  3. Bank runs : Continuously raising the current cause led to the rapid depletion of the liquid pool until "zero supply", and a greater market panic appeared.
The table below shows the total lending and total borrowings in Compound's SAI market in July 2019.

-Figure 5: SAI Lending and Borrowing Amount—Statistics when the interest rate contract is changed for the first time-
In Figure 5:
  • Green line is SAI total deposit
  • The red line is the total loan amount of SAI
  • The gray line is the utilization rate (loan amount / deposit amount)
  • The blue circle- close to the green and red lines-is when the liquidity is depleted and quasi-liquid
A total of three quasi-liquidity depletions and one actual liquidity depletion occurred in the SAI currency market in July—on July 15, 19, and 23, respectively. We notice some interesting commonalities.
  • Depositors' withdrawals are not the culprit that causes quasi-liquidity depletion . On these dates, the green line did not fall significantly (ie, there were no sudden large-scale withdrawals).
  • Consecutive large-scale loans are the real cause of quasi-liquidity depletion . On these dates, the red line suddenly spiked (that is, there was a sudden large-scale borrowing).
  • These loans have reduced the liquidity pool to the point where almost all available funds have been borrowed.
Among the two types of operational failure caused by insufficient liquidity, the negative impact of loan failure is relatively small. Obviously, being unable to withdraw your funds from the fund pool is more serious than being unable to borrow a certain amount of funds. Therefore, our focus is on the moment when people try to withdraw their funds but fail to operate due to insufficient liquidity.
So has Compound ever experienced a depletion of actual liquidity ? In other words, although the liquidity is almost close to 0, has anyone actually encountered the problem of liquidity withdrawal failure from the protocol?
The answer is, yes.

-Figure 6: All liquidity depletion events-
The above table shows that throughout the history of the Compound currency market, withdrawal failures ("REDEEM" in the "Info Descripition" column) have occurred three times, of which two were related to BAT. Since the BAT market is in its infancy and has a small volume of transactions, we do not think that these withdrawal failures are a good illustration. More noteworthy is the case that occurred on the SAI market with larger trading volume on July 19, 2019. Therefore, we can conclude that one of the three quasi-liquidity depletions that occurred in July 2019 shown in Figure 5 (occurred on July 19) was the actual liquidity depletion .

-Figure 7: Table 5 in more detail-the only time a SAI withdrawal transaction failed. See Block Browser.
Figure 6 marks the withdrawal failure that occurred on July 19 in yellow, and this event can also be observed in Figures 3 and 5. Figure 7 is an enlarged version of this moment. The failed withdrawal transaction was originally intended to redeem 344020.128054 cSAI tokens-the cSAI / SAI ratio at the time was 0.0203495763, meaning the transaction was worth 7000.66 SAI. However, at the same time, the utilization rate of funds in the market has exceeded 99.97%, and the available liquidity is only 5790.16 SAI.
For the transaction initiator, this incident meant that TA tried to withdraw 344,000 cSAIs in its own name, but the withdrawal failed because the application could not provide sufficient funds. In response, Compound adjusted its interest rate model to incentivize users to re-form a larger pool of funds, thereby returning liquidity to a higher level (see the appendix for details). As a result of this measure, the withdrawal was successfully redeemed in less than 5 minutes (see Figure 8).

Figure 8: The user successfully withdrew 344,000 SAI less than 5 minutes after the initial attempt failed.

A chance?

 

We can completely consider the failure of withdrawal on July 19 as an unusual case. However, despite the fact that this may be the case, in-depth analysis shows that Compound Finance has experienced several critical moments in the past.
We will show five large-scale events and analyze in depth the most serious one.

-Figure 9: Five large-scale "one-off" moments—withdrawal operations that significantly reduced available liquidity—
In these five events, Compound encountered a single withdrawal that was sufficient to reduce available liquidity by more than a quarter.
The largest (percentage) occurred at block 8208406 at 18:04 on July 23. (Figure 5 shows this transaction, at this moment the capital utilization rate in the market reached 99.17%). One address initiated the withdrawal of more than 216,000 SAIs, making the flow pool instantly fall to only 10,900 SAIs. The following figure (Figure 10) shows the large amount of capital suppliers and the liquidity situation of the market before the current proposal took place.

-Figure 10: The threshold of remaining liquidity (before the 216,000 SAI withdrawal operation) —meaning that only some large households can fully withdraw their loans, while other large depositors cannot-
We can also see that even before this 216,000 SAI huge withdrawal transaction occurred, most of the users in the top 30 of deposit volume were unable to withdraw their funds in full. It can be imagined that this critical line in the figure is facing two kinds of pressure-the depositor will push this line to the right by injecting funds, and the cashier / loan will push it back to the left. After the user with the address 0x… 5e3d (specially marked in Figure 10) withdrew 216,000 SAIs, the available liquidity dropped below 10,000 SAIs, making more users unable to successfully withdraw: compared to this withdrawal Before, another 2125 users faced the problem of not being able to withdraw in full.

Black Swan Crisis: Bank Run

 

Therefore, we can conclude from these pictures that at least five quasi-liquidity depletions have occurred in Compound Finance (Figure 9) and one actual liquidity depletion (Figure 6). Some people are alert, but most people choose to ignore these events. By adjusting the interest rate model, the agreement regains its functionality and liquidity. However, given the fact that Compound's incentive mechanism cannot effectively hedge the risk of liquidity depletion, and it will also cause withdrawal failures, we must accurately assess the risk of bank runs. A proven lack of liquidity at one time may only affect one or several users (usually larger users) in failing to withdraw cash, but a bank run will prevent a large number of other users from withdrawing even if they only hold relatively small Of deposits.
With the growth of Compound's user base, the expansion of loans has greatly reduced liquidity, which may cause depositors to panic and start to withdraw funds. First of all, large withdrawals will fail. At the same time, as the flow pool further shrinks, more and more users will not be able to successfully retrieve their funds. The end result will be like a traditional bank run, the only difference is that it happens on a decentralized platform.
It is foreseeable that a bank run like this will become a "black swan" event-that is, an unpredictable event that is rarely encountered in a lifetime, and it is also difficult for users to prevent it. However, we already know five liquidity depletions in history (three occurred in July) and one withdrawal failure. In addition, by detecting lenders and borrowers, we can also observe how close to zero the liquidity is at some point.

Mitigate insufficient liquidity and bank run risks

 

Introduce monitoring measures

Depletion of liquidity will always occur. Providing relevant information to open financial users as quickly as possible is the best way to help them avoid and / or respond to liquidity risks (thus preventing more serious events such as bank runs). Timely alerts help users better understand DeFi applications, prompting them to make choices and take action to better achieve their financial goals.
Effective alerting and monitoring facilities can:
  • Understand data from blockchain and other decentralized applications
  • The following steps can be repeated continuously: "Inform ➞ Urge a decision / action 采取 Inform ➞ Urge a decision / action …"
  • Measure the effectiveness of decisions / actions and integrate them into the data
We believe Alethio can do all this.
With Alethio's monitoring tools, users can set up active and customizable monitoring of any deployed smart contract or account. With these monitors, users can get alerts in real time as soon as conditions set are triggered. Alethio monitoring can eliminate the need for users to actively search for information, while meeting users' needs for real-time access to data on the chain.

-Figure 11: Setting goals in Alethio monitoring is so easy-

-Figure 12: Set up specific alerts based on your goals-the figure shows the cToken contract (the cSAI contract was set as the target in the previous step). This alert will monitor SAI liquidity.
The screenshot above shows the alert on Compound liquidity in the Alethio monitoring page. Whenever liquidity drops by 1%-or any set percentage or value (that is, when liquidity drops or rises above a certain limit)-monitoring will sound an alert.
All in all, we have set up the alert function so that existing and potential users can more confidently use open financial products such as Compound, and hope to take the DeFi system to the next level. With convenient channels to obtain data, information and analysis, users can use the open platform with peace of mind. We have developed Alethio components to make it easier for Ethereum users. And as the entire ecosystem grows, I believe we can make it better.

Appendix: Compound's Interest Rate Incentive Technology

 

As a loan agreement, Compound works as follows (response intensity may vary):

-Figure A: Simplified schematic diagram of the Compound flow pool (Note: When lenders deposit mortgage assets, they are actually suppliers on the collateral token market. It is only for the sake of simplicity that we call the two parties in this way)-
The depositor deposits one of the following seven tokens (BAT, SAI, ETH, REP, USDC, WBTC, ZRX) into the corresponding market, and the lender borrows these tokens by virtue of collateral. The money borrowed by the lender is taken from the pool of funds formed by the depositor's deposit. As each loan will shrink the liquidity pool, the size of the loan is limited by the size of the liquidity pool. However, it is not only loans that will shrink the pool of funds.

-Figure B: Schematic diagram of the liquidity pool of withdrawal activities of depositors-
A common understanding of Compound is that lenders can withdraw their deposit at any time. But is that really the case? As mentioned earlier, the amount of money that a user can loan is limited by the size of the liquidity pool; Figure B shows that the capital outflow of the agreement in two directions-the lender's loan and the depositor's withdrawal, will reduce the funds. Once liquidity begins to decrease, withdrawals or borrowings that exceed liquidity will not be completed.
Therefore, the two outflow funds will eventually be aggregated into one number-utilization rate. According to the Compound white paper:

-For any market α of tokens, there is a utilization rate U = loan amount / (cash in the pool + loan amount)-
The utilization rate can not only show which token market demand is higher, but also serve as a market supervision mechanism. Then, the interest rate is derived according to the utilization rate and the algorithm, so that the market can reach a state of equilibrium between supply and demand. This can be expressed by a simple equation mentioned in the white paper:

-Example: loan interest rate = 2.5% + U * 20%-
Please note that the constants in the above two formulas are only examples; although they are hard-coded in each market-related interest rate model contract, they can also be changed (by the administrator, ie Some multi-user addresses) change. The first constant is called the base rate and the second is called the rate. In addition, the formula also shows the upper limit of the loan interest rate (at 100% utilization, the loan interest rate reaches the maximum value, which is the sum of two constants).
At the time of writing, there are three different interest rate model contracts in Compound's seven currency markets, each with its own specific parameters. Now let's explore the changes that have occurred in these contracts-and more importantly, understand the context in which these changes occurred (because the details of these changes are too rich, we will only discuss the SAI market).

Interest rate model

By far the most interesting are the two changes in the SAI market (until mid-November, USDC replaced it, becoming the largest currency for loans) Is reverting to the original contract). The changes that occur are as follows:

0xa1046abfc2598f48c44fb320d281d3f3c0733c9a — Original contract, created on May 7th 0x8caa40e8b5227b7a1079a9e883d92de018957e5256f356aa6d28b2610e7b1c44

 
Basic rate: 5%
Magnification: 12%
Maximum loan interest rate = Maximum deposit yield = 17%

0xd928c8ead620bb316d2cefe3caf81dc2dec6ff63 — second contract, created on July 19 at 0x3abfc9be9f02c449bf85750736ecdca25bbe33e3632cae9c682824fd97e16cc9

 
Basic rate: 5%
Magnification: 15%
Maximum loan interest rate = Maximum deposit yield = 20%

0xa1046abfc2598f48c44fb320d281d3d3f3c0733c9a — return to original contract, traded on September 16th 0xd763ddbd5f7444bacc3dcbb2e21b4b8c864fd1b4bccf05ab11192e27a1acbbc1 activation

 
Basic rate: 5%
Magnification: 12%
Maximum loan interest rate = Maximum deposit yield = 17%

(Finish)

(Many hyperlinks are provided in the text, please click to read the original text and get it on the EthFans website)

Original link:

https://medium.com/alethio/overlooked-risk-illiquidity-and-bank-runs-on-compound-finance-5d6fc3922d0d

Author: Bogdan Gheorghe, Momo Araki, Everett Muzzy

Translation & Proofreading: Zhou Jin & A Jian

This article was translated and republished with permission from the original author EthFans.