@glacislabs/stablegenie-zerodelta 3.3.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.
package/dist/mount.cjs CHANGED
@@ -14,7 +14,27 @@ function useMergedConfig(local) {
14
14
  // src/core/constants.ts
15
15
  var DEFAULT_WIDGET_API_BASE = "/api/widget/v1";
16
16
  var SUPPORTED_CHAIN_IDS = /* @__PURE__ */ new Set([1, 10, 42161, 8453, 57073, 130, 9745, 146, 98866]);
17
- var SUPPORTED_ASSETS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE", "XAUT"]);
17
+ var EXECUTABLE_STABLE_ASSETS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE", "USDTB", "AUSD", "PYUSD", "USDG"]);
18
+ var STABLE_ASSETS = /* @__PURE__ */ new Set([...EXECUTABLE_STABLE_ASSETS, "USD1", "WM", "USDS", "DAI", "RLUSD"]);
19
+ var TRADEABLE_RWA_ASSETS = /* @__PURE__ */ new Set([
20
+ "XAUT",
21
+ // Nest vault shares — chained delivery on Plume, sellable from their Ethereum deployment.
22
+ "NALPHA",
23
+ "NTBILL",
24
+ "NBASIS",
25
+ "NCREDIT",
26
+ "NOPAL",
27
+ "NWISDOM",
28
+ "NACRDX",
29
+ "NLCRD",
30
+ "NAXI",
31
+ "NCLOA",
32
+ "NFALCON",
33
+ // Centrifuge deRWA pair — chained asks on Base.
34
+ "DEJAAA",
35
+ "DESPXA"
36
+ ]);
37
+ var SUPPORTED_ASSETS = /* @__PURE__ */ new Set([...STABLE_ASSETS, ...TRADEABLE_RWA_ASSETS]);
18
38
  var API_CACHE_TTL_MS = 6e4;
19
39
  var MAX_QUOTE_CANDIDATES = 8;
20
40
  var QUOTE_BUFFER_BPS = 50;
@@ -27,7 +47,41 @@ var ERC20_ALLOWANCE_SELECTOR = "0xdd62ed3e";
27
47
  var ERC20_BALANCEOF_SELECTOR = "0x70a08231";
28
48
  var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
29
49
  var PREVIEW_OWNER = "0x1111111111111111111111111111111111111111";
30
- var CANONICAL_DECIMALS = { USDC: 6, USDT: 6, USDE: 18, XAUT: 6 };
50
+ var CANONICAL_DECIMALS = {
51
+ USDC: 6,
52
+ USDT: 6,
53
+ USDE: 18,
54
+ XAUT: 6,
55
+ // Added 2026-09-08 with the dapp-parity asset expansion. Every value below was read from the
56
+ // token contract itself — `eth_call decimals()` against each deployment the registry lists on the
57
+ // nine escrow chains — and each symbol answered the SAME number on every chain it is deployed on.
58
+ // The set is a deliberate mix of 6 and 18, and a copy-pasted row is wrong by a factor of 1e12
59
+ // while still looking entirely plausible in review; that is the bug this pin exists to prevent.
60
+ USDTB: 18,
61
+ AUSD: 6,
62
+ PYUSD: 6,
63
+ USDG: 6,
64
+ // The wider stable list — the bid side of an RWA trade.
65
+ DAI: 18,
66
+ RLUSD: 18,
67
+ USD1: 18,
68
+ USDS: 18,
69
+ WM: 6,
70
+ // Real-world assets. Every Nest vault share is 6; the Centrifuge pair is 18.
71
+ NALPHA: 6,
72
+ NTBILL: 6,
73
+ NBASIS: 6,
74
+ NCREDIT: 6,
75
+ NOPAL: 6,
76
+ NWISDOM: 6,
77
+ NACRDX: 6,
78
+ NLCRD: 6,
79
+ NAXI: 6,
80
+ NCLOA: 6,
81
+ NFALCON: 6,
82
+ DEJAAA: 18,
83
+ DESPXA: 18
84
+ };
31
85
  var CANONICAL_ESCROW = Object.freeze({
32
86
  1: "0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40",
33
87
  // Ethereum
@@ -57,9 +111,40 @@ var CANONICAL_INBOUND_BRIDGE = {
57
111
  USDC: "cctp",
58
112
  USDT: "layerzero",
59
113
  USDE: "layerzero",
60
- XAUT: "layerzero"
114
+ XAUT: "layerzero",
115
+ // 2026-09-08: the four assets added for dapp parity are all LayerZero V2 OFTs on every chain the
116
+ // registry lists them on (`standard: "LayerZeroV2OFT"`, verified against dev and prod /tokens).
117
+ // USDC remains the only CCTP asset.
118
+ USDTB: "layerzero",
119
+ AUSD: "layerzero",
120
+ PYUSD: "layerzero",
121
+ USDG: "layerzero",
122
+ // `"none"` is a POSITIVE statement, not a gap: these assets have no inbound bridge adapter at all
123
+ // (the registry says `bridge: "None"`, or ships no bridge field at all), so they can only ever be
124
+ // bid on the chain the order already executes on and can never legitimately owe a native
125
+ // LayerZero fee. Pinning them matters because the fallback for an UNpinned asset is the label
126
+ // sniff, and a hostile quote controls the label — `bridge: "layerzero"` on one of these would
127
+ // otherwise let it attach msg.value to an order that forwards none, stranding it in the escrow.
128
+ DAI: "none",
129
+ RLUSD: "none",
130
+ USD1: "none",
131
+ USDS: "none",
132
+ WM: "none",
133
+ NALPHA: "none",
134
+ NTBILL: "none",
135
+ NBASIS: "none",
136
+ NCREDIT: "none",
137
+ NOPAL: "none",
138
+ NWISDOM: "none",
139
+ NACRDX: "none",
140
+ NLCRD: "none",
141
+ NAXI: "none",
142
+ NCLOA: "none",
143
+ NFALCON: "none",
144
+ DEJAAA: "none",
145
+ DESPXA: "none"
61
146
  };
62
- var SAME_CLASS_STABLE = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
147
+ var SAME_CLASS_STABLE = new Set(STABLE_ASSETS);
63
148
  var MAX_SAME_CLASS_PAY_BPS = 30000n;
64
149
  var BUNDLED_NATIVE_SYMBOL = {
65
150
  1: "ETH",
@@ -82,6 +167,55 @@ var BUNDLED_RPC = {
82
167
  42161: "https://arb1.arbitrum.io/rpc",
83
168
  98866: "https://rpc.plume.org"
84
169
  };
170
+ var CHAIN_DISPLAY_NAMES = Object.freeze({
171
+ 1: "Ethereum",
172
+ 10: "Optimism",
173
+ 14: "Flare",
174
+ 30: "Rootstock",
175
+ 50: "XDC Network",
176
+ 56: "BNB Chain",
177
+ 88: "Viction",
178
+ 130: "Unichain",
179
+ 137: "Polygon",
180
+ 143: "Monad",
181
+ 146: "Sonic",
182
+ 151: "Redbelly Network",
183
+ 169: "Manta Pacific",
184
+ 196: "X Layer",
185
+ 252: "Fraxtal",
186
+ 324: "zkSync Era",
187
+ 480: "World Chain",
188
+ 988: "Stable",
189
+ 999: "HyperEVM",
190
+ 1030: "Conflux eSpace",
191
+ 1088: "Metis",
192
+ 1135: "Lisk",
193
+ 1329: "Sei",
194
+ 1776: "Injective EVM",
195
+ 1868: "Soneium",
196
+ 1923: "Swellchain",
197
+ 2222: "Kava",
198
+ 2818: "Morph",
199
+ 3343: "EDGE",
200
+ 4326: "MegaETH",
201
+ 5e3: "Mantle",
202
+ 8453: "Base",
203
+ 9745: "Plasma",
204
+ 34443: "Mode",
205
+ 42161: "Arbitrum One",
206
+ 43114: "Avalanche C-Chain",
207
+ 48900: "Zircuit",
208
+ 57073: "Ink",
209
+ 59144: "Linea",
210
+ 80094: "Berachain",
211
+ 81224: "Codex",
212
+ 81457: "Blast",
213
+ 98866: "Plume",
214
+ 534352: "Scroll",
215
+ 747474: "Katana",
216
+ 7777777: "Zora",
217
+ 21e6: "Corn"
218
+ });
85
219
 
86
220
  // src/core/address.ts
87
221
  function symbolKey(value) {
@@ -346,18 +480,133 @@ function applyLayerZeroBuffer(quote, option = {}) {
346
480
  return gas * (10000n + LZ_FEE_BUFFER_BPS) / 10000n;
347
481
  }
348
482
 
483
+ // src/core/availability.ts
484
+ function assetClassOf(symbol) {
485
+ const key = symbolKey(symbol);
486
+ if (TRADEABLE_RWA_ASSETS.has(key)) return "rwa";
487
+ if (STABLE_ASSETS.has(key)) return "stable";
488
+ return null;
489
+ }
490
+ function productAssets(product) {
491
+ return product === "rwa" ? /* @__PURE__ */ new Set([...STABLE_ASSETS, ...TRADEABLE_RWA_ASSETS]) : EXECUTABLE_STABLE_ASSETS;
492
+ }
493
+ function counterpartTokens(tokens, selected) {
494
+ const want = assetClassOf(selected?.symbol) === "rwa" ? "stable" : "rwa";
495
+ return tokens.filter((token) => assetClassOf(token.symbol) === want);
496
+ }
497
+ function tokenKey(chainId, address) {
498
+ return `${Number(chainId)}:${String(address || "").toLowerCase()}`;
499
+ }
500
+ function laneKey(fromChainId, fromAddress, toChainId, toAddress) {
501
+ return `${tokenKey(fromChainId, fromAddress)}>${tokenKey(toChainId, toAddress)}`;
502
+ }
503
+ function isExecutableBridge(descriptor) {
504
+ const bridge = descriptor?.bridge?.trim().toLowerCase();
505
+ const standard = descriptor?.standard?.replace(/[\s_-]/g, "").toLowerCase();
506
+ return (bridge === "circle" || bridge === "cctp") && standard === "cctpv2" || bridge === "layerzero" && standard === "layerzerov2oft";
507
+ }
508
+ function isKnownUnbridgeable(bridge) {
509
+ return typeof bridge === "string" && bridge.trim().toLowerCase() === "none";
510
+ }
511
+ function executableRoutes(routes) {
512
+ return routes.filter((route) => route.isEnabled !== false && isExecutableBridge(route));
513
+ }
514
+ function sourceKeys(routes) {
515
+ return new Set(routes.filter((r) => r.isEnabled !== false).map((r) => tokenKey(r.fromChainId, r.fromAddress ?? "")));
516
+ }
517
+ function destinationKeys(routes) {
518
+ return new Set(routes.filter((r) => r.isEnabled !== false).map((r) => tokenKey(r.toChainId, r.toAddress ?? "")));
519
+ }
520
+ function laneKeys(routes) {
521
+ return new Set(routes.filter((r) => r.isEnabled !== false).map((r) => laneKey(r.fromChainId, r.fromAddress ?? "", r.toChainId, r.toAddress ?? "")));
522
+ }
523
+ function executionChainIds(chains) {
524
+ return new Set(chains.filter((c) => c.isEnabled !== false && c.isExecutionChain === true).map((c) => Number(c.chainId)));
525
+ }
526
+ function hubDeliverableSymbols(tokens, execution) {
527
+ return new Set(tokens.filter((t) => execution.has(Number(t.chainId))).map((t) => symbolKey(t.symbol)));
528
+ }
529
+ function isSourceToken(token, ctx) {
530
+ const chainId = Number(token.chainId);
531
+ if (!ctx.sourceChains.has(chainId)) return false;
532
+ return ctx.execution.has(chainId) || !isKnownUnbridgeable(token.bridge) && ctx.source.has(tokenKey(chainId, token.address));
533
+ }
534
+ function directLaneOK(token, source, lanes) {
535
+ if (!source || !lanes) return true;
536
+ if (symbolKey(source.symbol) !== symbolKey(token.symbol)) return true;
537
+ if (Number(source.chainId) === Number(token.chainId)) return true;
538
+ return lanes.has(laneKey(source.chainId, source.address, token.chainId, token.address));
539
+ }
540
+ function brokenLaneFor(token, source, brokenLanes) {
541
+ if (!source || !brokenLanes) return void 0;
542
+ return brokenLanes.get(laneKey(source.chainId, source.address, token.chainId, token.address));
543
+ }
544
+ function destinationAvailability(token, ctx, source) {
545
+ if (brokenLaneFor(token, source ?? void 0, ctx.brokenLanes)) return "unreachable";
546
+ if (ctx.execution.has(Number(token.chainId))) return "available";
547
+ if (token.isChainedDestination === true) return "available";
548
+ if (!isKnownUnbridgeable(token.bridge) && ctx.destination.has(tokenKey(token.chainId, token.address)) && directLaneOK(token, source ?? void 0, ctx.lanes)) {
549
+ return "available";
550
+ }
551
+ return ctx.hubSymbols.has(symbolKey(token.symbol)) ? "hub-only" : "unreachable";
552
+ }
553
+ function hasReachableDestination(source, catalogue, ctx) {
554
+ if (catalogue.length === 0) return true;
555
+ const from = tokenKey(source.chainId, source.address);
556
+ for (const candidate of catalogue) {
557
+ if (tokenKey(candidate.chainId, candidate.address) === from) continue;
558
+ if (destinationAvailability(candidate, ctx, source) === "available") return true;
559
+ }
560
+ return false;
561
+ }
562
+ function buildCatalogue(input) {
563
+ const { chains, tokens, routes, supportedChainIds, brokenLanes } = input;
564
+ const product = input.product ?? "stable";
565
+ const universe = productAssets(product);
566
+ const allowedAssets = input.allowedAssets ? new Set([...input.allowedAssets].filter((a) => universe.has(a))) : universe;
567
+ const enabledChains = chains.filter((c) => c.isEnabled !== false);
568
+ const registryChainIds = new Set(enabledChains.map((c) => Number(c.chainId)));
569
+ const sourceChains = new Set([...registryChainIds].filter((id) => supportedChainIds.has(id)));
570
+ const execution = executionChainIds(enabledChains);
571
+ const projected = product === "rwa" ? routes.filter((route) => route.isEnabled !== false) : executableRoutes(routes);
572
+ const source = sourceKeys(projected);
573
+ const destination = destinationKeys(projected);
574
+ const lanes = laneKeys(projected);
575
+ const chainIds = new Set(sourceChains);
576
+ for (const route of projected) {
577
+ const id = Number(route.toChainId);
578
+ if (Number.isSafeInteger(id) && id > 0) chainIds.add(id);
579
+ }
580
+ const allowed = tokens.filter((token) => token.isEnabled !== false && allowedAssets.has(symbolKey(token.symbol)));
581
+ const projectedCatalogue = allowed.filter((token) => {
582
+ if (!chainIds.has(Number(token.chainId))) return false;
583
+ if (product === "rwa") return true;
584
+ if (!isExecutableBridge(token)) return false;
585
+ const key = tokenKey(token.chainId, token.address);
586
+ return source.has(key) || destination.has(key) || execution.has(Number(token.chainId));
587
+ });
588
+ const ready = chains.length > 0 && routes.length > 0 && projectedCatalogue.length > 0;
589
+ const catalogue = ready ? projectedCatalogue : allowed;
590
+ const hubSymbols = hubDeliverableSymbols(catalogue, execution);
591
+ const ctx = { source, destination, lanes, execution, sourceChains, hubSymbols, ...brokenLanes ? { brokenLanes } : {} };
592
+ const sources = ready ? catalogue.filter((token) => isSourceToken(token, ctx) && hasReachableDestination(token, catalogue, ctx)) : (
593
+ // Unprojected: the only rule we can still apply with confidence is the escrow-chain bound,
594
+ // which comes from this build's own pins rather than from the registry.
595
+ catalogue.filter((token) => sourceChains.has(Number(token.chainId)))
596
+ );
597
+ const byId = new Map(enabledChains.map((c) => [Number(c.chainId), c]));
598
+ for (const id of chainIds) if (!byId.has(id)) byId.set(id, { chainId: id, isEnabled: true });
599
+ return { ...ctx, product, tokens: catalogue, sources, chainIds, chains: [...byId.values()], ready };
600
+ }
601
+
349
602
  // src/core/options.ts
350
603
  function chainNameOf(chainId, chains) {
351
604
  const chain = chains.find((item) => Number(item.chainId) === Number(chainId));
352
- return chain?.displayName || chain?.name || `Chain ${chainId}`;
605
+ return chain?.displayName || chain?.name || CHAIN_DISPLAY_NAMES[Number(chainId)] || `Chain ${chainId}`;
353
606
  }
354
607
  function chainById(chains, chainId) {
355
608
  return chains.find((chain) => Number(chain.chainId) === Number(chainId)) || null;
356
609
  }
357
- function isDeliverable(symbol, chainId) {
358
- if (Number(chainId) === 8453 && symbolKey(symbol) === "USDT") return false;
359
- return true;
360
- }
361
610
  function chainSelectable(chain, chainId) {
362
611
  if (!SUPPORTED_CHAIN_IDS.has(Number(chainId))) return false;
363
612
  if (!chain) return true;
@@ -370,45 +619,57 @@ function findToken(tokens, chainId, symbol) {
370
619
  const key = symbolKey(symbol);
371
620
  return tokens.find((token) => tokenEnabled(token) && Number(token.chainId) === Number(chainId) && symbolKey(token.symbol) === key) || null;
372
621
  }
373
- function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains, walletChainId }) {
622
+ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains, walletChainId, catalogue }) {
374
623
  const invoiceKey = symbolKey(invoiceAsset);
375
- const tokenBySymbolAndChain = /* @__PURE__ */ new Map();
376
- for (const token of tokens) {
377
- if (!tokenEnabled(token)) continue;
378
- const key = symbolKey(token.symbol);
379
- if (!tokenBySymbolAndChain.has(key)) tokenBySymbolAndChain.set(key, /* @__PURE__ */ new Map());
380
- tokenBySymbolAndChain.get(key).set(Number(token.chainId), token);
381
- }
624
+ const invoiceChain = Number(invoiceChainId);
625
+ const live = catalogue?.ready ? catalogue : null;
626
+ const destinationToken = findToken(tokens, invoiceChain, invoiceKey);
382
627
  const routeBridge = /* @__PURE__ */ new Map();
383
628
  for (const route of routes || []) {
384
- if (route.isEnabled === false || Number(route.toChainId) !== Number(invoiceChainId)) continue;
629
+ if (route.isEnabled === false || Number(route.toChainId) !== invoiceChain) continue;
385
630
  routeBridge.set(`${symbolKey(route.tokenName || route.tokenId)}:${Number(route.fromChainId)}`, route.bridge);
386
631
  routeBridge.set(`${symbolKey(route.tokenId)}:${Number(route.fromChainId)}`, route.bridge);
387
632
  }
388
- const receiveDeliverable = isDeliverable(invoiceKey, invoiceChainId);
389
- const options = [];
390
- for (const [payKey, byChain] of tokenBySymbolAndChain.entries()) {
391
- if (!byChain.has(Number(invoiceChainId))) continue;
392
- for (const [chainId, token] of byChain.entries()) {
393
- const chain = chainById(chains, chainId);
394
- if (!chainSelectable(chain, chainId)) continue;
395
- const direct = chainId === Number(invoiceChainId) && payKey === invoiceKey;
396
- if (!direct && payKey === invoiceKey) continue;
397
- if (!direct && (!receiveDeliverable || !isDeliverable(payKey, chainId))) continue;
398
- options.push({
399
- symbol: token.symbol,
400
- symbolKey: payKey,
401
- name: token.name || token.symbol,
402
- chainId,
403
- chainName: chainNameOf(chainId, chains),
404
- address: token.address,
405
- decimals: assetDecimals(token),
406
- logoUrl: token.logoUrl,
407
- bridge: routeBridge.get(`${payKey}:${chainId}`) || token.bridge,
408
- sameChain: chainId === Number(invoiceChainId),
409
- direct
410
- });
633
+ const knownLanes = live?.lanes && live.lanes.size > 0 ? live.lanes : null;
634
+ function refusal(token) {
635
+ const sameSymbol = symbolKey(token.symbol) === invoiceKey;
636
+ const sameChain = Number(token.chainId) === invoiceChain;
637
+ if (sameSymbol && sameChain) return null;
638
+ if (live && destinationToken && brokenLaneFor(destinationToken, token, live.brokenLanes)) return "measured";
639
+ if (live && !isSourceToken(token, live)) return "not-a-source";
640
+ if (sameSymbol && knownLanes && !knownLanes.has(laneKey(token.chainId, token.address, invoiceChain, destinationToken?.address ?? ""))) {
641
+ return "no-direct-lane";
411
642
  }
643
+ if (live && destinationToken && destinationAvailability(destinationToken, live, token) !== "available") return "undeliverable";
644
+ return null;
645
+ }
646
+ const options = [];
647
+ const seen = /* @__PURE__ */ new Set();
648
+ const universe = live ? live.tokens : tokens;
649
+ for (const token of universe) {
650
+ if (!tokenEnabled(token)) continue;
651
+ const chainId = Number(token.chainId);
652
+ const chain = chainById(chains, chainId);
653
+ if (!chainSelectable(chain, chainId)) continue;
654
+ const key = tokenKey(chainId, token.address);
655
+ if (seen.has(key)) continue;
656
+ if (refusal(token)) continue;
657
+ seen.add(key);
658
+ const payKey = symbolKey(token.symbol);
659
+ const direct = chainId === invoiceChain && payKey === invoiceKey;
660
+ options.push({
661
+ symbol: token.symbol,
662
+ symbolKey: payKey,
663
+ name: token.name || token.symbol,
664
+ chainId,
665
+ chainName: chainNameOf(chainId, chains),
666
+ address: token.address,
667
+ decimals: assetDecimals(token),
668
+ logoUrl: token.logoUrl,
669
+ bridge: routeBridge.get(`${payKey}:${chainId}`) || token.bridge,
670
+ sameChain: chainId === invoiceChain,
671
+ direct
672
+ });
412
673
  }
413
674
  options.sort((a, b) => {
414
675
  const walletChain = Number(walletChainId || 0);
@@ -467,6 +728,36 @@ function nativeFeeShortMessage(check, symbol, chainName2) {
467
728
  return `This route bridges via LayerZero, which charges a ${need} ${symbol} network fee paid as part of the transaction. Your wallet holds ${have} ${symbol}${where}. Add ${symbol}${where} and try again \u2014 gas is owed on top of this fee.`;
468
729
  }
469
730
 
731
+ // src/core/route-health.ts
732
+ var EMPTY = /* @__PURE__ */ new Map();
733
+ function suppressedLanes(health) {
734
+ if (health?.mode !== "enforce" || !Array.isArray(health.lanes)) return EMPTY;
735
+ const out = /* @__PURE__ */ new Map();
736
+ for (const lane of health.lanes) {
737
+ if (lane?.status !== "broken") continue;
738
+ const key = typeof lane.laneKey === "string" ? lane.laneKey.toLowerCase() : "";
739
+ if (!key) continue;
740
+ out.set(key, {
741
+ route: typeof lane.route === "string" ? lane.route : "",
742
+ code: typeof lane.code === "string" ? lane.code : "",
743
+ message: typeof lane.message === "string" ? lane.message : "",
744
+ ...typeof lane.kind === "string" ? { kind: lane.kind } : {}
745
+ });
746
+ }
747
+ return out;
748
+ }
749
+ function brokenLaneReason(lane) {
750
+ if (!lane) return "";
751
+ switch (lane.kind) {
752
+ case "bridge-throttled":
753
+ return "The issuer's bridge for this pair is closed right now.";
754
+ case "vault-closed":
755
+ return "This vault is not accepting deposits right now.";
756
+ default:
757
+ return "ZeroDelta could not price this pair in its latest check.";
758
+ }
759
+ }
760
+
470
761
  // src/core/solve.ts
471
762
  async function solveExactOut({ option, destination, destinationToken, payer, fetchQuote }) {
472
763
  const destDecimals = assetDecimals(destinationToken);
@@ -909,7 +1200,8 @@ function createApiClient(cfg) {
909
1200
  const cache = {
910
1201
  chains: null,
911
1202
  tokens: null,
912
- routes: null
1203
+ routes: null,
1204
+ health: null
913
1205
  };
914
1206
  const apiBase = cfg.apiBase.replace(/\/$/, "");
915
1207
  async function apiRequest(path, init = {}) {
@@ -979,6 +1271,18 @@ function createApiClient(cfg) {
979
1271
  return [];
980
1272
  }
981
1273
  }
1274
+ async function fetchRouteHealth() {
1275
+ if (nowFresh(cache.health)) return cache.health.value;
1276
+ let value = null;
1277
+ try {
1278
+ const health = await apiRequest("/route-health", { timeoutMs: 8e3 });
1279
+ value = health && typeof health === "object" && !Array.isArray(health) ? health : null;
1280
+ } catch {
1281
+ value = null;
1282
+ }
1283
+ cache.health = { at: Date.now(), value };
1284
+ return value;
1285
+ }
982
1286
  async function fetchQuote(body, retries = 1) {
983
1287
  let lastError;
984
1288
  for (let attempt = 0; attempt <= retries; attempt += 1) {
@@ -993,7 +1297,7 @@ function createApiClient(cfg) {
993
1297
  }
994
1298
  throw lastError;
995
1299
  }
996
- return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchQuote, apiBase };
1300
+ return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchQuote, apiBase };
997
1301
  }
998
1302
 
999
1303
  // src/core/plan.ts
@@ -1011,7 +1315,7 @@ function validateDestination(destination) {
1011
1315
  assertAddress(destination.address, "Destination address");
1012
1316
  const chainId = Number(destination.chainId);
1013
1317
  const asset = symbolKey(destination.asset);
1014
- if (!SUPPORTED_CHAIN_IDS.has(chainId)) throw new Error("Unsupported destination chain.");
1318
+ if (!Number.isSafeInteger(chainId) || chainId <= 0) throw new Error("Unsupported destination chain.");
1015
1319
  if (!SUPPORTED_ASSETS.has(asset)) throw new Error("Unsupported destination asset.");
1016
1320
  const normalizedAmount = normalizeDecimalText(destination.amount);
1017
1321
  if (!/^\d+(\.\d+)?$/.test(normalizedAmount)) throw new Error("Could not detect a valid payment amount.");
@@ -1025,7 +1329,15 @@ function planErrorSummary(errors) {
1025
1329
  async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances) {
1026
1330
  validateDestination(request);
1027
1331
  assertAddress(payer, "Payer wallet");
1028
- const [chains, tokens, routes] = await Promise.all([api.fetchChains(), api.fetchTokens(), api.fetchRoutes()]);
1332
+ const [chains, tokens, routes, health] = await Promise.all([api.fetchChains(), api.fetchTokens(), api.fetchRoutes(), api.fetchRouteHealth()]);
1333
+ const catalogue = buildCatalogue({
1334
+ chains,
1335
+ tokens,
1336
+ routes,
1337
+ product: "stable",
1338
+ supportedChainIds: SUPPORTED_CHAIN_IDS,
1339
+ brokenLanes: suppressedLanes(health)
1340
+ });
1029
1341
  const destination = {
1030
1342
  ...request,
1031
1343
  chainId: Number(request.chainId),
@@ -1040,7 +1352,8 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
1040
1352
  tokens,
1041
1353
  routes,
1042
1354
  chains,
1043
- walletChainId: wallet?.chainId
1355
+ walletChainId: wallet?.chainId,
1356
+ catalogue
1044
1357
  }).filter((option) => option.direct || !allowedFunding || allowedFunding.has(option.symbolKey));
1045
1358
  if (!options.length) throw new Error(`No enabled ZeroDelta funding assets can settle ${destination.asset} on ${chainNameOf(destination.chainId, chains)}.`);
1046
1359
  const balanceTargets = [];
@@ -1122,7 +1435,8 @@ function validateSwap(swap = {}) {
1122
1435
  const toChainId = Number(swap.toChainId);
1123
1436
  const fromToken = symbolKey(swap.fromToken);
1124
1437
  const toToken = symbolKey(swap.toToken);
1125
- if (!SUPPORTED_CHAIN_IDS.has(fromChainId) || !SUPPORTED_CHAIN_IDS.has(toChainId)) throw new Error("Unsupported swap chain.");
1438
+ if (!SUPPORTED_CHAIN_IDS.has(fromChainId)) throw new Error("Unsupported swap chain.");
1439
+ if (!Number.isSafeInteger(toChainId) || toChainId <= 0) throw new Error("Unsupported swap chain.");
1126
1440
  if (!SUPPORTED_ASSETS.has(fromToken) || !SUPPORTED_ASSETS.has(toToken)) throw new Error("Unsupported swap asset.");
1127
1441
  const amountIn = normalizeDecimalText(swap.amountIn);
1128
1442
  if (!/^\d+(\.\d+)?$/.test(amountIn) || Number(amountIn) <= 0 || Number(amountIn) > 1e9) throw new Error("Enter a valid swap amount.");
@@ -1568,7 +1882,26 @@ function createEngine(config = {}) {
1568
1882
  fetchChains: api.fetchChains,
1569
1883
  fetchTokens: api.fetchTokens,
1570
1884
  fetchRoutes: api.fetchRoutes,
1885
+ fetchRouteHealth: api.fetchRouteHealth,
1571
1886
  fetchQuote: api.fetchQuote,
1887
+ fetchCatalogue: async (allowedAssets, product) => {
1888
+ const [chains, tokens, routes, health] = await Promise.all([
1889
+ api.fetchChains().catch(() => []),
1890
+ api.fetchTokens().catch(() => []),
1891
+ api.fetchRoutes().catch(() => []),
1892
+ api.fetchRouteHealth()
1893
+ ]);
1894
+ const allowed = allowedAssets?.length ? new Set([...allowedAssets].map(symbolKey).filter((a) => SUPPORTED_ASSETS.has(a))) : void 0;
1895
+ return buildCatalogue({
1896
+ chains,
1897
+ tokens,
1898
+ routes,
1899
+ product,
1900
+ ...allowed ? { allowedAssets: allowed } : {},
1901
+ supportedChainIds: SUPPORTED_CHAIN_IDS,
1902
+ brokenLanes: suppressedLanes(health)
1903
+ });
1904
+ },
1572
1905
  fetchPaymentPlan: (request, payer, wallet) => fetchPaymentPlan(api, request, payer, wallet, verifier.readBalances),
1573
1906
  quoteSwapPreview: (swap, owner) => quoteSwapPreview(api, swap, owner),
1574
1907
  buildSwapPlan: (swap, payer, wallet) => buildSwapPlan(api, swap, payer, wallet),
@@ -2305,7 +2638,12 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
2305
2638
  .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}
2306
2639
  .sg-back:hover{background:var(--sg-surface)}
2307
2640
  .sg-sel-title{flex:1 1 auto;text-align:center;font-size:15px;font-weight:600;margin-right:32px}
2308
- .sg-chain-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px;margin-bottom:12px}
2641
+ /* Scrolls at ~2.5 rows. The catalogue's destination chains outnumber its source chains three to one
2642
+ (9 escrow chains, ~37 total), so an ungated grid was eight rows tall and pushed the token list \u2014
2643
+ the thing the panel exists for \u2014 below the fold. The fade is a scroll affordance, not decoration. */
2644
+ .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)}
2645
+ /* No mask once everything fits \u2014 a fade under a grid with nothing below it reads as a rendering bug. */
2646
+ .sg-chain-grid[data-scroll="false"]{mask-image:none;-webkit-mask-image:none;overflow-y:visible;max-height:none}
2309
2647
  .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}
2310
2648
  .sg-chain-chip img{width:22px;height:22px;border-radius:999px;display:block}
2311
2649
  .sg-chain-chip:hover{border-color:color-mix(in srgb,var(--sg-accent) 45%,var(--sg-border))}
@@ -2665,7 +3003,7 @@ function shortAddress(a) {
2665
3003
  if (!a) return "";
2666
3004
  return `${a.slice(0, 6)}\u2026${a.slice(-4)}`;
2667
3005
  }
2668
- var CHAIN_LABELS = {
3006
+ var SOURCE_CHAIN_LABELS = {
2669
3007
  1: "Ethereum",
2670
3008
  10: "Optimism",
2671
3009
  130: "Unichain",
@@ -2676,8 +3014,14 @@ var CHAIN_LABELS = {
2676
3014
  42161: "Arbitrum",
2677
3015
  98866: "Plume"
2678
3016
  };
3017
+ var CHAIN_LABELS = { ...CHAIN_DISPLAY_NAMES, ...SOURCE_CHAIN_LABELS };
2679
3018
  var SUPPORTED_CHAINS = [1, 10, 42161, 8453, 57073, 130, 9745, 146, 98866];
2680
- var SUPPORTED_ASSETS2 = ["USDC", "USDT", "USDE", "XAUT"];
3019
+ var SUPPORTED_ASSETS2 = [
3020
+ ...EXECUTABLE_STABLE_ASSETS,
3021
+ ...[...STABLE_ASSETS].filter((a) => !EXECUTABLE_STABLE_ASSETS.has(a)),
3022
+ ...[...SUPPORTED_ASSETS].filter((a) => !STABLE_ASSETS.has(a))
3023
+ ];
3024
+ [...EXECUTABLE_STABLE_ASSETS];
2681
3025
  function Button(props) {
2682
3026
  const soft = !!props.softDisabled && !props.disabled;
2683
3027
  const nativeDisabled = props.disabled || props.busy && !props.softDisabled;
@@ -2886,7 +3230,19 @@ var BUNDLED_TOKEN_LOGO = {
2886
3230
  USDC: "https://coin-images.coingecko.com/coins/images/6319/large/USDC.png",
2887
3231
  USDT: "https://coin-images.coingecko.com/coins/images/325/large/Tether.png",
2888
3232
  USDE: "https://coin-images.coingecko.com/coins/images/33613/large/usde.png",
2889
- XAUT: "https://coin-images.coingecko.com/coins/images/10481/large/Tether_Gold.png"
3233
+ XAUT: "https://coin-images.coingecko.com/coins/images/10481/large/Tether_Gold.png",
3234
+ // 2026-09-08, with the dapp-parity asset expansion — the same four URLs the dapp draws
3235
+ // (zd-dapp/src/lib/tokenLogos.ts), so the two products show one picture per coin.
3236
+ USDTB: "https://coin-images.coingecko.com/coins/images/52804/large/76357aa8-4ef7-446c-bad3-a3f944eeec7a.jpeg",
3237
+ AUSD: "https://coin-images.coingecko.com/coins/images/39284/large/AUSD_1024px.png",
3238
+ PYUSD: "https://coin-images.coingecko.com/coins/images/31212/large/PYUSD_Token_Logo_2x.png",
3239
+ USDG: "https://coin-images.coingecko.com/coins/images/51281/large/GDN_USDG_Token_200x200.png",
3240
+ // The wider stable list, added 2026-09-08 with the RWA exchange.
3241
+ DAI: "https://coin-images.coingecko.com/coins/images/9956/large/Badge_Dai.png",
3242
+ USDS: "https://coin-images.coingecko.com/coins/images/39926/large/usds.webp",
3243
+ RLUSD: "https://coin-images.coingecko.com/coins/images/39651/large/RLUSD_200x200_%281%29.png",
3244
+ USD1: "https://coin-images.coingecko.com/coins/images/54977/large/USD1_1000x1000_transparent.png",
3245
+ WM: "https://coin-images.coingecko.com/coins/images/50789/large/M.png"
2890
3246
  };
2891
3247
  function isHttpsUrl(u) {
2892
3248
  return typeof u === "string" && /^https:\/\//i.test(u);
@@ -2916,12 +3272,18 @@ var CHAIN_SHORT = {
2916
3272
  42161: "ARB",
2917
3273
  98866: "PLM"
2918
3274
  };
3275
+ function chainBadge(chainId) {
3276
+ const pinned = CHAIN_SHORT[Number(chainId)];
3277
+ if (pinned) return pinned;
3278
+ const name = CHAIN_LABELS[Number(chainId)];
3279
+ return name ? name.replace(/[^A-Za-z]/g, "").slice(0, 3).toUpperCase() : "?";
3280
+ }
2919
3281
  function TokenGlyph(props) {
2920
3282
  const [failed, setFailed] = react.useState([]);
2921
3283
  const src = tokenLogoCandidates(props.symbol, props.logoUrl).find((u) => !failed.includes(u));
2922
3284
  const mark = props.chainId ? chainLogoCandidates(props.chainId)[0] : void 0;
2923
3285
  let badge = null;
2924
- if (props.chainId) badge = mark ? /* @__PURE__ */ jsxRuntime.jsx("img", { className: "sg-tok-badge", src: mark, alt: "" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok-badge", children: CHAIN_SHORT[props.chainId] || "?" });
3286
+ if (props.chainId) badge = mark ? /* @__PURE__ */ jsxRuntime.jsx("img", { className: "sg-tok-badge", src: mark, alt: "" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok-badge", children: chainBadge(props.chainId) });
2925
3287
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tok", "data-size": props.size === "sm" ? "sm" : void 0, children: [
2926
3288
  src ? /* @__PURE__ */ jsxRuntime.jsx("img", { className: "sg-tok-img", src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok-fb", children: props.symbol.slice(0, 4) }),
2927
3289
  badge
@@ -2931,17 +3293,18 @@ function ChevronGlyph() {
2931
3293
  return /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx("path", { d: "m9 18 6-6-6-6" }) });
2932
3294
  }
2933
3295
  function TokenTile(props) {
3296
+ const shown = props.token?.symbol ?? props.pick?.symbol ?? "";
2934
3297
  const glyph = props.pick ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2935
3298
  /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: props.pick.symbol, logoUrl: props.token?.logoUrl, chainId: props.pick.chainId }),
2936
3299
  /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { minWidth: 0 }, children: [
2937
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-sym", children: props.pick.symbol }),
3300
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-sym", children: shown }),
2938
3301
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-chain", children: CHAIN_LABELS[props.pick.chainId] || `Chain ${props.pick.chainId}` })
2939
3302
  ] })
2940
3303
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2941
3304
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok-fb", children: "?" }) }),
2942
3305
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-empty", children: "Select\u2026" })
2943
3306
  ] });
2944
- const ariaLabel = `${props.label}: ${props.pick ? `${props.pick.symbol} on ${CHAIN_LABELS[props.pick.chainId] || props.pick.chainId}` : "select token"}`;
3307
+ const ariaLabel = `${props.label}: ${props.pick ? `${shown} on ${CHAIN_LABELS[props.pick.chainId] || props.pick.chainId}` : "select token"}`;
2945
3308
  if (props.row) {
2946
3309
  return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", ref: props.btnRef, className: "sg-tile sg-tile--row", disabled: props.disabled, onClick: props.onClick, "aria-label": ariaLabel, children: [
2947
3310
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-label", children: props.label }),
@@ -2982,7 +3345,8 @@ function FundingTile(props) {
2982
3345
  function ChainChip(props) {
2983
3346
  const [failed, setFailed] = react.useState([]);
2984
3347
  const src = chainLogoCandidates(props.chain?.chainId, props.chain?.logoUrl).find((u) => !failed.includes(u));
2985
- return /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx("img", { src, alt: props.label, loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : props.label });
3348
+ const name = props.name ?? props.label;
3349
+ return /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx("img", { src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : props.label });
2986
3350
  }
2987
3351
  function SearchGlyph() {
2988
3352
  return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", "aria-hidden": "true", children: [
@@ -3003,7 +3367,9 @@ function TokenSelect(props) {
3003
3367
  const q = query.trim().toLowerCase();
3004
3368
  const filtered = props.tokens.filter((t) => chainFilter == null ? true : Number(t.chainId) === chainFilter).filter((t) => {
3005
3369
  if (!q) return true;
3006
- return String(t.symbol || "").toLowerCase().includes(q) || String(t.name || "").toLowerCase().includes(q) || String(t.address || "").toLowerCase().includes(q);
3370
+ 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
3371
+ // show a three-letter badge, so "Katana" or "Berachain" has to be findable by typing it.
3372
+ String(CHAIN_LABELS[Number(t.chainId)] || "").toLowerCase().includes(q);
3007
3373
  });
3008
3374
  if (!props.balances) return filtered;
3009
3375
  const balNum = (t) => {
@@ -3017,13 +3383,14 @@ function TokenSelect(props) {
3017
3383
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-back", onClick: props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx(BackGlyph, {}) }),
3018
3384
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-sel-title", children: props.title })
3019
3385
  ] }),
3020
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-chain-grid", role: "group", "aria-label": "Filter by chain", children: [
3386
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-chain-grid", "data-scroll": props.chains.length > 14 ? void 0 : "false", role: "group", "aria-label": "Filter by chain", children: [
3021
3387
  /* @__PURE__ */ jsxRuntime.jsx(ChainChip, { label: "All", selected: chainFilter == null, onClick: () => setChainFilter(null) }),
3022
3388
  props.chains.map((c) => /* @__PURE__ */ jsxRuntime.jsx(
3023
3389
  ChainChip,
3024
3390
  {
3025
3391
  chain: c,
3026
- label: CHAIN_SHORT[Number(c.chainId)] || String(c.chainId),
3392
+ label: chainBadge(Number(c.chainId)),
3393
+ name: CHAIN_LABELS[Number(c.chainId)] || c.displayName || c.name || `Chain ${c.chainId}`,
3027
3394
  selected: chainFilter === Number(c.chainId),
3028
3395
  onClick: () => setChainFilter(Number(c.chainId))
3029
3396
  },
@@ -3032,7 +3399,7 @@ function TokenSelect(props) {
3032
3399
  ] }),
3033
3400
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-search", children: [
3034
3401
  /* @__PURE__ */ jsxRuntime.jsx(SearchGlyph, {}),
3035
- /* @__PURE__ */ jsxRuntime.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" })
3402
+ /* @__PURE__ */ jsxRuntime.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" })
3036
3403
  ] }),
3037
3404
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-toklist", role: "group", "aria-label": props.title, children: rows.length ? rows.map((t) => {
3038
3405
  const chainId = Number(t.chainId);
@@ -3064,7 +3431,7 @@ function TokenSelect(props) {
3064
3431
  },
3065
3432
  `${chainId}:${t.address}`
3066
3433
  );
3067
- }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-sel-empty", children: "No tokens match \u2014 try another chain or search." }) })
3434
+ }) : props.loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-sel-empty", children: "Loading the token list\u2026" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-sel-empty", children: "No tokens match \u2014 try another chain or search." }) })
3068
3435
  ] });
3069
3436
  }
3070
3437
  function useTxHistory(account) {
@@ -3305,7 +3672,7 @@ function forgetIdentity(account) {
3305
3672
  }
3306
3673
  var addrEq = (a, b) => String(a || "").toLowerCase() === String(b || "").toLowerCase();
3307
3674
  var chainName = (id) => id != null ? CHAIN_LABELS[id] || `Chain ${id}` : "";
3308
- var STABLES = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
3675
+ var STABLES = EXECUTABLE_STABLE_ASSETS;
3309
3676
  function BankGlyph() {
3310
3677
  return /* @__PURE__ */ jsxRuntime.jsx(
3311
3678
  "svg",
@@ -3546,19 +3913,17 @@ function PaymentIsland(props) {
3546
3913
  const mode = props.mode ?? "exchange";
3547
3914
  const rampMode = kind === "exchange" && mode !== "exchange";
3548
3915
  const bankSettlement = isPay && props.settlement === "bank";
3549
- const exAllowed = react.useMemo(
3550
- () => (props.assets?.length ? props.assets : ["USDC", "USDT", "USDE"]).map((a) => symbolKey(a)),
3551
- [props.assets]
3552
- );
3916
+ const exProduct = props.product ?? "stable";
3917
+ const exAllowed = react.useMemo(() => props.assets?.length ? props.assets.map((a) => symbolKey(a)) : void 0, [props.assets]);
3553
3918
  const [exFrom, setExFrom] = react.useState(() => {
3554
3919
  const chainId = props.defaultFromChainId ?? (kind === "swap" ? 42161 : void 0);
3555
3920
  const asset = props.defaultFromAsset ?? (kind === "swap" ? "USDT" : void 0);
3556
- return chainId && asset && exAllowed.includes(symbolKey(asset)) ? { chainId, symbol: symbolKey(asset) } : null;
3921
+ return chainId && asset ? { chainId, symbol: symbolKey(asset) } : null;
3557
3922
  });
3558
3923
  const [exTo, setExTo] = react.useState(() => {
3559
3924
  const chainId = props.defaultToChainId ?? (kind === "swap" ? 8453 : void 0);
3560
3925
  const asset = props.defaultToAsset ?? (kind === "swap" ? "USDC" : void 0);
3561
- return chainId && asset && exAllowed.includes(symbolKey(asset)) ? { chainId, symbol: symbolKey(asset) } : null;
3926
+ return chainId && asset ? { chainId, symbol: symbolKey(asset) } : null;
3562
3927
  });
3563
3928
  const [exAmount, setExAmount] = react.useState(props.defaultAmount ?? "");
3564
3929
  const exFromChainId = exFrom?.chainId;
@@ -3651,27 +4016,24 @@ function PaymentIsland(props) {
3651
4016
  }
3652
4017
  return map;
3653
4018
  }, [annotated, holdings.loading]);
3654
- const [chains, setChains] = react.useState([]);
3655
- const [registryTokens, setRegistryTokens] = react.useState([]);
4019
+ const [catalogue, setCatalogue] = react.useState(null);
3656
4020
  react.useEffect(() => {
3657
4021
  if (bankSettlement || !isPay && rampMode) return;
3658
4022
  let alive = true;
3659
- Promise.all([engine.fetchChains().catch(() => []), engine.fetchTokens().catch(() => [])]).then(([cs, ts]) => {
3660
- if (!alive) return;
3661
- const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
3662
- setChains(
3663
- 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))
3664
- );
3665
- setRegistryTokens(ts.filter((t) => tokenEnabled(t) && SUPPORTED_CHAIN_IDS.has(Number(t.chainId))));
4023
+ engine.fetchCatalogue(isPay ? void 0 : exAllowed, isPay ? "stable" : exProduct).then((next) => {
4024
+ if (alive) setCatalogue(next);
3666
4025
  });
3667
4026
  return () => {
3668
4027
  alive = false;
3669
4028
  };
3670
- }, [engine, isPay, rampMode, bankSettlement]);
3671
- const exchangeTokens = react.useMemo(
3672
- () => isPay ? [] : registryTokens.filter((t) => exAllowed.includes(symbolKey(t.symbol)) && isDeliverable(symbolKey(t.symbol), Number(t.chainId))),
3673
- [isPay, registryTokens, exAllowed]
3674
- );
4029
+ }, [engine, isPay, rampMode, bankSettlement, exAllowed, exProduct]);
4030
+ const chains = react.useMemo(() => {
4031
+ const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
4032
+ return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
4033
+ }, [catalogue]);
4034
+ const registryTokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
4035
+ const exchangeTokens = react.useMemo(() => isPay ? [] : registryTokens, [isPay, registryTokens]);
4036
+ const exSourceTokens = react.useMemo(() => isPay ? [] : catalogue?.sources ?? [], [isPay, catalogue]);
3675
4037
  const [exBalances, setExBalances] = react.useState({});
3676
4038
  const exBalReq = react.useRef(0);
3677
4039
  react.useEffect(() => {
@@ -3693,6 +4055,39 @@ function PaymentIsland(props) {
3693
4055
  }, [engine, isPay, wallet.account, exchangeTokens]);
3694
4056
  const exFromToken = react.useMemo(() => exFrom ? findToken(exchangeTokens, exFrom.chainId, exFrom.symbol) : null, [exchangeTokens, exFrom]);
3695
4057
  const exToToken = react.useMemo(() => exTo ? findToken(exchangeTokens, exTo.chainId, exTo.symbol) : null, [exchangeTokens, exTo]);
4058
+ const exFromPicker = react.useMemo(() => exProduct === "rwa" ? counterpartTokens(exSourceTokens, exToToken) : exSourceTokens, [exProduct, exSourceTokens, exToToken]);
4059
+ const exToPicker = react.useMemo(() => exProduct === "rwa" ? counterpartTokens(exchangeTokens, exFromToken) : exchangeTokens, [exProduct, exchangeTokens, exFromToken]);
4060
+ const exRwaSeeded = react.useRef(false);
4061
+ react.useEffect(() => {
4062
+ if (isPay || exProduct !== "rwa" || exRwaSeeded.current) return;
4063
+ if (props.defaultFromAsset || props.defaultToAsset || !catalogue?.ready) return;
4064
+ const stable = exSourceTokens.find((t) => Number(t.chainId) === 42161 && symbolKey(t.symbol) === "USDC") ?? exSourceTokens.find((t) => assetClassOf(t.symbol) === "stable");
4065
+ const rwa = exchangeTokens.find((t) => assetClassOf(t.symbol) === "rwa");
4066
+ if (!stable || !rwa) return;
4067
+ exRwaSeeded.current = true;
4068
+ setExFrom({ chainId: Number(stable.chainId), symbol: symbolKey(stable.symbol) });
4069
+ setExTo({ chainId: Number(rwa.chainId), symbol: symbolKey(rwa.symbol) });
4070
+ }, [isPay, exProduct, catalogue, exSourceTokens, exchangeTokens, props.defaultFromAsset, props.defaultToAsset]);
4071
+ const exDestinationStates = react.useMemo(() => {
4072
+ if (!catalogue?.ready) return void 0;
4073
+ const states = {};
4074
+ for (const token of catalogue.tokens) {
4075
+ const key = balanceKey(Number(token.chainId), token.address);
4076
+ const measured = exFromToken ? brokenLaneFor(token, exFromToken, catalogue.brokenLanes) : void 0;
4077
+ if (measured) {
4078
+ states[key] = { disabled: true, reason: brokenLaneReason(measured), hint: "Unavailable" };
4079
+ continue;
4080
+ }
4081
+ const verdict = destinationAvailability(token, catalogue, exFromToken);
4082
+ if (verdict === "available") continue;
4083
+ states[key] = {
4084
+ disabled: true,
4085
+ reason: verdict === "hub-only" ? `${token.symbol} cannot be delivered on this chain.` : "ZeroDelta cannot deliver this asset here.",
4086
+ hint: verdict === "hub-only" ? "Not here" : "Unavailable"
4087
+ };
4088
+ }
4089
+ return states;
4090
+ }, [catalogue, exFromToken]);
3696
4091
  const exFromBal = exFrom && exFromToken ? exBalances[balanceKey(exFrom.chainId, exFromToken.address)] : void 0;
3697
4092
  const fundingTokens = react.useMemo(() => {
3698
4093
  const seen = /* @__PURE__ */ new Set();
@@ -3940,8 +4335,10 @@ function PaymentIsland(props) {
3940
4335
  {
3941
4336
  title: isFrom ? "Exchange from" : "Exchange to",
3942
4337
  chains,
3943
- tokens: exchangeTokens,
4338
+ tokens: isFrom ? exFromPicker : exToPicker,
3944
4339
  balances: exBalances,
4340
+ optionStates: isFrom ? void 0 : exDestinationStates,
4341
+ loading: !catalogue?.ready,
3945
4342
  onBack: () => closeSelector(openerRef),
3946
4343
  onPick: (pick) => {
3947
4344
  (isFrom ? setExFrom : setExTo)({ chainId: pick.chainId, symbol: symbolKey(pick.symbol) });
@@ -4159,8 +4556,8 @@ function PaymentIsland(props) {
4159
4556
  ) }) })
4160
4557
  ] }) });
4161
4558
  }
4162
- var STABLES2 = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
4163
- var DEFAULT_FUNDING_ASSETS = ["USDC", "USDT", "USDE"];
4559
+ var STABLES2 = EXECUTABLE_STABLE_ASSETS;
4560
+ var DEFAULT_FUNDING_ASSETS = [...EXECUTABLE_STABLE_ASSETS];
4164
4561
  function CheckGlyph3() {
4165
4562
  return /* @__PURE__ */ jsxRuntime.jsx(
4166
4563
  "svg",
@@ -4265,23 +4662,22 @@ function StableGeniePay(props) {
4265
4662
  }
4266
4663
  return map;
4267
4664
  }, [annotated, holdings.loading]);
4268
- const [chains, setChains] = react.useState([]);
4269
- const [registryTokens, setRegistryTokens] = react.useState([]);
4665
+ const [catalogue, setCatalogue] = react.useState(null);
4666
+ const chains = react.useMemo(() => {
4667
+ const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
4668
+ return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
4669
+ }, [catalogue]);
4670
+ const registryTokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
4270
4671
  react.useEffect(() => {
4271
4672
  if (props.variant === "pill") return;
4272
4673
  let alive = true;
4273
- Promise.all([engine.fetchChains().catch(() => []), engine.fetchTokens().catch(() => [])]).then(([cs, ts]) => {
4274
- if (!alive) return;
4275
- const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
4276
- setChains(
4277
- 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))
4278
- );
4279
- setRegistryTokens(ts.filter((t) => tokenEnabled(t) && SUPPORTED_CHAIN_IDS.has(Number(t.chainId))));
4674
+ engine.fetchCatalogue().then((next) => {
4675
+ if (alive) setCatalogue(next);
4280
4676
  });
4281
4677
  return () => {
4282
4678
  alive = false;
4283
4679
  };
4284
- }, [engine]);
4680
+ }, [engine, props.variant]);
4285
4681
  const fundingTokens = react.useMemo(() => {
4286
4682
  const seen = /* @__PURE__ */ new Set();
4287
4683
  const list = [];
@@ -4460,8 +4856,8 @@ function StableGeniePay(props) {
4460
4856
  ) })
4461
4857
  ] }) }) });
4462
4858
  }
4463
- var chainOptions = SUPPORTED_CHAINS.map((c) => ({ value: c, label: CHAIN_LABELS[c] || `Chain ${c}` }));
4464
- var assetOptions = SUPPORTED_ASSETS2.map((a) => ({ value: a, label: a }));
4859
+ var sourceChainOptions = SUPPORTED_CHAINS.map((c) => ({ value: c, label: CHAIN_LABELS[c] || `Chain ${c}` }));
4860
+ var bundledAssetOptions = SUPPORTED_ASSETS2.map((a) => ({ value: a, label: a }));
4465
4861
  function CheckGlyph4() {
4466
4862
  return /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx("path", { d: "M20 6 9 17l-5-5" }) });
4467
4863
  }
@@ -4474,6 +4870,33 @@ function StableGenieSwap(props) {
4474
4870
  const [toChainId, setToChainId] = react.useState(props.defaultToChainId ?? 8453);
4475
4871
  const [toAsset, setToAsset] = react.useState(props.defaultToAsset ?? "USDC");
4476
4872
  const [amount, setAmount] = react.useState(props.defaultAmount ?? "");
4873
+ const [catalogue, setCatalogue] = react.useState(null);
4874
+ react.useEffect(() => {
4875
+ if (props.variant === "pill") return;
4876
+ let alive = true;
4877
+ engine.fetchCatalogue().then((next) => {
4878
+ if (alive && next.ready) setCatalogue(next);
4879
+ });
4880
+ return () => {
4881
+ alive = false;
4882
+ };
4883
+ }, [engine, props.variant]);
4884
+ const assetOptions = react.useMemo(() => {
4885
+ if (!catalogue) return bundledAssetOptions;
4886
+ const symbols = [...new Set(catalogue.tokens.map((t) => t.symbol.toUpperCase()))];
4887
+ const ordered = [...SUPPORTED_ASSETS2.filter((a) => symbols.includes(a)), ...symbols.filter((s) => !SUPPORTED_ASSETS2.includes(s))];
4888
+ return ordered.length ? ordered.map((a) => ({ value: a, label: a })) : bundledAssetOptions;
4889
+ }, [catalogue]);
4890
+ const toChainOptions = react.useMemo(() => {
4891
+ if (!catalogue) return sourceChainOptions;
4892
+ const ids = [...catalogue.chainIds].sort((a, b) => {
4893
+ const ai = SUPPORTED_CHAINS.indexOf(a);
4894
+ const bi = SUPPORTED_CHAINS.indexOf(b);
4895
+ if (ai !== bi) return (ai < 0 ? 999 : ai) - (bi < 0 ? 999 : bi);
4896
+ return a - b;
4897
+ });
4898
+ return ids.map((c) => ({ value: c, label: CHAIN_LABELS[c] || `Chain ${c}` }));
4899
+ }, [catalogue]);
4477
4900
  const amountValid = /^\d+(\.\d+)?$/.test(amount.replace(",", ".")) && Number(amount.replace(",", ".")) > 0;
4478
4901
  const enabled = amountValid && props.variant !== "pill";
4479
4902
  const paramsKey = `${fromChainId}|${fromAsset}|${toChainId}|${toAsset}|${amount}|${props.recipient ?? ""}`;
@@ -4550,7 +4973,7 @@ function StableGenieSwap(props) {
4550
4973
  /* @__PURE__ */ jsxRuntime.jsx(AmountInput, { value: amount, onChange: setAmount, disabled: submitting }),
4551
4974
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-row", style: { marginTop: 8 }, children: [
4552
4975
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsxRuntime.jsx(Select, { value: fromAsset, onChange: setFromAsset, options: assetOptions, disabled: submitting }) }),
4553
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsxRuntime.jsx(Select, { value: fromChainId, onChange: (v) => setFromChainId(Number(v)), options: chainOptions, disabled: submitting }) })
4976
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsxRuntime.jsx(Select, { value: fromChainId, onChange: (v) => setFromChainId(Number(v)), options: sourceChainOptions, disabled: submitting }) })
4554
4977
  ] })
4555
4978
  ] }),
4556
4979
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-reverse", onClick: reverse, "aria-label": "Reverse", disabled: submitting, children: "\u2193" }),
@@ -4559,7 +4982,7 @@ function StableGenieSwap(props) {
4559
4982
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-anchor sg-mono", children: toValue }),
4560
4983
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-row", style: { marginTop: 8 }, children: [
4561
4984
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsxRuntime.jsx(Select, { value: toAsset, onChange: setToAsset, options: assetOptions, disabled: submitting }) }),
4562
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsxRuntime.jsx(Select, { value: toChainId, onChange: (v) => setToChainId(Number(v)), options: chainOptions, disabled: submitting }) })
4985
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-grow", children: /* @__PURE__ */ jsxRuntime.jsx(Select, { value: toChainId, onChange: (v) => setToChainId(Number(v)), options: toChainOptions, disabled: submitting }) })
4563
4986
  ] })
4564
4987
  ] }),
4565
4988
  flow.status === "error" && flow.error ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: flow.error }) : null,
@@ -4571,7 +4994,6 @@ function StableGenieSwap(props) {
4571
4994
  ] })
4572
4995
  ] });
4573
4996
  }
4574
- var STABLE_ASSETS = ["USDC", "USDT", "USDE"];
4575
4997
  var FIAT = [
4576
4998
  { code: "USD", glyph: "$", label: "US Dollar" },
4577
4999
  { code: "EUR", glyph: "\u20AC", label: "Euro" },
@@ -4614,24 +5036,25 @@ function StableGenieExchange(props) {
4614
5036
  const mode = props.mode ?? "exchange";
4615
5037
  const wide = props.variant === "wide";
4616
5038
  const isPill = props.variant === "pill";
4617
- const allowed = react.useMemo(() => (props.assets?.length ? props.assets : STABLE_ASSETS).map((a) => symbolKey(a)), [props.assets]);
4618
- const [chains, setChains] = react.useState([]);
4619
- const [tokens, setTokens] = react.useState([]);
5039
+ const product = props.product ?? "stable";
5040
+ const allowed = react.useMemo(() => props.assets?.length ? props.assets.map((a) => symbolKey(a)) : void 0, [props.assets]);
5041
+ const [catalogue, setCatalogue] = react.useState(null);
4620
5042
  react.useEffect(() => {
4621
5043
  if (isPill) return;
4622
5044
  let alive = true;
4623
- Promise.all([engine.fetchChains().catch(() => []), engine.fetchTokens().catch(() => [])]).then(([cs, ts]) => {
4624
- if (!alive) return;
4625
- const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
4626
- setChains(
4627
- 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))
4628
- );
4629
- 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))));
5045
+ engine.fetchCatalogue(allowed, product).then((next) => {
5046
+ if (alive) setCatalogue(next);
4630
5047
  });
4631
5048
  return () => {
4632
5049
  alive = false;
4633
5050
  };
4634
- }, [engine, allowed]);
5051
+ }, [engine, allowed, product, isPill]);
5052
+ const chains = react.useMemo(() => {
5053
+ const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
5054
+ return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
5055
+ }, [catalogue]);
5056
+ const tokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
5057
+ const sourceTokens = react.useMemo(() => catalogue?.sources ?? [], [catalogue]);
4635
5058
  const [view, setView] = react.useState("main");
4636
5059
  const [hist, setHist] = react.useState(null);
4637
5060
  const histBtnRef = react.useRef(null);
@@ -4641,19 +5064,53 @@ function StableGenieExchange(props) {
4641
5064
  };
4642
5065
  react.useEffect(() => setHist(null), [wallet.account]);
4643
5066
  const [from, setFrom] = react.useState(
4644
- () => props.defaultFromChainId && props.defaultFromAsset && allowed.includes(symbolKey(props.defaultFromAsset)) ? { chainId: props.defaultFromChainId, symbol: symbolKey(props.defaultFromAsset) } : null
5067
+ () => props.defaultFromChainId && props.defaultFromAsset ? { chainId: props.defaultFromChainId, symbol: symbolKey(props.defaultFromAsset) } : null
4645
5068
  );
4646
5069
  const [to, setTo] = react.useState(
4647
- () => props.defaultToChainId && props.defaultToAsset && allowed.includes(symbolKey(props.defaultToAsset)) ? { chainId: props.defaultToChainId, symbol: symbolKey(props.defaultToAsset) } : null
5070
+ () => props.defaultToChainId && props.defaultToAsset ? { chainId: props.defaultToChainId, symbol: symbolKey(props.defaultToAsset) } : null
4648
5071
  );
4649
5072
  const [amount, setAmount] = react.useState(props.defaultAmount ?? "");
4650
5073
  const [fiatCurrency, setFiatCurrency] = react.useState(props.fiatCurrency ?? "EUR");
4651
5074
  const fromToken = react.useMemo(() => from ? findToken(tokens, from.chainId, from.symbol) : null, [tokens, from]);
4652
5075
  const toToken = react.useMemo(() => to ? findToken(tokens, to.chainId, to.symbol) : null, [tokens, to]);
5076
+ const toSymbol = toToken?.symbol ?? to?.symbol ?? "";
5077
+ const fromPickerTokens = react.useMemo(() => product === "rwa" ? counterpartTokens(sourceTokens, toToken) : sourceTokens, [product, sourceTokens, toToken]);
5078
+ const toPickerTokens = react.useMemo(() => product === "rwa" ? counterpartTokens(tokens, fromToken) : tokens, [product, tokens, fromToken]);
5079
+ const rwaSeeded = react.useRef(false);
5080
+ react.useEffect(() => {
5081
+ if (product !== "rwa" || rwaSeeded.current) return;
5082
+ if (props.defaultFromAsset || props.defaultToAsset || !catalogue?.ready) return;
5083
+ const stable = sourceTokens.find((t) => Number(t.chainId) === 42161 && symbolKey(t.symbol) === "USDC") ?? sourceTokens.find((t) => assetClassOf(t.symbol) === "stable");
5084
+ const rwa = tokens.find((t) => assetClassOf(t.symbol) === "rwa");
5085
+ if (!stable || !rwa) return;
5086
+ rwaSeeded.current = true;
5087
+ setFrom({ chainId: Number(stable.chainId), symbol: symbolKey(stable.symbol) });
5088
+ setTo({ chainId: Number(rwa.chainId), symbol: symbolKey(rwa.symbol) });
5089
+ }, [product, catalogue, sourceTokens, tokens, props.defaultFromAsset, props.defaultToAsset]);
5090
+ const destinationStates = react.useMemo(() => {
5091
+ if (!catalogue?.ready) return void 0;
5092
+ const states = {};
5093
+ for (const token of catalogue.tokens) {
5094
+ const key = `${Number(token.chainId)}:${String(token.address || "").toLowerCase()}`;
5095
+ const measured = fromToken ? brokenLaneFor(token, fromToken, catalogue.brokenLanes) : void 0;
5096
+ if (measured) {
5097
+ states[key] = { disabled: true, reason: brokenLaneReason(measured), hint: "Unavailable" };
5098
+ continue;
5099
+ }
5100
+ const verdict = destinationAvailability(token, catalogue, fromToken);
5101
+ if (verdict === "available") continue;
5102
+ states[key] = {
5103
+ disabled: true,
5104
+ reason: verdict === "hub-only" ? `${token.symbol} cannot be delivered on this chain \u2014 choose an execution chain.` : "ZeroDelta cannot deliver this asset here.",
5105
+ hint: verdict === "hub-only" ? "Not here" : "Unavailable"
5106
+ };
5107
+ }
5108
+ return states;
5109
+ }, [catalogue, fromToken]);
4653
5110
  const normalizedAmount = normalizeDecimalText(amount);
4654
5111
  const amountValid = /^\d+(\.\d+)?$/.test(normalizedAmount) && Number(normalizedAmount) > 0 && Number(normalizedAmount) <= 1e9;
4655
5112
  const rampMode = mode !== "exchange";
4656
- const inUniverse = (p) => Boolean(p && allowed.includes(p.symbol));
5113
+ const inUniverse = (p) => Boolean(p && tokens.some((t) => Number(t.chainId) === p.chainId && symbolKey(t.symbol) === p.symbol));
4657
5114
  const cryptoReady = rampMode ? inUniverse(mode === "onramp" ? to : from) : inUniverse(from) && inUniverse(to);
4658
5115
  const quotable = mode === "exchange" && inUniverse(from) && inUniverse(to) && amountValid;
4659
5116
  const [balances, setBalances] = react.useState({});
@@ -4676,7 +5133,7 @@ function StableGenieExchange(props) {
4676
5133
  });
4677
5134
  }, [engine, wallet.account, tokens]);
4678
5135
  const fromBal = from && fromToken ? balances[balanceKey(from.chainId, fromToken.address)] : void 0;
4679
- const paramsKey = `${mode}|${from?.chainId}|${from?.symbol}|${to?.chainId}|${to?.symbol}|${normalizedAmount}|${props.recipient ?? ""}`;
5136
+ const paramsKey = `${mode}|${from?.chainId}|${from?.symbol}|${to?.chainId}|${toSymbol}|${normalizedAmount}|${props.recipient ?? ""}`;
4680
5137
  const flow = useFlow({
4681
5138
  engine,
4682
5139
  wallet,
@@ -4748,8 +5205,10 @@ function StableGenieExchange(props) {
4748
5205
  {
4749
5206
  title: isFrom ? "Exchange from" : "Exchange to",
4750
5207
  chains,
4751
- tokens,
5208
+ tokens: isFrom ? fromPickerTokens : toPickerTokens,
4752
5209
  balances,
5210
+ optionStates: isFrom ? void 0 : destinationStates,
5211
+ loading: !catalogue?.ready,
4753
5212
  onBack: () => closeSelector(isFrom),
4754
5213
  onPick: (pick) => {
4755
5214
  (isFrom ? setFrom : setTo)({ chainId: pick.chainId, symbol: symbolKey(pick.symbol) });
@@ -4764,7 +5223,7 @@ function StableGenieExchange(props) {
4764
5223
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-amt sg-mono", children: [
4765
5224
  receive,
4766
5225
  " ",
4767
- to?.symbol
5226
+ toSymbol
4768
5227
  ] }),
4769
5228
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", children: [
4770
5229
  flow.verdict?.status === "confirmed" ? "Confirmed on-chain" : "Submitted \u2014 awaiting confirmation",
@@ -4805,7 +5264,7 @@ function StableGenieExchange(props) {
4805
5264
  !rampMode && quoteError && !wide ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: quoteError }) : null,
4806
5265
  !rampMode && !wide && quotable && !quoteError ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
4807
5266
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "You receive (estimated)" }),
4808
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-anchor sg-mono", children: quoting ? "\u2026" : receive ? `${receive} ${to?.symbol}` : "\u2014" }),
5267
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-anchor sg-mono", children: quoting ? "\u2026" : receive ? `${receive} ${toSymbol}` : "\u2014" }),
4809
5268
  meta && !quoting ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv-sub", children: [
4810
5269
  "via ",
4811
5270
  meta.bridge,
@@ -4853,7 +5312,7 @@ function StableGenieExchange(props) {
4853
5312
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv-amt sg-mono", children: [
4854
5313
  receive,
4855
5314
  " ",
4856
- to?.symbol
5315
+ toSymbol
4857
5316
  ] }),
4858
5317
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv-sub", children: [
4859
5318
  "on ",
@@ -4909,9 +5368,10 @@ function StableGenieExchange(props) {
4909
5368
  function mount(el, config) {
4910
5369
  const root = client.createRoot(el);
4911
5370
  const variant = config.variant ?? "pay";
4912
- const Comp = variant === "swap" ? StableGenieSwap : variant === "exchange" ? StableGenieExchange : StableGeniePay;
5371
+ const isExchange = variant === "exchange" || variant === "rwa";
5372
+ const Comp = variant === "swap" ? StableGenieSwap : isExchange ? StableGenieExchange : StableGeniePay;
4913
5373
  const { variant: _variant, ...props } = config;
4914
- root.render(react.createElement(Comp, props));
5374
+ root.render(react.createElement(Comp, variant === "rwa" ? { ...props, product: "rwa" } : props));
4915
5375
  return () => root.unmount();
4916
5376
  }
4917
5377