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: spot prices display edge cases #5311

Merged
merged 1 commit into from
Jan 20, 2025
Merged

Conversation

alfetopito
Copy link
Collaborator

Summary

Fix issue when sometimes spot/market prices are not loaded

To Test

  1. Load the app in the Safe https://app.safe.global/apps/open?safe=sep:0x8FAb71C0d4272698A3B2d1F3Ed5FC3c1B9b3E531
  2. Check limit orders
  • Market prices should load
    image

@alfetopito alfetopito self-assigned this Jan 20, 2025
Copy link

vercel bot commented Jan 20, 2025

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

Name Status Preview Updated (UTC)
cowfi ✅ Ready (Inspect) Visit Preview Jan 20, 2025 11:42am
explorer-dev ✅ Ready (Inspect) Visit Preview Jan 20, 2025 11:42am
swap-dev ✅ Ready (Inspect) Visit Preview Jan 20, 2025 11:42am
3 Skipped Deployments
Name Status Preview Updated (UTC)
cosmos ⬜️ Ignored (Inspect) Visit Preview Jan 20, 2025 11:42am
sdk-tools ⬜️ Ignored (Inspect) Visit Preview Jan 20, 2025 11:42am
widget-configurator ⬜️ Ignored (Inspect) Visit Preview Jan 20, 2025 11:42am

@alfetopito alfetopito force-pushed the fix/spot-prices-again branch from 6ea2d80 to 9bb7b67 Compare January 20, 2025 11:37
@alfetopito alfetopito changed the base branch from feat/limit-ui-upgrade-2 to develop January 20, 2025 11:38
Copy link
Contributor

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

Thanks!

@shoom3301 shoom3301 merged commit 3c02245 into develop Jan 20, 2025
12 of 13 checks passed
@shoom3301 shoom3301 deleted the fix/spot-prices-again branch January 20, 2025 11:45
@github-actions github-actions bot locked and limited conversation to collaborators Jan 20, 2025
Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

What was the issue? I can see the operation is more compact, but the old code reads correct to me. Are we not handling something we should in inputFraction.divide(outputFraction)?

@alfetopito
Copy link
Collaborator Author

What was the issue? I can see the operation is more compact, but the old code reads correct to me. Are we not handling something we should in inputFraction.divide(outputFraction)?

In some cases, the fraction ended up with huge numbers, without needing to.
For some reason it was not reducing it to the smaller numerator/denominators.

For example: 100000/200000 is equivalent to 1/2, but the fraction representation was using 100000 instead of 1 (but with lot more zeros in the real case).
Using directly price.asFraction seems to be enough to make it work as expected.

See https://docs.uniswap.org/sdk/core/reference/classes/Fraction and https://github.com/Uniswap/sdk-core/blob/9997e88/src/entities/fractions/fraction.ts#L154

Although, that's a good question.

@elena-zh did that work for tokens with different decimals? Keep in mind USDC on Sepolia has 18.

@elena-zh
Copy link
Contributor

elena-zh commented Jan 20, 2025

What was the issue? I can see the operation is more compact, but the old code reads correct to me. Are we not handling something we should in inputFraction.divide(outputFraction)?

In some cases, the fraction ended up with huge numbers, without needing to. For some reason it was not reducing it to the smaller numerator/denominators.

For example: 100000/200000 is equivalent to 1/2, but the fraction representation was using 100000 instead of 1 (but with lot more zeros in the real case). Using directly price.asFraction seems to be enough to make it work as expected.

See https://docs.uniswap.org/sdk/core/reference/classes/Fraction and https://github.com/Uniswap/sdk-core/blob/9997e88/src/entities/fractions/fraction.ts#L154

Although, that's a good question.

@elena-zh did that work for tokens with different decimals? Keep in mind USDC on Sepolia has 18.

@alfetopito
Oh no!!!
I did not know that I needed to do this specific test here: I've just checked that the app is not crashed :(
Prices for tokens with different decimals do not look good in this PR:
image
image

Opened this task to address it

@alfetopito
Copy link
Collaborator Author

New attempt to fix it at #5317

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants