There already are some resources to learn about the DJED algorithmic, crypto-backed stablecoin system:
- The original paper by some IOG people: https://iohk.io/en/research/library/papers/djed-a-formally-verified-crypto-backed-pegged-algorithmic-stablecoin/
- An IOG blogpost based on that: https://iohk.io/en/blog/posts/2021/08/18/djed-implementing-algorithmic-stablecoins-for-proven-price-stability/
- The FAQ by COTI: https://cotinetwork.medium.com/djed-frequently-asked-questions-f636735be76
In order to show (and see myself) how different movements of the ADA price and operations in the DJED system play out, I am constructing a toy example in the following. (I do not consider the different kinds of fees – see https://medium.com/cotinetwork/everything-you-need-to-know-about-djeds-fees-413ac2c6a55f – in this example.)
The operations that are possible – minting and burning DJED (the stablecoin) and SHEN (the reservecoin) – are shown in this graphic from the FAQ:
In our example, we start at an exchange rate of 0.5 USD/ADA or 2 ADA/USD – close to the current exchange rate. This means that people could mint DJED for 2 ADA/DJED, but this is not allowed at the beginning, since the reserve is empty and after minting the DJED we would be way below the minimal reserve ratio of 400% (exactly at 100%).
First, some people have to mint SHEN and put enough ADA into the reserve. (This would also be disallowed, because the reserve ratio would be ∞ after that, but in the paper – and hopefully in the implementation – there is an exception that minting SHEN is also allowed below a certain number of DJED in circulation to allow bootstrapping the system.) The initial price of SHEN is set to 1 ADA/SHEN. So, some of our example people buy/mint 600 SHEN for 600 ADA (worth 300 USD currently).
After that, some other example people can buy/mint 100 DJED for 200 ADA (worth 100 USD). After this we have 800 ADA (worth 400 USD) in the reserve. For the 100 DJED in circulation at the current exchange rate of 2 ADA/DJED, 200 ADA (worth 100 USD) are needed as liabilities. The reserve ratio is 800 ADA/200 ADA=400%. The remaining 600 ADA (worth 300 USD) in the reserve are equity divided among the 600 SHEN in circulation leading to 1 ADA/SHEN (worth 0.5 USD/SHEN).
If ADA now goes up to 0.71 USD/ADA, we have 1.4 ADA/USD. At this exchange rate, only 140 ADA (worth 100 USD) are needed as liabilities for the 100 DJED. The reserve ratio goes up to 800 ADA/140 ADA=571% (only because of the changed exchange rate without any transactions done). And now there are 660 ADA (worth 471 USD) left as equity for the 600 SHEN in circulation. So, the rate for SHEN goes to 1.1 ADA/SHEN (worth 0.79 USD/SHEN).
If you expect ADA to go up, holding SHEN will give you an additional boost. You will get more ADA back in addition to the ADA being worth more USD.
For our example, a few more people buy/mint 200 SHEN at this price, paying 220 ADA into the reserve. The reserve then has 1020 ADA (worth 729 USD), with still 140 ADA needed as liabilities and, hence, a reserve ratio of 1020 ADA/140 ADA=729% (getting close to the 800% maximum). The equity is now 880 ADA (worth 629 USD) for 800 SHEN in circulation, leading to the SHEN rate staying at 1.1 ADA/SHEN (worth 0.79 USD/SHEN).
If ADA now sky-rockets to 5 USD/ADA, 0.2 ADA/USD, the reserve of 1020 ADA is worth 5100 USD. We only need 20 ADA (worth 100 USD) for liabilities, anymore, and the reserve ratio goes to 1020 ADA/20 ADA=5100%. We have 1000 ADA (worth 5000 USD) as equity for 800 SHEN, leading to 1.25 ADA/SHEN (worth 6.25 USD/SHEN). Buying/minting SHEN is not allowed, because the reserve ratio is way above the maximum, but SHEN holders can sell/burn SHEN to take some of their profits and people can mint DJED to secure values at this high exchange rate.
If people buy/mint 400 additional DJED, they have to put 80 ADA into the reserve at the current exchange rate. We then have 1100 ADA (worth 5500 USD) in the reserve, 100 ADA (worth 500 USD) are needed as liabilities for the now 500 DJED, reserve ratio is at 1100%. 1000 ADA are still equity for 800 SHEN in circulation and the SHEN side of things stays at 1.25 ADA/SHEN (worth 6.25 USD/SHEN).
If SHEN holders now decide to sell/burn 560 SHEN, getting 700 ADA (worth 3500 USD) for it, there are 400 ADA (worth 2000 USD) left in the reserve. The reserve ratio goes down to the minimum of 400 ADA/100 ADA=400%. Equity is 300 ADA for 240 SHEN, which again lets the SHEN rate stay at 1.25 ADA/SHEN.
Interestingly, if ADA now loses only a bit of value, we go below the 400% minimum reserve ratio and buying/minting DJED and selling/burning SHEN is not allowed anymore. Even if SHEN holders are not allowed to sell, we can still calculate the value of the SHEN at falling ADA price:
- At 3.676 USD/ADA, 0.272 ADA/USD:
136 ADA liabilities, 294% reserve ratio, 264 ADA equity, 1.1 ADA/SHEN, 4.04 USD/SHEN
- At 3.125 USD/ADA, 0.32 ADA/USD:
160 ADA liabilities, 250% reserve ratio, 240 ADA equity, 1 ADA/SHEN, 3.125 USD/SHEN
- At 1.721 USD/ADA, 0.581 ADA/USD:
290 ADA liabilities, 138% reserve ratio, 110 ADA equity, 0.456 ADA/SHEN, 0.79 USD/SHEN
- At 1.55 USD/ADA, 0.645 ADA/USD:
323 ADA liabilities, 124% reserve ratio, 77 ADA equity, 0.323 ADA/SHEN, 0.5 USD/SHEN
- At 1.25 USD/ADA, 0.8 ADA/USD:
400 ADA liabilities, 100% reserve ratio, 0 ADA equity, 0 ADA/SHEN, 0 USD/SHEN
So, because of the trades done at the peak of the exchange rate, the SHEN rates that our example SHEN holders had on the way up are reached at much higher ADA rates on the way down. They will be in the loss zone quite fast.
Below 1.25 USD/ADA (which are 25% of the value it had, when we last had 400% reserve ratio), the system will start to depeg. DJED holders will not be able to get the full equivalent of 1 USD in ADA for 1 DJED, anymore.
There are several ways to regain the peg:
- The ADA exchange rate simply goes up again.
- DJED holders sell/burn DJED despite the depeg.
- People buy/mint SHEN.
For the last point: The SHEN rate never really goes to zero. The minimal price for SHEN is a protocol parameter that will be set to 0.001 ADA/SHEN according to https://medium.com/cotinetwork/everything-you-need-to-know-about-djeds-fees-413ac2c6a55f. So, people get SHEN really cheap, but not for nothing, in this depeg scenario. This will, however, distribute the equity also to these new SHEN holders on the way up again, which makes it still tougher for our old SHEN holders from the first way up.
I’m quite curious, how this will play out in reality through a real bull-bear-cycle.