Terra Bounties: Market Module
Q176. Explain in your own words what Terra’s “market module” is, and how it functions. Define at least two key metrics for the market module, and demonstrate how it’s performing in its stated goals based on these metrics.
Terra is a Tendermint-based blockchain maintained by validators who follow the Tendermint delegated proof-of-stake algorithm and vote on new blocks. As LUNA as it's native token has the role of maintaining its stablecoin peg. Terra’s stablecoins follow an algorithmic market module, which means the protocol adjusts its supply automatically based on the market’s condition. The protocol is able to achieve this through open market arbitrage incentives.
Imagine 1 TerraUSD (UST) trading above the $1 peg. LUNA holders, in this case, can swap $1 worth of LUNA and sell it for 1 UST. Then, users can sell this for its equivalent dollar value and profit from the difference. In this regard, the protocol effectively decreases the supply of LUNA and increases the supply of UST, which, with enough volume, could eventually pull it back down to $1.
On the other hand, when the price of UST goes below the $1 peg, the protocol incentivizes users to burn UST in exchange for LUNA. This expands the LUNA supply and reduces UST, driving its value back to $1. The volatility in UST’s price is, therefore, absorbed through the minting and burning of LUNA tokens.
Once a brief explanation of Terra and it's basic burning/minting mechanism it is done, it is necessary to have a look into Terra core ans it's module architecture. Terra core is structured in several diferent blocks called modules, each of them has an specific function inside Terra ecosystem, in this dashboard a deep analysis of Market Module will be carried out.
The market module is where all features related to swaps between all the different stablecoins and also with Luna are explained. This module also allows liquidty, fair exchange rates between the protocol’s assets and stable prices. As explained before, Terra’s stablecoins follow an algorithmic market module in order to mantain it's peg.
To get a fully understanding of market module some concepts have to be explained:
As known, there exists a delay between the price reported on-chain and the real-time price so a real chance for front-runnig attackers is created, so they can extract the exact value from the network.
In order to try to stop this kind of attack the market module enforces the following swap fees:
-
Tobin tax: The Tobin tax is a fixed percentage fee added to any market swap between Terra stablecoin. The rate varies depending on each Terra stablecoin. When stablecoins have different Tobin tax rates, the higher tax rate will be used for the transaction. Aproximatly a rate of 0,35% is applied. It is necesaary to note that this rate is a better rate than any retail currency exchange and remittance
-
Minimum spread: Spread fees are added to any market swap between Terra and Luna. The minimum spread fee is 0.5%. During times of extreme volatility, the market module adjusts the spread fee to maintain a constant product between the size of the Terra pool and the fiat value of the Luna pool, ensuring stability in the protocol.
To ensure liquidty on the Terra stablecoins vs Luna swaps, Terra has created a constant product Market Making Algorithm. This means that only the size of the pool affects to the constant product and not changes in Luna price. In order to fully understand this concept the CP fromula is attached.
This CP creates a big advantatge, it offers “unbounded” liquidity, and swaps of any size can be serviced.
The market starts with 2 Liquidty pools, one for Luna and one for Terra stablecoins, both pools are of the same size. Then a parameter that represents the deviation of the Terra pool from its base size (Terra Pool Delta) is created. So that both pools (Luna and Terra stablecoins) can be calculated by the following equations:
The pool base parameter is refered to the initial size of both pools.
When the block ends, the market module tries to resupply the pools by decreasing the value of Terra Pool Delta between the Terra stablecoins and Luna pools. When a change in demand occurs a change in supply need to be absorbed, so this mechanism allows spread fee to drop back down.
Circulating supply can be a good metric to analyse market module and liquidty. The next chart shows the Circulating supply of LUNA, separating between liquid and staked circulating supply.
Also a interesting metric is the swap volume, in the chart below we can se the daily Luna swap volume. We can see a clear positive trend.
Market module has been explained and some metrics have been added in order to get fully understanding.
A chart regarding this delta price is shown in order to prove that this is happening
Having a look again on the chart about the delta price and the UST chart fees we can see some correlation over time as markets gaining efficiency and liquidty.
As an extra bonus the UST peg to 1$ ans UST fees is also shown.