Skip to content

feat(swap): curated asset list with search + logos, custom slippage#319

Open
Dgetsylver wants to merge 1 commit into
mainfrom
feat/swap-curated-assets
Open

feat(swap): curated asset list with search + logos, custom slippage#319
Dgetsylver wants to merge 1 commit into
mainfrom
feat/swap-curated-assets

Conversation

@Dgetsylver

Copy link
Copy Markdown
Owner

Closes #318.

What

  • Curated asset list — replaces the hardcoded SWAP_ASSETS + BROKER_TO_CONTRACT with the LOBSTR curated feed (https://lobstr.co/api/v1/sep/assets/curated.json, CORS *, ~51 assets). New views/swapAssets.ts fetches + caches (in-memory + sessionStorage, 6h TTL), maps each entry to { brokerId, contractId, icon, decimals, … }, injects synthetic native XLM, and falls back to a small built-in list if the feed is unreachable.
  • Browse / search picker — the two dropdowns become asset pills (logo + code) that open a Modal search picker. Filters by code / name / domain / issuer / contract id, accepting both the C… StrKey and the raw 64-hex form. Curated-only: a pasted C… not in the feed shows "not in the curated list".
  • Token logos — from the feed icon, lazy-loaded, with a letter-avatar fallback on load error (pills + picker rows).
  • Custom slippage — keeps 0.1 / 0.5 / 1.0 chips, adds a 4th Custom chip → numeric input. Accepts 0 < x ≤ 50; warns above 5%; flags out-of-range as invalid and blocks the quote.

Unchanged

  • Quote (estimateSwap), DEX-rate cross-check (Aquarius), and the execute path — execution stays gated SWAP_EXECUTE_ENABLED = false ("coming soon"); the broker trade-XDR builder is still out of scope.

Files

  • frontend/src/views/swapAssets.ts (new) · frontend/src/views/swap.ts · frontend/src/views/swap.css
  • frontend/e2e/tests/swap.spec.ts (new) — picker render, search-filter, select, slippage validation

Verification

  • npm run build ✓ · npm run lint
  • hex→C… StrKey parity checked against real contracts (USDC CCW67TSZ…, EURC CDTKPWPL…, AQUA) — matches the previously hardcoded ids.
  • Full Playwright e2e suite green (4/4), including the new swap spec (deterministic via the fallback list, independent of the live feed).

Notes

🤖 Generated with Claude Code

…318)

Replace the hardcoded swap asset universe (SWAP_ASSETS + BROKER_TO_CONTRACT)
with the LOBSTR curated feed (curated.json). Users browse or search assets
(by code / name / domain / contract id — C… or raw hex) via a searchable
picker with token logos, instead of two fixed dropdowns. Slippage adds a
4th "Custom" option: a numeric input accepting 0 < x ≤ 50, warned above 5%.

- new views/swapAssets.ts: fetch + cache (in-memory + sessionStorage, 6h TTL),
  map each entry to { brokerId, contractId (StrKey from hex), icon, decimals,
  … }, inject synthetic native XLM, fall back to a built-in list on failure.
- swap.ts: asset pills open a Modal picker; logos with letter-avatar fallback;
  custom-slippage validation + high-slippage warning; balance + Aquarius lookups
  now resolve via contractForBroker. Quote / DEX-rate / execute flow unchanged
  (execute still gated "coming soon").
- e2e/tests/swap.spec.ts: picker render, search-filter, select, slippage
  validation (deterministic via the fallback list).

Verified: build + lint clean; hex→StrKey parity vs real contracts
(USDC/EURC/AQUA); full e2e suite green (4/4).
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying turbolong-app with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4f10a63
Status: ✅  Deploy successful!
Preview URL: https://b7cc330d.turbolong-app.pages.dev
Branch Preview URL: https://feat-swap-curated-assets.turbolong-app.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying turbolong-landing with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4f10a63
Status: ✅  Deploy successful!
Preview URL: https://8db17578.turbolong-landing.pages.dev
Branch Preview URL: https://feat-swap-curated-assets.turbolong-landing.pages.dev

View logs

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.

Swap: curated asset list (lobstr API) with search + logos, and custom slippage

1 participant