Complexity: High — 200 pts
Summary
StellarFlow swaps currently use Stellar's native DEX order book. Soroswap is a Soroban-based AMM on Stellar that often has better rates for certain pairs. This issue adds Soroswap as a parallel swap option — both quotes are fetched simultaneously and the user sees which gives a better rate.
Files to Create/Modify
- Create:
src/lib/soroswap.ts — Soroswap API client and Soroban tx builder
- Modify:
src/pages/SwapPage.tsx — dual quote UI and route selection
- Modify:
src/lib/stellar.ts — add Soroban contract invocation helper for Soroswap
Implementation Notes
soroswap.ts
const SOROSWAP_API = 'https://api.soroswap.finance';
export async function getSoroswapQuote(fromAsset, toAsset, amount, fromIssuer?, toIssuer?): Promise<{toAmount, route, contractAddress} | null>
export async function buildSoroswapTx(sourceAddress, contractAddress, ...): Promise<string>
getSoroswapQuote maps asset to Soroswap's format ('native' for XLM, 'ASSET_CODE:ISSUER' for others). buildSoroswapTx invokes the Soroban router contract using StellarSdk.Contract and StellarSdk.nativeToScVal.
SwapPage
const [dexQuote, soroswapQuote] = await Promise.allSettled([getSwapQuote(...), getSoroswapQuote(...)]);
Show both as selectable cards. Highlight the one with a better rate (add a "Best rate" badge). Store user's selection in selectedRoute state. On "Swap", use the selected route's tx builder.
If Soroswap throws or returns null, silently show only the DEX card.
Acceptance Criteria
Screen Recording Requirements
- Open Swap page → both DEX and Soroswap quotes load simultaneously
- One quote shows a better rate — it is highlighted
- Select the Soroswap route → sign and execute → success
- Select the DEX route → sign and execute → success
- Show the transaction on Stellar Expert confirming the correct operation type
Complexity: High — 200 pts
Summary
StellarFlow swaps currently use Stellar's native DEX order book. Soroswap is a Soroban-based AMM on Stellar that often has better rates for certain pairs. This issue adds Soroswap as a parallel swap option — both quotes are fetched simultaneously and the user sees which gives a better rate.
Files to Create/Modify
src/lib/soroswap.ts— Soroswap API client and Soroban tx buildersrc/pages/SwapPage.tsx— dual quote UI and route selectionsrc/lib/stellar.ts— add Soroban contract invocation helper for SoroswapImplementation Notes
soroswap.tsgetSoroswapQuotemaps asset to Soroswap's format ('native'for XLM,'ASSET_CODE:ISSUER'for others).buildSoroswapTxinvokes the Soroban router contract usingStellarSdk.ContractandStellarSdk.nativeToScVal.SwapPageShow both as selectable cards. Highlight the one with a better rate (add a "Best rate" badge). Store user's selection in
selectedRoutestate. On "Swap", use the selected route's tx builder.If Soroswap throws or returns null, silently show only the DEX card.
Acceptance Criteria
Screen Recording Requirements