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

Use quote id just for debugging #3054

Merged
merged 11 commits into from
Oct 17, 2024
Merged

Use quote id just for debugging #3054

merged 11 commits into from
Oct 17, 2024

Conversation

MartinquaXD
Copy link
Contributor

@MartinquaXD MartinquaXD commented Oct 11, 2024

Description

Passing the quote id during the order creation request has currently weird and not well documented behavior.
Essentially it's used to streamline fetching quotes from the DB and allows us to better link an order creation request with a quote request.
If you provide no quote id the backend computes a fresh quote in the order creation requests so this usually never fails. However, if you provide a quote id we are currently throwing errors if the referenced quote is expired or the parameters don't match.
That means passing the optional quote id (that the openapi scheme documents just as a debugging tool) can only be detrimental for the user compared to passing no id at all.

Changes

This PR makes it such that this ID is actually only used for debugging and can not introduce new error variants. That means if we can find a quote based on the order's search parameters we just use that but if we can't find it we always try to compute a fresh one. This eliminates 2 error cases (quote expired, or parameter mismatch) and makes it easier to reason about the code.

How to test

the (unit) test coverage on that logic was already pretty good so I mostly had to adjust some tests (to please the compiler) and remove a few test cases for the 2 removed error variants.

1 e2e test needed to be updated. The test relied on using the quote id to make sure the backend looks up an outdated quote while creating the order.
So previously we could:

  1. get a quote
  2. update liquidity sources
  3. create order with outdated quote id causing it to get flagged as limit / market order depending on the quote

But now we have to make sure the order would get classified as market / limit at the time of creation. Before we could use the liquidity sources as a synchronization mechanism but now that's no longer possible. As an easy (and more explicit) way around that I added a function to conveniently enable or disable a solver account to make sure no solutions get settled until we are ready.

@MartinquaXD MartinquaXD requested a review from a team as a code owner October 11, 2024 12:16
@MartinquaXD MartinquaXD marked this pull request as draft October 11, 2024 13:57
This reverts commit 68165ea6c428ec5a1646c8b5c5232cdd996576b5.
This reverts commit cf7551b76f60a8547016b09b65a463f91d9e0921.
@MartinquaXD MartinquaXD marked this pull request as ready for review October 16, 2024 12:09
Copy link
Contributor

@m-lord-renkse m-lord-renkse left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@squadgazzz squadgazzz left a comment

Choose a reason for hiding this comment

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

The QuoteStoring#get function seems no longer used. Should it be removed along with all the implementations?

Copy link
Contributor

@squadgazzz squadgazzz left a comment

Choose a reason for hiding this comment

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

LGTM

@MartinquaXD MartinquaXD enabled auto-merge (squash) October 17, 2024 14:17
@MartinquaXD MartinquaXD merged commit cea22f6 into main Oct 17, 2024
11 checks passed
@MartinquaXD MartinquaXD deleted the quote-id-just-for-debugging branch October 17, 2024 14:21
@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2024
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.

3 participants