-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relax trade verification checks for pre-interactions (#3081)
# Description Currently the trade verification does a few checks and actions on behalf of the user that requested the quote to make the verification possible. For example if a user has ETH and no WETH but requests a quote for WETH we'd try wrap the necessary WETH before doing the fake settlement in the simulation. We also do a check before the settlement to verify that the user has the required sell token balance. That way we can return a more helpful error message than when the settlement contract reverts due to the missing funds. Both of these things could fail if the user provides pre-hooks that will only set up the necessary trade pre-conditions for the `from` address. # Changes Adjusted the simulation code such that we can control whether some reasonable pre-conditions will be set up as part of the simulation or not. If a user provides pre-conditions we now assume that they are necessary to set things up and we don't do our set up to not interfere with that. ## How to test Added an e2e test that transfers the needed sell tokens from a safe to the trader address in a pre-hook. This test fails without the change introduced in this PR. Edit: The test works locally but appears to cause issues in CI for whatever reason. :/ Edit2: It's actually an existing test that fails exactly because of the reason described 👇 While working on the test I learned about a niche edge case that currently can't be verified: If you try to get a quote for a `from` address that is a contract that will only be deployed in the pre-interaction. The reason is that before we do the simulation we check whether the `from` address is a contract. If it is a contract we use some state override magic to make our fake user during the simulation behave like the contract that was deployed at that address. But we can't know that the `from` address will contain contract code if the contract will only be deployed in the pre-interaction.
- Loading branch information
1 parent
c0b1f9e
commit c1b102a
Showing
6 changed files
with
154 additions
and
18 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters