The key to evaluating liquidity protocols is to grasp the essence. The core is "lending", but the difference lies in whether the protocol can have a good price discovery mechanism, whether it can provide sufficient liquidity, and whether it can avoid unnecessary cost losses.
In order to set up a liquidity protocol, you need to comprehensively consider the following aspects, including ① the construction of the funding pool; ② the excess collateral mechanism; ③ the effectiveness of the oracle; ④ the interest rate function design; ⑤ the liquidation mechanism design; ⑥ the core mechanism design.
The key to evaluating liquidity protocols is to grasp the essence. The core is "lending", but the difference lies in whether the protocol can have a good price discovery mechanism, whether it can provide sufficient liquidity, and whether it can avoid unnecessary cost losses.
1. The decentralized financial world on the chain
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 is used as the standard currency, and the stablecoin is anchored on the chain at a constant price to connect the currency standard and the US dollar standard;
② Decentralized lending protocols replace traditional banks to achieve decentralized on-chain lending and price exchange mechanisms;
③Decentralized "bond market", RWA bonds + LSD-Fi under the native benchmark interest rate;
④ Decentralized derivatives realize hedging risk management of asset fluctuations;
In addition, there are decentralized insurance trusts, asset management funds, lottery competitions, and decentralized supply chain financial solutions. Any product in the traditional financial market can be reconstructed and realized in the on-chain world. And based on the characteristics of the chain, innovative functions such as lightning transactions that cannot be implemented off-chain can also be realized.
The Crypto world has, in a way, perfected the elements of the free financial market on the chain. Between different public chains (sovereign economies), based on the token economics of each project, the native currency is used as the standard currency for on-chain governance. Various tokens in the ecosystem can appear as both equity and debt. The value of a chain lies in how much economic activity it supports.
Under the construction of the on-chain native bond market, the RWA Treasury bond project and the Liquidity Staking Derivatives (LSDFi) upgraded from Shanghai are both very popular.
As a DeFi project, one of the core issues is to solve the liquidity problem. The so-called liquidity: in a broad sense, refers to the monetary funds that a subject can control. In the field of traditional finance, liquidity usually refers to the degree of tradability and easy redemption of an asset or market. Whether it is a liquidity lending agreement or a liquidity pledge agreement, it ultimately comes 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: banks, and talk about how to build and evaluate liquidity protocols in DeFi.
The essence of commercial banks lies in the integration of deposit absorption and loan issuance, which becomes an incentive system for actively creating 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, and borrowers and lenders can achieve Pareto optimal resource allocation through free transactions.
But this perfect situation is obviously impossible to achieve, and this is also the role of banks as the most important financial intermediaries in the real world.
For a commercial bank, there are two core businesses: on the one hand, it absorbs deposits and gives interest, and on the other hand, it lends deposits and gets interest, and provides liquidity to the market while earning interest rate spread. The central bank regulates the amount of deposits and loans and interest rates through various monetary policy tools.
Compared with the bank's 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 the liquidity protocol in decentralized finance. Let’s take JustLend, the lending protocol currently ranked third in TVL by Protocol Rankings, as an example.
JustLend DAO Protocol
JustLend DAO Protocol: This is a TRON-powered money market protocol that aims to establish a money market with interest rates determined by a supply and demand algorithm. The interest rates in this protocol are determined by an algorithm based on the supply and demand of TRON assets.
There are two roles in the protocol, the Supplier and the Borrower, both of which interact directly with the protocol to earn or pay floating interest rates.
supply:
In this protocol, all users' supply funds are first pooled to form a fund pool (loan pool), achieving high liquidity of borrowers from point to pool rather than point to point, and better achieving currency balance. In this case, the fund provider (LP) does not need to wait for a single loan to expire, but can withdraw assets from the pool at any time.
Suppliers deposit assets into the money market of the JustLend DAO smart contract, and the assets provided in the process are represented as jTokens (a TRC-20 token). Token holders are rewarded according to the relevant rules (enjoy the interest income of the loan).
loan:
If a borrower wants to borrow an asset, he or she first needs to purchase jToken as collateral for the underlying asset, and then the borrower based on the overcollateralized loan can borrow any available asset on the platform. The protocol only requires the borrower to specify the borrowed asset, and there are no other requirements such as the maturity date. In other words, as long as the borrowing conditions are met, you can borrow and never pay it back.
Borrowers can also repay their loans at any time. If the value of the borrower's collateral assets falls below the liquidation threshold, the protocol's smart contract will automatically trigger liquidation.
interest rate:
The interest rate of traditional financial loans generally remains unchanged throughout the loan period. However, in this protocol, the interest rate changes in real time based on changes in market supply and demand, and the lending/supply interest rates in different markets may vary from block to block. The interest in the protocol is calculated based on the block generation time on TRON, and the borrowing interest accumulates based on the number of blocks.
In this protocol, the borrowing interest rate is calculated according to two models, namely the smoothed interest rate model and the phased interest rate model. The mathematical model will not be repeated here, but the principle is: when the demand for crypto assets by borrowers decreases, the excess tokens available for lending in the pool will bring higher liquidity and lower interest rates, thereby encouraging lending. Similarly, when the demand for borrowed assets is high, the number of tokens available for lending will decrease, which will lead to lower liquidity and higher interest rates, thereby attracting supply.
The design of interest rates is a core part of the DeFi protocol. In October this year, the mortgage lending platform Yield Protocol announced plans to cease operations. One of the reasons was that there was a lack of demand for fixed-rate lending on the platform. A good interest rate mechanism can drive the development of a trend.
3. Liquidity Protocol Elements
From the JustLend DAO Protocol, a typical lending protocol, we can see that the construction of a liquidity protocol needs to consider the following points:
① Construction of fund pool: LP injects liquidity
②Over-collateralization mechanism: Borrowers obtain loans
③ Oracle validity: tracking collateral prices
④Interest rate function design: floating interest rate, fixed interest rate, etc.
⑤ Liquidation mechanism design: processing mechanism when the collateral is insufficient
⑥Core mechanism design: price stabilization mechanism, risk control construction
The mortgage mechanism is a form of liquidity lending, and this is also where some of the mechanism innovations lie. For example, by generating liquid project tokens for trading through full mortgage, there is no need to form a liquidity pool through lenders.
A classic example of this type of collateral asset is the Maker Protocol, the DAI stablecoin.
Anyone can use the Maker protocol to create a smart contract called "Maker Vault" and deposit assets to generate DAI, thereby using collateral assets to generate Dai as leverage on the Maker platform. Let's take a look at the idea of Dai collateral lending.
DAI’s mortgage lending ideas
Step 1: Create a vault and lock in collateral
Users create vaults through a community-created interface and lock in specific types and amounts of collateral to generate Dai. When funds are deposited, the vault is considered secured.
Step 2: Generate Dai through a secured vault
After locking the collateral assets into a vault, the vault owner can use any non-custodial cryptocurrency wallet to initiate and confirm transactions to generate a certain amount of Dai.
Step 3: Pay debt and stability fee
To get some or all of their collateral back, the vault owner must repay some or all of the Dai they generated, as well as pay the stability fee that accrued over the period that Dai was outstanding. The stability fee can only be paid in Dai.
Step 4: Removing collateral
After the Dai is repaid and the stability fee is paid, the vault owner can return some or all of the collateral to their wallet. After the Dai is fully repaid and all collateral is withdrawn, the vault will be empty and wait for its owner to lock in assets again.
It is particularly important that different collateral assets be placed in different vaults. Some users will have multiple vaults with different collateral types and collateral ratios.
DAI’s Liquidation Mechanism
The Maker Protocol uses an automated auction process to liquidate high-risk vaults to ensure that there is always enough collateral to support outstanding debt. Liquidation decisions are based on the liquidation rate and the vault's collateral value-debt ratio. Each vault type has a corresponding liquidation rate, which is voted on by MKR holders based on the risk of the collateral.
When the collateralization ratio of a vault falls below a minimum threshold, the auction liquidator will initiate the liquidation process. Dai obtained through the collateral auction is used to repay the debt in the vault, including liquidation penalties. If the Dai obtained from the auction is sufficient to repay the debt and pay the liquidation penalty, a reverse collateral auction will be conducted to reduce the amount of collateral sold.
If the Dai obtained from the collateral auction is not enough to pay off the debt, the loss becomes a liability of the Maker Protocol. The Dai in the Maker Buffer is used to repay this part of the debt. If the buffer is insufficient, the debt auction mechanism will be triggered. During the debt auction, the system mints new MKR and sells it to users who use Dai to participate in the auction. The Dai obtained from the collateral auction goes into the Maker Buffer.
The role of the Maker Buffer is to buffer the impact of insufficient collateral and excessive issuance of MKR due to rising Dai deposit rates in the future. If the Dai obtained through auctions and stability fees exceeds the upper limit of the Maker Buffer, it will be sold through a surplus auction. During the surplus auction, MKR is used to bid for a fixed amount of Dai, and the highest bidder wins. After the surplus auction ends, the Maker Protocol automatically destroys the MKR obtained from the auction, reducing the total supply of MKR.
Liquidity Protocol Suffers Price Attack
Through the cases of JustLend DAO Protocol and MakerDAO, we can observe some key points of creating liquidity protocols. While writing this article, a well-known DeFi project dYdX suffered a price attack, and part of the liquidity in the insurance pool was withdrawn.
dYdX is a decentralized derivatives exchange for perpetual contracts and margin trading, providing order book-style blockchain digital asset trading services, and providing leverage and contract trading functions. In short, it is a decentralized order book model contract exchange where anyone can freely trade contracts.
However, in the platform's recent YFI-USD trading pair, the YFI token was gradually pulled up and then suddenly smashed, causing $YFI's open interest on 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 led to a large amount of funds being withdrawn from dYdX's insurance pool. The founder also announced that the liquidation engine would be redesigned in version V4.
YFI in this trading pair is the native token of the project liquidity mining Yearn Finance. Users can complete different liquidity mining strategies through Yearn Finance and interact with other DeFi projects through the platform’s three core products Earn, Vaults, and Iron Bank. Yearn Finance is also an important participant in the DeFi Lego concept.
The dYdX case shows that if some small liquidity protocols encounter price attacks, their liquidity can be easily drained. This situation is especially likely to occur in trading protocols that use the Automatic Market Maker model, and is often accompanied by huge price discovery problems with oracles.
Mango is a decentralized contract platform on Solana, and it also suffered a price attack in October 2022.
In that incident, the attacker established a position by transferring $5 million to the A and B addresses of the Mango trading platform, using the contract to make his own counterparty on Mango, and opening both long and short MANGO. Subsequently, the attacker used more funds to buy MANGO tokens, manipulating its price from 2 cents to 91 cents, and used the huge book net assets in the platform to cash out part of the proceeds from Mango through loans, and despite the lack of liquidity, he still cashed out $110 million.
In December of the same year, the Bsc chain lending protocol Helio also suffered a price attack. The attacker took advantage of the oracle's untimely price feeding loophole and successfully carried out a mortgage loan operation by exploiting the smart contract loophole to over-issue aBNBc tokens and converting them into Hello's hBNB. The attacker borrowed 16.44 million stablecoins HAY and exchanged them for about $15 million in general assets for withdrawal. This attack caused significant losses to the Helio protocol, revealing the risks of oracle and contract loopholes, and the importance of security to lending protocols.
4. Liquidity Asset Pool
Now that we understand what elements are needed for a liquidity protocol, the key step is to build a liquidity pool. There are many classifications of liquidity pools. This article will focus on the evolution of AMM liquidity pools, and briefly introduce loan pools, option mortgage pools, and machine gun pools.
AMM Liquidity Pool
Regarding Automatic Market Maker, we have actually written it quite clearly in [DeFi Evaluation Method ①: Uniswap Iteration Review]. After all, the first project that comes to mind when mentioning AMM is definitely Uniswap. In AMM, a decentralized market maker model is implemented, and anyone can provide liquidity.
However, with the development of time, AMM is also constantly updated. It is not just a simple CPMM model, but also optimizes and upgrades the original defects.
First, there are several 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 the two assets being traded into one liquidity pool, with the goal of ensuring that the size of the liquidity pool will remain constant regardless of the size of the trade. When the pool becomes unbalanced in one direction, arbitrageurs come in and quickly rebalance it, taking the difference in profit.
CPMM issues: slippage, impermanent loss, and security risks. For details on this part, please refer to the previous tweet [DeFi Evaluation Method ①: Uniswap Iteration 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 during transactions are close to zero, but this model cannot provide unlimited liquidity.
Disadvantages: When the off-chain price does not match the price of the token in the pool, traders and arbitrageurs have the opportunity to consume the reserve in the pool and undermine the stability of the liquidity pool. This will cause the assets in the liquidity pool to be concentrated in a certain asset, resulting in a loss of 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, which is more flexible than Uniswap and can create liquidity pools composed of a variety of different assets. The defects are the same as CPMM: slippage, impermanent loss and security risks.
In the three cases of CFMM, the problems are concentrated, mainly in slippage, impermanent loss and liquidity. In order to avoid these problems, new projects continue to try to introduce innovative model mechanisms for the formula, such as:
④Hybrid CPMMs(Stableswap)
Hybrid CPMMs is a combination of CPMM and CSMM, and Curve Finance uses it to create exponentially dense liquidity through a new formula and provide linear exchange rates for most of the curve.
Curves Stableswap is a special CSMM. When the liquidity pool is balanced, it is CSMM. Once the pool becomes unbalanced, it will turn to CPMM. It significantly reduces the slippage when trading related assets by finding its own market match.
In addition to AMM (automatic market maker), there are also attempts at PMM and DMM.
⑤PMM (Proactive Market Maker)
PMM appeared in the DODO protocol. Its core is to introduce oracles to collect accurate price data while leveraging the supply and demand mechanism on the chain for price discovery, aggregating liquidity near the current market price, and achieving unilateral liquidity and lower slippage.
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 a liquidity pool with a specific token pair, each liquidity pool will support dynamic fees. Increasing fees when the market is volatile and reducing fees when the market volatility is low can promote transactions and trading volume.
Doing so optimizes potential returns for liquidity providers, as pool creators can customize programmable pricing curves with specific amplification (AMP) factors, and the dynamic fee range will also change based on the AMP used for pool creation.
Loan Pool
After introducing AMM, other models are actually relatively simple, so we will just give an example. The loan pool model aims to promote the liquidity of the decentralized lending market, directly acting as a unified counterparty for lending transactions (peer-to-peer pool). The benefits of this type of loan pool are: Very common, such as the JustLend DAO Protocol we mentioned above, as well as Compound and AAVE.
Taking AAVE as an example, creating a loan pool requires the following steps:
① Asset preparation: First, set up specific crypto assets as the funding pool for lending and deposits, which can be USDT, USDC, BTC, etc. The liquidity pool supports multiple types of assets.
②Configure lending rates: Configure lending rates for different assets through smart contracts. Interest rates can be adjusted based on market demand, supply, and risk parameters. Borrowers can choose appropriate lending conditions based on their risk tolerance and market interest rates.
③Provide liquidity: As LP, users deposit assets into AAVE’s liquidity pool, provide funds required by the lending market, and obtain corresponding interest returns.
④ Lending operations: Borrowers select the assets to borrow and obtain loans by over-collateralizing them based on the value of their collateral and the lending rate.
⑤ Interest distribution: Calculate the interest return that LP should receive based on the amount and time of funds provided by the supplier.
Smart Pool
Machine gun pool refers to the process of switching the computing power to the currency with higher yield in PoW mining in an automated manner according to the real-time mining yield of different currencies with the same algorithm. In short, it means mining the currency with higher yield.
In this scenario, the pool takes advantage of arbitrage opportunities between different liquidity mining projects and dynamically allocates funds to different liquidity pools to obtain the highest returns.
Option Collateral Pool
Option contracts can also be moved to the chain for decentralized management in the form of smart contracts. At the same time, major exchanges have now launched option products. Derivatives are contracts based on changes in the value of a certain underlying asset. They can be used for hedging and can also be used in the design of more structured financial products. For example, Snowball in traditional finance is also a structured product.
Currently, there are some options protocols focusing on decentralization. Among them, the AMM fund pool model is introduced to use the fund pool as the unified seller of options, thus solving the problems of poor option liquidity and lack of counterparties.
For example, the MASP (Multi-assets single pool) model, which was popular for a while, combines the oracle and AMM mechanisms. This can concentrate different underlying assets into a unified liquidity pool, providing margin support and liquidity support for transactions.
The key to evaluating liquidity protocols is to grasp the essence. The core is "lending", but the difference lies in whether the protocol can have a good price discovery mechanism, whether it can provide sufficient liquidity, and whether it can avoid unnecessary cost losses.