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.
- Trade types : On-chain swap, Off-chain exchanges
- 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.
