Why did Terra really collapse?

Geminon
10 min readMay 14, 2022

--

The last few days have been extremely difficult in the crypto market, and especially for the supporters and users of Terra and its (formerly) stablecoin UST. Given the magnitude of the crash, which some are already calling the biggest and fastest crash in cryptocurrency history, it is now important to fully understand what went wrong to prevent it from happening again. This importance is even greater for us since our project was strongly inspired by the success of the UST as an algorithmic stablecoin, so the failure of Terra affects us more directly than it has already done to the entire crypto ecosystem.

Chronicle of a Death Foretold

First of all, understand how the Terra protocol works. From the project documentation:

The Terra protocol’s market module enables users to always trade 1 USD worth of Luna for 1 UST, and vice versa, incentivizing users to maintain the price of Terra.

Example
If 1 UST is trading at .99 USD, users can buy 1 UST for .99 USD. Users then utilize Terra Station’s market swap function to trade 1 UST for 1 USD of Luna. The swap burns 1 UST and mints 1 USD of Luna. Users profit .01 UST from the swap. This arbitrage continues, and UST is burned to mint Luna until the price of UST rises back to 1 USD.

The theory is simple: users can always go to the Terra app and exchange their UST for exactly $1 worth of Luna tokens. If this is really the case, then how is it possible that the protocol has collapsed and the UST is still trading well below $1 days later?

The answer to this question is found by trying to perform ourselves that simple arbitrage trade that the documentation explains:

At the time of the screenshot, UST was trading at 0.91 USDT, so Luna was trading at 30 against USDT (which was worth $1) and 33 against UST (which was worth 0.91). As according to the documentation of the protocol, the UST could always be exchanged for Luna with a value of 1 $ for the UST, the following arbitrage operation could be carried out:

  1. Buy on the exchange 30 UST for 27.3 USDT (at 0.91 UST/USDT)
  2. Send the 30 UST from the exchange to our private wallet, and exchange the 30 UST for 1 Luna (remember that Luna traded against the USDT at 30) in the Terra Station application. This step is the key to everything, because this is where the valuation of the UST at $1 that the documentation says is implicit: the application pays us Luna at the price that it quotes against the USDT (which is worth $1), which is equivalent to pay our UST at $1, the theoretical price it should be.
  3. We send 1 Luna back to the exchange, where we sell it for 30 USDT. Since in step 1 we bought it for 27.3 USDT, we just made a 9.9% profit.
  4. We repeat from step 1, using the 30 USDT we just got to buy 32.95 UST. Every time we do this, we put buying pressure on the UST, driving its price up and inching it back towards its $1 peg.

With a potential risk-free-profit of nearly 10% per trade, it is hard to see why the market did not flock to these arbitrage trades immediately restoring the value of the UST to $1. What happened then?

Let’s take a closer look at the screenshot above, from step 2 where we used the Terra Station app to exchange 30 UST for 1 Luna:

As we can see, the application does not pay us 1 Luna, but 0.91. That is, it does not pay us the UST at $1 as it was supposed to do according to the documentation to force the $1 peg, but at 0.91, which is the same price at which it was trading on the rest of the exchanges. How is it possible for this to happen, since the basis of the whole operation of the protocol was supposed to be that the UST could always be redeemed at $1?

Terra’s own documentation gives us clues about this in the technical specifications of the market module:

Terra uses a Constant Product market-making algorithm to ensure liquidity for Terra<>Luna swaps.

For example, start with equal pools of Terra and Luna, both worth 1000 SDR total. The size of the Terra pool is 1000 SDT, and assuming the price of Luna<>SDR is 0.5, the size of the Luna pool is 2000 Luna. A swap of 100 SDT for Luna would return around 90.91 SDR worth of Luna (≈ 181.82 Luna). The offer of 100 SDT is added to the Terra pool, and the 90.91 SDT worth of Luna are taken out of the Luna pool.

Translation: Terra’s market module is not a pure mint / burn token mechanism, but rather a variant of Uniswap’s liquidity pool. This means that the main mechanism that was supposed to guarantee the price stability of the UST had a limited capacity to do so, which depended on the available Luna liquidity, instead of being a pure mint / burn mechanism with infinite liquidity as it should in theory be to ensure that in all situations UST could be redeemed at $1.

Nick Platias’s presentation during SFBW 2019 gives more details of this implementation of the market module:

What it says there is that in reality the market module cannot always pay the UST at exactly $1 when using a liquidity pool, and that the actual price to pay varies by an amount ε (the spread). But best of all, he then admits that the spread between the theoretical redemption price of the UST and the actual price could get out of control in the event of an imbalance in pool liquidity, which is exactly what happened when the collapse of the protocol began: a wave of large sales overwhelmed the market module, unbalancing the pool’s liquidity and increasing that spread. Since the price of the UST in the market depended directly on the price provided by the market module (thanks to the arbitrage trades described above), the moment the module became unbalanced and started paying the UST below $1, it caused contagion to all exchanges, leaving the UST market price below its theoretical value. The price could no longer return to its peg value simply because the mechanism that was supposed to enforce this was not capable of doing so due to a serious design error.

Change of the invariant for the valuation of the stablecoin based on the variation of the supply of Luna in the liquidity pool of the Terra market module. (Platias, N. 2019)

This poor design of the market module with a finite capacity meant that once that capacity was reached, the price of UST remained steadily below its $1 target, which started to cause alarm among UST and Luna holders, generating a chain reaction: the dreaded “death spiral”. The more people tried to sell their UST on the market, the more it drifted away from its theoretical value, and all the market makers and arbitrageurs were working not to defend the value of $1, but to defend a value only slightly higher than what was being traded on exchanges. In addition, ordinary users could not help participating in such arbitrage either because they had no guarantee that in the time it took to send their UST from the exchange to their wallet, the spread ε of the market module would widen causing them to lose money in the operation. The protocol at this point was like an autoimmune disease, with the market module supporting the depeg from $1 rather than defending it, fighting the entire market rather than having its help to restore the price. The catastrophe was already inevitable.

It is important to note that what ultimately caused the collapse of Terra was not a one-time sell-off by one or several players, but the poor design of the market module, which was the most important piece of the protocol. If a correct implementation of the mechanism described in the documentation had been made that would always allow UST to be redeemed at exactly $1 with a mint / burn mechanism (infinite liquidity) instead of just copying the Uniswap pool (limited liquidity), the collapse of Terra would not have occurred under these circumstances as the price of UST would have been able to quickly return to its peg value and the panic spiral that eventually produced the collapse would not have started.

Summarizing

  • The actual behavior of the Terra market module that was the core of the protocol that was supposed to guarantee the stability of the UST did not correspond to what was described in the documentation, since it could not guarantee the redemption of UST at $1 under all conditions.
  • Implementing the market module as a Uniswap liquidity pool instead of a pure token mint / burn mechanism was a serious mistake, as doing so had inherently unstable and reflexive behavior.
  • What ultimately caused the collapse of Terra was that poor implementation of the core protocol, not an alleged attack by third parties or the fact that it was a purely algorithmic currency. Had it been correctly implemented, the idea might have worked.
  • The protocol was doomed from day one. It was a question of when, not if.

Geminon is not like Terra

As we said at the beginning, the Geminon protocol was heavily inspired by the success of Terra. However, it was also inspired by other protocols such as Frax, with an initial design halfway between the two, but with significant improvements over both. The most important differences between Geminon and Terra are:

  1. Our implementation of the stablecoin mint and redeem mechanism is done correctly: it is not a copy of the Uniswap liquidity pool as in Terra, but a proprietary design that allows in all conditions to redeem the stablecoin for its peg value without slippage and in unlimited amount (infinite liquidity).
  2. The Geminon protocol was designed to be collateralized from the beginning in a fully decentralized way (unlike Terra) and using purely decentralized assets (Frax uses centralized stablecoins).
  3. The stablecoins issued with the Geminon protocol do not keep the peg with the fiat currency, but with its associated inflation index. In the short term, its price is constant, but after a few months its peg value grows slowly, preserving its purchasing power.

Geminon protocol enhancements

Despite the fact that the design of our protocol did not have the serious mistakes that caused the collapse of Terra, in view of the events we have decided to implement additional measures to reinforce the robustness of the protocol against market events:

  1. Strong collateralization. Our initial design included soft collateralization of the protocol with established cryptocurrencies such as BTC, ETH, BNB, AVAX and LINK (a more detailed explanation of this choice can be found in our whitepaper) starting with 33% collateral. The reason behind this decision was that by planning to launch our project during the bear market, with valuations of these coins between 50 and 80% below their ATH, the level of collateralization would increase by itself in the future, being able to reach or exceed 100% in the next bull cycle. We have decided to move to a strong collateralization system, with a goal of 100% collateralization from the outset.
  2. Uncorrelated exogenous collateral. Another lesson learned from the collapse of Terra is that the high correlation between the different cryptocurrencies works against the protocol at times of greatest need, forcing collateral liquidations precisely when it is most undervalued. For this reason we have looked for alternatives that, being available within the chain, are not correlated. The choice of the rest of the protocols in this situation is to use other stablecoins such as USDT, USDC, DAI, etc. For our protocol this choice would not be suitable as its goal is to provide inflation-indexed stablecoins. For this reason, we have decided to use tokenized gold as part of the collateral using one of the existing providers such as Paxos. Geminon would thus become the first inflation-resistant stablecoin protocol collateralized by physical gold.
  3. Collateralization of the Geminon token. Existing collateralized stablecoin protocols have arranged collateral as a means of direct redemption of the stablecoin, exposing the stablecoin directly to fluctuations in collateral and leaving project token holders without any protection. We are going one step further, adopting a new system where both collateral and stablecoin redemptions are through the Geminon token. This simultaneously provides security to the holders of the token and the stablecoins, as well as greater stability of the price of the latter, since it is the protocol token that absorbs the volatility of the collateral. The principle of operation is similar to that of Frax, which uses a mixed fractional and algorithmic reserve, although the implementation is completely different (FXS is not backed by collateral, while in our protocol the Geminon token is).

Final note: we are finalizing the creation of the protocol MVP, and it will be available on the testnet soon. Geminon is in the seed phase, so we are seeking funding from VCs and partners for the project. Follow us on twitter and telegram to be aware of the news of the project.

--

--