Implement new quote verification logic#4402
Open
MartinquaXD wants to merge 5 commits into
Open
Conversation
Remove Trader.sol and code_fetcher infrastructure. The new trade verifier uses Solver.sol directly (with new swap() API including trader/sellToken/ sellAmount args) and Spardose for balance measurement. Simplify Verification to carry only from, receiver, and app_data instead of token balance sources and interaction lists. Remove CachedCodeFetcher from all callers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the quote verification and simulation framework by replacing the Trader impersonation contract with direct state overrides and a simplified Spardose funding mechanism. Key updates include gas measurement logic in the Solver contract, refactoring Verification to use app_data, and optimizing Tenderly simulation parameters. A high-severity issue was identified in Solver.sol where gas measurement incorrectly subtracts cold access costs for a warm contract, leading to an underestimation of approximately 2500 gas per quote.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements a new quote verification strategy which does not rely on a helper contract deployed at the trader address for setting up the necessary preconditions (balance and approval).
Approvals are now being faked using state overrides with the helper functions introduced in previous comments.
And to transfer the necessary sell tokens to the user without acting "as the user" we adjust the
Spardoseaccount to directly transfer to the user instead ofmsg.sender.Changes
Trader.soland references in build infraSpardose::requestFundsto also take thereceiverSimulationBuilderfor setting up all the state overrides and computing the callldataverify_innerinto a couple of smaller functionsCodeFetchingas it's not needed anymoreAppDatastring insideVerification(currently gets parsed once per quote verification for simplicity sake - might make sense to change later on)How to test
tests for quote verification are still passing