delvtech / hyperdrive-frontend

A monorepo of apps and packages for the Hyperdrive AMM.
https://hyperdrive.box
GNU Affero General Public License v3.0
9 stars 1 forks source link

Estimated market impact #284

Closed jalextowle closed 1 month ago

jalextowle commented 11 months ago

Is your feature request related to a problem? Please describe. I'm always frustrated when I open a long to see that it pushed the rate further down than I expected. I guess I'm really frustrated by the fact that I don't know what the ending rate will be and I have to guess (using "frustrated" since it's a user story).

Describe the solution you'd like I'd like to see the estimated market rate and the impact on the market (i.e. how much did the rate change). Seeing this compared to my slippage tolerance would be a good way to estimate revert likelihood and is generally a nice feature.

Describe alternatives you've considered Slippage tolerances do serve a similar purpose. We could also show similar impact estimations for the spot price.

With MEV in mind, we may have to be more sophisticated to give users a realistic estimation of impact. If MEV bots always bring users trades to the minOutput, the minOutput would be a more reasonable guess than the simulation. My guess is that reality will be somewhere in between, but it's a real question.

Additional Context In the trading competition, I opened a large short at 1.47% because I thought I was seizing a great opportunity. The variable rate is 5%, and my short brought the rate to 16%. With this in mind, I made a terrible trade, but there was nothing that showed me that I was making a bad decision. Even with slippage tolerance, it would be nice to see an estimated impact so that I can set reasonable expectations.

jackburrus commented 11 months ago

Given what we have today on the FE, is this calculation possible? ie. Open Long currently only returns the number of open bonds you get back. Can it also include the rate impact? If not, how could we calculate this on the frontend?

DannyDelott commented 11 months ago

If the new Preview contract can include the new bondReserves and shareReserves, then this can be done easily with the feature proposed here: https://github.com/delvtech/hyperdrive/issues/464

ryangoree commented 11 months ago

@jalextowle Can we implement this in the SDK?