feat(api-server, matching-engine): implement markets endpoints#1407
feat(api-server, matching-engine): implement markets endpoints#1407
Conversation
|
Claude finished @akirillo's task in 3m 54s —— View job Code Review
Overall this is clean and well-structured. The approach of using the existing Issue 1 —
|
acc2d3e to
b22e10e
Compare
|
Claude finished @akirillo's task in 2m 27s —— View job Code Review
All five issues from the previous review have been addressed. Here's a full re-review of the current state. Previously Flagged Issues — All Resolved ✅
New ObservationsMinor —
// Order with matchable_amount (100) >= min_fill_size (1) — should be counted
let order1 = create_test_order(100);The comment claims Nit — Float roundtrip for buy-side
let buy_usd = Token::usdc().convert_to_decimal(buy_amount_quote);
let buy_quantity_base = if market.price.price > 0.0 {
let base_decimal = buy_usd / market.price.price;
token.convert_from_decimal(base_decimal)
} else {
0u128
};The sell-side Overall this is clean — the implementation is well-structured, the previous feedback was addressed thoroughly, and the new tests (especially |
Addressed all issues mentioned here |
sehyunc
left a comment
There was a problem hiding this comment.
Cross-repo compatibility risk:
This PR changes GET /v2/markets to add_admin_authenticated_route in crates/workers/api-server/src/http.rs (around lines 277-282).
typescript-sdk still routes getMarkets() through relayerHttpClient without API-key headers in packages/external-match/src/client.ts (551-553), while rust-sdk has already switched to the auth client path.
Please coordinate/land the matching typescript-sdk update (or keep this endpoint unauthenticated until that client is updated), otherwise TS clients can start returning 401 on getMarkets().
sehyunc
left a comment
There was a problem hiding this comment.
Behavior note on market handlers:
In crates/workers/api-server/src/http/market.rs, both get_markets and get_market_depths currently drop per-token errors via .ok() and return partial results (128-131, 160-167).
That can silently mask state/price failures and make token availability appear inconsistent to clients. Prefer surfacing an error for the request (or returning explicit per-token error metadata) instead of silently filtering failed entries.
sehyunc
left a comment
There was a problem hiding this comment.
Approved.
Non-blocking follow-ups:
-
Cross-repo compatibility risk:
GET /v2/marketsis now admin-authenticated incrates/workers/api-server/src/http.rs(277-282).typescript-sdkstill callsgetMarkets()viarelayerHttpClientinpackages/external-match/src/client.ts(551-553) without the API-key header path used by auth-proxied endpoints. Please coordinate the matchingtypescript-sdkupdate to avoid401for TS clients. -
Silent partial responses:
Incrates/workers/api-server/src/http/market.rs, handlers currently drop per-token errors via.ok()and return partial results (128-131,160-167). Prefer surfacing request-level failure (or explicit per-token error metadata) rather than silently filtering failed entries.
|
Summary
get_liquidity_for_pairin the matching engine to aggregate buy/sell depth across all poolsBook::total_matchable_amount()helper to sum matchable amounts across all orders in a bookGET /v2/markets/depth,GET /v2/markets/:mint/depth) so they return real data instead of panickingTest plan
cargo build -p matching-engine-corecargo test -p matching-engine-core(47 tests pass, including new liquidity query tests)cargo build -p api-serverTODO: