delvtech / hyperdrive

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

Timestretch Analysis #835

Closed jrhea closed 3 months ago

jrhea commented 5 months ago

With the DSR moving from 5% to 15%, we need to decide how to configure this yield source. We don't want to do anything cute like configure it to 5% and initialize it to 15%.

1) factory would prevent this 2) spearbit found an issue that leads to insolvency if this were to be allowed. a fix was applied, but we should still keep this in mind: https://github.com/spearbit-audits/review-element-february/issues/51

Things to consider: 1) how long do we expect the DSR to stay at 15%? This will require a time stretch that allows for more slippage. 2) if the DSR were to move back down to 5%, how much would LPs lose? 3) how much volume could the pool support at a 15% slippage? 4) if the pool was configured with a time stretch of 5%, then the variable moves to 15% - would the pool support this? What would happen to available liquidity as the shorts that pushed the rate to 15% mature. In other words, lets plot idle liquidity and share adjustment 5) Re-run fuzz tests configured for 15%

wakamex commented 5 months ago

after some rigorous economic analysis I have determined the next sDai rate move will be lower image

wakamex commented 5 months ago

rule of thumb for LP loss: your_loss_as_a_percentage = Δrate * arb_trade_size / liquidity let's verify that empirically

intuition:

wakamex commented 5 months ago

checks out image

formula

effective_spot_price = trade.base_proceeds / trade.bond_amount
effective_interest_rate = (1 - effective_spot_price) / effective_spot_price
arb_return = variable_rate - effective_interest_rate
lp_return = variable_rate - arb_return * arb_base_proceeds / lp_liquidity
wakamex commented 5 months ago

should we: pinch off this issue with #s 1-2 and start a new issue with the remaining questions, along with some new ones like:

or just change the deadline to something like Apr. 5?

@jrhea do you mean comparing sDai vs. Uniswap or LPing in an sDai Hyperdrive pool vs. Uniswap?

remaining for #2: summarize impact of low initialization at 5% going to high rates vs. high initialization at 15% going to low rates

summarizing remaining #s:

  1. measure market depth in general, and apply it to different pool states (low init w/ high rates, high init w/ low rates) to see if this captures negative pool outcomes
  2. what happens to liquidity as arbs mature (idle liquidity, share adjustment, market depth)
  3. do you mean our broader fuzz tests? or just the above metrics?
jrhea commented 3 months ago

Ask @jalextowle about the min share reserves for dai and steth and update @wakamex's rule of thumb analysis:

Rule of thumb for estimating a timestretch APR's reasonable rate discovery: ts_apr *4. For example, if ts_apr=5% then price discovery is smooth (linear) until ~20%.

jalextowle commented 3 months ago

The minimum share reserves is 10e18 for DAI and 1e15 for ETH

wakamex commented 3 months ago

Using those minimums works (10e18 for DAI and 1e15 for ETH), with the following recommendations: time stretch of 5% works well for rates up to 15-20% even with low liquidity time stretch of 10% works well for rates up to 40% even with low liquidity time stretch of 20% works well for rates up to 80-100% even with low liquidity I'd probably still want to re-run some analysis for some instances, but this should cover the majority of cases