[#1286] feat(frontend): add AMM vs SDEX depth comparison view in LiquidityFragmentation page - #1382
Merged
Conversation
…view in LiquidityFragmentation page The Liquidity Fragmentation page reported total liquidity as a single aggregated number, hiding how it splits between Stellar Classic (SDEX) order book depth and Soroban AMM pool reserves. Adds a venue comparison section that consumes the existing `GET /api/v1/assets/:symbol/liquidity` aggregated-liquidity data (previously unused by this page, which only read the fragmentation endpoints): - `VenueDepthComparison` — interactive stacked area chart of cumulative depth with one area per venue, a bid/ask side toggle, and a per-venue legend that labels each venue as limit-order-book or pooled-reserve liquidity. - `VenueSlippageCalculator` — estimated price impact for 10k / 50k / 100k USDC orders on each venue, so the cheapest venue for a given notional is visible at a glance. Venues that cannot absorb an order are flagged rather than reporting a misleadingly small number. - `venueModel` / `venueSlippage` — pure helpers holding the venue-model classification, cumulative depth curve construction, and slippage maths, kept separate from presentation so they are directly testable. SDEX depth grows as price moves away from the mid (discrete levels), whereas AMM reserves are flat across impact levels; plotting both on one cumulative curve makes the two liquidity models directly comparable. Adds 36 tests covering the depth curve, venue classification, slippage maths, both components, and the page wiring.
|
@ToryMic Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Adds the AMM vs SDEX venue split that #1286 asks for on the Liquidity Fragmentation page. The page previously showed total liquidity as one aggregated number, with no breakdown between Stellar Classic order book depth and Soroban AMM pool reserves.
This consumes the existing
GET /api/v1/assets/:symbol/liquidityendpoint via the existinguseLiquidityhook. That endpoint already returns per-venuebidDepth/askDepth/priceLevelsfor SDEX and StellarX AMM, and no frontend code was using it on this page.What was added
VenueDepthComparison) — cumulative depth with one stacked area per venue, a bid/ask side toggle, hover tooltips, and a legend that labels each venue as limit order book or pooled reserves.VenueSlippageCalculator) — estimated price impact for 10k / 50k / 100k USDC orders on each venue, so the cheapest venue for a given notional is visible at a glance.venueModel.ts/venueSlippage.ts— pure helpers for venue-model classification, cumulative depth curve construction, and slippage maths. Kept out of the components so they are directly testable.Notes on the modelling
Plotting both on one cumulative curve is what makes the two models comparable. Where a venue cannot absorb an order, the calculator reports
insufficient depthrather than a misleadingly small percentage, and flags that cross-venue routing would be needed.Testing
venueModel.test.ts,VenueSlippageCalculator.test.ts,VenueDepthComparison.test.tsx,LiquidityFragmentation.test.tsxeslintclean on all changed filestsc --noEmitreports no errors in any changed filePre-existing baseline failures (not touched by this PR): the frontend suite on
mainalready fails with 76 failing tests across 15 files (useAlertSnoozes,useBridgeNotes,HealthScoreCard,AssetDetail, and the admin token-storage tests, among others). Before and after this branch that count is identical — 15 failed files / 76 failed tests — so this change adds no new failures..github/workflows/ci.ymlanddocker.ymlalso currently fail to parse onmain(${{ runner.temp }}in job-levelenv, and${{ id.meta.* }}), so the CI jobs for this PR may not report. Both are upstream issues and I have left them alone here; happy to fix them in a separate PR if useful.Reviewer notes
LiquidityDepthChart/PriceImpactCalculator, which operate on the combined book. Mine are per-venue, so the two are complementary rather than duplicative.Closes #1286