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(SQS): custom quote query #7001

Merged
merged 4 commits into from
Dec 6, 2023
Merged

feat(SQS): custom quote query #7001

merged 4 commits into from
Dec 6, 2023

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Dec 5, 2023

Closes: #XXX

What is the purpose of the change

There are cases where it might be desired to specify a specific query path for quoting. This is especially useful for debugging.

As a result, such query is exposed.

It takes a list of pool IDs. If there is a route that mathes these pool IDs, such route is quotes. Otherwise, an error is returned.

Example:

curl "localhost:9092/custom-quote?tokenIn=5000000uosmo&tokenOutDenom=uion&poolIDs=2" | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   305  100   305    0     0    309      0 --:--:-- --:--:-- --:--:--   309
{
  "amount_in": {
    "denom": "uosmo",
    "amount": "5000000"
  },
  "amount_out": "8714",
  "route": [
    {
      "pools": [
        {
          "id": 2,
          "type": 0,
          "balances": [],
          "spread_factor": "0.005000000000000000",
          "token_out_denom": "uion",
          "taker_fee": "0.001000000000000000"
        }
      ],
      "out_amount": "8714",
      "in_amount": "5000000"
    }
  ],
  "effective_fee": "0.006000000000000000"
}

Testing and Verifying

Go test added with uion/uosmo

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes?
  • Changelog entry added to Unreleased section of CHANGELOG.md?

Where is the change documented?

  • Specification (x/{module}/README.md)
  • Osmosis documentation site
  • Code comments?
  • N/A

@p0mvn p0mvn added V:state/compatible/backport State machine compatible PR, should be backported A:no-changelog A:backport/v20.x backport patches to v20.x branch A:backport/v21.x backport patches to v21.x branch C:app-wiring Changes to the app folder and removed C:app-wiring Changes to the app folder A:backport/v20.x backport patches to v20.x branch labels Dec 5, 2023
@p0mvn p0mvn closed this Dec 5, 2023
@p0mvn p0mvn reopened this Dec 5, 2023
@p0mvn p0mvn marked this pull request as ready for review December 5, 2023 07:17
Comment on lines +118 to +121
// Skip routes that do not match the pool length.
if len(routePools) != len(poolIDs) {
continue
}
Copy link
Member

Choose a reason for hiding this comment

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

consider in the future adding length to GetRoutesFromCandidates to prevent having to iterate over them again here

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm note sure what recommendation is exactly. We would have to iterate anyways since we want to make sure each pool's ID matches the id of the given list of pool IDs in the same order

Copy link
Member Author

Choose a reason for hiding this comment

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

Will not be blocking on this, please lmk if any follow-ups are needed

@p0mvn p0mvn merged commit 8214a60 into main Dec 6, 2023
1 check passed
@p0mvn p0mvn deleted the roman/custom-quote-sqs branch December 6, 2023 04:59
mergify bot pushed a commit that referenced this pull request Dec 6, 2023
* feat(SQS): custom quote query

* lint

* add test for ParseNumbers

(cherry picked from commit 8214a60)
mergify bot pushed a commit that referenced this pull request Dec 6, 2023
* feat(SQS): custom quote query

* lint

* add test for ParseNumbers

(cherry picked from commit 8214a60)
p0mvn added a commit that referenced this pull request Dec 6, 2023
* feat(SQS): custom quote query

* lint

* add test for ParseNumbers

(cherry picked from commit 8214a60)

Co-authored-by: Roman <roman@osmosis.team>
p0mvn added a commit that referenced this pull request Dec 6, 2023
* feat(SQS): custom quote query (#7001)

* feat(SQS): custom quote query

* lint

* add test for ParseNumbers

(cherry picked from commit 8214a60)

* fix

---------

Co-authored-by: Roman <roman@osmosis.team>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v20.x backport patches to v20.x branch A:backport/v21.x backport patches to v21.x branch A:no-changelog V:state/compatible/backport State machine compatible PR, should be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants