Skip to content

[#1286] feat(frontend): add AMM vs SDEX depth comparison view in LiquidityFragmentation page - #1382

Merged
Mosas2000 merged 1 commit into
StellaBridge:mainfrom
ToryMic:fix/1286-feat-frontend-add-amm-vs-sdex-depth-comparison-view-in-liquidityfragmentation-page
Sep 29, 2026
Merged

Mosas2000 merged 1 commit into
StellaBridge:mainfrom
ToryMic:fix/1286-feat-frontend-add-amm-vs-sdex-depth-comparison-view-in-liquidityfragmentation-page

Conversation

@ToryMic

@ToryMic ToryMic commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

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/liquidity endpoint via the existing useLiquidity hook. That endpoint already returns per-venue bidDepth / askDepth / priceLevels for SDEX and StellarX AMM, and no frontend code was using it on this page.

What was added

  1. Interactive stacked area chart (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.
  2. Venue slippage calculator (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.
  3. 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

  • SDEX depth is a discrete limit order book, so depth grows as price moves away from the mid.
  • Soroban AMM liquidity is pooled reserves, so it is flat across impact levels.

Plotting both on one cumulative curve is what makes the two models comparable. Where a venue cannot absorb an order, the calculator reports insufficient depth rather than a misleadingly small percentage, and flags that cross-venue routing would be needed.

Testing

  • 36 new tests: venueModel.test.ts, VenueSlippageCalculator.test.ts, VenueDepthComparison.test.tsx, LiquidityFragmentation.test.tsx
  • All 36 pass
  • eslint clean on all changed files
  • tsc --noEmit reports no errors in any changed file

Pre-existing baseline failures (not touched by this PR): the frontend suite on main already 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.yml and docker.yml also currently fail to parse on main (${{ runner.temp }} in job-level env, 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

  • No backend changes were needed — the venue-split data was already available and unused.
  • The new components sit alongside the existing LiquidityDepthChart / PriceImpactCalculator, which operate on the combined book. Mine are per-venue, so the two are complementary rather than duplicative.

Closes #1286

…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.
@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Mosas2000
Mosas2000 merged commit c4f9390 into StellaBridge:main Sep 29, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(frontend): add AMM vs SDEX depth comparison view in LiquidityFragmentation page

2 participants