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

feat: warn against high price impact at confirm step #5032

Merged

Conversation

gomesalexandre
Copy link
Contributor

@gomesalexandre gomesalexandre commented Aug 4, 2023

Description

Now that we have custom slippage under flag, we can implement #4858, since users may input custom slippage up to 30%, effectively having a maximum downside of 30% on the trade itself (excluding fees, which are separate from the trade value and are typically paid in addition to it for most swappers).

Disregard this. This is only implemented for price impact (the fiat difference between what you're selling and what you're getting), discusses this one out with @reallybeard and confirmed having slippage under the same umbrella would be all sorts of weird.

Pull Request Type

  • 🐛 Bug fix (Non-breaking Change: Fixes an issue)
  • 🛠️ Chore (Non-breaking Change: Doc updates, pkg upgrades, typos, etc..)
  • 💅 New Feature (Breaking/Non-breaking Change)

Issue (if applicable)

closes #4858

Risk

This may show when it shouldn't, test accordingly

Testing

  • Try an unfavorable trade e.g UTXO to ETH with THOR and the smallest amount you can swap (e.g 100 DOGE to ETH, might be more like 200 at the time you're testing this)
  • Note, we don't properly handle minimums and balance checks after the multi-hop refactor (Swapper balance check is broken  #5011) so you'll see weird negative values until we get that fixed, if you're under the minimum or the quote fails for any reason related to your balance
  • Ensure the price impact is reflected with a confirm window
  • Disregard me ~~With the custom slippage flag on, add custom slippage e.g 9% (which is lower than the 10% minimum heuristics to display the confirm window), and ensure that the unfavorable downside (~60% at the time of testing) takes precedence over the custom slippage~~
  • Disregard me Repeat the above with a favorable trade (e.g ERC-20 -> ERC-20 on Gnosis) and high custom slippage, ensuring the high custom slippage is reflected with a confirmed window, not the price impact downside (which should be very low, closeish to 0)

Engineering

Operations

Screenshots (if applicable)

  • High price impact
image
  • Disregard me High slippage taking precedence over low price impact
image
  • Disregard me High price impact taking precedence over low slippage
image
  • Disregard meHigh slippage
Screenshot 2023-08-04 at 13 52 44

Copy link
Contributor Author

gomesalexandre commented Aug 4, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@gomesalexandre gomesalexandre changed the title feat: handle high price impact/slippage at confirm step feat: warn against high price impact/slippage at confirm step Aug 4, 2023
@gomesalexandre gomesalexandre marked this pull request as ready for review August 4, 2023 12:10
@gomesalexandre gomesalexandre requested a review from a team as a code owner August 4, 2023 12:10
@gomesalexandre gomesalexandre changed the title feat: warn against high price impact/slippage at confirm step feat: warn against high price impact at confirm step Aug 4, 2023
@gomesalexandre gomesalexandre force-pushed the feat_handle_window_confirm_high_price_impact_slippage branch from 62bf9cd to 4c89583 Compare August 4, 2023 18:38
Copy link
Contributor

@0xApotheosis 0xApotheosis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and working as described, though my only concerns are more from a product perspective.

The price impact percentage constant calculated in this PR includes the buy asset protocol fee in the receive amount, which is unrelated to price impacts caused by illiquid pools.

@shapeshift/product thoughts?

src/state/slices/tradeQuoteSlice/selectors.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@0xApotheosis 0xApotheosis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See testing notes at the bottom of the stack (#5033).

@0xApotheosis 0xApotheosis merged commit 1f01ebc into develop Aug 9, 2023
3 checks passed
@0xApotheosis 0xApotheosis deleted the feat_handle_window_confirm_high_price_impact_slippage branch August 9, 2023 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display an additional warning if price impact is greater than 10% and user attempts to trade anyway
3 participants