MakerDAO CDPs Liquidation Analysis

Natan
9 min readSep 3, 2019

--

Introduction

MakerDAO CDPs platform has been live since December 18th 2017. It allows users to create CDPs through the deposit of ethers as collateral and issue DAI stablecoin as the loan principal. MakerDAO enforces a collateral ratio, so that in case of an ether price decrease, the CDP is not undercollateralized resulting in losses for the platform.

A CDP turns “unsafe” if the collateralization ratio falls under 150% and the collateral becomes available for liquidation. The ETHs are sold for DAI and the system burns them, to keep the DAI value pegged to the US dollar. Also, users pay a penalty fee for having their loan liquidated. When liquidating the collateral, the penalty fee is added to the loan principal.

Given that MakerDao is a decentralized platform, the smart contract allows any interested party to act as a liquidator and obtain a profit. These liquidators are called “keepers” and they profit from buying the liquidated collateral at a 3% discount to the ETH/DAI pair. The objective of this article is to explain the liquidation process, analyze how keepers operate and quantify the business opportunity through observing the historical data of the liquidations.

Liquidation Process

The CDPs collateral is not denominated in ETH, but in PETH. PETH is the token used to represent the debtor ETHs in the MakerDAO system. When a user wants to open a CDP, they deposit a number of ETHs in the PETH pool and receives their corresponding PETH. PETH are also used to accumulate the surplus that the system obtains during the liquidations. When a CDP is liquidated, the collateral is usually more valuable than the debt to be repaid. Each time this happens, the MakerDAO system uses the surplus to buy PETH and burn them. This burning increases the price of the PETH/ETH pair, given that the pool holds more ETH than PETH issued.

The liquidation process consists of several steps:

1- The CDP falls under the 150% collateralization ratio and becomes “unsafe”.

2- An Ethereum account calls the BITE function in the MakerDAO CDPs smart contract, closing the CDP and transferring the collateral to a liquidation contract.

3- The collateral is sold at a 3% discount of the ETH/DAI pair to repay the loan principal plus the penalty fee. An Ethereum account can buy the collateral by calling the BUST function in the MakerDAO liquidation contract and transferring the correspondent amount of DAI to repay the debt.

4- The remaining DAI obtained in the liquidation are used by the MakerDAO system to buy PETH and burn them.

Currently, not many accounts take part of this liquidation process as it requires an advanced technical know-how to perform it. After the keeper buys the collateral, they have to sell it back for DAI to avoid the risk of a drop in the ETH price and loose their 3% margin. Keepers currently do all this process through a single transaction. They perform the BITE, the BUST and sell the collateral in a decentralized exchange such as UniSwap or Eth2Dai (created by MakerDao developers). This can be done through a proxy contract which executes a sequence of transactions from a single call.

Liquidation Example

We are going to analyze how these transactions works considering all the information is available on the Ethereum blockchain. All the BITE operations can be obtained from the Maker Tools Website. Also, it is possible to read the transaction data of the liquidations in Etherscan. We are going to analyze a liquidation that occurred on July 23rd 2019. The liquidation consisted of CDP 18380, which held 39.617544 PETH. The liquidation transaction data can be accessed through this link.

As mentioned above, the experimented keepers do all the liquidation process through a single transaction. This transaction triggers the different ERC-20 transactions needed to perform the liquidation. We can see all these transactions in the information provided by Etherscan (they have been ordered to show the sequence of transactions):

Image 1 — CDP 18380 liquidation process

1- BITE: the keeper calls the BITE function to the Maker Contract 1 (0x44…) and the collateral is transferred to the Maker Contract 2 (0xbda…), also known as the liquidation pool. From that point, the collateral is available for liquidation.

2- BUST: the keeper transfers from their account (0x21…) 7,837 DAI to buy the collateral and repay the outstanding CDP debt.

3- BUST: the Maker Contract 2 (0xbda…) transfers the collateral bought, 39.617 PETH, to the keeper account (0x21…).

4- EXIT: the keeper account (0x21…) executes the EXIT function to the Maker Contract 1 (0x44…) to retrieve WETH[1] for PETH. As we can observe, the keeper obtains 41.32 WETH for 39.617 PETH, meaning that the system had 4.42% surplus accumulated at that time. The PETH transfer from the keeper to the Maker contract is not observed here.

5- EXCHANGE: the keeper transfers 39.5852 WETH to an unidentified account.

6- EXCHANGE: the keeper receives 7,837 DAI from the ETH2DAI contract. Meaning that they exchanged its WETH for DAI through that platform.

If we make some basic calculations, we can obtain the profit made by this keeper. As far as we know, this keeper saved its profit in WETH. It transferred 7837 DAI to buy 41,32 WETH and then sold 39.58 WETH for the same amount of DAI, claiming a profit of 1,74 WETH. Profit can vary depending on multiple factors that will be commented below.

[1] WETH is an ERC-20 1:1 representation of ETH. It is used to interact with smart contracts in an easier way.

Variables that affect keeper’s profitability

From a protocol perspective, in the current MakerDAO version keepers can buy the liquidated collateral at a 3% discount. That does not mean that keepers obtain a profit of 3% of their capital in each liquidation transaction. The profit the keeper obtains may vary due to different factors:

  • Gas Price: some liquidations involve an insignificant amount of PETH and are not profitable due to the gas that needs to be spent to execute all the ERC-20 transactions mentioned above.
  • Price Feed: the Maker liquidation contract sells the collateral at a 3% discount. The contract receives a price feed from 10 oracles, and it performs a calculation to obtain a fair market price. That means that this price can be higher or lower than the price the keeper liquidates their WETH in Eth2DAI (or another exchange).
  • Liquidity: if the keeper pursues a liquidation through a decentralized exchange, they may find liquidity shortage in the ETH/DAI pair provoking a price slippage and obtaining a lower price.

There are more variables to be analyzed but these ones are sufficient proof that the keeper’s profitability does not depend only on the discount offered by the Maker contract. Some of these variables also affect the competition between keepers, as only one of them gets to BITE each CDP.

Keeper’s competition

The keeper’s business is determined by which one can “get its transaction first” into the blockchain. Keepers have multiple techniques to predict which CDPs are going to be liquidated and get their transactions confirmed on the blockchain before everyone else (we are going to consider that a CDP is liquidated in block n):

CDPs monitoring

Keepers query the Ethereum blockchain data constantly to watch for CDPs that are close to the liquidation ratio. Intuitively, we may think that the CDP is “unsafe” in the block n-1 and liquidated in the block n. But most of the time, this is not what happens.

Price Feed

Keepers also keep track of the transactions made by oracles that define the ETH/DAI price. A keeper may know that a CDP is going to be “unsafe” in the block n by watching the unconfirmed price feed transaction in the Ethereum mempool. In this case, the CDP can turn into “unsafe” in the same block that is liquidated. That depends on whether the keeper broadcasts its transaction and gets it included into the block in a superior order than the price feed transaction. If the keeper’s transaction gets included by the miner before the price feed transaction, the CDP is still collateralized, and the liquidation transaction fails.

Gas price

Keepers also compete with the gas price spent to get their transactions included in the blockchain. Given two keeper’s transactions broadcasted at the same time, one is going to fail and the other is going to succeed. Given two valid transactions, miners prioritize the one that has more gas involved.

These are some of the variables that define the competition between the keepers of MakerDAO liquidations. Keepers keep innovating the way they perform their transactions to obtain higher profits.

Opportunity size

Since December 2017, more than 64 million USD have been liquidated. It is possible to obtain granular data of each CDP liquidation price through the MakerDAO GraphQL API and the Etherscan API.

Image 2: Market value of liquidations by CDP size

The data shows that 50% of the liquidations have been of less than 55.66 USD. However, these liquidations represent less than 1% of the total market value of the liquidated CDPs. The major part of the total market value is assigned to liquidations over 16,745 USD. These liquidations represent more than 80% of the total market value.

Usually, large CDPs are not liquidated in the same way that small CDPs, such as the one we analyzed above. Most of the large CDPs are liquidated by more than one keeper. This happens because the keeper that calls the BITE function may not have enough liquidity to buy all the collateral and can only take a small part of it. So, this keeper shares the remaining collateral with other keepers.

Taking into account the historical total market value, the 3% discount awarded to the keepers represents 1,942,644 USD since December 2017. It is difficult to calculate the cost associated to each liquidation because it varies depending on the size of the CDP, the network costs, the liquidity costs, the exchange costs and the efficiency of each keeper.

Influence of ETH price and collateral locked

The ETH price is an important variable in liquidation’s occurrence. CDPs get liquidated when there is a decrease in the ETH price that puts their collateralization ratio at risk.

Image 3: ETH price and MakerDAO liquidations

In Image 3 we can observe the ETH price and the 30-day average liquidation value. It is evident the strong relation between ETH price drops and an increase in liquidations value per day. The steepest price drop was the one evidenced in the beginning of 2018. However, it did not represent the peak of daily liquidation value because there were fewer open CDPs than now.

Image 4: CDPs locked WETH market value

As more collateral is held in MakerDAO’s CDPs, there is a bigger opportunity for CDP’s liquidation given an ETH price decrease. Since June, the collateral market value has decreased due to an ETH price drop and the liquidation of CDPs (Image 4). However, the value locked in MakerDAO’s CDPs has risen exponentially since the platform’s creation.

Image 5: Monthly market value of liquidations

The increase in the amount of collateral held does not mean that CDP’s liquidation opportunities will grow proportionally. In 2019 we have seen fewer ETH price drops than in 2018 resulting in less liquidation’s volume (Image 5).

Also, due to the growth in the DeFi ecosystem, applications have been developed allowing users to monitor their open CDPs and add collateral if they are at risk. This has been done to protect users from paying the penalty fee, which is 13%.

Conclusion

As long as CDPs are liquidated the opportunity for keepers will prevail. The MakerDAO platform locked collateral has been increasing substantially in 2019. This can be explained due to the fact that CDPs can be used to take long positions on ETH/USD with margin, and the ETH price increase has encouraged that. Future price drops will open new liquidation opportunities and encourage keeper’s competition. If the liquidation volume keeps increasing, we will definitely see more professional keepers entering the market.

Also, in the near future, the incentive model for keepers will change. MakerDAO is preparing the release of the Multi-Collateral DAI CDPs in which the liquidations will not have a 3% discount. Instead, the collateral will be liquidated through auctions with a defined duration depending on the collateral auctioned. This will promote alternative techniques for keepers willing to make a profit from liquidations.

We believe the keeper’s opportunity can be extrapolated to other DeFi protocols such as Compound or Dharma. The DeFi ecosystem keeps growing and we are still in an experimental phase. The increasing volume in these protocols will open new business opportunities.

Acknowledgment: big thanks to José Baredes for helping out with the data analysis. Also, thanks to Gonzalo Balabasquer for helping me sort the technical difficulties of retrieving the data.

--

--