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

fix(limit-orders): update price and amounts when tokens changed #5356

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

shoom3301
Copy link
Collaborator

@shoom3301 shoom3301 commented Jan 29, 2025

Summary

Fixes https://www.notion.so/cownation/Price-is-wrong-when-change-a-token-using-token-selector-1858da5f04ca802c99e1caa36375b7d5

This problem more likely comes from #4668 fix. At least I can reproduce it on prod now.
In useUpdateActiveRate() we have a logic which depends on isRateFromUrl flag.
Mainly, it serves for keeping amounts static after coming from another trade widget.
But we should not prevent amounts and price update when we change tokens.
So, we reset isRateFromUrl flag when at least one of the tokens is changed.

To Test

  1. Open swap widget in Sepolia, setup selling WETH to USDC
  2. Go to limit orders
  3. Change one of the tokens. You can do it in 3 ways: a) using token selector b) switching tokens places c) changing tokens in URL
  • AR: you will see >999% after "is worth"
  • ER: price and amounts are recalculated correctly

@shoom3301 shoom3301 requested review from a team January 29, 2025 14:39
@shoom3301 shoom3301 self-assigned this Jan 29, 2025
Copy link

vercel bot commented Jan 29, 2025

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

Name Status Preview Updated (UTC)
cowfi ✅ Ready (Inspect) Visit Preview Jan 29, 2025 5:00pm
explorer-dev ✅ Ready (Inspect) Visit Preview Jan 29, 2025 5:00pm
swap-dev ✅ Ready (Inspect) Visit Preview Jan 29, 2025 5:00pm
3 Skipped Deployments
Name Status Preview Updated (UTC)
cosmos ⬜️ Ignored (Inspect) Visit Preview Jan 29, 2025 5:00pm
sdk-tools ⬜️ Ignored (Inspect) Visit Preview Jan 29, 2025 5:00pm
widget-configurator ⬜️ Ignored (Inspect) Visit Preview Jan 29, 2025 5:00pm

Copy link
Collaborator

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Amazing fix.

@shoom3301 shoom3301 merged commit 753e5b0 into feat/limit-ui-upgrade Feb 4, 2025
12 of 13 checks passed
@shoom3301 shoom3301 deleted the fix/limit-price-recalculation-fix branch February 4, 2025 04:40
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants