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