article

xla·Nov 27th, 2022

Analysing Execution Quality in Osmosis

Update 1 - 2022-12-08: The original article released on 2022-12-06 used a dataset generated by a script which had a bug for the way sandwich attacks were counted. Originally we identified 181K sandwich attacks when the actual number is 14.8K . All numbers have been updated with the correct values. Any additions have been labeled as such.

Building on the Toxic Order Flow article, the following report summarises the findings of an execution analysis on Osmosis carried out in collaboration with Numia Data . The study aims to learn more about slippage in general and its relationship with sandwich attacks. Based on our findings we were able to identify that sandwiched transactions have on average twice as much slippage as the average transaction. In addition, we identified that sandwich attacks increase during downturn events with high sell pressure of assets like the Terra collapse.

Approach

  • We looked at the top OSMO-based pools in Osmosis between September 2021 and November 23rd, 2022
  • We used the token_swapped event which was only introduced starting in September 2021
  • We calculate slippage a posteriori as the difference in $OSMO between tokens_in * previous_trade_price minus tokens_out.
  • We looked at the top 22 $OSMO-based pools that account for more than 90% of the $OSMO volume
  • A sandwich attack in this context is identified as a sequence of trades for the same pool where:
- account_x: asset_a => asset_b
- account_y: asset_a => asset_b
- account_x: asset_b => asset_a

Finding 1: Slippage was heavily affected by the Terra collapse in May

Overall slippage is 0.34% of total volume. During May and the Terra collapse, we saw a 74% increase vs the average monthly slippage.

Finding 2: Sandwich attackers also tried to take advantage of the Terra collapse and increased the frequency of their attacks

We not only saw the expected increase in slippage but also identified a spike in the percentage of sandwich attacks relative to the number of trades. This suggests that attackers take explicit action in more vulnerable market conditions and users need more protection.

Finding 3: Sandwiched transactions have on average twice as much slippage as the average transaction

Out of 10.1M trades analyzed we saw a total of 14.8K sandwich attacks. These resulted in a total of 53.5K $OSMO in slippage.

Finding 4: 0.15% of all trades are sandwich-attacked

Finding 5: The net loss in Slippage is 27.5K $OSMO

  • If all sandwiched trades would have not been attacked they would have had a total slippage of 26K $OSMO (53.5K $OSMO / 0.70% * 0.34%)
  • Based on the total sandwiched slippage of 53.5K $OSMO, this yields a net loss of 27.5K $OSMO in toxic slippage which is now more than the total value generated for LPs (see next finding).

Finding 6: The net loss in Slippage is less than the total LP fees generated by sandwich attacks but remains still fairly low.

  • If we add up all the volume generated by all sandwich attacks we find that these have created a total of 6.7M $OSMO in volume.
  • Assuming an average fee of 0.20% for all the pools we find that the value for LPs accounts for a little over 13.4K $OSMO in income (ignoring impermanent loss).
  • Since the revenue generated for LPs (13.4K $OSMO) is lower than the net loss in sandwiched slippage (27.5K $OSMO) we could argue that overall sandwich attacks generate net negative value for the ecosystem, however, this remains fairly low and we did not exclude yet some outliers that account for high slippage. There are obviously different perspectives we can take on this and this and this type of debate we want to bring to the table.

Takeaway

Looking into the data shows a complex interplay between parties in the value chain and while clear-cut at a glance it substantiates further that the conversation of what MEV is harmful is a lot more nuanced.

Furthermore, externalities to any (not closed) system dictate the size of MEV as it exists at the intersection of varying security models. The analysis above illustrates that point quite well with the stark changes in market dynamics during two major external events.

Added 2022-12-08: Looking at the small fraction of trades which are affected by worse execution quality should make us as an ecosystem have another critical pass to update the understanding as to which kind of exploits meaningfully affect users.

We will continue our research journey - with the support from Numia Data - into the blockspace dynamics of the Interchain.

Contact us at: