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.

    db_img

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

    With Constant Product, we define a value CP set to the size of the Terra pool multiplied by a set fiat value of Luna, and ensure our market-maker maintains it as invariant during any swaps through adjusting the spread.

    CP = TerraPool * LunaPool * LunaPrice / SDRPrice

    Virtual Liquidity Pools The market starts out with two liquidity pools of equal sizes, one representing Terra (all denominations) and another representing Luna, initialiazed by the parameter BasePool, which defines the initial size of the Terra and Luna liquidity pools.

    In practice, rather than keeping track of the sizes of the two pools, the information is encoded in a number delta, which the blockchain stores as TerraPoolDelta, representing the deviation of the Terra pool from its base size in units µSDR.

    The size of the Terra and Luna liquidity pools can be generated from using the following formulas:

    TerraPool = BasePool + delta

    LunaPool * LunaPice / SDRPrice = (BasePool * BasePool) / TerraPool

    LunaPool = (SDRPrice / LunaPrice) * (BasePool * BasePool) / TerraPool

    At the end of each block, the market module will attempt to "replenish" the pools by decreasing the magnitude of between the Terra and Luna pools. The rate at which the pools will be replenished toward equilibrium is set by the parameter PoolRecoveryPeriod, with lower periods meaning lower sensitivity to trades, meaning previous trades are more quickly forgotten and the market is able to offer more liquidity.

    This mechanism ensures liquidity and acts as a sort of low-pass filter, allowing for the spread fee (which is a function of TerraPoolDelta) to drop back down when there is a change in demand, hence necessary change in supply which needs to be absorbed.

    Swap Procedure

    Market module receives MsgSwap message and performs basic validation checks

    Calculate ask and spread using k.ComputeSwap()

    Update TerraPoolDelta with k.ApplySwapToPool()

    Transfer OfferCoin from account to module using supply.SendCoinsFromAccountToModule()

    Burn offered coins, with supply.BurnCoins().

    Let fee = spread * ask, this is the spread fee.

    Mint ask - fee coins of AskDenom with supply.MintCoins(). This implicitly applies the spread fee as the fee coins are burned.

    Send newly minted coins to trader with supply.SendCoinsFromModuleToAccount()

    Emit swap event to publicize swap and record spread fee

    If the trader's Account has insufficient balance to execute the swap, the swap transaction fails.

    Upon successful completion of Terra<>Luna swaps, a portion of the coins to be credited to the user's account is withheld as the spread fee.

    Prior to the Columbus-5 upgrade last year, seigniorage was directed to a community pool to foster more adoption during expansions. Now, all seigniorage are burned, simplifying the economic design of Terra where minting 1 UST means burning $1 worth of LUNA. All fees are also rerouted to staking rewards for LUNA, making staking more attractive as a long-term commitment.

    an increase in the volume of transactions and an increase in the price would mean an increase in demand for stablecoins. It would be necessary to mint and introduce the stablecoin in the market, generating an expansion in the UST supply so that the price does not deviate from its peg. When the UST price rises to $ 1.10, the arbitrageur will have incentives to burn LUNA to mint UST and sell it on the market, increasing the supply and, therefore, lowering the price to the desired target.

    When UST is minted, LUNA is burned. So, the UST demand promotes the burning of LUNA, reducing the supply and, thus, making it more scarce and valuable. Therefore, the constant minting of UST could create a deflationary cycle for LUNA’s value. Hence the difference with other stablecoins, LUNA is designed to capture value.

    FCD and LCD on the Terra Blockchain

    The Full Client Deamon (FCD) and the Light Client Deamon (LCD) are REST-based adapters to the Remote Procedure Call (RPC) endpoints and are used for decoding the Amino-encoded blockchain data into parseable JSON.

    The LCD is a “light” client while the FCD isn’t as it pulls data from the LCD to its own database. When using the LCD or FCD, we are basically connecting to a Terra node so that we can broadcast our transaction or query.

    Delta neutral

    Delta neutral is a portfolio strategy utilizing multiple positions with balancing positive and negative deltas so that the overall delta of the assets in question totals zero.” (Source: Investopedia) Essentially, you create a delta-neutral position by betting on and against the same thing at the same time.

    db_img

    Once the delta-neutral position is fully established, you will earn yield from 3 venues — savings interests from Anchor Earn, the short-farm yield from Mirror, and long-farm yield from either Mirror or Spectrum.

    The risks

    Liquidation Risks

    Deviation from Delta-neutral

    Price Fluctuation of the Reward Tokens

    Here you can see the fluctuations on March 15th:

    Loading...