Why Is DAI Stable?

Published time

source: https://makerdao.com/en/dai source: https://makerdao.com/en/dai

Why Stable Coins Matter#

Last year, a part of my salary was paid with ether. It made sense for both my client and me because it was easy and cost-efficient. As you may know, the market price of ether plummeted last year, and as a lazy person who didn’t bother exchanging it immediately with fiat money, I lost a fair amount of money. It was around that time of the bear market that I first seriously looked into stable coins. How wonderful is it if cryptocurrencies protect us from downward fluctuations without going through a tedious process of exchanging volatile cryptocurrencies with fiat money?

The volatility of cryptocurrencies might be a good feature for investors, but a bug for others. Stable coins enable us to use cryptocurrencies other than speculative purposes. Immigrants can remit their earning to their family back home and the family can save it without worrying about the price change. International workers, shop owners or customers don’t have to worry about the price change when they pay or get paid with cryptocurrencies for goods and services. Moreover, the long-term stability enables other essential financial functions such as loans and credit. People don’t want to take out the loan in something volatile. Why would I borrow 1 bitcoin today if it could be worth twice as much next month? Now I owe a lot more money than I borrowed. Conversely, why would I lend out 1 bitcoin today if it could be worth half as much next month? Now I lost money just by lending it out. Furthermore, as we build more smart contract-based systems, stability becomes a critical part of the system. For example, token issuers of DAICO system don’t want to see their ETH lose its value by half when they withdraw it, and Dapps users don’t want to use volatile currencies.

There are different implementations of stable coins, and in this post, I focus on DAI(the stable coin by MakerDAO.) I will start by talking about the basic idea of MakerDAO and how to stabilize the price of DAI. If you follow along, you will be able to issue and manage your first DAI through smart contracts.

Soft-Pegged Coin#

In short, DAI is a decentralized stable coin on Ethereum that is soft-pegged to USD. The value of DAI deviates a bit but it will go back to 1 USD over time.

You may say it would be difficult to control the price once people start to trade coins in the open market. I was thinking about the same thing especially because there is no central entity like the central bank that controls the supply and the demand for money. But it turned out that MakerDAO system can stabilize DAI by nudging the human behavior in the market with well-designed incentives.

In fact, DAI has been working well so far. The beauty of stable coins is that they cannot fake their legitimacy: just look at the price change. Last year, Ethereum plummeted from $1400 to $90.

But DAI fluctuated slightly around $1.

Sure, they fluctuate a little bit, but this is much more stable than other cryptocurrencies that fluctuate as much as 25% in a day.

The Crypto-Collateralized Model#

So how does MakerDAO soft-peg the price of DAI to $1? MakerDAO falls in the crypto-collateralized model among other models. DAI is backed by valuable crypto assets that are sitting in smart contracts on the Ethereum blockchain and is essentially available to buy back DAI. It’s like the blockchain version of gold standard where all the money were backed by gold so that you have redeemability. Unlike central banks, MakerDAO system doesn’t print money out of thin air.

Collateral doesn’t guarantee the stability of DAI by itself, but this is the core part of the MakerDAO system.

Collateralized Debt Position (CDP)#

In the crypto-collateralize model, you generate DAI by locking crypto collateral on smart contracts. In MakerDAO, the smart contracts are called Collateralized Debt Position or CDP in short, and this is the only way DAI comes into circulation: the CDP is the engine of supply.

Precisely speaking, you make a loan with the smart contracts to issue DAI. In other words, you can borrow DAI by locking up your ETH in the smart contracts as collateral. You own your collateral, but the collateral is locked behind debt and you can only retrieve the collateral out of the system again by paying back the debt.

Think of it as like a mortgage where you’re using your house as collateral from a bank to take out a loan. You go to the bank and say here’s the claim on my house and then a bank teller will give you an amount that you can borrow based on the value of your collateral. Only then you can borrow some money from a bank. You still own your house but the bank has a lien on it.

Why would you create DAI when you can just buy it on exchanges? Or what’s the point of borrowing in the first place if you have to lock ether as collateral?

This is because you believe ETH will appreciate in value, and you want to hold onto it, but you also want to use that value to do something else. e.g. pay for something or investment.

You can even do leverage investment. You lock up your ETH in a CDP, borrow DAI against it, use the DAI to buy more ETH on an exchange(e.g. Eth2Dai), and then use that ETH to further increase the size of your CDP. And then you repeat. With MakerDAO, you can take loans at some annual interest(you can check the latest rate here). This can be accomplished without any third-party or centralized authority allowing you to do so - margin trading can be accomplished entirely on the blockchain.

You might still be thinking that the incentive is not strong enough, but roughly 2% of the entire ETH supply is already locked in the MakerDAO credit system.

To sum up, the CDP is the permissionless credit system that allows anyone to lock their ETH up as collateral and borrow DAI against them. Again, this is the only way that DAI comes into existence, and in this way, every DAI is backed by a corresponding piece of ETH.

Open the CDP, Deposit ETH, and Generate DAI DEMO#

Now, we’ll go over the process of generating DAI so that we can get a more intuitive understanding. We’ll walk through the simplest scenario in which you create DAI for yourself.

Go to this website:

Since you will be making some transactions to create some DAI, you need a wallet. You can choose either MetaMask, Ledger Nano S or Trezor:

I will go for MetaMask for the sake of demonstration. Unlock your MetaMask(you can choose either Kovan testnet or Mainnet) and accept the request from MakerDAO.

You will be directed to this page below. At the left, you will see the information about your CDP once it’s created. At the top right, you can see the information about your MetaMask: your balance of ETH, DAI and MKR(the governance token). Below that, you can see the price information. They are taken from exchanges except DAI/USD price. PETH is a collateral token for single-collateral DAI. When depositing ETH into a CDP, it first gets converted into PETH (Pooled ETH). At the bottom, you have information about CDP, and you will understand what this means by the end of this demo. You might feel intimidated by terminologies here, but don’t worry too much about them as the goal of this demo is to intuitively understand how to create your CDP and issue DAI.

Click on the OPEN CDP button. Now you should see this page:

You can choose

  1. how much ETH you want to deposit as a collateral at the left input field and
  2. how much DAI you would like to borrow at the right input field

You need to meet the minimum amount required, which is currently 0.006 ETH. Ignore the information at the bottom left. I will explain them later.

Now you can input the amount of DAI you would like to borrow, and you need to think about the collateralization ratio. The collateralization ratio is the ratio between the value of the collateral deposited in your CDP and how much DAI you have generated from it. In this case, it is the ETH vs. DAI ratio.

collateral / debt // collateral ($) divided by debt ($)

I will elaborate the reason later but the ratio must be at least more than 150% and it is strongly encouraged that the ratio is more than 200%. If you look at the Global CDP Collateralization number at the bottom right, you can see that people have more than 300% of collateralization ratio in average.

Once you input ETH and DAI data that meet the requirements, click on the COLLATERALIZE AND GENERATE DAI button. Then finalize and create CDP.

Confirm your transaction on MetaMask.

*If the transaction doesn’t go through, you can speed up the transaction from MetaMask.

Then you wait for a while.

You might have noticed that your gas price was quite high. This is because there are multiple transactions happening behind the scene. There is a proxy contract that enables users to atomically carry out multiple transactions such as opening a CDP, locking collateral and generating DAI.

This is also why it takes some time. But if you wait for a while, then… tada!

Now you can see the dashboard, and you can see that you have ETH deposited in CDP, and DAI is generated in your wallet. You can think of CDP as your individual account on top of MakerDAO.

If you were curious, check your transaction on MetaMask. Now that you understand how DAI comes into circulation, I will explain how MakerDAO stabilizes this DAI in the market.

Stability Mechanism#

We looked at how DAI comes into circulation and why people would do that so far. Now I would like to explain how to make DAI stable.

There are five levels in stability mechanism, and we will go over them one by one.

  1. Over-Collateralization
  2. Automatic Liquidations of Risky CDPs
  3. The Supply Control Through Financial Incentives
  4. MKR Dilution
  5. Emergency Shutdown

Over-Collateralization#

It’s critical to avoid under-collateralization where users cannot pay back their debt to avoid insolvency. Imagine what will happen to the price if people are told that there is no backing up.

To this end, you cannot have more debt than your collateral. This is a common practice in a financial system, and also true in MakerDAO system. This means active CDPs should always be collateralized in excess: the value of the collateral is higher than the value of the debt.

MakerDAO system goes one step further. The ratio must be at least more than 150% and it is strongly encouraged that the ratio is more than 200%. Let’s say you have $100 worth of ETH. Some people might think they can generate 100 DAI, but as you’ve seen in the demo, you cannot generate more than 75(150%), and you are encouraged to issue only 50(200%).

This is how they grapple with the risk of collateral volatility. If the value of ETH goes down, the collateralization ratio goes down, and this can be a problem because there might not be enough collateral to cover the value of DAI. If we were 100% collateralized and ETH dropped even $0.01 the DAI created would be under-collateralized. Over-collateralization is one of the main stability mechanisms that ensure the integrity of DAI with a buffer.

Over-collateralization also helps the system to save time when their smart contracts liquidate the ETH while still being over-collateralized, and we will see how liquidation works next.

Automatic Liquidations of Risky CDPs#

What happens if the value of the collateral falls below a certain minimum threshold(150%)? This is where automatic liquidations come along.

In the liquidation process, the value of your debt(DAI), the stability fee and the liquidation penalty are subtracted from your collateral value. And you receive the value of the leftover collateral.

This means you will have DAI you have at your hands and ETH after the stability fee, the liquidation penalty and the value of debt are subtracted.

The stability fee is like the interest rate you have to pay to the bank. The stability fee will be charged every time pay back your debt. So you will be charged when you pack back some DAI, close CDP entirely and at the event of the automatic liquidations of risky CDPs. The stability fee can be paid both with MKR or DAI now(behind the scene, DAI will be converted into MKR and the stability fee will be paid with MKR). It is subject to change through the governance process and you can check the latest rate here. It continuously accrues on the debt over time.

The liquidation penalty exists to punish users for not managing their CDP well, and it will help the system to prevent people from issuing DAI without enough collateral. As of today(June 2, 2019), Liquidation Penalty is 13%.

In single-collateral DAI(the current system of MakerDAO), the Liquidity Providing Contract will be in charge of the liquidation process. The contract set the collateral(PETH) for sale, and keepers(they constantly keep a constant watch for CDPs that become unsafe) can atomically purchase it in exchange with DAI. The sale price is determined by the Oracle feeds with a discount(oracles give you the price feed outside of the blockchain). This discount incentivizes keepers for a quick recapitalization of the system. All DAI paid this way are immediately removed from the DAI supply, until an amount equal to the CDP debt has been removed. This means enough collateral is seized to cover its debt.

Precisely speaking, the actual formula to calculate your leftover looks like below, but you can skip this for now.

(Collateral \* Oracle Price \* PETH/ETH Ratio) — (Liquidation Penalty \* Debt) — (Stability Fee \* Debt) — Debt = (Remaining Collateral \* Oracle Price) DAI

If this doesn’t make much sense yet, don’t worry. Keep reading for now. Just keep in mind that 150% is the lowest point at which a CDP can avoid being liquidated. Again, it is strongly encouraged to stay well above that minimum level in anticipation of market volatility. You can see the live information about liquidations here.

DEMO#

To avoid under-collateralization, it’s critical to manage the health of your CDP well. As long as you monitor your CDP and make sure that the value of the locked up ETH is always more than 150% of the DAI that you have generated, your CDP won’t be liquidated. You also want to make sure that you have sufficient liquid assets available that can be used to top up your position, or assets you can sell for DAI to pay down your debt.

If the value of the collateral comes too close to 150%, you can either pay back some DAI or deposit more ETH as collateral. We will go over them one by one.

Pay Back DAI#

Go to the CDP dashboard again. Click on PAYBACK button in DAI position section. Then a new section will slide in at the right of your screen.

Set up how much DAI you want to pay back, choose Pay stability fee with DAI. Liquidation price is the ETH/USD price at which your collateral will be liquidated. So if ETH price goes below the liquidation price, your CDP will be liquidated. You can see that the liquidation price will go down after the payment. You will also see that your collateralization ratio will go up after this payment.

Click on PAYBACK.

Choose Confirm in the pop-up screen of MetaMask, and wait for confirmations. You can see it on Etherscan(mine as an example). They are using a proxy contract here as well.

Now you can see that your DAI was paid back. Your liquidation price went down and the collateralization went up.

Deposit ETH#

Next, click on DEPOSIT button in ETH collateral section. Then a new section will slide in at the right of your screen.

Set up how much ETH you want to deposit.

Click on DEPOSIT.

Choose Confirm in the pop-up screen of MetaMask, and wait for confirmations. You can see it on Etherscan(mine as an example). Again, they are using a proxy contract here.

Now you can see that your ETH was deposited. Your liquidation price went down and the collateralization went up.

The Supply Control Through Financial Incentives#

This mechanism is about nudging people’s market behavior through incentives to control the supply of DAI. There are two components to this mechanism.

Arbitrage Between the Contract Price and the Market Price#

First, arbitrageurs can arbitrage the contract price and the market price.

When you create a new CDP, you can generate DAI, but you can also just buy DAI in the open market. So when does it make sense to generate DAI from CDP and when is it rational buy DAI in the open market?

If in the market DAI is in the short supply, the value might be slightly higher than a dollar. Let’s look at an example. Let’s say the market price was below before you locked in your ETH:

USD: 100 DAI: 95

Then you would want to borrow DAI from CDP because their smart contract always assumes that 1DAI = 1USD: you can get 100DAI with $100 worth of ETH when in the market you can get only 95DAI. Once you make more loans, you could trade DAI in an open market and gain some capital. This is essentially free money.

You are financially incentivized to make more loans if 1DAI is more than 1USD(This is actually another reason why you want to create CDP.) Then the contracts issue more tokens, which pull the price down to 1 dollar due to a larger supply.

Conversely, if in the market there is oversupply of DAI, the value might be slightly lower than a dollar:

USD: 100 DAI: 105

Then you want to buy DAI in the open market, and you can use that DAI to pay off your debt in your CDP. Why? Because you can get 105DAI with $100 worth of ETH.

It is cheaper to buy in the open market and use that DAI to pay back the loan if 1DAI is less than 1USD. When you pay back your loan, the smart contracts burn the DAI and then give ETH back to you, which means the price is pushed up to 1 dollar due to a shorter supply.

The key here is the difference between the contract price and the market price. Participants in the DAI ecosystem are either incentivized to make more loans or pay back their loans depending on the gap between the contract price and the market price. You can see that there are two forces at play: pull the price down or push the price up. If 1DAI is more than 1USD, people are incentivized to lock ETH and issue/get more DAI, which pulls down the price of DAI. If 1DAI is less than 1 USD, they are incentivized to pay back the loan and burn DAI, which pushes up the price of DAI.

Adjustment of the Stability Fee#

The second component of this supply control mechanism is the adjustment of a stability fee. The stability fee can be adjusted by MKR holders responding to the dynamic price of DAI.

An increase in the stability fee results in a higher cost of borrowing for CDP users, thus dampening the DAI supply by making CDP usage less attractive. Conversely, a decrease in the stability fee (cost of borrowing) will incentivize the additional creation of DAI, acting as a policy tool to tweak supply growth.

You can see that MakerDAO beautifully designed the game-theoretical model with the price gap and the stability fee adjustment.

MKR Dilution#

The next stability mechanism is MKR dilution. We discussed about the automatic liquidation as a way to avoid under-collateralization before. However, even if there were the automatic liquidation, at the time when they sell collateral off, the value might significantly drop and then the collateralization ratio might go below 100%.

MKR, the governance token in MakerDAO, is used to cover the unpaid debt here. The MKR gives its holders the rights to vote for risk parameters such as debt ceiling, liquidation ratio, stability fee, or liquidation penalty. The MKR holders are incentivized to do well to stabilize the price of DAI. When automatic liquidation fails, it’s hard to say that they are doing a good job. So when the automatic liquidation fails, the system generates more MKR tokens, sell it on the market to cover for the gap that was not covered by the collateral liquidation. This means MKR value depreciate in value. This is why MKR holders are incentivized to keep the system well.

Emergency Shutdown#

All right! Finally, we came to the last stability mechanism. Emergency shutdown(formerly known as Global Settlement). This is the last resort that hopefully never has to be used. It literally shuts down the system at the event of insane market volatility, security breaches or system upgrades.

The emergency oracles chosen by MKR holders trigger the emergency shutdown function. This freezes the system at its last known safe state. CDP creation/manipulation is frozen and the Price Feeds is also frozen at a fixed value. The Price Feeds is the ETH/USD rate obtained by a price oracle. At this frozen rate, your DAI can be redeemed for ETH in your CDPs. Now, this doesn’t mean MakerDAO stops operating completely. They redeploy the system and migrate to it. Although the migration process of your CDPs has to be done manually at the moment, MakerDAO team is planning to make it almost automatic where your CDPs will be migrated from one system to another.

That’s all for the stability mechanism.

As I wanted to focus solely on the stabilization mechanism, I didn’t mention much about their smart contracts, the governance, multi-collateral DAI system and all the other details here. This post might have led to more questions, but that’s fine because learning start from a question! If you want to dig deeper, I suggest that you take a look at this list that aggregated useful resources to help you learn more about the system.

Also, stay tuned as I am planning to write about other aspects of MakerDAO in upcoming posts. :) Thanks for reading!