Summary

Because TWAP inherently lags behind the spot price, it is helpful to understand the potential financial loss, and look into mitigations and tradeoffs.

In particular, it may be useful to quantify the over-valuation of MKR due to TWAP lagging behind the spot price using past swap data. [1][2]

It is shown that on average a 1 hour TWAP over-values MKR compared to spot price by 0.5% but 10% in the worst case. Noticing the worst case and that there is no limiting of loss in the current kiln implementation, I will give more specifics and approaches to mitigate loss.

Hopefully, this article and the iPython notebook linked below, as well as other linked resources, are helpful to quantify the impact of the TWAP oracle lagging the spot price.

Method

  1. Gathered and derived price data from swaps
    1. Executed in the UNIv3 MKR-ETH 0.3% pool
    2. Dates: 2022-08-15 to 2022-11-15
  2. Computed the average and worst TWAP deviation, specifically TWAP overvaluing the sell token, by comparing the differences between:
    1. 1 hour TWAP
    2. 1 minute TWAP
    3. Pool spot price

Findings

Histogram of 1 hour TWAP deviation from the pool’s spot price (negative values excluded)

Histogram of 1 hour TWAP deviation from the pool’s spot price (negative values excluded)

3934676 observations over 2022-08-15 to 2022-11-15

mean          0.0048
std           0.0058
min           0.0000
25%           0.0013
50%           0.0030
75%           0.0062
max           0.1054

Untitled

50 trials

mean     8941.3001
std      2156.6957
min      3892.8330
25%      7433.8469
50%      8841.7192
75%     10514.1229
max     15499.7326