Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview user actions: open/close longs, shorts, and lp #464

Closed
6 tasks
Tracked by #539
DannyDelott opened this issue Jul 15, 2023 · 4 comments · Fixed by #568
Closed
6 tasks
Tracked by #539

Preview user actions: open/close longs, shorts, and lp #464

DannyDelott opened this issue Jul 15, 2023 · 4 comments · Fixed by #568
Labels
enhancement New feature or request

Comments

@DannyDelott
Copy link
Contributor

DannyDelott commented Jul 15, 2023

Feature Request
The frontend needs a way to get quotes for common actions (openLong, closeShort) without submitting the transaction. These are the desired methods:

  • openLongPreview
  • closeLongPreview
  • openShortPreview
  • closeShortPreview
  • addLiquidityPreview
  • removeLiquidityPreview

What this solves
Lots of UX shortfalls. Today the UI is calling the existing Hyperdrive functions in view mode, however this requires allowances first. This means users are essentially having to pay before they can even see the price tag on a trade. And secondly, a view mode call will fail if you don't have enough base, bonds, or shares to get a real quote, so you can't preview large hypothetical trades.

Additional context
It's pretty much table stakes for an AMM to provide these methods on-chain. Here's how two of the largest AMMs have implemented this:

@DannyDelott
Copy link
Contributor Author

One note about openShortPreview is that it currently takes an amount of bonds to short, and returns the amount of base spent.

    function openShort(
        uint256 _bondAmount,
        uint256 _maxDeposit,
        address _destination,
        bool _asUnderlying
    )
        external
        payable
        nonReentrant
        isNotPaused
        returns (uint256 maturityTime, uint256 traderDeposit)

In the UI however, we will want the inverse of this. Users will want a quote based on the amount of base they choose to deposit.

@gtowle03
Copy link
Contributor

add the function that calculate openLong etc. to DataProvider.sol and queries that return the results. Front end should be able to specify trade size. Should call hyperdrive and add getter function

@ryangoree
Copy link
Member

ryangoree commented Jul 18, 2023

One note about openShortPreview is that it currently takes an amount of bonds to short, and returns the amount of base spent.

    function openShort(
        uint256 _bondAmount,
        uint256 _maxDeposit,
        address _destination,
        bool _asUnderlying
    )
        external
        payable
        nonReentrant
        isNotPaused
        returns (uint256 maturityTime, uint256 traderDeposit)

In the UI however, we will want the inverse of this. Users will want a quote based on the amount of base they choose to deposit.

@DannyDelott That's just the way we've added it to the UI now, but that could change. Depending on how we end up talking about shorts and longs, users could end up preferring to choose an amount of bonds to short.

@gtowle03 @jalextowle Do these changes affect audits? How easy would it be to change this later?

@DannyDelott
Copy link
Contributor Author

Discussing with @jalextowle that we'll be punting on this for now in favor of higher priority work that's emerged from audit feedback. This will be revisited later, likely prior to a public testnet release (ie: goerli).

In the meantime, we'll communicate the limitations of the UI during the trading competition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants