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

refactor: decouple base fee fetching as part of quote from simulation (backport #550) #551

Closed
wants to merge 1 commit into from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 5, 2024

Several changes:

  • Pre-compute base fee by fetching it at the end of ingest via an always-enabled plugin
  • Add a query param to fetch base fee as part of quote without having to simulate
  • Makes simulation optimistic. If it fails, we propagate the error but also propagate the base fee value regardless of the success of the simulation

Ultimately, this will allow us to compute fees more precisely in a more performant way in the Polaris SQS integration while having gas estimates hardcoded.

The next big improvement would be to implement swap simulations without requiring bank sends. Documented the proposal in this chain task

Testing

  • Covered by existing tests (unit and integration)
  • Added new
  • Added API tests
  • Tested manually via swagger

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

…#550)

* refactor: return base fee in /quote regardless of simulation success.

* separate base fee from simulation. Pre-compute during ingest

* updates

* updates

* Update router/repository/memory_router_repository.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix

* separate interface

* rename

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
(cherry picked from commit fcbf7b6)

# Conflicts:
#	CHANGELOG.md
#	app/sidecar_query_server.go
#	docs/docs.go
#	docs/swagger.json
#	docs/swagger.yaml
#	domain/cosmos/tx/msg_simulator.go
#	domain/cosmos/tx/msg_simulator_test.go
#	domain/cosmos/tx/tx.go
#	domain/mocks/msg_simulator_mock.go
#	domain/mocks/quote_mock.go
#	domain/mocks/quote_simulator_mock.go
#	domain/quote_simulator.go
#	domain/router.go
#	ingest/usecase/plugins/orderbook/claimbot/config.go
#	ingest/usecase/plugins/orderbook/claimbot/export_test.go
#	ingest/usecase/plugins/orderbook/claimbot/plugin.go
#	ingest/usecase/plugins/orderbook/claimbot/tx.go
#	ingest/usecase/plugins/orderbook/claimbot/tx_test.go
#	quotesimulator/quote_simulator.go
#	quotesimulator/quote_simulator_test.go
#	router/delivery/http/router_handler.go
#	router/delivery/http/router_handler_test.go
#	router/types/get_quote_request.go
#	router/usecase/quote_out_given_in.go
#	router/usecase/routertesting/parsing/quote_amount_in_response_simulated.json
@mergify mergify bot added the conflicts label Nov 5, 2024
@mergify mergify bot assigned p0mvn Nov 5, 2024
Copy link
Contributor Author

mergify bot commented Nov 5, 2024

Cherry-pick of fcbf7b6 has failed:

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

You are currently cherry-picking commit fcbf7b6.
  (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:
	new file:   domain/base_fee.go
	modified:   domain/cosmos/tx/tx_test.go
	modified:   domain/mocks/router_usecase_mock.go
	modified:   domain/mvc/router.go
	new file:   domain/tx_fee_info.go
	new file:   ingest/usecase/plugins/basefee/base_fee_end_block_update_plugin.go
	modified:   router/repository/memory_router_repository.go
	modified:   router/usecase/router_usecase.go
	new file:   router/usecase/routertesting/parsing/quote_amount_in_response_base_fee.json

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	both modified:   CHANGELOG.md
	both modified:   app/sidecar_query_server.go
	both modified:   docs/docs.go
	both modified:   docs/swagger.json
	both modified:   docs/swagger.yaml
	deleted by us:   domain/cosmos/tx/msg_simulator.go
	deleted by us:   domain/cosmos/tx/msg_simulator_test.go
	both modified:   domain/cosmos/tx/tx.go
	deleted by us:   domain/mocks/msg_simulator_mock.go
	deleted by us:   domain/mocks/quote_mock.go
	deleted by us:   domain/mocks/quote_simulator_mock.go
	deleted by us:   domain/quote_simulator.go
	both modified:   domain/router.go
	both modified:   ingest/usecase/plugins/orderbook/claimbot/config.go
	both modified:   ingest/usecase/plugins/orderbook/claimbot/export_test.go
	both modified:   ingest/usecase/plugins/orderbook/claimbot/plugin.go
	both modified:   ingest/usecase/plugins/orderbook/claimbot/tx.go
	both modified:   ingest/usecase/plugins/orderbook/claimbot/tx_test.go
	deleted by us:   quotesimulator/quote_simulator.go
	deleted by us:   quotesimulator/quote_simulator_test.go
	both modified:   router/delivery/http/router_handler.go
	both modified:   router/delivery/http/router_handler_test.go
	both modified:   router/types/get_quote_request.go
	both modified:   router/usecase/quote_out_given_in.go
	deleted by us:   router/usecase/routertesting/parsing/quote_amount_in_response_simulated.json

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 closed this Nov 12, 2024
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