@glacislabs/stablegenie-zerodelta 4.2.1 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mount.cjs CHANGED
@@ -565,6 +565,10 @@ function brokenLaneFor(token, source, brokenLanes) {
565
565
  if (!source || !brokenLanes) return void 0;
566
566
  return brokenLanes.get(laneKey(source.chainId, source.address, token.chainId, token.address));
567
567
  }
568
+ function laneLimitFor(token, source, limitedLanes2) {
569
+ if (!source || !limitedLanes2) return void 0;
570
+ return limitedLanes2.get(laneKey(source.chainId, source.address, token.chainId, token.address));
571
+ }
568
572
  function destinationAvailability(token, ctx, source) {
569
573
  if (brokenLaneFor(token, source ?? void 0, ctx.brokenLanes)) return "unreachable";
570
574
  if (directLaneOK(token, source ?? void 0, ctx.lanes)) {
@@ -620,7 +624,17 @@ function buildCatalogue(input) {
620
624
  );
621
625
  const byId = new Map(enabledChains.map((c) => [Number(c.chainId), c]));
622
626
  for (const id of chainIds) if (!byId.has(id)) byId.set(id, { chainId: id, isEnabled: true });
623
- return { ...ctx, product, tokens: catalogue, sources, chainIds, chains: [...byId.values()], ready, vaultIcons: input.vaultIcons ?? /* @__PURE__ */ new Map() };
627
+ return {
628
+ ...ctx,
629
+ product,
630
+ tokens: catalogue,
631
+ sources,
632
+ chainIds,
633
+ chains: [...byId.values()],
634
+ ready,
635
+ vaultIcons: input.vaultIcons ?? /* @__PURE__ */ new Map(),
636
+ limitedLanes: input.limitedLanes ?? /* @__PURE__ */ new Map()
637
+ };
624
638
  }
625
639
 
626
640
  // src/core/options.ts
@@ -755,23 +769,89 @@ function nativeFeeShortMessage(check, symbol, chainName3) {
755
769
 
756
770
  // src/core/route-health.ts
757
771
  var EMPTY = /* @__PURE__ */ new Map();
772
+ var NO_LIMITS = /* @__PURE__ */ new Map();
773
+ function laneAvailabilityState(lane) {
774
+ const availability = lane?.availability;
775
+ if (!availability || typeof availability !== "object") return null;
776
+ const state = availability.state;
777
+ return state === "available" || state === "limited" || state === "unavailable" ? state : null;
778
+ }
779
+ function isSuppressed(lane) {
780
+ const state = laneAvailabilityState(lane);
781
+ if (state) return state === "unavailable";
782
+ const firewalled = lane.status === "unknown" && lane.kind === "firewalled";
783
+ return lane.status === "broken" || firewalled;
784
+ }
758
785
  function suppressedLanes(health) {
759
786
  if (health?.mode !== "enforce" || !Array.isArray(health.lanes)) return EMPTY;
760
787
  const out = /* @__PURE__ */ new Map();
761
788
  for (const lane of health.lanes) {
762
- const firewalled = lane?.status === "unknown" && lane?.kind === "firewalled";
763
- if (lane?.status !== "broken" && !firewalled) continue;
789
+ if (!lane || typeof lane !== "object" || !isSuppressed(lane)) continue;
764
790
  const key = typeof lane.laneKey === "string" ? lane.laneKey.toLowerCase() : "";
765
791
  if (!key) continue;
792
+ const availability = laneAvailabilityState(lane) ? lane.availability : void 0;
793
+ const code = typeof availability?.code === "string" && availability.code ? availability.code : lane.code;
794
+ const message = typeof availability?.message === "string" && availability.message ? availability.message : lane.message;
766
795
  out.set(key, {
767
796
  route: typeof lane.route === "string" ? lane.route : "",
768
- code: typeof lane.code === "string" ? lane.code : "",
769
- message: typeof lane.message === "string" ? lane.message : "",
797
+ code: typeof code === "string" ? code : "",
798
+ message: typeof message === "string" ? message : "",
770
799
  ...typeof lane.kind === "string" ? { kind: lane.kind } : {}
771
800
  });
772
801
  }
773
802
  return out;
774
803
  }
804
+ var BASE_UNITS = /^\d{1,78}$/;
805
+ function limitedLanes(health) {
806
+ if (health?.mode !== "enforce" || !Array.isArray(health.lanes)) return NO_LIMITS;
807
+ const out = /* @__PURE__ */ new Map();
808
+ for (const lane of health.lanes) {
809
+ if (!lane || typeof lane !== "object" || laneAvailabilityState(lane) !== "limited") continue;
810
+ const key = typeof lane.laneKey === "string" ? lane.laneKey.toLowerCase() : "";
811
+ const limit = lane.availability?.limit;
812
+ if (!key || !limit || typeof limit !== "object") continue;
813
+ const side = limit.side === "bid" || limit.side === "ask" ? limit.side : null;
814
+ const maxAmount = typeof limit.maxAmount === "string" ? limit.maxAmount.trim() : "";
815
+ const decimals = limit.decimals;
816
+ if (!side || !BASE_UNITS.test(maxAmount) || typeof decimals !== "number" || !Number.isInteger(decimals) || decimals < 0 || decimals > 36) continue;
817
+ const code = lane.availability?.code;
818
+ out.set(key, {
819
+ side,
820
+ token: typeof limit.token === "string" ? limit.token : "",
821
+ fromChainId: Number(limit.fromChainId) || 0,
822
+ toChainId: Number(limit.toChainId) || 0,
823
+ maxAmount,
824
+ decimals,
825
+ code: typeof code === "string" ? code : "",
826
+ ...typeof limit.measuredAt === "string" ? { measuredAt: limit.measuredAt } : {}
827
+ });
828
+ }
829
+ return out;
830
+ }
831
+ function exceedsLaneLimit(limit, amount, bidDecimals) {
832
+ if (limit?.side !== "bid" || !BASE_UNITS.test(limit.maxAmount)) return false;
833
+ let raw;
834
+ try {
835
+ raw = parseUnitsDecimal(amount, bidDecimals);
836
+ } catch {
837
+ return false;
838
+ }
839
+ const scale = Math.max(bidDecimals, limit.decimals);
840
+ return scaleDecimals(raw, bidDecimals, scale) > scaleDecimals(BigInt(limit.maxAmount), limit.decimals, scale);
841
+ }
842
+ function laneLimitAmount(limit) {
843
+ return formatUnits(limit.maxAmount, limit.decimals);
844
+ }
845
+ function laneLimitSymbol(limit, bidTicker) {
846
+ if (limit.side === "bid" && bidTicker) return bidTicker;
847
+ return safeTicker(limit.token, limit.token);
848
+ }
849
+ function laneLimitHint(limit, symbol) {
850
+ return `Max ${laneLimitAmount(limit)}${symbol ? ` ${symbol}` : ""} right now`;
851
+ }
852
+ function laneLimitError(limit, symbol) {
853
+ return `Maximum: ${laneLimitAmount(limit)}${symbol ? ` ${symbol}` : ""} right now`;
854
+ }
775
855
  function brokenLaneReason(lane) {
776
856
  if (!lane) return "";
777
857
  switch (lane.kind) {
@@ -1264,9 +1344,18 @@ async function solveExactIn({ option, destination, destinationToken, payer, fetc
1264
1344
  // src/core/order.ts
1265
1345
  var DEFAULT_DEADLINE_SECONDS = 1800;
1266
1346
  var MAX_DEADLINE_SECONDS = 60 * 60;
1267
- function normalizeOrderRequest(order, payer, destination, fallbackExecutionChainId, deadlineOverride) {
1347
+ var ABSOLUTE_MAX_DEADLINE_SECONDS = 24 * 60 * 60;
1348
+ function recommendedDeadlineSeconds(quote) {
1349
+ const recommended = Number(quote?.recommendedDeadlineSeconds);
1350
+ if (!Number.isFinite(recommended) || recommended <= 0) return DEFAULT_DEADLINE_SECONDS;
1351
+ return Math.min(Math.floor(recommended), ABSOLUTE_MAX_DEADLINE_SECONDS);
1352
+ }
1353
+ function maxDeadlineSeconds(quote) {
1354
+ return Math.min(Math.max(MAX_DEADLINE_SECONDS, recommendedDeadlineSeconds(quote)), ABSOLUTE_MAX_DEADLINE_SECONDS);
1355
+ }
1356
+ function normalizeOrderRequest(order, payer, destination, fallbackExecutionChainId, deadlineOverride, lifetimeSeconds = DEFAULT_DEADLINE_SECONDS) {
1268
1357
  const apiDeadline = Number(order.deadline);
1269
- const deadline = deadlineOverride ?? (Number.isFinite(apiDeadline) && apiDeadline > 0 ? String(order.deadline) : String(Math.floor(Date.now() / 1e3) + DEFAULT_DEADLINE_SECONDS));
1358
+ const deadline = deadlineOverride ?? (Number.isFinite(apiDeadline) && apiDeadline > 0 ? String(order.deadline) : String(Math.floor(Date.now() / 1e3) + lifetimeSeconds));
1270
1359
  const executionChainId = String(order.executionChainId || fallbackExecutionChainId || "0");
1271
1360
  if (!/^\d+$/.test(executionChainId) || BigInt(executionChainId) <= 0n) throw new Error("ZeroDelta quote did not include an execution chain.");
1272
1361
  return {
@@ -1281,10 +1370,10 @@ function normalizeOrderRequest(order, payer, destination, fallbackExecutionChain
1281
1370
  deadline
1282
1371
  };
1283
1372
  }
1284
- function normalizeOrderRequests(requests, payer, destination, fallbackExecutionChainId) {
1373
+ function normalizeOrderRequests(requests, payer, destination, fallbackExecutionChainId, lifetimeSeconds = DEFAULT_DEADLINE_SECONDS) {
1285
1374
  if (!requests.length) throw new Error("ZeroDelta quote did not include any order requests.");
1286
1375
  return requests.map(
1287
- (request, index) => index === 0 ? normalizeOrderRequest(request, payer, destination, fallbackExecutionChainId) : normalizeOrderRequest(request, payer, destination, fallbackExecutionChainId, String(request.deadline || "0"))
1376
+ (request, index) => index === 0 ? normalizeOrderRequest(request, payer, destination, fallbackExecutionChainId, void 0, lifetimeSeconds) : normalizeOrderRequest(request, payer, destination, fallbackExecutionChainId, String(request.deadline || "0"))
1288
1377
  );
1289
1378
  }
1290
1379
  function assertQuoteMatchesSelection({ quote, order, orders, option, destinationToken, destination, payer, result }) {
@@ -1334,7 +1423,8 @@ function assertQuoteMatchesSelection({ quote, order, orders, option, destination
1334
1423
  if (BigInt(finalOrder.askTokenAmount || "0") < BigInt(result.recipientReceivesRaw || "0")) {
1335
1424
  throw new Error("ZeroDelta order guarantees less than the displayed receive amount.");
1336
1425
  }
1337
- if (!Number.isFinite(deadline) || deadline <= now || deadline > now + MAX_DEADLINE_SECONDS) {
1426
+ const maxDeadline = maxDeadlineSeconds(quote);
1427
+ if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline) {
1338
1428
  throw new Error("ZeroDelta quote deadline is invalid or too far in the future.");
1339
1429
  }
1340
1430
  for (let index = 1; index < list.length; index += 1) {
@@ -1347,7 +1437,7 @@ function assertQuoteMatchesSelection({ quote, order, orders, option, destination
1347
1437
  throw new Error("ZeroDelta chained quote returned disconnected execution chains.");
1348
1438
  }
1349
1439
  const followupDeadline = Number(current.deadline || 0);
1350
- if (followupDeadline !== 0 && (!Number.isFinite(followupDeadline) || followupDeadline <= now || followupDeadline > now + MAX_DEADLINE_SECONDS)) {
1440
+ if (followupDeadline !== 0 && (!Number.isFinite(followupDeadline) || followupDeadline <= now || followupDeadline > now + maxDeadline)) {
1351
1441
  throw new Error("ZeroDelta chained quote returned an invalid follow-up deadline.");
1352
1442
  }
1353
1443
  }
@@ -1510,7 +1600,7 @@ async function buildRoute({
1510
1600
  if (!requestList.length) throw new Error("ZeroDelta quote did not include an order request.");
1511
1601
  const sourceChain = chainById(chains, option.chainId);
1512
1602
  const escrow = checkEscrow(option.chainId, quote.escrowAddress, sourceChain?.escrowContract);
1513
- const orders = normalizeOrderRequests(requestList, payer, destination, quote.executionChainId);
1603
+ const orders = normalizeOrderRequests(requestList, payer, destination, quote.executionChainId, recommendedDeadlineSeconds(quote));
1514
1604
  const order = orders[0];
1515
1605
  assertQuoteMatchesSelection({ quote, order, orders, option, destinationToken, destination, payer, result });
1516
1606
  const needsNativeFee = requiresNativeBridgeFee(quote, option);
@@ -1650,10 +1740,18 @@ function classifyQuoteError(error) {
1650
1740
  message: `This payment was blocked by compliance screening \u2014 the recipient is ${label}. Choose a different recipient or connect a different wallet.`
1651
1741
  };
1652
1742
  }
1743
+ function amountFieldError(error) {
1744
+ const fieldErrors = error?.fieldErrors;
1745
+ if (!Array.isArray(fieldErrors)) return null;
1746
+ const entry = fieldErrors.find((e) => e && typeof e === "object" && e.field === "fromAmount" && typeof e.message === "string");
1747
+ const message = entry ? sanitizeMessage(entry.message, "") : "";
1748
+ return message || null;
1749
+ }
1653
1750
  function nowFresh(entry) {
1654
1751
  return !!entry && Date.now() - entry.at < API_CACHE_TTL_MS;
1655
1752
  }
1656
1753
  function isTransientQuoteError(error) {
1754
+ if (error?.code === "BRIDGE_RATE_LIMITED" || Array.isArray(error?.fieldErrors) && error.fieldErrors.length > 0) return false;
1657
1755
  return error?.code === "gateway_timeout" || error?.status === 502 || error?.status === 503 || error?.status === 504 || /failed to get swap quote|timeout|temporar/i.test(error?.message || "");
1658
1756
  }
1659
1757
  function wait(ms) {
@@ -1705,6 +1803,7 @@ function createApiClient(cfg) {
1705
1803
  status: response.status,
1706
1804
  code: json?.error?.code || json?.code || (response.status >= 502 ? "gateway_timeout" : "api_error"),
1707
1805
  fieldErrors: json?.error?.fieldErrors || json?.fieldErrors,
1806
+ limits: json?.error?.limits || json?.limits,
1708
1807
  reasons: json?.error?.reasons || json?.reasons
1709
1808
  });
1710
1809
  }
@@ -2493,6 +2592,8 @@ function createEngine(config = {}) {
2493
2592
  ...allowed ? { allowedAssets: allowed } : {},
2494
2593
  supportedChainIds: SUPPORTED_CHAIN_IDS,
2495
2594
  brokenLanes: suppressedLanes(health),
2595
+ // Same read, same degraded mode: a null health response limits nothing.
2596
+ limitedLanes: limitedLanes(health),
2496
2597
  vaultIcons
2497
2598
  });
2498
2599
  },
@@ -2794,6 +2895,7 @@ function useFlow(args) {
2794
2895
  const [plan, setPlan] = react.useState(null);
2795
2896
  const [selectedId, setSelectedId] = react.useState(null);
2796
2897
  const [error, setError] = react.useState(null);
2898
+ const [fieldError, setFieldError] = react.useState(null);
2797
2899
  const [insufficient, setInsufficient] = react.useState(false);
2798
2900
  const [nativeShortfall, setNativeShortfall] = react.useState(null);
2799
2901
  const [steps, setSteps] = react.useState([]);
@@ -2808,6 +2910,7 @@ function useFlow(args) {
2808
2910
  const reload = react.useCallback(() => setNonce((n) => n + 1), []);
2809
2911
  react.useEffect(() => {
2810
2912
  if (busyRef.current) return;
2913
+ setFieldError(null);
2811
2914
  if (!enabled || !wallet.account) {
2812
2915
  setStatus("idle");
2813
2916
  setPlan(null);
@@ -2831,6 +2934,7 @@ function useFlow(args) {
2831
2934
  if (id !== reqId.current) return;
2832
2935
  setPlan(null);
2833
2936
  setError(e?.message || "Could not price this right now.");
2937
+ setFieldError(amountFieldError(e));
2834
2938
  setStatus("error");
2835
2939
  onError?.(e instanceof Error ? e : new Error(String(e)));
2836
2940
  }
@@ -2997,6 +3101,7 @@ function useFlow(args) {
2997
3101
  selected,
2998
3102
  selectRoute: setSelectedId,
2999
3103
  error,
3104
+ fieldError,
3000
3105
  insufficient,
3001
3106
  nativeShortfall,
3002
3107
  steps,
@@ -3234,6 +3339,10 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
3234
3339
  .sg-send-row{display:flex;align-items:center;gap:12px}
3235
3340
  .sg-send-row .sg-amount{flex:1 1 auto;min-width:0}
3236
3341
  .sg-send-bal{font-size:11px;color:var(--sg-text-muted);margin-top:6px}
3342
+ /* the line under the amount: a lane's current size limit (muted), or why the amount is refused (danger) */
3343
+ .sg-amount-note{font-size:12px;font-weight:600;line-height:1.35;color:var(--sg-text-muted);margin-top:6px}
3344
+ .sg-amount-note[data-tone="error"]{color:var(--sg-danger)}
3345
+ .sg-amount[aria-invalid="true"]{color:var(--sg-danger)}
3237
3346
  .sg-pct-row{display:flex;gap:8px;margin-top:12px}
3238
3347
  .sg-pct{flex:1 1 0;padding:7px 0;border-radius:var(--sg-radius-cta);border:1px solid var(--sg-border);background:var(--sg-bg);color:var(--sg-text-muted);font:inherit;font-size:12px;font-weight:600;cursor:pointer;transition:color 120ms ease,border-color 120ms ease}
3239
3348
  .sg-pct:hover:not(:disabled){color:var(--sg-accent);border-color:var(--sg-accent)}
@@ -3275,6 +3384,8 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
3275
3384
  .sg-tokrow--off:hover,.sg-tokrow[disabled]:hover{background:transparent}
3276
3385
  .sg-tokrow--off .sg-tokrow-sym,.sg-tokrow--off .sg-tokrow-name,.sg-tokrow--off .sg-tokrow-bal{color:var(--sg-text-muted)}
3277
3386
  .sg-tokrow-hint{display:block;font-size:11px;font-weight:600;color:var(--sg-danger)}
3387
+ /* on a row that stays selectable (a limited lane): a caveat, not a refusal */
3388
+ .sg-tokrow-hint[data-tone="note"]{color:var(--sg-text-muted)}
3278
3389
  .sg-sel-empty{padding:26px 10px;text-align:center;font-size:13px;color:var(--sg-text-muted)}
3279
3390
 
3280
3391
  /* wide (duo) layout: main card + receive/routes side card. The collapse is keyed to the WIDGET'S
@@ -3811,10 +3922,16 @@ function AmountInput(props) {
3811
3922
  placeholder: props.placeholder ?? "0.0",
3812
3923
  value: props.value,
3813
3924
  disabled: props.disabled,
3925
+ "aria-invalid": props.invalid || void 0,
3926
+ "aria-describedby": props.describedBy,
3814
3927
  onChange: (e) => props.onChange(e.target.value.replace(/[^0-9.,]/g, ""))
3815
3928
  }
3816
3929
  );
3817
3930
  }
3931
+ function AmountNote(props) {
3932
+ const error = props.tone === "error";
3933
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { id: props.id, className: "sg-amount-note", "data-tone": error ? "error" : void 0, role: error ? "alert" : void 0, children: props.children });
3934
+ }
3818
3935
  function StatusPanel(props) {
3819
3936
  const tone = props.tone ?? "neutral";
3820
3937
  return (
@@ -4423,7 +4540,7 @@ function TokenSelect(props) {
4423
4540
  ] }),
4424
4541
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tokrow-end", children: [
4425
4542
  bal ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-bal sg-mono", children: bal.formatted }) : null,
4426
- disabled && st?.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-hint", children: st.hint }) : null,
4543
+ st?.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-hint", "data-tone": disabled ? void 0 : "note", children: st.hint }) : null,
4427
4544
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-chain", children: CHAIN_LABELS[chainId] || `Chain ${chainId}` })
4428
4545
  ] })
4429
4546
  ]
@@ -5027,7 +5144,40 @@ function PaymentIsland(props) {
5027
5144
  const exToAsset = exTo?.symbol;
5028
5145
  const normEx = normalizeDecimalText(exAmount);
5029
5146
  const exAmountValid = /^\d+(\.\d+)?$/.test(normEx) && Number(normEx) > 0 && Number(normEx) <= 1e9;
5030
- const exQuotable = !rampMode && exAmountValid && Boolean(exFromChainId && exFromAsset && exToChainId && exToAsset);
5147
+ const [catalogue, setCatalogue] = react.useState(null);
5148
+ react.useEffect(() => {
5149
+ if (bankSettlement || !isPay && rampMode) return;
5150
+ let alive = true;
5151
+ engine.fetchCatalogue(isPay ? void 0 : exAllowed, isPay ? "stable" : exProduct).then((next) => {
5152
+ if (alive) setCatalogue(next);
5153
+ });
5154
+ return () => {
5155
+ alive = false;
5156
+ };
5157
+ }, [engine, isPay, rampMode, bankSettlement, exAllowed, exProduct]);
5158
+ const chains = react.useMemo(() => {
5159
+ const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
5160
+ return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
5161
+ }, [catalogue]);
5162
+ const registryTokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
5163
+ const exchangeTokens = react.useMemo(() => isPay ? [] : registryTokens, [isPay, registryTokens]);
5164
+ const exSourceTokens = react.useMemo(() => isPay ? [] : catalogue?.sources ?? [], [isPay, catalogue]);
5165
+ const exFromToken = react.useMemo(() => exFrom ? findToken(exchangeTokens, exFrom.chainId, exFrom.symbol) : null, [exchangeTokens, exFrom]);
5166
+ const exToToken = react.useMemo(() => exTo ? findToken(exchangeTokens, exTo.chainId, exTo.symbol) : null, [exchangeTokens, exTo]);
5167
+ const exLaneLimit = react.useMemo(
5168
+ () => !isPay && !rampMode && exFromToken && exToToken ? laneLimitFor(exToToken, exFromToken, catalogue?.limitedLanes) : void 0,
5169
+ [isPay, rampMode, catalogue, exFromToken, exToToken]
5170
+ );
5171
+ const exLimitSymbol = exLaneLimit ? laneLimitSymbol(exLaneLimit, exFromToken ? tokenTicker(exFromToken) : void 0) : "";
5172
+ const exOverLimit = react.useMemo(() => {
5173
+ if (!exLaneLimit || !exFromToken || !exAmountValid) return false;
5174
+ try {
5175
+ return exceedsLaneLimit(exLaneLimit, normEx, assetDecimals(exFromToken));
5176
+ } catch {
5177
+ return false;
5178
+ }
5179
+ }, [exLaneLimit, exFromToken, exAmountValid, normEx]);
5180
+ const exQuotable = !rampMode && exAmountValid && !exOverLimit && Boolean(exFromChainId && exFromAsset && exToChainId && exToAsset);
5031
5181
  const payFundingAssets = props.fundingAssets?.length ? props.fundingAssets : ["USDC", "USDT", "USDE"];
5032
5182
  const payParamsKey = `pay|${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}|${payFundingAssets.join(",")}`;
5033
5183
  const exParamsKey = `${kind}|${mode}|${exFromChainId}|${exFromAsset}|${exToChainId}|${exToAsset}|${normEx}|${props.recipient ?? ""}`;
@@ -5111,24 +5261,6 @@ function PaymentIsland(props) {
5111
5261
  }
5112
5262
  return map;
5113
5263
  }, [annotated, holdings.loading]);
5114
- const [catalogue, setCatalogue] = react.useState(null);
5115
- react.useEffect(() => {
5116
- if (bankSettlement || !isPay && rampMode) return;
5117
- let alive = true;
5118
- engine.fetchCatalogue(isPay ? void 0 : exAllowed, isPay ? "stable" : exProduct).then((next) => {
5119
- if (alive) setCatalogue(next);
5120
- });
5121
- return () => {
5122
- alive = false;
5123
- };
5124
- }, [engine, isPay, rampMode, bankSettlement, exAllowed, exProduct]);
5125
- const chains = react.useMemo(() => {
5126
- const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
5127
- return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
5128
- }, [catalogue]);
5129
- const registryTokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
5130
- const exchangeTokens = react.useMemo(() => isPay ? [] : registryTokens, [isPay, registryTokens]);
5131
- const exSourceTokens = react.useMemo(() => isPay ? [] : catalogue?.sources ?? [], [isPay, catalogue]);
5132
5264
  const [exBalances, setExBalances] = react.useState({});
5133
5265
  const exBalReq = react.useRef(0);
5134
5266
  react.useEffect(() => {
@@ -5148,8 +5280,6 @@ function PaymentIsland(props) {
5148
5280
  if (id === exBalReq.current) setExBalances(res);
5149
5281
  });
5150
5282
  }, [engine, isPay, wallet.account, exchangeTokens]);
5151
- const exFromToken = react.useMemo(() => exFrom ? findToken(exchangeTokens, exFrom.chainId, exFrom.symbol) : null, [exchangeTokens, exFrom]);
5152
- const exToToken = react.useMemo(() => exTo ? findToken(exchangeTokens, exTo.chainId, exTo.symbol) : null, [exchangeTokens, exTo]);
5153
5283
  const exFromPicker = react.useMemo(() => exProduct === "rwa" ? counterpartTokens(exSourceTokens, exToToken) : exSourceTokens, [exProduct, exSourceTokens, exToToken]);
5154
5284
  const exToPicker = react.useMemo(() => exProduct === "rwa" ? counterpartTokens(exchangeTokens, exFromToken) : exchangeTokens, [exProduct, exchangeTokens, exFromToken]);
5155
5285
  const exRwaSeeded = react.useRef(false);
@@ -5174,7 +5304,11 @@ function PaymentIsland(props) {
5174
5304
  continue;
5175
5305
  }
5176
5306
  const verdict = destinationAvailability(token, catalogue, exFromToken);
5177
- if (verdict === "available") continue;
5307
+ if (verdict === "available") {
5308
+ const limit = laneLimitFor(token, exFromToken, catalogue.limitedLanes);
5309
+ if (limit) states[key] = { disabled: false, hint: laneLimitHint(limit, laneLimitSymbol(limit, exFromToken ? tokenTicker(exFromToken) : void 0)) };
5310
+ continue;
5311
+ }
5178
5312
  states[key] = {
5179
5313
  disabled: true,
5180
5314
  reason: verdict === "hub-only" ? `${tokenTicker(token)} cannot be delivered on this chain.` : "ZeroDelta cannot deliver this asset here.",
@@ -5290,6 +5424,7 @@ function PaymentIsland(props) {
5290
5424
  const exToTileRef = react.useRef(null);
5291
5425
  const regionRef = react.useRef(null);
5292
5426
  const panelId = react.useId();
5427
+ const exAmountNoteId = react.useId();
5293
5428
  react.useEffect(() => setView("main"), [wallet.account, payParamsKey]);
5294
5429
  react.useEffect(() => setHist(null), [wallet.account]);
5295
5430
  const firstRender = react.useRef(true);
@@ -5393,6 +5528,9 @@ function PaymentIsland(props) {
5393
5528
  const raw = BigInt(exFromBal.raw);
5394
5529
  setExAmount(formatUnits(p === 100 ? raw : raw * BigInt(p) / 100n, assetDecimals(exFromToken)));
5395
5530
  };
5531
+ const exGatewayAmountError = !isPay && exQuotable && flow.status === "error" && flow.steps.length === 0 ? flow.fieldError : null;
5532
+ const exAmountError = exOverLimit && exLaneLimit ? laneLimitError(exLaneLimit, exLimitSymbol) : exGatewayAmountError;
5533
+ const exAmountNote = exAmountError || (exLaneLimit ? laneLimitHint(exLaneLimit, exLimitSymbol) : null);
5396
5534
  const exchangeControls = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5397
5535
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ft", style: { marginTop: 12 }, children: [
5398
5536
  /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "From", pick: exFrom, token: exFromToken, disabled: submitting, btnRef: exFromTileRef, onClick: () => setView("from") }),
@@ -5403,8 +5541,18 @@ function PaymentIsland(props) {
5403
5541
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "Send" }),
5404
5542
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-row", children: [
5405
5543
  exFrom ? /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: exFrom.symbol, logoUrl: exFromToken?.logoUrl, chainId: exFrom.chainId, size: "sm" }) : null,
5406
- /* @__PURE__ */ jsxRuntime.jsx(AmountInput, { value: exAmount, onChange: setExAmount, disabled: submitting })
5544
+ /* @__PURE__ */ jsxRuntime.jsx(
5545
+ AmountInput,
5546
+ {
5547
+ value: exAmount,
5548
+ onChange: setExAmount,
5549
+ disabled: submitting,
5550
+ invalid: !!exAmountError,
5551
+ describedBy: exAmountNote ? exAmountNoteId : void 0
5552
+ }
5553
+ )
5407
5554
  ] }),
5555
+ exAmountNote ? /* @__PURE__ */ jsxRuntime.jsx(AmountNote, { id: exAmountNoteId, tone: exAmountError ? "error" : "neutral", children: exAmountNote }) : null,
5408
5556
  exFromBal ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-bal sg-mono", children: [
5409
5557
  "Balance: ",
5410
5558
  exFromBal.formatted,
@@ -5536,7 +5684,7 @@ function PaymentIsland(props) {
5536
5684
  lastTxOwned ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
5537
5685
  ] });
5538
5686
  } else {
5539
- const quoteError = flow.status === "error" && flow.steps.length === 0;
5687
+ const quoteError = flow.status === "error" && flow.steps.length === 0 && !exGatewayAmountError;
5540
5688
  const walletError = flow.status === "error" && flow.steps.length > 0;
5541
5689
  body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5542
5690
  /* @__PURE__ */ jsxRuntime.jsx(IdentityLine, { account: wallet.account, email: identity?.email }),
@@ -6207,7 +6355,11 @@ function StableGenieExchange(props) {
6207
6355
  continue;
6208
6356
  }
6209
6357
  const verdict = destinationAvailability(token, catalogue, fromToken);
6210
- if (verdict === "available") continue;
6358
+ if (verdict === "available") {
6359
+ const limit = laneLimitFor(token, fromToken, catalogue.limitedLanes);
6360
+ if (limit) states[key] = { disabled: false, hint: laneLimitHint(limit, laneLimitSymbol(limit, fromToken ? tokenTicker(fromToken) : void 0)) };
6361
+ continue;
6362
+ }
6211
6363
  states[key] = {
6212
6364
  disabled: true,
6213
6365
  reason: verdict === "hub-only" ? `${tokenTicker(token)} cannot be delivered on this chain \u2014 choose an execution chain.` : "ZeroDelta cannot deliver this asset here.",
@@ -6219,9 +6371,23 @@ function StableGenieExchange(props) {
6219
6371
  const normalizedAmount = normalizeDecimalText(amount);
6220
6372
  const amountValid = /^\d+(\.\d+)?$/.test(normalizedAmount) && Number(normalizedAmount) > 0 && Number(normalizedAmount) <= 1e9;
6221
6373
  const rampMode = mode !== "exchange";
6374
+ const laneLimit = react.useMemo(
6375
+ () => mode === "exchange" && fromToken && toToken ? laneLimitFor(toToken, fromToken, catalogue?.limitedLanes) : void 0,
6376
+ [mode, catalogue, fromToken, toToken]
6377
+ );
6378
+ const limitSymbol = laneLimit ? laneLimitSymbol(laneLimit, fromTicker) : "";
6379
+ const overLimit = react.useMemo(() => {
6380
+ if (!laneLimit || !fromToken || !amountValid) return false;
6381
+ try {
6382
+ return exceedsLaneLimit(laneLimit, normalizedAmount, assetDecimals(fromToken));
6383
+ } catch {
6384
+ return false;
6385
+ }
6386
+ }, [laneLimit, fromToken, amountValid, normalizedAmount]);
6387
+ const amountNoteId = react.useId();
6222
6388
  const inUniverse = (p) => Boolean(p && tokens.some((t) => Number(t.chainId) === p.chainId && symbolKey(t.symbol) === p.symbol));
6223
6389
  const cryptoReady = rampMode ? inUniverse(mode === "onramp" ? to : from) : inUniverse(from) && inUniverse(to);
6224
- const quotable = mode === "exchange" && inUniverse(from) && inUniverse(to) && amountValid;
6390
+ const quotable = mode === "exchange" && inUniverse(from) && inUniverse(to) && amountValid && !overLimit;
6225
6391
  const [balances, setBalances] = react.useState({});
6226
6392
  const balReq = react.useRef(0);
6227
6393
  react.useEffect(() => {
@@ -6269,7 +6435,7 @@ function StableGenieExchange(props) {
6269
6435
  engine.quoteSwapPreview({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient: props.recipient }).then((data) => {
6270
6436
  if (id === prevReq.current) setPreview({ status: "ready", data });
6271
6437
  }).catch((e) => {
6272
- if (id === prevReq.current) setPreview({ status: "error", error: e instanceof Error ? e.message : String(e) });
6438
+ if (id === prevReq.current) setPreview({ status: "error", error: e instanceof Error ? e.message : String(e), fieldError: amountFieldError(e) });
6273
6439
  });
6274
6440
  }, 350);
6275
6441
  return () => clearTimeout(timer);
@@ -6279,6 +6445,9 @@ function StableGenieExchange(props) {
6279
6445
  const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
6280
6446
  const quoting = connected ? flow.status === "loading" : preview.status === "loading";
6281
6447
  const quoteError = !quotable ? null : connected ? flow.status === "error" ? flow.error : null : preview.status === "error" ? preview.error ?? "No route." : null;
6448
+ const gatewayAmountError = !quoteError ? null : connected ? flow.fieldError : preview.fieldError ?? null;
6449
+ const amountError = overLimit && laneLimit ? laneLimitError(laneLimit, limitSymbol) : gatewayAmountError;
6450
+ const amountNote = mode === "exchange" ? amountError || (laneLimit ? laneLimitHint(laneLimit, limitSymbol) : null) : null;
6282
6451
  const receive = connected ? flow.selected?.receive.amount : preview.data?.receive;
6283
6452
  const meta = connected ? flow.selected ? { bridge: flow.selected.quote.bridge || "ZeroDelta", feeBps: Number(flow.selected.quote.feeBps || 0), duration: Number(flow.selected.quote.estimatedDuration || 0) } : null : preview.data ? { bridge: preview.data.bridge || "ZeroDelta", feeBps: preview.data.feeBps, duration: preview.data.estimatedDuration } : null;
6284
6453
  const pct = (p) => {
@@ -6355,8 +6524,18 @@ function StableGenieExchange(props) {
6355
6524
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: mode === "onramp" ? `You pay (${fiatCurrency})` : "Send" }),
6356
6525
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-row", children: [
6357
6526
  mode === "onramp" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-fiat", children: FIAT.find((f) => f.code === fiatCurrency)?.glyph ?? "$" }) : from ? /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: from.symbol, logoUrl: fromToken?.logoUrl, chainId: from.chainId, size: "sm" }) : null,
6358
- /* @__PURE__ */ jsxRuntime.jsx(AmountInput, { value: amount, onChange: setAmount, disabled: submitting })
6527
+ /* @__PURE__ */ jsxRuntime.jsx(
6528
+ AmountInput,
6529
+ {
6530
+ value: amount,
6531
+ onChange: setAmount,
6532
+ disabled: submitting,
6533
+ invalid: !!amountError,
6534
+ describedBy: amountNote ? amountNoteId : void 0
6535
+ }
6536
+ )
6359
6537
  ] }),
6538
+ amountNote ? /* @__PURE__ */ jsxRuntime.jsx(AmountNote, { id: amountNoteId, tone: amountError ? "error" : "neutral", children: amountNote }) : null,
6360
6539
  mode !== "onramp" && fromBal ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-bal sg-mono", children: [
6361
6540
  "Balance: ",
6362
6541
  fromBal.formatted,
@@ -6370,7 +6549,7 @@ function StableGenieExchange(props) {
6370
6549
  ) : null
6371
6550
  ] }),
6372
6551
  rampMode ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { children: mode === "onramp" ? "Buy supported stablecoins with card or bank transfer \u2014 coming soon. Today the widget settles crypto-to-crypto." : "Cash out supported stablecoins to your bank \u2014 coming soon. Today the widget settles crypto-to-crypto." }) : null,
6373
- !rampMode && quoteError && !wide ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: quoteError }) : null,
6552
+ !rampMode && quoteError && !gatewayAmountError && !wide ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: quoteError }) : null,
6374
6553
  !rampMode && !wide && quotable && !quoteError ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
6375
6554
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "You receive (estimated)" }),
6376
6555
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-anchor sg-mono", children: quoting ? "\u2026" : receive ? `${receive} ${toTicker}` : "\u2014" }),
@@ -6402,6 +6581,12 @@ function StableGenieExchange(props) {
6402
6581
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-noroutes-title", children: soonLabel }),
6403
6582
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-noroutes-sub", children: "Fiat rails are on the roadmap. Crypto-to-crypto exchange is live today." })
6404
6583
  ] });
6584
+ } else if (amountError) {
6585
+ side = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-noroutes", children: [
6586
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-noroutes-icon", children: /* @__PURE__ */ jsxRuntime.jsx(RouteGlyph, {}) }),
6587
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-noroutes-title", children: "Change the amount" }),
6588
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-noroutes-sub", children: amountError })
6589
+ ] });
6405
6590
  } else if (quoting) {
6406
6591
  side = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
6407
6592
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-skel" }),
package/dist/mount.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export { M as MountConfig, r as mount } from './mount-Dtbtdry1.cjs';
1
+ export { M as MountConfig, r as mount } from './mount-D8hY-a-s.cjs';
2
2
  import 'react';
3
- import './verify-57gjg_dM.cjs';
3
+ import './verify-C1VaWfiy.cjs';
package/dist/mount.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { M as MountConfig, r as mount } from './mount-Bver3O2z.js';
1
+ export { M as MountConfig, r as mount } from './mount-Blg-caPn.js';
2
2
  import 'react';
3
- import './verify-57gjg_dM.js';
3
+ import './verify-C1VaWfiy.js';
package/dist/mount.js CHANGED
@@ -1,2 +1,2 @@
1
- export { mount } from './chunk-OOESQYM3.js';
2
- import './chunk-FDCSZ3OY.js';
1
+ export { mount } from './chunk-NYIORRFU.js';
2
+ import './chunk-53K3BXT5.js';