Skip to content

Add path payment route explorer #31

Description

@MJ-RWA

Complexity: High — 200 pts

Summary

Stellar's DEX supports multi-hop path payments through intermediate assets. StellarFlow's swap picks the first Horizon result automatically. This issue builds a dedicated Path Explorer that shows all available routes between two assets, ranked by output, so users can pick the best one.

Files to Create/Modify

  • Create: src/pages/PathExplorerPage.tsx
  • Modify: src/lib/stellar.ts — add findAllPaths and PathOption
  • Modify: src/pages/SwapPage.tsx — add "Explore routes" link, read path URL param
  • Modify: src/App.tsx — add /paths route
  • Modify: src/types/index.ts — add PathOption type

Implementation Notes

findAllPaths in stellar.ts

export interface PathOption {
  rank: number;
  pathLabels: string[];
  pathAssets: StellarSdk.Asset[];
  destinationAmount: string;
  rate: string;
  isBest: boolean;
}
export async function findAllPaths(fromAssetCode, toAssetCode, amount, fromIssuer?, toIssuer?): Promise<PathOption[]>

Call server.strictSendPaths(sendAsset, amount, [destAsset]).call(), map each record to a PathOption with the full asset chain as pathLabels, sort descending by destinationAmount, mark index 0 as isBest.

PathExplorerPage layout

From: [XLM ▾]  To: [USDC ▾]  Amount: [100]  [Find Routes]
★ Best   XLM → USDC      You get: 41.23 USDC   [Use this route]
#2       XLM → yXLM → USDC   You get: 41.18 USDC   [Use this route]

"Use this route" navigates to /swap?from=XLM&to=USDC&amount=100&path=.... Empty state: "No routes found. Try a smaller amount."

SwapPage update

Read a path URL param and pre-select it, skipping the quote fetch and using the provided pathAssets directly. Add an "Explore routes" link below the quote details card.

Acceptance Criteria

  • All Horizon-returned paths displayed and sorted by destination amount (highest first)
  • Best route clearly labeled with ★ or "Best Rate" badge
  • Each route shows the full intermediate asset chain as a visual breadcrumb
  • "Use this route" navigates to Swap with the selected path pre-loaded
  • Swap page accepts and uses a pre-selected path from URL params
  • Empty state shown when Horizon returns no paths
  • Works for any asset pair supported by the user's balance
  • Works on Stellar mainnet

Screen Recording Requirements

  1. From the Swap page, click "Explore routes"
  2. Path Explorer opens pre-filled with current swap params
  3. Multiple route options appear sorted by output amount
  4. Best route has ★ badge
  5. Click "Use this route" on the second-best route → navigated to Swap pre-filled with that exact route
  6. Execute the swap → confirm the route used on Stellar Expert matches what was selected

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions