DeFi Evaluation Method 2: Analyzing Liquidity Protocols

BeginnerJan 24, 2024
This article begins by dissecting the operational principles of lending protocols and CDP (Collateralized Debt Position) protocols through Justlend and MakerDAO, respectively. It then uses DYDX to illustrate the significance of protocol risk management.
DeFi Evaluation Method 2: Analyzing Liquidity Protocols

To establish a sound liquidity protocol, a comprehensive evaluation needs to consider various aspects, including ① the construction of liquidity pools; ② the mechanism of over-collateralization; ③ the effectiveness of oracle services; ④ the design of interest rate functions; ⑤ the mechanism for liquidation; ⑥ the core mechanism design.

The key points for evaluating liquidity protocols lie in grasping the essence, with the core being “lending.” However, the difference lies in whether the protocol can have an effective price discovery mechanism, provide ample liquidity, and avoid unnecessary cost losses.

1. The On-Chain DeFi

Since the birth of Bitcoin, the concept of peer-to-peer decentralized payment has finally made a breakthrough. Many project parties are committed to building a decentralized free financial market on the chain - taking a single public chain as an example, a public chain with users, ecology, and native currency can be understood as a country to some extent, and in this sovereign economic ecosystem:

① The native currency serves as the standard currency, and the stable currency anchors a constant price on the chain to connect the currency standard and the US dollar standard;

② The decentralized lending protocol replaces traditional banks to implement a decentralized on-chain lending and price exchange mechanism;

③ Decentralized “bond market”, RWA treasury bonds under the original benchmark interest rate + LSD-Fi;

④ Decentralized derivatives provide risk management for hedging against asset volatility;

In addition, there are the emergence of decentralized insurance trusts, asset management funds, lottery competitions, and decentralized supply chain finance solutions. Any product in the traditional financial market can be reconstructed and implemented in the world of blockchain. Furthermore, based on the characteristics of the blockchain, innovative functions like lightning-fast transactions, which are impractical offline, can also be realized.

The crypto world has, to some extent, perfected the elements constituting the decentralized financial market. Among different blockchains (sovereign economic entities), based on the token economics of each project, the native currency serves as the standard currency for on-chain governance. Various tokens within the ecosystem can appear both as equity and debt. The value of a chain lies in how much economic activity it supports.

Underpinned by the establishment of an on-chain native bond market, RWA national debt projects and Liquidity Staking Derivatives (LSDFi) post the Shanghai upgrade have gained significant popularity.

As a DeFi project, one of the core aspects is addressing liquidity issues. Liquidity, in a broad sense, refers to the monetary funds that an entity can control. In the traditional financial sector, liquidity usually indicates the tradability and ease of cashing out of an asset or market. Whether it is a liquidity lending protocol or a liquidity staking protocol, it all boils down to the essence of finance: borrowing and lending.

2. How to build a liquidity protocol

Let’s start with the most important intermediary in traditional finance, the bank, and talk about the construction and evaluation methods of liquidity protocols in DeFi.

The essence of a commercial bank is that it integrates deposit-taking and loan-issuing and becomes an incentive system that actively creates liquidity.

According to traditional financial theory, in a perfect world with complete markets, symmetric information and zero transaction costs, there is no need for banks and non-bank financial intermediaries to exist. Borrowers and lenders can achieve Pareto optimal resource allocation results through free transactions.

But this perfect situation is obviously impossible to achieve, which is also the role of banks as the most important financial intermediaries in the real world.

For a commercial bank, the core business has two points: on the one hand, it absorbs deposits and provides interest, and on the other hand, it lends deposits to obtain interest, which provides liquidity to the market while earning interest differentials. The central bank regulates the amount of deposits and loans and interest rates through various monetary policy tools.

Compared with banks’ lending and price exchange mechanisms, the advantages of non-custodial decentralized protocols include: transparency and effective pricing based on market demand, fast and convenient lending, and resistance to censorship.

After understanding this, we can easily understand liquidity protocols in decentralized finance. The following is a simple example of the lending protocol currently ranked third in TVL in Protocol Rankings, taking JustLend as a simple example.

JustLend DAO Protocol

This is a TRON-powered money market protocol that aims to establish a money market based on interest rates determined by supply and demand algorithms. The interest rate in this protocol is determined by an algorithm based on the supply and demand of TRON assets.

There are two roles in the protocol, Supplier and Borrower, both parties interact directly with the protocol to earn or pay floating interest rates.

Supply:

In this protocol, the funds supplied by all users are first aggregated to form a liquidity pool (loan pool), achieving high liquidity by lending to the pool rather than on a peer-to-peer basis, better realizing monetary balance. In this scenario, liquidity providers (LPs) do not need to wait for individual loans to mature but can withdraw assets from the pool at any time.

Suppliers deposit assets into the currency market of the JustLend DAO smart contract, and the assets provided in this process are represented as jTokens (a type of TRC-20 token). Holders of these tokens receive rewards according to the relevant rules (enjoying interest income from the loans).

IInterest rate:

The interest rate on a traditional financial loan generally remains the same throughout the life of the loan. But in this protocol, interest rates will change in real time based on changes in market supply and demand, and lending/supply rates in different markets may vary from block to block. Interest in the protocol is calculated based on the block generation time on TRON, and borrowing interest will accumulate based on the number of blocks.

In this protocol, the borrowing interest rate is calculated based on two models, namely the smoothing interest rate model and the staged interest rate model. The mathematical model will not go into details. The principle is: when borrower demand for crypto assets declines, the excess tokens in the pool that can be used for lending will bring higher liquidity and lower interest rates, thus encouraging lending. Likewise, when demand for borrowing an asset is high, the number of tokens available for lending decreases, which results in lower liquidity and higher interest rates, thus attracting supply.

The design of interest rates is a core part of the DeFi protocol. Just in October this year, the collateral lending platform Yield Protocol announced plans to cease operations. One of the reasons was that it lacks demand for fixed-rate lending on the platform. A good interest rate mechanism can drive the development of a trend.

3. Elements of Liquidity Protocol

It can be seen from a typical lending protocol such as JustLend DAO Protocol that the following points need to be considered when building a liquidity protocol:

① Construction of capital pool: LP injects liquidity

②Over-collateralization mechanism: the borrower obtains a loan

③Oracle effectiveness: tracking collateral prices

④Interest rate: floating interest rate, fixed interest rate, etc.

⑤Design of liquidation mechanism: processing mechanism when the collateral is insufficient

⑥Core mechanism design: price stabilization mechanism and risk control establishment

The collateral mechanism is a kind of liquidity lending, which is also the innovation point of some mechanisms, such as generating liquid project tokens for transactions through full collateral, so that there is no need to set up a liquidity pool through the lender.

The typical example of this kind of collateral asset is the Maker protocol.DAI stablecoin.

Anyone can use the Maker protocol to create a smart contract called “Maker Vault (Maker Vault)” and deposit assets to generate DAI, thereby using collateral assets to generate Dai for leverage on the Maker platform. Let’s take a look at Dai’s collateral lending ideas.

Collateralized Borrowing with DAI

Step 1: Create a Vault and Lock in Collateral

Users create a vault through an interface provided by the community and lock in a specific type and quantity of collateral to generate DAI. The vault is considered collateralized once funds are deposited.

Step 2: Generate DAI from Collateralized Vault

After locking collateral assets into a vault, the vault owner can use any non-custodial cryptocurrency wallet to initiate and confirm transactions, generating a certain quantity of DAI.

Step 3: Repay Debt and Pay Stability Fee

To retrieve some or all of the collateral, the vault owner must partially or fully repay the generated DAI and pay the stability fee that accumulates during the outstanding DAI period. The stability fee can only be paid in DAI.

Step 4: Withdraw Collateral

After repaying DAI and settling the stability fee, the vault owner can withdraw some or all of the collateral back to their wallet. Once all DAI is fully repaid and all collateral is withdrawn, the vault becomes empty, awaiting its owner to lock in assets again.

It is crucial to note that different collateral assets must be placed in separate vaults. Some users may have multiple vaults with different collateral types and collateralization ratios.

Liquidation Mechanism of DAI

The Maker Protocol employs an automated auction process to liquidate high-risk vaults, ensuring there is always sufficient collateral to support outstanding debt. Liquidation decisions are based on the liquidation ratio and the collateral-to-debt ratio of the vault. Each vault type has a corresponding liquidation ratio, determined by MKR holders through a voting process based on the risk of the collateral.

When the collateralization ratio of a vault falls below the minimum threshold, the auction liquidation process is initiated. The DAI obtained through collateral auctions is used to repay the debt within the vault, including liquidation penalties. If the auction proceeds in DAI are sufficient to cover the debt and pay the liquidation penalties, a reverse collateral auction is conducted to reduce the amount of collateral sold.

If the DAI obtained from collateral auctions is insufficient to cover the debt, the deficit becomes a liability for the Maker Protocol. DAI from the Maker Buffer is used to repay this portion of the liability. If the buffer is insufficient, it triggers the debt auction mechanism. During debt auctions, new MKR is minted and sold to users participating in the auction using DAI. The DAI obtained from collateral auctions enters the Maker Buffer.

The role of the Maker Buffer is to mitigate the impact of future collateral shortages and excessive MKR issuance due to rising DAI deposit rates. If the DAI obtained through auctions and stability fees exceeds the upper limit of the Maker Buffer, surplus auctions are conducted. During surplus auctions, MKR is auctioned for a fixed quantity of DAI, with the highest bidder winning. After surplus auctions conclude, the Maker Protocol automatically burns the auctioned MKR, reducing the total supply of MKR.

Liquidity protocol suffers price attack

Above, through the cases of JustLend DAO Protocol and MakerDAO, we can observe some key points in creating a liquidity protocol. While writing this article, a well-known DeFi project, dYdX, suffered a price attack, and part of the liquidity in the insurance pool was drained.

dYdX is a decentralized derivatives exchange for perpetual contracts and margin trading. It provides order book-style blockchain digital asset trading services and provides leverage and contract trading functions. Simply put, it is a decentralized order book model contract exchange where anyone can freely trade contracts on this exchange.

However, in the recent YFI-USD trading pair on the platform, the YFI token was gradually pulled up and then suddenly crashed, causing $YFI’s open interest in dYdX to soar from $800,000 to $67 million in a few days. Before the price collapsed, the price attacker was able to withdraw a large amount of USDC from dYdX, which caused a large amount of dYdX’s insurance pool funds to be drained. The founder also announced that the liquidation engine would be redesigned in the V4 version.

In this trading pair, YFI is the native token of the Yearn Finance project, known for its liquidity mining strategies. Users can engage in various liquidity mining strategies through Yearn Finance, interacting with other DeFi projects through the platform’s three core products: Earn, Vaults, and Iron Bank. Yearn Finance is also a significant participant in the DeFi Lego concept.

It can be seen from the case of dYdX that if some small liquidity protocols encounter price attacks, they will easily be drained of liquidity. This situation will especially occur when using the Automatic Market Maker model. In trading protocols, there are often huge price discovery problems associated with oracle machines.

Mango is a decentralized contract platform on Solana. It also suffered a price attack on October 22.

In that incident, the attacker established a position by transferring US$5 million to the A and B addresses of the Mango trading platform, used the contract to make his own counterparty on Mango, and opened MANGO for both long and short positions. Subsequently, the attacker used more funds to purchase MANGO tokens, manipulating its price from 2 cents to 91 cents, and used the huge net book assets within the platform to realize part of the proceeds from Mango through borrowing. Despite insufficient liquidity, they were able to withdraw 110 million US dollars.

In December of the same year, the Bsc chain lending protocol Helio also suffered a price attack. The attacker took advantage of the vulnerability of the oracle’s untimely price feed, and successfully conducted collateral lending operations by exploiting a smart contract vulnerability to overissue aBNBc tokens and convert them into Hello’s hBNB. The attacker lent the stablecoin HAY worth 16.44 million US dollars and exchanged it for approximately US$15 million in general assets for withdrawal. The attack caused significant damage to the Helio protocol, revealing the risks of oracle and contract vulnerabilities and the importance to the security of lending protocols.

4. Liquidity Asset Pool

Once we understand the elements required for a liquidity protocol, a crucial step is to establish a liquidity asset pool. There are many classifications for liquidity asset pools, with a focus on the evolutionary path of Automated Market Maker (AMM) liquidity pools. Additionally, we will briefly introduce loan pools, options collateral pools, and machine gun pools.

AMM Liquidity Pools

Regarding Automated Market Makers (AMMs), as we discussed in “DeFi Evaluation Method 1: Uniswap Iterative Review,” Uniswap is undoubtedly the first project that comes to mind. In AMM, a decentralized market-making model is implemented, allowing anyone to provide liquidity.

However, with the passage of time, AMMs continue to evolve, moving beyond simple Constant Product Market Maker (CPMM) models by optimizing and upgrading existing deficiencies.

Firstly, there are several types of Constant Function Market Makers (CFMMs), including CPMM, CSMM, and CMMM.

①Constant product market maker (CPMM) model

x·y=k

(x is token1, y is token2, k is a constant)

Essentially, Uniswap combines two assets being traded into a single liquidity pool, with the goal of ensuring that the size of the liquidity pool will remain the same regardless of the size of the trade. And when the capital pool becomes unbalanced and tilted in a certain direction, arbitrageurs will come in and quickly rebalance in exchange for the difference in profits.

Problems with CPMM: Slippage, impermanent losses and security risks. For details on this part, you can read the previous tweet [DeFi Evaluation Method 1: Uniswap Iterative Review], which is very clear.

②Constant sum market maker (CSMM) model

x+y=k

(x is token1, y is token2, k is a constant)

CSMM is more suitable for scenarios where price changes in transactions are close to zero, but this model cannot provide unlimited liquidity.

Disadvantage: When the off-chain price does not match the token price in the pool, traders and arbitrageurs have the opportunity to consume the reserves in the pool and destabilize the liquidity pool. This will cause the assets in the liquidity pool to be concentrated into a certain asset, thus losing liquidity.

③Constant mean market maker (CMMM) model

(x·y·z)*(1/3)=k

(x is token1, y is token2, z is token3, k is a constant)

The main case of CMMM is Balancer. This protocol is more flexible than Uniswap, and the liquidity pool created can be composed of a variety of different assets. The flaws are the same as CPMM: slippage, impermanent losses and security risks.

In the three cases of CFMM, problems are concentrated, mainly in slippage, impermanent loss and liquidity. In order to avoid these problems, new projects are constantly trying to introduce innovative model mechanisms for formulas, such as:

④Hybrid CPMMs(Stableswap)

Hybrid CPMMs are a combination of CPMM and CSMM, and are applied by Curve Finance. Through a new formula, exponentially dense liquidity is created and linear exchange rates are provided for most of the curve.

Curves Stableswap is a special type of Constant Sum Market Maker (CSMM). When the pool is balanced, it functions as a CSMM; however, once the pool becomes unbalanced, it shifts towards a Constant Product Market Maker (CPMM). By finding its own market fit, it significantly reduces slippage when trading related assets.

Outside of Automated Market Makers (AMMs), there are also attempts with Parameterized Market Makers (PMMs) and Dynamic Market Makers (DMMs).

⑤PMM (Proactive Market Maker)

PMM appeared in the DODO protocol. The core is to introduce oracles to collect accurate price data, while using the supply and demand mechanism on the chain to conduct price discovery, and aggregate liquidity near the current market price, which can achieve unilateral liquidity and lower slippage. point.

PMM can provide more sufficient liquidity, but it relies more on high-frequency trading, which is difficult to achieve in reality.

⑥ DMM (Dynamic Market Maker)

The core of dynamic market makers lies in dynamic fees. After creating liquidity pools with specific token pairs, each liquidity pool will support dynamic fees. Increasing fees when market volatility is high and reducing fees when market volatility is low, boosting trading and volume.

By doing so, it optimizes potential returns for liquidity providers. As a pool creator, programmable pricing curves can be customized using specific amplification (AMP) factors. Dynamic fee ranges will also change based on the AMP used for pool creation.

Loan Pool

After introducing AMM, other models are relatively straightforward and can be illustrated with examples. The loan pool model aims to facilitate liquidity in decentralized lending markets, acting directly as the counterparty for lending transactions (pool-to-point). This type of loan pool has various benefits and is quite common, as seen in the JustLend DAO Protocol mentioned earlier, as well as Compound and AAVE.

Taking AAVE as an example, creating a loan pool involves the following steps:

①Asset Preparation: First, specific cryptocurrencies are designated as the pool of funds for lending and borrowing, such as USDT, USDC, BTC, etc. The liquidity pool supports various types of assets.

②Configuring Loan Rates: Loan rates for different assets are configured through smart contracts. Rates can be adjusted based on market demand, supply, and risk parameters. Borrowers can choose lending conditions based on their risk tolerance and prevailing market rates.

③Providing Liquidity: Users, as Liquidity Providers (LPs), deposit assets into AAVE’s liquidity pool, providing the necessary funds for the lending market and earning corresponding interest returns.

④Lending Operations: Borrowers select the assets they want to borrow and obtain loans by over-collateralizing based on the value of their collateral and the loan rate.

⑤Interest Distribution: LPs receive interest returns based on the amount of funds they provided and the duration.

Machine gun pool

A machine gun pool refers to the process in Proof-of-Work (PoW) mining where, for different currencies using the same algorithm, the mining power is automatically switched to mine the currency with the highest real-time mining returns. In other words, it mines the currency with the highest yield.

In this scenario, the pool exploits arbitrage opportunities between different liquidity mining projects, dynamically allocating funds to different liquidity pools to maximize returns.

Options Collateral Pool

Options contracts can also be decentralized and managed through smart contracts. Currently, major exchanges have also listed options products. Derivatives, based on the value changes of an underlying asset, can be used for hedging and structured financial product designs. For example, the Snowball structure in traditional finance is a form of structured product.

There are now decentralized options protocols emerging, some of which use the AMM liquidity pool model. In this model, the liquidity pool serves as the unified seller of options, addressing issues such as poor options liquidity and lack of counterparties.

One example is the previously popular Multi-assets Single Pool (MASP) model. This model combines oracle and AMM mechanisms, consolidating different underlying assets into a unified liquidity pool. This approach provides margin and liquidity support for trades.

The key evaluation points for liquidity protocols lie in grasping the essence; while the core is lending, the difference lies in whether the protocol can have a good price discovery mechanism, provide sufficient liquidity, and avoid unnecessary cost losses.

Disclaimer:

  1. This article is reprinted from [weixin]. All copyrights belong to the original author [Arrow杂谈]. If there are objections to this reprint, please contact the Gate Learn team, and they will handle it promptly.
  2. Liability Disclaimer: The views and opinions expressed in this article are solely those of the author and do not constitute any investment advice.
  3. Translations of the article into other languages are done by the Gate Learn team. Unless mentioned, copying, distributing, or plagiarizing the translated articles is prohibited.
Start Now
Sign up and get a
$100
Voucher!
Create Account