@glacislabs/stablegenie-zerodelta 3.0.0 → 3.0.2

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/index.cjs CHANGED
@@ -872,6 +872,16 @@ function createApiClient(cfg) {
872
872
  }
873
873
 
874
874
  // src/core/plan.ts
875
+ function optionBalanceKey(option) {
876
+ return `${Number(option.chainId)}:${String(option.address || "").toLowerCase()}`;
877
+ }
878
+ function hasPositiveBalance(option, balances) {
879
+ try {
880
+ return BigInt(balances[optionBalanceKey(option)]?.raw ?? "0") > 0n;
881
+ } catch {
882
+ return false;
883
+ }
884
+ }
875
885
  function validateDestination(destination) {
876
886
  assertAddress(destination.address, "Destination address");
877
887
  const chainId = Number(destination.chainId);
@@ -887,7 +897,7 @@ function planErrorSummary(errors) {
887
897
  const unique = [...new Set(errors.map((error) => error?.message || String(error)).filter(Boolean))].slice(0, 3);
888
898
  return unique.length ? unique.join(" | ") : "No ZeroDelta route is currently available for this payment.";
889
899
  }
890
- async function fetchPaymentPlan(api, request, payer, wallet = {}) {
900
+ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances) {
891
901
  validateDestination(request);
892
902
  assertAddress(payer, "Payer wallet");
893
903
  const [chains, tokens, routes] = await Promise.all([api.fetchChains(), api.fetchTokens(), api.fetchRoutes()]);
@@ -898,6 +908,7 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}) {
898
908
  };
899
909
  const destinationToken = findToken(tokens, destination.chainId, destination.asset);
900
910
  if (!destinationToken) throw new Error(`${destination.asset} is not enabled on ${chainNameOf(destination.chainId, chains)}.`);
911
+ const allowedFunding = wallet.fundingAssets?.length ? new Set(wallet.fundingAssets.map(symbolKey)) : null;
901
912
  const options = buildPayOptions({
902
913
  invoiceAsset: destination.asset,
903
914
  invoiceChainId: destination.chainId,
@@ -905,14 +916,25 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}) {
905
916
  routes,
906
917
  chains,
907
918
  walletChainId: wallet?.chainId
908
- });
919
+ }).filter((option) => option.direct || !allowedFunding || allowedFunding.has(option.symbolKey));
909
920
  if (!options.length) throw new Error(`No enabled ZeroDelta funding assets can settle ${destination.asset} on ${chainNameOf(destination.chainId, chains)}.`);
921
+ const balanceTargets = [];
922
+ const seenTargets = /* @__PURE__ */ new Set();
923
+ for (const option of options) {
924
+ const key = optionBalanceKey(option);
925
+ if (seenTargets.has(key)) continue;
926
+ seenTargets.add(key);
927
+ balanceTargets.push({ chainId: option.chainId, tokenAddress: option.address, decimals: option.decimals });
928
+ }
929
+ const walletBalances = readBalances ? await readBalances(payer, balanceTargets).catch(() => ({})) : {};
910
930
  const candidates = options.filter((option) => option.direct);
931
+ const heldOptions = options.filter((option) => !option.direct && hasPositiveBalance(option, walletBalances));
932
+ const heldKeys = new Set(heldOptions.map(optionBalanceKey));
911
933
  const seenChains = /* @__PURE__ */ new Set();
912
934
  const perChainBest = [];
913
935
  const leftovers = [];
914
936
  for (const option of options) {
915
- if (option.direct) continue;
937
+ if (option.direct || heldKeys.has(optionBalanceKey(option))) continue;
916
938
  if (seenChains.has(option.chainId)) {
917
939
  leftovers.push(option);
918
940
  } else {
@@ -920,7 +942,7 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}) {
920
942
  perChainBest.push(option);
921
943
  }
922
944
  }
923
- for (const option of [...perChainBest, ...leftovers].slice(0, MAX_QUOTE_CANDIDATES)) {
945
+ for (const option of [...heldOptions, ...perChainBest, ...leftovers].slice(0, MAX_QUOTE_CANDIDATES)) {
924
946
  candidates.push(option);
925
947
  }
926
948
  const routeErrors = [];
@@ -955,6 +977,8 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}) {
955
977
  expiresAt: new Date(Date.now() + 2 * 60 * 1e3).toISOString(),
956
978
  apiBase: api.apiBase,
957
979
  routes: routesBuilt,
980
+ fundingBalances: walletBalances,
981
+ fundingAccount: payer.toLowerCase(),
958
982
  destination: {
959
983
  asset: destinationToken.symbol,
960
984
  chainId: destination.chainId,
@@ -1183,6 +1207,23 @@ function createVerifier(api, fetchImpl, rpcOverrides = {}) {
1183
1207
  const json = await response.json();
1184
1208
  return json?.result ?? null;
1185
1209
  }
1210
+ async function rpcBatchCall(rpcUrl, calls) {
1211
+ const response = await fetchImpl(rpcUrl, {
1212
+ method: "POST",
1213
+ headers: { "Content-Type": "application/json" },
1214
+ body: JSON.stringify(calls.map((call, index) => ({ jsonrpc: "2.0", id: index + 1, ...call }))),
1215
+ signal: AbortSignal.timeout(TX_VERIFY_FETCH_MS)
1216
+ });
1217
+ if (!response.ok) throw new Error(`RPC ${response.status}`);
1218
+ const json = await response.json();
1219
+ if (!Array.isArray(json)) throw new Error("RPC batch unsupported");
1220
+ const results = /* @__PURE__ */ new Map();
1221
+ for (const item of json) {
1222
+ const id = Number(item?.id);
1223
+ if (Number.isInteger(id) && Object.hasOwn(item || {}, "result")) results.set(id, item.result);
1224
+ }
1225
+ return results;
1226
+ }
1186
1227
  async function payerNonceBaseline(chainId, account) {
1187
1228
  if (!isAddress(account)) return null;
1188
1229
  const rpcUrl = await chainRpcUrl(chainId);
@@ -1249,25 +1290,54 @@ function createVerifier(api, fetchImpl, rpcOverrides = {}) {
1249
1290
  const out = {};
1250
1291
  if (!isAddress(account) || !Array.isArray(targets) || !targets.length) return out;
1251
1292
  const owner = normalizeAddress(account);
1252
- const CONCURRENCY = 6;
1253
- let cursor = 0;
1254
- async function worker() {
1255
- while (cursor < targets.length) {
1256
- const target = targets[cursor++];
1257
- if (!target || !isAddress(target.tokenAddress)) continue;
1258
- const key = `${Number(target.chainId)}:${String(target.tokenAddress).toLowerCase()}`;
1259
- try {
1260
- const rpcUrl = await balanceRpcUrl(Number(target.chainId));
1261
- if (!rpcUrl) continue;
1262
- const hex = await rpcCall(rpcUrl, "eth_call", [{ to: normalizeAddress(target.tokenAddress), data: encodeBalanceOf(owner) }, "latest"]);
1263
- if (typeof hex !== "string" || !/^0x[0-9a-fA-F]*$/.test(hex)) continue;
1264
- const raw = BigInt(hex || "0x0").toString();
1265
- out[key] = { raw, formatted: formatUnits(raw, Number(target.decimals)) };
1266
- } catch {
1267
- }
1293
+ const groups = /* @__PURE__ */ new Map();
1294
+ const seen = /* @__PURE__ */ new Set();
1295
+ for (const target of targets) {
1296
+ if (!target || !isAddress(target.tokenAddress)) continue;
1297
+ const key = `${Number(target.chainId)}:${String(target.tokenAddress).toLowerCase()}`;
1298
+ if (seen.has(key)) continue;
1299
+ seen.add(key);
1300
+ const chainId = Number(target.chainId);
1301
+ const group = groups.get(chainId) || [];
1302
+ group.push(target);
1303
+ groups.set(chainId, group);
1304
+ }
1305
+ function record(target, hex) {
1306
+ if (typeof hex !== "string" || !/^0x[0-9a-fA-F]*$/.test(hex)) return false;
1307
+ const raw = BigInt(hex || "0x0").toString();
1308
+ const key = `${Number(target.chainId)}:${String(target.tokenAddress).toLowerCase()}`;
1309
+ out[key] = { raw, formatted: formatUnits(raw, Number(target.decimals)) };
1310
+ return true;
1311
+ }
1312
+ async function readOne(rpcUrl, target) {
1313
+ try {
1314
+ const hex = await rpcCall(rpcUrl, "eth_call", [{ to: normalizeAddress(target.tokenAddress), data: encodeBalanceOf(owner) }, "latest"]);
1315
+ record(target, hex);
1316
+ } catch {
1268
1317
  }
1269
1318
  }
1270
- await Promise.all(Array.from({ length: Math.min(CONCURRENCY, targets.length) }, () => worker()));
1319
+ async function readGroup(chainId, group) {
1320
+ const rpcUrl = await balanceRpcUrl(chainId).catch(() => "");
1321
+ if (!rpcUrl) return;
1322
+ if (group.length === 1) return readOne(rpcUrl, group[0]);
1323
+ try {
1324
+ const results = await rpcBatchCall(
1325
+ rpcUrl,
1326
+ group.map((target) => ({
1327
+ method: "eth_call",
1328
+ params: [{ to: normalizeAddress(target.tokenAddress), data: encodeBalanceOf(owner) }, "latest"]
1329
+ }))
1330
+ );
1331
+ const missing = [];
1332
+ group.forEach((target, index) => {
1333
+ if (!record(target, results.get(index + 1))) missing.push(target);
1334
+ });
1335
+ await Promise.all(missing.map((target) => readOne(rpcUrl, target)));
1336
+ } catch {
1337
+ await Promise.all(group.map((target) => readOne(rpcUrl, target)));
1338
+ }
1339
+ }
1340
+ await Promise.all([...groups.entries()].map(([chainId, group]) => readGroup(chainId, group)));
1271
1341
  return out;
1272
1342
  }
1273
1343
  async function readNativeBalance(chainId, account) {
@@ -1369,7 +1439,7 @@ function createEngine(config = {}) {
1369
1439
  fetchTokens: api.fetchTokens,
1370
1440
  fetchRoutes: api.fetchRoutes,
1371
1441
  fetchQuote: api.fetchQuote,
1372
- fetchPaymentPlan: (request, payer, wallet) => fetchPaymentPlan(api, request, payer, wallet),
1442
+ fetchPaymentPlan: (request, payer, wallet) => fetchPaymentPlan(api, request, payer, wallet, verifier.readBalances),
1373
1443
  quoteSwapPreview: (swap, owner) => quoteSwapPreview(api, swap, owner),
1374
1444
  buildSwapPlan: (swap, payer, wallet) => buildSwapPlan(api, swap, payer, wallet),
1375
1445
  payerNonceBaseline: verifier.payerNonceBaseline,
@@ -1878,7 +1948,7 @@ function useFlow(args) {
1878
1948
  function balanceKey(chainId, tokenAddress) {
1879
1949
  return `${Number(chainId)}:${String(tokenAddress || "").toLowerCase()}`;
1880
1950
  }
1881
- function useHoldings(engine, account, routes) {
1951
+ function useHoldings(engine, account, routes, initialBalances) {
1882
1952
  const [balances, setBalances] = react.useState({});
1883
1953
  const [loading, setLoading] = react.useState(false);
1884
1954
  const reqId = react.useRef(0);
@@ -1903,19 +1973,32 @@ function useHoldings(engine, account, routes) {
1903
1973
  return;
1904
1974
  }
1905
1975
  const id = ++reqId.current;
1976
+ const seeded = {};
1977
+ const missing = [];
1978
+ for (const target of targets) {
1979
+ const key = balanceKey(target.chainId, target.tokenAddress);
1980
+ const balance = initialBalances?.[key];
1981
+ if (balance) seeded[key] = balance;
1982
+ else missing.push(target);
1983
+ }
1984
+ setBalances(seeded);
1985
+ if (!missing.length) {
1986
+ setLoading(false);
1987
+ return;
1988
+ }
1906
1989
  setLoading(true);
1907
1990
  (async () => {
1908
1991
  try {
1909
- const res = await engine.readBalances(account, targets);
1992
+ const res = await engine.readBalances(account, missing);
1910
1993
  if (id !== reqId.current) return;
1911
- setBalances(res);
1994
+ setBalances({ ...seeded, ...res });
1912
1995
  } catch {
1913
- if (id === reqId.current) setBalances({});
1996
+ if (id === reqId.current) setBalances(seeded);
1914
1997
  } finally {
1915
1998
  if (id === reqId.current) setLoading(false);
1916
1999
  }
1917
2000
  })();
1918
- }, [engine, account, targetsKey]);
2001
+ }, [engine, account, targetsKey, initialBalances]);
1919
2002
  return { balances, loading };
1920
2003
  }
1921
2004
 
@@ -2060,6 +2143,10 @@ var WIDGET_CSS = `
2060
2143
  .sg-tile-sym{font-size:16px;font-weight:700;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
2061
2144
  .sg-tile-chain{font-size:11px;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
2062
2145
  .sg-tile-empty{color:var(--sg-text-muted);font-size:15px;font-weight:600}
2146
+ .sg-funding-glyphs{display:flex;align-items:center;flex:0 0 auto;padding-right:2px}
2147
+ .sg-funding-glyphs .sg-tok{box-shadow:0 0 0 2px var(--sg-surface);border-radius:999px}
2148
+ .sg-funding-glyphs .sg-tok+.sg-tok{margin-left:-8px}
2149
+ .sg-funding-copy{display:flex;flex-direction:column;min-width:0}
2063
2150
  .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}
2064
2151
 
2065
2152
  /* token identity: logo circle + tiny chain badge, with a letters fallback */
@@ -2696,6 +2783,31 @@ function TokenTile(props) {
2696
2783
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-main", children: glyph })
2697
2784
  ] });
2698
2785
  }
2786
+ function FundingTile(props) {
2787
+ const symbols = props.assets.map((asset) => asset.symbol);
2788
+ const summary = props.loading ? "Checking wallet assets\u2026" : symbols.length ? symbols.join(", ") : "No payable balance";
2789
+ 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";
2790
+ const ariaLabel = `${props.label}: ${props.loading ? "checking wallet assets" : symbols.length ? symbols.join(", ") : "no payable balance"}`;
2791
+ const glyphs = props.loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok-fb", children: "\u2026" }) }) : symbols.length ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-funding-glyphs", "aria-hidden": "true", children: props.assets.slice(0, 3).map((asset) => /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: asset.symbol, logoUrl: asset.logoUrl, size: "sm" }, asset.symbol)) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok-fb", children: "?" }) });
2792
+ const main = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2793
+ glyphs,
2794
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-funding-copy", children: [
2795
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-sym", children: summary }),
2796
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-chain", children: detail })
2797
+ ] })
2798
+ ] });
2799
+ if (props.row) {
2800
+ 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: [
2801
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-label", children: props.label }),
2802
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-rowmain", children: main }),
2803
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-chev", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) })
2804
+ ] });
2805
+ }
2806
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", ref: props.btnRef, className: "sg-tile", disabled: props.disabled, onClick: props.onClick, "aria-label": ariaLabel, children: [
2807
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-label", children: props.label }),
2808
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-main", children: main })
2809
+ ] });
2810
+ }
2699
2811
  function ChainChip(props) {
2700
2812
  const [broken, setBroken] = react.useState(false);
2701
2813
  const logo = props.chain?.logoUrl;
@@ -3025,7 +3137,21 @@ var addrEq = (a, b) => String(a || "").toLowerCase() === String(b || "").toLower
3025
3137
  var chainName = (id) => id != null ? CHAIN_LABELS[id] || `Chain ${id}` : "";
3026
3138
  var STABLES = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
3027
3139
  function BankGlyph() {
3028
- return /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx("path", { d: "M3 10h18M5 10v8M10 10v8M14 10v8M19 10v8M3 19h18M12 3 3 8h18Z" }) });
3140
+ return /* @__PURE__ */ jsxRuntime.jsx(
3141
+ "svg",
3142
+ {
3143
+ width: "18",
3144
+ height: "18",
3145
+ viewBox: "0 0 24 24",
3146
+ fill: "none",
3147
+ stroke: "currentColor",
3148
+ strokeWidth: "2",
3149
+ strokeLinecap: "round",
3150
+ strokeLinejoin: "round",
3151
+ "aria-hidden": "true",
3152
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 10h18M5 10v8M10 10v8M14 10v8M19 10v8M3 19h18M12 3 3 8h18Z" })
3153
+ }
3154
+ );
3029
3155
  }
3030
3156
  function MerchantBankPayout(props) {
3031
3157
  const bankName = props.account?.bankName?.trim() || "Bank account";
@@ -3052,25 +3178,81 @@ function MerchantBankPayout(props) {
3052
3178
  ] }) }) });
3053
3179
  }
3054
3180
  function CheckGlyph2() {
3055
- 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" }) });
3181
+ return /* @__PURE__ */ jsxRuntime.jsx(
3182
+ "svg",
3183
+ {
3184
+ width: "20",
3185
+ height: "20",
3186
+ viewBox: "0 0 24 24",
3187
+ fill: "none",
3188
+ stroke: "currentColor",
3189
+ strokeWidth: "3",
3190
+ strokeLinecap: "round",
3191
+ strokeLinejoin: "round",
3192
+ "aria-hidden": "true",
3193
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 6 9 17l-5-5" })
3194
+ }
3195
+ );
3056
3196
  }
3057
3197
  function ArrowGlyph() {
3058
- return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
3059
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 12h14" }),
3060
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m13 6 6 6-6 6" })
3061
- ] });
3198
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3199
+ "svg",
3200
+ {
3201
+ width: "14",
3202
+ height: "14",
3203
+ viewBox: "0 0 24 24",
3204
+ fill: "none",
3205
+ stroke: "currentColor",
3206
+ strokeWidth: "2.4",
3207
+ strokeLinecap: "round",
3208
+ strokeLinejoin: "round",
3209
+ "aria-hidden": "true",
3210
+ children: [
3211
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 12h14" }),
3212
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m13 6 6 6-6 6" })
3213
+ ]
3214
+ }
3215
+ );
3062
3216
  }
3063
3217
  function ClockGlyph() {
3064
- return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
3065
- /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "9" }),
3066
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 7v5l3 2" })
3067
- ] });
3218
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3219
+ "svg",
3220
+ {
3221
+ width: "20",
3222
+ height: "20",
3223
+ viewBox: "0 0 24 24",
3224
+ fill: "none",
3225
+ stroke: "currentColor",
3226
+ strokeWidth: "2.2",
3227
+ strokeLinecap: "round",
3228
+ strokeLinejoin: "round",
3229
+ "aria-hidden": "true",
3230
+ children: [
3231
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "9" }),
3232
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 7v5l3 2" })
3233
+ ]
3234
+ }
3235
+ );
3068
3236
  }
3069
3237
  function WalletGlyph() {
3070
- return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
3071
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "6", width: "18", height: "13", rx: "2" }),
3072
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16 12h.01M3 9h18" })
3073
- ] });
3238
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3239
+ "svg",
3240
+ {
3241
+ width: "16",
3242
+ height: "16",
3243
+ viewBox: "0 0 24 24",
3244
+ fill: "none",
3245
+ stroke: "currentColor",
3246
+ strokeWidth: "2",
3247
+ strokeLinecap: "round",
3248
+ strokeLinejoin: "round",
3249
+ "aria-hidden": "true",
3250
+ children: [
3251
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "6", width: "18", height: "13", rx: "2" }),
3252
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16 12h.01M3 9h18" })
3253
+ ]
3254
+ }
3255
+ );
3074
3256
  }
3075
3257
  function LinkMenu(props) {
3076
3258
  const [open, setOpen] = react.useState(false);
@@ -3181,7 +3363,13 @@ function IdentityLine(props) {
3181
3363
  function PaymentIsland(props) {
3182
3364
  injectStyles();
3183
3365
  const config = useMergedConfig(props);
3184
- const engine = useEngine({ apiBase: config.apiBase, apiKey: config.apiKey, trustedApiOrigin: config.trustedApiOrigin, rpcOverrides: config.rpcOverrides, onTransaction: config.onTransaction });
3366
+ const engine = useEngine({
3367
+ apiBase: config.apiBase,
3368
+ apiKey: config.apiKey,
3369
+ trustedApiOrigin: config.trustedApiOrigin,
3370
+ rpcOverrides: config.rpcOverrides,
3371
+ onTransaction: config.onTransaction
3372
+ });
3185
3373
  const wallet = useWallet(config.provider);
3186
3374
  const kind = props.kind;
3187
3375
  const isPay = kind === "pay";
@@ -3210,7 +3398,8 @@ function PaymentIsland(props) {
3210
3398
  const normEx = normalizeDecimalText(exAmount);
3211
3399
  const exAmountValid = /^\d+(\.\d+)?$/.test(normEx) && Number(normEx) > 0 && Number(normEx) <= 1e9;
3212
3400
  const exQuotable = !rampMode && exAmountValid && Boolean(exFromChainId && exFromAsset && exToChainId && exToAsset);
3213
- const payParamsKey = `pay|${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}`;
3401
+ const payFundingAssets = props.fundingAssets?.length ? props.fundingAssets : ["USDC", "USDT", "USDE"];
3402
+ const payParamsKey = `pay|${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}|${payFundingAssets.join(",")}`;
3214
3403
  const exParamsKey = `${kind}|${mode}|${exFromChainId}|${exFromAsset}|${exToChainId}|${exToAsset}|${normEx}|${props.recipient ?? ""}`;
3215
3404
  const flow = useFlow({
3216
3405
  engine,
@@ -3220,7 +3409,20 @@ function PaymentIsland(props) {
3220
3409
  // quote (and fire onQuote) for a payment whose CTA it never shows.
3221
3410
  enabled: isPay ? Boolean(props.recipient && props.amount) && !bankSettlement : exQuotable,
3222
3411
  paramsKey: isPay ? payParamsKey : exParamsKey,
3223
- loadPlan: isPay ? (e, payer, chainId) => e.fetchPaymentPlan({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, payer, { chainId }) : (e, payer) => e.buildSwapPlan({ fromChainId: exFromChainId, toChainId: exToChainId, fromToken: exFromAsset, toToken: exToAsset, amountIn: normEx, recipient: props.recipient }, payer),
3412
+ loadPlan: isPay ? (e, payer, chainId) => e.fetchPaymentPlan({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, payer, {
3413
+ chainId,
3414
+ fundingAssets: payFundingAssets
3415
+ }) : (e, payer) => e.buildSwapPlan(
3416
+ {
3417
+ fromChainId: exFromChainId,
3418
+ toChainId: exToChainId,
3419
+ fromToken: exFromAsset,
3420
+ toToken: exToAsset,
3421
+ amountIn: normEx,
3422
+ recipient: props.recipient
3423
+ },
3424
+ payer
3425
+ ),
3224
3426
  recipientFor: (account) => isPay ? props.recipient : props.recipient || account,
3225
3427
  onQuote: config.onQuote,
3226
3428
  onSuccess: config.onSuccess,
@@ -3228,15 +3430,14 @@ function PaymentIsland(props) {
3228
3430
  });
3229
3431
  const [method, setMethod] = react.useState("stablecoin");
3230
3432
  const parked = isPay && !isLiveMethod(method);
3231
- const fundingSet = react.useMemo(
3232
- () => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null,
3233
- [props.fundingAssets]
3234
- );
3433
+ const fundingSet = react.useMemo(() => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null, [props.fundingAssets]);
3235
3434
  const visibleRoutes = react.useMemo(() => {
3236
3435
  const base = fundingSet ? flow.routes.filter((r) => fundingSet.has(r.source.asset.toUpperCase()) || r.state === "DIRECT") : flow.routes;
3237
- return isPay && method === "stablecoin" ? base.filter((r) => STABLES.has(r.source.asset)) : base;
3436
+ return isPay && method === "stablecoin" ? base.filter((r) => STABLES.has(symbolKey(r.source.asset))) : base;
3238
3437
  }, [flow.routes, fundingSet, isPay, method]);
3239
- const holdings = useHoldings(engine, wallet.account, flow.routes);
3438
+ const paymentPlan = flow.plan;
3439
+ const prefetchedBalances = paymentPlan && paymentPlan.fundingAccount === wallet.account?.toLowerCase() ? paymentPlan.fundingBalances : void 0;
3440
+ const holdings = useHoldings(engine, wallet.account, flow.routes, prefetchedBalances);
3240
3441
  const annotated = react.useMemo(
3241
3442
  () => visibleRoutes.map((r) => {
3242
3443
  const balance = holdings.balances[balanceKey(r.source.chainId, r.source.tokenAddress)];
@@ -3331,7 +3532,15 @@ function PaymentIsland(props) {
3331
3532
  if (seen.has(key)) continue;
3332
3533
  seen.add(key);
3333
3534
  const reg = registryTokens.find((t) => Number(t.chainId) === r.source.chainId && addrEq(t.address, r.source.tokenAddress));
3334
- list.push(reg ?? { symbol: r.source.asset, name: r.source.asset, chainId: r.source.chainId, address: r.source.tokenAddress ?? "", decimals: r.source.decimals ?? 18 });
3535
+ list.push(
3536
+ reg ?? {
3537
+ symbol: r.source.asset,
3538
+ name: r.source.asset,
3539
+ chainId: r.source.chainId,
3540
+ address: r.source.tokenAddress ?? "",
3541
+ decimals: r.source.decimals ?? 18
3542
+ }
3543
+ );
3335
3544
  }
3336
3545
  return list;
3337
3546
  }, [visibleRoutes, registryTokens]);
@@ -3339,6 +3548,18 @@ function PaymentIsland(props) {
3339
3548
  const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
3340
3549
  return chains.filter((c) => ids.has(Number(c.chainId)));
3341
3550
  }, [chains, fundingTokens]);
3551
+ const payableAssets = react.useMemo(() => {
3552
+ const seen = /* @__PURE__ */ new Set();
3553
+ const list = [];
3554
+ for (const { route } of held) {
3555
+ const symbol = symbolKey(route.source.asset);
3556
+ if (seen.has(symbol)) continue;
3557
+ seen.add(symbol);
3558
+ const token = registryTokens.find((t) => Number(t.chainId) === route.source.chainId && addrEq(t.address, route.source.tokenAddress));
3559
+ list.push({ symbol: route.source.asset, logoUrl: token?.logoUrl });
3560
+ }
3561
+ return list;
3562
+ }, [held, registryTokens]);
3342
3563
  const userPicked = react.useRef(false);
3343
3564
  const selectRoute = react.useCallback(
3344
3565
  (id) => {
@@ -3441,8 +3662,6 @@ function PaymentIsland(props) {
3441
3662
  const submitting = flow.status === "submitting";
3442
3663
  const sel = flow.selected;
3443
3664
  const selectedVisible = Boolean(sel && visibleRoutes.some((r) => r.id === sel.id));
3444
- const selPick = sel && selectedVisible ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null;
3445
- const selToken = sel ? registryTokens.find((t) => Number(t.chainId) === sel.source.chainId && addrEq(t.address, sel.source.tokenAddress)) ?? null : null;
3446
3665
  const selBal = sel ? holdings.balances[balanceKey(sel.source.chainId, sel.source.tokenAddress)] : void 0;
3447
3666
  const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
3448
3667
  const mismatch = flow.status === "error" && flow.verdict?.status === "mismatch";
@@ -3531,7 +3750,18 @@ function PaymentIsland(props) {
3531
3750
  if (hist && wallet.account) {
3532
3751
  body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory });
3533
3752
  } else if (isPay && view === "select" && wallet.account) {
3534
- body = /* @__PURE__ */ jsxRuntime.jsx(TokenSelect, { title: "Pay with", chains: fundingChains, tokens: fundingTokens, balances: holdings.balances, optionStates, onBack: () => closeSelector(), onPick: pickFunding });
3753
+ body = /* @__PURE__ */ jsxRuntime.jsx(
3754
+ TokenSelect,
3755
+ {
3756
+ title: "Pay with",
3757
+ chains: fundingChains,
3758
+ tokens: fundingTokens,
3759
+ balances: holdings.balances,
3760
+ optionStates,
3761
+ onBack: () => closeSelector(),
3762
+ onPick: pickFunding
3763
+ }
3764
+ );
3535
3765
  } else if (!isPay && (view === "from" || view === "to")) {
3536
3766
  const isFrom = view === "from";
3537
3767
  const openerRef = isFrom ? exFromTileRef : exToTileRef;
@@ -3666,7 +3896,18 @@ function PaymentIsland(props) {
3666
3896
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { disabled: true, children: method === "card" ? "Card \u2014 coming soon" : "Bank \u2014 coming soon" }) })
3667
3897
  ] })
3668
3898
  ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3669
- isPay ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { row: true, label: "Pay with", pick: selPick, token: selToken, disabled: submitting || !visibleRoutes.length, btnRef: methodRowRef, onClick: () => setView("select") }) }) : null,
3899
+ isPay ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(
3900
+ FundingTile,
3901
+ {
3902
+ row: true,
3903
+ label: "Pay with",
3904
+ assets: payableAssets,
3905
+ loading: flow.status === "loading" || holdings.loading,
3906
+ disabled: submitting || !visibleRoutes.length,
3907
+ btnRef: methodRowRef,
3908
+ onClick: () => setView("select")
3909
+ }
3910
+ ) }) : null,
3670
3911
  loading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
3671
3912
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-skel" }),
3672
3913
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-muted", style: { fontSize: 13 }, children: [
@@ -3720,22 +3961,66 @@ function PaymentIsland(props) {
3720
3961
  const islandVars = themeToVars(resolved);
3721
3962
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-island-wrap", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-island", "data-sg-mode": resolved.mode, "data-expanded": expanded, "data-status": flow.status, style: islandVars, children: [
3722
3963
  pillFace,
3723
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-island-reveal", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-island-reveal-inner", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-island-body", id: panelId, ref: regionRef, role: "region", "aria-label": isPay ? "ZeroDelta Link checkout" : `ZeroDelta Link ${verb.present.toLowerCase()}`, tabIndex: -1, children: expanded ? /* @__PURE__ */ jsxRuntime.jsxs(WidgetShell, { variant: "express", title: "ZeroDelta Link", theme: config.theme, heightPx: props.heightPx, brandSlot, walletSlot, children: [
3724
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", role: "status", "aria-live": "polite", children: liveMsg }),
3725
- body
3726
- ] }) : null }) }) })
3964
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-island-reveal", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-island-reveal-inner", children: /* @__PURE__ */ jsxRuntime.jsx(
3965
+ "div",
3966
+ {
3967
+ className: "sg-island-body",
3968
+ id: panelId,
3969
+ ref: regionRef,
3970
+ role: "region",
3971
+ "aria-label": isPay ? "ZeroDelta Link checkout" : `ZeroDelta Link ${verb.present.toLowerCase()}`,
3972
+ tabIndex: -1,
3973
+ children: expanded ? /* @__PURE__ */ jsxRuntime.jsxs(
3974
+ WidgetShell,
3975
+ {
3976
+ variant: "express",
3977
+ title: "ZeroDelta Link",
3978
+ theme: config.theme,
3979
+ heightPx: props.heightPx,
3980
+ brandSlot,
3981
+ walletSlot,
3982
+ children: [
3983
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", role: "status", "aria-live": "polite", children: liveMsg }),
3984
+ body
3985
+ ]
3986
+ }
3987
+ ) : null
3988
+ }
3989
+ ) }) })
3727
3990
  ] }) });
3728
3991
  }
3729
3992
  var STABLES2 = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
3993
+ var DEFAULT_FUNDING_ASSETS = ["USDC", "USDT", "USDE"];
3730
3994
  function CheckGlyph3() {
3731
- 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" }) });
3995
+ return /* @__PURE__ */ jsxRuntime.jsx(
3996
+ "svg",
3997
+ {
3998
+ width: "20",
3999
+ height: "20",
4000
+ viewBox: "0 0 24 24",
4001
+ fill: "none",
4002
+ stroke: "currentColor",
4003
+ strokeWidth: "3",
4004
+ strokeLinecap: "round",
4005
+ strokeLinejoin: "round",
4006
+ "aria-hidden": "true",
4007
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 6 9 17l-5-5" })
4008
+ }
4009
+ );
3732
4010
  }
3733
4011
  var addrEq2 = (a, b) => String(a || "").toLowerCase() === String(b || "").toLowerCase();
3734
4012
  function StableGeniePay(props) {
3735
4013
  const config = useMergedConfig(props);
3736
- const engine = useEngine({ apiBase: config.apiBase, apiKey: config.apiKey, trustedApiOrigin: config.trustedApiOrigin, rpcOverrides: config.rpcOverrides, onTransaction: config.onTransaction });
4014
+ const engine = useEngine({
4015
+ apiBase: config.apiBase,
4016
+ apiKey: config.apiKey,
4017
+ trustedApiOrigin: config.trustedApiOrigin,
4018
+ rpcOverrides: config.rpcOverrides,
4019
+ onTransaction: config.onTransaction
4020
+ });
3737
4021
  const wallet = useWallet(config.provider);
3738
- const paramsKey = `${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}`;
4022
+ const planFundingAssets = props.fundingAssets?.length ? props.fundingAssets : DEFAULT_FUNDING_ASSETS;
4023
+ const paramsKey = `${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}|${planFundingAssets.join(",")}`;
3739
4024
  const flow = useFlow({
3740
4025
  engine,
3741
4026
  wallet,
@@ -3744,22 +4029,24 @@ function StableGeniePay(props) {
3744
4029
  // network work here, or every quote / balance read fires twice and onQuote/onError double-fire.
3745
4030
  enabled: Boolean(props.recipient && props.amount) && props.variant !== "pill",
3746
4031
  paramsKey,
3747
- loadPlan: (e, payer, chainId) => e.fetchPaymentPlan({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, payer, { chainId }),
4032
+ loadPlan: (e, payer, chainId) => e.fetchPaymentPlan({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, payer, {
4033
+ chainId,
4034
+ fundingAssets: planFundingAssets
4035
+ }),
3748
4036
  recipientFor: () => props.recipient,
3749
4037
  onQuote: config.onQuote,
3750
4038
  onSuccess: config.onSuccess,
3751
4039
  onError: config.onError
3752
4040
  });
3753
4041
  const [method, setMethod] = react.useState("stablecoin");
3754
- const fundingSet = react.useMemo(
3755
- () => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null,
3756
- [props.fundingAssets]
3757
- );
4042
+ const fundingSet = react.useMemo(() => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null, [props.fundingAssets]);
3758
4043
  const visibleRoutes = react.useMemo(() => {
3759
4044
  const base = fundingSet ? flow.routes.filter((r) => fundingSet.has(r.source.asset.toUpperCase()) || r.state === "DIRECT") : flow.routes;
3760
- return method === "stablecoin" ? base.filter((r) => STABLES2.has(r.source.asset)) : base;
4045
+ return method === "stablecoin" ? base.filter((r) => STABLES2.has(symbolKey(r.source.asset))) : base;
3761
4046
  }, [flow.routes, method, fundingSet]);
3762
- const holdings = useHoldings(engine, wallet.account, flow.routes);
4047
+ const paymentPlan = flow.plan;
4048
+ const prefetchedBalances = paymentPlan && paymentPlan.fundingAccount === wallet.account?.toLowerCase() ? paymentPlan.fundingBalances : void 0;
4049
+ const holdings = useHoldings(engine, wallet.account, flow.routes, prefetchedBalances);
3763
4050
  const annotated = react.useMemo(
3764
4051
  () => visibleRoutes.map((r) => {
3765
4052
  const balance = holdings.balances[balanceKey(r.source.chainId, r.source.tokenAddress)];
@@ -3833,7 +4120,15 @@ function StableGeniePay(props) {
3833
4120
  if (seen.has(key)) continue;
3834
4121
  seen.add(key);
3835
4122
  const reg = registryTokens.find((t) => Number(t.chainId) === r.source.chainId && addrEq2(t.address, r.source.tokenAddress));
3836
- list.push(reg ?? { symbol: r.source.asset, name: r.source.asset, chainId: r.source.chainId, address: r.source.tokenAddress ?? "", decimals: r.source.decimals ?? 18 });
4123
+ list.push(
4124
+ reg ?? {
4125
+ symbol: r.source.asset,
4126
+ name: r.source.asset,
4127
+ chainId: r.source.chainId,
4128
+ address: r.source.tokenAddress ?? "",
4129
+ decimals: r.source.decimals ?? 18
4130
+ }
4131
+ );
3837
4132
  }
3838
4133
  return list;
3839
4134
  }, [visibleRoutes, registryTokens]);
@@ -3841,6 +4136,18 @@ function StableGeniePay(props) {
3841
4136
  const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
3842
4137
  return chains.filter((c) => ids.has(Number(c.chainId)));
3843
4138
  }, [chains, fundingTokens]);
4139
+ const payableAssets = react.useMemo(() => {
4140
+ const seen = /* @__PURE__ */ new Set();
4141
+ const list = [];
4142
+ for (const { route } of held) {
4143
+ const symbol = symbolKey(route.source.asset);
4144
+ if (seen.has(symbol)) continue;
4145
+ seen.add(symbol);
4146
+ const token = registryTokens.find((t) => Number(t.chainId) === route.source.chainId && addrEq2(t.address, route.source.tokenAddress));
4147
+ list.push({ symbol: route.source.asset, logoUrl: token?.logoUrl });
4148
+ }
4149
+ return list;
4150
+ }, [held, registryTokens]);
3844
4151
  const userPicked = react.useRef(false);
3845
4152
  const selectRoute = react.useCallback(
3846
4153
  (id) => {
@@ -3888,8 +4195,6 @@ function StableGeniePay(props) {
3888
4195
  const submitting = flow.status === "submitting";
3889
4196
  const sel = flow.selected;
3890
4197
  const selectedVisible = Boolean(sel && visibleRoutes.some((r) => r.id === sel.id));
3891
- const selPick = sel && selectedVisible ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null;
3892
- const selToken = sel ? registryTokens.find((t) => Number(t.chainId) === sel.source.chainId && addrEq2(t.address, sel.source.tokenAddress)) ?? null : null;
3893
4198
  const selBal = sel ? holdings.balances[balanceKey(sel.source.chainId, sel.source.tokenAddress)] : void 0;
3894
4199
  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` : (
3895
4200
  // Deliberately does NOT restate the destination amount — that is merchant config, not a payer fact.
@@ -3905,7 +4210,18 @@ function StableGeniePay(props) {
3905
4210
  ] })
3906
4211
  ] }) : void 0;
3907
4212
  if (props.variant === "pill") return /* @__PURE__ */ jsxRuntime.jsx(PaymentIsland, { kind: "pay", ...props });
3908
- return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, children: hist && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(TokenSelect, { title: "Pay with", chains: fundingChains, tokens: fundingTokens, balances: holdings.balances, optionStates, onBack: closeSelector, onPick: pickFunding }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: !wallet.account ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cta-wrap", children: [
4213
+ return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, children: hist && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(
4214
+ TokenSelect,
4215
+ {
4216
+ title: "Pay with",
4217
+ chains: fundingChains,
4218
+ tokens: fundingTokens,
4219
+ balances: holdings.balances,
4220
+ optionStates,
4221
+ onBack: closeSelector,
4222
+ onPick: pickFunding
4223
+ }
4224
+ ) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: !wallet.account ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cta-wrap", children: [
3909
4225
  /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }),
3910
4226
  wallet.error ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
3911
4227
  ] }) : flow.status === "success" || flow.status === "pending" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -3927,11 +4243,11 @@ function StableGeniePay(props) {
3927
4243
  /* @__PURE__ */ jsxRuntime.jsx(MethodTabs, { value: method, onChange: setMethod }),
3928
4244
  parked ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { children: comingSoon }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3929
4245
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(
3930
- TokenTile,
4246
+ FundingTile,
3931
4247
  {
3932
4248
  label: "Pay with",
3933
- pick: selPick,
3934
- token: selToken,
4249
+ assets: payableAssets,
4250
+ loading: flow.status === "loading" || holdings.loading,
3935
4251
  disabled: submitting || !visibleRoutes.length,
3936
4252
  btnRef: payTileRef,
3937
4253
  onClick: () => setView("select")
@@ -3963,7 +4279,15 @@ function StableGeniePay(props) {
3963
4279
  flow.status === "ready" && !visibleRoutes.length ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { children: "No funding route matches the accepted assets for this payment." }) : null
3964
4280
  ] }),
3965
4281
  submitting ? /* @__PURE__ */ jsxRuntime.jsx(StepList, { steps: flow.steps }) : null,
3966
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: parked || !selectedVisible ? void 0 : flow.submit, busy: submitting, disabled: parked || !selectedVisible || flow.insufficient || !!flow.nativeShortfall || flow.status === "loading", children: payLabel }) })
4282
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(
4283
+ Button,
4284
+ {
4285
+ onClick: parked || !selectedVisible ? void 0 : flow.submit,
4286
+ busy: submitting,
4287
+ disabled: parked || !selectedVisible || flow.insufficient || !!flow.nativeShortfall || flow.status === "loading",
4288
+ children: payLabel
4289
+ }
4290
+ ) })
3967
4291
  ] }) }) });
3968
4292
  }
3969
4293
  var chainOptions = SUPPORTED_CHAINS.map((c) => ({ value: c, label: CHAIN_LABELS[c] || `Chain ${c}` }));