Settle fast-path orders from the autopilot - #4729
Conversation
b6c9e30 to
9ceb810
Compare
9ceb810 to
a2eb919
Compare
d318fbe to
26528a1
Compare
|
Claude finished @AryanGodara's task in 4m 29s —— View job PR Review: Settle fast-path orders from the autopilotReviewed against One substantive finding, posted inline:
Nothing else blocking from my side. The |
| // The cached solution carries the fees and quote; so the recovered | ||
| // order needs neither. | ||
| let order = boundary::order::to_domain(&model_order, vec![], None); |
There was a problem hiding this comment.
I don't think this is true. When we send /quote requests we don't send any fee data with the order.
This might actually become quite painful. When the orderbook updates the competition data the executed_sell and executed_buy would already have to account for those fees. 🤕
We definitely need a test asserting that the price at which the order ultimately gets filled makes sense given the original quote, gas usage, and fees (protocol and partner).
| // Held out: not settled early by the fast path. | ||
| assert_eq!( | ||
| services.get_order(&uid).await.unwrap().metadata.status, | ||
| OrderStatus::Open | ||
| ); |
There was a problem hiding this comment.
I think this assertion doesn't give us anything. The order could be unsettled immediately after placing it just because the autopilot is a bit slow to kick things off.
| sqlx::query_scalar( | ||
| "SELECT id FROM competition_auctions WHERE order_uids @> ARRAY[$1::bytea]", | ||
| ) |
There was a problem hiding this comment.
Not sure what this is supposed to prove. The other test has the additional condition that the auction_id must not be the one associated with the quote but here we don't have that. So if we only settle after valid_from due to a bug but still in the original quote auction we wouldn't realize that.
Description
When a fast-path order arrives, the autopilot recovers its quote's winning solution and settles it out of competition via the driver's
/settle.Solves BE-62.
Stacked on #4737.
Changes
auction_id, then recover the winning solution + fill fromproposed_solutions/proposed_trade_executionsfastPathpayload to the autopilot's/settleDTOHow to test
No automated tests yet: the competition data this reads isn't persisted until BE-56, so the listener is no-op on real orders for now. I verified locally by seeding a competition in local DB (with all migrations) and asserting
fast_path_orderreturns it. The end-to-end test should land once BE-56 and orderbook fast-path support are in.For those reasons keeping this PR in draft for now