Skip to content

Align priceQuality implementation with API docs - #4805

Open
fleupold wants to merge 2 commits into
mainfrom
optimal_quotes_without_verification
Open

Align priceQuality implementation with API docs#4805
fleupold wants to merge 2 commits into
mainfrom
optimal_quotes_without_verification

Conversation

@fleupold

Copy link
Copy Markdown
Contributor

Description

The API docs state that "optimal" quotes should only care about the out amount, without attempting or taking verification into account. However, the current logic uses the same behavior for optimal and verified quotes. This PR changes this.

Note, that verification can still be turned off server side by setting verification-mode unverified.

Streamed quotes continue to use the verified quoting logic (as per docs)

Changes

  • Separate optimal and verified quoter (the former not having any verification configured) in the quote
  • Route requests to the respective quoter
  • Update documentation to be more explicit
  • Small refactor on pre-cached estimator entries (fast vs. optimal now becomes verified vs. unverified)

How to test

Adjusted e2e test

@fleupold
fleupold requested a review from a team as a code owner August 26, 2026 15:48
@fleupold
fleupold requested a review from MartinquaXD August 26, 2026 15:48
@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:

@claude

claude Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Claude finished @fleupold's task in 3m 33s —— View job


PR Review: Align priceQuality implementation with API docs

  • Load pr-review skill
  • Gather context (diff, related code)
  • Analyze changes
  • Post review

The change is well-structured and correctly implements the documented split between optimal (best price, no simulation) and verified (simulated + preferring verified quotes). I traced the wiring end-to-end and it holds up:

  • factory.rs — the verified/unverified entry rename is accurate: unverified is the raw instrumented estimator, verified wraps it in the trade verifier (falling back to unverified when none is configured). unverified_price_estimator correctly omits .with_verification(...), so the CompetitionEstimator defaults to QuoteVerificationMode::Unverified (no simulation, no preference for verified quotes) — exactly the intended "optimal" behavior. Estimator entries stay cached in the HashMap, so no extra driver load is introduced.
  • run.rs — order creation (order_validator) and streaming both correctly route to verified_quoter, preserving prior behavior for those paths; only the one-shot optimal path now uses the unverified quoter.
  • quoter.rs — routing per PriceQuality is correct, and the default verified_quoter field falling back to the base quoter (when the builder isn't called) is sensible.
  • model/quote.rs — moving #[default] from Optimal to Verified keeps default request behavior effectively unchanged, since the old default (Optimal) previously behaved as verified.

One maintainability note (inline): the price_estimation_drivers mapping block is now duplicated three times in run.rs — worth extracting into a single binding.

No correctness issues found. The behavior change for clients explicitly requesting optimal (previously simulated, now not) is intentional and already called out in the PR description / the compatibility bot comment.
· optimal_quotes_without_verification

Comment on lines +380 to +396
let unverified_price_estimator = price_estimator_factory
.unverified_price_estimator(
&config
.order_quoting
.price_estimation_drivers
.iter()
.map(
|price_estimator_driver| configs::native_price_estimators::ExternalSolver {
name: price_estimator_driver.name.clone(),
url: price_estimator_driver.url.clone(),
},
)
.collect::<Vec<_>>(),
native_price_estimator.clone(),
gas_price_estimator.clone(),
)
.unwrap();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This price_estimation_drivers.iter().map(...).collect() block is now repeated three times verbatim (here plus the price_estimator and fast_price_estimator calls above). Consider extracting it into a small local binding once, e.g.:

let price_estimation_solvers: Vec<_> = config
    .order_quoting
    .price_estimation_drivers
    .iter()
    .map(|d| configs::native_price_estimators::ExternalSolver {
        name: d.name.clone(),
        url: d.url.clone(),
    })
    .collect();

and pass &price_estimation_solvers to all three. Reduces the risk of the three copies drifting.

Fix this →

@MartinquaXD MartinquaXD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks alright to me.

@fleupold fleupold added the blocked This issue is blocked by some other work label Aug 31, 2026
@fleupold

Copy link
Copy Markdown
Contributor Author

Given this is a breaking change, I'm holding off merging until we have figured out which existing integration partners should change their priceQuality parameter to receive the optimal experience.

Comment on lines +1007 to +1016
Estimates do not get verified by
simulation.
Optimal: The price estimate is chosen among all price estimates, ranked
purely by the promised price. Estimates do not get verified by
simulation.
Verified: All price estimates get verified by simulation whenever
possible and verified estimates are preferred over unverified ones,
even when an unverified estimate promises a better price. The
response's `verified` flag indicates whether the returned estimate
was actually verified.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
Estimates do not get verified by
simulation.
Optimal: The price estimate is chosen among all price estimates, ranked
purely by the promised price. Estimates do not get verified by
simulation.
Verified: All price estimates get verified by simulation whenever
possible and verified estimates are preferred over unverified ones,
even when an unverified estimate promises a better price. The
response's `verified` flag indicates whether the returned estimate
was actually verified.
Estimates do not get verified by simulation.
Optimal: The price estimate is chosen among all price estimates, ranked
purely by the promised price. Estimates do not get verified by simulation.
Verified: All price estimates get verified by simulation whenever
possible and verified estimates are preferred over unverified ones,
even when an unverified estimate promises a better price. The
response's `verified` flag indicates whether the returned estimate
was actually verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked This issue is blocked by some other work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants