@glacislabs/stablegenie-zerodelta 2.0.0 → 3.0.1

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.
@@ -683,6 +683,10 @@ var WIDGET_CSS = `
683
683
  .sg-tile-sym{font-size:16px;font-weight:700;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
684
684
  .sg-tile-chain{font-size:11px;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
685
685
  .sg-tile-empty{color:var(--sg-text-muted);font-size:15px;font-weight:600}
686
+ .sg-funding-glyphs{display:flex;align-items:center;flex:0 0 auto;padding-right:2px}
687
+ .sg-funding-glyphs .sg-tok{box-shadow:0 0 0 2px var(--sg-surface);border-radius:999px}
688
+ .sg-funding-glyphs .sg-tok+.sg-tok{margin-left:-8px}
689
+ .sg-funding-copy{display:flex;flex-direction:column;min-width:0}
686
690
  .sg-ft-arrow{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:30px;height:30px;border-radius:999px;background:var(--sg-bg);border:1px solid var(--sg-border);display:flex;align-items:center;justify-content:center;color:var(--sg-text-muted);z-index:1;pointer-events:none}
687
691
 
688
692
  /* token identity: logo circle + tiny chain badge, with a letters fallback */
@@ -870,9 +874,7 @@ var WIDGET_CSS = `
870
874
  .sg-soonpanel-title{font-size:14px;font-weight:700;margin-bottom:6px}
871
875
  .sg-soonpanel-sub{font-size:12px;color:var(--sg-text-muted);line-height:1.45}
872
876
 
873
- /* compact merchant-receives anchor + click-to-expand "Details" disclosure (merchant-configured;
874
- the payer never edits it). Reveal mirrors the island's grid-rows morph; reduced-motion covered by
875
- the .sg-island guard below (it disables transitions on .sg-island *). */
877
+ /* payout slot \u2014 bank settlement only (the stablecoin destination anchor is never rendered) */
876
878
  .sg-merch-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
877
879
  .sg-merch-lead{min-width:0}
878
880
  /* bank payout destination (settlement="bank") \u2014 sits in the same anchor slot as the stablecoin
@@ -882,19 +884,6 @@ var WIDGET_CSS = `
882
884
  .sg-bank-text{display:flex;flex-direction:column;min-width:0}
883
885
  .sg-bank-name{font-size:16px;font-weight:700;color:var(--sg-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
884
886
  .sg-bank-cur{font-size:12px;color:var(--sg-text-muted)}
885
- .sg-details-toggle{flex:0 0 auto;display:inline-flex;align-items:center;gap:4px;padding:5px 10px;border:1px solid var(--sg-border);border-radius:var(--sg-radius-cta);background:transparent;color:var(--sg-text-muted);font:inherit;font-size:12px;font-weight:600;cursor:pointer;white-space:nowrap;transition:color var(--sg-motion-fast) var(--sg-ease-out-soft),border-color var(--sg-motion-fast) var(--sg-ease-out-soft)}
886
- .sg-details-toggle:hover{color:var(--sg-accent);border-color:var(--sg-accent)}
887
- .sg-details-chev{display:inline-flex;font-size:11px;line-height:1;transition:transform var(--sg-motion-fast) var(--sg-ease-out-soft)}
888
- .sg-details-toggle[data-open="true"] .sg-details-chev{transform:rotate(180deg)}
889
- .sg-details-reveal{display:grid;grid-template-rows:0fr;transition:grid-template-rows var(--sg-motion-base) var(--sg-ease-out-soft)}
890
- .sg-details-reveal[data-open="true"]{grid-template-rows:1fr}
891
- .sg-details-reveal-inner{min-height:0;overflow:hidden}
892
- .sg-details-body{margin-top:12px;padding-top:12px;border-top:1px solid var(--sg-border)}
893
- .sg-details-row{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:4px 0;font-size:12px}
894
- .sg-details-k{flex:0 0 auto;color:var(--sg-text-muted)}
895
- .sg-details-v{min-width:0;text-align:right;color:var(--sg-text)}
896
- .sg-details-addr{word-break:break-all;font-size:11px}
897
- .sg-details-note{margin-top:8px;font-size:11px;color:var(--sg-text-muted);line-height:1.45}
898
887
 
899
888
  /* express-card compaction for the 5-tab method selector (already overflow-x:auto for narrow cells) */
900
889
  .sg-widget[data-sg-express] .sg-tabs{margin:12px 0 8px}
@@ -924,7 +913,7 @@ var WIDGET_CSS = `
924
913
  broken) and shows the static accent dot instead; the label + live region carry the state. */
925
914
  @media (prefers-reduced-motion:reduce){
926
915
  .sg-island,.sg-island *{transition:none!important;animation:none!important}
927
- .sg-island-reveal,.sg-details-reveal{transition:none!important}
916
+ .sg-island-reveal{transition:none!important}
928
917
  .sg-island .sg-spinner{display:none!important}
929
918
  .sg-island .sg-rm-dot{display:inline-block}
930
919
  }
@@ -1172,14 +1161,22 @@ function StepList(props) {
1172
1161
  }
1173
1162
  var SHOW_ROADMAP_METHODS = true;
1174
1163
  var METHODS = [
1175
- { id: "recommended", label: "Recommended", live: true },
1176
1164
  { id: "stablecoin", label: "Stablecoin", live: true },
1177
- { id: "anyasset", label: "Any asset", live: true },
1178
1165
  { id: "card", label: "Card", live: false },
1179
- { id: "bank", label: "Bank", live: false }
1166
+ { id: "bank", label: "Bank account", live: false }
1180
1167
  ];
1181
1168
  function isLiveMethod(m) {
1182
- return m === "recommended" || m === "stablecoin" || m === "anyasset";
1169
+ return m === "stablecoin";
1170
+ }
1171
+ function balanceRank(raw, decimals) {
1172
+ if (raw == null) return 0n;
1173
+ try {
1174
+ const d = Number.isFinite(Number(decimals)) ? Math.max(0, Math.trunc(Number(decimals))) : 18;
1175
+ const v = BigInt(raw);
1176
+ return d <= 18 ? v * 10n ** BigInt(18 - d) : v / 10n ** BigInt(d - 18);
1177
+ } catch {
1178
+ return 0n;
1179
+ }
1183
1180
  }
1184
1181
  function MethodTabs(props) {
1185
1182
  const showRoadmap = props.showRoadmap ?? SHOW_ROADMAP_METHODS;
@@ -1326,6 +1323,31 @@ function TokenTile(props) {
1326
1323
  /* @__PURE__ */ jsx("span", { className: "sg-tile-main", children: glyph })
1327
1324
  ] });
1328
1325
  }
1326
+ function FundingTile(props) {
1327
+ const symbols = props.assets.map((asset) => asset.symbol);
1328
+ const summary = props.loading ? "Checking wallet assets\u2026" : symbols.length ? symbols.join(", ") : "No payable balance";
1329
+ const detail = props.loading ? "Finding what you can pay with" : symbols.length ? `${symbols.length} wallet asset${symbols.length === 1 ? "" : "s"} available` : "Open to review funding options";
1330
+ const ariaLabel = `${props.label}: ${props.loading ? "checking wallet assets" : symbols.length ? symbols.join(", ") : "no payable balance"}`;
1331
+ const glyphs = props.loading ? /* @__PURE__ */ jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsx("span", { className: "sg-tok-fb", children: "\u2026" }) }) : symbols.length ? /* @__PURE__ */ jsx("span", { className: "sg-funding-glyphs", "aria-hidden": "true", children: props.assets.slice(0, 3).map((asset) => /* @__PURE__ */ jsx(TokenGlyph, { symbol: asset.symbol, logoUrl: asset.logoUrl, size: "sm" }, asset.symbol)) }) : /* @__PURE__ */ jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsx("span", { className: "sg-tok-fb", children: "?" }) });
1332
+ const main = /* @__PURE__ */ jsxs(Fragment, { children: [
1333
+ glyphs,
1334
+ /* @__PURE__ */ jsxs("span", { className: "sg-funding-copy", children: [
1335
+ /* @__PURE__ */ jsx("span", { className: "sg-tile-sym", children: summary }),
1336
+ /* @__PURE__ */ jsx("span", { className: "sg-tile-chain", children: detail })
1337
+ ] })
1338
+ ] });
1339
+ if (props.row) {
1340
+ 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: [
1341
+ /* @__PURE__ */ jsx("span", { className: "sg-tile-label", children: props.label }),
1342
+ /* @__PURE__ */ jsx("span", { className: "sg-tile-rowmain", children: main }),
1343
+ /* @__PURE__ */ jsx("span", { className: "sg-tile-chev", children: /* @__PURE__ */ jsx(ChevronGlyph, {}) })
1344
+ ] });
1345
+ }
1346
+ return /* @__PURE__ */ jsxs("button", { type: "button", ref: props.btnRef, className: "sg-tile", disabled: props.disabled, onClick: props.onClick, "aria-label": ariaLabel, children: [
1347
+ /* @__PURE__ */ jsx("span", { className: "sg-tile-label", children: props.label }),
1348
+ /* @__PURE__ */ jsx("span", { className: "sg-tile-main", children: main })
1349
+ ] });
1350
+ }
1329
1351
  function ChainChip(props) {
1330
1352
  const [broken, setBroken] = useState(false);
1331
1353
  const logo = props.chain?.logoUrl;
@@ -1654,55 +1676,6 @@ function forgetIdentity(account) {
1654
1676
  var addrEq = (a, b) => String(a || "").toLowerCase() === String(b || "").toLowerCase();
1655
1677
  var chainName = (id) => id != null ? CHAIN_LABELS[id] || `Chain ${id}` : "";
1656
1678
  var STABLES = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
1657
- function MerchantReceives(props) {
1658
- const [open, setOpen] = useState(false);
1659
- const bodyId = useId();
1660
- const hasDetails = Boolean(props.recipient);
1661
- return /* @__PURE__ */ jsxs("div", { className: "sg-panel sg-merch", children: [
1662
- /* @__PURE__ */ jsxs("div", { className: "sg-merch-head", children: [
1663
- /* @__PURE__ */ jsxs("div", { className: "sg-merch-lead", children: [
1664
- /* @__PURE__ */ jsx("div", { className: "sg-label", children: "Merchant receives exactly" }),
1665
- /* @__PURE__ */ jsxs("div", { className: "sg-anchor sg-mono", children: [
1666
- props.amount,
1667
- " ",
1668
- props.asset
1669
- ] })
1670
- ] }),
1671
- hasDetails ? /* @__PURE__ */ jsxs(
1672
- "button",
1673
- {
1674
- type: "button",
1675
- className: "sg-details-toggle",
1676
- "data-open": open,
1677
- "aria-expanded": open,
1678
- "aria-controls": bodyId,
1679
- onClick: () => setOpen((o) => !o),
1680
- children: [
1681
- "Details",
1682
- /* @__PURE__ */ jsx("span", { className: "sg-details-chev", "aria-hidden": "true", children: "\u2304" })
1683
- ]
1684
- }
1685
- ) : null
1686
- ] }),
1687
- hasDetails ? /* @__PURE__ */ jsx("div", { className: "sg-details-reveal", "data-open": open, children: /* @__PURE__ */ jsx("div", { className: "sg-details-reveal-inner", children: /* @__PURE__ */ jsxs("div", { className: "sg-details-body", id: bodyId, children: [
1688
- /* @__PURE__ */ jsxs("div", { className: "sg-details-row", children: [
1689
- /* @__PURE__ */ jsx("span", { className: "sg-details-k", children: "Network" }),
1690
- /* @__PURE__ */ jsx("span", { className: "sg-details-v", children: chainName(props.chainId) })
1691
- ] }),
1692
- /* @__PURE__ */ jsxs("div", { className: "sg-details-row", children: [
1693
- /* @__PURE__ */ jsx("span", { className: "sg-details-k", children: "Recipient" }),
1694
- /* @__PURE__ */ jsx("span", { className: "sg-details-v sg-mono sg-details-addr", children: props.recipient })
1695
- ] }),
1696
- /* @__PURE__ */ jsxs("div", { className: "sg-details-note", children: [
1697
- "Settled like a card \u2014 the merchant always receives exactly ",
1698
- props.amount,
1699
- " ",
1700
- props.asset,
1701
- ". You pay a little more to cover the network cost."
1702
- ] })
1703
- ] }) }) }) : null
1704
- ] });
1705
- }
1706
1679
  function BankGlyph() {
1707
1680
  return /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M3 10h18M5 10v8M10 10v8M14 10v8M19 10v8M3 19h18M12 3 3 8h18Z" }) });
1708
1681
  }
@@ -1905,7 +1878,7 @@ function PaymentIsland(props) {
1905
1878
  onSuccess: config.onSuccess,
1906
1879
  onError: config.onError
1907
1880
  });
1908
- const [method, setMethod] = useState("recommended");
1881
+ const [method, setMethod] = useState("stablecoin");
1909
1882
  const parked = isPay && !isLiveMethod(method);
1910
1883
  const fundingSet = useMemo(
1911
1884
  () => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null,
@@ -1931,7 +1904,13 @@ function PaymentIsland(props) {
1931
1904
  }),
1932
1905
  [visibleRoutes, holdings.balances]
1933
1906
  );
1934
- const held = useMemo(() => annotated.filter((a) => a.affordable === true), [annotated]);
1907
+ const held = useMemo(
1908
+ () => annotated.filter((a) => a.affordable === true).sort((a, b) => {
1909
+ const d = balanceRank(b.balance?.raw, b.route.source.decimals) - balanceRank(a.balance?.raw, a.route.source.decimals);
1910
+ return d > 0n ? 1 : d < 0n ? -1 : 0;
1911
+ }),
1912
+ [annotated]
1913
+ );
1935
1914
  const heldIds = useMemo(() => new Set(held.map((a) => a.route.id)), [held]);
1936
1915
  const optionStates = useMemo(() => {
1937
1916
  const map = {};
@@ -2012,6 +1991,18 @@ function PaymentIsland(props) {
2012
1991
  const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
2013
1992
  return chains.filter((c) => ids.has(Number(c.chainId)));
2014
1993
  }, [chains, fundingTokens]);
1994
+ const payableAssets = useMemo(() => {
1995
+ const seen = /* @__PURE__ */ new Set();
1996
+ const list = [];
1997
+ for (const { route } of held) {
1998
+ const symbol = symbolKey(route.source.asset);
1999
+ if (seen.has(symbol)) continue;
2000
+ seen.add(symbol);
2001
+ const token = registryTokens.find((t) => Number(t.chainId) === route.source.chainId && addrEq(t.address, route.source.tokenAddress));
2002
+ list.push({ symbol: route.source.asset, logoUrl: token?.logoUrl });
2003
+ }
2004
+ return list;
2005
+ }, [held, registryTokens]);
2015
2006
  const userPicked = useRef(false);
2016
2007
  const selectRoute = useCallback(
2017
2008
  (id) => {
@@ -2114,15 +2105,11 @@ function PaymentIsland(props) {
2114
2105
  const submitting = flow.status === "submitting";
2115
2106
  const sel = flow.selected;
2116
2107
  const selectedVisible = Boolean(sel && visibleRoutes.some((r) => r.id === sel.id));
2117
- const selPick = sel && selectedVisible ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null;
2118
- const selToken = sel ? registryTokens.find((t) => Number(t.chainId) === sel.source.chainId && addrEq(t.address, sel.source.tokenAddress)) ?? null : null;
2119
2108
  const selBal = sel ? holdings.balances[balanceKey(sel.source.chainId, sel.source.tokenAddress)] : void 0;
2120
2109
  const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
2121
2110
  const mismatch = flow.status === "error" && flow.verdict?.status === "mismatch";
2122
2111
  const destAsset = isPay ? props.toAsset : exToAsset;
2123
- const destChainId = isPay ? props.toChainId : exToChainId;
2124
- const anchorLabel = isPay ? "Merchant receives exactly" : "You receive (estimated)";
2125
- const anchorAmount = isPay ? props.amount : sel?.receive.amount ?? (flow.status === "loading" ? "\u2026" : "\u2014");
2112
+ const anchorAmount = sel?.receive.amount ?? (flow.status === "loading" ? "\u2026" : "\u2014");
2126
2113
  const successAmount = isPay ? props.amount : sel?.receive.amount;
2127
2114
  const money = props.moneyDisplay ?? (isPay ? props.amount ? `${props.amount} ${props.toAsset}` : "" : exAmount ? `${exAmount} ${exFromAsset ?? ""}`.trim() : "");
2128
2115
  const verb = isPay ? { present: "Pay", gerund: "Paying", past: "Paid" } : kind === "swap" ? { present: "Swap", gerund: "Swapping", past: "Swapped" } : { present: "Exchange", gerund: "Exchanging", past: "Exchanged" };
@@ -2244,7 +2231,7 @@ function PaymentIsland(props) {
2244
2231
  } else if (!wallet.account) {
2245
2232
  body = /* @__PURE__ */ jsxs(Fragment, { children: [
2246
2233
  /* @__PURE__ */ jsx(IdentityLine, { account: null, email: identity?.email }),
2247
- isPay ? /* @__PURE__ */ jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx(MerchantReceives, { amount: props.amount, asset: destAsset, chainId: destChainId, recipient: props.recipient }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2234
+ isPay ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
2248
2235
  exchangeControls,
2249
2236
  /* @__PURE__ */ jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
2250
2237
  /* @__PURE__ */ jsx("div", { className: "sg-label", children: "You receive (estimated)" }),
@@ -2315,10 +2302,10 @@ function PaymentIsland(props) {
2315
2302
  const walletError = flow.status === "error" && flow.steps.length > 0;
2316
2303
  body = /* @__PURE__ */ jsxs(Fragment, { children: [
2317
2304
  /* @__PURE__ */ jsx(IdentityLine, { account: wallet.account, email: identity?.email }),
2318
- isPay ? /* @__PURE__ */ jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx(MerchantReceives, { amount: props.amount, asset: destAsset, chainId: destChainId, recipient: props.recipient }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2305
+ isPay ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
2319
2306
  exchangeControls,
2320
2307
  /* @__PURE__ */ jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
2321
- /* @__PURE__ */ jsx("div", { className: "sg-label", children: anchorLabel }),
2308
+ /* @__PURE__ */ jsx("div", { className: "sg-label", children: "You receive (estimated)" }),
2322
2309
  /* @__PURE__ */ jsxs("div", { className: "sg-anchor sg-mono", children: [
2323
2310
  anchorAmount,
2324
2311
  " ",
@@ -2341,7 +2328,18 @@ function PaymentIsland(props) {
2341
2328
  /* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(Button, { disabled: true, children: method === "card" ? "Card \u2014 coming soon" : "Bank \u2014 coming soon" }) })
2342
2329
  ] })
2343
2330
  ) : /* @__PURE__ */ jsxs(Fragment, { children: [
2344
- isPay ? /* @__PURE__ */ jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx(TokenTile, { row: true, label: "Pay with", pick: selPick, token: selToken, disabled: submitting || !visibleRoutes.length, btnRef: methodRowRef, onClick: () => setView("select") }) }) : null,
2331
+ isPay ? /* @__PURE__ */ jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx(
2332
+ FundingTile,
2333
+ {
2334
+ row: true,
2335
+ label: "Pay with",
2336
+ assets: payableAssets,
2337
+ loading: flow.status === "loading" || holdings.loading,
2338
+ disabled: submitting || !visibleRoutes.length,
2339
+ btnRef: methodRowRef,
2340
+ onClick: () => setView("select")
2341
+ }
2342
+ ) }) : null,
2345
2343
  loading ? /* @__PURE__ */ jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
2346
2344
  /* @__PURE__ */ jsx("div", { className: "sg-skel" }),
2347
2345
  /* @__PURE__ */ jsxs("div", { className: "sg-muted", style: { fontSize: 13 }, children: [
@@ -2425,7 +2423,7 @@ function StableGeniePay(props) {
2425
2423
  onSuccess: config.onSuccess,
2426
2424
  onError: config.onError
2427
2425
  });
2428
- const [method, setMethod] = useState("recommended");
2426
+ const [method, setMethod] = useState("stablecoin");
2429
2427
  const fundingSet = useMemo(
2430
2428
  () => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null,
2431
2429
  [props.fundingAssets]
@@ -2450,7 +2448,13 @@ function StableGeniePay(props) {
2450
2448
  }),
2451
2449
  [visibleRoutes, holdings.balances]
2452
2450
  );
2453
- const held = useMemo(() => annotated.filter((a) => a.affordable === true), [annotated]);
2451
+ const held = useMemo(
2452
+ () => annotated.filter((a) => a.affordable === true).sort((a, b) => {
2453
+ const d = balanceRank(b.balance?.raw, b.route.source.decimals) - balanceRank(a.balance?.raw, a.route.source.decimals);
2454
+ return d > 0n ? 1 : d < 0n ? -1 : 0;
2455
+ }),
2456
+ [annotated]
2457
+ );
2454
2458
  const heldIds = useMemo(() => new Set(held.map((a) => a.route.id)), [held]);
2455
2459
  const scannedEmpty = !holdings.loading && Object.keys(holdings.balances).length > 0 && held.length === 0;
2456
2460
  const optionStates = useMemo(() => {
@@ -2510,6 +2514,18 @@ function StableGeniePay(props) {
2510
2514
  const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
2511
2515
  return chains.filter((c) => ids.has(Number(c.chainId)));
2512
2516
  }, [chains, fundingTokens]);
2517
+ const payableAssets = useMemo(() => {
2518
+ const seen = /* @__PURE__ */ new Set();
2519
+ const list = [];
2520
+ for (const { route } of held) {
2521
+ const symbol = symbolKey(route.source.asset);
2522
+ if (seen.has(symbol)) continue;
2523
+ seen.add(symbol);
2524
+ const token = registryTokens.find((t) => Number(t.chainId) === route.source.chainId && addrEq2(t.address, route.source.tokenAddress));
2525
+ list.push({ symbol: route.source.asset, logoUrl: token?.logoUrl });
2526
+ }
2527
+ return list;
2528
+ }, [held, registryTokens]);
2513
2529
  const userPicked = useRef(false);
2514
2530
  const selectRoute = useCallback(
2515
2531
  (id) => {
@@ -2553,15 +2569,15 @@ function StableGeniePay(props) {
2553
2569
  if (r) selectRoute(r.id);
2554
2570
  closeSelector();
2555
2571
  };
2556
- const chainName2 = CHAIN_LABELS[props.toChainId] || `Chain ${props.toChainId}`;
2557
2572
  const parked = !isLiveMethod(method);
2558
2573
  const submitting = flow.status === "submitting";
2559
2574
  const sel = flow.selected;
2560
2575
  const selectedVisible = Boolean(sel && visibleRoutes.some((r) => r.id === sel.id));
2561
- const selPick = sel && selectedVisible ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null;
2562
- const selToken = sel ? registryTokens.find((t) => Number(t.chainId) === sel.source.chainId && addrEq2(t.address, sel.source.tokenAddress)) ?? null : null;
2563
2576
  const selBal = sel ? holdings.balances[balanceKey(sel.source.chainId, sel.source.tokenAddress)] : void 0;
2564
- const why = parked ? "" : sel && selectedVisible ? sel.state === "DIRECT" ? `Direct ${sel.source.asset} transfer on ${CHAIN_LABELS[sel.source.chainId] || sel.source.chainName} \xB7 lowest cost` : `Routed through ZeroDelta \u2014 the merchant still receives exactly ${props.amount} ${props.toAsset}` : method === "stablecoin" ? "Pay with USDC, USDT, or USDE from your wallet." : method === "anyasset" ? "Pay with any supported asset \u2014 we route it to exactly what the merchant needs." : "Best route \xB7 picked for you";
2577
+ const why = parked ? "" : sel && selectedVisible ? sel.state === "DIRECT" ? `Direct ${sel.source.asset} transfer on ${CHAIN_LABELS[sel.source.chainId] || sel.source.chainName} \xB7 lowest cost` : (
2578
+ // Deliberately does NOT restate the destination amount — that is merchant config, not a payer fact.
2579
+ `Routed through ZeroDelta \xB7 the extra covers the network cost`
2580
+ ) : "Pay with USDC, USDT, or USDE from your wallet.";
2565
2581
  const comingSoon = method === "card" ? "Card payments are coming soon. Today StableGenie pays from your connected wallet." : "Bank transfers are coming soon.";
2566
2582
  const payLabel = parked ? method === "card" ? "Card \u2014 coming soon" : "Bank \u2014 coming soon" : submitting ? "Paying\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall ? flow.nativeShortfall : sel && selectedVisible ? `Pay ${sel.source.payAmount} ${sel.source.asset}` : "Pay";
2567
2583
  const walletSlot = wallet.account ? /* @__PURE__ */ jsxs("div", { className: "sg-head-tools", children: [
@@ -2572,82 +2588,66 @@ function StableGeniePay(props) {
2572
2588
  ] })
2573
2589
  ] }) : void 0;
2574
2590
  if (props.variant === "pill") return /* @__PURE__ */ jsx(PaymentIsland, { kind: "pay", ...props });
2575
- return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, children: hist && wallet.account ? /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsx(TokenSelect, { title: "Pay with", chains: fundingChains, tokens: fundingTokens, balances: holdings.balances, optionStates, onBack: closeSelector, onPick: pickFunding }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2576
- /* @__PURE__ */ jsxs("div", { className: "sg-panel", children: [
2577
- /* @__PURE__ */ jsx("div", { className: "sg-label", children: "Merchant receives exactly" }),
2578
- /* @__PURE__ */ jsxs("div", { className: "sg-anchor sg-mono", children: [
2591
+ return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, children: hist && wallet.account ? /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsx(TokenSelect, { title: "Pay with", chains: fundingChains, tokens: fundingTokens, balances: holdings.balances, optionStates, onBack: closeSelector, onPick: pickFunding }) : /* @__PURE__ */ jsx(Fragment, { children: !wallet.account ? /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
2592
+ /* @__PURE__ */ jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }),
2593
+ wallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
2594
+ ] }) : flow.status === "success" || flow.status === "pending" ? /* @__PURE__ */ jsxs(Fragment, { children: [
2595
+ /* @__PURE__ */ jsxs("div", { className: "sg-success", children: [
2596
+ /* @__PURE__ */ jsx("div", { className: "sg-success-check", "data-pending": flow.verdict?.status !== "confirmed", children: /* @__PURE__ */ jsx(CheckGlyph3, {}) }),
2597
+ /* @__PURE__ */ jsxs("div", { className: "sg-success-amt sg-mono", children: [
2579
2598
  props.amount,
2580
2599
  " ",
2581
2600
  props.toAsset
2582
2601
  ] }),
2583
- /* @__PURE__ */ jsxs("div", { className: "sg-anchor-sub", children: [
2584
- "on ",
2585
- chainName2,
2602
+ /* @__PURE__ */ jsxs("div", { className: "sg-success-sub", children: [
2603
+ flow.verdict?.status === "confirmed" ? "Confirmed on-chain" : "Submitted \u2014 awaiting confirmation",
2586
2604
  " \xB7 ",
2587
2605
  shortAddress(props.recipient)
2588
2606
  ] })
2589
2607
  ] }),
2590
- !wallet.account ? /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
2591
- /* @__PURE__ */ jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }),
2592
- wallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
2593
- ] }) : flow.status === "success" || flow.status === "pending" ? /* @__PURE__ */ jsxs(Fragment, { children: [
2594
- /* @__PURE__ */ jsxs("div", { className: "sg-success", children: [
2595
- /* @__PURE__ */ jsx("div", { className: "sg-success-check", "data-pending": flow.verdict?.status !== "confirmed", children: /* @__PURE__ */ jsx(CheckGlyph3, {}) }),
2596
- /* @__PURE__ */ jsxs("div", { className: "sg-success-amt sg-mono", children: [
2597
- props.amount,
2608
+ lastTxOwned ? /* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
2609
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2610
+ /* @__PURE__ */ jsx(MethodTabs, { value: method, onChange: setMethod }),
2611
+ parked ? /* @__PURE__ */ jsx(StatusPanel, { children: comingSoon }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2612
+ /* @__PURE__ */ jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx(
2613
+ FundingTile,
2614
+ {
2615
+ label: "Pay with",
2616
+ assets: payableAssets,
2617
+ loading: flow.status === "loading" || holdings.loading,
2618
+ disabled: submitting || !visibleRoutes.length,
2619
+ btnRef: payTileRef,
2620
+ onClick: () => setView("select")
2621
+ }
2622
+ ) }),
2623
+ flow.status === "loading" ? /* @__PURE__ */ jsxs("div", { className: "sg-route", style: { marginTop: 12 }, children: [
2624
+ /* @__PURE__ */ jsx("div", { className: "sg-skel" }),
2625
+ /* @__PURE__ */ jsxs("div", { className: "sg-muted", style: { fontSize: 13 }, children: [
2626
+ /* @__PURE__ */ jsx("span", { className: "sg-spinner" }),
2627
+ " Finding the best way to pay\u2026"
2628
+ ] })
2629
+ ] }) : null,
2630
+ flow.status === "error" && flow.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: flow.error }) : null,
2631
+ sel && selectedVisible && flow.status !== "loading" ? /* @__PURE__ */ jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
2632
+ /* @__PURE__ */ jsx("div", { className: "sg-label", children: "You pay" }),
2633
+ /* @__PURE__ */ jsxs("div", { className: "sg-anchor sg-mono", children: [
2634
+ sel.source.payAmount,
2598
2635
  " ",
2599
- props.toAsset
2636
+ sel.source.asset
2600
2637
  ] }),
2601
- /* @__PURE__ */ jsxs("div", { className: "sg-success-sub", children: [
2602
- flow.verdict?.status === "confirmed" ? "Confirmed on-chain" : "Submitted \u2014 awaiting confirmation",
2603
- " \xB7 ",
2604
- shortAddress(props.recipient)
2638
+ /* @__PURE__ */ jsxs("div", { className: "sg-anchor-sub", children: [
2639
+ "on ",
2640
+ CHAIN_LABELS[sel.source.chainId] || sel.source.chainName,
2641
+ selBal ? ` \xB7 balance ${selBal.formatted}` : ""
2605
2642
  ] })
2606
- ] }),
2607
- lastTxOwned ? /* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
2608
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2609
- /* @__PURE__ */ jsx(MethodTabs, { value: method, onChange: setMethod }),
2610
- parked ? /* @__PURE__ */ jsx(StatusPanel, { children: comingSoon }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2611
- /* @__PURE__ */ jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx(
2612
- TokenTile,
2613
- {
2614
- label: "Pay with",
2615
- pick: selPick,
2616
- token: selToken,
2617
- disabled: submitting || !visibleRoutes.length,
2618
- btnRef: payTileRef,
2619
- onClick: () => setView("select")
2620
- }
2621
- ) }),
2622
- flow.status === "loading" ? /* @__PURE__ */ jsxs("div", { className: "sg-route", style: { marginTop: 12 }, children: [
2623
- /* @__PURE__ */ jsx("div", { className: "sg-skel" }),
2624
- /* @__PURE__ */ jsxs("div", { className: "sg-muted", style: { fontSize: 13 }, children: [
2625
- /* @__PURE__ */ jsx("span", { className: "sg-spinner" }),
2626
- " Finding the best way to pay\u2026"
2627
- ] })
2628
- ] }) : null,
2629
- flow.status === "error" && flow.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: flow.error }) : null,
2630
- sel && selectedVisible && flow.status !== "loading" ? /* @__PURE__ */ jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
2631
- /* @__PURE__ */ jsx("div", { className: "sg-label", children: "You pay" }),
2632
- /* @__PURE__ */ jsxs("div", { className: "sg-anchor sg-mono", children: [
2633
- sel.source.payAmount,
2634
- " ",
2635
- sel.source.asset
2636
- ] }),
2637
- /* @__PURE__ */ jsxs("div", { className: "sg-anchor-sub", children: [
2638
- "on ",
2639
- CHAIN_LABELS[sel.source.chainId] || sel.source.chainName,
2640
- selBal ? ` \xB7 balance ${selBal.formatted}` : ""
2641
- ] })
2642
- ] }) : null,
2643
- why ? /* @__PURE__ */ jsx("div", { className: "sg-why", style: { marginTop: 10 }, children: why }) : null,
2644
- scannedEmpty ? /* @__PURE__ */ jsx("div", { className: "sg-note", children: "None of your balances can cover this yet \u2014 pick a different asset to fund with." }) : null,
2645
- flow.status === "ready" && !visibleRoutes.length ? /* @__PURE__ */ jsx(StatusPanel, { children: "No funding route matches the accepted assets for this payment." }) : null
2646
- ] }),
2647
- submitting ? /* @__PURE__ */ jsx(StepList, { steps: flow.steps }) : null,
2648
- /* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(Button, { onClick: parked || !selectedVisible ? void 0 : flow.submit, busy: submitting, disabled: parked || !selectedVisible || flow.insufficient || !!flow.nativeShortfall || flow.status === "loading", children: payLabel }) })
2649
- ] })
2650
- ] }) });
2643
+ ] }) : null,
2644
+ why ? /* @__PURE__ */ jsx("div", { className: "sg-why", style: { marginTop: 10 }, children: why }) : null,
2645
+ scannedEmpty ? /* @__PURE__ */ jsx("div", { className: "sg-note", children: "None of your balances can cover this yet \u2014 pick a different asset to fund with." }) : null,
2646
+ flow.status === "ready" && !visibleRoutes.length ? /* @__PURE__ */ jsx(StatusPanel, { children: "No funding route matches the accepted assets for this payment." }) : null
2647
+ ] }),
2648
+ submitting ? /* @__PURE__ */ jsx(StepList, { steps: flow.steps }) : null,
2649
+ /* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(Button, { onClick: parked || !selectedVisible ? void 0 : flow.submit, busy: submitting, disabled: parked || !selectedVisible || flow.insufficient || !!flow.nativeShortfall || flow.status === "loading", children: payLabel }) })
2650
+ ] }) }) });
2651
2651
  }
2652
2652
  var chainOptions = SUPPORTED_CHAINS.map((c) => ({ value: c, label: CHAIN_LABELS[c] || `Chain ${c}` }));
2653
2653
  var assetOptions = SUPPORTED_ASSETS2.map((a) => ({ value: a, label: a }));