Always quote with limit orders rebased - #4874
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Claude finished @fleupold's task in 2m 57s —— View job PR Review — Always quote with limit orders
The change is clean and consistent: quotes always build a Two things worth confirming (posted as inline comments, non-blocking):
Nothing here is blocking — both are "confirm the invariant / add a guard" notes. |
| // Only simulate gas if the auction has a sell token price (ie. we are | ||
| // in a proper auction). For quotes, we use the indicated gas | ||
| // value from the solver to save time. | ||
| let gas = if sell_token.is_some() { |
There was a problem hiding this comment.
The gas-simulation gate changed from order.class == Class::Limit to sell_token.is_some(). Two consequences worth confirming:
-
Market orders in real auctions now get simulated. Previously a market order (in a priced auction) used heuristic gas; now
sell_token.is_some()is true for it, so it goes throughsimulator.gas(...). That's arguably more accurate, but it's a behavioral change (and a per-order simulation cost) for a path the old code deliberately skipped. Since market orders are being deprecated this is likely fine, but it's worth being explicit that it's intended. -
sell_token.is_some()is being used as a proxy for "this is a real auction, not a quote". That coupling is implicit — it works only because quote auctions setprice: Nonefor every token (seedriver/src/domain/quote.rs:237) and real auctions always price traded tokens. Consider naming the intent more directly (e.g. deriving anis_quote/has_reference_priceboolean) so a future change to price population doesn't silently flip this branch.
| ), | ||
| // For quote auctions (which don't contain native prices) we fall back to a zero | ||
| // fee. The orderbook API will estimate a proper fee itself. | ||
| None => Default::default(), |
There was a problem hiding this comment.
This is the key semantic change: previously sell_token? made a solver-fee order skip (no solution) when no reference price was available; now it produces a solution with a zero fee.
For the quote path this is exactly what you want. The risk is that it also silently changes behavior for any real auction where a limit order's sell token happens to lack a reference price — instead of skipping, the solver would now settle it with a zero network fee (an unprofitable settlement / effective loss) rather than declining.
In practice this should be safe because the autopilot filters orders whose tokens have no native price, so priced auctions always carry a sell-token reference price. But that invariant is now load-bearing and only enforced elsewhere. Worth either (a) a comment stating the assumption, or (b) a tracing::warn! in the None branch when the auction isn't a quote, so a regression in price population surfaces instead of quietly zeroing fees.
Description
Remove the "quote with limit orders flag" which becomes the only option to quote now. This is a pre-requisite to removing the Market order class which is a legacy artifact and no longer used. It also allows implementing the haircut logic as a basic fee (since market orders don't allow solvers to determine fees).
The challenge that comes with quoting as limit orders is that drivers cannot accurately compute network fees (as those require a native price in sell token, which is not part of the auction and which aren't usually computed in the driver). The workaround is leaving the fee 0 in this case since it's anyways overridden by the orderbook API with the simulated or reported gas amount * sell token price.
Changes
How to test
Added a unit test that okx solver can quote with limit orders.
Warning
This PR requires merging infra PRs at the same time that remove the deprecated flags.