[econ] dynamic `MaxAnchorSlip` calculation
The Problem
The MaxAnchorSlip
is a mimir that controls the sensitivity of the depth of the derived asset virtual pool. This sensitivity allows the virtual pool to contract in depth based on layer1 volatility, making it difficult to price manipulate the network (then open a loan) as well as create resistance in the event of a FUD event (bank run).
This mimir sets the global value, which is less than optimal. This is because the trade volume of the layer1 pools (determined by volume/depth) is variable. This causes the "resting point" of derived virtual pools to be different for different pools (lower for BTC/ETH, higher for less popular pools).
While this mimir was originally set to 6000
(60%), and that value was correct at the time, new features (like streaming swaps) change the capital efficiency of the pools and cause the derived pool to "rest" at a lower value than we'd like (causing more slippage fees in normal market conditions, which becomes friction for loans to be opened).
The Solution
The validators should set where the "resting point" of derived virtual pools should be. The recommendation from the protocol architects is 95%. Once this is established, the protocol can dynamically calculate the MaxAnchorSlip
on a per-pool basis. One important element of this is to NOT have this be too responsive to current market conditions (be resistant to change), but change when there is a sustained change in capital efficiency of any given pool (more than 1 week is the recommendation).
To calculate the MaxAnchorSlip
, each pool calculates its value once a day. It looks at the last 2 weeks of total pool slippage (every 300 blocks) and finds the median value. Then calculates the pool slippage that would result in 95% of the derived depth.
ms = median total slip (over the last two weeks, sampling every 300 blocks)
td = target depth (ie 9500 basis points, or 95%)
mbps = max basis points (static 10k)
maxAnchorSlip = (ms * mbps) / (mbps - td)