feat(sep-38): aggregate RFQ quotes with Stellar DEX order book depth … - #668
Merged
Topmatrixmor2014 merged 2 commits intoAug 18, 2026
Conversation
🤖 Greptile AI Code ReviewGreptile will automatically review this PR (9 file(s) changed). Review gates:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(sep-38): aggregate RFQ quotes with Stellar DEX order book depth (#347)
Summary
Aggregates SEP-38 RFQ quotes across Stellar DEX order book depth via Horizon, calculating volume-weighted average execution prices, slippage, and price impact with a 2-second cache TTL. It also updates the frontend
TradeFormto display order book depth, estimated slippage, and a "Best Price" badge for optimal fills.Type of change
Related issue
Closes #347
Changes
backend/src/services/sep/orderBookService.js):parseAssetsupporting SEP-38 identifiers (stellar:native,stellar:CODE:ISSUER, shorthand assets).getOrderBookwith Horizon/order_bookintegration and a 2-second Redis/LRU cache TTL.calculateWeightedPriceto walk order book depth levels, compute volume-weighted execution prices, and handle partial fills.estimateSlippageto calculate execution slippage against top-of-book and price impact against the marginal fill level.backend/src/services/sep/sep38Service.js,backend/src/routes/sep38.js,backend/src/server.js):getAggregatedQuotemethod returning execution price, top-of-book price, slippage %, price impact %, levels consumed, and partial fill indicators.GET /api/v1/sep38/quote/aggregatedandGET /sep38/quote/aggregatedendpoints with full query validation (sell_asset,buy_asset,sell_amount)./api/v1/sep38routes inserver.js.frontend/components/TradeForm.tsx):fetchAggregatedQuotewith client-side 2-second caching.backend/__tests__/orderBook.test.jsand updatedbackend/__tests__/sep38.test.js(single-level fill, multi-level depth fill, partial fill, 2s cache TTL).frontend/__tests__/TradeForm.test.tsxfor aggregated quotes, Best Price badge, and depth display.Testing
Test Results:
backend:jest __tests__/orderBook.test.js __tests__/sep38.test.js(25/25 tests passing)frontend:jest __tests__/TradeForm.test.tsx(41/41 tests passing)Screenshots (if UI change)
Aggregated quote details and "Best Price" badge rendered in the
TradeFormswap preview.Checklist
main