@glacislabs/stablegenie-zerodelta 3.2.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { symbolKey, normalizeDecimalText, parseUnitsDecimal, SUPPORTED_CHAIN_IDS, tokenEnabled, isDeliverable, assetDecimals, findToken, formatUnits, createEngine, routeNativeValue, checkNativeFee, nativeFeeShortLabel, nativeSymbol, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, SUPPORTED_ASSETS, BUNDLED_RPC } from './chunk-OOURZ5DL.js';
1
+ import { CHAIN_DISPLAY_NAMES, EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, symbolKey, normalizeDecimalText, parseUnitsDecimal, assetDecimals, findToken, counterpartTokens, assetClassOf, brokenLaneFor, brokenLaneReason, destinationAvailability, SUPPORTED_CHAIN_IDS, formatUnits, createEngine, routeNativeValue, checkNativeFee, nativeFeeShortLabel, nativeSymbol, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, BUNDLED_RPC } from './chunk-TYQF2L5C.js';
2
2
  import { createContext, useMemo, useState, useEffect, useRef, useCallback, useId, createElement, useContext } from 'react';
3
3
  import { createRoot } from 'react-dom/client';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -728,7 +728,12 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
728
728
  .sg-back{width:32px;height:32px;flex:0 0 auto;border:none;border-radius:999px;background:transparent;color:var(--sg-text);cursor:pointer;font:inherit;display:flex;align-items:center;justify-content:center;transition:background 120ms ease}
729
729
  .sg-back:hover{background:var(--sg-surface)}
730
730
  .sg-sel-title{flex:1 1 auto;text-align:center;font-size:15px;font-weight:600;margin-right:32px}
731
- .sg-chain-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px;margin-bottom:12px}
731
+ /* Scrolls at ~2.5 rows. The catalogue's destination chains outnumber its source chains three to one
732
+ (9 escrow chains, ~37 total), so an ungated grid was eight rows tall and pushed the token list \u2014
733
+ the thing the panel exists for \u2014 below the fold. The fade is a scroll affordance, not decoration. */
734
+ .sg-chain-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px;margin-bottom:12px;max-height:124px;overflow-y:auto;scrollbar-width:thin;padding-bottom:2px;mask-image:linear-gradient(to bottom,#000 calc(100% - 14px),transparent);-webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 14px),transparent)}
735
+ /* No mask once everything fits \u2014 a fade under a grid with nothing below it reads as a rendering bug. */
736
+ .sg-chain-grid[data-scroll="false"]{mask-image:none;-webkit-mask-image:none;overflow-y:visible;max-height:none}
732
737
  .sg-chain-chip{height:44px;border-radius:var(--sg-radius-control);border:1px solid var(--sg-border);background:var(--sg-surface);color:var(--sg-text);display:flex;align-items:center;justify-content:center;cursor:pointer;font:inherit;font-size:10px;font-weight:700;letter-spacing:.02em;transition:border-color 120ms ease,background 120ms ease;overflow:hidden}
733
738
  .sg-chain-chip img{width:22px;height:22px;border-radius:999px;display:block}
734
739
  .sg-chain-chip:hover{border-color:color-mix(in srgb,var(--sg-accent) 45%,var(--sg-border))}
@@ -1088,7 +1093,7 @@ function shortAddress(a) {
1088
1093
  if (!a) return "";
1089
1094
  return `${a.slice(0, 6)}\u2026${a.slice(-4)}`;
1090
1095
  }
1091
- var CHAIN_LABELS = {
1096
+ var SOURCE_CHAIN_LABELS = {
1092
1097
  1: "Ethereum",
1093
1098
  10: "Optimism",
1094
1099
  130: "Unichain",
@@ -1099,8 +1104,14 @@ var CHAIN_LABELS = {
1099
1104
  42161: "Arbitrum",
1100
1105
  98866: "Plume"
1101
1106
  };
1107
+ var CHAIN_LABELS = { ...CHAIN_DISPLAY_NAMES, ...SOURCE_CHAIN_LABELS };
1102
1108
  var SUPPORTED_CHAINS = [1, 10, 42161, 8453, 57073, 130, 9745, 146, 98866];
1103
- var SUPPORTED_ASSETS2 = ["USDC", "USDT", "USDE", "XAUT"];
1109
+ var SUPPORTED_ASSETS2 = [
1110
+ ...EXECUTABLE_STABLE_ASSETS,
1111
+ ...[...STABLE_ASSETS].filter((a) => !EXECUTABLE_STABLE_ASSETS.has(a)),
1112
+ ...[...SUPPORTED_ASSETS].filter((a) => !STABLE_ASSETS.has(a))
1113
+ ];
1114
+ [...EXECUTABLE_STABLE_ASSETS];
1104
1115
  function Button(props) {
1105
1116
  const soft = !!props.softDisabled && !props.disabled;
1106
1117
  const nativeDisabled = props.disabled || props.busy && !props.softDisabled;
@@ -1309,7 +1320,19 @@ var BUNDLED_TOKEN_LOGO = {
1309
1320
  USDC: "https://coin-images.coingecko.com/coins/images/6319/large/USDC.png",
1310
1321
  USDT: "https://coin-images.coingecko.com/coins/images/325/large/Tether.png",
1311
1322
  USDE: "https://coin-images.coingecko.com/coins/images/33613/large/usde.png",
1312
- XAUT: "https://coin-images.coingecko.com/coins/images/10481/large/Tether_Gold.png"
1323
+ XAUT: "https://coin-images.coingecko.com/coins/images/10481/large/Tether_Gold.png",
1324
+ // 2026-09-08, with the dapp-parity asset expansion — the same four URLs the dapp draws
1325
+ // (zd-dapp/src/lib/tokenLogos.ts), so the two products show one picture per coin.
1326
+ USDTB: "https://coin-images.coingecko.com/coins/images/52804/large/76357aa8-4ef7-446c-bad3-a3f944eeec7a.jpeg",
1327
+ AUSD: "https://coin-images.coingecko.com/coins/images/39284/large/AUSD_1024px.png",
1328
+ PYUSD: "https://coin-images.coingecko.com/coins/images/31212/large/PYUSD_Token_Logo_2x.png",
1329
+ USDG: "https://coin-images.coingecko.com/coins/images/51281/large/GDN_USDG_Token_200x200.png",
1330
+ // The wider stable list, added 2026-09-08 with the RWA exchange.
1331
+ DAI: "https://coin-images.coingecko.com/coins/images/9956/large/Badge_Dai.png",
1332
+ USDS: "https://coin-images.coingecko.com/coins/images/39926/large/usds.webp",
1333
+ RLUSD: "https://coin-images.coingecko.com/coins/images/39651/large/RLUSD_200x200_%281%29.png",
1334
+ USD1: "https://coin-images.coingecko.com/coins/images/54977/large/USD1_1000x1000_transparent.png",
1335
+ WM: "https://coin-images.coingecko.com/coins/images/50789/large/M.png"
1313
1336
  };
1314
1337
  function isHttpsUrl(u) {
1315
1338
  return typeof u === "string" && /^https:\/\//i.test(u);
@@ -1339,12 +1362,18 @@ var CHAIN_SHORT = {
1339
1362
  42161: "ARB",
1340
1363
  98866: "PLM"
1341
1364
  };
1365
+ function chainBadge(chainId) {
1366
+ const pinned = CHAIN_SHORT[Number(chainId)];
1367
+ if (pinned) return pinned;
1368
+ const name = CHAIN_LABELS[Number(chainId)];
1369
+ return name ? name.replace(/[^A-Za-z]/g, "").slice(0, 3).toUpperCase() : "?";
1370
+ }
1342
1371
  function TokenGlyph(props) {
1343
1372
  const [failed, setFailed] = useState([]);
1344
1373
  const src = tokenLogoCandidates(props.symbol, props.logoUrl).find((u) => !failed.includes(u));
1345
1374
  const mark = props.chainId ? chainLogoCandidates(props.chainId)[0] : void 0;
1346
1375
  let badge = null;
1347
- if (props.chainId) badge = mark ? /* @__PURE__ */ jsx("img", { className: "sg-tok-badge", src: mark, alt: "" }) : /* @__PURE__ */ jsx("span", { className: "sg-tok-badge", children: CHAIN_SHORT[props.chainId] || "?" });
1376
+ if (props.chainId) badge = mark ? /* @__PURE__ */ jsx("img", { className: "sg-tok-badge", src: mark, alt: "" }) : /* @__PURE__ */ jsx("span", { className: "sg-tok-badge", children: chainBadge(props.chainId) });
1348
1377
  return /* @__PURE__ */ jsxs("span", { className: "sg-tok", "data-size": props.size === "sm" ? "sm" : void 0, children: [
1349
1378
  src ? /* @__PURE__ */ jsx("img", { className: "sg-tok-img", src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : /* @__PURE__ */ jsx("span", { className: "sg-tok-fb", children: props.symbol.slice(0, 4) }),
1350
1379
  badge
@@ -1354,17 +1383,18 @@ function ChevronGlyph() {
1354
1383
  return /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }) });
1355
1384
  }
1356
1385
  function TokenTile(props) {
1386
+ const shown = props.token?.symbol ?? props.pick?.symbol ?? "";
1357
1387
  const glyph = props.pick ? /* @__PURE__ */ jsxs(Fragment, { children: [
1358
1388
  /* @__PURE__ */ jsx(TokenGlyph, { symbol: props.pick.symbol, logoUrl: props.token?.logoUrl, chainId: props.pick.chainId }),
1359
1389
  /* @__PURE__ */ jsxs("span", { style: { minWidth: 0 }, children: [
1360
- /* @__PURE__ */ jsx("span", { className: "sg-tile-sym", children: props.pick.symbol }),
1390
+ /* @__PURE__ */ jsx("span", { className: "sg-tile-sym", children: shown }),
1361
1391
  /* @__PURE__ */ jsx("span", { className: "sg-tile-chain", children: CHAIN_LABELS[props.pick.chainId] || `Chain ${props.pick.chainId}` })
1362
1392
  ] })
1363
1393
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1364
1394
  /* @__PURE__ */ jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsx("span", { className: "sg-tok-fb", children: "?" }) }),
1365
1395
  /* @__PURE__ */ jsx("span", { className: "sg-tile-empty", children: "Select\u2026" })
1366
1396
  ] });
1367
- const ariaLabel = `${props.label}: ${props.pick ? `${props.pick.symbol} on ${CHAIN_LABELS[props.pick.chainId] || props.pick.chainId}` : "select token"}`;
1397
+ const ariaLabel = `${props.label}: ${props.pick ? `${shown} on ${CHAIN_LABELS[props.pick.chainId] || props.pick.chainId}` : "select token"}`;
1368
1398
  if (props.row) {
1369
1399
  return /* @__PURE__ */ jsxs("button", { type: "button", ref: props.btnRef, className: "sg-tile sg-tile--row", disabled: props.disabled, onClick: props.onClick, "aria-label": ariaLabel, children: [
1370
1400
  /* @__PURE__ */ jsx("span", { className: "sg-tile-label", children: props.label }),
@@ -1405,7 +1435,8 @@ function FundingTile(props) {
1405
1435
  function ChainChip(props) {
1406
1436
  const [failed, setFailed] = useState([]);
1407
1437
  const src = chainLogoCandidates(props.chain?.chainId, props.chain?.logoUrl).find((u) => !failed.includes(u));
1408
- return /* @__PURE__ */ jsx("button", { type: "button", className: "sg-chain-chip", "data-selected": props.selected, title: props.label, "aria-pressed": props.selected, onClick: props.onClick, children: src ? /* @__PURE__ */ jsx("img", { src, alt: props.label, loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : props.label });
1438
+ const name = props.name ?? props.label;
1439
+ return /* @__PURE__ */ jsx("button", { type: "button", className: "sg-chain-chip", "data-selected": props.selected, title: name, "aria-label": name, "aria-pressed": props.selected, onClick: props.onClick, children: src ? /* @__PURE__ */ jsx("img", { src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : props.label });
1409
1440
  }
1410
1441
  function SearchGlyph() {
1411
1442
  return /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", "aria-hidden": "true", children: [
@@ -1426,7 +1457,9 @@ function TokenSelect(props) {
1426
1457
  const q = query.trim().toLowerCase();
1427
1458
  const filtered = props.tokens.filter((t) => chainFilter == null ? true : Number(t.chainId) === chainFilter).filter((t) => {
1428
1459
  if (!q) return true;
1429
- return String(t.symbol || "").toLowerCase().includes(q) || String(t.name || "").toLowerCase().includes(q) || String(t.address || "").toLowerCase().includes(q);
1460
+ return String(t.symbol || "").toLowerCase().includes(q) || String(t.name || "").toLowerCase().includes(q) || String(t.address || "").toLowerCase().includes(q) || // Chain name too (2026-09-08): with ~37 destination chains most have no bundled mark and
1461
+ // show a three-letter badge, so "Katana" or "Berachain" has to be findable by typing it.
1462
+ String(CHAIN_LABELS[Number(t.chainId)] || "").toLowerCase().includes(q);
1430
1463
  });
1431
1464
  if (!props.balances) return filtered;
1432
1465
  const balNum = (t) => {
@@ -1440,13 +1473,14 @@ function TokenSelect(props) {
1440
1473
  /* @__PURE__ */ jsx("button", { type: "button", className: "sg-back", onClick: props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsx(BackGlyph, {}) }),
1441
1474
  /* @__PURE__ */ jsx("div", { className: "sg-sel-title", children: props.title })
1442
1475
  ] }),
1443
- /* @__PURE__ */ jsxs("div", { className: "sg-chain-grid", role: "group", "aria-label": "Filter by chain", children: [
1476
+ /* @__PURE__ */ jsxs("div", { className: "sg-chain-grid", "data-scroll": props.chains.length > 14 ? void 0 : "false", role: "group", "aria-label": "Filter by chain", children: [
1444
1477
  /* @__PURE__ */ jsx(ChainChip, { label: "All", selected: chainFilter == null, onClick: () => setChainFilter(null) }),
1445
1478
  props.chains.map((c) => /* @__PURE__ */ jsx(
1446
1479
  ChainChip,
1447
1480
  {
1448
1481
  chain: c,
1449
- label: CHAIN_SHORT[Number(c.chainId)] || String(c.chainId),
1482
+ label: chainBadge(Number(c.chainId)),
1483
+ name: CHAIN_LABELS[Number(c.chainId)] || c.displayName || c.name || `Chain ${c.chainId}`,
1450
1484
  selected: chainFilter === Number(c.chainId),
1451
1485
  onClick: () => setChainFilter(Number(c.chainId))
1452
1486
  },
@@ -1455,7 +1489,7 @@ function TokenSelect(props) {
1455
1489
  ] }),
1456
1490
  /* @__PURE__ */ jsxs("div", { className: "sg-search", children: [
1457
1491
  /* @__PURE__ */ jsx(SearchGlyph, {}),
1458
- /* @__PURE__ */ jsx("input", { autoFocus: true, placeholder: "Search by token or address", value: query, onChange: (e) => setQuery(e.target.value), spellCheck: false, "aria-label": "Search by token or address" })
1492
+ /* @__PURE__ */ jsx("input", { autoFocus: true, placeholder: "Search by token, network or address", value: query, onChange: (e) => setQuery(e.target.value), spellCheck: false, "aria-label": "Search by token, network or address" })
1459
1493
  ] }),
1460
1494
  /* @__PURE__ */ jsx("div", { className: "sg-toklist", role: "group", "aria-label": props.title, children: rows.length ? rows.map((t) => {
1461
1495
  const chainId = Number(t.chainId);
@@ -1487,7 +1521,7 @@ function TokenSelect(props) {
1487
1521
  },
1488
1522
  `${chainId}:${t.address}`
1489
1523
  );
1490
- }) : /* @__PURE__ */ jsx("div", { className: "sg-sel-empty", children: "No tokens match \u2014 try another chain or search." }) })
1524
+ }) : props.loading ? /* @__PURE__ */ jsx("div", { className: "sg-sel-empty", children: "Loading the token list\u2026" }) : /* @__PURE__ */ jsx("div", { className: "sg-sel-empty", children: "No tokens match \u2014 try another chain or search." }) })
1491
1525
  ] });
1492
1526
  }
1493
1527
  function useTxHistory(account) {
@@ -1728,7 +1762,7 @@ function forgetIdentity(account) {
1728
1762
  }
1729
1763
  var addrEq = (a, b) => String(a || "").toLowerCase() === String(b || "").toLowerCase();
1730
1764
  var chainName = (id) => id != null ? CHAIN_LABELS[id] || `Chain ${id}` : "";
1731
- var STABLES = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
1765
+ var STABLES = EXECUTABLE_STABLE_ASSETS;
1732
1766
  function BankGlyph() {
1733
1767
  return /* @__PURE__ */ jsx(
1734
1768
  "svg",
@@ -1969,19 +2003,17 @@ function PaymentIsland(props) {
1969
2003
  const mode = props.mode ?? "exchange";
1970
2004
  const rampMode = kind === "exchange" && mode !== "exchange";
1971
2005
  const bankSettlement = isPay && props.settlement === "bank";
1972
- const exAllowed = useMemo(
1973
- () => (props.assets?.length ? props.assets : ["USDC", "USDT", "USDE"]).map((a) => symbolKey(a)),
1974
- [props.assets]
1975
- );
2006
+ const exProduct = props.product ?? "stable";
2007
+ const exAllowed = useMemo(() => props.assets?.length ? props.assets.map((a) => symbolKey(a)) : void 0, [props.assets]);
1976
2008
  const [exFrom, setExFrom] = useState(() => {
1977
2009
  const chainId = props.defaultFromChainId ?? (kind === "swap" ? 42161 : void 0);
1978
2010
  const asset = props.defaultFromAsset ?? (kind === "swap" ? "USDT" : void 0);
1979
- return chainId && asset && exAllowed.includes(symbolKey(asset)) ? { chainId, symbol: symbolKey(asset) } : null;
2011
+ return chainId && asset ? { chainId, symbol: symbolKey(asset) } : null;
1980
2012
  });
1981
2013
  const [exTo, setExTo] = useState(() => {
1982
2014
  const chainId = props.defaultToChainId ?? (kind === "swap" ? 8453 : void 0);
1983
2015
  const asset = props.defaultToAsset ?? (kind === "swap" ? "USDC" : void 0);
1984
- return chainId && asset && exAllowed.includes(symbolKey(asset)) ? { chainId, symbol: symbolKey(asset) } : null;
2016
+ return chainId && asset ? { chainId, symbol: symbolKey(asset) } : null;
1985
2017
  });
1986
2018
  const [exAmount, setExAmount] = useState(props.defaultAmount ?? "");
1987
2019
  const exFromChainId = exFrom?.chainId;
@@ -2074,27 +2106,24 @@ function PaymentIsland(props) {
2074
2106
  }
2075
2107
  return map;
2076
2108
  }, [annotated, holdings.loading]);
2077
- const [chains, setChains] = useState([]);
2078
- const [registryTokens, setRegistryTokens] = useState([]);
2109
+ const [catalogue, setCatalogue] = useState(null);
2079
2110
  useEffect(() => {
2080
2111
  if (bankSettlement || !isPay && rampMode) return;
2081
2112
  let alive = true;
2082
- Promise.all([engine.fetchChains().catch(() => []), engine.fetchTokens().catch(() => [])]).then(([cs, ts]) => {
2083
- if (!alive) return;
2084
- const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
2085
- setChains(
2086
- cs.filter((c) => SUPPORTED_CHAIN_IDS.has(Number(c.chainId)) && c.isEnabled !== false).sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99))
2087
- );
2088
- setRegistryTokens(ts.filter((t) => tokenEnabled(t) && SUPPORTED_CHAIN_IDS.has(Number(t.chainId))));
2113
+ engine.fetchCatalogue(isPay ? void 0 : exAllowed, isPay ? "stable" : exProduct).then((next) => {
2114
+ if (alive) setCatalogue(next);
2089
2115
  });
2090
2116
  return () => {
2091
2117
  alive = false;
2092
2118
  };
2093
- }, [engine, isPay, rampMode, bankSettlement]);
2094
- const exchangeTokens = useMemo(
2095
- () => isPay ? [] : registryTokens.filter((t) => exAllowed.includes(symbolKey(t.symbol)) && isDeliverable(symbolKey(t.symbol), Number(t.chainId))),
2096
- [isPay, registryTokens, exAllowed]
2097
- );
2119
+ }, [engine, isPay, rampMode, bankSettlement, exAllowed, exProduct]);
2120
+ const chains = useMemo(() => {
2121
+ const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
2122
+ return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
2123
+ }, [catalogue]);
2124
+ const registryTokens = useMemo(() => catalogue?.tokens ?? [], [catalogue]);
2125
+ const exchangeTokens = useMemo(() => isPay ? [] : registryTokens, [isPay, registryTokens]);
2126
+ const exSourceTokens = useMemo(() => isPay ? [] : catalogue?.sources ?? [], [isPay, catalogue]);
2098
2127
  const [exBalances, setExBalances] = useState({});
2099
2128
  const exBalReq = useRef(0);
2100
2129
  useEffect(() => {
@@ -2116,6 +2145,39 @@ function PaymentIsland(props) {
2116
2145
  }, [engine, isPay, wallet.account, exchangeTokens]);
2117
2146
  const exFromToken = useMemo(() => exFrom ? findToken(exchangeTokens, exFrom.chainId, exFrom.symbol) : null, [exchangeTokens, exFrom]);
2118
2147
  const exToToken = useMemo(() => exTo ? findToken(exchangeTokens, exTo.chainId, exTo.symbol) : null, [exchangeTokens, exTo]);
2148
+ const exFromPicker = useMemo(() => exProduct === "rwa" ? counterpartTokens(exSourceTokens, exToToken) : exSourceTokens, [exProduct, exSourceTokens, exToToken]);
2149
+ const exToPicker = useMemo(() => exProduct === "rwa" ? counterpartTokens(exchangeTokens, exFromToken) : exchangeTokens, [exProduct, exchangeTokens, exFromToken]);
2150
+ const exRwaSeeded = useRef(false);
2151
+ useEffect(() => {
2152
+ if (isPay || exProduct !== "rwa" || exRwaSeeded.current) return;
2153
+ if (props.defaultFromAsset || props.defaultToAsset || !catalogue?.ready) return;
2154
+ const stable = exSourceTokens.find((t) => Number(t.chainId) === 42161 && symbolKey(t.symbol) === "USDC") ?? exSourceTokens.find((t) => assetClassOf(t.symbol) === "stable");
2155
+ const rwa = exchangeTokens.find((t) => assetClassOf(t.symbol) === "rwa");
2156
+ if (!stable || !rwa) return;
2157
+ exRwaSeeded.current = true;
2158
+ setExFrom({ chainId: Number(stable.chainId), symbol: symbolKey(stable.symbol) });
2159
+ setExTo({ chainId: Number(rwa.chainId), symbol: symbolKey(rwa.symbol) });
2160
+ }, [isPay, exProduct, catalogue, exSourceTokens, exchangeTokens, props.defaultFromAsset, props.defaultToAsset]);
2161
+ const exDestinationStates = useMemo(() => {
2162
+ if (!catalogue?.ready) return void 0;
2163
+ const states = {};
2164
+ for (const token of catalogue.tokens) {
2165
+ const key = balanceKey(Number(token.chainId), token.address);
2166
+ const measured = exFromToken ? brokenLaneFor(token, exFromToken, catalogue.brokenLanes) : void 0;
2167
+ if (measured) {
2168
+ states[key] = { disabled: true, reason: brokenLaneReason(measured), hint: "Unavailable" };
2169
+ continue;
2170
+ }
2171
+ const verdict = destinationAvailability(token, catalogue, exFromToken);
2172
+ if (verdict === "available") continue;
2173
+ states[key] = {
2174
+ disabled: true,
2175
+ reason: verdict === "hub-only" ? `${token.symbol} cannot be delivered on this chain.` : "ZeroDelta cannot deliver this asset here.",
2176
+ hint: verdict === "hub-only" ? "Not here" : "Unavailable"
2177
+ };
2178
+ }
2179
+ return states;
2180
+ }, [catalogue, exFromToken]);
2119
2181
  const exFromBal = exFrom && exFromToken ? exBalances[balanceKey(exFrom.chainId, exFromToken.address)] : void 0;
2120
2182
  const fundingTokens = useMemo(() => {
2121
2183
  const seen = /* @__PURE__ */ new Set();
@@ -2363,8 +2425,10 @@ function PaymentIsland(props) {
2363
2425
  {
2364
2426
  title: isFrom ? "Exchange from" : "Exchange to",
2365
2427
  chains,
2366
- tokens: exchangeTokens,
2428
+ tokens: isFrom ? exFromPicker : exToPicker,
2367
2429
  balances: exBalances,
2430
+ optionStates: isFrom ? void 0 : exDestinationStates,
2431
+ loading: !catalogue?.ready,
2368
2432
  onBack: () => closeSelector(openerRef),
2369
2433
  onPick: (pick) => {
2370
2434
  (isFrom ? setExFrom : setExTo)({ chainId: pick.chainId, symbol: symbolKey(pick.symbol) });
@@ -2582,8 +2646,8 @@ function PaymentIsland(props) {
2582
2646
  ) }) })
2583
2647
  ] }) });
2584
2648
  }
2585
- var STABLES2 = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
2586
- var DEFAULT_FUNDING_ASSETS = ["USDC", "USDT", "USDE"];
2649
+ var STABLES2 = EXECUTABLE_STABLE_ASSETS;
2650
+ var DEFAULT_FUNDING_ASSETS = [...EXECUTABLE_STABLE_ASSETS];
2587
2651
  function CheckGlyph3() {
2588
2652
  return /* @__PURE__ */ jsx(
2589
2653
  "svg",
@@ -2688,23 +2752,22 @@ function StableGeniePay(props) {
2688
2752
  }
2689
2753
  return map;
2690
2754
  }, [annotated, holdings.loading]);
2691
- const [chains, setChains] = useState([]);
2692
- const [registryTokens, setRegistryTokens] = useState([]);
2755
+ const [catalogue, setCatalogue] = useState(null);
2756
+ const chains = useMemo(() => {
2757
+ const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
2758
+ return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
2759
+ }, [catalogue]);
2760
+ const registryTokens = useMemo(() => catalogue?.tokens ?? [], [catalogue]);
2693
2761
  useEffect(() => {
2694
2762
  if (props.variant === "pill") return;
2695
2763
  let alive = true;
2696
- Promise.all([engine.fetchChains().catch(() => []), engine.fetchTokens().catch(() => [])]).then(([cs, ts]) => {
2697
- if (!alive) return;
2698
- const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
2699
- setChains(
2700
- cs.filter((c) => SUPPORTED_CHAIN_IDS.has(Number(c.chainId)) && c.isEnabled !== false).sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99))
2701
- );
2702
- setRegistryTokens(ts.filter((t) => tokenEnabled(t) && SUPPORTED_CHAIN_IDS.has(Number(t.chainId))));
2764
+ engine.fetchCatalogue().then((next) => {
2765
+ if (alive) setCatalogue(next);
2703
2766
  });
2704
2767
  return () => {
2705
2768
  alive = false;
2706
2769
  };
2707
- }, [engine]);
2770
+ }, [engine, props.variant]);
2708
2771
  const fundingTokens = useMemo(() => {
2709
2772
  const seen = /* @__PURE__ */ new Set();
2710
2773
  const list = [];
@@ -2883,8 +2946,8 @@ function StableGeniePay(props) {
2883
2946
  ) })
2884
2947
  ] }) }) });
2885
2948
  }
2886
- var chainOptions = SUPPORTED_CHAINS.map((c) => ({ value: c, label: CHAIN_LABELS[c] || `Chain ${c}` }));
2887
- var assetOptions = SUPPORTED_ASSETS2.map((a) => ({ value: a, label: a }));
2949
+ var sourceChainOptions = SUPPORTED_CHAINS.map((c) => ({ value: c, label: CHAIN_LABELS[c] || `Chain ${c}` }));
2950
+ var bundledAssetOptions = SUPPORTED_ASSETS2.map((a) => ({ value: a, label: a }));
2888
2951
  function CheckGlyph4() {
2889
2952
  return /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) });
2890
2953
  }
@@ -2897,6 +2960,33 @@ function StableGenieSwap(props) {
2897
2960
  const [toChainId, setToChainId] = useState(props.defaultToChainId ?? 8453);
2898
2961
  const [toAsset, setToAsset] = useState(props.defaultToAsset ?? "USDC");
2899
2962
  const [amount, setAmount] = useState(props.defaultAmount ?? "");
2963
+ const [catalogue, setCatalogue] = useState(null);
2964
+ useEffect(() => {
2965
+ if (props.variant === "pill") return;
2966
+ let alive = true;
2967
+ engine.fetchCatalogue().then((next) => {
2968
+ if (alive && next.ready) setCatalogue(next);
2969
+ });
2970
+ return () => {
2971
+ alive = false;
2972
+ };
2973
+ }, [engine, props.variant]);
2974
+ const assetOptions = useMemo(() => {
2975
+ if (!catalogue) return bundledAssetOptions;
2976
+ const symbols = [...new Set(catalogue.tokens.map((t) => t.symbol.toUpperCase()))];
2977
+ const ordered = [...SUPPORTED_ASSETS2.filter((a) => symbols.includes(a)), ...symbols.filter((s) => !SUPPORTED_ASSETS2.includes(s))];
2978
+ return ordered.length ? ordered.map((a) => ({ value: a, label: a })) : bundledAssetOptions;
2979
+ }, [catalogue]);
2980
+ const toChainOptions = useMemo(() => {
2981
+ if (!catalogue) return sourceChainOptions;
2982
+ const ids = [...catalogue.chainIds].sort((a, b) => {
2983
+ const ai = SUPPORTED_CHAINS.indexOf(a);
2984
+ const bi = SUPPORTED_CHAINS.indexOf(b);
2985
+ if (ai !== bi) return (ai < 0 ? 999 : ai) - (bi < 0 ? 999 : bi);
2986
+ return a - b;
2987
+ });
2988
+ return ids.map((c) => ({ value: c, label: CHAIN_LABELS[c] || `Chain ${c}` }));
2989
+ }, [catalogue]);
2900
2990
  const amountValid = /^\d+(\.\d+)?$/.test(amount.replace(",", ".")) && Number(amount.replace(",", ".")) > 0;
2901
2991
  const enabled = amountValid && props.variant !== "pill";
2902
2992
  const paramsKey = `${fromChainId}|${fromAsset}|${toChainId}|${toAsset}|${amount}|${props.recipient ?? ""}`;
@@ -2973,7 +3063,7 @@ function StableGenieSwap(props) {
2973
3063
  /* @__PURE__ */ jsx(AmountInput, { value: amount, onChange: setAmount, disabled: submitting }),
2974
3064
  /* @__PURE__ */ jsxs("div", { className: "sg-row", style: { marginTop: 8 }, children: [
2975
3065
  /* @__PURE__ */ jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsx(Select, { value: fromAsset, onChange: setFromAsset, options: assetOptions, disabled: submitting }) }),
2976
- /* @__PURE__ */ jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsx(Select, { value: fromChainId, onChange: (v) => setFromChainId(Number(v)), options: chainOptions, disabled: submitting }) })
3066
+ /* @__PURE__ */ jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsx(Select, { value: fromChainId, onChange: (v) => setFromChainId(Number(v)), options: sourceChainOptions, disabled: submitting }) })
2977
3067
  ] })
2978
3068
  ] }),
2979
3069
  /* @__PURE__ */ jsx("button", { type: "button", className: "sg-reverse", onClick: reverse, "aria-label": "Reverse", disabled: submitting, children: "\u2193" }),
@@ -2982,7 +3072,7 @@ function StableGenieSwap(props) {
2982
3072
  /* @__PURE__ */ jsx("div", { className: "sg-anchor sg-mono", children: toValue }),
2983
3073
  /* @__PURE__ */ jsxs("div", { className: "sg-row", style: { marginTop: 8 }, children: [
2984
3074
  /* @__PURE__ */ jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsx(Select, { value: toAsset, onChange: setToAsset, options: assetOptions, disabled: submitting }) }),
2985
- /* @__PURE__ */ jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsx(Select, { value: toChainId, onChange: (v) => setToChainId(Number(v)), options: chainOptions, disabled: submitting }) })
3075
+ /* @__PURE__ */ jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsx(Select, { value: toChainId, onChange: (v) => setToChainId(Number(v)), options: toChainOptions, disabled: submitting }) })
2986
3076
  ] })
2987
3077
  ] }),
2988
3078
  flow.status === "error" && flow.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: flow.error }) : null,
@@ -2994,7 +3084,6 @@ function StableGenieSwap(props) {
2994
3084
  ] })
2995
3085
  ] });
2996
3086
  }
2997
- var STABLE_ASSETS = ["USDC", "USDT", "USDE"];
2998
3087
  var FIAT = [
2999
3088
  { code: "USD", glyph: "$", label: "US Dollar" },
3000
3089
  { code: "EUR", glyph: "\u20AC", label: "Euro" },
@@ -3037,24 +3126,25 @@ function StableGenieExchange(props) {
3037
3126
  const mode = props.mode ?? "exchange";
3038
3127
  const wide = props.variant === "wide";
3039
3128
  const isPill = props.variant === "pill";
3040
- const allowed = useMemo(() => (props.assets?.length ? props.assets : STABLE_ASSETS).map((a) => symbolKey(a)), [props.assets]);
3041
- const [chains, setChains] = useState([]);
3042
- const [tokens, setTokens] = useState([]);
3129
+ const product = props.product ?? "stable";
3130
+ const allowed = useMemo(() => props.assets?.length ? props.assets.map((a) => symbolKey(a)) : void 0, [props.assets]);
3131
+ const [catalogue, setCatalogue] = useState(null);
3043
3132
  useEffect(() => {
3044
3133
  if (isPill) return;
3045
3134
  let alive = true;
3046
- Promise.all([engine.fetchChains().catch(() => []), engine.fetchTokens().catch(() => [])]).then(([cs, ts]) => {
3047
- if (!alive) return;
3048
- const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
3049
- setChains(
3050
- cs.filter((c) => SUPPORTED_CHAIN_IDS.has(Number(c.chainId)) && c.isEnabled !== false).sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99))
3051
- );
3052
- setTokens(ts.filter((t) => tokenEnabled(t) && SUPPORTED_CHAIN_IDS.has(Number(t.chainId)) && allowed.includes(symbolKey(t.symbol)) && isDeliverable(symbolKey(t.symbol), Number(t.chainId))));
3135
+ engine.fetchCatalogue(allowed, product).then((next) => {
3136
+ if (alive) setCatalogue(next);
3053
3137
  });
3054
3138
  return () => {
3055
3139
  alive = false;
3056
3140
  };
3057
- }, [engine, allowed]);
3141
+ }, [engine, allowed, product, isPill]);
3142
+ const chains = useMemo(() => {
3143
+ const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
3144
+ return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
3145
+ }, [catalogue]);
3146
+ const tokens = useMemo(() => catalogue?.tokens ?? [], [catalogue]);
3147
+ const sourceTokens = useMemo(() => catalogue?.sources ?? [], [catalogue]);
3058
3148
  const [view, setView] = useState("main");
3059
3149
  const [hist, setHist] = useState(null);
3060
3150
  const histBtnRef = useRef(null);
@@ -3064,19 +3154,53 @@ function StableGenieExchange(props) {
3064
3154
  };
3065
3155
  useEffect(() => setHist(null), [wallet.account]);
3066
3156
  const [from, setFrom] = useState(
3067
- () => props.defaultFromChainId && props.defaultFromAsset && allowed.includes(symbolKey(props.defaultFromAsset)) ? { chainId: props.defaultFromChainId, symbol: symbolKey(props.defaultFromAsset) } : null
3157
+ () => props.defaultFromChainId && props.defaultFromAsset ? { chainId: props.defaultFromChainId, symbol: symbolKey(props.defaultFromAsset) } : null
3068
3158
  );
3069
3159
  const [to, setTo] = useState(
3070
- () => props.defaultToChainId && props.defaultToAsset && allowed.includes(symbolKey(props.defaultToAsset)) ? { chainId: props.defaultToChainId, symbol: symbolKey(props.defaultToAsset) } : null
3160
+ () => props.defaultToChainId && props.defaultToAsset ? { chainId: props.defaultToChainId, symbol: symbolKey(props.defaultToAsset) } : null
3071
3161
  );
3072
3162
  const [amount, setAmount] = useState(props.defaultAmount ?? "");
3073
3163
  const [fiatCurrency, setFiatCurrency] = useState(props.fiatCurrency ?? "EUR");
3074
3164
  const fromToken = useMemo(() => from ? findToken(tokens, from.chainId, from.symbol) : null, [tokens, from]);
3075
3165
  const toToken = useMemo(() => to ? findToken(tokens, to.chainId, to.symbol) : null, [tokens, to]);
3166
+ const toSymbol = toToken?.symbol ?? to?.symbol ?? "";
3167
+ const fromPickerTokens = useMemo(() => product === "rwa" ? counterpartTokens(sourceTokens, toToken) : sourceTokens, [product, sourceTokens, toToken]);
3168
+ const toPickerTokens = useMemo(() => product === "rwa" ? counterpartTokens(tokens, fromToken) : tokens, [product, tokens, fromToken]);
3169
+ const rwaSeeded = useRef(false);
3170
+ useEffect(() => {
3171
+ if (product !== "rwa" || rwaSeeded.current) return;
3172
+ if (props.defaultFromAsset || props.defaultToAsset || !catalogue?.ready) return;
3173
+ const stable = sourceTokens.find((t) => Number(t.chainId) === 42161 && symbolKey(t.symbol) === "USDC") ?? sourceTokens.find((t) => assetClassOf(t.symbol) === "stable");
3174
+ const rwa = tokens.find((t) => assetClassOf(t.symbol) === "rwa");
3175
+ if (!stable || !rwa) return;
3176
+ rwaSeeded.current = true;
3177
+ setFrom({ chainId: Number(stable.chainId), symbol: symbolKey(stable.symbol) });
3178
+ setTo({ chainId: Number(rwa.chainId), symbol: symbolKey(rwa.symbol) });
3179
+ }, [product, catalogue, sourceTokens, tokens, props.defaultFromAsset, props.defaultToAsset]);
3180
+ const destinationStates = useMemo(() => {
3181
+ if (!catalogue?.ready) return void 0;
3182
+ const states = {};
3183
+ for (const token of catalogue.tokens) {
3184
+ const key = `${Number(token.chainId)}:${String(token.address || "").toLowerCase()}`;
3185
+ const measured = fromToken ? brokenLaneFor(token, fromToken, catalogue.brokenLanes) : void 0;
3186
+ if (measured) {
3187
+ states[key] = { disabled: true, reason: brokenLaneReason(measured), hint: "Unavailable" };
3188
+ continue;
3189
+ }
3190
+ const verdict = destinationAvailability(token, catalogue, fromToken);
3191
+ if (verdict === "available") continue;
3192
+ states[key] = {
3193
+ disabled: true,
3194
+ reason: verdict === "hub-only" ? `${token.symbol} cannot be delivered on this chain \u2014 choose an execution chain.` : "ZeroDelta cannot deliver this asset here.",
3195
+ hint: verdict === "hub-only" ? "Not here" : "Unavailable"
3196
+ };
3197
+ }
3198
+ return states;
3199
+ }, [catalogue, fromToken]);
3076
3200
  const normalizedAmount = normalizeDecimalText(amount);
3077
3201
  const amountValid = /^\d+(\.\d+)?$/.test(normalizedAmount) && Number(normalizedAmount) > 0 && Number(normalizedAmount) <= 1e9;
3078
3202
  const rampMode = mode !== "exchange";
3079
- const inUniverse = (p) => Boolean(p && allowed.includes(p.symbol));
3203
+ const inUniverse = (p) => Boolean(p && tokens.some((t) => Number(t.chainId) === p.chainId && symbolKey(t.symbol) === p.symbol));
3080
3204
  const cryptoReady = rampMode ? inUniverse(mode === "onramp" ? to : from) : inUniverse(from) && inUniverse(to);
3081
3205
  const quotable = mode === "exchange" && inUniverse(from) && inUniverse(to) && amountValid;
3082
3206
  const [balances, setBalances] = useState({});
@@ -3099,7 +3223,7 @@ function StableGenieExchange(props) {
3099
3223
  });
3100
3224
  }, [engine, wallet.account, tokens]);
3101
3225
  const fromBal = from && fromToken ? balances[balanceKey(from.chainId, fromToken.address)] : void 0;
3102
- const paramsKey = `${mode}|${from?.chainId}|${from?.symbol}|${to?.chainId}|${to?.symbol}|${normalizedAmount}|${props.recipient ?? ""}`;
3226
+ const paramsKey = `${mode}|${from?.chainId}|${from?.symbol}|${to?.chainId}|${toSymbol}|${normalizedAmount}|${props.recipient ?? ""}`;
3103
3227
  const flow = useFlow({
3104
3228
  engine,
3105
3229
  wallet,
@@ -3171,8 +3295,10 @@ function StableGenieExchange(props) {
3171
3295
  {
3172
3296
  title: isFrom ? "Exchange from" : "Exchange to",
3173
3297
  chains,
3174
- tokens,
3298
+ tokens: isFrom ? fromPickerTokens : toPickerTokens,
3175
3299
  balances,
3300
+ optionStates: isFrom ? void 0 : destinationStates,
3301
+ loading: !catalogue?.ready,
3176
3302
  onBack: () => closeSelector(isFrom),
3177
3303
  onPick: (pick) => {
3178
3304
  (isFrom ? setFrom : setTo)({ chainId: pick.chainId, symbol: symbolKey(pick.symbol) });
@@ -3187,7 +3313,7 @@ function StableGenieExchange(props) {
3187
3313
  /* @__PURE__ */ jsxs("div", { className: "sg-success-amt sg-mono", children: [
3188
3314
  receive,
3189
3315
  " ",
3190
- to?.symbol
3316
+ toSymbol
3191
3317
  ] }),
3192
3318
  /* @__PURE__ */ jsxs("div", { className: "sg-success-sub", children: [
3193
3319
  flow.verdict?.status === "confirmed" ? "Confirmed on-chain" : "Submitted \u2014 awaiting confirmation",
@@ -3228,7 +3354,7 @@ function StableGenieExchange(props) {
3228
3354
  !rampMode && quoteError && !wide ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: quoteError }) : null,
3229
3355
  !rampMode && !wide && quotable && !quoteError ? /* @__PURE__ */ jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
3230
3356
  /* @__PURE__ */ jsx("div", { className: "sg-label", children: "You receive (estimated)" }),
3231
- /* @__PURE__ */ jsx("div", { className: "sg-anchor sg-mono", children: quoting ? "\u2026" : receive ? `${receive} ${to?.symbol}` : "\u2014" }),
3357
+ /* @__PURE__ */ jsx("div", { className: "sg-anchor sg-mono", children: quoting ? "\u2026" : receive ? `${receive} ${toSymbol}` : "\u2014" }),
3232
3358
  meta && !quoting ? /* @__PURE__ */ jsxs("div", { className: "sg-recv-sub", children: [
3233
3359
  "via ",
3234
3360
  meta.bridge,
@@ -3276,7 +3402,7 @@ function StableGenieExchange(props) {
3276
3402
  /* @__PURE__ */ jsxs("div", { className: "sg-recv-amt sg-mono", children: [
3277
3403
  receive,
3278
3404
  " ",
3279
- to?.symbol
3405
+ toSymbol
3280
3406
  ] }),
3281
3407
  /* @__PURE__ */ jsxs("div", { className: "sg-recv-sub", children: [
3282
3408
  "on ",
@@ -3327,15 +3453,19 @@ function StableGenieExchange(props) {
3327
3453
  ] })
3328
3454
  ] }) });
3329
3455
  }
3456
+ function StableGenieRwaExchange(props) {
3457
+ return /* @__PURE__ */ jsx(StableGenieExchange, { ...props, product: "rwa" });
3458
+ }
3330
3459
 
3331
3460
  // src/mount.ts
3332
3461
  function mount(el, config) {
3333
3462
  const root = createRoot(el);
3334
3463
  const variant = config.variant ?? "pay";
3335
- const Comp = variant === "swap" ? StableGenieSwap : variant === "exchange" ? StableGenieExchange : StableGeniePay;
3464
+ const isExchange = variant === "exchange" || variant === "rwa";
3465
+ const Comp = variant === "swap" ? StableGenieSwap : isExchange ? StableGenieExchange : StableGeniePay;
3336
3466
  const { variant: _variant, ...props } = config;
3337
- root.render(createElement(Comp, props));
3467
+ root.render(createElement(Comp, variant === "rwa" ? { ...props, product: "rwa" } : props));
3338
3468
  return () => root.unmount();
3339
3469
  }
3340
3470
 
3341
- export { PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieSwap, darkTheme, lightTheme, mount, resolveTheme };
3471
+ export { PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, darkTheme, lightTheme, mount, resolveTheme };