Skip to content

Implement new quote verification logic#4402

Open
MartinquaXD wants to merge 5 commits into
approval-overridesfrom
new-quote-verification-logic
Open

Implement new quote verification logic#4402
MartinquaXD wants to merge 5 commits into
approval-overridesfrom
new-quote-verification-logic

Conversation

@MartinquaXD
Copy link
Copy Markdown
Contributor

@MartinquaXD MartinquaXD commented May 11, 2026

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 Spardose account to directly transfer to the user instead of msg.sender.

Changes

  • removed now unused Trader.sol and references in build infra
  • adjust Spardose::requestFunds to also take the receiver
  • more accurate gas cost computation
    • copy to calldata to memory OUTSIDE of the metered section
    • setup trade pre-condition OUTSIDE of the metered section
    • account for 21K initial tx cost and calldata cost
  • re-generate changed crates
  • use new SimulationBuilder for setting up all the state overrides and computing the callldata
  • split verify_inner into a couple of smaller functions
  • deleted CodeFetching as it's not needed anymore
  • pass full AppData string inside Verification (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

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>
@MartinquaXD MartinquaXD requested a review from a team as a code owner May 11, 2026 16:03
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread contracts/solidity/Solver.sol Outdated
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