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(hackathon-surplus): do not show modal when too small amounts #2857

Merged

Conversation

alfetopito
Copy link
Collaborator

Summary

⚠️ Pointing to a potentially already merged branch ⚠️

Will point to the right place once ready

Fixes #2847 and #2848

Show the modal according to the rules (slightly different from the issue descriptions)

  • If FIAT surplus amount estimation available, show it if amount is > 1$
  • Otherwise, show if surplus amount > 0.1 units

Revert old behaviour for confirmation modal when surplus is not displayed

To Test

With FIAT

  1. Place order which generates > 1$ surplus
  2. Do not close confirmation modal
  • Surplus modal is displayed inside confirmation modal
  1. Repeat 1 but close the confirmation modal
  • Surplus modal is displayed as a new pop up modal
  1. Place order which generates < 1$ surplus
  2. Do not close confirmation modal
  • Surplus modal is not displayed. Instead, old (current prod) flow is used: Progress bar follow by old surplus display
  1. Repeat 4 but close the confirmation modal
  • Surplus modal is not displayed

Without FIAT

  1. Place order on goerli (or somewhere where there's no FIAT values) with surplus of > 0.1 units
  2. Do not close confirmation modal
  • Surplus modal is displayed inside confirmation modal
  1. Repeat 7 but close the confirmation modal
  • Surplus modal is displayed as a new pop up modal
  1. Place order which generates < 0.1 surplus units
  2. Do not close confirmation modal
  • Surplus modal is not displayed. Instead, old (current prod) flow is used: Progress bar follow by old surplus display
  1. Repeat 10 but close the confirmation modal
  • Surplus modal is not displayed

@vercel
Copy link

vercel bot commented Jul 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
swap-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 12, 2023 11:12am

@alfetopito alfetopito added RELEASE Included in the release that is being closed hackathon labels Jul 12, 2023
@alfetopito alfetopito self-assigned this Jul 12, 2023
@alfetopito alfetopito requested review from a team July 12, 2023 11:07
@alfetopito alfetopito changed the title Feature/surplus do not show modal when too small feat(hackathon-surplus): do not show modal when too small amounts Jul 12, 2023
): boolean | null {
if (fiatAmount) {
// When there's a fiat amount, use that to decide whether to display the modal
return Number(fiatAmount.toFixed(3)) > MIN_FIAT_SURPLUS_VALUE_MODAL
Copy link
Contributor

Choose a reason for hiding this comment

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

why converting to number? is not enough to compare directly the underling number without doing the toFixed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

toFixed returns a string.
fiatAmount is a Fraction so it cannot be directly compared with a number afaict.

See https://docs.uniswap.org/sdk/core/reference/classes/Fraction#greaterthan

Copy link
Contributor

Choose a reason for hiding this comment

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

you can compare a fraction and a fraction, 0.01 is 1/100 :P

Copy link
Contributor

Choose a reason for hiding this comment

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

anyways, merging to close the release

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, that's true...
If you mind I can create a new PR addressing this.
Let me know

if (showSurplus === false && orderId) {
removeOrderId(orderId)
}
}, [orderId, removeOrderId, showSurplus])
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to add to remove later? doesn't it make sense to not add in the queue in the first place?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The problem is, by the time we are adding it, the FIAT estimation is not available and has to be fetched/calculated.

It's a whole other can of worms to have it at that stage

Copy link
Contributor

Choose a reason for hiding this comment

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

okay, i though could be the case, NVM

@alfetopito alfetopito requested a review from anxolin July 12, 2023 12:41
if (showSurplus === false && orderId) {
removeOrderId(orderId)
}
}, [orderId, removeOrderId, showSurplus])
Copy link
Contributor

Choose a reason for hiding this comment

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

okay, i though could be the case, NVM

@anxolin anxolin merged commit 6a5fa72 into release/1.41.0 Jul 12, 2023
13 of 14 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 12, 2023
@alfetopito alfetopito deleted the feature/surplus_do-not-show-modal-when-too-small branch July 12, 2023 14:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
hackathon RELEASE Included in the release that is being closed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants