Terra blockchain core has modules, oracle and market, which characterize the functionality of Terra
- The oracle module listens to oracle votes from validators and calculate exchange rates of each token pair
- The voting procedure is composed of two step, “prevote” and “vote”
- Terra uses SALT mechanism to hide the price inside the oracle prevote so that no one can expect the final exchange rates in advance
- Validators are using different price source for calculating oracle vote prices, but the number of sources are limited and fairly publicly known
- The market module allows any Terra ecosystem participants to swap a token to another kind based on most recent available exchange rates
- There exists “Tobin Tax”(0.25%) for any market swap, and “Spread Fee”(minimum 2%) for Terra<>Luna swaps
- An arbitrage trader created roughly KRW 17.4 million in recent 2 months, taking advantage of “bumpy” SDR exchange rates
- Swap from ukrw to usdr when SDR exchange rate is under-priced
- Swap from usdr to ukrw when SDR exchange rate is over-priced
- When there exists enough frequency of SDR exchange rate swings which are wider than 2*TOBIN_TAX(0.25%), this strategy is long term profitable
- Note that the trader should pay 2*TOBIN_TAX = 0.5% per each trade round(buy&sell SDR over KRW)
- If the swing was 0.7% then the trader profits 0.7% — 0.5% = 0.2%
- The condition is enough frequency of wide SDR/KRW exchange rate swings(>0.5%) in very short time
- Then, question is, why SDR/KRW exchange rate is frequently shaking up and down?
Accumulated swap activity
A trader performed SDR-KRW swap trading for about 2 months, resulting in roughly 18 million KRW profit.
Capital utilized is around 90K SDR, and the player did almost 100 full round trips of swap trade.
We researched most recent swap trade round to understand the reason of the bumpy cross-exchange-rate of SDR/KRW
- A swap trade round explained
Above table explains that the trader found SDR expensive compared to KRW at height 209458, and immediately became cheaper at height 2090461~2090463.
Even thought the rate difference(profit rate of this round) was very small(about 0.1%) from “swap_rate_after_tax” value, actually it was much larger because the “swap_rate_after_tax” is calculated after the tobin tax 0.25%. Therefore we could guess that the swap rate for SDR/KRW was changed approximately 0.60%(0.1% + 2*0.25%) between 2090458 and 2090461
2. Votes during the trade round
Explanation of rate changes
- Note that usdr/ukrw = (usdr/uluna)/(ukrw/uluna)
- If we see the above table, the main factor of “changes” are from ukrw/uluna
- We see almost no change on “usdr/ukrw” rates
- But, we can observe that because median(usdr/uluna) changed 0.61% and median(ukrw/uluna) changed 0.14%, swap rate for usdr/ukrw changed -0.46%
- This is happening because Terra calculates median of each luna rates first, and then uses those calculated median to get each cross-rates
Suggested Solution : Alternative cross-rate computation process
- Alternative is to calculate each cross-rates from each vote, and then calculate median from calculated cross-rates
- From below example, if we apply alternative approach, the cross-rate doesn’t change at all, which is consistent result from the data because we can see that the cross-rates of each validator are not changed!
- So, in conclusion, when the state machine calculates each cross-rate, it should first calculate implied cross-rate of each validator, and then get median from those calculated implied cross-rate