@glacislabs/stablegenie-zerodelta 4.20.1 → 4.22.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.
@@ -1061,6 +1061,7 @@ function hubDeliverableSymbols(tokens, execution) {
1061
1061
  function isSourceToken(token, ctx) {
1062
1062
  const chainId = Number(token.chainId);
1063
1063
  if (!ctx.sourceChains.has(chainId)) return false;
1064
+ if (ctx.zdHeavySources?.has(tokenKey(chainId, token.address))) return true;
1064
1065
  return ctx.execution.has(chainId) || !isKnownUnbridgeable(token.bridge) && ctx.source.has(tokenKey(chainId, token.address));
1065
1066
  }
1066
1067
  function directLaneOK(token, source, lanes) {
@@ -1079,6 +1080,7 @@ function laneLimitFor(token, source, limitedLanes2) {
1079
1080
  }
1080
1081
  function destinationAvailability(token, ctx, source) {
1081
1082
  if (brokenLaneFor(token, source ?? void 0, ctx.brokenLanes)) return "unreachable";
1083
+ if (source && ctx.zdHeavyLanes?.has(laneKey(source.chainId, source.address, token.chainId, token.address))) return "available";
1082
1084
  if (directLaneOK(token, source ?? void 0, ctx.lanes)) {
1083
1085
  if (ctx.execution.has(Number(token.chainId))) return "available";
1084
1086
  if (token.isChainedDestination === true) return "available";
@@ -1097,6 +1099,7 @@ function hasReachableDestination(source, catalogue, ctx) {
1097
1099
  }
1098
1100
  function buildCatalogue(input) {
1099
1101
  const { chains, tokens, routes, supportedChainIds, brokenLanes } = input;
1102
+ const zdHeavy = (input.zdHeavyRoutes ?? []).filter((r) => !!r && typeof r === "object" && !Array.isArray(r) && r.isEnabled !== false && r.isQuotable === true);
1100
1103
  const product = input.product ?? "stable";
1101
1104
  const universe = productAssets(product);
1102
1105
  const allowedAssets = input.allowedAssets ? new Set([...input.allowedAssets].filter((a) => universe.has(a))) : universe;
@@ -1104,7 +1107,10 @@ function buildCatalogue(input) {
1104
1107
  const registryChainIds = new Set(enabledChains.map((c) => Number(c.chainId)));
1105
1108
  const sourceChains = new Set([...registryChainIds].filter((id) => supportedChainIds.has(id)));
1106
1109
  const execution = executionChainIds(enabledChains);
1107
- const projected = product === "rwa" ? routes.filter((route) => route.isEnabled !== false) : executableRoutes(routes);
1110
+ const projected = [...product === "rwa" ? routes.filter((route) => route.isEnabled !== false) : executableRoutes(routes), ...zdHeavy];
1111
+ const zdHeavyLanes = laneKeys(zdHeavy);
1112
+ const zdHeavySources = sourceKeys(zdHeavy);
1113
+ const zdHeavyKeys = /* @__PURE__ */ new Set([...zdHeavySources, ...destinationKeys(zdHeavy)]);
1108
1114
  const source = sourceKeys(projected);
1109
1115
  const destination = destinationKeys(projected);
1110
1116
  const lanes = laneKeys(projected);
@@ -1119,14 +1125,15 @@ function buildCatalogue(input) {
1119
1125
  if (!chainIds.has(chainId)) return false;
1120
1126
  if (product === "rwa") return true;
1121
1127
  if (execution.has(chainId) || token.isChainedDestination === true) return true;
1122
- if (!isExecutableBridge(token)) return false;
1123
1128
  const key2 = tokenKey(token.chainId, token.address);
1129
+ if (zdHeavyKeys.has(key2)) return true;
1130
+ if (!isExecutableBridge(token)) return false;
1124
1131
  return source.has(key2) || destination.has(key2);
1125
1132
  });
1126
1133
  const ready = chains.length > 0 && routes.length > 0 && projectedCatalogue.length > 0;
1127
1134
  const catalogue = ready ? projectedCatalogue : allowed;
1128
1135
  const hubSymbols = hubDeliverableSymbols(catalogue, execution);
1129
- const ctx = { source, destination, lanes, execution, sourceChains, hubSymbols, ...brokenLanes ? { brokenLanes } : {} };
1136
+ const ctx = { source, destination, lanes, execution, sourceChains, hubSymbols, ...zdHeavy.length ? { zdHeavyLanes, zdHeavySources } : {}, ...brokenLanes ? { brokenLanes } : {} };
1130
1137
  const sellable = (token) => product !== "rwa" || isSellableRwa(token);
1131
1138
  const sources = ready ? catalogue.filter((token) => sellable(token) && isSourceToken(token, ctx) && hasReachableDestination(token, catalogue, ctx)) : (
1132
1139
  // Unprojected: the only rule we can still apply with confidence is the escrow-chain bound,
@@ -1773,13 +1780,22 @@ var MAX_STEPS = 8;
1773
1780
  function isZdHeavy(r, steps) {
1774
1781
  return r.protocol === "zdheavy" || steps.some((s) => Number(s.stepNumber ?? 0) >= ZDH_FIRST_STEP);
1775
1782
  }
1783
+ var FILL_EVIDENCE = /* @__PURE__ */ new Set(["filled", "consumed", "step_executed", "paid_out", "delivered"]);
1784
+ function ownerCancelServedAsDeliveryFailure(steps) {
1785
+ const txHash = (s) => typeof s.txHash === "string" && /^0x[0-9a-fA-F]{64}$/.test(s.txHash);
1786
+ const anyTx = (s) => typeof s.txHash === "string" && s.txHash.length > 0;
1787
+ const cancelTx = steps.some((s) => s.stepName === "cancelled" && txHash(s));
1788
+ const refunded = steps.some((s) => s.stepName === "refunded" && word(s.stepStatus) === "recovered" && txHash(s));
1789
+ const filled = steps.some((s) => FILL_EVIDENCE.has(String(s.stepName)) && word(s.stepStatus) === "completed" && anyTx(s));
1790
+ return cancelTx && refunded && !filled;
1791
+ }
1776
1792
  function zdHeavyDelivery(own, rawSteps) {
1777
1793
  const named = rawSteps.filter((s) => s && typeof s === "object" && typeof s.stepName === "string");
1778
1794
  const lite = (name) => named.some((s) => Number(s.stepNumber ?? 0) < ZDH_FIRST_STEP && s.stepName === name && s.stepStatus === "completed");
1779
1795
  const events = named.map((s, i) => ({ s, i })).filter(({ s }) => Number(s.stepNumber ?? 0) >= ZDH_FIRST_STEP).sort((a, b) => (Date.parse(String(a.s.blockTimestamp ?? "")) || 0) - (Date.parse(String(b.s.blockTimestamp ?? "")) || 0) || a.i - b.i).map(({ s }) => s);
1780
1796
  const has = (name) => events.some((e) => e.stepName === name);
1781
1797
  const cancelled = has("cancelled");
1782
- const status = PROGRESS.has(own) && has("paid_out") && !cancelled ? "delivered" : own;
1798
+ const status = own === "delivery_failed" && ownerCancelServedAsDeliveryFailure(named) ? "cancelled" : PROGRESS.has(own) && has("paid_out") && !cancelled ? "delivered" : own;
1783
1799
  const steps = [];
1784
1800
  const push = (name, done) => {
1785
1801
  const last = steps[steps.length - 1];
@@ -1881,7 +1897,10 @@ function historyEntryFromOrder(raw2, tokens) {
1881
1897
  const toAsset = (to?.symbol ?? (str(r.finalToTokenSymbol) || str(r.toTokenSymbol))).slice(0, 10);
1882
1898
  const payAmount = amountOf(str(r.fromTokenRawAmount), from, r.fromTokenDecimals, str(r.fromTokenAmount));
1883
1899
  const receiveAmount = str(r.finalToTokenRawAmount) ? amountOf(str(r.finalToTokenRawAmount), to, r.finalToTokenDecimals, str(r.finalToTokenAmount)) : amountOf(str(r.toTokenRawAmount), to, r.toTokenDecimals, str(r.toTokenAmount));
1884
- const delivery = normalizeDelivery(r).phase;
1900
+ const tracked = normalizeDelivery(r);
1901
+ const delivery = tracked.phase;
1902
+ const protocol = str(r.protocol);
1903
+ const orderId = str(r.orderId);
1885
1904
  const wallet = str(r.wallet);
1886
1905
  const receiver = str(r.destinationReceiver);
1887
1906
  const at = str(r.createdAt) || str(r.submittedAt);
@@ -1903,6 +1922,11 @@ function historyEntryFromOrder(raw2, tokens) {
1903
1922
  status: "submitted",
1904
1923
  at: Number.isNaN(Date.parse(at)) ? (/* @__PURE__ */ new Date(0)).toISOString() : new Date(at).toISOString(),
1905
1924
  delivery: delivery === "tracking" || delivery === "unavailable" ? void 0 : delivery,
1925
+ ...tracked.status && delivery !== "tracking" && delivery !== "unavailable" ? { deliveryStatus: tracked.status.slice(0, 32) } : {},
1926
+ .../^[a-z]{1,16}$/.test(protocol) ? { protocol } : {},
1927
+ // Only a router order id (bytes32) is carried: it is the one thing a recovery call puts in a URL.
1928
+ .../^0x[0-9a-fA-F]{64}$/.test(orderId) ? { orderId } : {},
1929
+ ...r.claimable === true ? { claimable: true } : {},
1906
1930
  legs: [
1907
1931
  {
1908
1932
  index: 1,
@@ -1950,7 +1974,17 @@ function mergeHistory(local, remote, limit = WALLET_HISTORY_LIMIT) {
1950
1974
  if (seen.has(key2)) continue;
1951
1975
  seen.add(key2);
1952
1976
  const known = byHash.get(key2);
1953
- out.push(known ? { ...entry, delivery: known.delivery, legs: entry.legs ?? known.legs } : entry);
1977
+ out.push(
1978
+ known ? {
1979
+ ...entry,
1980
+ delivery: known.delivery,
1981
+ legs: entry.legs ?? known.legs,
1982
+ deliveryStatus: known.deliveryStatus,
1983
+ protocol: known.protocol,
1984
+ orderId: known.orderId,
1985
+ claimable: known.claimable
1986
+ } : entry
1987
+ );
1954
1988
  }
1955
1989
  for (const [key2, entry] of byHash) if (!seen.has(key2)) out.push(entry);
1956
1990
  return out.sort((a, b) => Date.parse(b.at) - Date.parse(a.at)).slice(0, limit);
@@ -2543,6 +2577,15 @@ function zdHeavyRouterPinned(chainId, router) {
2543
2577
  }
2544
2578
 
2545
2579
  // src/core/quote-option.ts
2580
+ function gateZdHeavyOptions(response, request, quotableRoutes) {
2581
+ if (!Array.isArray(response?.options)) return response;
2582
+ const matchesToken = (chainId, token, address, symbol) => typeof address === "string" && !!address && chainAddressKey(chainId, token) === chainAddressKey(chainId, address) || typeof symbol === "string" && !!symbolKey(symbol) && symbolKey(token) === symbolKey(symbol);
2583
+ const matchesLane = quotableRoutes.some(
2584
+ (r) => !!r && typeof r === "object" && !Array.isArray(r) && r.isEnabled !== false && r.isQuotable === true && Number(r.fromChainId) === Number(request.inputChain) && Number(r.toChainId) === Number(request.outputChain) && matchesToken(request.inputChain, request.inputToken, r.fromAddress, r.fromSymbol) && matchesToken(request.outputChain, request.outputToken, r.toAddress, r.toSymbol)
2585
+ );
2586
+ if (matchesLane) return response;
2587
+ return { ...response, options: response.options.filter((option) => option?.protocol !== "zdheavy") };
2588
+ }
2546
2589
  function zdHeavyExecutable(q) {
2547
2590
  const order = q.execution?.order;
2548
2591
  const chainId = typeof q.fromChainId === "number" ? q.fromChainId : Number(order?.chainNumber);
@@ -2799,16 +2842,16 @@ function normalizeOrderRequests(requests, payer, destination, fallbackExecutionC
2799
2842
  );
2800
2843
  }
2801
2844
  function assertQuoteMatchesSelection({ quote, order, orders, option, destinationToken, destination, payer, result, tokens = [] }) {
2802
- const list = orders?.length ? orders : [order];
2803
- const sourceOrder = list[0];
2804
- const finalOrder = list[list.length - 1];
2845
+ const list2 = orders?.length ? orders : [order];
2846
+ const sourceOrder = list2[0];
2847
+ const finalOrder = list2[list2.length - 1];
2805
2848
  const now = Math.floor(Date.now() / 1e3);
2806
2849
  const deadline = Number(sourceOrder.deadline || 0);
2807
2850
  const solana = isSolanaChainId(destination.chainId);
2808
2851
  if (solana && solanaDestinationAsset(destinationToken.address)?.symbol !== symbolKey(destinationToken.symbol)) {
2809
2852
  throw new Error("This Solana token is not supported for delivery; refusing to sign.");
2810
2853
  }
2811
- for (const current of list) {
2854
+ for (const current of list2) {
2812
2855
  if (normalizeAddress(current.owner) !== normalizeAddress(payer)) {
2813
2856
  throw new Error("ZeroDelta quote returned an owner that does not match the connected wallet.");
2814
2857
  }
@@ -2859,9 +2902,9 @@ function assertQuoteMatchesSelection({ quote, order, orders, option, destination
2859
2902
  if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline + DEADLINE_CLOCK_SKEW_SECONDS) {
2860
2903
  throw new Error("ZeroDelta quote deadline is invalid or too far in the future.");
2861
2904
  }
2862
- for (let index = 1; index < list.length; index += 1) {
2863
- const previous = list[index - 1];
2864
- const current = list[index];
2905
+ for (let index = 1; index < list2.length; index += 1) {
2906
+ const previous = list2[index - 1];
2907
+ const current = list2[index];
2865
2908
  if (normalizeAddress(previous.askToken) !== normalizeAddress(current.bidToken)) {
2866
2909
  throw new Error("ZeroDelta chained quote returned disconnected order tokens.");
2867
2910
  }
@@ -2938,10 +2981,10 @@ function keccak256Hex(bytes) {
2938
2981
  return out;
2939
2982
  }
2940
2983
  function toChecksumAddress(address) {
2941
- const lower3 = address.slice(2).toLowerCase();
2942
- const hash = keccak256Hex(new TextEncoder().encode(lower3));
2984
+ const lower4 = address.slice(2).toLowerCase();
2985
+ const hash = keccak256Hex(new TextEncoder().encode(lower4));
2943
2986
  let out = "0x";
2944
- for (let i = 0; i < 40; i++) out += Number.parseInt(hash[i], 16) >= 8 ? lower3[i].toUpperCase() : lower3[i];
2987
+ for (let i = 0; i < 40; i++) out += Number.parseInt(hash[i], 16) >= 8 ? lower4[i].toUpperCase() : lower4[i];
2945
2988
  return out;
2946
2989
  }
2947
2990
  function hasValidChecksum(address) {
@@ -2959,6 +3002,7 @@ var toHex = (v, opts) => "0x" + (typeof v === "bigint" ? v.toString(16).padStart
2959
3002
  var keccak256 = (h) => "0x" + keccak256Hex(hexToBytes(h));
2960
3003
  var STEP_VERSION = 5;
2961
3004
  var MAX_STEPS2 = 8;
3005
+ var ORDER_HEADER_LEN = 76;
2962
3006
  var StepKind = {
2963
3007
  LOCAL_PAYOUT: 1,
2964
3008
  REMOTE_PAYOUT: 2,
@@ -3099,11 +3143,11 @@ function decodeStep(step) {
3099
3143
  r.end();
3100
3144
  return result;
3101
3145
  }
3102
- function routerWord(addr) {
3103
- return concat([toHex(new Uint8Array(12)), checkedHex(addr, 20)]);
3146
+ function routerWord(addr2) {
3147
+ return concat([toHex(new Uint8Array(12)), checkedHex(addr2, 20)]);
3104
3148
  }
3105
- function ownerWord(addr) {
3106
- return routerWord(addr);
3149
+ function ownerWord(addr2) {
3150
+ return routerWord(addr2);
3107
3151
  }
3108
3152
  function encodeOrderHeader(serial, router, ownerType, owner) {
3109
3153
  if (!Number.isInteger(ownerType) || ownerType < 0 || ownerType > 255) throw new ZdHeavyCodecError("Invalid ownerType");
@@ -3474,6 +3518,16 @@ async function allowanceCovers(tx, account, ethCall) {
3474
3518
  }
3475
3519
 
3476
3520
  // src/core/zdheavy-route.ts
3521
+ var ZdHeavyQuoteExpiredError = class extends Error {
3522
+ code = "zdheavy_quote_expired";
3523
+ constructor() {
3524
+ super("This ZD Heavy quote expired before it was signed. A fresh quote is loading \u2014 review it and press Exchange again.");
3525
+ this.name = "ZdHeavyQuoteExpiredError";
3526
+ }
3527
+ };
3528
+ function assertZdHeavyQuoteFresh(order, nowSec) {
3529
+ if (order && (order.expiresAt <= nowSec || order.expiryDate <= nowSec)) throw new ZdHeavyQuoteExpiredError();
3530
+ }
3477
3531
  function zdHeavyExpected(route, owner, receiver, tokens, routes) {
3478
3532
  const heavy = route.zdHeavy;
3479
3533
  if (!heavy) throw new Error("Missing ZD Heavy order.");
@@ -3499,6 +3553,7 @@ function zdHeavyExpected(route, owner, receiver, tokens, routes) {
3499
3553
  };
3500
3554
  }
3501
3555
  function validateZdHeavyPlan(route, expected) {
3556
+ assertZdHeavyQuoteFresh(expected.order, expected.nowSec);
3502
3557
  if (route.transactions.length !== 2 || route.transactions[0].kind !== "approve" || route.transactions[1].kind !== "submitOrder") {
3503
3558
  throw new Error("ZD Heavy requires exactly approve then submitOrder; refusing to sign.");
3504
3559
  }
@@ -4370,7 +4425,7 @@ var CHANNEL_HEADER = "x-zd-channel";
4370
4425
  var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
4371
4426
  var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
4372
4427
  var WIDGET_CHANNEL = "widget";
4373
- var WIDGET_VERSION = "4.20.1" ;
4428
+ var WIDGET_VERSION = "4.22.0" ;
4374
4429
  var MAX_CHANNEL_VERSION_LEN = 32;
4375
4430
  function sanitizeVersion(raw2) {
4376
4431
  const v = String(raw2).trim();
@@ -4494,7 +4549,7 @@ function wait(ms) {
4494
4549
  }
4495
4550
  var PAGE_LIMIT = 500;
4496
4551
  var MAX_PAGES = 10;
4497
- var newRegistryCache = () => ({ chains: null, tokens: null, routes: null, health: null, vaults: null, promotions: null, inflight: /* @__PURE__ */ new Map() });
4552
+ var newRegistryCache = () => ({ chains: null, tokens: null, routes: null, zdHeavy: null, health: null, vaults: null, promotions: null, inflight: /* @__PURE__ */ new Map() });
4498
4553
  var SHARED_REGISTRY = /* @__PURE__ */ new WeakMap();
4499
4554
  function registryCacheFor(scope) {
4500
4555
  if (!scope) return newRegistryCache();
@@ -4571,13 +4626,14 @@ function createApiClient(cfg) {
4571
4626
  const json = await requestJson(path, init);
4572
4627
  return json?.data ?? json;
4573
4628
  }
4574
- async function requestAllPages(path) {
4629
+ async function requestAllPages(path, params = {}) {
4575
4630
  const rows = [];
4576
4631
  let firstRow = "";
4577
4632
  for (let page = 0; page < MAX_PAGES; page += 1) {
4578
- const json = await requestJson(`${path}${toQuery({ limit: PAGE_LIMIT, offset: rows.length || void 0 })}`);
4633
+ const json = await requestJson(`${path}${toQuery({ ...params, limit: PAGE_LIMIT, offset: rows.length || void 0 })}`);
4579
4634
  const envelope = json && !Array.isArray(json) ? json : {};
4580
4635
  const data = Array.isArray(json) ? json : envelope.data;
4636
+ if (params.protocol === "zdheavy" && !Array.isArray(data)) throw apiError(`ZeroDelta returned an unusable list (${path}).`, { code: "bad_response" });
4581
4637
  const pageRows = Array.isArray(data) ? data : [];
4582
4638
  const head = pageRows.length ? JSON.stringify(pageRows[0]) : "";
4583
4639
  if (page === 0) firstRow = head;
@@ -4623,6 +4679,20 @@ function createApiClient(cfg) {
4623
4679
  }
4624
4680
  });
4625
4681
  }
4682
+ function fetchZdHeavyRoutes() {
4683
+ if (nowFresh(cache.zdHeavy)) return Promise.resolve(cache.zdHeavy.value);
4684
+ return once("zdHeavy", async () => {
4685
+ let value = [];
4686
+ try {
4687
+ const rows = await requestAllPages("/routes", { protocol: "zdheavy", isEnabled: true });
4688
+ value = rows.filter((r) => !!r && typeof r === "object" && !Array.isArray(r) && r.isEnabled !== false && r.isQuotable === true);
4689
+ } catch {
4690
+ value = [];
4691
+ }
4692
+ cache.zdHeavy = { at: Date.now(), value };
4693
+ return value;
4694
+ });
4695
+ }
4626
4696
  function fetchRouteHealth() {
4627
4697
  if (nowFresh(cache.health)) return Promise.resolve(cache.health.value);
4628
4698
  return once("health", async () => {
@@ -4701,7 +4771,8 @@ function createApiClient(cfg) {
4701
4771
  for (let attempt = 0; attempt <= retries; attempt += 1) {
4702
4772
  try {
4703
4773
  const quote = await apiRequest("/quote", { method: "POST", headers: { "X-ZD-Shape": "native" }, body: JSON.stringify(request), timeoutMs: 18e3 });
4704
- return normalizeQuoteResponse(quote, request);
4774
+ const gated = Array.isArray(quote?.options) && quote.options.some((option) => option?.protocol === "zdheavy") ? gateZdHeavyOptions(quote, request, await fetchZdHeavyRoutes()) : quote;
4775
+ return normalizeQuoteResponse(gated, request);
4705
4776
  } catch (error) {
4706
4777
  lastError = error;
4707
4778
  if (attempt >= retries || !isTransientQuoteError(error)) throw error;
@@ -4711,24 +4782,24 @@ function createApiClient(cfg) {
4711
4782
  throw lastError;
4712
4783
  }
4713
4784
  async function screenWallet(address, chainId) {
4714
- const addr = String(address || "").trim();
4715
- if (!addr) throw apiError("An address is required to screen a wallet.", { code: "bad_request" });
4716
- const solana = isSolanaChainId(chainId) || isSolanaAddress(addr);
4717
- if (solana && !isSolanaAddress(addr)) throw apiError("Not a valid Solana address.", { code: "bad_request" });
4718
- const key2 = solana ? "solana|" + addr : (/^0x[0-9a-fA-F]+$/.test(addr) ? addr.toLowerCase() : addr) + "|" + (chainId ?? "");
4785
+ const addr2 = String(address || "").trim();
4786
+ if (!addr2) throw apiError("An address is required to screen a wallet.", { code: "bad_request" });
4787
+ const solana = isSolanaChainId(chainId) || isSolanaAddress(addr2);
4788
+ if (solana && !isSolanaAddress(addr2)) throw apiError("Not a valid Solana address.", { code: "bad_request" });
4789
+ const key2 = solana ? "solana|" + addr2 : (/^0x[0-9a-fA-F]+$/.test(addr2) ? addr2.toLowerCase() : addr2) + "|" + (chainId ?? "");
4719
4790
  const hit = screenCache.get(key2);
4720
4791
  if (hit && Date.now() - hit.at < SCREEN_CACHE_TTL_MS) return hit.value;
4721
4792
  const inflight = screenInflight.get(key2);
4722
4793
  if (inflight) return inflight;
4723
4794
  const request = apiRequest("/screen/wallet", {
4724
4795
  method: "POST",
4725
- body: JSON.stringify(solana ? { address: addr, network: "solana" } : chainId == null ? { address: addr } : { address: addr, chainId }),
4796
+ body: JSON.stringify(solana ? { address: addr2, network: "solana" } : chainId == null ? { address: addr2 } : { address: addr2, chainId }),
4726
4797
  timeoutMs: 12e3
4727
4798
  }).then((screen) => {
4728
4799
  if (!screen || typeof screen !== "object" || typeof screen.blocked !== "boolean") {
4729
4800
  throw apiError("Compliance screening returned an unusable result.", { code: "bad_response" });
4730
4801
  }
4731
- const value = { ...screen, address: screen.address || addr };
4802
+ const value = { ...screen, address: screen.address || addr2 };
4732
4803
  screenCache.set(key2, { at: Date.now(), value });
4733
4804
  return value;
4734
4805
  }).finally(() => {
@@ -4757,7 +4828,7 @@ function createApiClient(cfg) {
4757
4828
  return false;
4758
4829
  }
4759
4830
  }
4760
- return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchRwaVaults, fetchPrices, fetchPromotions, fetchQuote, screenWallet, reportSubmission, apiBase };
4831
+ return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchZdHeavyRoutes, fetchRouteHealth, fetchRwaVaults, fetchPrices, fetchPromotions, fetchQuote, screenWallet, reportSubmission, apiBase };
4761
4832
  }
4762
4833
 
4763
4834
  // src/core/plan.ts
@@ -4832,12 +4903,12 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
4832
4903
  const parties = [];
4833
4904
  const seenParty = /* @__PURE__ */ new Set();
4834
4905
  for (const raw2 of [payer, destination.address]) {
4835
- const addr = String(raw2 || "").trim();
4836
- if (!addr) continue;
4837
- const key2 = /^0x[0-9a-fA-F]+$/.test(addr) ? addr.toLowerCase() : addr;
4906
+ const addr2 = String(raw2 || "").trim();
4907
+ if (!addr2) continue;
4908
+ const key2 = /^0x[0-9a-fA-F]+$/.test(addr2) ? addr2.toLowerCase() : addr2;
4838
4909
  if (seenParty.has(key2)) continue;
4839
4910
  seenParty.add(key2);
4840
- parties.push(addr);
4911
+ parties.push(addr2);
4841
4912
  }
4842
4913
  try {
4843
4914
  const screens = await Promise.all(parties.map((address) => api.screenWallet(address, destination.chainId)));
@@ -5052,6 +5123,322 @@ async function buildSwapPlan(api, swap, payer, wallet = {}) {
5052
5123
  };
5053
5124
  }
5054
5125
 
5126
+ // src/core/zdheavy-cancel.ts
5127
+ var lower3 = (s) => (typeof s === "string" ? s : "").toLowerCase();
5128
+ var ORDER_ID = /^0x[0-9a-fA-F]{64}$/;
5129
+ var EVM_ADDRESS = /^0x[0-9a-fA-F]{40}$/;
5130
+ function isZdHeavyOrderId(v) {
5131
+ return typeof v === "string" && ORDER_ID.test(v);
5132
+ }
5133
+ function zdHeavyRecovery(plan, wallet) {
5134
+ const claims = wallet ? plan.places.flatMap(
5135
+ (p) => p.kind === "router" && p.chainId !== void 0 && p.contract ? p.claimable.filter((c) => lower3(c.payee) === lower3(wallet)).map((c) => ({ chainId: p.chainId, token: c.token, amount: c.amount })) : []
5136
+ ) : [];
5137
+ if (claims.length) return { kind: "claim", claims };
5138
+ if (plan.finished) return { kind: "delivered" };
5139
+ if (plan.state === "refund_complete" && plan.complete) {
5140
+ return { kind: "refunded", refunds: plan.places.flatMap((p) => p.refunds.map((r) => ({ ...r, chainId: p.chainId }))) };
5141
+ }
5142
+ if (plan.ownerType !== "evm") return { kind: "not-owner" };
5143
+ const holding = plan.places.filter(
5144
+ (p) => p.kind === "router" && p.chainId !== void 0 && !!p.contract && p.canCancelInPerson && !p.complete && p.lots.length > 0
5145
+ );
5146
+ if (holding.length) return { kind: "cancel", chains: holding.map((p) => p.chainId), requested: plan.state === "cancel_requested" };
5147
+ if (plan.state === "open" && !plan.complete) return { kind: "cancel", chains: [plan.originChainId], requested: false };
5148
+ return { kind: "waiting" };
5149
+ }
5150
+ var MAX_PLACES = 32;
5151
+ var MAX_ROWS = 64;
5152
+ var DIGITS = /^\d{1,78}$/;
5153
+ var LOT_KEY = /^(?:\d{1,78}|0x[0-9a-fA-F]{1,64})$/;
5154
+ var TX_HASH = /^0x[0-9a-fA-F]{64}$/;
5155
+ var posInt = (v) => typeof v === "number" && Number.isSafeInteger(v) && v > 0 ? v : void 0;
5156
+ var nonNegInt = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 0;
5157
+ var addr = (v) => typeof v === "string" && EVM_ADDRESS.test(v);
5158
+ var list = (v) => v === void 0 || v === null ? [] : Array.isArray(v) && v.length <= MAX_ROWS ? v : null;
5159
+ var obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : null;
5160
+ function normalizeCancellationPlan(raw2, orderId) {
5161
+ const r = obj(raw2);
5162
+ if (!r || !isZdHeavyOrderId(orderId) || lower3(r.orderId) !== lower3(orderId)) return null;
5163
+ const ownerType = r.ownerType === "evm" || r.ownerType === "solana" ? r.ownerType : null;
5164
+ const state = r.state === "open" || r.state === "cancel_requested" || r.state === "refund_complete" ? r.state : null;
5165
+ const originChainId = posInt(r.originChainId);
5166
+ if (!ownerType || !state || originChainId === void 0 || typeof r.complete !== "boolean" || typeof r.owner !== "string" || r.owner.length > 64) return null;
5167
+ if (r.finished !== void 0 && typeof r.finished !== "boolean") return null;
5168
+ if (!Array.isArray(r.places) || r.places.length > MAX_PLACES) return null;
5169
+ const places = [];
5170
+ for (const rawPlace of r.places) {
5171
+ const p = obj(rawPlace);
5172
+ if (!p || p.kind !== "router" && p.kind !== "hub" || typeof p.canCancelInPerson !== "boolean" || typeof p.complete !== "boolean") return null;
5173
+ const chainId = p.chainId === void 0 ? void 0 : posInt(p.chainId);
5174
+ if (p.chainId !== void 0 && chainId === void 0) return null;
5175
+ const contract = typeof p.contract === "string" ? p.contract : "";
5176
+ if (contract && !addr(contract)) return null;
5177
+ const lots = list(p.lots);
5178
+ const refunds = list(p.refunds);
5179
+ const claimable = list(p.claimable);
5180
+ if (!lots || !refunds || !claimable) return null;
5181
+ const place = {
5182
+ kind: p.kind,
5183
+ chainId,
5184
+ contract,
5185
+ canCancelInPerson: p.canCancelInPerson,
5186
+ complete: p.complete,
5187
+ lots: [],
5188
+ refunds: [],
5189
+ claimable: []
5190
+ };
5191
+ for (const rawLot of lots) {
5192
+ const l = obj(rawLot);
5193
+ if (!l || !nonNegInt(l.step) || !addr(l.token) || typeof l.amount !== "string" || !DIGITS.test(l.amount) || typeof l.key !== "string" || !LOT_KEY.test(l.key))
5194
+ return null;
5195
+ place.lots.push({ step: l.step, token: l.token, amount: l.amount, key: l.key });
5196
+ }
5197
+ for (const rawRefund of refunds) {
5198
+ const f = obj(rawRefund);
5199
+ if (!f || typeof f.txHash !== "string" || !TX_HASH.test(f.txHash) || !nonNegInt(f.step) || !addr(f.token) || typeof f.amount !== "string" || !DIGITS.test(f.amount) || !addr(f.to))
5200
+ return null;
5201
+ place.refunds.push({ txHash: f.txHash, step: f.step, token: f.token, amount: f.amount, to: f.to });
5202
+ }
5203
+ for (const rawClaim of claimable) {
5204
+ const c = obj(rawClaim);
5205
+ if (!c || !addr(c.payee) || !addr(c.token) || typeof c.amount !== "string" || !DIGITS.test(c.amount)) return null;
5206
+ place.claimable.push({ payee: c.payee, token: c.token, amount: c.amount });
5207
+ }
5208
+ places.push(place);
5209
+ }
5210
+ return {
5211
+ orderId: r.orderId,
5212
+ ownerType,
5213
+ owner: r.owner,
5214
+ originChainId,
5215
+ state,
5216
+ complete: r.complete,
5217
+ ...r.finished !== void 0 ? { finished: r.finished } : {},
5218
+ places
5219
+ };
5220
+ }
5221
+ function zdHeavyOrderPath(orderId, tail) {
5222
+ if (!isZdHeavyOrderId(orderId)) throw new ZdHeavyCodecError("Not a ZD Heavy order id.");
5223
+ return `/orders/${orderId.toLowerCase()}/${tail}`;
5224
+ }
5225
+ async function fetchZdHeavyCancellation(api, orderId) {
5226
+ if (!isZdHeavyOrderId(orderId)) return null;
5227
+ try {
5228
+ return normalizeCancellationPlan(await api.apiRequest(zdHeavyOrderPath(orderId, "cancellation"), { timeoutMs: 1e4 }), orderId);
5229
+ } catch {
5230
+ return null;
5231
+ }
5232
+ }
5233
+ function unsigned(raw2) {
5234
+ const r = obj(raw2);
5235
+ const s = (v) => typeof v === "string" ? v : typeof v === "number" ? String(v) : "";
5236
+ if (!r) return { purpose: "", chainId: "", from: "", to: "", data: "" };
5237
+ return {
5238
+ purpose: s(r.purpose),
5239
+ chainId: s(r.chainId),
5240
+ from: s(r.from),
5241
+ to: s(r.to),
5242
+ data: s(r.data),
5243
+ ...r.value !== void 0 ? { value: s(r.value) } : {}
5244
+ };
5245
+ }
5246
+ async function buildZdHeavyCancelTx(api, orderId, chainId) {
5247
+ return unsigned(
5248
+ await api.apiRequest(zdHeavyOrderPath(orderId, "cancel-tx"), {
5249
+ method: "POST",
5250
+ body: JSON.stringify(chainId === void 0 ? {} : { chainId }),
5251
+ timeoutMs: 15e3
5252
+ })
5253
+ );
5254
+ }
5255
+ async function buildZdHeavyClaimTx(api, orderId, chainId, token) {
5256
+ return unsigned(
5257
+ await api.apiRequest(zdHeavyOrderPath(orderId, "claim-tx"), {
5258
+ method: "POST",
5259
+ body: JSON.stringify({ chainId, token }),
5260
+ timeoutMs: 15e3
5261
+ })
5262
+ );
5263
+ }
5264
+ var ZDHEAVY_CANCEL_SELECTOR = "0xf26bce2c";
5265
+ var ZDHEAVY_CLAIM_SELECTOR = "0x1e83409a";
5266
+ var ZDHEAVY_CLAIM_TO_SELECTOR = "0x21c0b342";
5267
+ var MAX_CANCEL_KEYS = 32;
5268
+ function reader(data, selector) {
5269
+ if (typeof data !== "string" || !/^0x(?:[0-9a-fA-F]{2})*$/.test(data) || data.slice(0, 10).toLowerCase() !== selector) {
5270
+ throw new ZdHeavyCodecError("Unexpected call");
5271
+ }
5272
+ const body = data.slice(10).toLowerCase();
5273
+ const size = body.length / 2;
5274
+ const fail = () => {
5275
+ throw new ZdHeavyCodecError("Invalid calldata");
5276
+ };
5277
+ const word2 = (at, bits = 256) => {
5278
+ if (!Number.isSafeInteger(at) || at < 0 || at + 32 > size) return fail();
5279
+ const n = BigInt(`0x${body.slice(at * 2, (at + 32) * 2)}`);
5280
+ if (bits < 256 && n >= 1n << BigInt(bits)) return fail();
5281
+ return n;
5282
+ };
5283
+ const fixed = (at) => {
5284
+ word2(at);
5285
+ return `0x${body.slice(at * 2, (at + 32) * 2)}`;
5286
+ };
5287
+ const address = (at) => `0x${word2(at, 160).toString(16).padStart(40, "0")}`;
5288
+ const offset = (at, expected) => {
5289
+ if (word2(at) !== BigInt(expected)) fail();
5290
+ };
5291
+ const count = (at, each) => {
5292
+ const n = word2(at);
5293
+ if (n > BigInt(Math.floor((size - at - 32) / each))) return fail();
5294
+ return Number(n);
5295
+ };
5296
+ const bytes = (at) => {
5297
+ const n = word2(at);
5298
+ if (n > BigInt(size - at - 32)) return fail();
5299
+ const length = Number(n);
5300
+ const end = at + 32 + Math.ceil(length / 32) * 32;
5301
+ if (end > size || /[^0]/.test(body.slice((at + 32 + length) * 2, end * 2))) return fail();
5302
+ return { value: `0x${body.slice((at + 32) * 2, (at + 32 + length) * 2)}`, end };
5303
+ };
5304
+ return { size, fail, word: word2, fixed, address, offset, count, bytes };
5305
+ }
5306
+ function decodeZdHeavyCancel(data) {
5307
+ const r = reader(data, ZDHEAVY_CANCEL_SELECTOR);
5308
+ const orderId = r.fixed(0);
5309
+ const P2 = 96;
5310
+ r.offset(32, P2);
5311
+ const expiryDate = r.word(P2, 64);
5312
+ r.offset(P2 + 32, 96);
5313
+ const header = r.bytes(P2 + 96);
5314
+ r.offset(P2 + 64, header.end - P2);
5315
+ const hashesAt = header.end;
5316
+ const n = r.count(hashesAt, 32);
5317
+ const stepHashes = [];
5318
+ for (let i = 0; i < n; i++) stepHashes.push(r.fixed(hashesAt + 32 + i * 32));
5319
+ const keysAt = hashesAt + 32 + n * 32;
5320
+ r.offset(64, keysAt);
5321
+ const k = r.count(keysAt, 32);
5322
+ const keys = [];
5323
+ for (let i = 0; i < k; i++) keys.push(r.word(keysAt + 32 + i * 32));
5324
+ if (keysAt + 32 + k * 32 !== r.size) r.fail();
5325
+ return { orderId, proof: { expiryDate, orderHeader: header.value, stepHashes }, keys };
5326
+ }
5327
+ function decodeZdHeavyClaim(data) {
5328
+ const selector = typeof data === "string" ? data.slice(0, 10).toLowerCase() : "";
5329
+ if (selector === ZDHEAVY_CLAIM_SELECTOR) {
5330
+ const r2 = reader(data, ZDHEAVY_CLAIM_SELECTOR);
5331
+ if (r2.size !== 32) r2.fail();
5332
+ return { token: r2.address(0) };
5333
+ }
5334
+ const r = reader(data, ZDHEAVY_CLAIM_TO_SELECTOR);
5335
+ if (r.size !== 64) r.fail();
5336
+ return { token: r.address(0), to: r.address(32) };
5337
+ }
5338
+ var hexBytes2 = (h) => Uint8Array.from(h.slice(2).match(/../g) ?? [], (b) => Number.parseInt(b, 16));
5339
+ var keccak = (h) => `0x${keccak256Hex(hexBytes2(h))}`;
5340
+ function orderIdFromProof(expiryDate, header, stepHashes) {
5341
+ const tag = Array.from(new TextEncoder().encode("ZD/ORDER"), (b) => b.toString(16).padStart(2, "0")).join("");
5342
+ return keccak(`0x${tag}${expiryDate.toString(16).padStart(16, "0")}${keccak(header).slice(2)}${stepHashes.map((h) => h.slice(2)).join("")}`);
5343
+ }
5344
+ var TX = /^0x[0-9a-fA-F]{64}$/;
5345
+ var succeeded = (receipt) => {
5346
+ const status = obj(receipt)?.status;
5347
+ return typeof status === "string" && /^0x0*1$/.test(status);
5348
+ };
5349
+ async function verifyZdHeavySourceOrder(rpc, chainId, hash, orderId) {
5350
+ const no = (reason) => ({ ok: false, reason });
5351
+ if (!SUPPORTED_CHAIN_IDS.has(chainId) || typeof hash !== "string" || !TX.test(hash) || !isZdHeavyOrderId(orderId)) return no("not checkable");
5352
+ try {
5353
+ const [tx, receipt] = await Promise.all([rpc(chainId, "eth_getTransactionByHash", [hash]), rpc(chainId, "eth_getTransactionReceipt", [hash])]);
5354
+ const t = obj(tx);
5355
+ if (!t || lower3(t.hash) !== lower3(hash)) return no("source transaction not found");
5356
+ if (!succeeded(receipt) || lower3(obj(receipt)?.transactionHash) !== lower3(hash)) return no("source transaction not confirmed");
5357
+ const router = checkZdHeavyRouter(chainId, typeof t.to === "string" ? t.to : "");
5358
+ if (!router.ok) return no("source transaction is not to a pinned router");
5359
+ const input = typeof t.input === "string" ? t.input : typeof t.data === "string" ? t.data : "";
5360
+ const { submission } = decodeZdHeavySubmit(input);
5361
+ const id = orderIdOf(submission.expiryDate, encodeOrderHeader(submission.serial, router.address, submission.ownerType, submission.owner), submission.steps);
5362
+ return lower3(id) === lower3(orderId) ? { ok: true } : no("source transaction submitted another order");
5363
+ } catch {
5364
+ return no("source transaction could not be read");
5365
+ }
5366
+ }
5367
+ var refuse2 = (what) => ({ ok: false, reason: `The ${what} does not match this order. Refusing to sign.` });
5368
+ function commonChecks(tx, owner, purpose, chainId) {
5369
+ if (!tx || tx.purpose !== purpose) return refuse2("transaction kind");
5370
+ const chain2 = typeof tx.chainId === "string" && /^\d{1,12}$/.test(tx.chainId) ? Number(tx.chainId) : NaN;
5371
+ if (!Number.isSafeInteger(chain2) || chain2 <= 0) return refuse2("chain");
5372
+ if (chainId !== void 0 && chain2 !== chainId) return refuse2("chain");
5373
+ const router = checkZdHeavyRouter(chain2, tx.to);
5374
+ if (!router.ok) return { ok: false, reason: router.reason };
5375
+ if (!addr(owner) || !addr(tx.from) || lower3(tx.from) !== lower3(owner)) return refuse2("sender");
5376
+ try {
5377
+ if (tx.value !== void 0 && tx.value !== "" && BigInt(tx.value) !== 0n) return refuse2("value");
5378
+ } catch {
5379
+ return refuse2("value");
5380
+ }
5381
+ return { ok: true, chainId: chain2, router: router.address };
5382
+ }
5383
+ var accepted = (chainId, owner, router, data) => ({
5384
+ ok: true,
5385
+ chainId,
5386
+ tx: { from: owner, to: router, data: data.toLowerCase(), value: "0x0" }
5387
+ });
5388
+ function checkZdHeavyCancelTx(tx, e) {
5389
+ const base = commonChecks(tx, e.owner, "cancel", e.chainId);
5390
+ if (!base.ok) return base;
5391
+ let decoded;
5392
+ try {
5393
+ decoded = decodeZdHeavyCancel(tx.data);
5394
+ } catch {
5395
+ return refuse2("call");
5396
+ }
5397
+ const { orderId, proof, keys } = decoded;
5398
+ if (!isZdHeavyOrderId(e.orderId) || lower3(orderId) !== lower3(e.orderId)) return refuse2("order id");
5399
+ if (keys.length > MAX_CANCEL_KEYS) return refuse2("lot keys");
5400
+ const listed = e.lotKeys ? new Set(
5401
+ e.lotKeys.map((k) => {
5402
+ try {
5403
+ return BigInt(k).toString();
5404
+ } catch {
5405
+ return "";
5406
+ }
5407
+ })
5408
+ ) : void 0;
5409
+ const seen = /* @__PURE__ */ new Set();
5410
+ for (const k of keys) {
5411
+ if (listed && !listed.has(k.toString())) return refuse2("lot keys");
5412
+ const step = k >> 160n;
5413
+ const tokenBits = k & (1n << 160n) - 1n;
5414
+ if (step >= BigInt(proof.stepHashes.length) || tokenBits === 0n || seen.has(k.toString())) return refuse2("lot keys");
5415
+ seen.add(k.toString());
5416
+ }
5417
+ if (proof.stepHashes.length < 1 || proof.stepHashes.length > 8) return refuse2("order proof");
5418
+ if (lower3(orderIdFromProof(proof.expiryDate, proof.orderHeader, proof.stepHashes)) !== lower3(orderId)) return refuse2("order proof");
5419
+ const h = proof.orderHeader;
5420
+ if (h.length !== 2 + ORDER_HEADER_LEN * 2) return refuse2("order proof");
5421
+ const routerWordHex = `0x${h.slice(2 + 11 * 2, 2 + 43 * 2)}`;
5422
+ const ownerType = Number.parseInt(h.slice(2 + 43 * 2, 2 + 44 * 2), 16);
5423
+ const ownerWordHex = `0x${h.slice(2 + 44 * 2)}`;
5424
+ if (lower3(routerWordHex) !== lower3(ownerWord(base.router))) return refuse2("router");
5425
+ if (ownerType !== 1 || lower3(ownerWordHex) !== lower3(ownerWord(e.owner))) return refuse2("owner");
5426
+ return accepted(base.chainId, e.owner, base.router, tx.data);
5427
+ }
5428
+ function checkZdHeavyClaimTx(tx, e) {
5429
+ const base = commonChecks(tx, e.owner, "claim", e.chainId);
5430
+ if (!base.ok) return base;
5431
+ let decoded;
5432
+ try {
5433
+ decoded = decodeZdHeavyClaim(tx.data);
5434
+ } catch {
5435
+ return refuse2("call");
5436
+ }
5437
+ if (!addr(e.token) || lower3(decoded.token) !== lower3(e.token)) return refuse2("token");
5438
+ if (decoded.to !== void 0 && lower3(decoded.to) !== lower3(e.owner)) return refuse2("recipient");
5439
+ return accepted(base.chainId, e.owner, base.router, tx.data);
5440
+ }
5441
+
5055
5442
  // src/core/intent-schema.ts
5056
5443
  var STABLEGENIE_INTENT_VERSION = 1;
5057
5444
  var STABLEGENIE_INTENT_TTL_MS = 5 * 60 * 1e3;
@@ -5325,7 +5712,13 @@ function createVerifier(api, fetchImpl, rpcOverrides = {}) {
5325
5712
  return void 0;
5326
5713
  }
5327
5714
  }
5328
- return { payerNonceBaseline, verifySubmittedTx, readBalances, readNativeBalance, readZdHeavySubmitFee };
5715
+ async function bundledRpc(chainId, method, params) {
5716
+ const override = rpcOverrides[Number(chainId)];
5717
+ const rpc = override && /^https?:\/\//i.test(override) ? override : BUNDLED_RPC[Number(chainId)];
5718
+ if (!rpc) throw new Error("No bundled RPC for this chain");
5719
+ return rpcCall(rpc, method, params);
5720
+ }
5721
+ return { payerNonceBaseline, verifySubmittedTx, readBalances, readNativeBalance, readZdHeavySubmitFee, bundledRpc };
5329
5722
  }
5330
5723
 
5331
5724
  // src/core/config.ts
@@ -5448,10 +5841,11 @@ function createEngine(config = {}) {
5448
5841
  fetchPrices: (symbols) => api.fetchPrices ? api.fetchPrices(symbols) : Promise.resolve({}),
5449
5842
  fetchPromotions: () => api.fetchPromotions ? api.fetchPromotions() : Promise.resolve([]),
5450
5843
  fetchCatalogue: async (allowedAssets, product, options) => {
5451
- const [chains, registryTokens, routes, health, vaults] = await Promise.all([
5844
+ const [chains, registryTokens, routes, zdHeavyRoutes, health, vaults] = await Promise.all([
5452
5845
  api.fetchChains().catch(() => []),
5453
5846
  api.fetchTokens().catch(() => []),
5454
5847
  api.fetchRoutes().catch(() => []),
5848
+ api.fetchZdHeavyRoutes(),
5455
5849
  api.fetchRouteHealth(),
5456
5850
  api.fetchRwaVaults()
5457
5851
  ]);
@@ -5462,6 +5856,7 @@ function createEngine(config = {}) {
5462
5856
  chains,
5463
5857
  tokens,
5464
5858
  routes,
5859
+ zdHeavyRoutes,
5465
5860
  product,
5466
5861
  ...allowed ? { allowedAssets: allowed } : {},
5467
5862
  // Solana is a SOURCE only for a surface that can pay from it (the exchange card, through the
@@ -5483,6 +5878,10 @@ function createEngine(config = {}) {
5483
5878
  executeSolanaPlanStaged: (input) => executeSolanaPlanStaged({ ...input, rpc: input.rpc ?? solanaRpc }),
5484
5879
  previewSolanaSource: (input) => previewSolanaSource(api, input),
5485
5880
  trackDelivery: (hash) => fetchDelivery(api, hash),
5881
+ fetchZdHeavyCancellation: (orderId) => fetchZdHeavyCancellation(api, orderId),
5882
+ buildZdHeavyCancelTx: (orderId, chainId) => buildZdHeavyCancelTx(api, orderId, chainId),
5883
+ buildZdHeavyClaimTx: (orderId, chainId, tokenAddress) => buildZdHeavyClaimTx(api, orderId, chainId, tokenAddress),
5884
+ verifyZdHeavySourceOrder: (chainId, hash, orderId) => verifyZdHeavySourceOrder(verifier.bundledRpc, chainId, hash, orderId),
5486
5885
  fetchWalletHistory: (wallets) => fetchWalletHistory(api, wallets),
5487
5886
  readSolanaBalance: (owner, mint) => readSolanaBalance(solanaRpc, owner, mint),
5488
5887
  simulateSolanaCost: (plan) => simulateSolanaCost(solanaRpc, plan),
@@ -5502,4 +5901,4 @@ function createEngine(config = {}) {
5502
5901
  };
5503
5902
  }
5504
5903
 
5505
- export { API_CACHE_TTL_MS, BLOCK_LABEL_DEFAULT, BUNDLED_NATIVE_SYMBOL, BUNDLED_RPC, BUNDLED_SOLANA_RPC, CANONICAL_DECIMALS, CANONICAL_ESCROW, CANONICAL_INBOUND_BRIDGE, CANONICAL_SOLANA_PROGRAM, CENTIBIPS_PER_UNIT, CHAIN_DISPLAY_NAMES, COMPLIANCE_CHECK_ORDER, COMPLIANCE_DENY_LABEL, DEFAULT_WIDGET_API_BASE, DIRECT_CHECK_IDS, DIRECT_SCOPE_NOTE, ERC20_ALLOWANCE_SELECTOR, ERC20_APPROVE_SELECTOR, ERC20_BALANCEOF_SELECTOR, ERC20_TRANSFER_SELECTOR, EXECUTABLE_STABLE_ASSETS, FLOOR_CATEGORIES, LZ_FEE_BUFFER_BPS, MAX_LZ_MSG_VALUE_WEI, MAX_LZ_MSG_VALUE_WEI_BY_CHAIN, MAX_QUOTE_CANDIDATES, MAX_QUOTE_CARDS, MAX_SAME_CLASS_PAY_BPS, MAX_UINT64, NO_PARTNER_ID, PREVIEW_OWNER, QUOTE_BUFFER_BPS, SAME_CLASS_STABLE, SCREENING_BUCKETS, SCREEN_CACHE_TTL_MS, SOLANA_CHAIN_ID, SOLANA_DESTINATION_ASSETS, SOL_SHORTFALL_MESSAGE, STABLEGENIE_INTENT_TTL_MS, STABLEGENIE_INTENT_VERSION, STABLEGENIE_SUPPORTED_ASSETS, STABLEGENIE_SUPPORTED_CHAIN_IDS, STABLE_ASSETS, SUBMIT_ORDER_DISCRIMINATOR, SUBMIT_ORDER_SELECTOR, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, SolanaSendError, TOKEN_2022_PROGRAM, TOKEN_PROGRAM, TRACKING, TRADEABLE_RWA_ASSETS, TUNABLE_CATEGORIES, WAIT_MAX_SEC, WAIT_MIN_SEC, WAIT_POSITIONS, WAIT_STEP_SEC, WALLET_HISTORY_LIMIT, ZD_HEAVY_KEY_PREFIX, ZERO_ADDRESS, addressWord, allowanceCovers, amountFieldError, apiError, applyLayerZeroBuffer, askCovers, askTokenDecimals, assertAddress, assertChainAddress, assertQuoteMatchesSelection, assertWalletMessage, assetClassOf, assetDecimals, associatedTokenAddress, base58Decode, base58Encode, base64Decode, base64Encode, bestOutputOption, blockLabelFor, bonusFigure, bonusPercentLabel, brokenLaneFor, brokenLaneReason, buildCatalogue, buildPayOptions, buildRoute, buildSolanaSourcePlan, buildSwapPlan, bytes32Word, bytesEqual, bytesPayload, canAttachApiKey, categoryLabel, chainAddressKey, chainById, chainNameOf, chainSelectable, checkEscrow, checkNativeFee, checkSolanaPlan, checkSolanaProgram, checkSolanaReceiver, checkSolanaRouteBuffer, clampWait, classifyQuoteError, compareAmount, compareDuration, compareFeeUsd, compareHops, compareOptionOf, compareOptionsOf, complianceChecks, complianceControlsEvaluated, complianceControlsLine, complianceReasonHead, complianceReasonTag, complianceTagOf, complianceView, cornerTags, cosignSolanaEvent, counterpartTokens, createApiClient, createEngine, createSolanaRpc, createVerifier, decodeSolanaSubmitOrder, decodeSubmitOrderCalldata, deriveSolanaEvent, destinationAvailability, destinationKeys, directComplianceFromScreens, distinctScreenedWallets, encodeAllowance, encodeApprove, encodeBalanceOf, encodeNextSolanaOrders, encodeSubmitOrder, encodeTransfer, estimateBonus, exceedsLaneLimit, executableRoutes, executeSolanaPlan, executeSolanaPlanStaged, executionChainIds, expectedSolanaDelivery, extraVsFastest, fastestOption, fetchDelivery, fetchPaymentPlan, fetchWalletHistory, finalOf, findProgramAddress, findToken, foldTicker, formatJurisdiction, formatNative, formatUnits, fundedByLabel, hasReachableDestination, hasValidChecksum, hexBytes, hexToSolanaKey, historyEntryFromOrder, historyKey, hubDeliverableSymbols, humanizeComplianceReason, insteadFigures, isAddress, isChainAddress, isDeliverable, isExecutableBridge, isHexAddress, isHexData, isHexQuantity, isKnownUnbridgeable, isLayerZeroRoute, isOnEd25519Curve, isPreparationInstruction, isSellableRwa, isSolanaAddress, isSolanaChainId, isSourceToken, isSubmitOrder, laneAvailabilityState, laneKey, laneKeys, laneLimitAmount, laneLimitError, laneLimitFor, laneLimitHint, laneLimitSymbol, limitedLanes, maxDeadlineSeconds, maxNativeFeeWei, mergeHistory, nativeFeeShortLabel, nativeFeeShortMessage, nativeSymbol, normalizeAddress, normalizeDecimalText, normalizeDelivery, normalizeOrderRequest, normalizeOrderRequests, overwriteBlockhash, pairPromotionsInto, parity, parseAddressLookupTable, parseAllowedApiBase, parsePromotion, parsePromotions, parseSolanaTransaction, parseUnitsDecimal, pickForWait, placeSignature, planErrorSummary, planMsgValueHex, pollSolanaConfirmation, preflightZdHeavyPlan, previewSolanaSource, priceCompareOptions, productAssets, promotedAssets, promotionFor, proposedWait, quotePartnerId, quotePayOption, quoteSolanaSource, quoteSwapPreview, readSolanaBalance, recommendedDeadlineSeconds, registryRpc, requiresNativeBridgeFee, resolveApiBase, resolveConfig, resolveSolanaKeys, resolveSwapReceiver, resolveVaultIcon, resultForOption, routeBadges, routeNativeValue, routeShapeLabel, safeTicker, sameAddress, scaleDecimals, screeningOutcomeOf, selectableOptions, serializeSolanaTransaction, sha256, simulateSolanaCost, snapWait, solanaBridgeOf, solanaDestinationAsset, solanaKeyBytes, solanaKeyHex, solanaLamportShortfall, solanaPlanNeedsPreparation, solanaQuoteCompliance, solveExactIn, solveExactOut, sourceKeys, stableGenieIntentSchema, strip0x, suppressedLanes, symbolKey, tickerOn, toHexQuantity, tokenEnabled, tokenKey, tokenTicker, txMatchesPlan, uint64Word, uintWord, unattributedComplianceReasons, usdStablePair, validateDestination, validatePlannedTransaction, validateSwap, vaultIconsBySymbol, verifySolanaSubmit, verifySolanaTransaction, visibleOptions, waitFraction, waitFromFraction, waitLabel, waitScaleFor, withVaultArtwork, zdHeavyExpected, zdHeavyOptionKey, zdHeavyUnavailableStatus };
5904
+ export { API_CACHE_TTL_MS, BLOCK_LABEL_DEFAULT, BUNDLED_NATIVE_SYMBOL, BUNDLED_RPC, BUNDLED_SOLANA_RPC, CANONICAL_DECIMALS, CANONICAL_ESCROW, CANONICAL_INBOUND_BRIDGE, CANONICAL_SOLANA_PROGRAM, CENTIBIPS_PER_UNIT, CHAIN_DISPLAY_NAMES, COMPLIANCE_CHECK_ORDER, COMPLIANCE_DENY_LABEL, DEFAULT_WIDGET_API_BASE, DIRECT_CHECK_IDS, DIRECT_SCOPE_NOTE, ERC20_ALLOWANCE_SELECTOR, ERC20_APPROVE_SELECTOR, ERC20_BALANCEOF_SELECTOR, ERC20_TRANSFER_SELECTOR, EXECUTABLE_STABLE_ASSETS, FLOOR_CATEGORIES, LZ_FEE_BUFFER_BPS, MAX_CANCEL_KEYS, MAX_LZ_MSG_VALUE_WEI, MAX_LZ_MSG_VALUE_WEI_BY_CHAIN, MAX_QUOTE_CANDIDATES, MAX_QUOTE_CARDS, MAX_SAME_CLASS_PAY_BPS, MAX_UINT64, NO_PARTNER_ID, PREVIEW_OWNER, QUOTE_BUFFER_BPS, SAME_CLASS_STABLE, SCREENING_BUCKETS, SCREEN_CACHE_TTL_MS, SOLANA_CHAIN_ID, SOLANA_DESTINATION_ASSETS, SOL_SHORTFALL_MESSAGE, STABLEGENIE_INTENT_TTL_MS, STABLEGENIE_INTENT_VERSION, STABLEGENIE_SUPPORTED_ASSETS, STABLEGENIE_SUPPORTED_CHAIN_IDS, STABLE_ASSETS, SUBMIT_ORDER_DISCRIMINATOR, SUBMIT_ORDER_SELECTOR, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, SolanaSendError, TOKEN_2022_PROGRAM, TOKEN_PROGRAM, TRACKING, TRADEABLE_RWA_ASSETS, TUNABLE_CATEGORIES, WAIT_MAX_SEC, WAIT_MIN_SEC, WAIT_POSITIONS, WAIT_STEP_SEC, WALLET_HISTORY_LIMIT, ZDHEAVY_CANCEL_SELECTOR, ZDHEAVY_CLAIM_SELECTOR, ZDHEAVY_CLAIM_TO_SELECTOR, ZD_HEAVY_KEY_PREFIX, ZERO_ADDRESS, ZdHeavyQuoteExpiredError, addressWord, allowanceCovers, amountFieldError, apiError, applyLayerZeroBuffer, askCovers, askTokenDecimals, assertAddress, assertChainAddress, assertQuoteMatchesSelection, assertWalletMessage, assertZdHeavyQuoteFresh, assetClassOf, assetDecimals, associatedTokenAddress, base58Decode, base58Encode, base64Decode, base64Encode, bestOutputOption, blockLabelFor, bonusFigure, bonusPercentLabel, brokenLaneFor, brokenLaneReason, buildCatalogue, buildPayOptions, buildRoute, buildSolanaSourcePlan, buildSwapPlan, buildZdHeavyCancelTx, buildZdHeavyClaimTx, bytes32Word, bytesEqual, bytesPayload, canAttachApiKey, categoryLabel, chainAddressKey, chainById, chainNameOf, chainSelectable, checkEscrow, checkNativeFee, checkSolanaPlan, checkSolanaProgram, checkSolanaReceiver, checkSolanaRouteBuffer, checkZdHeavyCancelTx, checkZdHeavyClaimTx, clampWait, classifyQuoteError, compareAmount, compareDuration, compareFeeUsd, compareHops, compareOptionOf, compareOptionsOf, complianceChecks, complianceControlsEvaluated, complianceControlsLine, complianceReasonHead, complianceReasonTag, complianceTagOf, complianceView, cornerTags, cosignSolanaEvent, counterpartTokens, createApiClient, createEngine, createSolanaRpc, createVerifier, decodeSolanaSubmitOrder, decodeSubmitOrderCalldata, decodeZdHeavyCancel, decodeZdHeavyClaim, deriveSolanaEvent, destinationAvailability, destinationKeys, directComplianceFromScreens, distinctScreenedWallets, encodeAllowance, encodeApprove, encodeBalanceOf, encodeNextSolanaOrders, encodeSubmitOrder, encodeTransfer, estimateBonus, exceedsLaneLimit, executableRoutes, executeSolanaPlan, executeSolanaPlanStaged, executionChainIds, expectedSolanaDelivery, extraVsFastest, fastestOption, fetchDelivery, fetchPaymentPlan, fetchWalletHistory, fetchZdHeavyCancellation, finalOf, findProgramAddress, findToken, foldTicker, formatJurisdiction, formatNative, formatUnits, fundedByLabel, hasReachableDestination, hasValidChecksum, hexBytes, hexToSolanaKey, historyEntryFromOrder, historyKey, hubDeliverableSymbols, humanizeComplianceReason, insteadFigures, isAddress, isChainAddress, isDeliverable, isExecutableBridge, isHexAddress, isHexData, isHexQuantity, isKnownUnbridgeable, isLayerZeroRoute, isOnEd25519Curve, isPreparationInstruction, isSellableRwa, isSolanaAddress, isSolanaChainId, isSourceToken, isSubmitOrder, isZdHeavyOrderId, laneAvailabilityState, laneKey, laneKeys, laneLimitAmount, laneLimitError, laneLimitFor, laneLimitHint, laneLimitSymbol, limitedLanes, maxDeadlineSeconds, maxNativeFeeWei, mergeHistory, nativeFeeShortLabel, nativeFeeShortMessage, nativeSymbol, normalizeAddress, normalizeCancellationPlan, normalizeDecimalText, normalizeDelivery, normalizeOrderRequest, normalizeOrderRequests, orderIdFromProof, overwriteBlockhash, pairPromotionsInto, parity, parseAddressLookupTable, parseAllowedApiBase, parsePromotion, parsePromotions, parseSolanaTransaction, parseUnitsDecimal, pickForWait, placeSignature, planErrorSummary, planMsgValueHex, pollSolanaConfirmation, preflightZdHeavyPlan, previewSolanaSource, priceCompareOptions, productAssets, promotedAssets, promotionFor, proposedWait, quotePartnerId, quotePayOption, quoteSolanaSource, quoteSwapPreview, readSolanaBalance, recommendedDeadlineSeconds, registryRpc, requiresNativeBridgeFee, resolveApiBase, resolveConfig, resolveSolanaKeys, resolveSwapReceiver, resolveVaultIcon, resultForOption, routeBadges, routeNativeValue, routeShapeLabel, safeTicker, sameAddress, scaleDecimals, screeningOutcomeOf, selectableOptions, serializeSolanaTransaction, sha256, simulateSolanaCost, snapWait, solanaBridgeOf, solanaDestinationAsset, solanaKeyBytes, solanaKeyHex, solanaLamportShortfall, solanaPlanNeedsPreparation, solanaQuoteCompliance, solveExactIn, solveExactOut, sourceKeys, stableGenieIntentSchema, strip0x, suppressedLanes, symbolKey, tickerOn, toHexQuantity, tokenEnabled, tokenKey, tokenTicker, txMatchesPlan, uint64Word, uintWord, unattributedComplianceReasons, usdStablePair, validateDestination, validatePlannedTransaction, validateSwap, vaultIconsBySymbol, verifySolanaSubmit, verifySolanaTransaction, verifyZdHeavySourceOrder, visibleOptions, waitFraction, waitFromFraction, waitLabel, waitScaleFor, withVaultArtwork, zdHeavyExpected, zdHeavyOptionKey, zdHeavyRecovery, zdHeavyUnavailableStatus };