Skip to content

Unified order simulation logic #4006

@MartinquaXD

Description

@MartinquaXD

Background

Being able to simulate what would happen if an order were to be executed is very useful. This can tell us for example if an EIP 1271 is currently valid or would revert besides other things.
Over the time this logic was built multiple times with varying degrees of accuracy. With the latest advancements in our balance override logic (#3937) it should be possible to solve this once and for all.
The idea is very simple:
Take ALL the information of an order (wrappers, flashloan, pre-/post-interactions, signed order data) and encode a settle() call settling only that order at the limit price. In order to not have the call revert when paying out the buy_token (in the absence of a solver provided routing interactions) the call needs to be simulated with state overrides giving the settlement contract the necessary buy_token (using the aforementioned balance override logic).

This e2e simulation will essentially make sure everything but the solver's routing logic works:

  • wrapper / flashloan router setup
  • pre-/post-hooks
  • EIP 1271 signature validity
  • sell token transfer (balance, allowance)
  • buy token transfer

So far this will only give us a binary answer: all is good or something is broken. In order to find out what something is it would also be useful to have the ability to generate a tenderly link for failing calls. This can be further improved by generating a execution report (similar to how the quote verification logic tracks certain token balances throughout the execution of the settlement) but this would be a separate issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions