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 order never keep stale values for buy asset market price #8456

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

gomesalexandre
Copy link
Contributor

Description

Buy asset market data price looks like it's a purely derived value as a product of the input buy amount and sell amount, however, it is derived from the quote buy and sell amounts.

A quote however, is RTK query data, and stale RTK query data will stil be present when:

  • fetching
  • current query is errored, but previous (stale) one was happy

This was producing odd bugs where failures in getting a CoW quote (i.e inputting too low of am amount) would return the previous stale quote, however, the previous quote was for an entirely different asset, and possibly a different precision, which will lead to amounts being off.

Fixed by zero'ing amounts out when fetching/errored.

Issue (if applicable)

closes #8414

Risk

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Low to none

Testing

  • In limit orders, try to sell a non-18 precision asset that's much higher than FOX (the default USDC -> FOX pair is perfect for that)
  • Sell high enough of an amount e.g 100 USDC
  • Then, choose another, much cheaper, and ideally non-18 precision asset (selecting FOX i.e FOX -> USDC is perfect for that)
  • Try inputting some low amount e.g the same 100 as previously (i.e 100 FOX -> USDC)
  • Notice there is no longer amounts which are totally off

Engineering

  • ^

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)
  • ^

Screenshots (if applicable)

  • develop

https://jam.dev/c/7ef95c99-ae34-4902-ac15-6302d26ef7ab

  • this diff

https://jam.dev/c/d9e4e20e-6239-43d4-afa7-4fbaab9336b4

@gomesalexandre gomesalexandre requested a review from a team as a code owner January 3, 2025 14:54
@gomesalexandre gomesalexandre changed the title fix: limit order never keep stale values for market price fix: limit order never keep stale values for buy asset market price Jan 3, 2025
Copy link
Member

@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.

Does precisely what it says on the box!

Screenshot 2025-01-06 at 13 59 39

@0xApotheosis 0xApotheosis merged commit ef9ae6c into develop Jan 6, 2025
3 checks passed
@0xApotheosis 0xApotheosis deleted the fix_limit_stale_values branch January 6, 2025 03:00
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.

Limit orders - stale and wrong precision price when switching buy/sell direction
2 participants