delvtech / hyperdrive

An automated market maker for fixed and variable yield with on-demand terms.
Apache License 2.0
31 stars 3 forks source link

FRB analysis #1132

Open wakamex opened 2 months ago

wakamex commented 2 months ago

QUESTION: what slippage would we encounter when fixing a 10k loan on a market with X liquidity?

BETTER QUESTION: What is the rule of thumb that tells us the expected slippage when fixing a loan of size X, in a market with Y liquidity.

jrhea commented 2 months ago

Question:

How much liquidity would it take to support a 10000 Dai short with a RYPS of 1%?

Solution:

Looking at the 182d Morpho USDe/DAI market we know that:

If we were to open a 1000 Dai short, the resulting fixed rate would be 8.50%. This gives us a Rate You Pay Slippage (RYPS) of 1%.

Since 10,000 is 10 times larger than 1,000, the required liquidity would also need to be 10 times larger than 25,000.

In other words, we need 250k of liquidity to support a 10k short

Question: Can we derive a function that calculates the required liquidity for a given short size (S) and timestretch (T) to maintain a rate slippage of 1?

Solution:

We know from experience with Yield Space that slippage is proportional to:

$$ \text{RYPS} = k \frac{S}{L} T $$

where k can be determined from the 182d Morpho USDe/DAI market:

$$ 1 = k \frac{1,000}{25,000} 10 $$

$$ k = 2.5 $$

Finally, we have,

$$ RYPS = 2.5 \frac{S}{L} T $$

This is directionally correct. You can plug it into the 182 steth market and see that it is typically < .25% off assuming we keep the S/LP < .2. However, it is a little weird using the timestretch apr as an independent variable. To get a more accurate result, we can do a regression analysis and switch to the timestretch definition:

$$ T=\frac{5.24592}{0.04665 * rate} $$

We mentioned earlier that T and S/LP are significant; however, the simple model we derived also convinced us that the interaction term $T * \frac{S}{LP}$ should be considered in any model attempting to predict RYSP. As a result, the regression model should have the following terms:

jrhea commented 2 months ago

Question: Given the following table, define a regression model that calculates the required liquidity for a given short size (S) and timestretch (T) to maintain a rate slippage of 1?

Market timestretch short/liquidity starting market rate rate you pay rate you pay slippage
morpho usde/dai 11.24527331 0.2 7.5 12.55 5.05
morpho usde/dai 11.24527331 0.1 7.5 9.88 2.38
morpho usde/dai 11.24527331 0.05 7.5 8.72 1.22
morpho usde/dai 11.24527331 0.04 7.5 8.5 1
morpho usde/dai 11.24527331 0.025 7.5 8.17 0.67
steth 32.12935232 0.1978785578 3.03 5.03 2
steth 32.12935232 0.1150456731 3.03 4.13 1.1
steth 32.12935232 0.02300913463 3.03 3.31 0.28
morpho susde/dai 11.24527331 0.2 6.71 11.58 4.87
morpho susde/dai 11.24527331 0.1 6.71 9.02 2.31
morpho susde/dai 11.24527331 0.05 6.71 7.89 1.18
morpho susde/dai 11.24527331 0.0414 6.71 7.71 1
morpho susde/dai 11.24527331 0.025 6.71 7.36 0.65

Solution:

$$ RYPS=−0.0408+0.0021×T+32.6468×S/LP−0.7105×(T×S/LP) $$

Question:

When opening a loan of size X, how much liquidity is needed to maintain Y RYSP?

Solution:

We can simplify the regression model above to make it easier to work with:

$$ RYPS=−0.04+33\frac{S}{LP}−0.7(T\frac{S}{LP}) $$

Solving for the LP value gives us:

$$ LP=\frac{S(33 - 0.7T)}{0.04+RYPS} $$

Let's plug in the numbers from the 182d Morpho USDe/DAI market example above:

$$ LP=\frac{10,000(33 - 0.7(11.24527331))}{0.04+1} = 241,618.352721154 $$