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: simulate swap as part of quotes (backport #547) #549

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 4, 2024

https://osmosis-network.slack.com/archives/C079LNKRUCB/p1730651766930679

Implementing MsgSwapExactAmountIn quote estimation logic directly into SQS.

This will allow to wire SQS integration into Polaris. Ref: https://github.com/polaris-portal/polaris/pull/1011/files

Currently, in Polaris, as we get a quote, we also want to know the pricing for it.

To avoid round trips, we can have an optional query parameter to request SQS to run simulation logic immediately after estimating a quote.

Support

  • "out given in", direct (non-split) quotes
  • controlled by the optiona simulationAddress and simulationSlippageTolerance query parameters
  • backwards compatible

Testing

  • Unit tests with mock
  • Integration test

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a PriceMsgs method for improved gas estimation and fee calculation in message simulations.
    • Added a QuoteSimulator interface and a SimulateQuote method for simulating quotes in token swaps.
    • Enhanced GetQuoteRequest to handle simulation parameters, including SimulatorAddress and SlippageToleranceMultiplier.
    • Added a mock implementation of the QuoteSimulator for testing purposes.
  • Improvements

    • Updated RouterHandler to utilize the new quote simulation functionality.
    • Added a SetQuotePriceInfo method to manage quote price data effectively.
    • Enhanced server initialization to integrate the new quote simulator.
  • Bug Fixes

    • Improved error handling in the quote simulation process to ensure proper validation and responses.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced PriceMsgs method for improved gas estimation and fee calculation in message simulation.
    • Added QuoteSimulator interface and SimulateQuote method for simulating quotes with slippage tolerance.
    • Enhanced GetOptimalQuote method to support quote simulation based on a specified address and slippage tolerance.
    • New fields in GetQuoteRequest to manage simulation parameters.
    • Added optional price_info parameter to QuoteExactAmountInResponse for additional pricing details.
  • Bug Fixes

    • Adjusted error handling for quote simulation to ensure proper responses.
  • Documentation

    • Updated Swagger documentation to include new parameters for quote simulation.
  • Tests

    • Added tests for simulation slippage tolerance and updated existing tests to accommodate new parameters.

This is an automatic backport of pull request #547 done by [Mergify](https://mergify.com).

* feat: simulate swap as part of quotes

* try adding e2e test

* updates

* lint

* fix test

* swagger

* attempt fix grpc wiring

* fix e2e sim test

* updates

(cherry picked from commit f2931d8)

# Conflicts:
#	domain/cosmos/tx/msg_simulator.go
#	domain/cosmos/tx/msg_simulator_test.go
#	domain/mocks/msg_simulator_mock.go
#	domain/passthrough/passthrough_grpc_client.go
@mergify mergify bot added the conflicts label Nov 4, 2024
@mergify mergify bot assigned p0mvn Nov 4, 2024
Copy link
Contributor Author

mergify bot commented Nov 4, 2024

Cherry-pick of f2931d8 has failed:

On branch mergify/bp/v27.x/pr-547
Your branch is up to date with 'origin/v27.x'.

You are currently cherry-picking commit f2931d8.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   app/sidecar_query_server.go
	modified:   docs/docs.go
	modified:   docs/swagger.json
	modified:   docs/swagger.yaml
	modified:   domain/mocks/passthrough_grpc_client_mock.go
	new file:   domain/mocks/quote_mock.go
	new file:   domain/mocks/quote_simulator_mock.go
	modified:   domain/mocks/route_mock.go
	new file:   domain/quote_simulator.go
	modified:   domain/router.go
	modified:   ingest/usecase/plugins/orderbook/fillbot/context/block/block_context.go
	new file:   quotesimulator/quote_simulator.go
	new file:   quotesimulator/quote_simulator_test.go
	modified:   router/delivery/http/router_handler.go
	modified:   router/delivery/http/router_handler_test.go
	new file:   router/types/export_test.go
	modified:   router/types/get_quote_request.go
	modified:   router/types/get_quote_request_test.go
	modified:   router/usecase/quote_out_given_in.go
	new file:   router/usecase/routertesting/parsing/quote_amount_in_response_simulated.json
	modified:   tests/quote.py
	modified:   tests/quote_response.py
	modified:   tests/sqs_service.py
	modified:   tests/test_router_quote_out_given_in.py

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	deleted by us:   domain/cosmos/tx/msg_simulator.go
	deleted by us:   domain/cosmos/tx/msg_simulator_test.go
	deleted by us:   domain/mocks/msg_simulator_mock.go
	both modified:   domain/passthrough/passthrough_grpc_client.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@p0mvn p0mvn merged commit 829a871 into v27.x Nov 12, 2024
7 of 8 checks passed
@p0mvn p0mvn deleted the mergify/bp/v27.x/pr-547 branch November 12, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant