Market Module
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.
Market Module and Terraswap/Astroport
First (Market Module)
If you've tried to swap any native tokens on the Terra Station desktop/mobile app or on , including $LUNA, $UST, or other Terra stablecoins, you have probably noticed these two options; 'Market' and 'Terraswap' and 'Astroport and wondered how the 3 differs.
The Terraswap option will use liquidity from the AMM, which AFAIK follows the standard XYK design of Uniswap and other traditional AMMs, implemented using CosmWasm contracts the 'Market' option, which we'll be focusing on, is slightly more special.
Cosmos based chains contains 'modules' responsible for different tasks, e.g. the bank module responsible for tracking address balances
One of these modules, Market, is special to Terra and is responsible for facilitating direct on-chain swaps
But since the exchange rate used for the conversion is based on the oracle price, there is naturally a delay between the price last reported on-chain and the actual real-time price in the markets.
This delay enables an attacker to possibly extract value from the network through front-running the oracle price updates.
Third (Swap Mechanisim)
Back to the swap mechanics itself.
When a user performs a swap using the Market module, they're swapping using the aggregate of the above validator-proposed exchange rates.
This swap, while still based on the XYK formula, differs from other constant product formulas AMMs in a few ways.
First, there is no actual liquidity pools, and the swap instead employs virtual liquidity
Instead of depositing the offerCoin into the pool and taking askCoin out of the desired pool, offerCoin is sent to the module ('burnt'), and askCoin is sent from the module ('minted')
The Market's variant of the XYK formula variant then uses the fiat value of Luna instead of the size of the Luna pool
Thus, the swap rate is not directly influenced by the on-chain demand, but through how the overall token demand demand is reflected in the exchange rate
Fourth (Protection from hackers)
To protect against the above possibility, two swap fees are imposed
- Tobin Tx for spot-converting Terra <> Terra swaps (0.25%)
- Minimum Spread for Terra <> Luna swaps (2%)
On virtual pools, instead of representing Luna and each Terra stablecoins as multiple individual separate pools, the protocol instead uses only 2 virtual pools, one for Luna, and another for all denominations of Terra stables.
These pools are initialized by the BasePool parameter, which defines the initial (virtual) size of the two pools and now we get to the interesting part. A delta (𝜹) variable stored by the protocol.
Instead of directly tracking the size of the pools, the network instead stores this info in the 𝜹 variable
Specifically, 𝜹 represents the deviation of the Terra pools size from its base size
The size of the pools can then be calculated from 𝜹 using the formulas below
The replenish rate is set by the PoolRecoveryPeriod parameter, with lower period meaning lower sensitivity to trades, meaning previous trades are more quickly forgotten and the market is able to offer more liquidity.
Sixth (Spread)
Since the spread of a non Terra <> Terra swap is a function of 𝜹 (see below), the period represents how fast the virtual pool can forget the previous trade, return to the optimal/equilibrium point, and for the spread fee to drop.
Put differently, a lower PoolRecoveryPeriod means the pool is more resistant and can recover quickly from large trades.
Source :
Daily burned LUNA minted UST amount in the last 90 days
With for LUNA supply being burn for the UST, the LUNA token by means will rise due to the decrease in LUNA token supply while demand in the market remain strong. Hence, we need strong demand and adoption of UST from crypto users and entire crypto market.
The chart below showing the amount of UST being burn to LUNA in the last 90 days
The bilateral mint and burn between LUNA and UST ensure the expansion and contraction of the supply for both token. It makes the UST pegged at $1 USD all the time. With the play of supply and demand fundamentally.