Skip to content

Baseline solver accurate tx gas estimation#4302

Draft
m-sz wants to merge 82 commits intomainfrom
tx-gas-simulation
Draft

Baseline solver accurate tx gas estimation#4302
m-sz wants to merge 82 commits intomainfrom
tx-gas-simulation

Conversation

@m-sz
Copy link
Copy Markdown
Contributor

@m-sz m-sz commented Mar 31, 2026

Description

The baseline solver does not estimate the gas used by the solution accurately. It is fine-ish for basic swaps but in case of sell=buy swaps, which are inherently hook gas heavy the provided quotes do not account for the costs.

Having the simulator crate and taking inspiration from already existing order simulation endpoint, an accurate method of estimating solution gas usage can be utilized.

Changes

  • Added pre and post interactions to the solver's domain Order struct
  • Added optional gas-simulation node URL to the solver
  • Used the simulated gas when computing a solution

How to test

Unit tests, E2E tests and test staging deployment

m-sz and others added 30 commits March 12, 2026 18:02
Contact and Token addresses now are private structs containing Address.
Implemented Deref for them and updated usages.
Contact and Token addresses now are private structs containing Address.
Implemented Deref for them and updated usages.
Adds dependency on simulator for solver
These can be added as post-processing step at the callsite.

Reverted invalid contracts changes
Addressed comments
Co-authored-by: José Duarte <duarte.gmj@gmail.com>
m-sz and others added 26 commits March 20, 2026 17:53
Removed unecessary tracing call and cleand up From conversion
Co-authored-by: José Duarte <duarte.gmj@gmail.com>
It makes more sense from the perspective of simulation and trade encoding
since the sell tokens are always transferred into settlement contract
and the buy tokens are always withdrawn from it.

From the perspective of trade verification, the in and out amounts make
sense since they are calculated based on the provided price query.
Trade verification logic encodes a trade that is the most disadvantageous
while not affecting the outcome of the simulation (if it reverts)

For simple order simulation this is not necessary.
@github-actions
Copy link
Copy Markdown

Reminder: Please consider backward compatibility when modifying the API specification.
If breaking changes are unavoidable, ensure:

  • You explicitly pointed out breaking changes.
  • You communicate the changes to affected teams (at least Frontend team and SAFE team).
  • You provide proper versioning and migration mechanisms.

Caused by:

@m-sz m-sz changed the base branch from main to simulation-endpoint March 31, 2026 16:11
@m-sz m-sz changed the title Move common eth domain types to separate crate Baseline solver accurate tx gas estimation Mar 31, 2026
Base automatically changed from simulation-endpoint to main April 1, 2026 17:12
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.

1 participant