@glacislabs/stablegenie-zerodelta 4.18.2 → 4.20.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/README.md +2 -0
- package/dist/{chunk-LMK5C6VA.js → chunk-FXH7TCJ5.js} +1130 -116
- package/dist/{chunk-OIJN6SHV.js → chunk-JIQRTR3C.js} +1532 -182
- package/dist/core/index.cjs +1566 -181
- package/dist/core/index.d.cts +26 -5
- package/dist/core/index.d.ts +26 -5
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +2797 -500
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-BSXfSSP2.d.cts → mount-D2tDkHea.d.cts} +1 -1
- package/dist/{mount-BdxMZC70.d.ts → mount-DuTF5CQV.d.ts} +1 -1
- package/dist/mount.cjs +2797 -500
- package/dist/mount.d.cts +2 -2
- package/dist/mount.d.ts +2 -2
- package/dist/mount.js +2 -2
- package/dist/standalone.global.js +221 -9
- package/dist/{verify-BBREdvIM.d.cts → verify-UqDjAVxa.d.cts} +470 -2
- package/dist/{verify-BBREdvIM.d.ts → verify-UqDjAVxa.d.ts} +470 -2
- package/package.json +1 -1
package/dist/mount.cjs
CHANGED
|
@@ -581,6 +581,58 @@ var TRACKING = Object.freeze({ phase: "tracking", status: "", steps: [] });
|
|
|
581
581
|
var word = (v) => typeof v === "string" ? v.trim().toLowerCase() : "";
|
|
582
582
|
var STEP_ORDER = { submitted: 0, arrived: 1, filled: 2, delivered: 3 };
|
|
583
583
|
var STATUS_REACHED = { in_progress: 1, outbound_bridging: 2, delivery_failed: 2, delivered: 3 };
|
|
584
|
+
var ZDH_FIRST_STEP = 20;
|
|
585
|
+
var ZDH_STEP = {
|
|
586
|
+
paid_out: "delivered",
|
|
587
|
+
cancelled: "cancellation_requested",
|
|
588
|
+
refunded: "refunded"
|
|
589
|
+
};
|
|
590
|
+
var ROUTE_MECHANICS = /* @__PURE__ */ new Set(["consumed", "step_executed", "step_filled", "returned"]);
|
|
591
|
+
var PROGRESS = /* @__PURE__ */ new Set(["pending", "in_progress", "outbound_bridging"]);
|
|
592
|
+
var MAX_STEPS = 8;
|
|
593
|
+
function isZdHeavy(r, steps) {
|
|
594
|
+
return r.protocol === "zdheavy" || steps.some((s) => Number(s.stepNumber ?? 0) >= ZDH_FIRST_STEP);
|
|
595
|
+
}
|
|
596
|
+
function zdHeavyDelivery(own, rawSteps) {
|
|
597
|
+
const named = rawSteps.filter((s) => s && typeof s === "object" && typeof s.stepName === "string");
|
|
598
|
+
const lite = (name) => named.some((s) => Number(s.stepNumber ?? 0) < ZDH_FIRST_STEP && s.stepName === name && s.stepStatus === "completed");
|
|
599
|
+
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);
|
|
600
|
+
const has = (name) => events.some((e) => e.stepName === name);
|
|
601
|
+
const cancelled = has("cancelled");
|
|
602
|
+
const status = PROGRESS.has(own) && has("paid_out") && !cancelled ? "delivered" : own;
|
|
603
|
+
const steps = [];
|
|
604
|
+
const push = (name, done) => {
|
|
605
|
+
const last = steps[steps.length - 1];
|
|
606
|
+
if (last && last.name === name && last.done === done) return;
|
|
607
|
+
steps.push({ name, done });
|
|
608
|
+
};
|
|
609
|
+
if (lite("submitted")) push("submitted", true);
|
|
610
|
+
const terminal = cancelled || FAILED.has(status) || ATTENTION.has(status) || status === "delivered";
|
|
611
|
+
if (!cancelled && !FAILED.has(status) && !ATTENTION.has(status)) {
|
|
612
|
+
if (status === "delivered") {
|
|
613
|
+
push("route_completed", true);
|
|
614
|
+
} else {
|
|
615
|
+
push("route", false);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
for (const e of events) {
|
|
619
|
+
const name = String(e.stepName);
|
|
620
|
+
if (ROUTE_MECHANICS.has(name)) continue;
|
|
621
|
+
if (name === "refund_parked") {
|
|
622
|
+
push(e.stepStatus === "recovered" ? "claimed" : "ready_to_claim", e.stepStatus === "recovered");
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
push(ZDH_STEP[name] ?? name.slice(0, 32), true);
|
|
626
|
+
}
|
|
627
|
+
if (!terminal) push("delivered", false);
|
|
628
|
+
const capped = steps.length > MAX_STEPS ? [...steps.slice(0, MAX_STEPS - 1), steps[steps.length - 1]] : steps;
|
|
629
|
+
const refunded = cancelled && has("refunded");
|
|
630
|
+
if (!status) return TRACKING;
|
|
631
|
+
if (FAILED.has(status)) return { phase: "failed", status, steps: capped, ...refunded ? { refunded } : {} };
|
|
632
|
+
if (ATTENTION.has(status)) return { phase: "attention", status, steps: capped };
|
|
633
|
+
if (status === "delivered") return { phase: "delivered", status, steps: capped };
|
|
634
|
+
return { phase: "in-progress", status, steps: capped };
|
|
635
|
+
}
|
|
584
636
|
function normalizeDelivery(raw2) {
|
|
585
637
|
const row = raw2 && typeof raw2 === "object" && !Array.isArray(raw2) ? raw2.data ?? raw2 : null;
|
|
586
638
|
if (!row || typeof row !== "object" || Array.isArray(row)) return TRACKING;
|
|
@@ -590,6 +642,7 @@ function normalizeDelivery(raw2) {
|
|
|
590
642
|
const own = word(r.status);
|
|
591
643
|
const status = journey || own;
|
|
592
644
|
const rawSteps = Array.isArray(r.steps) ? r.steps : [];
|
|
645
|
+
if (isZdHeavy(r, rawSteps) && !chained) return zdHeavyDelivery(own, rawSteps);
|
|
593
646
|
const listed = rawSteps.filter((s) => s && typeof s === "object" && typeof s.stepName === "string").sort((a, b) => Number(a.stepNumber ?? 0) - Number(b.stepNumber ?? 0)).slice(0, 8).map((s) => ({ name: String(s.stepName).slice(0, 32), done: s.stepStatus === "completed" }));
|
|
594
647
|
const reached = Math.max(STATUS_REACHED[own] ?? -1, ...listed.filter((s) => s.done).map((s) => STEP_ORDER[s.name] ?? -1));
|
|
595
648
|
const steps = listed.map((s) => (STEP_ORDER[s.name] ?? Infinity) <= reached ? { ...s, done: true } : s);
|
|
@@ -679,7 +732,15 @@ var STEP_LABEL = {
|
|
|
679
732
|
arrived: "Arrived",
|
|
680
733
|
filled: "Filled",
|
|
681
734
|
outbound_bridging: "Bridging",
|
|
682
|
-
delivered: "Delivered"
|
|
735
|
+
delivered: "Delivered",
|
|
736
|
+
// ZD Heavy (core/delivery.ts; mirrors zd-dapp src/lib/zdHeavyTimeline.ts). How the order was filled
|
|
737
|
+
// (netted, partly netted, swapped) is the protocol's business, so the holder reads one "Filled".
|
|
738
|
+
route_completed: "Filled",
|
|
739
|
+
route: "Filled",
|
|
740
|
+
cancellation_requested: "Cancellation requested",
|
|
741
|
+
refunded: "Refunded",
|
|
742
|
+
ready_to_claim: "Ready to claim",
|
|
743
|
+
claimed: "Claimed"
|
|
683
744
|
};
|
|
684
745
|
var label = (name) => STEP_LABEL[name] ?? name.replace(/_/g, " ");
|
|
685
746
|
function deliveryHeadline(delivery, sourceConfirmed, direct2 = false) {
|
|
@@ -688,12 +749,14 @@ function deliveryHeadline(delivery, sourceConfirmed, direct2 = false) {
|
|
|
688
749
|
case "delivered":
|
|
689
750
|
return "Delivered";
|
|
690
751
|
case "failed":
|
|
752
|
+
if (delivery.status === "cancelled" && delivery.refunded) return "Cancelled \u2014 refunded to the owner";
|
|
691
753
|
return delivery.status === "cancelled" ? "Cancelled \u2014 not delivered" : `Not delivered (${delivery.status.replace(/_/g, " ")}) \u2014 open the transaction for details`;
|
|
692
754
|
case "attention":
|
|
693
755
|
return delivery.status === "cancel_pending" ? "Being cancelled \u2014 not delivered" : "Waiting to be claimed \u2014 open the transaction";
|
|
694
756
|
case "in-progress": {
|
|
695
757
|
if (delivery.status === "continuing") return "On its way \u2014 final leg next";
|
|
696
758
|
const next = delivery.steps.find((s) => !s.done);
|
|
759
|
+
if (next?.name === "route") return "On its way";
|
|
697
760
|
return next ? `On its way \u2014 ${label(next.name).toLowerCase()} next` : "On its way";
|
|
698
761
|
}
|
|
699
762
|
case "unavailable":
|
|
@@ -915,7 +978,7 @@ var CHAIN_DISPLAY_NAMES = Object.freeze({
|
|
|
915
978
|
8453: "Base",
|
|
916
979
|
9745: "Plasma",
|
|
917
980
|
34443: "Mode",
|
|
918
|
-
42161: "Arbitrum
|
|
981
|
+
42161: "Arbitrum",
|
|
919
982
|
// "Avalanche", as the dApp prints it since zd-dapp#582 (from ZD Heavy's /chains). The widget's
|
|
920
983
|
// registry read lists no row for a payout-only chain, so this table is what names it here.
|
|
921
984
|
43114: "Avalanche",
|
|
@@ -991,8 +1054,8 @@ var SOLANA_DESTINATION_ASSETS = Object.freeze({
|
|
|
991
1054
|
AymATz4TCL9sWNEEV9Kvyz45CHVhDZ6kUgjTJPzLpU9P: pin("XAUT", 6, "layerzero", TOKEN_PROGRAM)
|
|
992
1055
|
});
|
|
993
1056
|
function solanaDestinationAsset(mint) {
|
|
994
|
-
const
|
|
995
|
-
return Object.prototype.hasOwnProperty.call(SOLANA_DESTINATION_ASSETS,
|
|
1057
|
+
const key2 = typeof mint === "string" ? mint.trim() : "";
|
|
1058
|
+
return Object.prototype.hasOwnProperty.call(SOLANA_DESTINATION_ASSETS, key2) ? SOLANA_DESTINATION_ASSETS[key2] : null;
|
|
996
1059
|
}
|
|
997
1060
|
function solanaBridgeOf(token) {
|
|
998
1061
|
const pinned = solanaDestinationAsset(token.address);
|
|
@@ -1366,9 +1429,9 @@ function hexBytes(hex) {
|
|
|
1366
1429
|
if (h2.length % 2 || !/^[a-fA-F0-9]*$/.test(h2)) throw new Error("Invalid hex bytes.");
|
|
1367
1430
|
return Uint8Array.from(h2.match(/../g) || [], (v) => Number.parseInt(v, 16));
|
|
1368
1431
|
}
|
|
1369
|
-
function solanaKeyBytes(
|
|
1370
|
-
if (!isSolanaAddress(
|
|
1371
|
-
return base58Decode(
|
|
1432
|
+
function solanaKeyBytes(key2) {
|
|
1433
|
+
if (!isSolanaAddress(key2) || key2 !== key2.trim()) throw new Error("Invalid Solana public key.");
|
|
1434
|
+
return base58Decode(key2);
|
|
1372
1435
|
}
|
|
1373
1436
|
var B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
1374
1437
|
function base64Decode(text) {
|
|
@@ -1714,16 +1777,16 @@ function tokenTicker(token) {
|
|
|
1714
1777
|
}
|
|
1715
1778
|
function tickerOn(tokens, chainId, symbol) {
|
|
1716
1779
|
if (!symbol || !chainId || !tokens?.length) return symbol;
|
|
1717
|
-
const
|
|
1718
|
-
const deployment = tokens.find((t) => Number(t.chainId) === Number(chainId) && symbolKey(t.symbol) ===
|
|
1780
|
+
const key2 = symbolKey(symbol);
|
|
1781
|
+
const deployment = tokens.find((t) => Number(t.chainId) === Number(chainId) && symbolKey(t.symbol) === key2);
|
|
1719
1782
|
return deployment ? tokenTicker(deployment) : symbol;
|
|
1720
1783
|
}
|
|
1721
1784
|
|
|
1722
1785
|
// src/core/availability.ts
|
|
1723
1786
|
function assetClassOf(symbol) {
|
|
1724
|
-
const
|
|
1725
|
-
if (TRADEABLE_RWA_ASSETS.has(
|
|
1726
|
-
if (STABLE_ASSETS.has(
|
|
1787
|
+
const key2 = symbolKey(symbol);
|
|
1788
|
+
if (TRADEABLE_RWA_ASSETS.has(key2)) return "rwa";
|
|
1789
|
+
if (STABLE_ASSETS.has(key2)) return "stable";
|
|
1727
1790
|
return null;
|
|
1728
1791
|
}
|
|
1729
1792
|
var NEST_VAULT_SHARES = /* @__PURE__ */ new Set(["NALPHA", "NTBILL", "NBASIS", "NCREDIT", "NOPAL", "NWISDOM", "NACRDX", "NLCRD", "NAXI", "NCLOA", "NFALCON"]);
|
|
@@ -1832,8 +1895,8 @@ function buildCatalogue(input) {
|
|
|
1832
1895
|
if (product === "rwa") return true;
|
|
1833
1896
|
if (execution.has(chainId) || token.isChainedDestination === true) return true;
|
|
1834
1897
|
if (!isExecutableBridge(token)) return false;
|
|
1835
|
-
const
|
|
1836
|
-
return source2.has(
|
|
1898
|
+
const key2 = tokenKey(token.chainId, token.address);
|
|
1899
|
+
return source2.has(key2) || destination.has(key2);
|
|
1837
1900
|
});
|
|
1838
1901
|
const ready = chains.length > 0 && routes.length > 0 && projectedCatalogue.length > 0;
|
|
1839
1902
|
const catalogue = ready ? projectedCatalogue : allowed;
|
|
@@ -1877,8 +1940,8 @@ function tokenEnabled(token) {
|
|
|
1877
1940
|
return token?.isEnabled !== false && isChainAddress(token?.chainId, token?.address) && Number.isFinite(Number(token?.chainId));
|
|
1878
1941
|
}
|
|
1879
1942
|
function findToken(tokens, chainId, symbol) {
|
|
1880
|
-
const
|
|
1881
|
-
return tokens.find((token) => tokenEnabled(token) && Number(token.chainId) === Number(chainId) && symbolKey(token.symbol) ===
|
|
1943
|
+
const key2 = symbolKey(symbol);
|
|
1944
|
+
return tokens.find((token) => tokenEnabled(token) && Number(token.chainId) === Number(chainId) && symbolKey(token.symbol) === key2) || null;
|
|
1882
1945
|
}
|
|
1883
1946
|
function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains, walletChainId, catalogue }) {
|
|
1884
1947
|
const invoiceKey = symbolKey(invoiceAsset);
|
|
@@ -1912,10 +1975,10 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1912
1975
|
const chainId = Number(token.chainId);
|
|
1913
1976
|
const chain2 = chainById(chains, chainId);
|
|
1914
1977
|
if (!chainSelectable(chain2, chainId)) continue;
|
|
1915
|
-
const
|
|
1916
|
-
if (seen.has(
|
|
1978
|
+
const key2 = tokenKey(chainId, token.address);
|
|
1979
|
+
if (seen.has(key2)) continue;
|
|
1917
1980
|
if (refusal(token)) continue;
|
|
1918
|
-
seen.add(
|
|
1981
|
+
seen.add(key2);
|
|
1919
1982
|
const payKey = symbolKey(token.symbol);
|
|
1920
1983
|
const direct2 = chainId === invoiceChain && payKey === invoiceKey;
|
|
1921
1984
|
options.push({
|
|
@@ -2101,7 +2164,7 @@ function normalizePreview(request, quote, to, amount) {
|
|
|
2101
2164
|
async function quoteSolanaSource(api, input) {
|
|
2102
2165
|
const { from, to, amount } = selections(input, await api.fetchTokens());
|
|
2103
2166
|
const request = makeRequest(input, from, to, amount);
|
|
2104
|
-
const quote = await api.apiRequest("/quote", { method: "POST", body: JSON.stringify(request), timeoutMs: 18e3 });
|
|
2167
|
+
const quote = await api.apiRequest("/quote", { method: "POST", headers: { "X-ZD-Shape": "native" }, body: JSON.stringify(request), timeoutMs: 18e3 });
|
|
2105
2168
|
const preview = normalizePreview(request, quote, to, input.amountIn);
|
|
2106
2169
|
quoteRequests.set(preview, { api, request: clone(request) });
|
|
2107
2170
|
return preview;
|
|
@@ -2115,7 +2178,7 @@ async function previewSolanaSource(api, input) {
|
|
|
2115
2178
|
raw(amount, "input amount", true);
|
|
2116
2179
|
const body = { inputChain: SOLANA_CHAIN_ID, outputChain: input.toChainId, inputToken: from.symbol, outputToken: to.symbol, inputAmount: amount };
|
|
2117
2180
|
const request = body;
|
|
2118
|
-
const quote = await api.apiRequest("/quote", { method: "POST", body: JSON.stringify(request), timeoutMs: 18e3 });
|
|
2181
|
+
const quote = await api.apiRequest("/quote", { method: "POST", headers: { "X-ZD-Shape": "native" }, body: JSON.stringify(request), timeoutMs: 18e3 });
|
|
2119
2182
|
const option = quote?.options?.[0];
|
|
2120
2183
|
if (!option) throw new Error("Native quote returned no options.");
|
|
2121
2184
|
const receive = raw(option.finalAmount, "quoted output", true);
|
|
@@ -2472,8 +2535,8 @@ function historyKey(value) {
|
|
|
2472
2535
|
var str = (v) => typeof v === "string" ? v : typeof v === "number" ? String(v) : "";
|
|
2473
2536
|
function tokenAt(tokens, chainId, address) {
|
|
2474
2537
|
if (!address) return void 0;
|
|
2475
|
-
const
|
|
2476
|
-
return tokens.find((t) => Number(t.chainId) === chainId && historyKey(String(t.address)) ===
|
|
2538
|
+
const key2 = historyKey(address);
|
|
2539
|
+
return tokens.find((t) => Number(t.chainId) === chainId && historyKey(String(t.address)) === key2);
|
|
2477
2540
|
}
|
|
2478
2541
|
function amountOf(raw2, token, rowDecimals, rowAmount) {
|
|
2479
2542
|
const decimals = token ? Number(token.decimals) : Number(rowDecimals);
|
|
@@ -2559,13 +2622,13 @@ function mergeHistory(local, remote, limit = WALLET_HISTORY_LIMIT) {
|
|
|
2559
2622
|
const out = [];
|
|
2560
2623
|
const seen = /* @__PURE__ */ new Set();
|
|
2561
2624
|
for (const entry of local) {
|
|
2562
|
-
const
|
|
2563
|
-
if (seen.has(
|
|
2564
|
-
seen.add(
|
|
2565
|
-
const known = byHash.get(
|
|
2625
|
+
const key2 = historyKey(entry.hash);
|
|
2626
|
+
if (seen.has(key2)) continue;
|
|
2627
|
+
seen.add(key2);
|
|
2628
|
+
const known = byHash.get(key2);
|
|
2566
2629
|
out.push(known ? { ...entry, delivery: known.delivery, legs: entry.legs ?? known.legs } : entry);
|
|
2567
2630
|
}
|
|
2568
|
-
for (const [
|
|
2631
|
+
for (const [key2, entry] of byHash) if (!seen.has(key2)) out.push(entry);
|
|
2569
2632
|
return out.sort((a, b) => Date.parse(b.at) - Date.parse(a.at)).slice(0, limit);
|
|
2570
2633
|
}
|
|
2571
2634
|
|
|
@@ -2676,12 +2739,12 @@ function suppressedLanes(health) {
|
|
|
2676
2739
|
const out = /* @__PURE__ */ new Map();
|
|
2677
2740
|
for (const lane of health.lanes) {
|
|
2678
2741
|
if (!lane || typeof lane !== "object" || !isSuppressed(lane)) continue;
|
|
2679
|
-
const
|
|
2680
|
-
if (!
|
|
2742
|
+
const key2 = healthLaneKey(lane.laneKey);
|
|
2743
|
+
if (!key2) continue;
|
|
2681
2744
|
const availability = laneAvailabilityState(lane) ? lane.availability : void 0;
|
|
2682
2745
|
const code = typeof availability?.code === "string" && availability.code ? availability.code : lane.code;
|
|
2683
2746
|
const message = typeof availability?.message === "string" && availability.message ? availability.message : lane.message;
|
|
2684
|
-
out.set(
|
|
2747
|
+
out.set(key2, {
|
|
2685
2748
|
route: typeof lane.route === "string" ? lane.route : "",
|
|
2686
2749
|
code: typeof code === "string" ? code : "",
|
|
2687
2750
|
message: typeof message === "string" ? message : "",
|
|
@@ -2696,15 +2759,15 @@ function limitedLanes(health) {
|
|
|
2696
2759
|
const out = /* @__PURE__ */ new Map();
|
|
2697
2760
|
for (const lane of health.lanes) {
|
|
2698
2761
|
if (!lane || typeof lane !== "object" || laneAvailabilityState(lane) !== "limited") continue;
|
|
2699
|
-
const
|
|
2762
|
+
const key2 = healthLaneKey(lane.laneKey);
|
|
2700
2763
|
const limit = lane.availability?.limit;
|
|
2701
|
-
if (!
|
|
2764
|
+
if (!key2 || !limit || typeof limit !== "object") continue;
|
|
2702
2765
|
const side = limit.side === "bid" || limit.side === "ask" ? limit.side : null;
|
|
2703
2766
|
const maxAmount = typeof limit.maxAmount === "string" ? limit.maxAmount.trim() : "";
|
|
2704
2767
|
const decimals = limit.decimals;
|
|
2705
2768
|
if (!side || !BASE_UNITS.test(maxAmount) || typeof decimals !== "number" || !Number.isInteger(decimals) || decimals < 0 || decimals > 36) continue;
|
|
2706
2769
|
const code = lane.availability?.code;
|
|
2707
|
-
out.set(
|
|
2770
|
+
out.set(key2, {
|
|
2708
2771
|
side,
|
|
2709
2772
|
token: typeof limit.token === "string" ? limit.token : "",
|
|
2710
2773
|
fromChainId: Number(limit.fromChainId) || 0,
|
|
@@ -2767,10 +2830,10 @@ function resolveVaultIcon(apiBase, iconPath) {
|
|
|
2767
2830
|
function vaultIconsBySymbol(apiBase, vaults) {
|
|
2768
2831
|
const out = /* @__PURE__ */ new Map();
|
|
2769
2832
|
for (const vault of vaults) {
|
|
2770
|
-
const
|
|
2771
|
-
if (!
|
|
2833
|
+
const key2 = symbolKey(vault?.symbol);
|
|
2834
|
+
if (!key2 || out.has(key2)) continue;
|
|
2772
2835
|
const url = resolveVaultIcon(apiBase, vault?.iconMiniUrl) ?? resolveVaultIcon(apiBase, vault?.iconUrl);
|
|
2773
|
-
if (url) out.set(
|
|
2836
|
+
if (url) out.set(key2, url);
|
|
2774
2837
|
}
|
|
2775
2838
|
return out;
|
|
2776
2839
|
}
|
|
@@ -2867,7 +2930,7 @@ var CATEGORY_PHRASES = {
|
|
|
2867
2930
|
UNKNOWN: "an unrecognized risk"
|
|
2868
2931
|
};
|
|
2869
2932
|
function categoryLabel(code) {
|
|
2870
|
-
const
|
|
2933
|
+
const key2 = code.trim().toUpperCase();
|
|
2871
2934
|
const LABELS = {
|
|
2872
2935
|
SANCTIONS: "Sanctions",
|
|
2873
2936
|
TERRORISM_FINANCING: "Terrorist financing",
|
|
@@ -2882,7 +2945,7 @@ function categoryLabel(code) {
|
|
|
2882
2945
|
UNCLASSIFIED: "Unclassified risk",
|
|
2883
2946
|
UNKNOWN: "Unclassified risk"
|
|
2884
2947
|
};
|
|
2885
|
-
return LABELS[
|
|
2948
|
+
return LABELS[key2] ?? key2.toLowerCase().replace(/_/g, " ");
|
|
2886
2949
|
}
|
|
2887
2950
|
function cleanJurisdiction(code) {
|
|
2888
2951
|
return code.replace(/^(OFAC|TIER\d+|SANCTIONED)_/i, "").trim();
|
|
@@ -2995,9 +3058,9 @@ function distinctScreenedWallets(compliance) {
|
|
|
2995
3058
|
for (const raw2 of compliance?.screenedWallets ?? []) {
|
|
2996
3059
|
const address = raw2?.trim();
|
|
2997
3060
|
if (!address) continue;
|
|
2998
|
-
const
|
|
2999
|
-
if (seen.has(
|
|
3000
|
-
seen.add(
|
|
3061
|
+
const key2 = /^0x[0-9a-fA-F]+$/.test(address) ? address.toLowerCase() : address;
|
|
3062
|
+
if (seen.has(key2)) continue;
|
|
3063
|
+
seen.add(key2);
|
|
3001
3064
|
wallets.push(address);
|
|
3002
3065
|
}
|
|
3003
3066
|
return wallets;
|
|
@@ -3108,9 +3171,9 @@ var TUNED_OUTCOMES = {
|
|
|
3108
3171
|
UNCLASSIFIED: "flagged"
|
|
3109
3172
|
};
|
|
3110
3173
|
function screeningOutcomeOf(category) {
|
|
3111
|
-
const
|
|
3112
|
-
if (FLOOR_CATEGORIES.includes(
|
|
3113
|
-
return TUNED_OUTCOMES[
|
|
3174
|
+
const key2 = category.trim().toUpperCase();
|
|
3175
|
+
if (FLOOR_CATEGORIES.includes(key2)) return "always-blocked";
|
|
3176
|
+
return TUNED_OUTCOMES[key2] ?? null;
|
|
3114
3177
|
}
|
|
3115
3178
|
var labelsFor = (outcome) => [...FLOOR_CATEGORIES, ...TUNABLE_CATEGORIES].filter((c) => screeningOutcomeOf(c) === outcome).map(categoryLabel);
|
|
3116
3179
|
var SCREENING_BUCKETS = [
|
|
@@ -3119,6 +3182,91 @@ var SCREENING_BUCKETS = [
|
|
|
3119
3182
|
{ outcome: "flagged", title: "Flagged", detail: "A warning is shown.", categories: labelsFor("flagged") }
|
|
3120
3183
|
];
|
|
3121
3184
|
|
|
3185
|
+
// src/core/zdheavy-routers.ts
|
|
3186
|
+
var ZDHEAVY_ROUTER_TEST05 = "0x94c5cC7f4689AD7B0Abd0975F4C8E159e4633251";
|
|
3187
|
+
var ZDHEAVY_ROUTER_TEST04 = "0x72EA420DCE5BE939062E527b49388479d7171379";
|
|
3188
|
+
var ZDHEAVY_ROUTER_DEV = "0xD813690937324417cFBE12E742dD53054F90dF04";
|
|
3189
|
+
var ZDHEAVY_ROUTER_DEV_V6 = "0xa6155b1505378e6C9871483c55375dcBBB16f897";
|
|
3190
|
+
var ZDHEAVY_ROUTER_PROD = "0x7D50305f2855Bf2225FE51E15858b4BA0C0844e1";
|
|
3191
|
+
var ZDHEAVY_DEV_CHAINS = [1, 10, 56, 130, 137, 143, 146, 1329, 1672, 4663, 5e3, 8453, 9745, 42161, 43114, 57073, 98866];
|
|
3192
|
+
var ZDHEAVY_SANDBOX_CHAINS = [8453, 9745, 42161];
|
|
3193
|
+
var ZDHEAVY_ROUTER_ADDRESSES = Object.fromEntries(
|
|
3194
|
+
ZDHEAVY_DEV_CHAINS.map((id) => [
|
|
3195
|
+
id,
|
|
3196
|
+
ZDHEAVY_SANDBOX_CHAINS.includes(id) ? [ZDHEAVY_ROUTER_TEST05, ZDHEAVY_ROUTER_TEST04, ZDHEAVY_ROUTER_DEV, ZDHEAVY_ROUTER_DEV_V6, ZDHEAVY_ROUTER_PROD] : [ZDHEAVY_ROUTER_DEV, ZDHEAVY_ROUTER_DEV_V6, ZDHEAVY_ROUTER_PROD]
|
|
3197
|
+
])
|
|
3198
|
+
);
|
|
3199
|
+
function zdHeavyRouterPinned(chainId, router) {
|
|
3200
|
+
if (typeof router !== "string" || !/^0x[0-9a-fA-F]{40}$/.test(router)) return false;
|
|
3201
|
+
const want = router.toLowerCase();
|
|
3202
|
+
return (ZDHEAVY_ROUTER_ADDRESSES[chainId] ?? []).some((a) => a.toLowerCase() === want);
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
// src/core/quote-option.ts
|
|
3206
|
+
function zdHeavyExecutable(q) {
|
|
3207
|
+
const order = q.execution?.order;
|
|
3208
|
+
const chainId = typeof q.fromChainId === "number" ? q.fromChainId : Number(order?.chainNumber);
|
|
3209
|
+
return q.protocol === "zdheavy" && q.payloadStatus === "resolved-offchain-signed" && !!order && !!q.rootHash && Array.isArray(q.txData) && q.txData.some((tx) => (tx.actionType === "submit" || tx.actionType === "submitOrder") && typeof tx.to === "string" && typeof tx.data === "string") && zdHeavyRouterPinned(chainId, order.router);
|
|
3210
|
+
}
|
|
3211
|
+
function liteExecutable(q) {
|
|
3212
|
+
return q.protocol !== "zdheavy" && Array.isArray(q.orderRequests) && q.orderRequests.length > 0;
|
|
3213
|
+
}
|
|
3214
|
+
function selectQuoteOption(quote) {
|
|
3215
|
+
if (!Array.isArray(quote.options)) return quote;
|
|
3216
|
+
const option = quote.options.find(zdHeavyExecutable) ?? quote.options.find((q) => q.protocol !== "zdheavy" && !!q.orderRequests?.length);
|
|
3217
|
+
if (!option) throw new Error("ZeroDelta quote has no executable option.");
|
|
3218
|
+
const gatewayOptions = [];
|
|
3219
|
+
let gatewayOptionIndex = -1;
|
|
3220
|
+
for (const o of quote.options) {
|
|
3221
|
+
if (!o || typeof o !== "object" || Array.isArray(o)) continue;
|
|
3222
|
+
if (o === option) gatewayOptionIndex = gatewayOptions.length;
|
|
3223
|
+
gatewayOptions.push(projectOption(quote, o));
|
|
3224
|
+
}
|
|
3225
|
+
return { ...projectOption(quote, option), gatewayOptions, gatewayOptionIndex };
|
|
3226
|
+
}
|
|
3227
|
+
function projectOption(quote, option) {
|
|
3228
|
+
const { fromChainId, toChainId, fromToken, toToken: toToken2, fromAmount } = quote;
|
|
3229
|
+
const last = option.orderRequests?.[option.orderRequests.length - 1];
|
|
3230
|
+
const { entersNetting, gasSponsored, gatewayOptions: _g, gatewayOptionIndex: _i, ...rest } = option;
|
|
3231
|
+
return {
|
|
3232
|
+
...rest,
|
|
3233
|
+
...entersNetting === true ? { entersNetting: true } : {},
|
|
3234
|
+
...gasSponsored === true ? { gasSponsored: true } : {},
|
|
3235
|
+
fromChainId,
|
|
3236
|
+
toChainId,
|
|
3237
|
+
fromToken,
|
|
3238
|
+
toToken: toToken2,
|
|
3239
|
+
fromAmount,
|
|
3240
|
+
quoteId: quote.quoteId,
|
|
3241
|
+
toAmount: String(last?.askTokenAmount ?? option.outputAmount ?? option.toAmount ?? ""),
|
|
3242
|
+
finalAmount: String(option.finalAmount || last?.askTokenAmount || option.outputAmount || ""),
|
|
3243
|
+
compliance: complianceDecision(quote),
|
|
3244
|
+
estimatedDuration: option.estimatedTimeSec ?? option.estimatedDuration
|
|
3245
|
+
};
|
|
3246
|
+
}
|
|
3247
|
+
function complianceDecision(quote) {
|
|
3248
|
+
const decision = quote.complianceDecision ?? quote.compliance;
|
|
3249
|
+
return decision && typeof decision === "object" && !Array.isArray(decision) ? decision : void 0;
|
|
3250
|
+
}
|
|
3251
|
+
function normalizeQuoteResponse(response, request) {
|
|
3252
|
+
const quote = Array.isArray(response?.options) ? selectQuoteOption({
|
|
3253
|
+
...response,
|
|
3254
|
+
fromChainId: request.inputChain,
|
|
3255
|
+
toChainId: request.outputChain,
|
|
3256
|
+
fromToken: request.inputToken,
|
|
3257
|
+
toToken: request.outputToken,
|
|
3258
|
+
fromAmount: request.inputAmount
|
|
3259
|
+
}) : response;
|
|
3260
|
+
if (quote?.gatewayOptions) quote.gatewayOptions = quote.gatewayOptions.map(numericExecutionChain);
|
|
3261
|
+
return numericExecutionChain(quote);
|
|
3262
|
+
}
|
|
3263
|
+
function numericExecutionChain(quote) {
|
|
3264
|
+
return quote && quote.executionChainId != null ? { ...quote, executionChainId: Number(quote.executionChainId) } : quote;
|
|
3265
|
+
}
|
|
3266
|
+
function deliveredAmount(quote, solanaDestination) {
|
|
3267
|
+
return BigInt(quote.protocol === "zdheavy" || solanaDestination ? quote.finalAmount || quote.toAmount || "0" : quote.toAmount || "0");
|
|
3268
|
+
}
|
|
3269
|
+
|
|
3122
3270
|
// src/core/solve.ts
|
|
3123
3271
|
async function solveExactOut({ option, destination, destinationToken, payer, fetchQuote }) {
|
|
3124
3272
|
const destDecimals = assetDecimals(destinationToken);
|
|
@@ -3165,7 +3313,7 @@ async function solveExactOut({ option, destination, destinationToken, payer, fet
|
|
|
3165
3313
|
let bestGuess = guess;
|
|
3166
3314
|
for (let i = 0; i < 3; i += 1) {
|
|
3167
3315
|
const guessSent = guess;
|
|
3168
|
-
const quote = await fetchQuote({
|
|
3316
|
+
const quote = selectQuoteOption(await fetchQuote({
|
|
3169
3317
|
fromChainId: option.chainId,
|
|
3170
3318
|
toChainId: Number(destination.chainId),
|
|
3171
3319
|
fromToken: option.symbol,
|
|
@@ -3173,11 +3321,11 @@ async function solveExactOut({ option, destination, destinationToken, payer, fet
|
|
|
3173
3321
|
fromAmount: guessSent.toString(),
|
|
3174
3322
|
owner: payer,
|
|
3175
3323
|
destinationReceiver: destination.address
|
|
3176
|
-
});
|
|
3324
|
+
}));
|
|
3177
3325
|
if (BigInt(quote?.fromAmount || "0") !== guessSent) {
|
|
3178
3326
|
throw new Error("ZeroDelta echoed a different input amount than requested.");
|
|
3179
3327
|
}
|
|
3180
|
-
const guaranteed = isSolanaChainId(destination.chainId)
|
|
3328
|
+
const guaranteed = deliveredAmount(quote, isSolanaChainId(destination.chainId));
|
|
3181
3329
|
const final = finalOf(quote);
|
|
3182
3330
|
if (final > bestFinal) {
|
|
3183
3331
|
bestFinal = final;
|
|
@@ -3214,7 +3362,7 @@ async function solveExactOut({ option, destination, destinationToken, payer, fet
|
|
|
3214
3362
|
directTransfer: false,
|
|
3215
3363
|
quote: best,
|
|
3216
3364
|
youPayRaw: bestGuess.toString(),
|
|
3217
|
-
recipientReceivesRaw: (isSolanaChainId(destination.chainId)
|
|
3365
|
+
recipientReceivesRaw: deliveredAmount(best, isSolanaChainId(destination.chainId)).toString(),
|
|
3218
3366
|
targetRaw: targetRaw.toString(),
|
|
3219
3367
|
overageBps: targetRaw > 0n ? Number((bestFinal - targetRaw) * 10000n / targetRaw) : 0,
|
|
3220
3368
|
meetsTarget: bestFinal >= targetRaw,
|
|
@@ -3224,7 +3372,7 @@ async function solveExactOut({ option, destination, destinationToken, payer, fet
|
|
|
3224
3372
|
async function solveExactIn({ option, destination, destinationToken, payer, fetchQuote, amountInRaw }) {
|
|
3225
3373
|
const fromRaw = BigInt(amountInRaw || "0");
|
|
3226
3374
|
if (fromRaw <= 0n) throw new Error("Swap amount must be greater than zero.");
|
|
3227
|
-
const quote = await fetchQuote({
|
|
3375
|
+
const quote = selectQuoteOption(await fetchQuote({
|
|
3228
3376
|
fromChainId: option.chainId,
|
|
3229
3377
|
toChainId: Number(destination.chainId),
|
|
3230
3378
|
fromToken: option.symbol,
|
|
@@ -3232,11 +3380,11 @@ async function solveExactIn({ option, destination, destinationToken, payer, fetc
|
|
|
3232
3380
|
fromAmount: fromRaw.toString(),
|
|
3233
3381
|
owner: payer,
|
|
3234
3382
|
destinationReceiver: destination.address
|
|
3235
|
-
});
|
|
3383
|
+
}));
|
|
3236
3384
|
if (BigInt(quote?.fromAmount || "0") !== fromRaw) {
|
|
3237
3385
|
throw new Error("ZeroDelta echoed a different input amount than requested.");
|
|
3238
3386
|
}
|
|
3239
|
-
const guaranteed = isSolanaChainId(destination.chainId)
|
|
3387
|
+
const guaranteed = deliveredAmount(quote, isSolanaChainId(destination.chainId));
|
|
3240
3388
|
if (guaranteed <= 0n) throw new Error("ZeroDelta could not price this swap.");
|
|
3241
3389
|
return {
|
|
3242
3390
|
directTransfer: false,
|
|
@@ -3249,6 +3397,24 @@ async function solveExactIn({ option, destination, destinationToken, payer, fetc
|
|
|
3249
3397
|
iterations: 1
|
|
3250
3398
|
};
|
|
3251
3399
|
}
|
|
3400
|
+
function resultForOption(result, option, mode, destinationChainId) {
|
|
3401
|
+
if (result.directTransfer) throw new Error("A direct transfer has no other option.");
|
|
3402
|
+
if (BigInt(option.fromAmount || "0") !== BigInt(result.youPayRaw)) throw new Error("ZeroDelta echoed a different input amount than requested.");
|
|
3403
|
+
const guaranteed = deliveredAmount(option, isSolanaChainId(destinationChainId));
|
|
3404
|
+
if (mode === "exact-in") {
|
|
3405
|
+
if (guaranteed <= 0n) throw new Error("ZeroDelta could not price this swap.");
|
|
3406
|
+
return { ...result, quote: option, recipientReceivesRaw: guaranteed.toString(), targetRaw: guaranteed.toString(), overageBps: 0, meetsTarget: true };
|
|
3407
|
+
}
|
|
3408
|
+
const targetRaw = BigInt(result.targetRaw);
|
|
3409
|
+
const final = finalOf(option);
|
|
3410
|
+
return {
|
|
3411
|
+
...result,
|
|
3412
|
+
quote: option,
|
|
3413
|
+
recipientReceivesRaw: guaranteed.toString(),
|
|
3414
|
+
overageBps: targetRaw > 0n ? Number((final - targetRaw) * 10000n / targetRaw) : 0,
|
|
3415
|
+
meetsTarget: final >= targetRaw
|
|
3416
|
+
};
|
|
3417
|
+
}
|
|
3252
3418
|
|
|
3253
3419
|
// src/core/order.ts
|
|
3254
3420
|
var DEFAULT_DEADLINE_SECONDS = 1800;
|
|
@@ -3368,134 +3534,1173 @@ function assertQuoteMatchesSelection({ quote, order, orders, option, destination
|
|
|
3368
3534
|
}
|
|
3369
3535
|
}
|
|
3370
3536
|
|
|
3371
|
-
// src/core/
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3537
|
+
// src/core/checksum.ts
|
|
3538
|
+
var RC = [
|
|
3539
|
+
0x0000000000000001n,
|
|
3540
|
+
0x0000000000008082n,
|
|
3541
|
+
0x800000000000808an,
|
|
3542
|
+
0x8000000080008000n,
|
|
3543
|
+
0x000000000000808bn,
|
|
3544
|
+
0x0000000080000001n,
|
|
3545
|
+
0x8000000080008081n,
|
|
3546
|
+
0x8000000000008009n,
|
|
3547
|
+
0x000000000000008an,
|
|
3548
|
+
0x0000000000000088n,
|
|
3549
|
+
0x0000000080008009n,
|
|
3550
|
+
0x000000008000000an,
|
|
3551
|
+
0x000000008000808bn,
|
|
3552
|
+
0x800000000000008bn,
|
|
3553
|
+
0x8000000000008089n,
|
|
3554
|
+
0x8000000000008003n,
|
|
3555
|
+
0x8000000000008002n,
|
|
3556
|
+
0x8000000000000080n,
|
|
3557
|
+
0x000000000000800an,
|
|
3558
|
+
0x800000008000000an,
|
|
3559
|
+
0x8000000080008081n,
|
|
3560
|
+
0x8000000000008080n,
|
|
3561
|
+
0x0000000080000001n,
|
|
3562
|
+
0x8000000080008008n
|
|
3563
|
+
];
|
|
3564
|
+
var ROT = [0, 1, 62, 28, 27, 36, 44, 6, 55, 20, 3, 10, 43, 25, 39, 41, 45, 15, 21, 8, 18, 2, 61, 56, 14];
|
|
3565
|
+
var MASK = (1n << 64n) - 1n;
|
|
3566
|
+
var rotl = (x, n) => n === 0 ? x : (x << BigInt(n) | x >> BigInt(64 - n)) & MASK;
|
|
3567
|
+
function keccakF(s) {
|
|
3568
|
+
for (let round = 0; round < 24; round++) {
|
|
3569
|
+
const c = [0, 1, 2, 3, 4].map((x) => s[x] ^ s[x + 5] ^ s[x + 10] ^ s[x + 15] ^ s[x + 20]);
|
|
3570
|
+
for (let x = 0; x < 5; x++) {
|
|
3571
|
+
const d = c[(x + 4) % 5] ^ rotl(c[(x + 1) % 5], 1);
|
|
3572
|
+
for (let y = 0; y < 25; y += 5) s[y + x] = s[y + x] ^ d;
|
|
3573
|
+
}
|
|
3574
|
+
const b = new Array(25);
|
|
3575
|
+
for (let x = 0; x < 5; x++) for (let y = 0; y < 5; y++) b[y + 5 * ((2 * x + 3 * y) % 5)] = rotl(s[x + 5 * y], ROT[x + 5 * y]);
|
|
3576
|
+
for (let x = 0; x < 5; x++) for (let y = 0; y < 25; y += 5) s[y + x] = b[y + x] ^ ~b[y + (x + 1) % 5] & MASK & b[y + (x + 2) % 5];
|
|
3577
|
+
s[0] = s[0] ^ RC[round];
|
|
3578
|
+
}
|
|
3378
3579
|
}
|
|
3379
|
-
function
|
|
3380
|
-
const
|
|
3381
|
-
|
|
3580
|
+
function keccak256Hex(bytes) {
|
|
3581
|
+
const rate = 136;
|
|
3582
|
+
const padded = new Uint8Array(Math.ceil((bytes.length + 1) / rate) * rate);
|
|
3583
|
+
padded.set(bytes);
|
|
3584
|
+
padded[bytes.length] = padded[bytes.length] ^ 1;
|
|
3585
|
+
padded[padded.length - 1] = padded[padded.length - 1] ^ 128;
|
|
3586
|
+
const s = new Array(25).fill(0n);
|
|
3587
|
+
for (let off = 0; off < padded.length; off += rate) {
|
|
3588
|
+
for (let i = 0; i < rate / 8; i++) {
|
|
3589
|
+
let lane = 0n;
|
|
3590
|
+
for (let j = 7; j >= 0; j--) lane = lane << 8n | BigInt(padded[off + i * 8 + j]);
|
|
3591
|
+
s[i] = s[i] ^ lane;
|
|
3592
|
+
}
|
|
3593
|
+
keccakF(s);
|
|
3594
|
+
}
|
|
3595
|
+
let out = "";
|
|
3596
|
+
for (let i = 0; i < 4; i++) for (let j = 0; j < 8; j++) out += Number(s[i] >> BigInt(8 * j) & 0xffn).toString(16).padStart(2, "0");
|
|
3597
|
+
return out;
|
|
3382
3598
|
}
|
|
3383
|
-
function
|
|
3384
|
-
|
|
3599
|
+
function toChecksumAddress(address) {
|
|
3600
|
+
const lower3 = address.slice(2).toLowerCase();
|
|
3601
|
+
const hash2 = keccak256Hex(new TextEncoder().encode(lower3));
|
|
3602
|
+
let out = "0x";
|
|
3603
|
+
for (let i = 0; i < 40; i++) out += Number.parseInt(hash2[i], 16) >= 8 ? lower3[i].toUpperCase() : lower3[i];
|
|
3604
|
+
return out;
|
|
3385
3605
|
}
|
|
3386
|
-
function
|
|
3387
|
-
if (
|
|
3388
|
-
const
|
|
3389
|
-
|
|
3606
|
+
function hasValidChecksum(address) {
|
|
3607
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(address)) return false;
|
|
3608
|
+
const body = address.slice(2);
|
|
3609
|
+
if (body === body.toLowerCase() || body === body.toUpperCase()) return true;
|
|
3610
|
+
return toChecksumAddress(address) === address;
|
|
3390
3611
|
}
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3612
|
+
|
|
3613
|
+
// src/core/zdheavy-codec.ts
|
|
3614
|
+
var concat = (parts) => "0x" + parts.map((p) => p.slice(2)).join("");
|
|
3615
|
+
var hexToBytes2 = (h2) => Uint8Array.from(h2.slice(2).match(/../g) ?? [], (b) => Number.parseInt(b, 16));
|
|
3616
|
+
var toBytes = (s) => new TextEncoder().encode(s);
|
|
3617
|
+
var toHex = (v, opts) => "0x" + (typeof v === "bigint" ? v.toString(16).padStart((opts?.size ?? 0) * 2, "0") : Array.from(v, (b) => b.toString(16).padStart(2, "0")).join(""));
|
|
3618
|
+
var keccak256 = (h2) => "0x" + keccak256Hex(hexToBytes2(h2));
|
|
3619
|
+
var STEP_VERSION = 5;
|
|
3620
|
+
var MAX_STEPS2 = 8;
|
|
3621
|
+
var StepKind = {
|
|
3622
|
+
LOCAL_PAYOUT: 1,
|
|
3623
|
+
REMOTE_PAYOUT: 2,
|
|
3624
|
+
SEND: 3,
|
|
3625
|
+
SWAP: 4,
|
|
3626
|
+
EXECUTE: 5,
|
|
3627
|
+
NET: 6,
|
|
3628
|
+
SUBSIDY: 7
|
|
3629
|
+
};
|
|
3630
|
+
var ZdHeavyCodecError = class extends Error {
|
|
3631
|
+
constructor(message) {
|
|
3632
|
+
super(message);
|
|
3633
|
+
this.name = "ZdHeavyCodecError";
|
|
3634
|
+
}
|
|
3635
|
+
};
|
|
3636
|
+
function checkedHex(value, length) {
|
|
3637
|
+
if (typeof value !== "string" || !/^0x(?:[0-9a-fA-F]{2})*$/.test(value) || length !== void 0 && value.length !== 2 + length * 2) {
|
|
3638
|
+
throw new ZdHeavyCodecError(`Expected ${length === void 0 ? "byte-aligned" : length + "-byte"} hex`);
|
|
3639
|
+
}
|
|
3640
|
+
return value.toLowerCase();
|
|
3396
3641
|
}
|
|
3397
|
-
function
|
|
3398
|
-
if (
|
|
3642
|
+
function uint(value, bytes) {
|
|
3643
|
+
if (typeof value !== "bigint" || value < 0n || value >= 1n << BigInt(bytes * 8)) {
|
|
3644
|
+
throw new ZdHeavyCodecError(`Value outside uint${bytes * 8}`);
|
|
3645
|
+
}
|
|
3646
|
+
return toHex(value, { size: bytes });
|
|
3647
|
+
}
|
|
3648
|
+
var Reader2 = class {
|
|
3649
|
+
bytes;
|
|
3650
|
+
offset = 0;
|
|
3651
|
+
constructor(step) {
|
|
3652
|
+
this.bytes = hexToBytes2(checkedHex(step));
|
|
3653
|
+
}
|
|
3654
|
+
take(n) {
|
|
3655
|
+
if (this.offset + n > this.bytes.length) throw new ZdHeavyCodecError("Short step");
|
|
3656
|
+
const result = this.bytes.slice(this.offset, this.offset + n);
|
|
3657
|
+
this.offset += n;
|
|
3658
|
+
return result;
|
|
3659
|
+
}
|
|
3660
|
+
hex(n) {
|
|
3661
|
+
return toHex(this.take(n));
|
|
3662
|
+
}
|
|
3663
|
+
uint(n) {
|
|
3664
|
+
let result = 0n;
|
|
3665
|
+
for (const byte of this.take(n)) result = result << 8n | BigInt(byte);
|
|
3666
|
+
return result;
|
|
3667
|
+
}
|
|
3668
|
+
number(n) {
|
|
3669
|
+
return Number(this.uint(n));
|
|
3670
|
+
}
|
|
3671
|
+
address() {
|
|
3672
|
+
const n = this.number(1);
|
|
3673
|
+
if (n === 0 || n > 64) throw new ZdHeavyCodecError("Address length must be 1..64");
|
|
3674
|
+
return this.hex(n);
|
|
3675
|
+
}
|
|
3676
|
+
bytes16() {
|
|
3677
|
+
return this.hex(this.number(2));
|
|
3678
|
+
}
|
|
3679
|
+
adapters() {
|
|
3680
|
+
const count = this.number(1);
|
|
3681
|
+
if (count > 8) throw new ZdHeavyCodecError("Too many bridge adapters");
|
|
3682
|
+
return Array.from({ length: count }, () => this.number(2));
|
|
3683
|
+
}
|
|
3684
|
+
end() {
|
|
3685
|
+
if (this.offset !== this.bytes.length) throw new ZdHeavyCodecError("Trailing step bytes");
|
|
3686
|
+
}
|
|
3687
|
+
};
|
|
3688
|
+
function decodeStep(step) {
|
|
3689
|
+
const r = new Reader2(step);
|
|
3690
|
+
if (r.number(1) !== STEP_VERSION) throw new ZdHeavyCodecError("Unsupported step version");
|
|
3691
|
+
const kind = r.number(2);
|
|
3692
|
+
if (kind < 1 || kind > 7) throw new ZdHeavyCodecError("Unknown step kind");
|
|
3693
|
+
const chainId = r.uint(8);
|
|
3694
|
+
const count = r.number(1);
|
|
3695
|
+
if (kind !== StepKind.SWAP && count !== 0) throw new ZdHeavyCodecError("Unexpected allowances");
|
|
3696
|
+
const allowances = Array.from({ length: count }, () => ({
|
|
3697
|
+
pathwayId: r.number(1),
|
|
3698
|
+
maxShareBps: r.number(2),
|
|
3699
|
+
params: r.bytes16()
|
|
3700
|
+
}));
|
|
3701
|
+
const base = { chainId, allowances };
|
|
3702
|
+
let result;
|
|
3703
|
+
switch (kind) {
|
|
3704
|
+
case StepKind.LOCAL_PAYOUT:
|
|
3705
|
+
result = { ...base, kind: "LOCAL_PAYOUT", token: r.address(), receiver: r.address(), minAmountOut: r.uint(16) };
|
|
3706
|
+
break;
|
|
3707
|
+
case StepKind.REMOTE_PAYOUT:
|
|
3708
|
+
result = {
|
|
3709
|
+
...base,
|
|
3710
|
+
kind: "REMOTE_PAYOUT",
|
|
3711
|
+
token: r.address(),
|
|
3712
|
+
receiverChainId: r.uint(8),
|
|
3713
|
+
receiver: r.address(),
|
|
3714
|
+
bridgeAdapters: r.adapters(),
|
|
3715
|
+
maxFee: r.uint(16),
|
|
3716
|
+
minAmountOut: r.uint(16)
|
|
3717
|
+
};
|
|
3718
|
+
break;
|
|
3719
|
+
case StepKind.SEND:
|
|
3720
|
+
result = {
|
|
3721
|
+
...base,
|
|
3722
|
+
kind: "SEND",
|
|
3723
|
+
token: r.address(),
|
|
3724
|
+
dstChainId: r.uint(8),
|
|
3725
|
+
bridgeAdapters: r.adapters(),
|
|
3726
|
+
maxFee: r.uint(16),
|
|
3727
|
+
inUnit: r.uint(16),
|
|
3728
|
+
outUnit: r.uint(16)
|
|
3729
|
+
};
|
|
3730
|
+
break;
|
|
3731
|
+
case StepKind.SWAP:
|
|
3732
|
+
result = { ...base, kind: "SWAP", tokenIn: r.address(), tokenOut: r.address(), expectedIn: r.uint(16), minOut: r.uint(16) };
|
|
3733
|
+
break;
|
|
3734
|
+
case StepKind.EXECUTE:
|
|
3735
|
+
result = { ...base, kind: "EXECUTE", token: r.address(), receiver: r.address(), minAmountOut: r.uint(16), gasLimit: r.uint(8), data: r.bytes16() };
|
|
3736
|
+
break;
|
|
3737
|
+
case StepKind.NET: {
|
|
3738
|
+
const token = r.address(), pathwayId = r.number(1), arriveStep = r.number(1);
|
|
3739
|
+
const params = r.hex(78);
|
|
3740
|
+
const t = new Reader2(params);
|
|
3741
|
+
const terms = {
|
|
3742
|
+
nettingDeadline: t.uint(8),
|
|
3743
|
+
dstDomain: t.number(4),
|
|
3744
|
+
dstAsset: t.hex(32),
|
|
3745
|
+
inUnit: t.uint(16),
|
|
3746
|
+
outUnit: t.uint(16),
|
|
3747
|
+
complianceClass: t.number(2)
|
|
3748
|
+
};
|
|
3749
|
+
result = { chainId, allowances: [{ pathwayId, maxShareBps: 0, params }], kind: "NET", token, pathwayId, arriveStep, terms };
|
|
3750
|
+
break;
|
|
3751
|
+
}
|
|
3752
|
+
case StepKind.SUBSIDY:
|
|
3753
|
+
result = { ...base, kind: "SUBSIDY", token: r.address(), minIn: r.uint(16), amountOut: r.uint(16) };
|
|
3754
|
+
break;
|
|
3755
|
+
default:
|
|
3756
|
+
throw new ZdHeavyCodecError("Unknown step kind");
|
|
3757
|
+
}
|
|
3758
|
+
r.end();
|
|
3759
|
+
return result;
|
|
3760
|
+
}
|
|
3761
|
+
function routerWord(addr) {
|
|
3762
|
+
return concat([toHex(new Uint8Array(12)), checkedHex(addr, 20)]);
|
|
3763
|
+
}
|
|
3764
|
+
function ownerWord(addr) {
|
|
3765
|
+
return routerWord(addr);
|
|
3766
|
+
}
|
|
3767
|
+
function encodeOrderHeader(serial, router, ownerType, owner) {
|
|
3768
|
+
if (!Number.isInteger(ownerType) || ownerType < 0 || ownerType > 255) throw new ZdHeavyCodecError("Invalid ownerType");
|
|
3769
|
+
return concat(["0x050000", uint(serial, 8), routerWord(router), uint(BigInt(ownerType), 1), checkedHex(owner, 32)]);
|
|
3770
|
+
}
|
|
3771
|
+
function orderIdOf(expiryDate, header, steps) {
|
|
3772
|
+
if (steps.length < 1 || steps.length > MAX_STEPS2) throw new ZdHeavyCodecError("Step count must be 1..8");
|
|
3773
|
+
return keccak256(
|
|
3774
|
+
concat([toHex(toBytes("ZD/ORDER")), uint(expiryDate, 8), keccak256(checkedHex(header)), ...steps.map((step) => keccak256(checkedHex(step)))])
|
|
3775
|
+
);
|
|
3776
|
+
}
|
|
3777
|
+
var ZDHEAVY_SUBMIT_SELECTOR = "0x1a579a0c";
|
|
3778
|
+
var ZDHEAVY_PARTNER_SUBMIT_SELECTOR = "0xdd3d9749";
|
|
3779
|
+
var ZDHEAVY_QUOTE_SELECTOR = "0x3cfc3141";
|
|
3780
|
+
function decodeZdHeavySubmit(data) {
|
|
3781
|
+
const hex = checkedHex(data);
|
|
3782
|
+
const selector = hex.slice(0, 10);
|
|
3783
|
+
if (selector !== ZDHEAVY_SUBMIT_SELECTOR && selector !== ZDHEAVY_PARTNER_SUBMIT_SELECTOR) {
|
|
3784
|
+
throw new ZdHeavyCodecError("Expected submitOrder");
|
|
3785
|
+
}
|
|
3786
|
+
const body = hex.slice(10);
|
|
3787
|
+
const size = body.length / 2;
|
|
3788
|
+
const fail = () => {
|
|
3789
|
+
throw new ZdHeavyCodecError("Invalid submitOrder calldata");
|
|
3790
|
+
};
|
|
3791
|
+
const word2 = (at, bits = 256) => {
|
|
3792
|
+
if (!Number.isSafeInteger(at) || at < 0 || at + 32 > size) return fail();
|
|
3793
|
+
const n2 = BigInt(`0x${body.slice(at * 2, (at + 32) * 2)}`);
|
|
3794
|
+
if (n2 >= 1n << BigInt(bits)) return fail();
|
|
3795
|
+
return n2;
|
|
3796
|
+
};
|
|
3797
|
+
const fixed = (at) => {
|
|
3798
|
+
word2(at);
|
|
3799
|
+
return `0x${body.slice(at * 2, (at + 32) * 2)}`;
|
|
3800
|
+
};
|
|
3801
|
+
const offset = (at, expected) => {
|
|
3802
|
+
if (word2(at) !== BigInt(expected)) fail();
|
|
3803
|
+
};
|
|
3804
|
+
const bytes = (at) => {
|
|
3805
|
+
const n2 = word2(at);
|
|
3806
|
+
if (n2 > BigInt(size - at - 32)) return fail();
|
|
3807
|
+
const length = Number(n2);
|
|
3808
|
+
const end = at + 32 + Math.ceil(length / 32) * 32;
|
|
3809
|
+
if (end > size || /[^0]/.test(body.slice((at + 32 + length) * 2, end * 2))) return fail();
|
|
3810
|
+
return { value: `0x${body.slice((at + 32) * 2, (at + 32 + length) * 2)}`, end };
|
|
3811
|
+
};
|
|
3812
|
+
const base = selector === ZDHEAVY_SUBMIT_SELECTOR ? 32 : 64;
|
|
3813
|
+
offset(0, base);
|
|
3814
|
+
const partnerId = base === 64 ? fixed(32) : null;
|
|
3815
|
+
const serial = word2(base, 64);
|
|
3816
|
+
const ownerType = Number(word2(base + 32, 8));
|
|
3817
|
+
const owner = fixed(base + 64);
|
|
3818
|
+
const expiryDate = word2(base + 160, 64);
|
|
3819
|
+
offset(base + 96, 224);
|
|
3820
|
+
const ownerSignature = bytes(base + 224);
|
|
3821
|
+
offset(base + 128, ownerSignature.end - base);
|
|
3822
|
+
const array = ownerSignature.end;
|
|
3823
|
+
const count = word2(array);
|
|
3824
|
+
if (count > BigInt(Math.floor((size - array - 32) / 32))) return fail();
|
|
3825
|
+
const n = Number(count);
|
|
3826
|
+
const arrayBase = array + 32;
|
|
3827
|
+
let next = arrayBase + n * 32;
|
|
3828
|
+
const steps = [];
|
|
3829
|
+
for (let i = 0; i < n; i++) {
|
|
3830
|
+
offset(arrayBase + i * 32, next - arrayBase);
|
|
3831
|
+
const step = bytes(next);
|
|
3832
|
+
steps.push(step.value);
|
|
3833
|
+
next = step.end;
|
|
3834
|
+
}
|
|
3835
|
+
offset(base + 192, next - base);
|
|
3836
|
+
const q = next;
|
|
3837
|
+
const amountIn = word2(q, 128);
|
|
3838
|
+
const fee = { input: word2(q + 32, 128), native: word2(q + 64, 128) };
|
|
3839
|
+
const quoteId = fixed(q + 96);
|
|
3840
|
+
const requestId = fixed(q + 128);
|
|
3841
|
+
const expiresAt = word2(q + 160, 64);
|
|
3842
|
+
offset(q + 192, 224);
|
|
3843
|
+
const signature = bytes(q + 224);
|
|
3844
|
+
if (signature.end !== size) return fail();
|
|
3845
|
+
return {
|
|
3846
|
+
submission: {
|
|
3847
|
+
serial,
|
|
3848
|
+
ownerType,
|
|
3849
|
+
owner,
|
|
3850
|
+
ownerSignature: ownerSignature.value,
|
|
3851
|
+
steps,
|
|
3852
|
+
expiryDate,
|
|
3853
|
+
quote: { amountIn, fee, quoteId, requestId, expiresAt, signature: signature.value }
|
|
3854
|
+
},
|
|
3855
|
+
partnerId
|
|
3856
|
+
};
|
|
3857
|
+
}
|
|
3858
|
+
function quoteSubmitCalldata(data) {
|
|
3859
|
+
decodeZdHeavySubmit(data);
|
|
3860
|
+
const tuple = data.slice(data.slice(0, 10).toLowerCase() === ZDHEAVY_SUBMIT_SELECTOR ? 74 : 138);
|
|
3861
|
+
return `${ZDHEAVY_QUOTE_SELECTOR}${uintWord(32)}${tuple}`;
|
|
3862
|
+
}
|
|
3863
|
+
|
|
3864
|
+
// src/core/zdheavy-check.ts
|
|
3865
|
+
var isAddress2 = hasValidChecksum;
|
|
3866
|
+
var getAddress = (s) => toChecksumAddress(s);
|
|
3867
|
+
var refuse = (what) => ({
|
|
3868
|
+
ok: false,
|
|
3869
|
+
reason: `The ZD Heavy order the gateway built does not match the order shown (${what}) \u2014 refusing to sign.`
|
|
3870
|
+
});
|
|
3871
|
+
var lower = (v) => typeof v === "string" ? v.toLowerCase() : "";
|
|
3872
|
+
function big2(v) {
|
|
3873
|
+
if (v === void 0 || v === null || v === "") return null;
|
|
3399
3874
|
try {
|
|
3400
|
-
return
|
|
3875
|
+
return BigInt(v);
|
|
3401
3876
|
} catch {
|
|
3402
|
-
return
|
|
3877
|
+
return null;
|
|
3403
3878
|
}
|
|
3404
3879
|
}
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3880
|
+
var sameBig = (a, b) => big2(b) === a;
|
|
3881
|
+
var sameAddr = (a, b) => !!b && lower(a) === lower(b);
|
|
3882
|
+
function checkZdHeavyRouter(chainId, router) {
|
|
3883
|
+
if (!router || !isAddress2(router)) return { ok: false, reason: "No valid ZD Heavy router address for this chain \u2014 refusing to sign." };
|
|
3884
|
+
const address = getAddress(router);
|
|
3885
|
+
const pinned = (ZDHEAVY_ROUTER_ADDRESSES[chainId] ?? []).map((a) => getAddress(a));
|
|
3886
|
+
if (!pinned.includes(address)) {
|
|
3887
|
+
return { ok: false, reason: `Router ${address} is not a trusted ZD Heavy router on this chain \u2014 refusing to sign.` };
|
|
3888
|
+
}
|
|
3889
|
+
return { ok: true, address };
|
|
3890
|
+
}
|
|
3891
|
+
function checkZdHeavyValue(txValue, quotedSubmit) {
|
|
3892
|
+
if (quotedSubmit === void 0) return { ok: false, reason: "The router\u2019s submit fee could not be read \u2014 refusing to sign." };
|
|
3893
|
+
if (big2(txValue) !== quotedSubmit) return { ok: false, reason: "The transaction carries a native value the router did not quote \u2014 refusing to sign." };
|
|
3894
|
+
return { ok: true };
|
|
3895
|
+
}
|
|
3896
|
+
function sameAllowances(d, j) {
|
|
3897
|
+
if (d.kind !== "SWAP") return true;
|
|
3898
|
+
const want = j.allowances ?? [];
|
|
3899
|
+
if (want.length !== d.allowances.length) return false;
|
|
3900
|
+
return d.allowances.every((a, i) => {
|
|
3901
|
+
const w = want[i];
|
|
3902
|
+
return a.pathwayId === w.pathwayId && a.maxShareBps === w.maxShareBps && lower(a.params) === lower(w.params && w.params !== "" ? w.params : "0x");
|
|
3903
|
+
});
|
|
3904
|
+
}
|
|
3905
|
+
function sameAdapters(a, b) {
|
|
3906
|
+
const w = b ?? [];
|
|
3907
|
+
return a.length === w.length && a.every((x, i) => x === w[i]);
|
|
3908
|
+
}
|
|
3909
|
+
function sameStep(d, j) {
|
|
3910
|
+
if (d.kind !== String(j.kind).toUpperCase()) return false;
|
|
3911
|
+
if (!sameBig(d.chainId, j.chainId)) return false;
|
|
3912
|
+
if (!sameAllowances(d, j)) return false;
|
|
3913
|
+
switch (d.kind) {
|
|
3914
|
+
case "SWAP":
|
|
3915
|
+
return sameAddr(d.tokenIn, j.tokenIn) && sameAddr(d.tokenOut, j.tokenOut) && sameBig(d.expectedIn, j.expectedIn) && sameBig(d.minOut, j.minOut);
|
|
3916
|
+
case "LOCAL_PAYOUT":
|
|
3917
|
+
return sameAddr(d.token, j.token) && sameAddr(d.receiver, j.receiver) && sameBig(d.minAmountOut, j.minAmountOut);
|
|
3918
|
+
case "REMOTE_PAYOUT":
|
|
3919
|
+
return sameAddr(d.token, j.token) && sameBig(d.receiverChainId, j.receiverChainId) && sameAddr(d.receiver, j.receiver) && sameAdapters(d.bridgeAdapters, j.bridgeAdapters) && sameBig(d.maxFee, j.maxFee) && sameBig(d.minAmountOut, j.minAmountOut);
|
|
3920
|
+
case "SEND":
|
|
3921
|
+
return sameAddr(d.token, j.token) && sameBig(d.dstChainId, j.dstChainId) && sameAdapters(d.bridgeAdapters, j.bridgeAdapters) && sameBig(d.maxFee, j.maxFee) && sameBig(d.inUnit, j.inUnit) && sameBig(d.outUnit, j.outUnit);
|
|
3922
|
+
case "SUBSIDY":
|
|
3923
|
+
return sameAddr(d.token, j.token) && sameBig(d.minIn, j.minIn) && sameBig(d.amountOut, j.amountOut);
|
|
3924
|
+
case "NET": {
|
|
3925
|
+
const t = j.terms;
|
|
3926
|
+
if (!t) return false;
|
|
3927
|
+
const domainOfAsset = Number(BigInt(t.dstAsset) >> 224n);
|
|
3928
|
+
return sameAddr(d.token, j.token) && d.pathwayId === j.pathwayId && d.arriveStep === j.arriveStep && sameBig(d.terms.nettingDeadline, t.nettingDeadline) && d.terms.dstDomain === domainOfAsset && lower(d.terms.dstAsset) === lower(t.dstAsset) && sameBig(d.terms.inUnit, t.inUnit) && sameBig(d.terms.outUnit, t.outUnit);
|
|
3929
|
+
}
|
|
3930
|
+
default:
|
|
3931
|
+
return false;
|
|
3439
3932
|
}
|
|
3440
|
-
return legs;
|
|
3441
3933
|
}
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
const
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
if (
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3934
|
+
function checkSubmit(tx, e) {
|
|
3935
|
+
if (tx.chainId !== String(e.chainId)) return refuse("chain");
|
|
3936
|
+
if (!sameAddr(e.router, tx.to)) return refuse("router");
|
|
3937
|
+
let decoded;
|
|
3938
|
+
try {
|
|
3939
|
+
decoded = decodeZdHeavySubmit(tx.data);
|
|
3940
|
+
} catch {
|
|
3941
|
+
return refuse("not a router submitOrder");
|
|
3942
|
+
}
|
|
3943
|
+
const { submission: s, partnerId } = decoded;
|
|
3944
|
+
const order = e.order;
|
|
3945
|
+
if (!order) return refuse("no order");
|
|
3946
|
+
const wantPartner = typeof e.partnerId === "string" && /^0x[0-9a-fA-F]{64}$/.test(e.partnerId) ? lower(e.partnerId) : null;
|
|
3947
|
+
if ((partnerId ? lower(partnerId) : null) !== wantPartner) return refuse("partner id");
|
|
3948
|
+
if (!isAddress2(e.owner)) return refuse("owner");
|
|
3949
|
+
if (s.ownerType !== 1 || lower(s.owner) !== lower(ownerWord(e.owner))) return refuse("owner");
|
|
3950
|
+
if (s.ownerSignature !== "0x") return refuse("owner signature");
|
|
3951
|
+
if (!s.quote.signature || s.quote.signature === "0x") return refuse("no API signature");
|
|
3952
|
+
if (order.chainNumber !== e.chainId || !sameAddr(e.router, order.router)) return refuse("router");
|
|
3953
|
+
if (s.steps.length < 1 || s.steps.length > MAX_STEPS2 || s.steps.length !== order.steps.length) return refuse("number of steps");
|
|
3954
|
+
const steps = [];
|
|
3955
|
+
for (let i = 0; i < s.steps.length; i++) {
|
|
3956
|
+
let d;
|
|
3957
|
+
try {
|
|
3958
|
+
d = decodeStep(s.steps[i]);
|
|
3959
|
+
} catch {
|
|
3960
|
+
return refuse(`step ${i} encoding`);
|
|
3961
|
+
}
|
|
3962
|
+
if (d.kind === "EXECUTE") return refuse(`step ${i} kind EXECUTE`);
|
|
3963
|
+
if (!sameStep(d, order.steps[i])) return refuse(`step ${i}`);
|
|
3964
|
+
steps.push(d);
|
|
3965
|
+
}
|
|
3966
|
+
const first = steps[0];
|
|
3967
|
+
if (first.chainId !== BigInt(e.chainId)) return refuse("source chain");
|
|
3968
|
+
const firstToken = first.kind === "SWAP" ? first.tokenIn : "token" in first ? first.token : "";
|
|
3969
|
+
if (!sameAddr(e.fromToken, firstToken) || !sameAddr(e.fromToken, order.tokenIn)) return refuse("source token");
|
|
3970
|
+
const last = steps[steps.length - 1];
|
|
3971
|
+
if (steps.slice(0, -1).some((d) => d.kind === "LOCAL_PAYOUT" || d.kind === "REMOTE_PAYOUT")) return refuse("payout before the last step");
|
|
3972
|
+
if (last.kind !== "LOCAL_PAYOUT" && last.kind !== "REMOTE_PAYOUT") return refuse("no payout");
|
|
3973
|
+
const deliveryChain = last.kind === "LOCAL_PAYOUT" ? last.chainId : last.receiverChainId;
|
|
3974
|
+
if (deliveryChain !== BigInt(e.toChainId)) return refuse("destination chain");
|
|
3975
|
+
if (last.kind === "LOCAL_PAYOUT") {
|
|
3976
|
+
if (!sameAddr(e.toToken, last.token)) return refuse("destination token");
|
|
3977
|
+
} else {
|
|
3978
|
+
if (!e.remotePayoutToken?.(last.token, Number(last.chainId))) return refuse("destination token of a cross-chain payout");
|
|
3979
|
+
}
|
|
3980
|
+
if (!sameAddr(e.receiver, last.receiver)) return refuse("receiver");
|
|
3981
|
+
const amountIn = big2(order.amountIn);
|
|
3982
|
+
const feeInput = big2(order.fee.input);
|
|
3983
|
+
const feeNative = big2(order.fee.native);
|
|
3984
|
+
if (amountIn === null || feeInput === null || feeNative === null) return refuse("amount");
|
|
3985
|
+
if (s.quote.amountIn !== amountIn || s.quote.fee.input !== feeInput || s.quote.fee.native !== feeNative) return refuse("amount");
|
|
3986
|
+
if (amountIn + feeInput !== e.amountRaw || big2(order.grossIn) !== e.amountRaw) return refuse("amount");
|
|
3987
|
+
if (s.expiryDate !== BigInt(order.expiryDate) || s.quote.expiresAt !== BigInt(order.expiresAt)) return refuse("expiry");
|
|
3988
|
+
if (s.expiryDate <= BigInt(e.nowSec) || s.quote.expiresAt <= BigInt(e.nowSec)) return refuse("expired");
|
|
3989
|
+
if (last.kind === "REMOTE_PAYOUT" && last.maxFee >= last.minAmountOut) return refuse("minimum out");
|
|
3990
|
+
const floor = last.kind === "REMOTE_PAYOUT" ? last.minAmountOut - last.maxFee : last.minAmountOut;
|
|
3991
|
+
if (floor <= 0n || floor !== e.finalAmount) return refuse("minimum out");
|
|
3992
|
+
let orderId;
|
|
3993
|
+
try {
|
|
3994
|
+
orderId = orderIdOf(s.expiryDate, encodeOrderHeader(s.serial, getAddress(e.router), 1, s.owner), s.steps);
|
|
3995
|
+
} catch {
|
|
3996
|
+
return refuse("order id");
|
|
3997
|
+
}
|
|
3998
|
+
if (!e.rootHash || lower(orderId) !== lower(e.rootHash)) return refuse("order id");
|
|
3999
|
+
return { ok: true, floor, orderId };
|
|
4000
|
+
}
|
|
4001
|
+
function checkZdHeavySubmit(tx, e) {
|
|
4002
|
+
try {
|
|
4003
|
+
return checkSubmit(tx, e);
|
|
4004
|
+
} catch {
|
|
4005
|
+
return refuse("malformed order");
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
|
|
4009
|
+
// src/core/asset-identity.ts
|
|
4010
|
+
function key(chainId, address) {
|
|
4011
|
+
const id = Number(chainId);
|
|
4012
|
+
return Number.isSafeInteger(id) && id > 0 && typeof address === "string" && isChainAddress(id, address) ? tokenKey(id, address) : null;
|
|
4013
|
+
}
|
|
4014
|
+
function sameAssetDeployment(tokens, routes, a, b) {
|
|
4015
|
+
const ka = key(a.chainId, a.address);
|
|
4016
|
+
const kb = key(b.chainId, b.address);
|
|
4017
|
+
if (!ka || !kb) return false;
|
|
4018
|
+
const parent = /* @__PURE__ */ new Map();
|
|
4019
|
+
const find = (k) => {
|
|
4020
|
+
const p = parent.get(k);
|
|
4021
|
+
if (p === void 0) {
|
|
4022
|
+
parent.set(k, k);
|
|
4023
|
+
return k;
|
|
4024
|
+
}
|
|
4025
|
+
if (p === k) return k;
|
|
4026
|
+
const root = find(p);
|
|
4027
|
+
parent.set(k, root);
|
|
4028
|
+
return root;
|
|
4029
|
+
};
|
|
4030
|
+
const join = (x, y) => {
|
|
4031
|
+
if (x && y) parent.set(find(y), find(x));
|
|
4032
|
+
};
|
|
4033
|
+
for (const r of routes) {
|
|
4034
|
+
if (r.isEnabled === false) continue;
|
|
4035
|
+
const from = key(r.fromChainId, r.fromAddress);
|
|
4036
|
+
const to = key(r.toChainId, r.toAddress);
|
|
4037
|
+
join(from, to);
|
|
4038
|
+
const home = key(r.homeChainId, r.homeTokenAddress);
|
|
4039
|
+
join(from, home);
|
|
4040
|
+
join(to, home);
|
|
4041
|
+
}
|
|
4042
|
+
for (const t of tokens) join(key(t.chainId, t.address), key(t.homeChainId, t.homeTokenAddress));
|
|
4043
|
+
return parent.has(ka) && parent.has(kb) && find(ka) === find(kb);
|
|
4044
|
+
}
|
|
4045
|
+
|
|
4046
|
+
// src/core/validate-tx.ts
|
|
4047
|
+
var lower2 = (v) => String(v || "").toLowerCase();
|
|
4048
|
+
function isHexAddress(value) {
|
|
4049
|
+
return /^0x[a-fA-F0-9]{40}$/.test(String(value || ""));
|
|
4050
|
+
}
|
|
4051
|
+
function isHexData(value) {
|
|
4052
|
+
return /^0x(?:[a-fA-F0-9]{2})*$/.test(String(value || "0x"));
|
|
4053
|
+
}
|
|
4054
|
+
function isHexQuantity(value) {
|
|
4055
|
+
return /^0x[0-9a-fA-F]+$/.test(String(value || "0x0"));
|
|
4056
|
+
}
|
|
4057
|
+
function dataWord(data, index) {
|
|
4058
|
+
const word2 = String(data || "").slice(10 + index * 64, 10 + (index + 1) * 64);
|
|
4059
|
+
return /^[a-fA-F0-9]{64}$/.test(word2) ? word2 : "";
|
|
4060
|
+
}
|
|
4061
|
+
function dataAddress(data, index) {
|
|
4062
|
+
const word2 = dataWord(data, index);
|
|
4063
|
+
return word2 ? `0x${word2.slice(24)}` : "";
|
|
4064
|
+
}
|
|
4065
|
+
function dataUint(data, index) {
|
|
4066
|
+
const word2 = dataWord(data, index);
|
|
4067
|
+
return word2 ? BigInt(`0x${word2}`) : null;
|
|
4068
|
+
}
|
|
4069
|
+
function rawEquals(value, expected) {
|
|
4070
|
+
try {
|
|
4071
|
+
return value === BigInt(expected || "0");
|
|
4072
|
+
} catch {
|
|
4073
|
+
return false;
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
function planMsgValueHex(route) {
|
|
4077
|
+
try {
|
|
4078
|
+
const raw2 = route?.quote?.msgValue;
|
|
4079
|
+
if (raw2 === void 0 || raw2 === null || raw2 === "") return "0x0";
|
|
4080
|
+
return "0x" + BigInt(raw2).toString(16);
|
|
4081
|
+
} catch {
|
|
4082
|
+
return null;
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
4085
|
+
function validatePlannedTransaction(tx, route, expectedRecipient, heavyExpected) {
|
|
4086
|
+
if (!tx || tx.mock) return true;
|
|
4087
|
+
if (!isHexAddress(tx.to) || !isHexData(tx.data || "0x") || !isHexQuantity(tx.value || "0x0")) return false;
|
|
4088
|
+
const data = String(tx.data || "0x").toLowerCase();
|
|
4089
|
+
const selector = data.slice(0, 10);
|
|
4090
|
+
const value = lower2(tx.value || "0x0");
|
|
4091
|
+
if (tx.kind === "transfer") {
|
|
4092
|
+
if (value !== "0x0") return false;
|
|
4093
|
+
return selector === "0xa9059cbb" && isHexAddress(tx.token) && lower2(tx.to) === lower2(tx.token) && lower2(dataAddress(data, 0)) === lower2(expectedRecipient) && rawEquals(dataUint(data, 1), tx.amountRaw);
|
|
4094
|
+
}
|
|
4095
|
+
if (tx.kind === "approve") {
|
|
4096
|
+
if (route.zdHeavy) {
|
|
4097
|
+
return !!heavyExpected && tx.chainId === heavyExpected.chainId && lower2(tx.to) === lower2(heavyExpected.fromToken) && lower2(data) === lower2(encodeApprove(heavyExpected.router, heavyExpected.amountRaw)) && BigInt(value) === 0n;
|
|
4098
|
+
}
|
|
4099
|
+
if (value !== "0x0") return false;
|
|
4100
|
+
return selector === "0x095ea7b3" && isHexAddress(tx.token) && isHexAddress(tx.spender) && lower2(tx.to) === lower2(tx.token) && lower2(dataAddress(data, 0)) === lower2(tx.spender) && rawEquals(dataUint(data, 1), tx.amountRaw);
|
|
4101
|
+
}
|
|
4102
|
+
if (tx.kind === "submitOrder") {
|
|
4103
|
+
if (route.zdHeavy) {
|
|
4104
|
+
const expectedValue = planMsgValueHex(route);
|
|
4105
|
+
return expectedValue !== null && value === lower2(expectedValue) && !!heavyExpected && checkZdHeavySubmit({ ...tx, chainId: String(tx.chainId) }, heavyExpected).ok;
|
|
4106
|
+
}
|
|
4107
|
+
const expected = planMsgValueHex(route);
|
|
4108
|
+
if (expected === null || value !== lower2(expected)) return false;
|
|
4109
|
+
if (selector !== SUBMIT_ORDER_SELECTOR || !isHexAddress(tx.escrow) || lower2(tx.to) !== lower2(tx.escrow)) return false;
|
|
4110
|
+
const decoded = decodeSubmitOrderCalldata(data);
|
|
4111
|
+
if (!decoded) return false;
|
|
4112
|
+
const first = decoded.orders[0];
|
|
4113
|
+
const last = decoded.orders[decoded.orders.length - 1];
|
|
4114
|
+
return decoded.partnerId === lower2(route.quote?.partnerId || NO_PARTNER_ID) && lower2(first.bidToken) === lower2(route.source.tokenAddress) && rawEquals(first.bidTokenAmount, tx.amountRaw) && lower2(last.askToken) === lower2(isSolanaChainId(route.receive.chainId) ? solanaKeyHex(route.receive.tokenAddress || "") : route.receive.tokenAddress) && Number(last.destinationChainId) === Number(route.receive.chainId) && (isSolanaChainId(route.receive.chainId) ? solanaDeliveryMatches(last.destinationReceiver, expectedRecipient, route.receive.tokenAddress) : lower2(last.destinationReceiver) === lower2(expectedRecipient));
|
|
4115
|
+
}
|
|
4116
|
+
return false;
|
|
4117
|
+
}
|
|
4118
|
+
function solanaDeliveryMatches(encoded, recipient2, mint) {
|
|
4119
|
+
try {
|
|
4120
|
+
return lower2(encoded) === expectedSolanaDelivery(recipient2, mint || "");
|
|
4121
|
+
} catch {
|
|
4122
|
+
return false;
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
async function allowanceCovers(tx, account, ethCall2) {
|
|
4126
|
+
if (tx?.kind !== "approve" || !tx.token || !tx.spender || !tx.amountRaw || !account) return false;
|
|
4127
|
+
try {
|
|
4128
|
+
const raw2 = await ethCall2(tx.token, encodeAllowance(account, tx.spender));
|
|
4129
|
+
return BigInt(raw2 || "0x0") >= BigInt(tx.amountRaw || "0");
|
|
4130
|
+
} catch {
|
|
4131
|
+
return false;
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
4134
|
+
|
|
4135
|
+
// src/core/zdheavy-route.ts
|
|
4136
|
+
function zdHeavyExpected(route, owner, receiver, tokens, routes) {
|
|
4137
|
+
const heavy = route.zdHeavy;
|
|
4138
|
+
if (!heavy) throw new Error("Missing ZD Heavy order.");
|
|
4139
|
+
const pin2 = checkZdHeavyRouter(route.source.chainId, heavy.order.router);
|
|
4140
|
+
if (!pin2.ok) throw new Error(pin2.reason);
|
|
4141
|
+
if (route.source.amount !== formatUnits(heavy.amountRaw, route.source.decimals) || route.source.payAmount !== route.source.amount || route.receive.amount !== formatUnits(heavy.finalAmount, route.receive.decimals))
|
|
4142
|
+
throw new Error("ZD Heavy display amount mismatch.");
|
|
4143
|
+
return {
|
|
4144
|
+
chainId: route.source.chainId,
|
|
4145
|
+
router: pin2.address,
|
|
4146
|
+
owner,
|
|
4147
|
+
receiver,
|
|
4148
|
+
fromToken: route.source.tokenAddress,
|
|
4149
|
+
toToken: route.receive.tokenAddress,
|
|
4150
|
+
toChainId: route.receive.chainId,
|
|
4151
|
+
amountRaw: BigInt(heavy.amountRaw),
|
|
4152
|
+
finalAmount: BigInt(heavy.finalAmount),
|
|
4153
|
+
order: heavy.order,
|
|
4154
|
+
rootHash: heavy.rootHash,
|
|
4155
|
+
partnerId: route.quote.partnerId,
|
|
4156
|
+
nowSec: Math.floor(Date.now() / 1e3),
|
|
4157
|
+
remotePayoutToken: (token, chainId) => sameAssetDeployment(tokens, routes, { chainId, address: token }, { chainId: route.receive.chainId, address: route.receive.tokenAddress })
|
|
4158
|
+
};
|
|
4159
|
+
}
|
|
4160
|
+
function validateZdHeavyPlan(route, expected) {
|
|
4161
|
+
if (route.transactions.length !== 2 || route.transactions[0].kind !== "approve" || route.transactions[1].kind !== "submitOrder") {
|
|
4162
|
+
throw new Error("ZD Heavy requires exactly approve then submitOrder; refusing to sign.");
|
|
4163
|
+
}
|
|
4164
|
+
for (const tx of route.transactions) {
|
|
4165
|
+
if (tx.mock || tx.chainId !== expected.chainId || !validatePlannedTransaction(tx, route, expected.receiver, expected)) {
|
|
4166
|
+
throw new Error("ZD Heavy transaction does not match the reviewed plan; refusing to sign.");
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
const submit = route.transactions[1];
|
|
4170
|
+
const checked = checkZdHeavySubmit({ ...submit, chainId: String(submit.chainId) }, expected);
|
|
4171
|
+
if (!checked.ok) throw new Error(checked.reason);
|
|
4172
|
+
return checked.floor;
|
|
4173
|
+
}
|
|
4174
|
+
async function preflightZdHeavyPlan(route, expected, readFee) {
|
|
4175
|
+
validateZdHeavyPlan(route, expected);
|
|
4176
|
+
const tx = route.transactions[1];
|
|
4177
|
+
const value = checkZdHeavyValue(tx.value, await readFee(expected.chainId, expected.router, tx.data));
|
|
4178
|
+
if (!value.ok) throw new Error(value.reason);
|
|
4179
|
+
}
|
|
4180
|
+
|
|
4181
|
+
// src/core/zdheavy-build.ts
|
|
4182
|
+
function buildZdHeavyRoute(ctx) {
|
|
4183
|
+
const { option, destination, destinationToken, chains, result } = ctx;
|
|
4184
|
+
const q = result.quote;
|
|
4185
|
+
if (!zdHeavyExecutable(q)) throw new Error("ZD Heavy quote is not signed and executable.");
|
|
4186
|
+
const order = q.execution.order;
|
|
4187
|
+
const sourceAmount = formatUnits(result.youPayRaw, option.decimals);
|
|
4188
|
+
const decimals = assetDecimals(destinationToken);
|
|
4189
|
+
const receiveAmount = formatUnits(result.recipientReceivesRaw, decimals);
|
|
4190
|
+
const partnerId = typeof q.partnerId === "string" && /^0x[0-9a-fA-F]{64}$/.test(q.partnerId) ? q.partnerId : void 0;
|
|
4191
|
+
const route = {
|
|
4192
|
+
id: `zdh-${option.chainId}-${option.symbolKey}-${destination.chainId}-${destinationToken.symbol}`,
|
|
4193
|
+
recommended: false,
|
|
4194
|
+
state: result.meetsTarget ? "ROUTE" : "SHORT",
|
|
4195
|
+
source: {
|
|
4196
|
+
asset: option.symbol,
|
|
4197
|
+
ticker: option.ticker || option.symbol,
|
|
4198
|
+
chainId: option.chainId,
|
|
4199
|
+
chainName: option.chainName,
|
|
4200
|
+
tokenAddress: option.address,
|
|
4201
|
+
decimals: option.decimals,
|
|
4202
|
+
amount: sourceAmount,
|
|
4203
|
+
payAmount: sourceAmount
|
|
4204
|
+
},
|
|
4205
|
+
receive: {
|
|
4206
|
+
asset: destinationToken.symbol,
|
|
4207
|
+
ticker: tokenTicker(destinationToken),
|
|
4208
|
+
chainId: Number(destination.chainId),
|
|
4209
|
+
chainName: chainNameOf(Number(destination.chainId), chains),
|
|
4210
|
+
tokenAddress: destinationToken.address,
|
|
4211
|
+
decimals,
|
|
4212
|
+
amount: receiveAmount
|
|
4213
|
+
},
|
|
4214
|
+
routeLabel: "Settle on ZeroDelta via ZD Heavy.",
|
|
4215
|
+
deltaLabel: result.meetsTarget ? "~0" : "Below requested amount",
|
|
4216
|
+
legs: [
|
|
4217
|
+
{
|
|
4218
|
+
index: 1,
|
|
4219
|
+
fromAsset: option.symbol,
|
|
4220
|
+
fromTicker: option.ticker || option.symbol,
|
|
4221
|
+
fromChainId: option.chainId,
|
|
4222
|
+
fromChainName: option.chainName,
|
|
4223
|
+
fromAmount: sourceAmount,
|
|
4224
|
+
toAsset: destinationToken.symbol,
|
|
4225
|
+
toTicker: tokenTicker(destinationToken),
|
|
4226
|
+
toChainId: Number(destination.chainId),
|
|
4227
|
+
toChainName: chainNameOf(Number(destination.chainId), chains),
|
|
4228
|
+
toAmount: receiveAmount,
|
|
4229
|
+
executionChainId: option.chainId,
|
|
4230
|
+
executionChainName: option.chainName
|
|
4231
|
+
}
|
|
4232
|
+
],
|
|
4233
|
+
transactions: q.txData.map((tx, i) => {
|
|
4234
|
+
const submit = tx.actionType === "submit" || tx.actionType === "submitOrder";
|
|
4235
|
+
if (tx.actionType !== "approve" && !submit) throw new Error("Unexpected ZD Heavy transaction action.");
|
|
4236
|
+
if (typeof tx.value !== "string" || !/^(?:[0-9]+|0x[0-9a-fA-F]+)$/.test(tx.value)) throw new Error("Invalid ZD Heavy native value.");
|
|
4237
|
+
return {
|
|
4238
|
+
id: submit ? "submit-order" : `approve-${i}`,
|
|
4239
|
+
kind: submit ? "submitOrder" : "approve",
|
|
4240
|
+
label: submit ? "Submit ZeroDelta order" : `Approve ${option.ticker || option.symbol}`,
|
|
4241
|
+
chainId: Number(tx.chainId),
|
|
4242
|
+
to: tx.to,
|
|
4243
|
+
data: tx.data,
|
|
4244
|
+
// The gateway publishes decimal wei; EIP-1193 requires a hex quantity.
|
|
4245
|
+
// Calldata and targets remain the gateway's exact bytes.
|
|
4246
|
+
value: toHexQuantity(tx.value),
|
|
4247
|
+
token: option.address,
|
|
4248
|
+
spender: order.router,
|
|
4249
|
+
amountRaw: result.youPayRaw
|
|
4250
|
+
};
|
|
4251
|
+
}),
|
|
4252
|
+
quote: {
|
|
4253
|
+
bridge: q.bridge,
|
|
4254
|
+
feeBps: q.feeBps,
|
|
4255
|
+
estimatedDuration: q.estimatedDuration,
|
|
4256
|
+
gasCostSource: q.gasCostSource,
|
|
4257
|
+
iterations: result.iterations,
|
|
4258
|
+
compliance: q.compliance,
|
|
4259
|
+
partnerId,
|
|
4260
|
+
zeroDeltaFeeCentibips: q.zeroDeltaFeeCentibips,
|
|
4261
|
+
zeroDeltaFeeNative: q.zeroDeltaFeeNative
|
|
4262
|
+
},
|
|
4263
|
+
zdHeavy: { order, rootHash: q.rootHash, amountRaw: result.youPayRaw, finalAmount: result.recipientReceivesRaw, floor: "" }
|
|
4264
|
+
};
|
|
4265
|
+
if (route.transactions.length === 2) route.quote.msgValue = BigInt(route.transactions[1].value).toString();
|
|
4266
|
+
const expected = zdHeavyExpected(route, ctx.payer, destination.address, ctx.tokens, ctx.routes);
|
|
4267
|
+
route.zdHeavy.floor = validateZdHeavyPlan(route, expected).toString();
|
|
4268
|
+
return route;
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
// src/core/quote-compare.ts
|
|
4272
|
+
var WAIT_MIN_SEC = 180;
|
|
4273
|
+
var WAIT_MAX_SEC = 7200;
|
|
4274
|
+
var WAIT_STEP_SEC = 60;
|
|
4275
|
+
function clampWait(sec) {
|
|
4276
|
+
if (!Number.isFinite(sec)) return WAIT_MIN_SEC;
|
|
4277
|
+
return Math.min(WAIT_MAX_SEC, Math.max(WAIT_MIN_SEC, sec));
|
|
4278
|
+
}
|
|
4279
|
+
var WAIT_POINTS = [
|
|
4280
|
+
[WAIT_MIN_SEC, 0],
|
|
4281
|
+
[1800, 0.295],
|
|
4282
|
+
[2700, 0.4725],
|
|
4283
|
+
[WAIT_MAX_SEC, 1]
|
|
4284
|
+
];
|
|
4285
|
+
var FIGMA_TRAVEL_PX = 400;
|
|
4286
|
+
function waitScaleFor(travelPx) {
|
|
4287
|
+
if (!Number.isFinite(travelPx) || travelPx >= FIGMA_TRAVEL_PX || travelPx < 200) return WAIT_POINTS;
|
|
4288
|
+
return WAIT_POINTS.map(
|
|
4289
|
+
([sec, fraction], i) => i === 0 || i === WAIT_POINTS.length - 1 ? [sec, fraction] : [sec, fraction * FIGMA_TRAVEL_PX / travelPx]
|
|
4290
|
+
);
|
|
4291
|
+
}
|
|
4292
|
+
var WAIT_POSITIONS = 1e3;
|
|
4293
|
+
function waitFraction(sec, points = WAIT_POINTS) {
|
|
4294
|
+
const s = clampWait(sec);
|
|
4295
|
+
for (let i = 1; i < points.length; i++) {
|
|
4296
|
+
const [s1, f1] = points[i];
|
|
4297
|
+
if (s <= s1) {
|
|
4298
|
+
const [s0, f0] = points[i - 1];
|
|
4299
|
+
return f0 + (s - s0) / (s1 - s0) * (f1 - f0);
|
|
4300
|
+
}
|
|
4301
|
+
}
|
|
4302
|
+
return 1;
|
|
4303
|
+
}
|
|
4304
|
+
function waitFromFraction(fraction, points = WAIT_POINTS) {
|
|
4305
|
+
const f = Number.isFinite(fraction) ? Math.min(1, Math.max(0, fraction)) : 0;
|
|
4306
|
+
for (let i = 1; i < points.length; i++) {
|
|
4307
|
+
const [s1, f1] = points[i];
|
|
4308
|
+
if (f <= f1) {
|
|
4309
|
+
const [s0, f0] = points[i - 1];
|
|
4310
|
+
return s0 + (f - f0) / (f1 - f0) * (s1 - s0);
|
|
4311
|
+
}
|
|
4312
|
+
}
|
|
4313
|
+
return WAIT_MAX_SEC;
|
|
4314
|
+
}
|
|
4315
|
+
function snapWait(sec) {
|
|
4316
|
+
return clampWait(Math.round(sec / WAIT_STEP_SEC) * WAIT_STEP_SEC);
|
|
4317
|
+
}
|
|
4318
|
+
function waitLabel(sec) {
|
|
4319
|
+
const min = Math.round(clampWait(sec) / 60);
|
|
4320
|
+
if (min >= 60 && min % 60 === 0) return `Up to ${min / 60} ${min === 60 ? "hour" : "hours"}`;
|
|
4321
|
+
return `Up to ${min} min`;
|
|
4322
|
+
}
|
|
4323
|
+
var hasTime = (o) => Number.isFinite(o.estimatedDuration) && o.estimatedDuration > 0;
|
|
4324
|
+
function selectableOptions(options) {
|
|
4325
|
+
return options.filter((o) => !o.unavailable);
|
|
4326
|
+
}
|
|
4327
|
+
function bestOutputOption(options) {
|
|
4328
|
+
return selectableOptions(options).reduce((best, o) => !best || o.amount > best.amount ? o : best, void 0);
|
|
4329
|
+
}
|
|
4330
|
+
function fastestOption(options) {
|
|
4331
|
+
const selectable = selectableOptions(options);
|
|
4332
|
+
const labelled = selectable.find((o) => o.label?.toLowerCase() === "fastest");
|
|
4333
|
+
if (labelled) return labelled;
|
|
4334
|
+
return selectable.filter(hasTime).reduce((f, o) => !f || o.estimatedDuration < f.estimatedDuration ? o : f, void 0);
|
|
4335
|
+
}
|
|
4336
|
+
function proposedWait(options) {
|
|
4337
|
+
const best = bestOutputOption(options);
|
|
4338
|
+
return clampWait(best && hasTime(best) ? best.estimatedDuration : WAIT_MIN_SEC);
|
|
4339
|
+
}
|
|
4340
|
+
function pickForWait(options, waitSec) {
|
|
4341
|
+
const within = selectableOptions(options).filter((o) => hasTime(o) && o.estimatedDuration <= waitSec);
|
|
4342
|
+
return bestOutputOption(within) ?? fastestOption(options);
|
|
4343
|
+
}
|
|
4344
|
+
var MAX_QUOTE_CARDS = 3;
|
|
4345
|
+
function visibleOptions(options, waitSec, selectedId) {
|
|
4346
|
+
if (options.length <= MAX_QUOTE_CARDS) return nettingFirst(options);
|
|
4347
|
+
const selectable = selectableOptions(options);
|
|
4348
|
+
if (selectable.length === 0) return nettingFirst(options.slice(0, MAX_QUOTE_CARDS));
|
|
4349
|
+
const chosen = selectable.find((o) => o.id === selectedId) ?? pickForWait(options, waitSec);
|
|
4350
|
+
const gasless = bestOutputOption(selectable.filter((o) => o.gasSponsored));
|
|
4351
|
+
const netting = bestOutputOption(selectable.filter((o) => o.entersNetting));
|
|
4352
|
+
const ids = new Set([chosen?.id, fastestOption(options)?.id, gasless?.id, netting?.id].filter((id) => !!id));
|
|
4353
|
+
const keep = new Set([...ids].slice(0, MAX_QUOTE_CARDS));
|
|
4354
|
+
return nettingFirst(options.filter((o) => keep.has(o.id)));
|
|
4355
|
+
}
|
|
4356
|
+
function nettingFirst(options) {
|
|
4357
|
+
return [...options.filter((o) => o.entersNetting), ...options.filter((o) => !o.entersNetting)];
|
|
4358
|
+
}
|
|
4359
|
+
function compareDuration(seconds) {
|
|
4360
|
+
if (!Number.isFinite(seconds) || seconds <= 0) return "--";
|
|
4361
|
+
if (seconds < 60) return `~${Math.round(seconds)} s`;
|
|
4362
|
+
return `~${Math.round(seconds / 60)} min`;
|
|
4363
|
+
}
|
|
4364
|
+
function parity(options, inputUsd, toUnitUsd) {
|
|
4365
|
+
const priced = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
4366
|
+
if (!priced(inputUsd) || !priced(toUnitUsd)) return { kind: "unknown" };
|
|
4367
|
+
const reaching = selectableOptions(options).filter((o) => hasTime(o) && o.amount * toUnitUsd >= inputUsd);
|
|
4368
|
+
const earliest = reaching.reduce(
|
|
4369
|
+
(e, o) => !e || o.estimatedDuration < e.estimatedDuration || o.estimatedDuration === e.estimatedDuration && o.amount > e.amount ? o : e,
|
|
4370
|
+
void 0
|
|
4371
|
+
);
|
|
4372
|
+
return earliest ? { kind: "at", option: earliest, timeSec: earliest.estimatedDuration } : { kind: "unavailable" };
|
|
4373
|
+
}
|
|
4374
|
+
function extraVsFastest(options, selectedId) {
|
|
4375
|
+
const selected = selectableOptions(options).find((o) => o.id === selectedId);
|
|
4376
|
+
const fastest = fastestOption(options);
|
|
4377
|
+
if (!selected || !fastest) return null;
|
|
4378
|
+
const extra = selected.amount - fastest.amount;
|
|
4379
|
+
return extra > 1e-9 ? extra : null;
|
|
4380
|
+
}
|
|
4381
|
+
function routeBadges(options) {
|
|
4382
|
+
const field = options.filter((o) => !o.unavailable);
|
|
4383
|
+
const out = /* @__PURE__ */ new Map();
|
|
4384
|
+
if (field.length < 2) return out;
|
|
4385
|
+
const best = (pick, better) => field.reduce((acc, o) => {
|
|
4386
|
+
const value = pick(o);
|
|
4387
|
+
if (value === null) return acc;
|
|
4388
|
+
const accValue = acc ? pick(acc) : null;
|
|
4389
|
+
return accValue === null || better(value, accValue) ? o : acc;
|
|
4390
|
+
}, null);
|
|
4391
|
+
const bestReturn = best(
|
|
4392
|
+
(o) => o.amount,
|
|
4393
|
+
(a, b) => a > b
|
|
4394
|
+
);
|
|
4395
|
+
const fastest = best(
|
|
4396
|
+
(o) => o.estimatedDuration,
|
|
4397
|
+
(a, b) => a < b
|
|
4398
|
+
);
|
|
4399
|
+
const lowestFee = best(
|
|
4400
|
+
(o) => o.feeUsd,
|
|
4401
|
+
(a, b) => a < b
|
|
4402
|
+
);
|
|
4403
|
+
if (bestReturn) out.set(bestReturn.id, "Best return");
|
|
4404
|
+
if (fastest && !out.has(fastest.id)) out.set(fastest.id, "Fastest");
|
|
4405
|
+
if (lowestFee && !out.has(lowestFee.id)) out.set(lowestFee.id, "Lowest fee");
|
|
4406
|
+
return out;
|
|
4407
|
+
}
|
|
4408
|
+
function routeShapeLabel(option) {
|
|
4409
|
+
if (!option) return null;
|
|
4410
|
+
if (option.kind === "transfer") return "Transfer";
|
|
4411
|
+
const middle = option.hops.slice(1, -1);
|
|
4412
|
+
if (middle.length === 0) return "Direct";
|
|
4413
|
+
return `Via ${middle.map((h2) => h2.ticker).join(" \xB7 ")}`;
|
|
4414
|
+
}
|
|
4415
|
+
function cornerTags(options, option, parityState) {
|
|
4416
|
+
if (option.unavailable) return [];
|
|
4417
|
+
if (option.kind === "transfer") return [{ text: "Transfer", tone: "brand" }];
|
|
4418
|
+
if (option.entersNetting) return [{ text: "Best return", tone: "green" }];
|
|
4419
|
+
const tags = [];
|
|
4420
|
+
const labelledFastest = selectableOptions(options).some((o) => o.label?.toLowerCase() === "fastest");
|
|
4421
|
+
if (parityState.kind === "at" && parityState.option.id === option.id) tags.push({ text: "Target 1:1", tone: "brand" });
|
|
4422
|
+
else if (option.label?.toLowerCase() === "fastest") tags.push({ text: "Fastest", tone: "brand" });
|
|
4423
|
+
else if (option.gasSponsored) tags.push({ text: "Gasless", tone: "purple" });
|
|
4424
|
+
else {
|
|
4425
|
+
const badge = routeBadges(options).get(option.id);
|
|
4426
|
+
const text = badge === "Fastest" && labelledFastest ? void 0 : badge ?? routeShapeLabel(option) ?? void 0;
|
|
4427
|
+
if (text) tags.push({ text, tone: "brand" });
|
|
4428
|
+
}
|
|
4429
|
+
return tags;
|
|
4430
|
+
}
|
|
4431
|
+
function humanAmount(n, maxFrac = 6) {
|
|
4432
|
+
if (!Number.isFinite(n)) return String(n);
|
|
4433
|
+
if (n === 0) return "0";
|
|
4434
|
+
const digits = Math.min(Math.max(0, Math.trunc(maxFrac)), 8);
|
|
4435
|
+
const fixed = n.toFixed(digits);
|
|
4436
|
+
const out = fixed.includes(".") ? fixed.replace(/\.?0+$/, "") : fixed;
|
|
4437
|
+
if (Number(out) === 0) return `<${digits > 0 ? `0.${"0".repeat(digits - 1)}1` : "1"}`;
|
|
4438
|
+
const match = out.match(/^([+-]?)(\d+)(\.\d+)?$/);
|
|
4439
|
+
return match ? `${match[1]}${match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${match[3] ?? ""}` : out;
|
|
4440
|
+
}
|
|
4441
|
+
function compareAmount(value) {
|
|
4442
|
+
const text = humanAmount(value, 6);
|
|
4443
|
+
if (text.startsWith("<")) return text;
|
|
4444
|
+
const [whole, fraction = ""] = text.split(".");
|
|
4445
|
+
return fraction.length >= 2 ? text : `${whole}.${fraction.padEnd(2, "0")}`;
|
|
4446
|
+
}
|
|
4447
|
+
function compareFeeUsd(option, fromUsd) {
|
|
4448
|
+
const centibips = option.feeCentibips;
|
|
4449
|
+
if (centibips === void 0 || option.feeNative) return null;
|
|
4450
|
+
if (centibips === 0) return 0;
|
|
4451
|
+
return typeof fromUsd === "number" && Number.isFinite(fromUsd) && fromUsd > 0 ? fromUsd * centibips / 1e6 : null;
|
|
4452
|
+
}
|
|
4453
|
+
function priceCompareOptions(options, fromUsd) {
|
|
4454
|
+
return options.map((o) => ({ ...o, feeUsd: compareFeeUsd(o, fromUsd) }));
|
|
4455
|
+
}
|
|
4456
|
+
var ZD_HEAVY_KEY_PREFIX = "zdheavy:";
|
|
4457
|
+
function zdHeavyOptionKey(q) {
|
|
4458
|
+
return q.label ? `${ZD_HEAVY_KEY_PREFIX}${q.label}:${String(q.escrowAddress ?? "").toLowerCase()}` : `${ZD_HEAVY_KEY_PREFIX}id:${q.optionId ?? ""}`;
|
|
4459
|
+
}
|
|
4460
|
+
function zdHeavyUnavailableStatus(q) {
|
|
4461
|
+
return zdHeavyExecutable(q) ? void 0 : typeof q.payloadStatus === "string" && q.payloadStatus ? q.payloadStatus : "unknown";
|
|
4462
|
+
}
|
|
4463
|
+
function tokenAt2(tokens, chainId, address) {
|
|
4464
|
+
const key2 = isSolanaChainId(chainId) ? hexToSolanaKey(address) || address : address;
|
|
4465
|
+
const wanted = isChainAddress(chainId, key2) ? chainAddressKey(chainId, key2) : null;
|
|
4466
|
+
if (!wanted || !tokens?.length) return void 0;
|
|
4467
|
+
return tokens.find((t) => Number(t.chainId) === Number(chainId) && chainAddressKey(chainId, t.address) === wanted);
|
|
4468
|
+
}
|
|
4469
|
+
function hopFor(tokens, address, chainId, fallback) {
|
|
4470
|
+
const token = tokenAt2(tokens, chainId, address);
|
|
4471
|
+
return { address, chainId, ticker: token ? tokenTicker(token) : fallback ?? "Unknown" };
|
|
4472
|
+
}
|
|
4473
|
+
function compareHops(quote, ctx) {
|
|
4474
|
+
if (quote.protocol === "zdheavy") {
|
|
4475
|
+
const order = quote.execution?.order;
|
|
4476
|
+
if (!order || !Array.isArray(order.steps) || !order.steps.length) return [];
|
|
4477
|
+
const first = order.steps[0];
|
|
4478
|
+
const hops2 = [hopFor(ctx.tokens, String(first.tokenIn ?? first.token ?? order.tokenIn ?? ""), Number(order.chainNumber), ctx.from.ticker)];
|
|
4479
|
+
const push = (address, chainId, fallback) => {
|
|
4480
|
+
if (!address || chainId === void 0) return;
|
|
4481
|
+
const previous = hops2[hops2.length - 1];
|
|
4482
|
+
if (previous.address.toLowerCase() === address.toLowerCase() && previous.chainId === Number(chainId)) return;
|
|
4483
|
+
hops2.push(hopFor(ctx.tokens, address, Number(chainId), fallback));
|
|
4484
|
+
};
|
|
4485
|
+
order.steps.forEach((s, i) => {
|
|
4486
|
+
const n = order.steps[i + 1];
|
|
4487
|
+
const p = hops2[hops2.length - 1];
|
|
4488
|
+
if (s.kind === "SWAP") push(s.tokenOut, s.chainId);
|
|
4489
|
+
else if (s.kind === "SEND") push(n?.tokenIn ?? n?.token, s.dstChainId, p.ticker);
|
|
4490
|
+
else if (s.kind === "LOCAL_PAYOUT") push(s.token, s.chainId, ctx.to.ticker);
|
|
4491
|
+
else if (s.kind === "REMOTE_PAYOUT") push(ctx.to.address, s.receiverChainId, ctx.to.ticker);
|
|
4492
|
+
});
|
|
4493
|
+
return hops2;
|
|
4494
|
+
}
|
|
4495
|
+
const requests = Array.isArray(quote.orderRequests) ? quote.orderRequests : [];
|
|
4496
|
+
if (!requests.length) return [];
|
|
4497
|
+
const hops = [hopFor(ctx.tokens, String(requests[0].bidToken ?? ""), Number(quote.fromChainId), ctx.from.ticker)];
|
|
4498
|
+
requests.forEach((request, i) => {
|
|
4499
|
+
const last = i === requests.length - 1;
|
|
4500
|
+
hops.push(hopFor(ctx.tokens, String(request.askToken ?? ""), Number(request.destinationChainId || quote.toChainId), last ? ctx.to.ticker : void 0));
|
|
4501
|
+
});
|
|
4502
|
+
return hops;
|
|
4503
|
+
}
|
|
4504
|
+
var shortAddress2 = (address) => address.slice(0, 10).toLowerCase();
|
|
4505
|
+
function compareOptionOf(quote, ctx) {
|
|
4506
|
+
const heavy = quote.protocol === "zdheavy";
|
|
4507
|
+
if (!heavy && !liteExecutable(quote)) return null;
|
|
4508
|
+
const hops = compareHops(quote, ctx);
|
|
4509
|
+
if (hops.length < 2 && !heavy) return null;
|
|
4510
|
+
let amountRaw;
|
|
4511
|
+
let amount;
|
|
4512
|
+
try {
|
|
4513
|
+
amountRaw = BigInt(quote.finalAmount || quote.toAmount || "");
|
|
4514
|
+
amount = Number(formatUnits(amountRaw, ctx.to.decimals, ctx.to.decimals));
|
|
4515
|
+
} catch {
|
|
4516
|
+
return null;
|
|
4517
|
+
}
|
|
4518
|
+
const centibips = quote.zeroDeltaFeeCentibips;
|
|
4519
|
+
const native = quote.zeroDeltaFeeNative;
|
|
4520
|
+
const feeNative = typeof native === "string" && /^\d+$/.test(native) && BigInt(native) > 0n;
|
|
4521
|
+
const feeCentibips = typeof centibips === "number" && Number.isSafeInteger(centibips) && centibips >= 0 ? centibips : void 0;
|
|
4522
|
+
const unavailable = heavy ? zdHeavyUnavailableStatus(quote) : void 0;
|
|
4523
|
+
const option = {
|
|
4524
|
+
// The path, not the amount: the amount moves on every re-quote, and a key that changes would drop a pick.
|
|
4525
|
+
id: heavy ? zdHeavyOptionKey(quote) : hops.map((h2) => `${h2.chainId}:${shortAddress2(h2.address)}`).join(">"),
|
|
4526
|
+
...typeof quote.label === "string" && quote.label ? { label: quote.label } : {},
|
|
4527
|
+
...unavailable ? { unavailable } : {},
|
|
4528
|
+
amount,
|
|
4529
|
+
amountRaw: amountRaw.toString(),
|
|
4530
|
+
estimatedDuration: Number(quote.estimatedDuration) || 0,
|
|
4531
|
+
feeUsd: null,
|
|
4532
|
+
...feeCentibips !== void 0 ? { feeCentibips } : {},
|
|
4533
|
+
...feeNative ? { feeNative: true } : {},
|
|
4534
|
+
hops,
|
|
4535
|
+
...quote.entersNetting === true ? { entersNetting: true } : {},
|
|
4536
|
+
...quote.gasSponsored === true ? { gasSponsored: true } : {}
|
|
4537
|
+
};
|
|
4538
|
+
option.feeUsd = compareFeeUsd(option);
|
|
4539
|
+
return option;
|
|
4540
|
+
}
|
|
4541
|
+
function compareOptionsOf(quote, ctx) {
|
|
4542
|
+
const all = quote.gatewayOptions?.length ? quote.gatewayOptions : [quote];
|
|
4543
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4544
|
+
const byIndex = all.map((q) => {
|
|
4545
|
+
const row = compareOptionOf(q, ctx);
|
|
4546
|
+
if (!row || seen.has(row.id)) return null;
|
|
4547
|
+
seen.add(row.id);
|
|
4548
|
+
return row;
|
|
4549
|
+
});
|
|
4550
|
+
return { options: byIndex.filter((o) => !!o), byIndex };
|
|
4551
|
+
}
|
|
4552
|
+
|
|
4553
|
+
// src/core/route.ts
|
|
4554
|
+
function routeDeltaLabel(result, quote) {
|
|
4555
|
+
if (result.directTransfer) return "~0";
|
|
4556
|
+
if (!result.meetsTarget) return "Below requested amount";
|
|
4557
|
+
if (result.overageBps > 0) return `+${(result.overageBps / 100).toFixed(2)}% buffer`;
|
|
4558
|
+
if (quote.feeBps) return `${quote.feeBps} bps fee`;
|
|
4559
|
+
return "~0";
|
|
4560
|
+
}
|
|
4561
|
+
function quotePartnerId(quote) {
|
|
4562
|
+
const raw2 = quote.partnerId;
|
|
4563
|
+
return typeof raw2 === "string" && /^0x[0-9a-fA-F]{64}$/.test(raw2) ? raw2.toLowerCase() : NO_PARTNER_ID;
|
|
4564
|
+
}
|
|
4565
|
+
function optionTicker(option) {
|
|
4566
|
+
return option.ticker || option.symbol;
|
|
4567
|
+
}
|
|
4568
|
+
function routeLabelFor(option, destinationToken, result) {
|
|
4569
|
+
if (result.directTransfer) return "Direct transfer: asset and chain already match.";
|
|
4570
|
+
const bridge = result.quote.bridge ? ` via ${result.quote.bridge}` : "";
|
|
4571
|
+
return `Swap ${optionTicker(option)} to ${tokenTicker(destinationToken)} and settle on ZeroDelta${bridge}.`;
|
|
4572
|
+
}
|
|
4573
|
+
function tokenAt3(tokens, chainId, address) {
|
|
4574
|
+
const key2 = isSolanaChainId(chainId) ? hexToSolanaKey(address) || address : address;
|
|
4575
|
+
const wanted = isChainAddress(chainId, key2) ? chainAddressKey(chainId, key2) : null;
|
|
4576
|
+
if (!wanted || !tokens?.length) return void 0;
|
|
4577
|
+
return tokens.find((t) => Number(t.chainId) === Number(chainId) && chainAddressKey(chainId, t.address) === wanted);
|
|
4578
|
+
}
|
|
4579
|
+
function legAmount(raw2, decimals) {
|
|
4580
|
+
if (decimals === void 0) return "";
|
|
4581
|
+
try {
|
|
4582
|
+
return formatUnits(raw2 || "0", decimals);
|
|
4583
|
+
} catch {
|
|
4584
|
+
return "";
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4587
|
+
function buildLegs(orders, ctx) {
|
|
4588
|
+
const legs = [];
|
|
4589
|
+
let fromChainId = ctx.option.chainId;
|
|
4590
|
+
let fromAsset = ctx.option.symbol;
|
|
4591
|
+
let fromTicker = optionTicker(ctx.option);
|
|
4592
|
+
let fromDecimals = ctx.option.decimals;
|
|
4593
|
+
for (let index = 0; index < orders.length; index += 1) {
|
|
4594
|
+
const order = orders[index];
|
|
4595
|
+
const isLast = index === orders.length - 1;
|
|
4596
|
+
const toChainId = Number(order.destinationChainId);
|
|
4597
|
+
const askToken = isLast ? ctx.destinationToken : tokenAt3(ctx.tokens, toChainId, order.askToken);
|
|
4598
|
+
const toAsset = isLast ? ctx.destinationToken.symbol : askToken?.symbol ?? "";
|
|
4599
|
+
const toTicker = askToken ? tokenTicker(askToken) : "";
|
|
4600
|
+
const toDecimals = askToken ? assetDecimals(askToken) : void 0;
|
|
4601
|
+
const executionChainId = Number(order.executionChainId);
|
|
4602
|
+
legs.push({
|
|
4603
|
+
index: index + 1,
|
|
4604
|
+
fromAsset,
|
|
4605
|
+
fromTicker,
|
|
4606
|
+
fromChainId,
|
|
4607
|
+
fromChainName: chainNameOf(fromChainId, ctx.chains),
|
|
4608
|
+
fromAmount: legAmount(order.bidTokenAmount, fromDecimals),
|
|
4609
|
+
toAsset,
|
|
4610
|
+
toTicker,
|
|
4611
|
+
toChainId,
|
|
4612
|
+
toChainName: chainNameOf(toChainId, ctx.chains),
|
|
4613
|
+
toAmount: legAmount(order.askTokenAmount, isLast ? askTokenDecimals(ctx.quote, ctx.tokens || [], ctx.option, ctx.destinationToken) : toDecimals),
|
|
4614
|
+
executionChainId,
|
|
4615
|
+
executionChainName: chainNameOf(executionChainId, ctx.chains)
|
|
4616
|
+
});
|
|
4617
|
+
fromChainId = toChainId;
|
|
4618
|
+
fromAsset = toAsset;
|
|
4619
|
+
fromTicker = toTicker;
|
|
4620
|
+
fromDecimals = toDecimals;
|
|
4621
|
+
}
|
|
4622
|
+
return legs;
|
|
4623
|
+
}
|
|
4624
|
+
async function buildRoute(args) {
|
|
4625
|
+
const { option, destination, destinationToken, payer, fetchQuote, amountInRaw } = args;
|
|
4626
|
+
const solve = args.solve ?? solveExactOut;
|
|
4627
|
+
const result = await solve({ option, destination, destinationToken, payer, fetchQuote, amountInRaw });
|
|
4628
|
+
const route = routeFromResult(args, result);
|
|
4629
|
+
return result.directTransfer ? route : withQuoteOptions(route, args, result, solve === solveExactIn ? "exact-in" : "exact-out");
|
|
4630
|
+
}
|
|
4631
|
+
function withQuoteOptions(route, args, result, mode) {
|
|
4632
|
+
const { option, destination, destinationToken } = args;
|
|
4633
|
+
const quote = result.quote;
|
|
4634
|
+
const { byIndex } = compareOptionsOf(quote, {
|
|
4635
|
+
tokens: args.tokens,
|
|
4636
|
+
from: { chainId: option.chainId, address: option.address, ticker: optionTicker(option) },
|
|
4637
|
+
to: { chainId: Number(destination.chainId), address: destinationToken.address, ticker: tokenTicker(destinationToken), decimals: assetDecimals(destinationToken) }
|
|
4638
|
+
});
|
|
4639
|
+
const selectedIndex = quote.gatewayOptions?.length ? quote.gatewayOptionIndex ?? -1 : 0;
|
|
4640
|
+
const built = [];
|
|
4641
|
+
const refused = /* @__PURE__ */ new Set();
|
|
4642
|
+
(quote.gatewayOptions ?? []).forEach((candidate, index) => {
|
|
4643
|
+
const row = byIndex[index];
|
|
4644
|
+
if (!row || row.unavailable || index === selectedIndex) return;
|
|
4645
|
+
try {
|
|
4646
|
+
built.push({ index, route: routeFromResult(args, resultForOption(result, candidate, mode, destination.chainId)) });
|
|
4647
|
+
} catch {
|
|
4648
|
+
refused.add(index);
|
|
4649
|
+
}
|
|
4650
|
+
});
|
|
4651
|
+
const options = [];
|
|
4652
|
+
byIndex.forEach((row, index) => {
|
|
4653
|
+
if (row) options.push(refused.has(index) ? { ...row, unavailable: "refused-by-widget" } : row);
|
|
4654
|
+
});
|
|
4655
|
+
const selectedOptionId = byIndex[selectedIndex]?.id;
|
|
4656
|
+
const alternatives = built.map(({ index, route: alt }) => ({ ...alt, id: route.id, options, selectedOptionId: byIndex[index].id }));
|
|
4657
|
+
return { ...route, options, ...selectedOptionId ? { selectedOptionId } : {}, ...alternatives.length ? { alternatives } : {} };
|
|
4658
|
+
}
|
|
4659
|
+
function routeFromResult({ option, destination, destinationToken, chains, tokens, routes, payer, compliance }, result) {
|
|
4660
|
+
const quote = result.quote;
|
|
4661
|
+
const destDecimals = assetDecimals(destinationToken);
|
|
4662
|
+
const receiveAmount = formatUnits(result.recipientReceivesRaw, destDecimals);
|
|
4663
|
+
const sourceAmount = formatUnits(result.youPayRaw, option.decimals);
|
|
4664
|
+
if (result.directTransfer) {
|
|
4665
|
+
return {
|
|
4666
|
+
id: `direct-${option.symbolKey}-${option.chainId}`,
|
|
4667
|
+
recommended: false,
|
|
4668
|
+
state: "DIRECT",
|
|
4669
|
+
source: {
|
|
4670
|
+
asset: option.symbol,
|
|
4671
|
+
ticker: optionTicker(option),
|
|
4672
|
+
chainId: option.chainId,
|
|
4673
|
+
chainName: option.chainName,
|
|
4674
|
+
tokenAddress: option.address,
|
|
4675
|
+
decimals: option.decimals,
|
|
4676
|
+
amount: sourceAmount,
|
|
4677
|
+
payAmount: sourceAmount
|
|
4678
|
+
},
|
|
4679
|
+
receive: {
|
|
4680
|
+
asset: destinationToken.symbol,
|
|
4681
|
+
ticker: tokenTicker(destinationToken),
|
|
4682
|
+
chainId: Number(destination.chainId),
|
|
4683
|
+
chainName: chainNameOf(Number(destination.chainId), chains),
|
|
4684
|
+
tokenAddress: destinationToken.address,
|
|
4685
|
+
decimals: destDecimals,
|
|
4686
|
+
amount: receiveAmount
|
|
4687
|
+
},
|
|
4688
|
+
routeLabel: routeLabelFor(option, destinationToken, result),
|
|
4689
|
+
deltaLabel: routeDeltaLabel(result, quote),
|
|
4690
|
+
// A direct transfer submits no order at all, but it is still ONE hop and history renders the
|
|
4691
|
+
// same shape for it — an empty `legs` would leave "one order or two?" unanswerable for it alone.
|
|
4692
|
+
legs: [
|
|
4693
|
+
{
|
|
4694
|
+
index: 1,
|
|
4695
|
+
fromAsset: option.symbol,
|
|
4696
|
+
fromTicker: optionTicker(option),
|
|
4697
|
+
fromChainId: option.chainId,
|
|
4698
|
+
fromChainName: option.chainName,
|
|
4699
|
+
fromAmount: sourceAmount,
|
|
4700
|
+
toAsset: destinationToken.symbol,
|
|
4701
|
+
toTicker: tokenTicker(destinationToken),
|
|
4702
|
+
toChainId: Number(destination.chainId),
|
|
4703
|
+
toChainName: chainNameOf(Number(destination.chainId), chains),
|
|
3499
4704
|
toAmount: receiveAmount,
|
|
3500
4705
|
executionChainId: option.chainId,
|
|
3501
4706
|
executionChainName: option.chainName
|
|
@@ -3526,6 +4731,9 @@ async function buildRoute({
|
|
|
3526
4731
|
}
|
|
3527
4732
|
};
|
|
3528
4733
|
}
|
|
4734
|
+
if (quote.protocol === "zdheavy") {
|
|
4735
|
+
return buildZdHeavyRoute({ option, destination, destinationToken, chains, tokens: tokens ?? [], routes: routes ?? [], payer, result });
|
|
4736
|
+
}
|
|
3529
4737
|
const requestList = quote.orderRequests?.length ? quote.orderRequests : quote.orderRequest ? [quote.orderRequest] : [];
|
|
3530
4738
|
if (!requestList.length) throw new Error("ZeroDelta quote did not include an order request.");
|
|
3531
4739
|
const sourceChain = chainById(chains, option.chainId);
|
|
@@ -3627,12 +4835,134 @@ async function buildRoute({
|
|
|
3627
4835
|
};
|
|
3628
4836
|
}
|
|
3629
4837
|
|
|
4838
|
+
// src/core/promotions.ts
|
|
4839
|
+
var CENTIBIPS_PER_UNIT = 1e6;
|
|
4840
|
+
function toToken(raw2) {
|
|
4841
|
+
if (!raw2 || typeof raw2 !== "object") return void 0;
|
|
4842
|
+
const r = raw2;
|
|
4843
|
+
const chainId = Number(r.chainId);
|
|
4844
|
+
if (!Number.isSafeInteger(chainId) || chainId <= 0) return void 0;
|
|
4845
|
+
if (typeof r.address !== "string" || !r.address) return void 0;
|
|
4846
|
+
if (typeof r.symbol !== "string" || !r.symbol) return void 0;
|
|
4847
|
+
return { chainId, address: r.address, symbol: r.symbol };
|
|
4848
|
+
}
|
|
4849
|
+
function parsePromotion(raw2, now = Date.now()) {
|
|
4850
|
+
if (!raw2 || typeof raw2 !== "object") return void 0;
|
|
4851
|
+
const r = raw2;
|
|
4852
|
+
if (typeof r.id !== "string" || !r.id) return void 0;
|
|
4853
|
+
if (r.kind !== "token" && r.kind !== "pair") return void 0;
|
|
4854
|
+
const destination = toToken(r.destination);
|
|
4855
|
+
if (!destination) return void 0;
|
|
4856
|
+
const source2 = r.kind === "pair" ? toToken(r.source) : void 0;
|
|
4857
|
+
if (r.kind === "pair" && !source2) return void 0;
|
|
4858
|
+
const bonusCentibips = Number(r.bonusCentibips);
|
|
4859
|
+
if (!Number.isSafeInteger(bonusCentibips) || bonusCentibips <= 0) return void 0;
|
|
4860
|
+
if (r.fundedBy !== "issuer" && r.fundedBy !== "zerodelta") return void 0;
|
|
4861
|
+
if (typeof r.startsAt !== "string" || typeof r.endsAt !== "string") return void 0;
|
|
4862
|
+
const starts = Date.parse(r.startsAt);
|
|
4863
|
+
const ends = Date.parse(r.endsAt);
|
|
4864
|
+
if (!Number.isFinite(starts) || !Number.isFinite(ends) || !(starts <= now && now < ends)) return void 0;
|
|
4865
|
+
let maxBonusAmount;
|
|
4866
|
+
if (r.maxBonusAmount !== void 0) {
|
|
4867
|
+
if (typeof r.maxBonusAmount !== "string" || !/^[1-9]\d*$/.test(r.maxBonusAmount)) return void 0;
|
|
4868
|
+
maxBonusAmount = r.maxBonusAmount;
|
|
4869
|
+
}
|
|
4870
|
+
return {
|
|
4871
|
+
id: r.id,
|
|
4872
|
+
kind: r.kind,
|
|
4873
|
+
destination,
|
|
4874
|
+
...source2 ? { source: source2 } : {},
|
|
4875
|
+
bonusCentibips,
|
|
4876
|
+
...maxBonusAmount ? { maxBonusAmount } : {},
|
|
4877
|
+
fundedBy: r.fundedBy,
|
|
4878
|
+
...typeof r.funderName === "string" && r.funderName ? { funderName: r.funderName } : {},
|
|
4879
|
+
startsAt: r.startsAt,
|
|
4880
|
+
endsAt: r.endsAt
|
|
4881
|
+
};
|
|
4882
|
+
}
|
|
4883
|
+
function parsePromotions(rows, now = Date.now()) {
|
|
4884
|
+
if (!Array.isArray(rows)) return [];
|
|
4885
|
+
return rows.map((row) => parsePromotion(row, now)).filter((p) => !!p);
|
|
4886
|
+
}
|
|
4887
|
+
function sameAddress(a, b) {
|
|
4888
|
+
return a.startsWith("0x") && b.startsWith("0x") ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
4889
|
+
}
|
|
4890
|
+
function sameToken(t, chainId, address) {
|
|
4891
|
+
return t.chainId === chainId && sameAddress(t.address, address);
|
|
4892
|
+
}
|
|
4893
|
+
function promotedAssets(promotions) {
|
|
4894
|
+
const bySymbol = /* @__PURE__ */ new Map();
|
|
4895
|
+
for (const p of promotions) {
|
|
4896
|
+
if (p.kind !== "token") continue;
|
|
4897
|
+
const key2 = p.destination.symbol.toUpperCase();
|
|
4898
|
+
const asset = bySymbol.get(key2) ?? { symbol: p.destination.symbol, maxCentibips: 0, networks: [], fundedBy: p.fundedBy };
|
|
4899
|
+
asset.networks.push({ promotion: p, chainId: p.destination.chainId, address: p.destination.address, bonusCentibips: p.bonusCentibips });
|
|
4900
|
+
if (p.bonusCentibips > asset.maxCentibips) {
|
|
4901
|
+
asset.maxCentibips = p.bonusCentibips;
|
|
4902
|
+
asset.fundedBy = p.fundedBy;
|
|
4903
|
+
}
|
|
4904
|
+
bySymbol.set(key2, asset);
|
|
4905
|
+
}
|
|
4906
|
+
const assets = [...bySymbol.values()];
|
|
4907
|
+
for (const a of assets) a.networks.sort((x, y) => y.bonusCentibips - x.bonusCentibips || x.chainId - y.chainId);
|
|
4908
|
+
return assets.sort((a, b) => b.maxCentibips - a.maxCentibips || a.symbol.localeCompare(b.symbol));
|
|
4909
|
+
}
|
|
4910
|
+
function promotionFor(promotions, ends) {
|
|
4911
|
+
let best;
|
|
4912
|
+
for (const p of promotions) {
|
|
4913
|
+
if (!sameToken(p.destination, ends.toChainId, ends.toAddress)) continue;
|
|
4914
|
+
if (p.kind === "pair") {
|
|
4915
|
+
if (!p.source || ends.fromChainId === void 0 || !ends.fromAddress) continue;
|
|
4916
|
+
if (!sameToken(p.source, ends.fromChainId, ends.fromAddress)) continue;
|
|
4917
|
+
}
|
|
4918
|
+
if (!best || p.bonusCentibips > best.bonusCentibips) best = p;
|
|
4919
|
+
}
|
|
4920
|
+
return best;
|
|
4921
|
+
}
|
|
4922
|
+
function pairPromotionsInto(promotions, chainId, address) {
|
|
4923
|
+
return promotions.filter((p) => p.kind === "pair" && sameToken(p.destination, chainId, address));
|
|
4924
|
+
}
|
|
4925
|
+
function estimateBonus(amount, promotion) {
|
|
4926
|
+
if (amount <= 0n) return 0n;
|
|
4927
|
+
const bonus = amount * BigInt(promotion.bonusCentibips) / BigInt(CENTIBIPS_PER_UNIT);
|
|
4928
|
+
if (promotion.maxBonusAmount) {
|
|
4929
|
+
const cap = BigInt(promotion.maxBonusAmount);
|
|
4930
|
+
return bonus > cap ? cap : bonus;
|
|
4931
|
+
}
|
|
4932
|
+
return bonus;
|
|
4933
|
+
}
|
|
4934
|
+
/* @__PURE__ */ new Set([...STABLE_ASSETS, "GHO", "USD0", "USDF"]);
|
|
4935
|
+
|
|
4936
|
+
// src/core/quote-request.ts
|
|
4937
|
+
function nativeQuoteRequest(body) {
|
|
4938
|
+
const inputChain = Number(body.fromChainId);
|
|
4939
|
+
const owner = typeof body.owner === "string" && body.owner ? body.owner : void 0;
|
|
4940
|
+
const destinationWallet = typeof body.destinationReceiver === "string" && body.destinationReceiver ? body.destinationReceiver : void 0;
|
|
4941
|
+
const owners = owner ? isSolanaChainId(inputChain) && isSolanaAddress(owner) ? { svm: owner } : { evm: owner } : void 0;
|
|
4942
|
+
const sender = typeof body.sender === "string" ? body.sender : !isSolanaChainId(inputChain) ? owner : void 0;
|
|
4943
|
+
return {
|
|
4944
|
+
inputChain,
|
|
4945
|
+
outputChain: Number(body.toChainId),
|
|
4946
|
+
inputToken: String(body.fromToken ?? ""),
|
|
4947
|
+
outputToken: String(body.toToken ?? ""),
|
|
4948
|
+
inputAmount: String(body.fromAmount ?? ""),
|
|
4949
|
+
...owners ? { owners } : {},
|
|
4950
|
+
...destinationWallet ? { destinationWallet } : {},
|
|
4951
|
+
...sender && owners && destinationWallet ? { sender } : {},
|
|
4952
|
+
// No new deadline, latency limit or subject is invented for EVM quoting. The
|
|
4953
|
+
// gateway derives the subject from owners when this caller has no explicit one.
|
|
4954
|
+
...body.deadline !== void 0 ? { deadline: String(body.deadline) } : {},
|
|
4955
|
+
...typeof body.maxTimeSec === "number" ? { maxTimeSec: body.maxTimeSec } : {},
|
|
4956
|
+
...typeof body.subjectId === "string" ? { subjectId: body.subjectId } : {}
|
|
4957
|
+
};
|
|
4958
|
+
}
|
|
4959
|
+
|
|
3630
4960
|
// src/core/channel.ts
|
|
3631
4961
|
var CHANNEL_HEADER = "x-zd-channel";
|
|
3632
4962
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
3633
4963
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
3634
4964
|
var WIDGET_CHANNEL = "widget";
|
|
3635
|
-
var WIDGET_VERSION = "4.
|
|
4965
|
+
var WIDGET_VERSION = "4.20.0" ;
|
|
3636
4966
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
3637
4967
|
function sanitizeVersion(raw2) {
|
|
3638
4968
|
const v = String(raw2).trim();
|
|
@@ -3669,6 +4999,20 @@ function isReportableSubmission(report) {
|
|
|
3669
4999
|
return typeof wallet === "string" && /^0x[0-9a-fA-F]{40}$/.test(wallet);
|
|
3670
5000
|
}
|
|
3671
5001
|
|
|
5002
|
+
// src/core/quote-refusals.ts
|
|
5003
|
+
var GATE_REFUSALS = /* @__PURE__ */ new Set(["ROUTE_UNHEALTHY", "ROUTE_UNMEASURED", "GATE_UNAVAILABLE"]);
|
|
5004
|
+
function quoteRefusalCopy(code) {
|
|
5005
|
+
return code && GATE_REFUSALS.has(code) ? "This route is not available right now. Try again in a moment, or pick another token or network." : void 0;
|
|
5006
|
+
}
|
|
5007
|
+
var DETERMINISTIC_REFUSALS = /* @__PURE__ */ new Set(["ROUTE_UNHEALTHY", "ROUTE_UNMEASURED", "ROUTE_BLOCKED", "PAIR_HALTED", "PROTOCOL_DISABLED"]);
|
|
5008
|
+
var TRANSIENT_REFUSALS = /* @__PURE__ */ new Set(["GATE_UNAVAILABLE", "MARKET_HALTED"]);
|
|
5009
|
+
function gateRefusalRetryable(code) {
|
|
5010
|
+
if (!code) return void 0;
|
|
5011
|
+
if (DETERMINISTIC_REFUSALS.has(code)) return false;
|
|
5012
|
+
if (TRANSIENT_REFUSALS.has(code)) return true;
|
|
5013
|
+
return void 0;
|
|
5014
|
+
}
|
|
5015
|
+
|
|
3672
5016
|
// src/core/api.ts
|
|
3673
5017
|
function apiError(message, props = {}) {
|
|
3674
5018
|
const err2 = new Error(message);
|
|
@@ -3724,7 +5068,7 @@ function classifyQuoteError(error) {
|
|
|
3724
5068
|
function amountFieldError(error) {
|
|
3725
5069
|
const fieldErrors = error?.fieldErrors;
|
|
3726
5070
|
if (!Array.isArray(fieldErrors)) return null;
|
|
3727
|
-
const entry = fieldErrors.find((e) => e && typeof e === "object" && e.field === "fromAmount" && typeof e.message === "string");
|
|
5071
|
+
const entry = fieldErrors.find((e) => e && typeof e === "object" && (e.field === "fromAmount" || e.field === "inputAmount") && typeof e.message === "string");
|
|
3728
5072
|
const message = entry ? sanitizeMessage(entry.message, "") : "";
|
|
3729
5073
|
return message || null;
|
|
3730
5074
|
}
|
|
@@ -3732,6 +5076,8 @@ function nowFresh(entry) {
|
|
|
3732
5076
|
return !!entry && Date.now() - entry.at < API_CACHE_TTL_MS;
|
|
3733
5077
|
}
|
|
3734
5078
|
function isTransientQuoteError(error) {
|
|
5079
|
+
const gate = gateRefusalRetryable(error?.code);
|
|
5080
|
+
if (gate !== void 0) return gate;
|
|
3735
5081
|
if (error?.code === "BRIDGE_RATE_LIMITED" || Array.isArray(error?.fieldErrors) && error.fieldErrors.length > 0) return false;
|
|
3736
5082
|
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 || "");
|
|
3737
5083
|
}
|
|
@@ -3740,7 +5086,7 @@ function wait(ms) {
|
|
|
3740
5086
|
}
|
|
3741
5087
|
var PAGE_LIMIT = 500;
|
|
3742
5088
|
var MAX_PAGES = 10;
|
|
3743
|
-
var newRegistryCache = () => ({ chains: null, tokens: null, routes: null, health: null, vaults: null, inflight: /* @__PURE__ */ new Map() });
|
|
5089
|
+
var newRegistryCache = () => ({ chains: null, tokens: null, routes: null, health: null, vaults: null, promotions: null, inflight: /* @__PURE__ */ new Map() });
|
|
3744
5090
|
var SHARED_REGISTRY = /* @__PURE__ */ new WeakMap();
|
|
3745
5091
|
function registryCacheFor(scope) {
|
|
3746
5092
|
if (!scope) return newRegistryCache();
|
|
@@ -3802,9 +5148,10 @@ function createApiClient(cfg) {
|
|
|
3802
5148
|
}
|
|
3803
5149
|
}
|
|
3804
5150
|
if (!response.ok) {
|
|
3805
|
-
|
|
5151
|
+
const code = json?.error?.code || json?.code || (response.status >= 502 ? "gateway_timeout" : "api_error");
|
|
5152
|
+
throw apiError(quoteRefusalCopy(code) ?? apiMessage(json, `ZeroDelta request failed (${response.status}).`), {
|
|
3806
5153
|
status: response.status,
|
|
3807
|
-
code
|
|
5154
|
+
code,
|
|
3808
5155
|
fieldErrors: json?.error?.fieldErrors || json?.fieldErrors,
|
|
3809
5156
|
limits: json?.error?.limits || json?.limits,
|
|
3810
5157
|
reasons: json?.error?.reasons || json?.reasons
|
|
@@ -3897,6 +5244,20 @@ function createApiClient(cfg) {
|
|
|
3897
5244
|
return value;
|
|
3898
5245
|
});
|
|
3899
5246
|
}
|
|
5247
|
+
function fetchPromotions() {
|
|
5248
|
+
if (nowFresh(cache.promotions)) return Promise.resolve(parsePromotions(cache.promotions.value));
|
|
5249
|
+
return once("promotions", async () => {
|
|
5250
|
+
let value = [];
|
|
5251
|
+
try {
|
|
5252
|
+
const rows = await apiRequest("/promotions", { timeoutMs: 8e3 });
|
|
5253
|
+
value = Array.isArray(rows) ? rows : [];
|
|
5254
|
+
} catch {
|
|
5255
|
+
value = [];
|
|
5256
|
+
}
|
|
5257
|
+
cache.promotions = { at: Date.now(), value };
|
|
5258
|
+
return parsePromotions(value);
|
|
5259
|
+
});
|
|
5260
|
+
}
|
|
3900
5261
|
const priceCache = /* @__PURE__ */ new Map();
|
|
3901
5262
|
async function fetchPrices(symbols) {
|
|
3902
5263
|
const wanted = [...new Set(symbols.map((s) => String(s || "").toUpperCase()).filter((s) => /^[A-Z0-9]{1,16}$/.test(s)))];
|
|
@@ -3927,11 +5288,12 @@ function createApiClient(cfg) {
|
|
|
3927
5288
|
return out;
|
|
3928
5289
|
}
|
|
3929
5290
|
async function fetchQuote(body, retries = 1) {
|
|
5291
|
+
const request = nativeQuoteRequest(body);
|
|
3930
5292
|
let lastError;
|
|
3931
5293
|
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
3932
5294
|
try {
|
|
3933
|
-
const quote = await apiRequest("/quote", { method: "POST", body: JSON.stringify(
|
|
3934
|
-
return quote
|
|
5295
|
+
const quote = await apiRequest("/quote", { method: "POST", headers: { "X-ZD-Shape": "native" }, body: JSON.stringify(request), timeoutMs: 18e3 });
|
|
5296
|
+
return normalizeQuoteResponse(quote, request);
|
|
3935
5297
|
} catch (error) {
|
|
3936
5298
|
lastError = error;
|
|
3937
5299
|
if (attempt >= retries || !isTransientQuoteError(error)) throw error;
|
|
@@ -3945,10 +5307,10 @@ function createApiClient(cfg) {
|
|
|
3945
5307
|
if (!addr) throw apiError("An address is required to screen a wallet.", { code: "bad_request" });
|
|
3946
5308
|
const solana = isSolanaChainId(chainId) || isSolanaAddress(addr);
|
|
3947
5309
|
if (solana && !isSolanaAddress(addr)) throw apiError("Not a valid Solana address.", { code: "bad_request" });
|
|
3948
|
-
const
|
|
3949
|
-
const hit = screenCache.get(
|
|
5310
|
+
const key2 = solana ? "solana|" + addr : (/^0x[0-9a-fA-F]+$/.test(addr) ? addr.toLowerCase() : addr) + "|" + (chainId ?? "");
|
|
5311
|
+
const hit = screenCache.get(key2);
|
|
3950
5312
|
if (hit && Date.now() - hit.at < SCREEN_CACHE_TTL_MS) return hit.value;
|
|
3951
|
-
const inflight = screenInflight.get(
|
|
5313
|
+
const inflight = screenInflight.get(key2);
|
|
3952
5314
|
if (inflight) return inflight;
|
|
3953
5315
|
const request = apiRequest("/screen/wallet", {
|
|
3954
5316
|
method: "POST",
|
|
@@ -3959,12 +5321,12 @@ function createApiClient(cfg) {
|
|
|
3959
5321
|
throw apiError("Compliance screening returned an unusable result.", { code: "bad_response" });
|
|
3960
5322
|
}
|
|
3961
5323
|
const value = { ...screen, address: screen.address || addr };
|
|
3962
|
-
screenCache.set(
|
|
5324
|
+
screenCache.set(key2, { at: Date.now(), value });
|
|
3963
5325
|
return value;
|
|
3964
5326
|
}).finally(() => {
|
|
3965
|
-
screenInflight.delete(
|
|
5327
|
+
screenInflight.delete(key2);
|
|
3966
5328
|
});
|
|
3967
|
-
screenInflight.set(
|
|
5329
|
+
screenInflight.set(key2, request);
|
|
3968
5330
|
return request;
|
|
3969
5331
|
}
|
|
3970
5332
|
async function reportSubmission(report) {
|
|
@@ -3987,7 +5349,7 @@ function createApiClient(cfg) {
|
|
|
3987
5349
|
return false;
|
|
3988
5350
|
}
|
|
3989
5351
|
}
|
|
3990
|
-
return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchRwaVaults, fetchPrices, fetchQuote, screenWallet, reportSubmission, apiBase };
|
|
5352
|
+
return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchRwaVaults, fetchPrices, fetchPromotions, fetchQuote, screenWallet, reportSubmission, apiBase };
|
|
3991
5353
|
}
|
|
3992
5354
|
|
|
3993
5355
|
// src/core/plan.ts
|
|
@@ -4050,9 +5412,9 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
4050
5412
|
const balanceTargets = [];
|
|
4051
5413
|
const seenTargets = /* @__PURE__ */ new Set();
|
|
4052
5414
|
for (const option of options) {
|
|
4053
|
-
const
|
|
4054
|
-
if (seenTargets.has(
|
|
4055
|
-
seenTargets.add(
|
|
5415
|
+
const key2 = optionBalanceKey(option);
|
|
5416
|
+
if (seenTargets.has(key2)) continue;
|
|
5417
|
+
seenTargets.add(key2);
|
|
4056
5418
|
balanceTargets.push({ chainId: option.chainId, tokenAddress: option.address, decimals: option.decimals });
|
|
4057
5419
|
}
|
|
4058
5420
|
const walletBalances = readBalances ? await readBalances(payer, balanceTargets).catch(() => ({})) : {};
|
|
@@ -4064,9 +5426,9 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
4064
5426
|
for (const raw2 of [payer, destination.address]) {
|
|
4065
5427
|
const addr = String(raw2 || "").trim();
|
|
4066
5428
|
if (!addr) continue;
|
|
4067
|
-
const
|
|
4068
|
-
if (seenParty.has(
|
|
4069
|
-
seenParty.add(
|
|
5429
|
+
const key2 = /^0x[0-9a-fA-F]+$/.test(addr) ? addr.toLowerCase() : addr;
|
|
5430
|
+
if (seenParty.has(key2)) continue;
|
|
5431
|
+
seenParty.add(key2);
|
|
4070
5432
|
parties.push(addr);
|
|
4071
5433
|
}
|
|
4072
5434
|
try {
|
|
@@ -4113,6 +5475,7 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
4113
5475
|
destinationToken,
|
|
4114
5476
|
chains,
|
|
4115
5477
|
tokens,
|
|
5478
|
+
routes,
|
|
4116
5479
|
payer,
|
|
4117
5480
|
fetchQuote: api.fetchQuote,
|
|
4118
5481
|
compliance: option.direct ? directCompliance ?? void 0 : void 0
|
|
@@ -4173,7 +5536,7 @@ async function quotePayOption(api, request, payer, picked, wallet = {}) {
|
|
|
4173
5536
|
(o) => !o.direct && Number(o.chainId) === Number(picked.chainId) && chainAddressKey(o.chainId, o.address) === chainAddressKey(picked.chainId, picked.address) && (!allowedFunding || allowedFunding.has(o.symbolKey))
|
|
4174
5537
|
);
|
|
4175
5538
|
if (!option) throw new Error("That funding option is not available for this payment right now.");
|
|
4176
|
-
return buildRoute({ option, destination, destinationToken, chains, tokens, payer, fetchQuote: api.fetchQuote });
|
|
5539
|
+
return buildRoute({ option, destination, destinationToken, chains, tokens, routes, payer, fetchQuote: api.fetchQuote });
|
|
4177
5540
|
}
|
|
4178
5541
|
|
|
4179
5542
|
// src/core/swap.ts
|
|
@@ -4181,13 +5544,13 @@ function validateSwap(swap = {}) {
|
|
|
4181
5544
|
const fromChainId = Number(swap.fromChainId);
|
|
4182
5545
|
const toChainId = Number(swap.toChainId);
|
|
4183
5546
|
const fromToken = symbolKey(swap.fromToken);
|
|
4184
|
-
const
|
|
5547
|
+
const toToken2 = symbolKey(swap.toToken);
|
|
4185
5548
|
if (!SUPPORTED_CHAIN_IDS.has(fromChainId)) throw new Error("Unsupported swap chain.");
|
|
4186
5549
|
if (!Number.isSafeInteger(toChainId) || toChainId <= 0) throw new Error("Unsupported swap chain.");
|
|
4187
|
-
if (!SUPPORTED_ASSETS.has(fromToken) || !SUPPORTED_ASSETS.has(
|
|
5550
|
+
if (!SUPPORTED_ASSETS.has(fromToken) || !SUPPORTED_ASSETS.has(toToken2)) throw new Error("Unsupported swap asset.");
|
|
4188
5551
|
const amountIn = normalizeDecimalText(swap.amountIn);
|
|
4189
5552
|
if (!/^\d+(\.\d+)?$/.test(amountIn) || Number(amountIn) <= 0 || Number(amountIn) > 1e9) throw new Error("Enter a valid swap amount.");
|
|
4190
|
-
return { fromChainId, toChainId, fromToken, toToken, amountIn };
|
|
5553
|
+
return { fromChainId, toChainId, fromToken, toToken: toToken2, amountIn };
|
|
4191
5554
|
}
|
|
4192
5555
|
function viaOf(quote, tokens) {
|
|
4193
5556
|
const orders = Array.isArray(quote.orderRequests) ? quote.orderRequests : [];
|
|
@@ -4237,7 +5600,7 @@ async function quoteSwapPreview(api, swap, owner) {
|
|
|
4237
5600
|
async function buildSwapPlan(api, swap, payer, wallet = {}) {
|
|
4238
5601
|
const v = validateSwap(swap);
|
|
4239
5602
|
const account = assertAddress(payer, "Swap wallet");
|
|
4240
|
-
const [chains, tokens] = await Promise.all([api.fetchChains(), api.fetchTokens()]);
|
|
5603
|
+
const [chains, tokens, routes] = await Promise.all([api.fetchChains(), api.fetchTokens(), api.fetchRoutes()]);
|
|
4241
5604
|
const sourceToken = findToken(tokens, v.fromChainId, v.fromToken);
|
|
4242
5605
|
const destToken = findToken(tokens, v.toChainId, v.toToken);
|
|
4243
5606
|
if (!sourceToken) throw new Error(`${v.fromToken} is not enabled on ${chainNameOf(v.fromChainId, chains)}.`);
|
|
@@ -4260,7 +5623,7 @@ async function buildSwapPlan(api, swap, payer, wallet = {}) {
|
|
|
4260
5623
|
direct: false
|
|
4261
5624
|
};
|
|
4262
5625
|
const destination = { address: receiver, chainId: v.toChainId, asset: destToken.symbol };
|
|
4263
|
-
const route = await buildRoute({ option, destination, destinationToken: destToken, chains, tokens, payer: account, fetchQuote: api.fetchQuote, solve: solveExactIn, amountInRaw });
|
|
5626
|
+
const route = await buildRoute({ option, destination, destinationToken: destToken, chains, tokens, routes, payer: account, fetchQuote: api.fetchQuote, solve: solveExactIn, amountInRaw });
|
|
4264
5627
|
if (route.state === "SHORT") throw new Error("ZeroDelta could not price this swap right now.");
|
|
4265
5628
|
route.recommended = true;
|
|
4266
5629
|
return {
|
|
@@ -4281,88 +5644,6 @@ async function buildSwapPlan(api, swap, payer, wallet = {}) {
|
|
|
4281
5644
|
};
|
|
4282
5645
|
}
|
|
4283
5646
|
|
|
4284
|
-
// src/core/validate-tx.ts
|
|
4285
|
-
var lower = (v) => String(v || "").toLowerCase();
|
|
4286
|
-
function isHexAddress(value) {
|
|
4287
|
-
return /^0x[a-fA-F0-9]{40}$/.test(String(value || ""));
|
|
4288
|
-
}
|
|
4289
|
-
function isHexData(value) {
|
|
4290
|
-
return /^0x(?:[a-fA-F0-9]{2})*$/.test(String(value));
|
|
4291
|
-
}
|
|
4292
|
-
function isHexQuantity(value) {
|
|
4293
|
-
return /^0x[0-9a-fA-F]+$/.test(String(value));
|
|
4294
|
-
}
|
|
4295
|
-
function dataWord(data, index) {
|
|
4296
|
-
const word2 = String(data || "").slice(10 + index * 64, 10 + (index + 1) * 64);
|
|
4297
|
-
return /^[a-fA-F0-9]{64}$/.test(word2) ? word2 : "";
|
|
4298
|
-
}
|
|
4299
|
-
function dataAddress(data, index) {
|
|
4300
|
-
const word2 = dataWord(data, index);
|
|
4301
|
-
return word2 ? `0x${word2.slice(24)}` : "";
|
|
4302
|
-
}
|
|
4303
|
-
function dataUint(data, index) {
|
|
4304
|
-
const word2 = dataWord(data, index);
|
|
4305
|
-
return word2 ? BigInt(`0x${word2}`) : null;
|
|
4306
|
-
}
|
|
4307
|
-
function rawEquals(value, expected) {
|
|
4308
|
-
try {
|
|
4309
|
-
return value === BigInt(expected || "0");
|
|
4310
|
-
} catch {
|
|
4311
|
-
return false;
|
|
4312
|
-
}
|
|
4313
|
-
}
|
|
4314
|
-
function planMsgValueHex(route) {
|
|
4315
|
-
try {
|
|
4316
|
-
const raw2 = route?.quote?.msgValue;
|
|
4317
|
-
if (raw2 === void 0 || raw2 === null || raw2 === "") return "0x0";
|
|
4318
|
-
return "0x" + BigInt(raw2).toString(16);
|
|
4319
|
-
} catch {
|
|
4320
|
-
return null;
|
|
4321
|
-
}
|
|
4322
|
-
}
|
|
4323
|
-
function validatePlannedTransaction(tx, route, expectedRecipient) {
|
|
4324
|
-
if (!tx || tx.mock) return true;
|
|
4325
|
-
if (!isHexAddress(tx.to) || !isHexData(tx.data || "0x") || !isHexQuantity(tx.value || "0x0")) return false;
|
|
4326
|
-
const data = String(tx.data || "0x").toLowerCase();
|
|
4327
|
-
const selector = data.slice(0, 10);
|
|
4328
|
-
const value = lower(tx.value || "0x0");
|
|
4329
|
-
if (tx.kind === "transfer") {
|
|
4330
|
-
if (value !== "0x0") return false;
|
|
4331
|
-
return selector === "0xa9059cbb" && isHexAddress(tx.token) && lower(tx.to) === lower(tx.token) && lower(dataAddress(data, 0)) === lower(expectedRecipient) && rawEquals(dataUint(data, 1), tx.amountRaw);
|
|
4332
|
-
}
|
|
4333
|
-
if (tx.kind === "approve") {
|
|
4334
|
-
if (value !== "0x0") return false;
|
|
4335
|
-
return selector === "0x095ea7b3" && isHexAddress(tx.token) && isHexAddress(tx.spender) && lower(tx.to) === lower(tx.token) && lower(dataAddress(data, 0)) === lower(tx.spender) && rawEquals(dataUint(data, 1), tx.amountRaw);
|
|
4336
|
-
}
|
|
4337
|
-
if (tx.kind === "submitOrder") {
|
|
4338
|
-
const expected = planMsgValueHex(route);
|
|
4339
|
-
if (expected === null || value !== lower(expected)) return false;
|
|
4340
|
-
if (selector !== SUBMIT_ORDER_SELECTOR || !isHexAddress(tx.escrow) || lower(tx.to) !== lower(tx.escrow)) return false;
|
|
4341
|
-
const decoded = decodeSubmitOrderCalldata(data);
|
|
4342
|
-
if (!decoded) return false;
|
|
4343
|
-
const first = decoded.orders[0];
|
|
4344
|
-
const last = decoded.orders[decoded.orders.length - 1];
|
|
4345
|
-
return decoded.partnerId === lower(route.quote?.partnerId || NO_PARTNER_ID) && lower(first.bidToken) === lower(route.source.tokenAddress) && rawEquals(first.bidTokenAmount, tx.amountRaw) && lower(last.askToken) === lower(isSolanaChainId(route.receive.chainId) ? solanaKeyHex(route.receive.tokenAddress || "") : route.receive.tokenAddress) && Number(last.destinationChainId) === Number(route.receive.chainId) && (isSolanaChainId(route.receive.chainId) ? solanaDeliveryMatches(last.destinationReceiver, expectedRecipient, route.receive.tokenAddress) : lower(last.destinationReceiver) === lower(expectedRecipient));
|
|
4346
|
-
}
|
|
4347
|
-
return false;
|
|
4348
|
-
}
|
|
4349
|
-
function solanaDeliveryMatches(encoded, recipient2, mint) {
|
|
4350
|
-
try {
|
|
4351
|
-
return lower(encoded) === expectedSolanaDelivery(recipient2, mint || "");
|
|
4352
|
-
} catch {
|
|
4353
|
-
return false;
|
|
4354
|
-
}
|
|
4355
|
-
}
|
|
4356
|
-
async function allowanceCovers(tx, account, ethCall2) {
|
|
4357
|
-
if (tx?.kind !== "approve" || !tx.token || !tx.spender || !tx.amountRaw || !account) return false;
|
|
4358
|
-
try {
|
|
4359
|
-
const raw2 = await ethCall2(tx.token, encodeAllowance(account, tx.spender));
|
|
4360
|
-
return BigInt(raw2 || "0x0") >= BigInt(tx.amountRaw || "0");
|
|
4361
|
-
} catch {
|
|
4362
|
-
return false;
|
|
4363
|
-
}
|
|
4364
|
-
}
|
|
4365
|
-
|
|
4366
5647
|
// src/core/verify.ts
|
|
4367
5648
|
var TX_VERIFY_ATTEMPTS = 5;
|
|
4368
5649
|
var TX_VERIFY_INTERVAL_MS = 2500;
|
|
@@ -4507,9 +5788,9 @@ function createVerifier(api, fetchImpl, rpcOverrides = {}) {
|
|
|
4507
5788
|
const seen = /* @__PURE__ */ new Set();
|
|
4508
5789
|
for (const target of targets) {
|
|
4509
5790
|
if (!target || !isAddress(target.tokenAddress)) continue;
|
|
4510
|
-
const
|
|
4511
|
-
if (seen.has(
|
|
4512
|
-
seen.add(
|
|
5791
|
+
const key2 = `${Number(target.chainId)}:${String(target.tokenAddress).toLowerCase()}`;
|
|
5792
|
+
if (seen.has(key2)) continue;
|
|
5793
|
+
seen.add(key2);
|
|
4513
5794
|
const chainId = Number(target.chainId);
|
|
4514
5795
|
const group = groups.get(chainId) || [];
|
|
4515
5796
|
group.push(target);
|
|
@@ -4518,8 +5799,8 @@ function createVerifier(api, fetchImpl, rpcOverrides = {}) {
|
|
|
4518
5799
|
function record(target, hex) {
|
|
4519
5800
|
if (typeof hex !== "string" || !/^0x[0-9a-fA-F]*$/.test(hex)) return false;
|
|
4520
5801
|
const raw2 = BigInt(hex || "0x0").toString();
|
|
4521
|
-
const
|
|
4522
|
-
out[
|
|
5802
|
+
const key2 = `${Number(target.chainId)}:${String(target.tokenAddress).toLowerCase()}`;
|
|
5803
|
+
out[key2] = { raw: raw2, formatted: formatUnits(raw2, Number(target.decimals)) };
|
|
4523
5804
|
return true;
|
|
4524
5805
|
}
|
|
4525
5806
|
async function readOne(rpcUrl, target) {
|
|
@@ -4565,7 +5846,18 @@ function createVerifier(api, fetchImpl, rpcOverrides = {}) {
|
|
|
4565
5846
|
return null;
|
|
4566
5847
|
}
|
|
4567
5848
|
}
|
|
4568
|
-
|
|
5849
|
+
async function readZdHeavySubmitFee(chainId, to, data) {
|
|
5850
|
+
try {
|
|
5851
|
+
const override = rpcOverrides[Number(chainId)];
|
|
5852
|
+
const rpc = override && /^https?:\/\//i.test(override) ? override : BUNDLED_RPC[Number(chainId)];
|
|
5853
|
+
if (!rpc) return void 0;
|
|
5854
|
+
const result = await rpcCall(rpc, "eth_call", [{ to, data: quoteSubmitCalldata(data) }, "latest"]);
|
|
5855
|
+
return typeof result === "string" && /^0x[0-9a-fA-F]{64}$/.test(result) ? BigInt(result) : void 0;
|
|
5856
|
+
} catch {
|
|
5857
|
+
return void 0;
|
|
5858
|
+
}
|
|
5859
|
+
}
|
|
5860
|
+
return { payerNonceBaseline, verifySubmittedTx, readBalances, readNativeBalance, readZdHeavySubmitFee };
|
|
4569
5861
|
}
|
|
4570
5862
|
|
|
4571
5863
|
// src/core/config.ts
|
|
@@ -4686,6 +5978,7 @@ function createEngine(config = {}) {
|
|
|
4686
5978
|
fetchRouteHealth: api.fetchRouteHealth,
|
|
4687
5979
|
fetchQuote: api.fetchQuote,
|
|
4688
5980
|
fetchPrices: (symbols) => api.fetchPrices ? api.fetchPrices(symbols) : Promise.resolve({}),
|
|
5981
|
+
fetchPromotions: () => api.fetchPromotions ? api.fetchPromotions() : Promise.resolve([]),
|
|
4689
5982
|
fetchCatalogue: async (allowedAssets, product, options) => {
|
|
4690
5983
|
const [chains, registryTokens, routes, health, vaults] = await Promise.all([
|
|
4691
5984
|
api.fetchChains().catch(() => []),
|
|
@@ -5129,7 +6422,13 @@ function useFlow(args) {
|
|
|
5129
6422
|
statusRef.current = status;
|
|
5130
6423
|
const { idle: idle2, returnedAt: returnedAt2 } = useUserPresence();
|
|
5131
6424
|
const routes = plan?.routes ?? [];
|
|
5132
|
-
const
|
|
6425
|
+
const baseSelected = react.useMemo(() => routes.find((r) => r.id === selectedId) ?? routes.find((r) => r.recommended) ?? routes[0] ?? null, [routes, selectedId]);
|
|
6426
|
+
const [pickedOptionId, setPickedOptionId] = react.useState(null);
|
|
6427
|
+
const selected = react.useMemo(() => {
|
|
6428
|
+
if (!baseSelected || !pickedOptionId || pickedOptionId === baseSelected.selectedOptionId) return baseSelected;
|
|
6429
|
+
const alt = baseSelected.alternatives?.find((r) => r.selectedOptionId === pickedOptionId);
|
|
6430
|
+
return alt ? { ...alt, recommended: baseSelected.recommended } : baseSelected;
|
|
6431
|
+
}, [baseSelected, pickedOptionId]);
|
|
5133
6432
|
const reload = react.useCallback(() => setNonce((n) => n + 1), []);
|
|
5134
6433
|
const addRoute = react.useCallback((route) => {
|
|
5135
6434
|
setPlan((p) => p ? { ...p, routes: [...p.routes.filter((r) => r.id !== route.id), route] } : p);
|
|
@@ -5184,11 +6483,11 @@ function useFlow(args) {
|
|
|
5184
6483
|
if (!wallet.account || !src?.tokenAddress || src.decimals == null) return;
|
|
5185
6484
|
(async () => {
|
|
5186
6485
|
try {
|
|
5187
|
-
const
|
|
6486
|
+
const key2 = `${Number(src.chainId)}:${String(src.tokenAddress).toLowerCase()}`;
|
|
5188
6487
|
const balances = await engine.readBalances(wallet.account, [
|
|
5189
6488
|
{ chainId: Number(src.chainId), tokenAddress: src.tokenAddress, decimals: Number(src.decimals) }
|
|
5190
6489
|
]);
|
|
5191
|
-
const entry = balances[
|
|
6490
|
+
const entry = balances[key2];
|
|
5192
6491
|
if (!entry) return;
|
|
5193
6492
|
const need = parseUnitsDecimal(src.payAmount || src.amount, src.decimals);
|
|
5194
6493
|
if (alive) setInsufficient(BigInt(entry.raw) < need);
|
|
@@ -5252,6 +6551,8 @@ function useFlow(args) {
|
|
|
5252
6551
|
throw new Error(nativeFeeShortMessage(check2, nativeSymbol(Number(sourceChainId), chains), route.source.chainName));
|
|
5253
6552
|
}
|
|
5254
6553
|
}
|
|
6554
|
+
const heavyExpected = route.zdHeavy ? zdHeavyExpected(route, account, recipient2, ...await Promise.all([engine.fetchTokens(), engine.fetchRoutes()])) : void 0;
|
|
6555
|
+
if (heavyExpected) await preflightZdHeavyPlan(route, heavyExpected, engine.verifier.readZdHeavySubmitFee);
|
|
5255
6556
|
const minNonce = await engine.payerNonceBaseline(Number(sourceChainId), account);
|
|
5256
6557
|
const txs = route.transactions;
|
|
5257
6558
|
let settleHash = "";
|
|
@@ -5267,7 +6568,7 @@ function useFlow(args) {
|
|
|
5267
6568
|
patch(tx.id, "done");
|
|
5268
6569
|
continue;
|
|
5269
6570
|
}
|
|
5270
|
-
if (!validatePlannedTransaction(tx, route, recipient2)) {
|
|
6571
|
+
if (!validatePlannedTransaction(tx, route, recipient2, heavyExpected ? { ...heavyExpected, nowSec: Math.floor(Date.now() / 1e3) } : void 0)) {
|
|
5271
6572
|
throw new Error(`Refusing to sign a ${tx.kind} that does not match the reviewed plan.`);
|
|
5272
6573
|
}
|
|
5273
6574
|
patch(tx.id, "active");
|
|
@@ -5338,6 +6639,98 @@ function useFlow(args) {
|
|
|
5338
6639
|
busyRef.current = false;
|
|
5339
6640
|
}
|
|
5340
6641
|
}, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError]);
|
|
6642
|
+
const [prices, setPrices] = react.useState(null);
|
|
6643
|
+
const priceKey = baseSelected?.options?.length ? `${baseSelected.source.asset}|${baseSelected.receive.asset}` : "";
|
|
6644
|
+
react.useEffect(() => {
|
|
6645
|
+
if (!priceKey || typeof engine.fetchPrices !== "function") return;
|
|
6646
|
+
let alive = true;
|
|
6647
|
+
const [from, to] = priceKey.split("|");
|
|
6648
|
+
(async () => {
|
|
6649
|
+
try {
|
|
6650
|
+
const p = await engine.fetchPrices([from, to]);
|
|
6651
|
+
const next = { key: priceKey, from: p[from.toUpperCase()], to: p[to.toUpperCase()] };
|
|
6652
|
+
if (alive) setPrices((prev) => prev && prev.key === next.key && prev.from === next.from && prev.to === next.to ? prev : next);
|
|
6653
|
+
} catch {
|
|
6654
|
+
}
|
|
6655
|
+
})();
|
|
6656
|
+
return () => {
|
|
6657
|
+
alive = false;
|
|
6658
|
+
};
|
|
6659
|
+
}, [engine, priceKey]);
|
|
6660
|
+
const compare = react.useMemo(() => {
|
|
6661
|
+
const base = baseSelected;
|
|
6662
|
+
if (!base?.options?.length) return null;
|
|
6663
|
+
const priced = prices?.key === priceKey ? prices : null;
|
|
6664
|
+
const inputAmount = Number(base.source.payAmount || base.source.amount);
|
|
6665
|
+
const fromUsd = priced?.from && Number.isFinite(inputAmount) ? inputAmount * priced.from : null;
|
|
6666
|
+
const options = priceCompareOptions(base.options, fromUsd);
|
|
6667
|
+
const selectedOptionId = selected?.selectedOptionId ?? null;
|
|
6668
|
+
const parityState = parity(options, fromUsd, priced?.to ?? null);
|
|
6669
|
+
return {
|
|
6670
|
+
options,
|
|
6671
|
+
visibleOptions: visibleOptions(options, proposedWait(options), selectedOptionId),
|
|
6672
|
+
selectedId: selectedOptionId,
|
|
6673
|
+
proposedWait: proposedWait(options),
|
|
6674
|
+
parity: parityState,
|
|
6675
|
+
extraVsFastest: extraVsFastest(options, selectedOptionId),
|
|
6676
|
+
tags: Object.fromEntries(options.map((o) => [o.id, cornerTags(options, o, parityState)])),
|
|
6677
|
+
pickForWait: (waitSec) => pickForWait(options, waitSec)
|
|
6678
|
+
};
|
|
6679
|
+
}, [baseSelected, selected, prices, priceKey]);
|
|
6680
|
+
const selectOption = react.useCallback(
|
|
6681
|
+
(optionId) => {
|
|
6682
|
+
if (busyRef.current || !baseSelected) return false;
|
|
6683
|
+
const signable = optionId === baseSelected.selectedOptionId || !!baseSelected.alternatives?.some((r) => r.selectedOptionId === optionId);
|
|
6684
|
+
if (!signable) return false;
|
|
6685
|
+
setPickedOptionId(optionId === baseSelected.selectedOptionId ? null : optionId);
|
|
6686
|
+
return true;
|
|
6687
|
+
},
|
|
6688
|
+
[baseSelected]
|
|
6689
|
+
);
|
|
6690
|
+
const [promotionList, setPromotionList] = react.useState([]);
|
|
6691
|
+
react.useEffect(() => {
|
|
6692
|
+
if (!enabled) return;
|
|
6693
|
+
let alive = true;
|
|
6694
|
+
(async () => {
|
|
6695
|
+
try {
|
|
6696
|
+
if (typeof engine.fetchPromotions !== "function") return;
|
|
6697
|
+
const read = await engine.fetchPromotions();
|
|
6698
|
+
const list = Array.isArray(read) ? read : [];
|
|
6699
|
+
if (alive) setPromotionList((prev) => JSON.stringify(prev) === JSON.stringify(list) ? prev : list);
|
|
6700
|
+
} catch {
|
|
6701
|
+
}
|
|
6702
|
+
})();
|
|
6703
|
+
return () => {
|
|
6704
|
+
alive = false;
|
|
6705
|
+
};
|
|
6706
|
+
}, [engine, enabled]);
|
|
6707
|
+
const promotions = react.useMemo(() => {
|
|
6708
|
+
const route = selected;
|
|
6709
|
+
const toAddress = route?.receive.tokenAddress;
|
|
6710
|
+
const forSelection = route && toAddress ? promotionFor(promotionList, {
|
|
6711
|
+
fromChainId: Number(route.source.chainId),
|
|
6712
|
+
...route.source.tokenAddress ? { fromAddress: route.source.tokenAddress } : {},
|
|
6713
|
+
toChainId: Number(route.receive.chainId),
|
|
6714
|
+
toAddress
|
|
6715
|
+
}) : void 0;
|
|
6716
|
+
let bonusEstimateRaw = null;
|
|
6717
|
+
if (forSelection && route) {
|
|
6718
|
+
const pickedRow = route.options?.find((o) => o.id === route.selectedOptionId);
|
|
6719
|
+
try {
|
|
6720
|
+
const delivered = pickedRow ? BigInt(pickedRow.amountRaw) : parseUnitsDecimal(route.receive.amount, Number(route.receive.decimals));
|
|
6721
|
+
bonusEstimateRaw = estimateBonus(delivered, forSelection).toString();
|
|
6722
|
+
} catch {
|
|
6723
|
+
bonusEstimateRaw = null;
|
|
6724
|
+
}
|
|
6725
|
+
}
|
|
6726
|
+
return {
|
|
6727
|
+
all: promotionList,
|
|
6728
|
+
promotedAssets: promotedAssets(promotionList),
|
|
6729
|
+
forSelection,
|
|
6730
|
+
pairsInto: route && toAddress ? pairPromotionsInto(promotionList, Number(route.receive.chainId), toAddress) : [],
|
|
6731
|
+
bonusEstimateRaw
|
|
6732
|
+
};
|
|
6733
|
+
}, [promotionList, selected]);
|
|
5341
6734
|
const quoteReady = status === "ready" && !!plan;
|
|
5342
6735
|
const quotePaused = quoteReady && idle2;
|
|
5343
6736
|
const quoteStale = quoteReady && (idle2 || planAt < returnedAt2);
|
|
@@ -5359,10 +6752,18 @@ function useFlow(args) {
|
|
|
5359
6752
|
quoteStale,
|
|
5360
6753
|
submit,
|
|
5361
6754
|
reload,
|
|
5362
|
-
addRoute
|
|
6755
|
+
addRoute,
|
|
6756
|
+
compare,
|
|
6757
|
+
selectOption,
|
|
6758
|
+
promotions
|
|
5363
6759
|
};
|
|
5364
6760
|
}
|
|
5365
6761
|
var RETRY_DELAYS_MS = [800, 2400, 6e3];
|
|
6762
|
+
var CATALOGUE_REFRESH_MS = 6e4 + 250;
|
|
6763
|
+
function catalogueSignature(c) {
|
|
6764
|
+
const ids = (list) => list.map((t) => `${Number(t.chainId)}:${String(t.address).toLowerCase()}`).join(",");
|
|
6765
|
+
return [ids(c.tokens), ids(c.sources), [...c.source].sort().join(","), [...c.destination].sort().join(","), [...c.lanes ?? []].sort().join(","), [...c.brokenLanes?.keys() ?? []].sort().join(","), [...c.limitedLanes.keys()].sort().join(",")].join("|");
|
|
6766
|
+
}
|
|
5366
6767
|
function useCatalogue(engine, options = {}) {
|
|
5367
6768
|
const { allowedAssets, product, solanaSources } = options;
|
|
5368
6769
|
const enabled = options.enabled !== false;
|
|
@@ -5379,7 +6780,10 @@ function useCatalogue(engine, options = {}) {
|
|
|
5379
6780
|
engine.fetchCatalogue(allowedAssets, product, solanaSources ? { solanaSources: true } : void 0).then((next) => {
|
|
5380
6781
|
if (!alive) return;
|
|
5381
6782
|
setCatalogue(next);
|
|
5382
|
-
if (next.ready)
|
|
6783
|
+
if (next.ready) {
|
|
6784
|
+
timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
|
|
6785
|
+
return;
|
|
6786
|
+
}
|
|
5383
6787
|
if (attempt >= RETRY_DELAYS_MS.length) {
|
|
5384
6788
|
setFailed(true);
|
|
5385
6789
|
return;
|
|
@@ -5387,6 +6791,23 @@ function useCatalogue(engine, options = {}) {
|
|
|
5387
6791
|
timer2 = setTimeout(read, RETRY_DELAYS_MS[attempt++]);
|
|
5388
6792
|
});
|
|
5389
6793
|
};
|
|
6794
|
+
const refresh = () => {
|
|
6795
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") {
|
|
6796
|
+
timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
|
|
6797
|
+
return;
|
|
6798
|
+
}
|
|
6799
|
+
if (isUserIdle()) {
|
|
6800
|
+
timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
|
|
6801
|
+
return;
|
|
6802
|
+
}
|
|
6803
|
+
engine.fetchCatalogue(allowedAssets, product, solanaSources ? { solanaSources: true } : void 0).then((next) => {
|
|
6804
|
+
if (!alive) return;
|
|
6805
|
+
if (next.ready) setCatalogue((prev) => prev?.ready && catalogueSignature(prev) === catalogueSignature(next) ? prev : next);
|
|
6806
|
+
}).catch(() => {
|
|
6807
|
+
}).finally(() => {
|
|
6808
|
+
if (alive) timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
|
|
6809
|
+
});
|
|
6810
|
+
};
|
|
5390
6811
|
read();
|
|
5391
6812
|
return () => {
|
|
5392
6813
|
alive = false;
|
|
@@ -5427,9 +6848,9 @@ function useHoldings(engine, account, routes, initialBalances) {
|
|
|
5427
6848
|
const seeded = {};
|
|
5428
6849
|
const missing = [];
|
|
5429
6850
|
for (const target of targets) {
|
|
5430
|
-
const
|
|
5431
|
-
const balance = initialBalances?.[
|
|
5432
|
-
if (balance) seeded[
|
|
6851
|
+
const key2 = balanceKey(target.chainId, target.tokenAddress);
|
|
6852
|
+
const balance = initialBalances?.[key2];
|
|
6853
|
+
if (balance) seeded[key2] = balance;
|
|
5433
6854
|
else missing.push(target);
|
|
5434
6855
|
}
|
|
5435
6856
|
setBalances(seeded);
|
|
@@ -6374,6 +7795,217 @@ button.sg-rcp-row:focus-visible{outline:2px solid var(--sg-accent);outline-offse
|
|
|
6374
7795
|
.sg-widget[data-sg-side]:has(>.sg-ws){display:flex;flex-direction:column}
|
|
6375
7796
|
.sg-widget[data-sg-side]>.sg-ws{flex:1 1 auto}
|
|
6376
7797
|
@media (prefers-reduced-motion:reduce){.sg-ws{animation:none}.sg-ws-spin{animation:none}}
|
|
7798
|
+
/* \u2500\u2500 Compliance details screen (ComplianceDetails) \u2014 Figma Widget Playground 3238:16033 / 16419 / 16879 / 17276 / 17894 \u2500\u2500 */
|
|
7799
|
+
.sg-cd{--sg-cd-r:min(var(--sg-radius-control),20px);--sg-t50:color-mix(in srgb,var(--sg-text) 50%,transparent);--sg-t25:color-mix(in srgb,var(--sg-text) 25%,transparent);display:flex;flex-direction:column;gap:12px;width:100%;box-sizing:border-box;animation:sg-cp-in var(--sg-motion-fast) var(--sg-ease-out-soft) both}
|
|
7800
|
+
.sg-cd:focus{outline:none}
|
|
7801
|
+
.sg-cd-back{position:relative;align-self:flex-start;display:inline-flex;align-items:center;gap:10px;margin:0 0 12px;padding:0;border:0;background:transparent;color:var(--sg-t50);font:inherit;font-size:14px;font-weight:500;line-height:1.2;cursor:pointer;transition:color 120ms ease}
|
|
7802
|
+
.sg-cd-back::after{content:"";position:absolute;inset:-12px -10px}
|
|
7803
|
+
.sg-cd-back:hover{color:var(--sg-text)}
|
|
7804
|
+
.sg-cd-back:focus-visible{outline:2px solid var(--sg-accent);outline-offset:4px;border-radius:6px}
|
|
7805
|
+
.sg-cd-title{margin:0;font-family:var(--sg-font-display);font-size:16px;font-weight:600;line-height:19.2px;letter-spacing:.32px;color:var(--sg-t90)}
|
|
7806
|
+
.sg-cd-tabs{display:flex;align-items:stretch;gap:0;padding:4px;border:1px solid var(--sg-border);border-radius:calc(var(--sg-cd-r) - 4px)}
|
|
7807
|
+
.sg-cd-tab{flex:1 0 0;display:inline-flex;align-items:center;justify-content:center;gap:8px;min-width:0;padding:13px 8px;border:0;border-radius:calc(var(--sg-cd-r) - 4px);background:transparent;color:var(--sg-t50);font:inherit;font-size:10px;font-weight:700;line-height:14px;text-transform:uppercase;letter-spacing:.2px;white-space:nowrap;cursor:pointer;transition:background 120ms ease,color 120ms ease}
|
|
7808
|
+
.sg-cd-tab:hover{color:var(--sg-text)}
|
|
7809
|
+
.sg-cd-tab[data-active="true"]{background:color-mix(in srgb,var(--sg-accent) 8%,transparent);color:var(--sg-accent)}
|
|
7810
|
+
.sg-cd-tab:focus-visible{outline:2px solid var(--sg-accent);outline-offset:-2px}
|
|
7811
|
+
.sg-cd-tab-count{font-weight:700;color:var(--sg-t25)}
|
|
7812
|
+
.sg-cd-tab[data-active="true"] .sg-cd-tab-count{color:color-mix(in srgb,var(--sg-accent) 50%,transparent)}
|
|
7813
|
+
.sg-cd-panel{display:flex;flex-direction:column;gap:6px;margin-top:-4px}
|
|
7814
|
+
.sg-cd-card{display:flex;flex-direction:column;gap:20px;padding:16px;border:1px solid var(--sg-border);border-radius:var(--sg-cd-r)}
|
|
7815
|
+
.sg-cd-card-head{display:flex;align-items:center;gap:8px}
|
|
7816
|
+
.sg-cd-card-glyph{display:flex;flex:0 0 auto;color:var(--sg-accent)}
|
|
7817
|
+
.sg-cd-card-title{margin:0;font-size:15px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
|
|
7818
|
+
.sg-cd-summary{display:flex;flex-direction:column;gap:4px}
|
|
7819
|
+
.sg-cd-summary-head{display:flex;align-items:center;gap:8px;color:var(--sg-ok-ink)}
|
|
7820
|
+
.sg-cd-summary-head[data-tone="neutral"]{color:var(--sg-t60)}
|
|
7821
|
+
.sg-cd-summary-head[data-tone="blocked"],.sg-cd-summary-head[data-tone="warn"]{color:var(--sg-danger)}
|
|
7822
|
+
.sg-cd-summary-title{font-size:14px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
|
|
7823
|
+
.sg-cd-summary-head[data-tone="blocked"] .sg-cd-summary-title,.sg-cd-summary-head[data-tone="warn"] .sg-cd-summary-title{color:var(--sg-danger)}
|
|
7824
|
+
.sg-cd-summary-sub{margin:0;padding-left:24px;font-size:13px;line-height:1.2;color:var(--sg-t50)}
|
|
7825
|
+
.sg-cd-checks{list-style:none;margin:2px 0 -1px;padding:0;display:flex;flex-direction:column;gap:12px}
|
|
7826
|
+
.sg-cd-card:has(.sg-cd-facts){gap:16px}
|
|
7827
|
+
.sg-cd-check-line{display:flex;align-items:center;gap:8px;min-width:0}
|
|
7828
|
+
.sg-cd-check-mark{display:flex;flex:0 0 auto;width:12px;justify-content:center;color:var(--sg-ok-ink)}
|
|
7829
|
+
.sg-cd-check-mark[data-ok="false"]{color:var(--sg-danger)}
|
|
7830
|
+
.sg-cd-check-label{font-size:14px;line-height:17px;color:var(--sg-t90)}
|
|
7831
|
+
.sg-cd-check[data-ok="false"] .sg-cd-check-label{color:var(--sg-danger)}
|
|
7832
|
+
.sg-cd-check-note,.sg-cd-check-reason{display:block;padding-left:26px;margin-top:3px;font-size:12px;line-height:1.4;color:var(--sg-t60);overflow-wrap:anywhere}
|
|
7833
|
+
.sg-cd-check-reason{color:var(--sg-danger)}
|
|
7834
|
+
.sg-cd-orphans{list-style:none;margin:0;padding:0 0 0 26px;display:flex;flex-direction:column;gap:3px;font-size:12px;line-height:1.4;color:var(--sg-danger)}
|
|
7835
|
+
.sg-cd-scope{margin:0;font-size:12px;line-height:1.45;color:var(--sg-t60)}
|
|
7836
|
+
.sg-cd-flags{margin:0;font-size:14px;color:var(--sg-t90)}
|
|
7837
|
+
.sg-cd-facts{margin:0;display:flex;flex-direction:column;gap:10px;padding-left:24px}
|
|
7838
|
+
.sg-cd-fact{display:grid;grid-template-columns:94px minmax(0,1fr);align-items:baseline;gap:0}
|
|
7839
|
+
.sg-cd-fact dt{font-size:13px;line-height:17px;color:var(--sg-t50)}
|
|
7840
|
+
.sg-cd-fact dd{margin:0;min-width:0;font-size:14px;line-height:17px;color:var(--sg-t90);overflow-wrap:anywhere}
|
|
7841
|
+
.sg-cd-policies{gap:6px}
|
|
7842
|
+
.sg-cd-policy{display:flex;flex-direction:column}
|
|
7843
|
+
.sg-cd-policy-head{position:relative;z-index:1;display:flex;align-items:center;gap:12px;width:100%;box-sizing:border-box;padding:21px 17px;border:1px solid var(--sg-border);border-radius:var(--sg-cd-r);background:var(--sg-bg);color:inherit;font:inherit;text-align:left}
|
|
7844
|
+
button.sg-cd-policy-head{cursor:pointer;transition:border-color 120ms ease}
|
|
7845
|
+
button.sg-cd-policy-head:hover{border-color:color-mix(in srgb,var(--sg-accent) 40%,var(--sg-border))}
|
|
7846
|
+
button.sg-cd-policy-head:focus-visible{outline:2px solid var(--sg-accent);outline-offset:2px}
|
|
7847
|
+
.sg-cd-policy-mark{display:flex;flex:0 0 auto;color:color-mix(in srgb,var(--sg-text) 45%,transparent)}
|
|
7848
|
+
.sg-cd-policy-text{display:flex;flex:1 1 auto;min-width:0;flex-direction:column;gap:6px}
|
|
7849
|
+
.sg-cd-policy-name{font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90);overflow-wrap:anywhere}
|
|
7850
|
+
.sg-cd-policy-sub{font-size:14px;line-height:18px;color:var(--sg-t60)}
|
|
7851
|
+
.sg-cd-policy-chev{display:flex;flex:0 0 auto;color:var(--sg-t90)}
|
|
7852
|
+
.sg-cd-policy-body{display:flex;flex-direction:column;gap:6px;margin-top:-24px;padding:40px 16px 16px;border-radius:var(--sg-cd-r);background:color-mix(in srgb,var(--sg-accent) 8%,transparent);animation:sg-cp-in var(--sg-motion-fast) var(--sg-ease-out-soft) both}
|
|
7853
|
+
.sg-cd-bucket{position:relative;display:flex;flex-direction:column;gap:12px;padding:12px 16px;border-radius:var(--sg-cd-r);background:var(--sg-bg)}
|
|
7854
|
+
.sg-cd-bucket-head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:4px 8px}
|
|
7855
|
+
.sg-cd-bucket[data-outcome] .sg-cd-bucket-head:has(.sg-cd-hint){justify-content:flex-start;align-items:center;gap:8px}
|
|
7856
|
+
.sg-cd-bucket-title{font-size:14px;font-weight:500;line-height:16px;color:var(--sg-t90)}
|
|
7857
|
+
.sg-cd-bucket-detail{font-size:12px;line-height:14px;color:var(--sg-t50)}
|
|
7858
|
+
.sg-cd-cats{list-style:none;margin:0;padding:0 0 0 8px;display:flex;flex-direction:column;gap:4px}
|
|
7859
|
+
.sg-cd-cats li{display:flex;align-items:center;gap:12px;font-size:13px;line-height:18px;color:var(--sg-t90)}
|
|
7860
|
+
.sg-cd-dot{flex:0 0 auto;width:4px;height:4px;border-radius:999px;background:var(--sg-t90)}
|
|
7861
|
+
.sg-cd-bucket[data-outcome="flagged"] .sg-cd-dot{background:var(--sg-accent);opacity:.8}
|
|
7862
|
+
.sg-cd-cats li .sg-cd-hint{margin-left:-6px}
|
|
7863
|
+
.sg-cd-hint{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:20px;height:20px;padding:0;border:0;border-radius:999px;background:transparent;color:var(--sg-t60);cursor:pointer;transition:color 120ms ease}
|
|
7864
|
+
.sg-cd-hint{position:relative}
|
|
7865
|
+
.sg-cd-hint::after{content:"";position:absolute;inset:-12px}
|
|
7866
|
+
.sg-cd-hint:hover,.sg-cd-hint[aria-expanded="true"]{color:var(--sg-accent)}
|
|
7867
|
+
.sg-cd-hint:focus-visible{outline:2px solid var(--sg-accent);outline-offset:1px}
|
|
7868
|
+
.sg-cd-tip{position:absolute;z-index:3;left:0;right:0;top:100%;margin-top:2px;padding:10px 12px;border-radius:12px;background:var(--sg-text);color:var(--sg-bg);font-size:12px;font-weight:400;line-height:1.4;text-align:left;pointer-events:none;box-shadow:0 6px 20px rgba(0,0,0,.18)}
|
|
7869
|
+
.sg-cd-cats li,.sg-cd-bucket-head{position:relative}
|
|
7870
|
+
.sg-cd-policy-version{margin:0;padding:4px 4px 0;font-size:12px;line-height:14px;color:var(--sg-t60);overflow-wrap:anywhere}
|
|
7871
|
+
/* Wide's second panel (layout="side", 280px): the same screen on a denser scale \u2014 Figma 3238:16419 / 18187 / 18446 */
|
|
7872
|
+
.sg-cd[data-layout="side"] .sg-cd-back{font-size:12px;font-weight:400;line-height:16px;margin-bottom:4px}
|
|
7873
|
+
.sg-cd[data-layout="side"] .sg-cd-title{margin-bottom:4px;font-family:inherit;font-size:16px;font-weight:500;line-height:1.2;letter-spacing:0}
|
|
7874
|
+
.sg-cd[data-layout="side"] .sg-cd-panel{margin-top:-8px}
|
|
7875
|
+
.sg-cd[data-layout="side"] .sg-cd-card{padding:16px 12px;gap:16px}
|
|
7876
|
+
.sg-cd[data-layout="side"] .sg-cd-card:has(.sg-cd-facts){gap:16px}
|
|
7877
|
+
.sg-cd[data-layout="side"] .sg-cd-card-title{font-size:14px}
|
|
7878
|
+
.sg-cd[data-layout="side"] .sg-cd-summary-head,.sg-cd[data-layout="side"] .sg-cd-card-head{gap:8px}
|
|
7879
|
+
.sg-cd[data-layout="side"] .sg-cd-summary-sub{padding-left:0;font-size:13px;line-height:16px}
|
|
7880
|
+
.sg-cd[data-layout="side"] .sg-cd-checks{gap:12px}
|
|
7881
|
+
.sg-cd[data-layout="side"] .sg-cd-check-label,.sg-cd[data-layout="side"] .sg-cd-fact dt,.sg-cd[data-layout="side"] .sg-cd-fact dd{font-size:13px;line-height:16px}
|
|
7882
|
+
.sg-cd[data-layout="side"] .sg-cd-facts{padding-left:24px;gap:10px}
|
|
7883
|
+
.sg-cd[data-layout="side"] .sg-cd-policy-head{gap:6px;padding:21px 13px}
|
|
7884
|
+
.sg-cd[data-layout="side"] .sg-cd-policy-text{gap:2px}
|
|
7885
|
+
.sg-cd[data-layout="side"] .sg-cd-policy-name{font-size:14px;line-height:1.2}
|
|
7886
|
+
.sg-cd[data-layout="side"] .sg-cd-policy-sub{font-size:13px;line-height:1.4}
|
|
7887
|
+
.sg-cd[data-layout="side"] .sg-cd-policy-mark svg{width:16px;height:16px}
|
|
7888
|
+
.sg-cd[data-layout="side"] .sg-cd-policy-body{padding:32px 8px 16px}
|
|
7889
|
+
.sg-cd[data-layout="side"] .sg-cd-bucket{gap:8px;padding:12px 16px;border-radius:16px}
|
|
7890
|
+
@media (prefers-reduced-motion:reduce){.sg-cd,.sg-cd-policy-body{animation:none}}
|
|
7891
|
+
/* \u2500\u2500 Compare quotes \u2014 Figma Widget Playground 3237:13270 / 3237:13581 / 3237:13897 / 3237:14224 (2026-11-13) \u2500\u2500 */
|
|
7892
|
+
.sg-widget{--sg-a5:color-mix(in srgb,var(--sg-accent) 5%,transparent);--sg-a8:color-mix(in srgb,var(--sg-accent) 8%,transparent);--sg-a50:color-mix(in srgb,var(--sg-accent) 50%,transparent);--sg-purple:#4f24b4;--sg-green-12:color-mix(in srgb,var(--sg-ok-ink) 12%,transparent);--sg-cq-dot:#8fb8b4}
|
|
7893
|
+
.sg-widget[data-sg-mode="dark"]{--sg-purple:#b79cff;--sg-cq-dot:color-mix(in srgb,var(--sg-text) 50%,transparent)}
|
|
7894
|
+
.sg-ws-titlerow{display:flex;align-items:center;gap:12px}
|
|
7895
|
+
.sg-cq-refresh{display:flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:0;border-radius:4px;background:transparent;color:var(--sg-accent);cursor:pointer}
|
|
7896
|
+
.sg-cq-refresh:focus-visible,.sg-cq-main:focus-visible,.sg-cq-route-toggle:focus-visible,.sg-cq-info:focus-visible,.sg-cq-gap:focus-visible{outline:2px solid var(--sg-accent);outline-offset:2px}
|
|
7897
|
+
.sg-cq-spin{animation:sg-spin 900ms linear infinite}
|
|
7898
|
+
.sg-cq{display:flex;flex-direction:column;gap:16px}
|
|
7899
|
+
.sg-cq-wait{display:flex;flex-direction:column;gap:20px;padding:16px 12px 20px;border-radius:24px;background:var(--sg-a5)}
|
|
7900
|
+
.sg-cq-wait-top{display:flex;flex-direction:column;gap:8px}
|
|
7901
|
+
.sg-cq-wait-row{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;font-size:13px;line-height:1.4;color:var(--sg-t80)}
|
|
7902
|
+
.sg-cq-wait-scale{display:flex;flex-direction:column;gap:12px}
|
|
7903
|
+
.sg-cq-track{position:relative;width:100%;height:20px}
|
|
7904
|
+
.sg-cq-range{position:absolute;inset:0;z-index:1;width:100%;height:100%;margin:0;padding:0;border-radius:10px;opacity:0;cursor:pointer;appearance:none;-webkit-appearance:none}
|
|
7905
|
+
.sg-cq-rail{position:absolute;inset:0;overflow:hidden;border-radius:10px;border:1px solid color-mix(in srgb,var(--sg-bg) 80%,transparent);background:var(--sg-a8) repeating-linear-gradient(120deg,transparent 0 5.06px,color-mix(in srgb,var(--sg-bg) 30%,transparent) 5.06px 9.06px)}
|
|
7906
|
+
.sg-cq-range:focus-visible~.sg-cq-rail{outline:2px solid var(--sg-accent);outline-offset:2px}
|
|
7907
|
+
.sg-cq-thumb{position:absolute;left:2px;top:2px;bottom:2px;display:flex;align-items:center;justify-content:flex-end;border-radius:8px;border:1px solid var(--sg-bg);background:var(--sg-accent)}
|
|
7908
|
+
.sg-cq-thumb svg{flex:0 0 auto;margin-right:1px}
|
|
7909
|
+
.sg-cq-ends{position:relative;display:flex;align-items:center;justify-content:space-between;font-size:12px;font-weight:500;line-height:1.2;color:var(--sg-t50)}
|
|
7910
|
+
.sg-cq-parity{position:absolute;top:calc(50% + 2px);transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;padding:4px 8px;border-radius:8px;background:var(--sg-a8);font-size:11px;line-height:1.3;text-align:center;color:color-mix(in srgb,var(--sg-accent) 80%,var(--sg-text))}
|
|
7911
|
+
.sg-cq-parity-none{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);white-space:nowrap;font-size:11px;font-weight:400;color:var(--sg-t50)}
|
|
7912
|
+
.sg-cq-rule{height:1px;margin-top:-1px;background:var(--sg-a12)}
|
|
7913
|
+
.sg-cq-extra{display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;gap:8px}
|
|
7914
|
+
.sg-cq-extra-icon{flex:0 0 auto;align-self:center;display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:999px;background:var(--sg-green-12);color:var(--sg-ok-ink)}
|
|
7915
|
+
.sg-cq-extra-icon svg{width:16px;height:16px}
|
|
7916
|
+
.sg-cq-extra-text{display:flex;flex:0 1 auto;min-width:0;flex-direction:column;justify-content:center;gap:0;margin-right:auto}
|
|
7917
|
+
.sg-cq-parity{white-space:nowrap}
|
|
7918
|
+
.sg-ws:has(.sg-cq) .sg-ws-top{gap:24px}
|
|
7919
|
+
.sg-cq-info,.sg-cq-gap{padding:0;border:0;background:transparent;font:inherit}
|
|
7920
|
+
.sg-cq-extra-label{display:flex;align-items:center;gap:6px;white-space:nowrap;font-size:12px;line-height:1.2;color:var(--sg-t50)}
|
|
7921
|
+
.sg-cq-extra-amt{white-space:nowrap;font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
|
|
7922
|
+
.sg-cq-extra-note{align-self:center;flex:0 0 auto;margin-left:auto;min-width:0;white-space:nowrap;text-align:right;font-size:9px;line-height:1.2;color:var(--sg-t50)}
|
|
7923
|
+
.sg-cq-info{display:inline-flex;border-radius:4px;color:var(--sg-t50);cursor:help}
|
|
7924
|
+
.sg-cq-list{display:flex;flex-direction:column;gap:8px}
|
|
7925
|
+
.sg-cq-empty{margin:0;padding:24px 0;text-align:center;font-size:13px;line-height:1.4;color:var(--sg-t50)}
|
|
7926
|
+
.sg-cq-card{position:relative;display:flex;flex-direction:column;gap:16px;overflow:clip;padding:16px 12px;border-radius:20px;border:1px solid var(--sg-a12);background:var(--sg-bg)}
|
|
7927
|
+
.sg-cq-card[data-selected]{border-color:color-mix(in srgb,var(--sg-accent) 80%,transparent)}
|
|
7928
|
+
.sg-cq-card[data-unavailable]{background:var(--sg-a4);opacity:.6;filter:grayscale(1)}
|
|
7929
|
+
.sg-cq-main{display:flex;flex-direction:column;align-items:flex-start;gap:20px;width:100%;padding:0;border:0;border-radius:20px;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
|
|
7930
|
+
.sg-cq-main:disabled{cursor:not-allowed}
|
|
7931
|
+
.sg-cq-head{display:flex;align-items:flex-start;gap:8px;width:100%;padding-right:min(150px,42%)}
|
|
7932
|
+
.sg-cq-radio{flex:0 0 auto;display:grid;place-items:center;width:16px;height:16px;margin-top:1.6px;border-radius:999px;border:1px solid var(--sg-a50)}
|
|
7933
|
+
.sg-cq-radio[data-on]{border-color:var(--sg-accent)}
|
|
7934
|
+
.sg-cq-radio[data-on]::after{content:"";width:8px;height:8px;border-radius:999px;background:var(--sg-accent)}
|
|
7935
|
+
.sg-cq-amount{min-width:0;font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
|
|
7936
|
+
.sg-cq-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
|
|
7937
|
+
.sg-cq-tag{position:absolute;top:-2px;right:-2px;display:flex;align-items:center;gap:8px;padding:10px 32px 12px;border-radius:0 0 0 40px;background:var(--sg-a8);font-size:12px;font-weight:500;line-height:1.4;letter-spacing:.12px}
|
|
7938
|
+
.sg-cq-tag[data-kind="netting"]{background:var(--sg-green-12)}
|
|
7939
|
+
.sg-cq-tag[data-kind="purple"]{background:color-mix(in srgb,var(--sg-purple) 8%,transparent)}
|
|
7940
|
+
.sg-cq-tag-item{display:flex;align-items:center;gap:8px;white-space:nowrap}
|
|
7941
|
+
.sg-cq-tag-dot{width:4px;height:4px;border-radius:999px;background:var(--sg-cq-dot)}
|
|
7942
|
+
.sg-overlay[data-sg-overlay="drawer"] .sg-cq[data-layout="card"] .sg-cq-tag{padding:10px 20px 12px;border-radius:0 0 0 32px;font-size:11px;letter-spacing:.11px;gap:6px}
|
|
7943
|
+
.sg-cq-tag [data-tone="brand"]{color:var(--sg-accent)}
|
|
7944
|
+
.sg-cq-tag [data-tone="green"]{color:var(--sg-ok-ink)}
|
|
7945
|
+
.sg-cq-tag [data-tone="purple"]{color:var(--sg-purple)}
|
|
7946
|
+
.sg-widget[data-sg-mode="dark"] .sg-cq-tag [data-tone="brand"]{color:var(--sg-info)}
|
|
7947
|
+
.sg-cq-stats{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:0 12px 0 24px}
|
|
7948
|
+
.sg-cq-cols{display:flex;align-items:center;gap:32px;white-space:nowrap}
|
|
7949
|
+
.sg-cq-col{display:flex;flex-direction:column;justify-content:center;gap:6px}
|
|
7950
|
+
.sg-cq-col-label{font-size:10px;font-weight:500;line-height:1.2;text-transform:uppercase;color:var(--sg-t50)}
|
|
7951
|
+
.sg-cq-col-value{font-size:14px;line-height:1.2;color:var(--sg-text)}
|
|
7952
|
+
.sg-cq-note{width:125px;text-align:right;font-size:12px;line-height:1.2;color:var(--sg-t50)}
|
|
7953
|
+
.sg-cq-why{padding-left:24px;font-size:13px;line-height:1.3;color:var(--sg-t50)}
|
|
7954
|
+
.sg-cq-route{display:flex;flex-direction:column;gap:10px;padding-left:24px}
|
|
7955
|
+
.sg-cq-route-toggle{display:flex;align-items:center;gap:4px;width:fit-content;padding:0;border:0;border-radius:4px;background:transparent;font:inherit;font-size:10px;font-weight:500;line-height:1.2;text-transform:uppercase;color:var(--sg-t50);cursor:pointer}
|
|
7956
|
+
.sg-cq-route-toggle svg{color:var(--sg-text)}
|
|
7957
|
+
.sg-cq-hops{display:flex;flex-wrap:wrap;align-items:flex-start;gap:4px}
|
|
7958
|
+
.sg-cq-hop{display:flex;align-items:flex-start;gap:4px}
|
|
7959
|
+
.sg-cq-arrow{flex:0 0 auto;color:var(--sg-accent)}
|
|
7960
|
+
.sg-cq-hop-body{display:flex;flex-direction:column;gap:4px}
|
|
7961
|
+
.sg-cq-hop-name{display:flex;align-items:center;gap:4px;font-size:14px;line-height:1.2;color:var(--sg-text)}
|
|
7962
|
+
.sg-cq-hop-chain{white-space:nowrap;font-size:12px;line-height:1.2;color:var(--sg-t50)}
|
|
7963
|
+
.sg-cq .sg-tok[data-size="xxs"] .sg-tok-badge{min-width:8px;width:8px;height:8px;right:-1px;bottom:-1px;border-width:1px;border-color:var(--sg-bg);font-size:4px;padding:0}
|
|
7964
|
+
.sg-cq .sg-tok[data-size="xs"] .sg-tok-badge{min-width:11px;width:11px;height:11px;right:-3px;bottom:-3px;border-width:1px;border-color:var(--sg-bg);font-size:4px;padding:0}
|
|
7965
|
+
/* Back-link and gap scoped to Compare quotes (Figma: 14px t50 compact, 12px t50 wide, 24px/16px to the title). */
|
|
7966
|
+
.sg-ws:has(.sg-cq) .sg-ws-back{font-size:14px;font-weight:500;color:var(--sg-t50)}
|
|
7967
|
+
.sg-dialog .sg-ws:has(.sg-cq):not([data-wide]) .sg-ws-top{gap:16px}
|
|
7968
|
+
/* Wide: compact cards, the tag a centred band across the card's top, the route as inline marks */
|
|
7969
|
+
.sg-cq[data-layout="side"] .sg-cq-card{gap:12px;padding:0 0 16px;border-radius:20px}
|
|
7970
|
+
.sg-cq[data-layout="side"] .sg-cq-tag{position:static;justify-content:center;width:100%;padding:2px 20px 4px;border-radius:0;font-size:11px;line-height:1.4;letter-spacing:.11px;gap:6px}
|
|
7971
|
+
.sg-ws[data-wide]:has(.sg-cq) .sg-ws-top{gap:16px}
|
|
7972
|
+
.sg-ws[data-wide]:has(.sg-cq) .sg-ws-title{font-size:16px}
|
|
7973
|
+
.sg-ws[data-wide]:has(.sg-cq) .sg-ws-back{font-size:12px;font-weight:400;color:var(--sg-t50)}
|
|
7974
|
+
.sg-cq[data-layout="side"]{gap:12px}
|
|
7975
|
+
.sg-cq[data-layout="side"] .sg-cq-wait{padding:16px 12px 20px;gap:20px}
|
|
7976
|
+
.sg-cq[data-layout="side"] .sg-cq-rule{margin-bottom:-8px}
|
|
7977
|
+
.sg-cq[data-layout="side"] .sg-cq-card:not(:has(.sg-cq-tag)){padding-top:12px}
|
|
7978
|
+
.sg-cq[data-layout="side"] .sg-cq-main{gap:20px;padding:0 12px;border-radius:0}
|
|
7979
|
+
.sg-cq[data-layout="side"] .sg-cq-head{padding-right:0!important}
|
|
7980
|
+
.sg-cq[data-layout="side"] .sg-cq-amount{font-size:15px}
|
|
7981
|
+
.sg-cq[data-layout="side"] .sg-cq-stats{padding:0}
|
|
7982
|
+
.sg-cq[data-layout="side"] .sg-cq-cols{gap:20px}
|
|
7983
|
+
.sg-cq[data-layout="side"] .sg-cq-col{gap:4px}
|
|
7984
|
+
.sg-cq[data-layout="side"] .sg-cq-col-label{font-size:9px}
|
|
7985
|
+
.sg-cq[data-layout="side"] .sg-cq-col-value{font-size:13px}
|
|
7986
|
+
.sg-cq[data-layout="side"] .sg-cq-card[data-selected]{border-color:color-mix(in srgb,var(--sg-accent) 50%,transparent)}
|
|
7987
|
+
.sg-cq[data-layout="side"] .sg-cq-extra-amt{font-size:15px}
|
|
7988
|
+
.sg-cq[data-layout="side"] .sg-cq-extra-label{gap:4px}
|
|
7989
|
+
.sg-cq[data-layout="side"] .sg-cq-info svg{width:12px;height:12px}
|
|
7990
|
+
.sg-cq[data-layout="side"] .sg-cq-card:not(:has(.sg-cq-tag)) .sg-cq-main{padding-top:0}
|
|
7991
|
+
.sg-cq-route-icons{display:flex;align-items:center;gap:2px}
|
|
7992
|
+
.sg-cq-route-icons .sg-cq-arrow{width:10px;height:10px}
|
|
7993
|
+
.sg-cq-hop-inline{display:flex;align-items:center;gap:2px}
|
|
7994
|
+
.sg-cq-hop-inline>span{display:flex}
|
|
7995
|
+
.sg-cq-gap{display:inline-flex;padding:0 2px;border-radius:4px;color:var(--sg-accent);text-decoration:underline;cursor:help}
|
|
7996
|
+
.sg-cq[data-layout="side"] .sg-cq-wait-scale .sg-cq-parity{flex-direction:row;gap:4px}
|
|
7997
|
+
/* Below Figma's widths the cards must shrink, not clip (narrow page; container = the sheet). */
|
|
7998
|
+
.sg-ws:has(.sg-cq){container-type:inline-size}
|
|
7999
|
+
@container (max-width:300px){
|
|
8000
|
+
.sg-cq-head{padding-right:0!important}
|
|
8001
|
+
.sg-cq-stats{flex-wrap:wrap;gap:8px;padding-left:0}
|
|
8002
|
+
.sg-cq-cols{flex-wrap:wrap;gap:12px;white-space:normal}
|
|
8003
|
+
.sg-cq-note{width:auto;max-width:100%;text-align:left}
|
|
8004
|
+
.sg-cq-route-icons{flex-wrap:wrap}
|
|
8005
|
+
.sg-cq-extra{flex-wrap:wrap}
|
|
8006
|
+
.sg-cq-extra-note{margin-left:0;text-align:left}
|
|
8007
|
+
}
|
|
8008
|
+
@media (prefers-reduced-motion:reduce){.sg-cq-spin{animation:none}}
|
|
6377
8009
|
`;
|
|
6378
8010
|
var injected = false;
|
|
6379
8011
|
function injectStyles() {
|
|
@@ -6953,7 +8585,7 @@ function priceOf(prices, symbol) {
|
|
|
6953
8585
|
const p = prices?.[String(symbol).toUpperCase()];
|
|
6954
8586
|
return typeof p === "number" && Number.isFinite(p) ? p : void 0;
|
|
6955
8587
|
}
|
|
6956
|
-
function buildGroup(
|
|
8588
|
+
function buildGroup(key2, members, prices) {
|
|
6957
8589
|
const tokens = members.map((m) => m.token);
|
|
6958
8590
|
let amount = null;
|
|
6959
8591
|
let usd2 = null;
|
|
@@ -6965,7 +8597,7 @@ function buildGroup(key, members, prices) {
|
|
|
6965
8597
|
}
|
|
6966
8598
|
const first = members[0].token;
|
|
6967
8599
|
return {
|
|
6968
|
-
key,
|
|
8600
|
+
key: key2,
|
|
6969
8601
|
symbol: dominantSymbol(tokens),
|
|
6970
8602
|
name: String(first.name || first.symbol),
|
|
6971
8603
|
logoUrl: first.logoUrl,
|
|
@@ -6986,15 +8618,15 @@ function groupDeployments(deployments, prices) {
|
|
|
6986
8618
|
const order = [];
|
|
6987
8619
|
const members = /* @__PURE__ */ new Map();
|
|
6988
8620
|
for (const d of [...deployments].sort(byDeployment)) {
|
|
6989
|
-
const
|
|
6990
|
-
const list = members.get(
|
|
8621
|
+
const key2 = String(d.token.symbol).toUpperCase();
|
|
8622
|
+
const list = members.get(key2);
|
|
6991
8623
|
if (list) list.push(d);
|
|
6992
8624
|
else {
|
|
6993
|
-
members.set(
|
|
6994
|
-
order.push(
|
|
8625
|
+
members.set(key2, [d]);
|
|
8626
|
+
order.push(key2);
|
|
6995
8627
|
}
|
|
6996
8628
|
}
|
|
6997
|
-
return order.map((
|
|
8629
|
+
return order.map((key2) => buildGroup(key2, members.get(key2), prices)).sort(byPickability);
|
|
6998
8630
|
}
|
|
6999
8631
|
var CHAIN_ALIASES = {
|
|
7000
8632
|
56: ["bsc", "binance"],
|
|
@@ -7002,10 +8634,10 @@ var CHAIN_ALIASES = {
|
|
|
7002
8634
|
43114: ["avax"]
|
|
7003
8635
|
};
|
|
7004
8636
|
function labelForms(label2) {
|
|
7005
|
-
const
|
|
7006
|
-
if (!
|
|
7007
|
-
const compact =
|
|
7008
|
-
return compact && compact !==
|
|
8637
|
+
const lower3 = label2.trim().toLowerCase();
|
|
8638
|
+
if (!lower3) return [];
|
|
8639
|
+
const compact = lower3.replace(/[^a-z0-9]/g, "");
|
|
8640
|
+
return compact && compact !== lower3 ? [lower3, compact] : [lower3];
|
|
7009
8641
|
}
|
|
7010
8642
|
function buildChainSearchTerms(chains) {
|
|
7011
8643
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -7058,7 +8690,7 @@ function groupDecimal2(value) {
|
|
|
7058
8690
|
if (!match) return value;
|
|
7059
8691
|
return `${match[1]}${match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${match[3] ?? ""}`;
|
|
7060
8692
|
}
|
|
7061
|
-
function
|
|
8693
|
+
function humanAmount2(n, maxFrac = 6) {
|
|
7062
8694
|
if (!Number.isFinite(n)) return String(n);
|
|
7063
8695
|
if (n === 0) return "0";
|
|
7064
8696
|
const digits = Math.min(Math.max(0, Math.trunc(maxFrac)), 8);
|
|
@@ -7194,7 +8826,7 @@ function BalanceColumn(props) {
|
|
|
7194
8826
|
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal", children: [
|
|
7195
8827
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-usd sg-mono", children: props.usd == null ? "\u2014" : formatBalanceUsd(props.usd) }),
|
|
7196
8828
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal-amt sg-mono", children: [
|
|
7197
|
-
|
|
8829
|
+
humanAmount2(props.amount, 6),
|
|
7198
8830
|
" ",
|
|
7199
8831
|
props.symbol
|
|
7200
8832
|
] })
|
|
@@ -7268,14 +8900,14 @@ function TokenSelect(props) {
|
|
|
7268
8900
|
const groups = react.useMemo(() => {
|
|
7269
8901
|
const deployments = [];
|
|
7270
8902
|
for (const token of props.tokens) {
|
|
7271
|
-
const
|
|
7272
|
-
const n = Number(props.balances?.[
|
|
7273
|
-
const st = props.optionStates?.[
|
|
8903
|
+
const key2 = rowKey(token);
|
|
8904
|
+
const n = Number(props.balances?.[key2]?.formatted);
|
|
8905
|
+
const st = props.optionStates?.[key2];
|
|
7274
8906
|
if (st?.disabled && !WALLET_STATE_REASONS.has(String(st.reason))) continue;
|
|
7275
8907
|
deployments.push({
|
|
7276
8908
|
token,
|
|
7277
|
-
key,
|
|
7278
|
-
balance: showBalances && props.balances?.[
|
|
8909
|
+
key: key2,
|
|
8910
|
+
balance: showBalances && props.balances?.[key2] && Number.isFinite(n) ? n : null,
|
|
7279
8911
|
disabled: !!st?.disabled,
|
|
7280
8912
|
// The line under a greyed row says why. Callers send either a sentence in `reason` (the
|
|
7281
8913
|
// exchange's "cannot be delivered on this chain") or a machine code there with the words in
|
|
@@ -7647,7 +9279,7 @@ function WidgetShell(props) {
|
|
|
7647
9279
|
}
|
|
7648
9280
|
);
|
|
7649
9281
|
}
|
|
7650
|
-
function
|
|
9282
|
+
function shortAddress3(a) {
|
|
7651
9283
|
if (!a) return "";
|
|
7652
9284
|
return `${a.slice(0, 6)}\u2026${a.slice(-4)}`;
|
|
7653
9285
|
}
|
|
@@ -7916,13 +9548,13 @@ function useTxHistory(account) {
|
|
|
7916
9548
|
react.useEffect(() => {
|
|
7917
9549
|
setEntries(readTxHistory(account));
|
|
7918
9550
|
if (typeof window === "undefined" || !account) return;
|
|
7919
|
-
const
|
|
9551
|
+
const key2 = txHistoryKey(account);
|
|
7920
9552
|
const onLocal = (e) => {
|
|
7921
9553
|
const detail = e.detail;
|
|
7922
9554
|
if (!detail?.account || detail.account === account.toLowerCase()) setEntries(readTxHistory(account));
|
|
7923
9555
|
};
|
|
7924
9556
|
const onStorage = (e) => {
|
|
7925
|
-
if (e.key ===
|
|
9557
|
+
if (e.key === key2) setEntries(readTxHistory(account));
|
|
7926
9558
|
};
|
|
7927
9559
|
window.addEventListener(TX_HISTORY_EVENT, onLocal);
|
|
7928
9560
|
window.addEventListener("storage", onStorage);
|
|
@@ -7938,10 +9570,10 @@ var hidden2 = () => typeof document !== "undefined" && document.visibilityState
|
|
|
7938
9570
|
var travelling = (entries) => !!entries?.some((e) => e.delivery === "in-progress" || e.delivery === "attention");
|
|
7939
9571
|
function useWalletHistory(engine, wallets) {
|
|
7940
9572
|
const [entries, setEntries] = react.useState(null);
|
|
7941
|
-
const
|
|
9573
|
+
const key2 = wallets.filter((w) => !!w).join("|");
|
|
7942
9574
|
react.useEffect(() => {
|
|
7943
9575
|
setEntries(null);
|
|
7944
|
-
if (!engine || !
|
|
9576
|
+
if (!engine || !key2) return;
|
|
7945
9577
|
let alive = true;
|
|
7946
9578
|
let timer2;
|
|
7947
9579
|
let started2 = Date.now();
|
|
@@ -7949,7 +9581,7 @@ function useWalletHistory(engine, wallets) {
|
|
|
7949
9581
|
if (timer2) clearTimeout(timer2);
|
|
7950
9582
|
timer2 = void 0;
|
|
7951
9583
|
if (!hidden2()) {
|
|
7952
|
-
const next = await engine.fetchWalletHistory(
|
|
9584
|
+
const next = await engine.fetchWalletHistory(key2.split("|"));
|
|
7953
9585
|
if (!alive) return;
|
|
7954
9586
|
if (next) setEntries(next);
|
|
7955
9587
|
if (!travelling(next)) return;
|
|
@@ -7968,7 +9600,7 @@ function useWalletHistory(engine, wallets) {
|
|
|
7968
9600
|
if (timer2) clearTimeout(timer2);
|
|
7969
9601
|
if (typeof window !== "undefined") window.removeEventListener(TX_HISTORY_EVENT, onRecorded);
|
|
7970
9602
|
};
|
|
7971
|
-
}, [engine,
|
|
9603
|
+
}, [engine, key2]);
|
|
7972
9604
|
return entries;
|
|
7973
9605
|
}
|
|
7974
9606
|
function BackGlyph() {
|
|
@@ -8105,15 +9737,15 @@ function TxPair(props) {
|
|
|
8105
9737
|
] });
|
|
8106
9738
|
}
|
|
8107
9739
|
function logoFor(art, symbol, chainId) {
|
|
8108
|
-
const
|
|
8109
|
-
if (!
|
|
9740
|
+
const key2 = symbolKey(symbol);
|
|
9741
|
+
if (!key2) return void 0;
|
|
8110
9742
|
const tokens = art.tokens;
|
|
8111
9743
|
if (tokens?.length) {
|
|
8112
|
-
const sameChain = chainId == null ? void 0 : tokens.find((t) => Number(t.chainId) === chainId && symbolKey(t.symbol) ===
|
|
8113
|
-
const found = (sameChain ?? tokens.find((t) => symbolKey(t.symbol) ===
|
|
9744
|
+
const sameChain = chainId == null ? void 0 : tokens.find((t) => Number(t.chainId) === chainId && symbolKey(t.symbol) === key2);
|
|
9745
|
+
const found = (sameChain ?? tokens.find((t) => symbolKey(t.symbol) === key2))?.logoUrl;
|
|
8114
9746
|
if (found) return found;
|
|
8115
9747
|
}
|
|
8116
|
-
return art.vaultIcons?.get(
|
|
9748
|
+
return art.vaultIcons?.get(key2);
|
|
8117
9749
|
}
|
|
8118
9750
|
function TxHistoryList(props) {
|
|
8119
9751
|
if (!props.entries.length) {
|
|
@@ -8190,7 +9822,7 @@ function TxDetail(props) {
|
|
|
8190
9822
|
] }),
|
|
8191
9823
|
e.recipient ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
|
|
8192
9824
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Recipient" }),
|
|
8193
|
-
/* @__PURE__ */ jsxRuntime.jsx("b", { className: "sg-mono", children:
|
|
9825
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { className: "sg-mono", children: shortAddress3(e.recipient) })
|
|
8194
9826
|
] }) : null,
|
|
8195
9827
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
|
|
8196
9828
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Settlement" }),
|
|
@@ -8227,7 +9859,7 @@ function TxHistoryPanel(props) {
|
|
|
8227
9859
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", autoFocus: true, ref: backRef, className: "sg-back", onClick: selected ? () => setSelectedHash(null) : props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx(BackGlyph, {}) }),
|
|
8228
9860
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-title", children: [
|
|
8229
9861
|
selected ? "Transaction" : "Transaction history",
|
|
8230
|
-
account ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sel-sub sg-mono", children:
|
|
9862
|
+
account ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress3(account) }) : null
|
|
8231
9863
|
] })
|
|
8232
9864
|
] }),
|
|
8233
9865
|
selected ? /* @__PURE__ */ jsxRuntime.jsx(TxDetail, { entry: selected, tokens: props.tokens, vaultIcons: props.vaultIcons }) : /* @__PURE__ */ jsxRuntime.jsx(TxHistoryList, { entries, tokens: props.tokens, vaultIcons: props.vaultIcons, onPick: pick })
|
|
@@ -8409,8 +10041,8 @@ function onSolanaAccountChange(info, cb) {
|
|
|
8409
10041
|
}
|
|
8410
10042
|
}) ?? (() => {
|
|
8411
10043
|
});
|
|
8412
|
-
const changed = (
|
|
8413
|
-
const address = validAddress(
|
|
10044
|
+
const changed = (key2) => {
|
|
10045
|
+
const address = validAddress(key2);
|
|
8414
10046
|
connected.set(provider, address ? [{ address }] : []);
|
|
8415
10047
|
cb(address);
|
|
8416
10048
|
};
|
|
@@ -8567,96 +10199,20 @@ function useRecipient(destinationChainId, hostRecipient, opts = {}) {
|
|
|
8567
10199
|
else opts.evm?.connect();
|
|
8568
10200
|
return;
|
|
8569
10201
|
}
|
|
8570
|
-
if (wallet.address && !name) {
|
|
8571
|
-
selectAddress("");
|
|
8572
|
-
return;
|
|
8573
|
-
}
|
|
8574
|
-
if (!name && wallet.wallets.length !== 1) {
|
|
8575
|
-
setOpen(true);
|
|
8576
|
-
return;
|
|
8577
|
-
}
|
|
8578
|
-
const address = await wallet.connect(name);
|
|
8579
|
-
if (typeof address === "string") selectAddress("");
|
|
8580
|
-
else setOpen(true);
|
|
8581
|
-
};
|
|
8582
|
-
const recipientFor = (account) => required ? recipient2 || "" : hostRecipient || custom.evm || account;
|
|
8583
|
-
return { recipientFamily, recipientChainId: destinationChainId, recipient: recipient2, shown, typed, recipientFor, managed, missing, error, wallet, familyWallet, wallets, open: open && managed, show: () => setOpen(true), close, selectAddress, connect, triggerRef };
|
|
8584
|
-
}
|
|
8585
|
-
|
|
8586
|
-
// src/core/checksum.ts
|
|
8587
|
-
var RC = [
|
|
8588
|
-
0x0000000000000001n,
|
|
8589
|
-
0x0000000000008082n,
|
|
8590
|
-
0x800000000000808an,
|
|
8591
|
-
0x8000000080008000n,
|
|
8592
|
-
0x000000000000808bn,
|
|
8593
|
-
0x0000000080000001n,
|
|
8594
|
-
0x8000000080008081n,
|
|
8595
|
-
0x8000000000008009n,
|
|
8596
|
-
0x000000000000008an,
|
|
8597
|
-
0x0000000000000088n,
|
|
8598
|
-
0x0000000080008009n,
|
|
8599
|
-
0x000000008000000an,
|
|
8600
|
-
0x000000008000808bn,
|
|
8601
|
-
0x800000000000008bn,
|
|
8602
|
-
0x8000000000008089n,
|
|
8603
|
-
0x8000000000008003n,
|
|
8604
|
-
0x8000000000008002n,
|
|
8605
|
-
0x8000000000000080n,
|
|
8606
|
-
0x000000000000800an,
|
|
8607
|
-
0x800000008000000an,
|
|
8608
|
-
0x8000000080008081n,
|
|
8609
|
-
0x8000000000008080n,
|
|
8610
|
-
0x0000000080000001n,
|
|
8611
|
-
0x8000000080008008n
|
|
8612
|
-
];
|
|
8613
|
-
var ROT = [0, 1, 62, 28, 27, 36, 44, 6, 55, 20, 3, 10, 43, 25, 39, 41, 45, 15, 21, 8, 18, 2, 61, 56, 14];
|
|
8614
|
-
var MASK = (1n << 64n) - 1n;
|
|
8615
|
-
var rotl = (x, n) => n === 0 ? x : (x << BigInt(n) | x >> BigInt(64 - n)) & MASK;
|
|
8616
|
-
function keccakF(s) {
|
|
8617
|
-
for (let round = 0; round < 24; round++) {
|
|
8618
|
-
const c = [0, 1, 2, 3, 4].map((x) => s[x] ^ s[x + 5] ^ s[x + 10] ^ s[x + 15] ^ s[x + 20]);
|
|
8619
|
-
for (let x = 0; x < 5; x++) {
|
|
8620
|
-
const d = c[(x + 4) % 5] ^ rotl(c[(x + 1) % 5], 1);
|
|
8621
|
-
for (let y = 0; y < 25; y += 5) s[y + x] = s[y + x] ^ d;
|
|
10202
|
+
if (wallet.address && !name) {
|
|
10203
|
+
selectAddress("");
|
|
10204
|
+
return;
|
|
8622
10205
|
}
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
s[0] = s[0] ^ RC[round];
|
|
8627
|
-
}
|
|
8628
|
-
}
|
|
8629
|
-
function keccak256Hex(bytes) {
|
|
8630
|
-
const rate = 136;
|
|
8631
|
-
const padded = new Uint8Array(Math.ceil((bytes.length + 1) / rate) * rate);
|
|
8632
|
-
padded.set(bytes);
|
|
8633
|
-
padded[bytes.length] = padded[bytes.length] ^ 1;
|
|
8634
|
-
padded[padded.length - 1] = padded[padded.length - 1] ^ 128;
|
|
8635
|
-
const s = new Array(25).fill(0n);
|
|
8636
|
-
for (let off = 0; off < padded.length; off += rate) {
|
|
8637
|
-
for (let i = 0; i < rate / 8; i++) {
|
|
8638
|
-
let lane = 0n;
|
|
8639
|
-
for (let j = 7; j >= 0; j--) lane = lane << 8n | BigInt(padded[off + i * 8 + j]);
|
|
8640
|
-
s[i] = s[i] ^ lane;
|
|
10206
|
+
if (!name && wallet.wallets.length !== 1) {
|
|
10207
|
+
setOpen(true);
|
|
10208
|
+
return;
|
|
8641
10209
|
}
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
}
|
|
8648
|
-
function toChecksumAddress(address) {
|
|
8649
|
-
const lower2 = address.slice(2).toLowerCase();
|
|
8650
|
-
const hash2 = keccak256Hex(new TextEncoder().encode(lower2));
|
|
8651
|
-
let out = "0x";
|
|
8652
|
-
for (let i = 0; i < 40; i++) out += Number.parseInt(hash2[i], 16) >= 8 ? lower2[i].toUpperCase() : lower2[i];
|
|
8653
|
-
return out;
|
|
8654
|
-
}
|
|
8655
|
-
function hasValidChecksum(address) {
|
|
8656
|
-
if (!/^0x[0-9a-fA-F]{40}$/.test(address)) return false;
|
|
8657
|
-
const body = address.slice(2);
|
|
8658
|
-
if (body === body.toLowerCase() || body === body.toUpperCase()) return true;
|
|
8659
|
-
return toChecksumAddress(address) === address;
|
|
10210
|
+
const address = await wallet.connect(name);
|
|
10211
|
+
if (typeof address === "string") selectAddress("");
|
|
10212
|
+
else setOpen(true);
|
|
10213
|
+
};
|
|
10214
|
+
const recipientFor = (account) => required ? recipient2 || "" : hostRecipient || custom.evm || account;
|
|
10215
|
+
return { recipientFamily, recipientChainId: destinationChainId, recipient: recipient2, shown, typed, recipientFor, managed, missing, error, wallet, familyWallet, wallets, open: open && managed, show: () => setOpen(true), close, selectAddress, connect, triggerRef };
|
|
8660
10216
|
}
|
|
8661
10217
|
function ArrowLeft() {
|
|
8662
10218
|
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
|
|
@@ -8752,34 +10308,64 @@ function SheetFrame(props) {
|
|
|
8752
10308
|
document.addEventListener("keydown", onKey, true);
|
|
8753
10309
|
return () => document.removeEventListener("keydown", onKey, true);
|
|
8754
10310
|
}, []);
|
|
8755
|
-
return
|
|
8756
|
-
"
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
"
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
10311
|
+
return (
|
|
10312
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: role is "region" or "dialog" — both carry semantics; the Tab trap only runs for the modal (dialog) case.
|
|
10313
|
+
// biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-modal is set only when role is "dialog" (asRegion is false); a region never receives it.
|
|
10314
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10315
|
+
"div",
|
|
10316
|
+
{
|
|
10317
|
+
className: "sg-ws",
|
|
10318
|
+
"data-wide": props.wide || void 0,
|
|
10319
|
+
role: props.asRegion ? "region" : "dialog",
|
|
10320
|
+
"aria-modal": props.asRegion ? void 0 : "true",
|
|
10321
|
+
"aria-label": props.label,
|
|
10322
|
+
ref: sheetRef,
|
|
10323
|
+
tabIndex: -1,
|
|
10324
|
+
onKeyDown: props.trapFocus ? (event) => {
|
|
10325
|
+
if (event.key !== "Tab") return;
|
|
10326
|
+
const root = sheetRef.current;
|
|
10327
|
+
if (!root) return;
|
|
10328
|
+
const focusable = Array.from(
|
|
10329
|
+
root.querySelectorAll('a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])')
|
|
10330
|
+
).filter((el) => el.offsetParent !== null || el === document.activeElement);
|
|
10331
|
+
if (focusable.length === 0) {
|
|
10332
|
+
event.preventDefault();
|
|
10333
|
+
root.focus();
|
|
10334
|
+
return;
|
|
10335
|
+
}
|
|
10336
|
+
const first = focusable[0];
|
|
10337
|
+
const last = focusable[focusable.length - 1];
|
|
10338
|
+
const active = document.activeElement;
|
|
10339
|
+
if (event.shiftKey && (active === first || active === root)) {
|
|
10340
|
+
event.preventDefault();
|
|
10341
|
+
last.focus();
|
|
10342
|
+
} else if (!event.shiftKey && active === last) {
|
|
10343
|
+
event.preventDefault();
|
|
10344
|
+
first.focus();
|
|
10345
|
+
}
|
|
10346
|
+
} : void 0,
|
|
10347
|
+
style: props.minHeight ? { minHeight: props.minHeight } : void 0,
|
|
10348
|
+
children: [
|
|
10349
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-top", children: [
|
|
10350
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-head", children: [
|
|
10351
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-ws-back", onClick: () => closeRef.current(), children: [
|
|
10352
|
+
/* @__PURE__ */ jsxRuntime.jsx(ArrowLeft, {}),
|
|
10353
|
+
props.backLabel ?? "Back to Exchange"
|
|
10354
|
+
] }),
|
|
10355
|
+
props.wide || props.hideClose ? null : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-ws-close", onClick: () => closeRef.current(), "aria-label": `Close ${props.label.toLowerCase()}`, children: /* @__PURE__ */ jsxRuntime.jsx(CloseX, {}) })
|
|
8772
10356
|
] }),
|
|
8773
|
-
|
|
10357
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-main", children: [
|
|
10358
|
+
props.titleAddon ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-titlerow", children: [
|
|
10359
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-ws-title", id: titleId, children: props.title }),
|
|
10360
|
+
props.titleAddon
|
|
10361
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-ws-title", id: titleId, children: props.title }),
|
|
10362
|
+
props.children
|
|
10363
|
+
] })
|
|
8774
10364
|
] }),
|
|
8775
|
-
/* @__PURE__ */ jsxRuntime.
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
] }),
|
|
8780
|
-
props.footer ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-ws-foot", children: props.footer }) : null
|
|
8781
|
-
]
|
|
8782
|
-
}
|
|
10365
|
+
props.footer ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-ws-foot", children: props.footer }) : null
|
|
10366
|
+
]
|
|
10367
|
+
}
|
|
10368
|
+
)
|
|
8783
10369
|
);
|
|
8784
10370
|
}
|
|
8785
10371
|
function WalletChip(props) {
|
|
@@ -9338,7 +10924,7 @@ function IdentityLine(props) {
|
|
|
9338
10924
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-link-id", children: [
|
|
9339
10925
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-link-id-icon", children: /* @__PURE__ */ jsxRuntime.jsx(WalletGlyph, {}) }),
|
|
9340
10926
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-link-id-text", children: [
|
|
9341
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-link-id-primary", children: props.account ?
|
|
10927
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-link-id-primary", children: props.account ? shortAddress3(props.account) : "ZeroDelta Link" }),
|
|
9342
10928
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-link-id-secondary", children: props.email ? props.email : props.account ? "Connected wallet" : "Connect your wallet to continue" })
|
|
9343
10929
|
] }),
|
|
9344
10930
|
props.account ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-wallet-dot", "aria-hidden": "true" }) : null
|
|
@@ -9485,9 +11071,9 @@ function PaymentIsland(props) {
|
|
|
9485
11071
|
const optionStates = react.useMemo(() => {
|
|
9486
11072
|
const map = {};
|
|
9487
11073
|
for (const a of annotated) {
|
|
9488
|
-
const
|
|
11074
|
+
const key2 = balanceKey(a.route.source.chainId, a.route.source.tokenAddress);
|
|
9489
11075
|
if (!a.balance || holdings.loading) {
|
|
9490
|
-
map[
|
|
11076
|
+
map[key2] = { disabled: false, reason: "checking" };
|
|
9491
11077
|
continue;
|
|
9492
11078
|
}
|
|
9493
11079
|
let zero = false;
|
|
@@ -9496,9 +11082,9 @@ function PaymentIsland(props) {
|
|
|
9496
11082
|
} catch {
|
|
9497
11083
|
zero = false;
|
|
9498
11084
|
}
|
|
9499
|
-
if (zero) map[
|
|
9500
|
-
else if (a.affordable === false) map[
|
|
9501
|
-
else map[
|
|
11085
|
+
if (zero) map[key2] = { disabled: true, reason: "no-balance", hint: "No balance on this chain" };
|
|
11086
|
+
else if (a.affordable === false) map[key2] = { disabled: true, reason: "insufficient", hint: `Need ${a.route.source.payAmount} ${a.route.source.ticker || a.route.source.asset}` };
|
|
11087
|
+
else map[key2] = { disabled: false };
|
|
9502
11088
|
}
|
|
9503
11089
|
return map;
|
|
9504
11090
|
}, [annotated, holdings.loading]);
|
|
@@ -9538,19 +11124,19 @@ function PaymentIsland(props) {
|
|
|
9538
11124
|
if (!catalogue?.ready) return void 0;
|
|
9539
11125
|
const states2 = {};
|
|
9540
11126
|
for (const token of catalogue.tokens) {
|
|
9541
|
-
const
|
|
11127
|
+
const key2 = balanceKey(Number(token.chainId), token.address);
|
|
9542
11128
|
const measured = exFromToken ? brokenLaneFor(token, exFromToken, catalogue.brokenLanes) : void 0;
|
|
9543
11129
|
if (measured) {
|
|
9544
|
-
states2[
|
|
11130
|
+
states2[key2] = { disabled: true, reason: brokenLaneReason(measured), hint: "Unavailable" };
|
|
9545
11131
|
continue;
|
|
9546
11132
|
}
|
|
9547
11133
|
const verdict = destinationAvailability(token, catalogue, exFromToken);
|
|
9548
11134
|
if (verdict === "available") {
|
|
9549
11135
|
const limit = laneLimitFor(token, exFromToken, catalogue.limitedLanes);
|
|
9550
|
-
if (limit) states2[
|
|
11136
|
+
if (limit) states2[key2] = { disabled: false, hint: laneLimitHint(limit, laneLimitSymbol(limit, exFromToken ? tokenTicker(exFromToken) : void 0)) };
|
|
9551
11137
|
continue;
|
|
9552
11138
|
}
|
|
9553
|
-
states2[
|
|
11139
|
+
states2[key2] = {
|
|
9554
11140
|
disabled: true,
|
|
9555
11141
|
reason: verdict === "hub-only" ? `${tokenTicker(token)} cannot be delivered on this chain.` : "ZeroDelta cannot deliver this asset here.",
|
|
9556
11142
|
hint: verdict === "hub-only" ? "Not here" : "Unavailable"
|
|
@@ -9563,9 +11149,9 @@ function PaymentIsland(props) {
|
|
|
9563
11149
|
const seen = /* @__PURE__ */ new Set();
|
|
9564
11150
|
const list = [];
|
|
9565
11151
|
for (const r of visibleRoutes) {
|
|
9566
|
-
const
|
|
9567
|
-
if (seen.has(
|
|
9568
|
-
seen.add(
|
|
11152
|
+
const key2 = balanceKey(r.source.chainId, r.source.tokenAddress);
|
|
11153
|
+
if (seen.has(key2)) continue;
|
|
11154
|
+
seen.add(key2);
|
|
9569
11155
|
const reg = registryTokens.find((t) => Number(t.chainId) === r.source.chainId && addrEq(t.address, r.source.tokenAddress));
|
|
9570
11156
|
list.push(
|
|
9571
11157
|
reg ?? {
|
|
@@ -9905,7 +11491,7 @@ function PaymentIsland(props) {
|
|
|
9905
11491
|
] }),
|
|
9906
11492
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-receipt-sub", children: [
|
|
9907
11493
|
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
9908
|
-
(flow.lastTxEntry?.recipient || recipient2) && (isPay || recipientState.recipientFamily === "solana") ? ` \xB7 ${
|
|
11494
|
+
(flow.lastTxEntry?.recipient || recipient2) && (isPay || recipientState.recipientFamily === "solana") ? ` \xB7 ${shortAddress3(flow.lastTxEntry?.recipient || recipient2)}` : ""
|
|
9909
11495
|
] }),
|
|
9910
11496
|
evmDirect ? null : /* @__PURE__ */ jsxRuntime.jsx(DeliverySteps, { delivery: evmDelivery })
|
|
9911
11497
|
] }),
|
|
@@ -10081,6 +11667,7 @@ function PillLauncher(props) {
|
|
|
10081
11667
|
const openAs = props.openAs === "drawer" ? "drawer" : "modal";
|
|
10082
11668
|
const [open, setOpen] = react.useState(!!props.defaultOpen);
|
|
10083
11669
|
const buttonRef = react.useRef(null);
|
|
11670
|
+
const dialogRef = react.useRef(null);
|
|
10084
11671
|
const close = () => {
|
|
10085
11672
|
setOpen(false);
|
|
10086
11673
|
requestAnimationFrame(() => buttonRef.current?.focus());
|
|
@@ -10088,7 +11675,32 @@ function PillLauncher(props) {
|
|
|
10088
11675
|
react.useEffect(() => {
|
|
10089
11676
|
if (!open) return;
|
|
10090
11677
|
const onKey = (e) => {
|
|
10091
|
-
if (e.key === "Escape")
|
|
11678
|
+
if (e.key === "Escape") {
|
|
11679
|
+
close();
|
|
11680
|
+
return;
|
|
11681
|
+
}
|
|
11682
|
+
if (e.key !== "Tab") return;
|
|
11683
|
+
const root = dialogRef.current;
|
|
11684
|
+
if (!root) return;
|
|
11685
|
+
const list = Array.from(root.querySelectorAll("a[href],button,input,select,textarea,[tabindex]")).filter(
|
|
11686
|
+
(el) => el.tabIndex >= 0 && !el.hasAttribute("disabled") && el.getClientRects().length > 0
|
|
11687
|
+
);
|
|
11688
|
+
if (list.length === 0) {
|
|
11689
|
+
e.preventDefault();
|
|
11690
|
+
return;
|
|
11691
|
+
}
|
|
11692
|
+
const first = list[0];
|
|
11693
|
+
const last = list[list.length - 1];
|
|
11694
|
+
const idx = list.indexOf(document.activeElement);
|
|
11695
|
+
if (e.shiftKey) {
|
|
11696
|
+
if (idx <= 0) {
|
|
11697
|
+
e.preventDefault();
|
|
11698
|
+
last.focus();
|
|
11699
|
+
}
|
|
11700
|
+
} else if (idx === -1 || idx === list.length - 1) {
|
|
11701
|
+
e.preventDefault();
|
|
11702
|
+
first.focus();
|
|
11703
|
+
}
|
|
10092
11704
|
};
|
|
10093
11705
|
document.addEventListener("keydown", onKey);
|
|
10094
11706
|
return () => document.removeEventListener("keydown", onKey);
|
|
@@ -10103,7 +11715,7 @@ function PillLauncher(props) {
|
|
|
10103
11715
|
] }),
|
|
10104
11716
|
open ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-overlay", "data-sg-overlay": openAs, children: [
|
|
10105
11717
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-overlay-scrim", tabIndex: -1, "aria-label": "Close", onClick: close }),
|
|
10106
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-dialog", role: "dialog", "aria-modal": "true", "aria-label": props.verb, children: props.children(close, openAs) })
|
|
11718
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: dialogRef, className: "sg-dialog", role: "dialog", "aria-modal": "true", "aria-label": props.verb, children: props.children(close, openAs) })
|
|
10107
11719
|
] }) : null
|
|
10108
11720
|
] });
|
|
10109
11721
|
}
|
|
@@ -10218,9 +11830,9 @@ function PayCard(props) {
|
|
|
10218
11830
|
const optionStates = react.useMemo(() => {
|
|
10219
11831
|
const map = {};
|
|
10220
11832
|
for (const a of annotated) {
|
|
10221
|
-
const
|
|
11833
|
+
const key2 = balanceKey(a.route.source.chainId, a.route.source.tokenAddress);
|
|
10222
11834
|
if (!a.balance || holdings.loading) {
|
|
10223
|
-
map[
|
|
11835
|
+
map[key2] = { disabled: false, reason: "checking" };
|
|
10224
11836
|
continue;
|
|
10225
11837
|
}
|
|
10226
11838
|
let zero = false;
|
|
@@ -10230,23 +11842,23 @@ function PayCard(props) {
|
|
|
10230
11842
|
zero = false;
|
|
10231
11843
|
}
|
|
10232
11844
|
if (zero) {
|
|
10233
|
-
map[
|
|
11845
|
+
map[key2] = { disabled: true, reason: "no-balance", hint: "No balance on this chain" };
|
|
10234
11846
|
} else if (a.affordable === false) {
|
|
10235
|
-
map[
|
|
11847
|
+
map[key2] = { disabled: true, reason: "insufficient", hint: `Need ${a.route.source.payAmount} ${a.route.source.ticker || a.route.source.asset}` };
|
|
10236
11848
|
} else {
|
|
10237
|
-
map[
|
|
11849
|
+
map[key2] = { disabled: false };
|
|
10238
11850
|
}
|
|
10239
11851
|
}
|
|
10240
11852
|
for (const o of unquoted) {
|
|
10241
|
-
const
|
|
10242
|
-
if (map[
|
|
11853
|
+
const key2 = balanceKey(o.chainId, o.address);
|
|
11854
|
+
if (map[key2]) continue;
|
|
10243
11855
|
let zero = false;
|
|
10244
11856
|
try {
|
|
10245
|
-
zero = BigInt(listBalances[
|
|
11857
|
+
zero = BigInt(listBalances[key2]?.raw ?? "x") === 0n;
|
|
10246
11858
|
} catch {
|
|
10247
11859
|
zero = false;
|
|
10248
11860
|
}
|
|
10249
|
-
map[
|
|
11861
|
+
map[key2] = zero ? { disabled: true, reason: "no-balance", hint: "No balance on this chain" } : { disabled: false };
|
|
10250
11862
|
}
|
|
10251
11863
|
return map;
|
|
10252
11864
|
}, [annotated, holdings.loading, unquoted, listBalances]);
|
|
@@ -10260,9 +11872,9 @@ function PayCard(props) {
|
|
|
10260
11872
|
const seen = /* @__PURE__ */ new Set();
|
|
10261
11873
|
const list = [];
|
|
10262
11874
|
const push = (chainId, address, fallback) => {
|
|
10263
|
-
const
|
|
10264
|
-
if (seen.has(
|
|
10265
|
-
seen.add(
|
|
11875
|
+
const key2 = balanceKey(chainId, address);
|
|
11876
|
+
if (seen.has(key2)) return;
|
|
11877
|
+
seen.add(key2);
|
|
10266
11878
|
list.push(registryTokens.find((t) => Number(t.chainId) === chainId && addrEq2(t.address, address)) ?? fallback);
|
|
10267
11879
|
};
|
|
10268
11880
|
for (const r of visibleRoutes) {
|
|
@@ -10336,13 +11948,13 @@ function PayCard(props) {
|
|
|
10336
11948
|
const option = unquoted.find((o) => o.chainId === pick.chainId && o.symbolKey === symbolKey(pick.symbol));
|
|
10337
11949
|
closeSelector();
|
|
10338
11950
|
if (!option || !wallet.account) return;
|
|
10339
|
-
const
|
|
10340
|
-
setPricing(
|
|
11951
|
+
const key2 = balanceKey(option.chainId, option.address);
|
|
11952
|
+
setPricing(key2);
|
|
10341
11953
|
userPicked.current = true;
|
|
10342
11954
|
engine.quotePayOption({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, wallet.account, { chainId: option.chainId, address: option.address }, { chainId: wallet.chainId ?? void 0, fundingAssets: planFundingAssets }).then((route) => flow.addRoute(route)).catch(() => {
|
|
10343
|
-
setFailedOptions((prev) => /* @__PURE__ */ new Set([...prev,
|
|
11955
|
+
setFailedOptions((prev) => /* @__PURE__ */ new Set([...prev, key2]));
|
|
10344
11956
|
setPickError(`${option.ticker || option.symbol} on ${option.chainName} cannot settle this payment right now. Pick another way to pay.`);
|
|
10345
|
-
}).finally(() => setPricing((cur) => cur ===
|
|
11957
|
+
}).finally(() => setPricing((cur) => cur === key2 ? null : cur));
|
|
10346
11958
|
};
|
|
10347
11959
|
const parked = !isLiveMethod(method);
|
|
10348
11960
|
const submitting = flow.status === "submitting";
|
|
@@ -10375,7 +11987,7 @@ function PayCard(props) {
|
|
|
10375
11987
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-wallet", "data-connected": "true", children: [
|
|
10376
11988
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-wallet-dot", "aria-hidden": "true" }),
|
|
10377
11989
|
" ",
|
|
10378
|
-
|
|
11990
|
+
shortAddress3(wallet.account)
|
|
10379
11991
|
] })
|
|
10380
11992
|
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", {});
|
|
10381
11993
|
const nativeWei = sel ? routeNativeValue(sel) : 0n;
|
|
@@ -10415,7 +12027,7 @@ function PayCard(props) {
|
|
|
10415
12027
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
10416
12028
|
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
10417
12029
|
" \xB7 ",
|
|
10418
|
-
|
|
12030
|
+
shortAddress3(props.recipient)
|
|
10419
12031
|
] }),
|
|
10420
12032
|
evmDirect ? null : /* @__PURE__ */ jsxRuntime.jsx(DeliverySteps, { delivery: evmDelivery })
|
|
10421
12033
|
] }),
|
|
@@ -10583,7 +12195,7 @@ function StableGenieSwap(props) {
|
|
|
10583
12195
|
] }),
|
|
10584
12196
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
10585
12197
|
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
10586
|
-
recipientState.recipientFamily === "solana" ? ` \xB7 ${
|
|
12198
|
+
recipientState.recipientFamily === "solana" ? ` \xB7 ${shortAddress3(flow.lastTxEntry?.recipient || recipient2)}` : props.recipient ? ` \xB7 ${shortAddress3(props.recipient)}` : ""
|
|
10587
12199
|
] }),
|
|
10588
12200
|
evmDirect ? null : /* @__PURE__ */ jsxRuntime.jsx(DeliverySteps, { delivery: evmDelivery })
|
|
10589
12201
|
] }),
|
|
@@ -10647,7 +12259,7 @@ function useSolanaSourceFlow(args) {
|
|
|
10647
12259
|
const planArgs = react.useRef(null);
|
|
10648
12260
|
const changedWhileBusy = react.useRef(false);
|
|
10649
12261
|
const addressed = Boolean(owner && payer && recipient2);
|
|
10650
|
-
const
|
|
12262
|
+
const key2 = keyOf(args);
|
|
10651
12263
|
react.useEffect(() => {
|
|
10652
12264
|
const id = ++req.current;
|
|
10653
12265
|
if (!enabled || !fromSymbol || !toChainId || !toSymbol || !(Number(amount) > 0)) {
|
|
@@ -10681,7 +12293,7 @@ function useSolanaSourceFlow(args) {
|
|
|
10681
12293
|
const quoted = await engine.quoteSolanaSource(input);
|
|
10682
12294
|
const built = await engine.buildSolanaSourcePlan(input, quoted);
|
|
10683
12295
|
if (id !== req.current) return;
|
|
10684
|
-
planKey.current =
|
|
12296
|
+
planKey.current = key2;
|
|
10685
12297
|
planArgs.current = { ...latest.current };
|
|
10686
12298
|
setPreview(quoted);
|
|
10687
12299
|
setPlan(built);
|
|
@@ -10697,7 +12309,7 @@ function useSolanaSourceFlow(args) {
|
|
|
10697
12309
|
}
|
|
10698
12310
|
}, 350);
|
|
10699
12311
|
return () => clearTimeout(timer2);
|
|
10700
|
-
}, [engine, enabled,
|
|
12312
|
+
}, [engine, enabled, key2, addressed, nonce]);
|
|
10701
12313
|
react.useEffect(() => {
|
|
10702
12314
|
let alive = true;
|
|
10703
12315
|
setBalanceRaw(void 0);
|
|
@@ -10776,6 +12388,658 @@ function useSolanaSourceFlow(args) {
|
|
|
10776
12388
|
}, []);
|
|
10777
12389
|
return { status, preview, plan, error, balanceRaw, cost, progress, signature, lastTxEntry, sent, addressed, needsPreparation, insufficient, solShort, run, reset };
|
|
10778
12390
|
}
|
|
12391
|
+
function BackArrow() {
|
|
12392
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5m6-6-6 6 6 6", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
12393
|
+
}
|
|
12394
|
+
function ChevronDown2({ up = false }) {
|
|
12395
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", style: up ? { transform: "rotate(180deg)" } : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 9 6 6 6-6", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
12396
|
+
}
|
|
12397
|
+
function PolicyShield() {
|
|
12398
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
|
|
12399
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12400
|
+
"path",
|
|
12401
|
+
{
|
|
12402
|
+
d: "M17.0089 5.8002V7.3252C17.0089 7.85853 16.7589 8.35853 16.3255 8.66686L7.15885 15.3835C6.56719 15.8169 5.75885 15.8169 5.17552 15.3752L3.97552 14.4752C3.43385 14.0669 2.99219 13.1835 2.99219 12.5085V5.8002C2.99219 4.86686 3.70885 3.83353 4.58385 3.50853L9.14219 1.8002C9.61719 1.6252 10.3839 1.6252 10.8589 1.8002L15.4172 3.50853C16.2922 3.83353 17.0089 4.86686 17.0089 5.8002Z",
|
|
12403
|
+
fill: "currentColor"
|
|
12404
|
+
}
|
|
12405
|
+
),
|
|
12406
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12407
|
+
"path",
|
|
12408
|
+
{
|
|
12409
|
+
d: "M15.682 10.2829C16.232 9.88287 17.007 10.2745 17.007 10.9579V12.5245C17.007 13.1995 16.5654 14.0745 16.0237 14.4829L11.4654 17.8912C11.0654 18.1829 10.532 18.3329 9.9987 18.3329C9.46537 18.3329 8.93204 18.1829 8.53204 17.8829L7.84037 17.3662C7.39037 17.0329 7.39037 16.3579 7.84871 16.0245L15.682 10.2829Z",
|
|
12410
|
+
fill: "currentColor"
|
|
12411
|
+
}
|
|
12412
|
+
)
|
|
12413
|
+
] });
|
|
12414
|
+
}
|
|
12415
|
+
function InfoSquare() {
|
|
12416
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
12417
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "2", y: "2", width: "20", height: "20", rx: "6", fill: "currentColor" }),
|
|
12418
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 10.8v6", stroke: "var(--sg-bg)", strokeWidth: "2.1", strokeLinecap: "round" }),
|
|
12419
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "7.7", r: "1.25", fill: "var(--sg-bg)" })
|
|
12420
|
+
] });
|
|
12421
|
+
}
|
|
12422
|
+
function InfoOutline() {
|
|
12423
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
12424
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "9.2", stroke: "currentColor", strokeWidth: "1.7" }),
|
|
12425
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 11v5.4", stroke: "currentColor", strokeWidth: "1.9", strokeLinecap: "round" }),
|
|
12426
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "7.8", r: "1.15", fill: "currentColor" })
|
|
12427
|
+
] });
|
|
12428
|
+
}
|
|
12429
|
+
var FLAGGED_CATEGORY_HINTS = {
|
|
12430
|
+
"High-risk entity": "An entity associated with elevated financial-crime risk based on available screening data.",
|
|
12431
|
+
"Politically exposed person (PEP)": "A person who holds or has held a prominent public function, including close associates and family members.",
|
|
12432
|
+
"Unknown / unclassified": "The screening provider could not confidently assign the entity to a known risk category.",
|
|
12433
|
+
"Unclassified risk": "The screening provider could not confidently assign the entity to a known risk category."
|
|
12434
|
+
};
|
|
12435
|
+
var POLICY_DETAILS = {
|
|
12436
|
+
"always-blocked": "Cannot be changed or disabled",
|
|
12437
|
+
blocked: "Stops the order",
|
|
12438
|
+
flagged: "Does not automatically block"
|
|
12439
|
+
};
|
|
12440
|
+
function Hint({ id, label: label2, text, hint }) {
|
|
12441
|
+
const tipId = react.useId();
|
|
12442
|
+
const open = hint.open === id;
|
|
12443
|
+
const ptr = react.useRef("");
|
|
12444
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12445
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12446
|
+
"button",
|
|
12447
|
+
{
|
|
12448
|
+
type: "button",
|
|
12449
|
+
className: "sg-cd-hint",
|
|
12450
|
+
"data-sg-hint": "",
|
|
12451
|
+
"aria-label": `About ${label2}`,
|
|
12452
|
+
"aria-expanded": open,
|
|
12453
|
+
"aria-describedby": open ? tipId : void 0,
|
|
12454
|
+
onPointerEnter: (e) => {
|
|
12455
|
+
ptr.current = e.pointerType;
|
|
12456
|
+
if (e.pointerType === "mouse") hint.setOpen(id);
|
|
12457
|
+
},
|
|
12458
|
+
onPointerLeave: (e) => {
|
|
12459
|
+
if (e.pointerType === "mouse") hint.setOpen(null);
|
|
12460
|
+
},
|
|
12461
|
+
onClick: () => {
|
|
12462
|
+
hint.setOpen(ptr.current === "mouse" ? id : open ? null : id);
|
|
12463
|
+
ptr.current = "";
|
|
12464
|
+
},
|
|
12465
|
+
onBlur: () => {
|
|
12466
|
+
ptr.current = "";
|
|
12467
|
+
},
|
|
12468
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(InfoOutline, {})
|
|
12469
|
+
}
|
|
12470
|
+
),
|
|
12471
|
+
open ? /* @__PURE__ */ jsxRuntime.jsx("span", { role: "tooltip", id: tipId, className: "sg-cd-tip", children: text }) : null
|
|
12472
|
+
] });
|
|
12473
|
+
}
|
|
12474
|
+
function CheckRow2({ check: check2, hideNote }) {
|
|
12475
|
+
const label2 = check2.id === "risk" ? check2.ok ? "Risk screening passed" : "Risk screening failed" : check2.label;
|
|
12476
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "sg-cd-check", "data-ok": check2.ok, children: [
|
|
12477
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-check-line", children: [
|
|
12478
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-mark", "data-ok": check2.ok, children: check2.ok ? /* @__PURE__ */ jsxRuntime.jsx(Tick, { size: 12 }) : /* @__PURE__ */ jsxRuntime.jsx(Cross, { size: 12 }) }),
|
|
12479
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-label", children: label2 }),
|
|
12480
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", children: check2.ok ? " \u2014 passed" : " \u2014 failed" })
|
|
12481
|
+
] }),
|
|
12482
|
+
check2.note && !hideNote ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-note", children: check2.note }) : null,
|
|
12483
|
+
check2.reasons.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-reason", children: humanizeComplianceReason(reason) }, reason))
|
|
12484
|
+
] });
|
|
12485
|
+
}
|
|
12486
|
+
function Fact2({ label: label2, value, title, mono = false }) {
|
|
12487
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-fact", children: [
|
|
12488
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: label2 }),
|
|
12489
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { title, className: mono ? "sg-mono" : void 0, children: value })
|
|
12490
|
+
] });
|
|
12491
|
+
}
|
|
12492
|
+
function QuoteChecks2(props) {
|
|
12493
|
+
const { compliance, cv, checks } = props;
|
|
12494
|
+
const allPassed = cv.tone === "ok" && checks.length > 0 && checks.every((c) => c.ok);
|
|
12495
|
+
const summary = allPassed ? "All checks passed" : cv.label;
|
|
12496
|
+
const orphans = unattributedComplianceReasons(compliance, cv);
|
|
12497
|
+
const wallets = distinctScreenedWallets(compliance);
|
|
12498
|
+
const jurisdiction = formatJurisdiction(compliance?.sourceJurisdiction, compliance?.sourceCountry);
|
|
12499
|
+
const hasDetails = Boolean(jurisdiction || wallets.length || compliance?.checkId);
|
|
12500
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-panel", children: [
|
|
12501
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd-card", children: [
|
|
12502
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-summary", children: [
|
|
12503
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-summary-head", "data-tone": cv.tone, children: [
|
|
12504
|
+
cv.tone === "blocked" || cv.tone === "warn" ? /* @__PURE__ */ jsxRuntime.jsx(CloseCircle, {}) : cv.tone === "neutral" ? /* @__PURE__ */ jsxRuntime.jsx(PendingCircle, {}) : /* @__PURE__ */ jsxRuntime.jsx(TickCircle, {}),
|
|
12505
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-summary-title", children: summary })
|
|
12506
|
+
] }),
|
|
12507
|
+
checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "sg-cd-summary-sub", children: [
|
|
12508
|
+
checks.length,
|
|
12509
|
+
" check",
|
|
12510
|
+
checks.length === 1 ? " was" : "s were",
|
|
12511
|
+
" completed for this quote"
|
|
12512
|
+
] }) : (
|
|
12513
|
+
// No decision was issued. Listing the controls here would be ticks for a verdict nobody gave,
|
|
12514
|
+
// and an unconfigured gate is not a set of passed checks.
|
|
12515
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-summary-sub", children: "The gateway returned no compliance decision for this quote, so there is nothing to show. It is not a failed check." })
|
|
12516
|
+
)
|
|
12517
|
+
] }),
|
|
12518
|
+
checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-checks", children: checks.map((check2) => (
|
|
12519
|
+
// The Figma row carries no sub-line: with ONE screened wallet the note would repeat the
|
|
12520
|
+
// address Quote details names two cards down. Any other note (a count of wallets) stays.
|
|
12521
|
+
/* @__PURE__ */ jsxRuntime.jsx(CheckRow2, { check: check2, hideNote: check2.id === "screening" && wallets.length === 1 && hasDetails }, check2.id)
|
|
12522
|
+
)) }) : null,
|
|
12523
|
+
orphans.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
|
|
12524
|
+
props.direct && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
12525
|
+
] }),
|
|
12526
|
+
compliance?.flaggedCategories?.length ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd-card", children: [
|
|
12527
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-cd-card-title", children: "Flagged, not blocking" }),
|
|
12528
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-flags", children: compliance.flaggedCategories.map(categoryLabel).join(" \xB7 ") }),
|
|
12529
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-scope", children: "The policy records these and still allows the payment. They do not stop settlement." })
|
|
12530
|
+
] }) : null,
|
|
12531
|
+
hasDetails ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd-card", children: [
|
|
12532
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-card-head", children: [
|
|
12533
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-card-glyph", children: /* @__PURE__ */ jsxRuntime.jsx(InfoSquare, {}) }),
|
|
12534
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-cd-card-title", children: "Quote details" })
|
|
12535
|
+
] }),
|
|
12536
|
+
/* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "sg-cd-facts", children: [
|
|
12537
|
+
jurisdiction ? /* @__PURE__ */ jsxRuntime.jsx(Fact2, { label: "Jurisdiction", value: jurisdiction }) : null,
|
|
12538
|
+
wallets.map((w, i) => /* @__PURE__ */ jsxRuntime.jsx(Fact2, { label: wallets.length > 1 ? i === 0 ? "Payer" : "Recipient" : "Wallet", value: shortAddr(w), title: w, mono: false }, w)),
|
|
12539
|
+
compliance?.checkId ? /* @__PURE__ */ jsxRuntime.jsx(Fact2, { label: "Check ID", value: compliance.checkId, mono: true }) : null
|
|
12540
|
+
] })
|
|
12541
|
+
] }) : null
|
|
12542
|
+
] });
|
|
12543
|
+
}
|
|
12544
|
+
function riskRuleCount() {
|
|
12545
|
+
return SCREENING_BUCKETS.reduce((total, bucket) => total + bucket.categories.length, 0);
|
|
12546
|
+
}
|
|
12547
|
+
function appliedPolicies(compliance) {
|
|
12548
|
+
const names = compliance?.appliedPolicyNames ?? [];
|
|
12549
|
+
const legislation = compliance?.appliedLegislation ?? [];
|
|
12550
|
+
const applied = Boolean(compliance?.decision || compliance?.policyVersion?.trim()) || names.length > 0;
|
|
12551
|
+
if (!applied) return [];
|
|
12552
|
+
const ids = compliance?.appliedPolicyIds ?? [];
|
|
12553
|
+
const summary = `${riskRuleCount()} risk rules`;
|
|
12554
|
+
const statements = legislation.map((name, i) => ({ id: `legislation-${i}-${name}`, name, summary: null, buckets: null }));
|
|
12555
|
+
if (names.length === 0) return [{ id: "zd-screening-matrix", name: "Transaction screening", summary, buckets: SCREENING_BUCKETS }, ...statements];
|
|
12556
|
+
if (names.length === 1) return [{ id: ids[0] ?? names[0], name: names[0], summary, buckets: SCREENING_BUCKETS }, ...statements];
|
|
12557
|
+
return [
|
|
12558
|
+
...names.map((name, i) => ({ id: ids[i] ?? `${name}-${i}`, name, summary: null, buckets: null })),
|
|
12559
|
+
...statements,
|
|
12560
|
+
{ id: "zd-screening-matrix", name: "Transaction screening", summary, buckets: SCREENING_BUCKETS }
|
|
12561
|
+
];
|
|
12562
|
+
}
|
|
12563
|
+
function PolicyBuckets({ policyId, layout, hint }) {
|
|
12564
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: SCREENING_BUCKETS.map((bucket) => {
|
|
12565
|
+
const detail = POLICY_DETAILS[bucket.outcome];
|
|
12566
|
+
const bucketHint = `${policyId}:${bucket.outcome}`;
|
|
12567
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-bucket", "data-outcome": bucket.outcome, children: [
|
|
12568
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-bucket-head", children: [
|
|
12569
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-bucket-title", children: bucket.title }),
|
|
12570
|
+
layout === "side" ? /* @__PURE__ */ jsxRuntime.jsx(Hint, { id: bucketHint, label: bucket.title, text: detail, hint }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-bucket-detail", children: detail })
|
|
12571
|
+
] }),
|
|
12572
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-cats", children: bucket.categories.map((category) => {
|
|
12573
|
+
const text = bucket.outcome === "flagged" ? FLAGGED_CATEGORY_HINTS[category] : void 0;
|
|
12574
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
12575
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-dot", "aria-hidden": "true" }),
|
|
12576
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: category }),
|
|
12577
|
+
text ? /* @__PURE__ */ jsxRuntime.jsx(Hint, { id: `${policyId}:${category}`, label: category, text, hint }) : null
|
|
12578
|
+
] }, category);
|
|
12579
|
+
}) })
|
|
12580
|
+
] }, bucket.outcome);
|
|
12581
|
+
}) });
|
|
12582
|
+
}
|
|
12583
|
+
function PolicyRow({
|
|
12584
|
+
policy,
|
|
12585
|
+
open,
|
|
12586
|
+
onToggle,
|
|
12587
|
+
layout,
|
|
12588
|
+
hint,
|
|
12589
|
+
policyVersion
|
|
12590
|
+
}) {
|
|
12591
|
+
const bodyId = react.useId();
|
|
12592
|
+
const head = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12593
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-mark", children: /* @__PURE__ */ jsxRuntime.jsx(PolicyShield, {}) }),
|
|
12594
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-policy-text", children: [
|
|
12595
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-name", children: policy.name }),
|
|
12596
|
+
policy.summary ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-sub", children: policy.summary }) : null
|
|
12597
|
+
] }),
|
|
12598
|
+
policy.buckets ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-chev", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDown2, { up: open }) }) : null
|
|
12599
|
+
] });
|
|
12600
|
+
if (!policy.buckets) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cd-policy", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cd-policy-head", "data-static": "", children: head }) });
|
|
12601
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-policy", "data-open": open, children: [
|
|
12602
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cd-policy-head", "aria-expanded": open, "aria-controls": bodyId, onClick: onToggle, children: head }),
|
|
12603
|
+
open ? /* @__PURE__ */ jsxRuntime.jsxs("div", { id: bodyId, className: "sg-cd-policy-body", children: [
|
|
12604
|
+
/* @__PURE__ */ jsxRuntime.jsx(PolicyBuckets, { policyId: policy.id, layout, hint }),
|
|
12605
|
+
policyVersion ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "sg-cd-policy-version sg-mono", children: [
|
|
12606
|
+
"Policy version ",
|
|
12607
|
+
policyVersion
|
|
12608
|
+
] }) : null
|
|
12609
|
+
] }) : null
|
|
12610
|
+
] });
|
|
12611
|
+
}
|
|
12612
|
+
function AppliedPolicies({ policies, layout, hint, policyVersion }) {
|
|
12613
|
+
const [openId, setOpenId] = react.useState(() => policies.find((p) => p.buckets)?.id ?? null);
|
|
12614
|
+
if (policies.length === 0) {
|
|
12615
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cd-panel", children: /* @__PURE__ */ jsxRuntime.jsx("section", { className: "sg-cd-card", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-summary", children: [
|
|
12616
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-summary-head", "data-tone": "neutral", children: [
|
|
12617
|
+
/* @__PURE__ */ jsxRuntime.jsx(PendingCircle, {}),
|
|
12618
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-summary-title", children: "No policy decision was returned" })
|
|
12619
|
+
] }),
|
|
12620
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-summary-sub", children: "There is no applied policy to show for this quote. It is not a failed check." })
|
|
12621
|
+
] }) }) });
|
|
12622
|
+
}
|
|
12623
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cd-panel sg-cd-policies", children: policies.map((policy) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
12624
|
+
PolicyRow,
|
|
12625
|
+
{
|
|
12626
|
+
policy,
|
|
12627
|
+
open: openId === policy.id,
|
|
12628
|
+
onToggle: () => setOpenId(openId === policy.id ? null : policy.id),
|
|
12629
|
+
layout,
|
|
12630
|
+
hint,
|
|
12631
|
+
policyVersion: openId === policy.id ? policyVersion : void 0
|
|
12632
|
+
},
|
|
12633
|
+
policy.id
|
|
12634
|
+
)) });
|
|
12635
|
+
}
|
|
12636
|
+
function ComplianceDetails(props) {
|
|
12637
|
+
const [tab, setTab] = react.useState("checks");
|
|
12638
|
+
const [hintOpen, setHintOpen] = react.useState(null);
|
|
12639
|
+
const rootRef = react.useRef(null);
|
|
12640
|
+
const ids = react.useId();
|
|
12641
|
+
const compliance = props.compliance ?? null;
|
|
12642
|
+
const cv = complianceView(compliance, props.hasQuote ?? true);
|
|
12643
|
+
const allChecks = complianceChecks(compliance, cv);
|
|
12644
|
+
const checks = props.direct ? allChecks.filter((c) => DIRECT_CHECK_IDS.includes(c.id)) : allChecks;
|
|
12645
|
+
const policies = appliedPolicies(compliance);
|
|
12646
|
+
const policyVersion = compliance?.policyVersion?.trim() || void 0;
|
|
12647
|
+
const onBackRef = react.useRef(props.onBack);
|
|
12648
|
+
onBackRef.current = props.onBack;
|
|
12649
|
+
const hintRef = react.useRef(hintOpen);
|
|
12650
|
+
hintRef.current = hintOpen;
|
|
12651
|
+
react.useEffect(() => {
|
|
12652
|
+
rootRef.current?.focus({ preventScroll: true });
|
|
12653
|
+
const onKey = (e) => {
|
|
12654
|
+
if (e.key !== "Escape") return;
|
|
12655
|
+
e.stopPropagation();
|
|
12656
|
+
if (hintRef.current) setHintOpen(null);
|
|
12657
|
+
else onBackRef.current();
|
|
12658
|
+
};
|
|
12659
|
+
const onPointer = (e) => {
|
|
12660
|
+
if (hintRef.current && !e.target?.closest?.("[data-sg-hint]")) setHintOpen(null);
|
|
12661
|
+
};
|
|
12662
|
+
document.addEventListener("keydown", onKey, true);
|
|
12663
|
+
document.addEventListener("pointerdown", onPointer, true);
|
|
12664
|
+
return () => {
|
|
12665
|
+
document.removeEventListener("keydown", onKey, true);
|
|
12666
|
+
document.removeEventListener("pointerdown", onPointer, true);
|
|
12667
|
+
};
|
|
12668
|
+
}, []);
|
|
12669
|
+
const tabKeys = (e) => {
|
|
12670
|
+
const order = ["checks", "policy"];
|
|
12671
|
+
let next = null;
|
|
12672
|
+
if (e.key === "Home") next = order[0];
|
|
12673
|
+
else if (e.key === "End") next = order[order.length - 1];
|
|
12674
|
+
else if (e.key === "ArrowRight") next = order[(order.indexOf(tab) + 1) % order.length];
|
|
12675
|
+
else if (e.key === "ArrowLeft") next = order[(order.indexOf(tab) - 1 + order.length) % order.length];
|
|
12676
|
+
if (next === null) return;
|
|
12677
|
+
e.preventDefault();
|
|
12678
|
+
setTab(next);
|
|
12679
|
+
document.getElementById(`${ids}-tab-${next}`)?.focus();
|
|
12680
|
+
};
|
|
12681
|
+
const hint = { open: hintOpen, setOpen: setHintOpen };
|
|
12682
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd", "data-layout": props.layout, "aria-label": "Compliance details", ref: rootRef, tabIndex: -1, children: [
|
|
12683
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-cd-back", onClick: props.onBack, children: [
|
|
12684
|
+
/* @__PURE__ */ jsxRuntime.jsx(BackArrow, {}),
|
|
12685
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Back to Exchange" })
|
|
12686
|
+
] }),
|
|
12687
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "sg-cd-title", children: "Compliance details" }),
|
|
12688
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-tabs", role: "tablist", "aria-label": "Compliance details sections", children: [
|
|
12689
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12690
|
+
"button",
|
|
12691
|
+
{
|
|
12692
|
+
type: "button",
|
|
12693
|
+
role: "tab",
|
|
12694
|
+
id: `${ids}-tab-checks`,
|
|
12695
|
+
"aria-selected": tab === "checks",
|
|
12696
|
+
"aria-controls": `${ids}-panel`,
|
|
12697
|
+
tabIndex: tab === "checks" ? 0 : -1,
|
|
12698
|
+
"data-active": tab === "checks",
|
|
12699
|
+
className: "sg-cd-tab",
|
|
12700
|
+
onClick: () => setTab("checks"),
|
|
12701
|
+
onKeyDown: tabKeys,
|
|
12702
|
+
children: "Quote checks"
|
|
12703
|
+
}
|
|
12704
|
+
),
|
|
12705
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12706
|
+
"button",
|
|
12707
|
+
{
|
|
12708
|
+
type: "button",
|
|
12709
|
+
role: "tab",
|
|
12710
|
+
id: `${ids}-tab-policy`,
|
|
12711
|
+
"aria-selected": tab === "policy",
|
|
12712
|
+
"aria-controls": `${ids}-panel`,
|
|
12713
|
+
tabIndex: tab === "policy" ? 0 : -1,
|
|
12714
|
+
"data-active": tab === "policy",
|
|
12715
|
+
className: "sg-cd-tab",
|
|
12716
|
+
onClick: () => setTab("policy"),
|
|
12717
|
+
onKeyDown: tabKeys,
|
|
12718
|
+
children: [
|
|
12719
|
+
"Applied policies",
|
|
12720
|
+
policies.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-tab-count", children: policies.length }) : null
|
|
12721
|
+
]
|
|
12722
|
+
}
|
|
12723
|
+
)
|
|
12724
|
+
] }),
|
|
12725
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { id: `${ids}-panel`, role: "tabpanel", "aria-labelledby": `${ids}-tab-${tab}`, children: tab === "checks" ? /* @__PURE__ */ jsxRuntime.jsx(QuoteChecks2, { compliance, cv, checks, direct: !!props.direct }) : /* @__PURE__ */ jsxRuntime.jsx(AppliedPolicies, { policies, layout: props.layout, hint, policyVersion }) })
|
|
12726
|
+
] });
|
|
12727
|
+
}
|
|
12728
|
+
function RefreshGlyph({ spinning }) {
|
|
12729
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: spinning ? "sg-cq-spin" : void 0, width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4.22639 4.22667C4.71306 3.74 5.28639 3.35333 5.91972 3.08667C6.57972 2.80667 7.27306 2.66667 7.99306 2.66667V1.33333C7.09306 1.33333 6.21972 1.50667 5.39972 1.86C4.60639 2.19333 3.89306 2.68 3.27972 3.28667C2.66639 3.9 2.18639 4.61333 1.85306 5.40667C1.50639 6.22667 1.32639 7.1 1.32639 8C1.32639 8.9 1.49972 9.77333 1.85306 10.5933C2.18639 11.3867 2.66639 12.1 3.27972 12.7133C3.39306 12.8267 3.51306 12.9267 3.62639 13.0333L1.99306 14.6667H5.99306V10.6667L4.57306 12.0867C4.45306 11.9867 4.33306 11.88 4.22639 11.7667C3.7398 11.2804 3.3506 10.7057 3.07972 10.0733C2.79972 9.41333 2.65972 8.72 2.65972 8C2.65972 7.28 2.79972 6.58 3.07972 5.92667C3.34639 5.29333 3.73306 4.72 4.22639 4.23333V4.22667ZM12.7131 3.28667C12.5997 3.17333 12.4797 3.07333 12.3664 2.96667L13.9997 1.33333H9.99972V5.33333L11.4197 3.91333C11.5397 4.01333 11.6597 4.12 11.7664 4.23333C12.2597 4.72667 12.6397 5.29333 12.9131 5.92667C13.1931 6.58667 13.3331 7.28 13.3331 8C13.3331 8.72 13.1931 9.42 12.9131 10.0733C12.6464 10.7067 12.2597 11.28 11.7664 11.7667C11.2797 12.2533 10.7064 12.64 10.0731 12.9067C9.41306 13.1867 8.71972 13.3267 7.99972 13.3267V14.66C8.89972 14.66 9.77306 14.4867 10.5931 14.1333C11.3864 13.8 12.0997 13.3133 12.7131 12.7067C13.3264 12.0933 13.8064 11.38 14.1397 10.5867C14.4864 9.76667 14.6664 8.89333 14.6664 7.99333C14.6664 7.09333 14.4931 6.22 14.1397 5.4C13.8068 4.60714 13.3222 3.88698 12.7131 3.28V3.28667Z" }) });
|
|
12730
|
+
}
|
|
12731
|
+
function SliderGrip() {
|
|
12732
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "28", height: "12", viewBox: "0 0 28 12", fill: "none", "aria-hidden": "true", children: [
|
|
12733
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "27", height: "11", rx: "5.5", fill: "rgba(255,255,255,0.3)" }),
|
|
12734
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11 3l3 3-3 3M15 3l3 3-3 3", stroke: "#fff", strokeWidth: "1.1", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
12735
|
+
] });
|
|
12736
|
+
}
|
|
12737
|
+
function WalletAddGlyph() {
|
|
12738
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: [
|
|
12739
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9.95 1.84167L7.94167 6.51667H5.93333C5.6 6.51667 5.275 6.54167 4.95833 6.60833L5.79167 4.60833L5.825 4.53333L5.875 4.4C5.9 4.34167 5.91667 4.29167 5.94167 4.25C6.90833 2.00833 7.99167 1.30833 9.95 1.84167Z" }),
|
|
12740
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15.6083 6.74167L15.5917 6.73333C15.0917 6.59167 14.5833 6.51667 14.0667 6.51667H8.85L10.725 2.15833L10.75 2.1C10.8667 2.14167 10.9917 2.2 11.1167 2.24167L12.9583 3.01667C13.9833 3.44167 14.7 3.88333 15.1417 4.41667C15.2167 4.51667 15.2833 4.60833 15.35 4.71667C15.425 4.83333 15.4833 4.95 15.5167 5.075C15.55 5.15 15.575 5.21667 15.5917 5.29167C15.7167 5.71667 15.725 6.2 15.6083 6.74167Z" }),
|
|
12741
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15.2417 7.93333C14.8667 7.825 14.475 7.76667 14.0667 7.76667H5.93333C5.36667 7.76667 4.83333 7.875 4.33333 8.09167C2.88333 8.71667 1.86667 10.1583 1.86667 11.8333V13.4583C1.86667 13.6583 1.88333 13.85 1.90833 14.05C2.09167 16.7 3.50833 18.1167 6.15833 18.2917C6.35 18.3167 6.54167 18.3333 6.75 18.3333H13.25C16.3333 18.3333 17.9583 16.8667 18.1167 13.95C18.125 13.7917 18.1333 13.625 18.1333 13.4583V11.8333C18.1333 9.99167 16.9083 8.44167 15.2417 7.93333ZM12.0833 13.4917H10.625V15C10.625 15.3417 10.3417 15.625 10 15.625C9.65833 15.625 9.375 15.3417 9.375 15V13.4917H7.91667C7.575 13.4917 7.29167 13.2167 7.29167 12.8667C7.29167 12.525 7.575 12.2417 7.91667 12.2417H9.375V10.8333C9.375 10.4917 9.65833 10.2083 10 10.2083C10.3417 10.2083 10.625 10.4917 10.625 10.8333V12.2417H12.0833C12.425 12.2417 12.7083 12.525 12.7083 12.8667C12.7083 13.2167 12.425 13.4917 12.0833 13.4917Z" })
|
|
12742
|
+
] });
|
|
12743
|
+
}
|
|
12744
|
+
function ChevronGlyph2({ up }) {
|
|
12745
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", style: up ? { transform: "scaleY(-1)" } : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2.5 4.5 6 8l3.5-3.5", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
12746
|
+
}
|
|
12747
|
+
function ArrowGlyph2() {
|
|
12748
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "sg-cq-arrow", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 8h9M9 4.5 12.5 8 9 11.5", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
12749
|
+
}
|
|
12750
|
+
function InfoGlyph() {
|
|
12751
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: [
|
|
12752
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "5.6", stroke: "currentColor", strokeWidth: "1" }),
|
|
12753
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7 6.2v3.4", stroke: "currentColor", strokeWidth: "1.1", strokeLinecap: "round" }),
|
|
12754
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "4.5", r: ".7", fill: "currentColor" })
|
|
12755
|
+
] });
|
|
12756
|
+
}
|
|
12757
|
+
function unavailableCopy(status) {
|
|
12758
|
+
return status === "unsigned-cross-chain-off" ? "Cross-chain orders are not enabled yet" : status === "router-unresolved" || status === "escrow-unresolved" ? "Not available on this network yet" : "Not available right now";
|
|
12759
|
+
}
|
|
12760
|
+
function compareFeeLabel(usd2) {
|
|
12761
|
+
if (usd2 === null) return "--";
|
|
12762
|
+
if (!Number.isFinite(usd2) || usd2 <= 0) return "$0.00";
|
|
12763
|
+
if (usd2 >= 0.01) return `$${usd2.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
12764
|
+
if (usd2 < 1e-6) return "<$0.000001";
|
|
12765
|
+
return `$${usd2.toLocaleString("en-US", { maximumSignificantDigits: 2 })}`;
|
|
12766
|
+
}
|
|
12767
|
+
function logoOf(tokens, hop) {
|
|
12768
|
+
const wanted = hop.address.toLowerCase();
|
|
12769
|
+
return tokens.find((t) => Number(t.chainId) === hop.chainId && String(t.address).toLowerCase() === wanted)?.logoUrl;
|
|
12770
|
+
}
|
|
12771
|
+
var WIDE_SCALE_TRAVEL_PX = 189 * 228 / 130;
|
|
12772
|
+
function thumbWidth(fraction) {
|
|
12773
|
+
return `max(32px, calc((100% - 4px) * ${fraction}))`;
|
|
12774
|
+
}
|
|
12775
|
+
function CompareQuotes(props) {
|
|
12776
|
+
const side = props.layout === "side";
|
|
12777
|
+
const sliderId = react.useId();
|
|
12778
|
+
const options = props.compare?.options ?? [];
|
|
12779
|
+
const selectedId = props.compare?.selectedId ?? null;
|
|
12780
|
+
const selected = options.find((o) => o.id === selectedId && !o.unavailable)?.id ?? options.find((o) => !o.unavailable)?.id ?? null;
|
|
12781
|
+
const picked = options.find((o) => o.id === selectedId && !o.unavailable);
|
|
12782
|
+
const [movedWait, setMovedWait] = react.useState(null);
|
|
12783
|
+
const wait2 = movedWait ?? (picked ? clampWait(picked.estimatedDuration) : proposedWait(options));
|
|
12784
|
+
const [openRoutes, setOpenRoutes] = react.useState(() => /* @__PURE__ */ new Set());
|
|
12785
|
+
const parityState = props.compare?.parity ?? { kind: "unknown" };
|
|
12786
|
+
const extra = props.compare ? extraVsFastest(options, selected) : null;
|
|
12787
|
+
const selectedOption = options.find((o) => o.id === selected);
|
|
12788
|
+
const anySelectable = options.some((o) => !o.unavailable);
|
|
12789
|
+
const moveWait = (sec) => {
|
|
12790
|
+
setMovedWait(sec);
|
|
12791
|
+
const pick = pickForWait(options, sec);
|
|
12792
|
+
if (pick && pick.id !== selected) props.onSelect(pick.id);
|
|
12793
|
+
};
|
|
12794
|
+
const pickCard = (option) => {
|
|
12795
|
+
if (props.onSelect(option.id)) setMovedWait(clampWait(option.estimatedDuration));
|
|
12796
|
+
};
|
|
12797
|
+
const toggleRoute = (id) => setOpenRoutes((prev) => {
|
|
12798
|
+
const next = new Set(prev);
|
|
12799
|
+
if (next.has(id)) next.delete(id);
|
|
12800
|
+
else next.add(id);
|
|
12801
|
+
return next;
|
|
12802
|
+
});
|
|
12803
|
+
const trackRef = react.useRef(null);
|
|
12804
|
+
const listRef = react.useRef(null);
|
|
12805
|
+
const [travel, setTravel] = react.useState(400);
|
|
12806
|
+
react.useLayoutEffect(() => {
|
|
12807
|
+
const el = trackRef.current;
|
|
12808
|
+
if (!el) return;
|
|
12809
|
+
const measure = () => setTravel(el.offsetWidth - 4);
|
|
12810
|
+
measure();
|
|
12811
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
12812
|
+
const ro = new ResizeObserver(measure);
|
|
12813
|
+
ro.observe(el);
|
|
12814
|
+
return () => ro.disconnect();
|
|
12815
|
+
}, [anySelectable]);
|
|
12816
|
+
const scale = react.useMemo(() => waitScaleFor(side ? WIDE_SCALE_TRAVEL_PX : travel), [side, travel]);
|
|
12817
|
+
const pct = waitFraction(wait2, scale) * 100;
|
|
12818
|
+
const shown = react.useMemo(() => visibleOptions(options, wait2, selected), [options, wait2, selected]);
|
|
12819
|
+
const rovingId = shown.find((o) => o.id === selected && !o.unavailable)?.id ?? shown.find((o) => !o.unavailable)?.id ?? null;
|
|
12820
|
+
const refresh = props.onRefresh ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cq-refresh", onClick: props.onRefresh, "aria-label": "Refresh quotes", "aria-busy": props.refreshing || void 0, children: /* @__PURE__ */ jsxRuntime.jsx(RefreshGlyph, { spinning: !!props.refreshing }) }) : void 0;
|
|
12821
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SheetFrame, { label: "Compare quotes", title: "Compare quotes", titleAddon: refresh, hideClose: true, wide: side, asRegion: !props.modal, trapFocus: props.modal, onClose: props.onBack, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq", "data-layout": props.layout, children: [
|
|
12822
|
+
anySelectable ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait", "data-testid": "compare-wait", children: [
|
|
12823
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait-top", children: [
|
|
12824
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait-row", children: [
|
|
12825
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: sliderId, children: "I'm willing to wait" }),
|
|
12826
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "compare-wait-label", children: waitLabel(wait2) })
|
|
12827
|
+
] }),
|
|
12828
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait-scale", children: [
|
|
12829
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: trackRef, className: "sg-cq-track", children: [
|
|
12830
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12831
|
+
"input",
|
|
12832
|
+
{
|
|
12833
|
+
id: sliderId,
|
|
12834
|
+
className: "sg-cq-range",
|
|
12835
|
+
type: "range",
|
|
12836
|
+
min: 0,
|
|
12837
|
+
max: WAIT_POSITIONS,
|
|
12838
|
+
step: 1,
|
|
12839
|
+
value: Math.round(pct * WAIT_POSITIONS / 100),
|
|
12840
|
+
"aria-valuetext": waitLabel(wait2),
|
|
12841
|
+
onChange: (e) => moveWait(snapWait(waitFromFraction(Number(e.target.value) / WAIT_POSITIONS, scale))),
|
|
12842
|
+
onKeyDown: (e) => {
|
|
12843
|
+
const dir = e.key === "ArrowRight" || e.key === "ArrowUp" ? 1 : e.key === "ArrowLeft" || e.key === "ArrowDown" ? -1 : 0;
|
|
12844
|
+
if (dir === 0) return;
|
|
12845
|
+
e.preventDefault();
|
|
12846
|
+
moveWait(snapWait(wait2 + dir * WAIT_STEP_SEC));
|
|
12847
|
+
}
|
|
12848
|
+
}
|
|
12849
|
+
),
|
|
12850
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cq-rail", "aria-hidden": "true" }),
|
|
12851
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cq-thumb", "aria-hidden": "true", style: { width: thumbWidth(pct / 100) }, children: /* @__PURE__ */ jsxRuntime.jsx(SliderGrip, {}) })
|
|
12852
|
+
] }),
|
|
12853
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-ends", children: [
|
|
12854
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "3 min" }),
|
|
12855
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "2 h" }),
|
|
12856
|
+
parityState.kind === "at" ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12857
|
+
"span",
|
|
12858
|
+
{
|
|
12859
|
+
className: "sg-cq-parity",
|
|
12860
|
+
"data-testid": "compare-parity",
|
|
12861
|
+
style: { left: `clamp(${side ? 60 : 44}px, calc(${thumbWidth(waitFraction(parityState.timeSec, scale))} - 13px), calc(100% - ${side ? 60 : 44}px))` },
|
|
12862
|
+
children: [
|
|
12863
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "1:1" }),
|
|
12864
|
+
" ",
|
|
12865
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: compareDuration(parityState.timeSec) })
|
|
12866
|
+
]
|
|
12867
|
+
}
|
|
12868
|
+
) : null,
|
|
12869
|
+
parityState.kind === "unavailable" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-parity-none", "data-testid": "compare-parity", children: "1:1 currently unavailable" }) : null
|
|
12870
|
+
] })
|
|
12871
|
+
] })
|
|
12872
|
+
] }),
|
|
12873
|
+
extra !== null ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12874
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cq-rule", "aria-hidden": "true" }),
|
|
12875
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-extra", "data-testid": "compare-extra", children: [
|
|
12876
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-extra-icon", children: /* @__PURE__ */ jsxRuntime.jsx(WalletAddGlyph, {}) }),
|
|
12877
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-text", children: [
|
|
12878
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-label", children: [
|
|
12879
|
+
"Potential extra received",
|
|
12880
|
+
side ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cq-info", "aria-label": `Compared with fastest${selectedOption?.entersNetting ? ". Depends on a matching order" : ""}`, title: `Compared with fastest${selectedOption?.entersNetting ? "\nDepends on a matching order" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(InfoGlyph, {}) }) : null
|
|
12881
|
+
] }),
|
|
12882
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-amt", children: [
|
|
12883
|
+
"+",
|
|
12884
|
+
compareAmount(extra),
|
|
12885
|
+
" ",
|
|
12886
|
+
props.toSymbol
|
|
12887
|
+
] })
|
|
12888
|
+
] }),
|
|
12889
|
+
side ? null : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-note", children: [
|
|
12890
|
+
"Compared with fastest",
|
|
12891
|
+
selectedOption?.entersNetting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12892
|
+
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
12893
|
+
"Depends on a matching order"
|
|
12894
|
+
] }) : null
|
|
12895
|
+
] })
|
|
12896
|
+
] })
|
|
12897
|
+
] }) : null
|
|
12898
|
+
] }) : null,
|
|
12899
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12900
|
+
"div",
|
|
12901
|
+
{
|
|
12902
|
+
role: "radiogroup",
|
|
12903
|
+
"aria-label": "Quotes",
|
|
12904
|
+
className: "sg-cq-list",
|
|
12905
|
+
ref: listRef,
|
|
12906
|
+
onKeyDown: (e) => {
|
|
12907
|
+
const dir = e.key === "ArrowDown" || e.key === "ArrowRight" ? 1 : e.key === "ArrowUp" || e.key === "ArrowLeft" ? -1 : 0;
|
|
12908
|
+
if (dir === 0) return;
|
|
12909
|
+
const pickable = shown.filter((o) => !o.unavailable);
|
|
12910
|
+
if (pickable.length === 0) return;
|
|
12911
|
+
e.preventDefault();
|
|
12912
|
+
const cur = Math.max(0, pickable.findIndex((o) => o.id === rovingId));
|
|
12913
|
+
const next = pickable[(cur + dir + pickable.length) % pickable.length];
|
|
12914
|
+
pickCard(next);
|
|
12915
|
+
requestAnimationFrame(() => listRef.current?.querySelector(`[data-oid="${CSS.escape(next.id)}"]`)?.focus());
|
|
12916
|
+
},
|
|
12917
|
+
children: [
|
|
12918
|
+
shown.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
12919
|
+
QuoteCard,
|
|
12920
|
+
{
|
|
12921
|
+
option,
|
|
12922
|
+
isSelected: option.id === selected,
|
|
12923
|
+
tabIndex: option.id === rovingId ? 0 : -1,
|
|
12924
|
+
tags: cornerTags(options, option, parityState),
|
|
12925
|
+
toSymbol: props.toSymbol,
|
|
12926
|
+
side,
|
|
12927
|
+
routeOpen: openRoutes.has(option.id),
|
|
12928
|
+
tokens: props.tokens,
|
|
12929
|
+
chainName: props.chainName,
|
|
12930
|
+
onPick: () => pickCard(option),
|
|
12931
|
+
onToggleRoute: () => toggleRoute(option.id)
|
|
12932
|
+
},
|
|
12933
|
+
option.id
|
|
12934
|
+
)),
|
|
12935
|
+
options.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "status", className: "sg-cq-empty", children: props.emptyMessage ?? "No quote yet \u2014 enter an amount to get one." }) : null
|
|
12936
|
+
]
|
|
12937
|
+
}
|
|
12938
|
+
)
|
|
12939
|
+
] }) });
|
|
12940
|
+
}
|
|
12941
|
+
function Column({ label: label2, value }) {
|
|
12942
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-col", children: [
|
|
12943
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-col-label", children: label2 }),
|
|
12944
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-col-value", children: value })
|
|
12945
|
+
] });
|
|
12946
|
+
}
|
|
12947
|
+
function HopMark({ hop, tokens, size }) {
|
|
12948
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: hop.ticker, logoUrl: logoOf(tokens, hop), chainId: hop.chainId, size });
|
|
12949
|
+
}
|
|
12950
|
+
function QuoteCard(props) {
|
|
12951
|
+
const { option, tags, side } = props;
|
|
12952
|
+
const routeId = react.useId();
|
|
12953
|
+
const headRef = react.useRef(null);
|
|
12954
|
+
const tagRef = react.useRef(null);
|
|
12955
|
+
const [tagInset, setTagInset] = react.useState(null);
|
|
12956
|
+
react.useLayoutEffect(() => {
|
|
12957
|
+
const head = headRef.current;
|
|
12958
|
+
const tag = tagRef.current;
|
|
12959
|
+
if (side || !head || !tag) return setTagInset(null);
|
|
12960
|
+
const measure = () => setTagInset(Math.max(0, Math.ceil(head.getBoundingClientRect().right - tag.getBoundingClientRect().left) + 8));
|
|
12961
|
+
measure();
|
|
12962
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
12963
|
+
const observer = new ResizeObserver(measure);
|
|
12964
|
+
observer.observe(tag);
|
|
12965
|
+
observer.observe(head);
|
|
12966
|
+
return () => observer.disconnect();
|
|
12967
|
+
}, [tags.length, side]);
|
|
12968
|
+
const netting = !!option.entersNetting;
|
|
12969
|
+
const gasless = !!option.gasSponsored;
|
|
12970
|
+
const note = netting ? "Matches your swap with an opposite order" : gasless ? "No native token needed for gas" : null;
|
|
12971
|
+
const nettingTag = tags.some((t) => t.tone === "green");
|
|
12972
|
+
const purple = tags[0]?.tone === "purple" && !nettingTag;
|
|
12973
|
+
const hops = option.hops;
|
|
12974
|
+
const collapsed = side && hops.length > 3;
|
|
12975
|
+
const inline = collapsed ? [hops[0], hops[1], "gap", hops[hops.length - 1]] : hops;
|
|
12976
|
+
const hidden3 = collapsed ? hops.slice(2, -1) : [];
|
|
12977
|
+
const routeIcons = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-route-icons", "data-testid": "compare-route-inline", children: inline.map((hop, i) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-inline", children: [
|
|
12978
|
+
i > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ArrowGlyph2, {}) : null,
|
|
12979
|
+
hop === "gap" ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cq-gap", title: hidden3.map((h2) => `${h2.ticker} on ${props.chainName(h2.chainId)}`).join(" \u2192 "), "aria-label": `Also via ${hidden3.map((h2) => `${h2.ticker} on ${props.chainName(h2.chainId)}`).join(", ")}`, children: "\u2026" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { title: `${hop.ticker} on ${props.chainName(hop.chainId)}`, children: /* @__PURE__ */ jsxRuntime.jsx(HopMark, { hop, tokens: props.tokens, size: "xxs" }) })
|
|
12980
|
+
] }, hop === "gap" ? "gap" : `${hop.chainId}-${hop.address}-${i}`)) });
|
|
12981
|
+
const fee = compareFeeLabel(option.feeUsd);
|
|
12982
|
+
const tagEl = tags.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { ref: tagRef, className: "sg-cq-tag", "data-kind": nettingTag ? "netting" : purple ? "purple" : "brand", children: tags.map((tag, i) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-tag-item", children: [
|
|
12983
|
+
i > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-tag-dot", "aria-hidden": "true" }) : null,
|
|
12984
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-tone": tag.tone, children: tag.text })
|
|
12985
|
+
] }, tag.text)) }) : null;
|
|
12986
|
+
const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12987
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { ref: headRef, className: "sg-cq-head", style: tagInset === null ? void 0 : { paddingRight: tagInset }, children: [
|
|
12988
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-radio", "data-on": props.isSelected || void 0, "aria-hidden": "true" }),
|
|
12989
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-amount", children: [
|
|
12990
|
+
tags.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-sr", children: [
|
|
12991
|
+
tags.map((t) => t.text).join(", "),
|
|
12992
|
+
" "
|
|
12993
|
+
] }) : option.label ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-sr", children: [
|
|
12994
|
+
option.label.toLowerCase().replace(/^./, (c) => c.toUpperCase()),
|
|
12995
|
+
" "
|
|
12996
|
+
] }) : null,
|
|
12997
|
+
netting ? "~" : "",
|
|
12998
|
+
compareAmount(option.amount),
|
|
12999
|
+
" ",
|
|
13000
|
+
props.toSymbol
|
|
13001
|
+
] })
|
|
13002
|
+
] }),
|
|
13003
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-stats", children: [
|
|
13004
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-cols", children: [
|
|
13005
|
+
/* @__PURE__ */ jsxRuntime.jsx(Column, { label: "Est. time", value: netting ? compareDuration(option.estimatedDuration).replace(/^~/, "") : compareDuration(option.estimatedDuration) }),
|
|
13006
|
+
gasless ? /* @__PURE__ */ jsxRuntime.jsx(Column, { label: "Gas fee", value: "Sponsored" }) : /* @__PURE__ */ jsxRuntime.jsx(Column, { label: netting ? "Est. fee" : "Fee", value: fee }),
|
|
13007
|
+
side && hops.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-col", children: [
|
|
13008
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-col-label", children: "Route" }),
|
|
13009
|
+
routeIcons
|
|
13010
|
+
] }) : null
|
|
13011
|
+
] }),
|
|
13012
|
+
!side && note ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-note", children: note }) : null
|
|
13013
|
+
] }),
|
|
13014
|
+
option.unavailable ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-why", children: unavailableCopy(option.unavailable) }) : null
|
|
13015
|
+
] });
|
|
13016
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-card", "data-testid": "compare-quote", "data-selected": props.isSelected || void 0, "data-unavailable": option.unavailable ? true : void 0, children: [
|
|
13017
|
+
tagEl,
|
|
13018
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", role: "radio", "aria-checked": props.isSelected, disabled: !!option.unavailable, tabIndex: props.tabIndex, "data-oid": option.id, onClick: props.onPick, className: "sg-cq-main", children: body }),
|
|
13019
|
+
!side && hops.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-route", children: [
|
|
13020
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-cq-route-toggle", onClick: props.onToggleRoute, "aria-expanded": props.routeOpen, "aria-controls": routeId, children: [
|
|
13021
|
+
"Route",
|
|
13022
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph2, { up: props.routeOpen })
|
|
13023
|
+
] }),
|
|
13024
|
+
props.routeOpen ? /* @__PURE__ */ jsxRuntime.jsx("div", { id: routeId, className: "sg-cq-hops", "data-testid": "compare-route", children: hops.map((hop, i) => (
|
|
13025
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: a route is a fixed sequence, and a token can appear twice on it.
|
|
13026
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop", children: [
|
|
13027
|
+
i > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ArrowGlyph2, {}) : null,
|
|
13028
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-body", children: [
|
|
13029
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-name", children: [
|
|
13030
|
+
/* @__PURE__ */ jsxRuntime.jsx(HopMark, { hop, tokens: props.tokens, size: "xxs" }),
|
|
13031
|
+
hop.ticker
|
|
13032
|
+
] }),
|
|
13033
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-chain", children: [
|
|
13034
|
+
"On ",
|
|
13035
|
+
props.chainName(hop.chainId)
|
|
13036
|
+
] })
|
|
13037
|
+
] })
|
|
13038
|
+
] }, `${hop.chainId}-${hop.address}-${i}`)
|
|
13039
|
+
)) }) : null
|
|
13040
|
+
] }) : null
|
|
13041
|
+
] });
|
|
13042
|
+
}
|
|
10779
13043
|
function QuoteSheet(props) {
|
|
10780
13044
|
const sheetRef = react.useRef(null);
|
|
10781
13045
|
const onCloseRef = react.useRef(props.onClose);
|
|
@@ -11021,11 +13285,11 @@ function ExchangeCard(props) {
|
|
|
11021
13285
|
const [fiatCurrency, setFiatCurrency] = react.useState(props.fiatCurrency ?? "EUR");
|
|
11022
13286
|
const sellableFrom = react.useCallback((t) => t && product === "rwa" && !isSellableRwa(t) ? null : t, [product]);
|
|
11023
13287
|
const fromToken = react.useMemo(() => from ? sellableFrom(findToken(tokens, from.chainId, from.symbol)) : null, [tokens, from, sellableFrom]);
|
|
11024
|
-
const
|
|
11025
|
-
const toSymbol =
|
|
13288
|
+
const toToken2 = react.useMemo(() => to ? findToken(tokens, to.chainId, to.symbol) : null, [tokens, to]);
|
|
13289
|
+
const toSymbol = toToken2?.symbol ?? to?.symbol ?? "";
|
|
11026
13290
|
const fromTicker = fromToken ? tokenTicker(fromToken) : from?.symbol ?? "";
|
|
11027
|
-
const toTicker =
|
|
11028
|
-
const fromPickerTokens = react.useMemo(() => product === "rwa" ? counterpartTokens(sourceTokens,
|
|
13291
|
+
const toTicker = toToken2 ? tokenTicker(toToken2) : toSymbol;
|
|
13292
|
+
const fromPickerTokens = react.useMemo(() => product === "rwa" ? counterpartTokens(sourceTokens, toToken2) : sourceTokens, [product, sourceTokens, toToken2]);
|
|
11029
13293
|
const toPickerTokens = react.useMemo(() => product === "rwa" ? counterpartTokens(tokens, fromToken) : tokens, [product, tokens, fromToken]);
|
|
11030
13294
|
const rwaSeeded = react.useRef(false);
|
|
11031
13295
|
react.useEffect(() => {
|
|
@@ -11042,19 +13306,19 @@ function ExchangeCard(props) {
|
|
|
11042
13306
|
if (!catalogue?.ready) return void 0;
|
|
11043
13307
|
const states2 = {};
|
|
11044
13308
|
for (const token of catalogue.tokens) {
|
|
11045
|
-
const
|
|
13309
|
+
const key2 = `${Number(token.chainId)}:${String(token.address || "").toLowerCase()}`;
|
|
11046
13310
|
const measured = fromToken ? brokenLaneFor(token, fromToken, catalogue.brokenLanes) : void 0;
|
|
11047
13311
|
if (measured) {
|
|
11048
|
-
states2[
|
|
13312
|
+
states2[key2] = { disabled: true, reason: brokenLaneReason(measured), hint: "Unavailable" };
|
|
11049
13313
|
continue;
|
|
11050
13314
|
}
|
|
11051
13315
|
const verdict = destinationAvailability(token, catalogue, fromToken);
|
|
11052
13316
|
if (verdict === "available") {
|
|
11053
13317
|
const limit = laneLimitFor(token, fromToken, catalogue.limitedLanes);
|
|
11054
|
-
if (limit) states2[
|
|
13318
|
+
if (limit) states2[key2] = { disabled: false, hint: laneLimitHint(limit, laneLimitSymbol(limit, fromToken ? tokenTicker(fromToken) : void 0)) };
|
|
11055
13319
|
continue;
|
|
11056
13320
|
}
|
|
11057
|
-
states2[
|
|
13321
|
+
states2[key2] = {
|
|
11058
13322
|
disabled: true,
|
|
11059
13323
|
reason: verdict === "hub-only" ? `${tokenTicker(token)} cannot be delivered on this chain \u2014 choose an execution chain.` : "ZeroDelta cannot deliver this asset here.",
|
|
11060
13324
|
hint: verdict === "hub-only" ? "Not here" : "Unavailable"
|
|
@@ -11066,12 +13330,20 @@ function ExchangeCard(props) {
|
|
|
11066
13330
|
() => destinationStates ? toPickerTokens.filter((t) => !destinationStates[`${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`]?.disabled) : toPickerTokens,
|
|
11067
13331
|
[toPickerTokens, destinationStates]
|
|
11068
13332
|
);
|
|
13333
|
+
const seenReadyCatalogue = react.useRef(null);
|
|
13334
|
+
react.useEffect(() => {
|
|
13335
|
+
if (!catalogue?.ready) return;
|
|
13336
|
+
const first = seenReadyCatalogue.current === null;
|
|
13337
|
+
seenReadyCatalogue.current = catalogue;
|
|
13338
|
+
if (first || !to) return;
|
|
13339
|
+
if (destinationStates?.[`${Number(to.chainId)}:${String(findToken(tokens, to.chainId, to.symbol)?.address || "").toLowerCase()}`]?.disabled || !findToken(tokens, to.chainId, to.symbol)) setTo(null);
|
|
13340
|
+
}, [catalogue]);
|
|
11069
13341
|
const normalizedAmount = normalizeDecimalText(amount);
|
|
11070
13342
|
const amountValid = /^\d+(\.\d+)?$/.test(normalizedAmount) && Number(normalizedAmount) > 0 && Number(normalizedAmount) <= 1e9;
|
|
11071
13343
|
const rampMode = mode !== "exchange";
|
|
11072
13344
|
const laneLimit = react.useMemo(
|
|
11073
|
-
() => mode === "exchange" && fromToken &&
|
|
11074
|
-
[mode, catalogue, fromToken,
|
|
13345
|
+
() => mode === "exchange" && fromToken && toToken2 ? laneLimitFor(toToken2, fromToken, catalogue?.limitedLanes) : void 0,
|
|
13346
|
+
[mode, catalogue, fromToken, toToken2]
|
|
11075
13347
|
);
|
|
11076
13348
|
const limitSymbol = laneLimit ? laneLimitSymbol(laneLimit, fromTicker) : "";
|
|
11077
13349
|
const overLimit = react.useMemo(() => {
|
|
@@ -11225,11 +13497,11 @@ function ExchangeCard(props) {
|
|
|
11225
13497
|
useFitText(receiveSideRef, receiveShown);
|
|
11226
13498
|
const toDecimals = react.useMemo(() => {
|
|
11227
13499
|
try {
|
|
11228
|
-
return
|
|
13500
|
+
return toToken2 ? assetDecimals(toToken2) : void 0;
|
|
11229
13501
|
} catch {
|
|
11230
13502
|
return void 0;
|
|
11231
13503
|
}
|
|
11232
|
-
}, [
|
|
13504
|
+
}, [toToken2]);
|
|
11233
13505
|
const meta = solActive ? solFlow.preview ? { bridge: solFlow.preview.bridge || "ZeroDelta", feeBps: solFlow.preview.feeBps, duration: solFlow.preview.estimatedDuration } : null : addressed ? 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;
|
|
11234
13506
|
const pct = (p) => {
|
|
11235
13507
|
if (!fromBal || !fromToken) return;
|
|
@@ -11243,6 +13515,7 @@ function ExchangeCard(props) {
|
|
|
11243
13515
|
const recipientLocked = wide && recipientState.open && recipientPending;
|
|
11244
13516
|
const ctaLabel = rampMode ? soonLabel : submitting ? "Exchanging\u2026" : connected2 && flow.quoteStale ? flow.quotePaused ? "Refresh quote" : "Refreshing quote\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall || "Exchange";
|
|
11245
13517
|
const selected = addressed ? flow.selected : null;
|
|
13518
|
+
const compare = addressed && !solActive ? flow.compare : null;
|
|
11246
13519
|
const hasQuote = Boolean(quotable && !quoting && !quoteError && receive);
|
|
11247
13520
|
const nativeWei = (() => {
|
|
11248
13521
|
try {
|
|
@@ -11299,10 +13572,14 @@ function ExchangeCard(props) {
|
|
|
11299
13572
|
setView("main");
|
|
11300
13573
|
requestAnimationFrame(() => (isFrom ? fromTileRef : toTileRef).current?.focus());
|
|
11301
13574
|
};
|
|
13575
|
+
const openPicker = (v) => () => {
|
|
13576
|
+
setSheet(null);
|
|
13577
|
+
setView(v);
|
|
13578
|
+
};
|
|
11302
13579
|
const closeSheet = () => {
|
|
11303
13580
|
const was = sheet;
|
|
11304
13581
|
setSheet(null);
|
|
11305
|
-
requestAnimationFrame(() => (was === "quote" ? quoteBtnRef : complianceBtnRef).current?.focus());
|
|
13582
|
+
requestAnimationFrame(() => (was === "quote" || was === "compare" ? quoteBtnRef : complianceBtnRef).current?.focus());
|
|
11306
13583
|
};
|
|
11307
13584
|
const pctChips = mode !== "onramp" ? (
|
|
11308
13585
|
// a11y note: <fieldset> carries UA styling that would have to be reset on every host page;
|
|
@@ -11332,7 +13609,7 @@ function ExchangeCard(props) {
|
|
|
11332
13609
|
icon: /* @__PURE__ */ jsxRuntime.jsx(QuoteGlyph, {}),
|
|
11333
13610
|
label: "Quote",
|
|
11334
13611
|
badge: lg && hasQuote ? { text: "Best return", tone: "info" } : null,
|
|
11335
|
-
onClick: () => setSheet("quote"),
|
|
13612
|
+
onClick: () => setSheet(compare ? "compare" : "quote"),
|
|
11336
13613
|
disabled: !hasQuote
|
|
11337
13614
|
}
|
|
11338
13615
|
);
|
|
@@ -11349,7 +13626,27 @@ function ExchangeCard(props) {
|
|
|
11349
13626
|
connect: !wallet.account ? { family: "evm", onClick: () => void wallet.connect(), busy: wallet.connecting } : !solanaWallet.address ? { family: "solana", onClick: (name) => void solanaWallet.connect(name), busy: solanaWallet.status === "connecting", choices: solanaWallet.wallets.map((w) => w.name) } : void 0,
|
|
11350
13627
|
error: solanaWallet.error || wallet.error
|
|
11351
13628
|
}
|
|
11352
|
-
) : recipientState.open ? /* @__PURE__ */ jsxRuntime.jsx(RecipientSheet, { state: recipientState, wide, onPending: wide ? setRecipientPending : void 0 }) : sheet === "compliance" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
13629
|
+
) : recipientState.open ? /* @__PURE__ */ jsxRuntime.jsx(RecipientSheet, { state: recipientState, wide, onPending: wide ? setRecipientPending : void 0 }) : sheet === "compliance" ? /* @__PURE__ */ jsxRuntime.jsx(ComplianceDetails, { compliance, direct: selected?.state === "DIRECT", hasQuote: complianceHasQuote, onBack: closeSheet, layout: wide ? "side" : "card" }) : sheet === "compare" ? (
|
|
13630
|
+
// Stays mounted even when `compare` is momentarily null (a refresh that is loading or failed), mirroring the
|
|
13631
|
+
// dapp's CompareQuotesDialog: it shows the empty/error notice in place of the cards instead of popping the
|
|
13632
|
+
// screen and dropping focus (zd-dapp src/components/CompareQuotesDialog.tsx uses `emptyMessage` the same way).
|
|
13633
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13634
|
+
CompareQuotes,
|
|
13635
|
+
{
|
|
13636
|
+
compare,
|
|
13637
|
+
toSymbol: toTicker,
|
|
13638
|
+
tokens,
|
|
13639
|
+
chainName: (id) => nameOf(id) ?? `Chain ${id}`,
|
|
13640
|
+
onSelect: flow.selectOption,
|
|
13641
|
+
onBack: closeSheet,
|
|
13642
|
+
onRefresh: flow.reload,
|
|
13643
|
+
refreshing: flow.status === "loading",
|
|
13644
|
+
emptyMessage: flow.status === "loading" ? "Fetching quote\u2026" : quoteError || void 0,
|
|
13645
|
+
modal: !!props.inDialog,
|
|
13646
|
+
layout: wide ? "side" : "card"
|
|
13647
|
+
}
|
|
13648
|
+
)
|
|
13649
|
+
) : sheet === "quote" && hasQuote ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
11353
13650
|
QuoteSheet,
|
|
11354
13651
|
{
|
|
11355
13652
|
onClose: closeSheet,
|
|
@@ -11428,7 +13725,7 @@ function ExchangeCard(props) {
|
|
|
11428
13725
|
}
|
|
11429
13726
|
);
|
|
11430
13727
|
} else if (sheetBody && !wide) {
|
|
11431
|
-
takeover = walletsOpen && !walletDetails || recipientState.open;
|
|
13728
|
+
takeover = walletsOpen && !walletDetails || recipientState.open || !walletsOpen && (sheet === "compare" || sheet === "compliance");
|
|
11432
13729
|
body = sheetBody;
|
|
11433
13730
|
} else if (solActive && solFlow.status === "sent") {
|
|
11434
13731
|
body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -11441,7 +13738,7 @@ function ExchangeCard(props) {
|
|
|
11441
13738
|
] }),
|
|
11442
13739
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
11443
13740
|
solDelivery.phase === "tracking" ? "Submitted on Solana \u2014 tracking delivery" : deliveryHeadline(solDelivery, true),
|
|
11444
|
-
solFlow.sent?.recipient ? ` \xB7 ${
|
|
13741
|
+
solFlow.sent?.recipient ? ` \xB7 ${shortAddress3(solFlow.sent.recipient)}` : ""
|
|
11445
13742
|
] }),
|
|
11446
13743
|
/* @__PURE__ */ jsxRuntime.jsx(DeliverySteps, { delivery: solDelivery })
|
|
11447
13744
|
] }),
|
|
@@ -11462,7 +13759,7 @@ function ExchangeCard(props) {
|
|
|
11462
13759
|
] }),
|
|
11463
13760
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
11464
13761
|
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
11465
|
-
recipientState.recipientFamily === "solana" ? ` \xB7 ${
|
|
13762
|
+
recipientState.recipientFamily === "solana" ? ` \xB7 ${shortAddress3(flow.lastTxEntry?.recipient || recipient2)}` : props.recipient ? ` \xB7 ${shortAddress3(props.recipient)}` : ""
|
|
11466
13763
|
] }),
|
|
11467
13764
|
evmDirect ? null : /* @__PURE__ */ jsxRuntime.jsx(DeliverySteps, { delivery: evmDelivery })
|
|
11468
13765
|
] }),
|
|
@@ -11473,7 +13770,7 @@ function ExchangeCard(props) {
|
|
|
11473
13770
|
] });
|
|
11474
13771
|
} else {
|
|
11475
13772
|
const payToken = mode === "onramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatButton, { fiat, onCurrency: setFiatCurrency, disabled: submitting }) : /* @__PURE__ */ jsxRuntime.jsx(TokenButton, { label: "You pay", symbol: from?.symbol ?? null, chainId: from?.chainId ?? null, chainName: nameOf(from?.chainId), token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: () => setView("from") });
|
|
11476
|
-
const receiveToken = mode === "offramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatButton, { fiat, onCurrency: setFiatCurrency, disabled: submitting }) : /* @__PURE__ */ jsxRuntime.jsx(TokenButton, { label: "You receive", symbol: to?.symbol ?? null, chainId: to?.chainId ?? null, chainName: nameOf(to?.chainId), token:
|
|
13773
|
+
const receiveToken = mode === "offramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatButton, { fiat, onCurrency: setFiatCurrency, disabled: submitting }) : /* @__PURE__ */ jsxRuntime.jsx(TokenButton, { label: "You receive", symbol: to?.symbol ?? null, chainId: to?.chainId ?? null, chainName: nameOf(to?.chainId), token: toToken2, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") });
|
|
11477
13774
|
const cta = solActive ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cta-wrap", children: [
|
|
11478
13775
|
solanaSteps,
|
|
11479
13776
|
solanaCta,
|
|
@@ -11494,9 +13791,9 @@ function ExchangeCard(props) {
|
|
|
11494
13791
|
body = wide ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
11495
13792
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-stack", children: [
|
|
11496
13793
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ft", children: [
|
|
11497
|
-
mode === "onramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatTile, { label: "From", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "From", pick: from, chainName: nameOf(from?.chainId), token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: (
|
|
13794
|
+
mode === "onramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatTile, { label: "From", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "From", pick: from, chainName: nameOf(from?.chainId), token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: openPicker("from") }),
|
|
11498
13795
|
/* @__PURE__ */ jsxRuntime.jsx(FlipButton, { small: true, onClick: flip, disabled: !flippable }),
|
|
11499
|
-
mode === "offramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatTile, { label: "To", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "To", pick: to, chainName: nameOf(to?.chainId), token:
|
|
13796
|
+
mode === "offramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatTile, { label: "To", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "To", pick: to, chainName: nameOf(to?.chainId), token: toToken2, disabled: submitting, btnRef: toTileRef, onClick: openPicker("to") })
|
|
11500
13797
|
] }),
|
|
11501
13798
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane", "data-kind": "send", children: [
|
|
11502
13799
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane-top", children: [
|
|
@@ -11590,7 +13887,7 @@ function ExchangeCard(props) {
|
|
|
11590
13887
|
side = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-side-body", children: [
|
|
11591
13888
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv", children: [
|
|
11592
13889
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv-line", children: [
|
|
11593
|
-
/* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: to?.symbol ?? "", logoUrl:
|
|
13890
|
+
/* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: to?.symbol ?? "", logoUrl: toToken2?.logoUrl, chainId: to?.chainId, size: "xs" }),
|
|
11594
13891
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-recv-amt", ref: receiveSideRef, children: /* @__PURE__ */ jsxRuntime.jsx(AmountText, { value: formatCalculatedAmount(receive, toDecimals), exact: receive, suffix: toTicker }) })
|
|
11595
13892
|
] }),
|
|
11596
13893
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv-sub", children: [
|