Proposal to decrease minspread of Terra <> Luna swaps

Proposal to decrease minspread of Terra <> Luna swaps

  • Terra research
  • September 2nd, 2020

TLDR

  • Propose to change minspread value of Terra <> Luna swaps from 2% to 0.5%
  • By decreasing minspread value, we expect there will be more Luna to be burned after Col-4 update

Background

As Luna listed to major global exchanges, the liquidity of luna increased dramatically. As the liquidity increased, the short term volatility of Luna decreased compared to the past. The minspread value of Terra <> Luna swaps was first introduced to avoid front-running attack of terra blockchain. But, this minspread value also became a major hurdle for Terra’s stability as it determines the price range of Terra. Because, if the Terra’s price is currently in the price rage of ±2% from peg, there are no reason to be arbitrage to be executed. As the Luna’s liquidity increased, now I suggest to decrease minspread value based on the on-chain data. By changing the minspread value, we expect there will be more Luna to be burned after Columbus-4 update.

Front-running Attacks

Before getting into the details of data analysis, lets dig into types of front-running attacks.
There are several ways for Front-running terra oracle. To distinguish each attack, there are two standard.

  1. Trade types : On-chain swap, Off-chain exchanges
  2. What is a final denom for profit realization : Luna, Terra

First, we can distinguish Front-running attack by trade types. The front-running attack can be performed with only on-chain swaps or can be performed with on-chain swap and off-chain exchange trades. Second, we can use final denom of profit realization to distinguish Front-running.

On-chain swap only Off-chain exchanges
Terra(fiat) A B
Luna C D

As we describe above section, we have four types of Front-running attacks.

Attack ‘A’
Attack ‘A’ is a Front-running attack performed with on-chain swaps and its objective is to increase the numbers of Terra token. During the vote period N, attacker watch votes for N+1 period and if the (oracle_price(N+1) - oracle_price(N))/oracle_price(N) > 2 * minspread, attacker swap Terra to Luna. And during the N+1 period, attacker swap Luna to Terra to finalize the trade. This kind of attack happens when the Luna price increases fast.

Attack ‘B’
Attack ‘B’ is a Front-running attack performed with both on-chain swaps and off-chain exchanges and its objective is to increase numbers Terra token. It can be performed if the exchange’s Luna price is bigger than the oracle price. An attacker can sell Luna on the exchange and use on-chain swap to buy Luna at the same time. By doing this, the actual fiat/terra stablecoin of Attacker increases. But, as this attack has some hard condition for execution and there will be a price risk for the attacker. We will not consider this attack for calculating spread.

Attack ‘C’
Attack ‘C’ is a Front-running attack performed with on-chain swaps and its objective is to increase numbers of Luna token. During the vote period N, attacker watch votes for N+1 period and if the |(oracle_price(N+1) - oracle_price(N))/oracle_price(N)| < 2 * minspread attacker swap Luna to Terra. And during the N+1 period, attacker swap Terra to Luna to finalize the trade. This attack happens when the Luna price falls fast.

Attack ‘D’
Attack ‘D is a Front-running attack preformed with both on-chain swaps and off-chain exchanges and its objective are to increase the numbers of Luna token. It can be performed if the exchange’s Luna price is lower than the oracle price. An attacker can buy Luna at the exchange while swapping Luna into Terra. By doing this, the numbers of Luna that attacker has increased. But, as this attack has some hard conditions for execution and there will be a price risk for the attacker. We will not consider this attack for calculating spread.

As I described above, the most serious attack that we have to consider this attack ‘A’, as this attack is easy to execute

Methodology

  • Calculate deviation using oracle price
  • Calculate the P value that the current minspread value covers
  • Set several P value to calculate the minspread

To calculate the new minspread value, we will first consider an attack ‘A’ which means use positive variance between two continuous historical oracle price to calculate the new minspread value. Secondly, we will use negative variance between two continuous historical oracle price to calculate the new minspread value.

For calculation, we use 393844 real oracle price sample from the terra blockchain. The time period of this sample was from 2020/03/18 to 2020/08/18.

P value %
0.9 0.04748
0.99 0.3052
0.999 0.83933
0.9995 1.07522
0.9999 1.84935
0.99995 2.46879
0.99999 4.40761
P value %
0.1 -0.04712
0.01 -0.31546
0.001 -0.92167
0.0001 -2.10752
0.00005 -2.69777
0.00001 -5.28036

As we have constant product algorithm to prevent massive swap, We suggest to use the 0.9995 P value to set a new minspread for Luna <> Terra Swap as we have another safety, which is base_pool. As front-running needs two trade to finalize, We propose to use 0.5% as minspread value.

By decreasing minspread value to 0.5%, we expect more Luna to be burn after Col-4 update as smart contract enables various application using Terra stablecoin.

1 Like

Sorry can you explain how the frontrunning is affected by your suggestion? It’s not entirely clear to me whether frontrunning is currently more profitable or after your change. Can you explain the significance of the P value? How is it calculated and how does it affect frontrunning or the spread?

Before understanding your arguments, I am against this proposal as it would lead to far more LUNA dilution and therefore to less buying pressure of LUNA from the market. In fact I would even vote to increase the spread from Terra into LUNA for exactly that reason. People should use their staking rewards to buy LUNA on exchanges to reduce the circulating supply, but instead most of them swap inside the station because they either don’t have access to the needed exchanges or they misunderstand the station swap.

It would be good if you could present arguments on why you think a reduction of that spread would be a good idea for the ecosystem, so far I haven’t seen any.

On another note: Would it be possible to have different fees depending on which side the transaction goes? For example Terra > Luna should be expensive, but Luna > Terra could be cheap.

The objective of Terra <> Luna swaps are to stabilize Terra’s price. By lowering the minspread value, we can set more small price range for Terra. The front-running attack from Terra <> Luna swaps are not executed since Sep, 19. And 0.9995 P value represents the 0.05% of total sample. It is really small number and consider that we are using constant-product algorithm to prevent massive swaps, we think this minspread can help on stabilizing Terra’s price while safe from the front-running itself.

The Terra <> Luna arbitrage is a key for seigniorage but as the Luna’s liquidity is not great at the past, it is almost impossible to encourage Terra <> Luna swap for stability because of big minspread value. By decreasing the minspread value, we assume that the stability mechanism can actively work to burn more luna through the Terra <> Luna swaps as the Terra’s demand increased through our expected DeFi apps(including Anchor) and we think that this can add much more value than worrying about inflation. I think the idea of charging different minspread depends on the direction of swap is pretty interesting, but, as the Terra <> Luna swaps are designed for the terra’s stability, different minspread value might cause different possible price range of Terra.

Anyway, Thank you very much for your valuable questions and suggestions. Hope that this can answer your questions.

1 Like

Yes, this explains it better, but its not entirely clear to me whether there is actually a need for this.

The peg seems to hold pretty good, or can you provide specific examples where the peg didn’t hold good enough? How does the oracle deviation feed back into the pegs of the respective Terra currencies? How do we know the deviations have been caused by the swap spread and not by other activity?

I appreciate that you guys spend a lot of time on modelling these things and have such a detailed view on things, but you also need to explain things a bit more to let the average user comprehend whats going on here. Otherwise how do you expect anyone to vote in good conscience on these things?

The reason behind current price of Terra is that currently, there’s no demand for Terra except Chai, that’s the reason why the terra’s peg looks pretty good, but if we launch Col-4 and create several different applications, we are sure that this peg will not last long.

The Oracle deviation is to give you guys that how much new minspread is safe from Front-running, its not related to the peg directly. Deviation is the difference between the N vote-period an N+1 vote-period of on-chain Oracle price itself, the swap activity cannot affects the oracle price as the oracle price only determined by the validator’s vote.

Thanks for the questions, as you mention, I think our conversation will help average user’s understanding this proposal.