@glacislabs/stablegenie-zerodelta 4.15.1 → 4.17.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 +5 -2
- package/dist/{chunk-SKVRYU3E.js → chunk-5GVQQIGQ.js} +99 -19
- package/dist/{chunk-Z3W6DRWG.js → chunk-TIMSRHXC.js} +176 -59
- package/dist/core/index.cjs +101 -18
- package/dist/core/index.d.cts +23 -4
- package/dist/core/index.d.ts +23 -4
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +279 -82
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-DRCSjQp0.d.cts → mount-BSXfSSP2.d.cts} +1 -1
- package/dist/{mount-CMsgFE6g.d.ts → mount-BdxMZC70.d.ts} +1 -1
- package/dist/mount.cjs +279 -82
- 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 +10 -8
- package/dist/{verify-CoPaE02j.d.cts → verify-BBREdvIM.d.cts} +3 -0
- package/dist/{verify-CoPaE02j.d.ts → verify-BBREdvIM.d.ts} +3 -0
- package/package.json +1 -1
package/dist/mount.cjs
CHANGED
|
@@ -677,8 +677,8 @@ var STEP_LABEL = {
|
|
|
677
677
|
delivered: "Delivered"
|
|
678
678
|
};
|
|
679
679
|
var label = (name) => STEP_LABEL[name] ?? name.replace(/_/g, " ");
|
|
680
|
-
function deliveryHeadline(delivery, sourceConfirmed,
|
|
681
|
-
if (
|
|
680
|
+
function deliveryHeadline(delivery, sourceConfirmed, direct2 = false) {
|
|
681
|
+
if (direct2) return sourceConfirmed ? "Delivered" : "Submitted \u2014 awaiting confirmation";
|
|
682
682
|
switch (delivery.phase) {
|
|
683
683
|
case "delivered":
|
|
684
684
|
return "Delivered";
|
|
@@ -697,8 +697,8 @@ function deliveryHeadline(delivery, sourceConfirmed, direct = false) {
|
|
|
697
697
|
return sourceConfirmed ? "Sent \u2014 tracking delivery" : "Submitted \u2014 awaiting confirmation";
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
-
function isDelivered(delivery, sourceConfirmed,
|
|
701
|
-
return
|
|
700
|
+
function isDelivered(delivery, sourceConfirmed, direct2 = false) {
|
|
701
|
+
return direct2 ? sourceConfirmed : delivery.phase === "delivered";
|
|
702
702
|
}
|
|
703
703
|
function DeliverySteps(props) {
|
|
704
704
|
const { steps, phase } = props.delivery;
|
|
@@ -871,6 +871,7 @@ var BUNDLED_RPC = {
|
|
|
871
871
|
42161: "https://arb1.arbitrum.io/rpc",
|
|
872
872
|
98866: "https://rpc.plume.org"
|
|
873
873
|
};
|
|
874
|
+
var BUNDLED_SOLANA_RPC = ["https://solana-rpc.publicnode.com", "https://api.mainnet-beta.solana.com"];
|
|
874
875
|
var CHAIN_DISPLAY_NAMES = Object.freeze({
|
|
875
876
|
1: "Ethereum",
|
|
876
877
|
10: "Optimism",
|
|
@@ -910,7 +911,9 @@ var CHAIN_DISPLAY_NAMES = Object.freeze({
|
|
|
910
911
|
9745: "Plasma",
|
|
911
912
|
34443: "Mode",
|
|
912
913
|
42161: "Arbitrum One",
|
|
913
|
-
|
|
914
|
+
// "Avalanche", as the dApp prints it since zd-dapp#582 (from ZD Heavy's /chains). The widget's
|
|
915
|
+
// registry read lists no row for a payout-only chain, so this table is what names it here.
|
|
916
|
+
43114: "Avalanche",
|
|
914
917
|
48900: "Zircuit",
|
|
915
918
|
57073: "Ink",
|
|
916
919
|
59144: "Linea",
|
|
@@ -1907,7 +1910,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1907
1910
|
if (refusal(token)) continue;
|
|
1908
1911
|
seen.add(key);
|
|
1909
1912
|
const payKey = symbolKey(token.symbol);
|
|
1910
|
-
const
|
|
1913
|
+
const direct2 = chainId === invoiceChain && payKey === invoiceKey;
|
|
1911
1914
|
options.push({
|
|
1912
1915
|
symbol: token.symbol,
|
|
1913
1916
|
symbolKey: payKey,
|
|
@@ -1920,7 +1923,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1920
1923
|
logoUrl: token.logoUrl,
|
|
1921
1924
|
bridge: routeBridge.get(`${payKey}:${chainId}`) || token.bridge,
|
|
1922
1925
|
sameChain: chainId === invoiceChain,
|
|
1923
|
-
direct
|
|
1926
|
+
direct: direct2
|
|
1924
1927
|
});
|
|
1925
1928
|
}
|
|
1926
1929
|
options.sort((a, b) => {
|
|
@@ -1941,6 +1944,56 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1941
1944
|
return options;
|
|
1942
1945
|
}
|
|
1943
1946
|
|
|
1947
|
+
// src/core/solana-rpc.ts
|
|
1948
|
+
var ATTEMPT_TIMEOUT_MS = 12e3;
|
|
1949
|
+
var REFUSAL_CODES = /* @__PURE__ */ new Set([-32005, -32029, -32052, 403, 429]);
|
|
1950
|
+
function refusesService(body) {
|
|
1951
|
+
const error = body.error;
|
|
1952
|
+
if (!error) return false;
|
|
1953
|
+
if (REFUSAL_CODES.has(error.code)) return true;
|
|
1954
|
+
return error.code === -32602 && /personal token/i.test(String(error.message ?? ""));
|
|
1955
|
+
}
|
|
1956
|
+
function unwrap(body) {
|
|
1957
|
+
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
1958
|
+
if (body.error || body.result === void 0) throw new Error(String(body.error?.message || "Invalid Solana RPC response."));
|
|
1959
|
+
return body.result;
|
|
1960
|
+
}
|
|
1961
|
+
async function direct(fetchImpl, url, payload) {
|
|
1962
|
+
const controller = new AbortController();
|
|
1963
|
+
const timer2 = setTimeout(() => controller.abort(), ATTEMPT_TIMEOUT_MS);
|
|
1964
|
+
try {
|
|
1965
|
+
const response = await fetchImpl(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: payload, signal: controller.signal });
|
|
1966
|
+
if (!response.ok) return { refused: `HTTP ${response.status}` };
|
|
1967
|
+
const body = await response.json().catch(() => null);
|
|
1968
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return { refused: "not a JSON-RPC body" };
|
|
1969
|
+
if (refusesService(body)) return { refused: `refused (${String(body.error?.code)})` };
|
|
1970
|
+
return { body };
|
|
1971
|
+
} catch (error) {
|
|
1972
|
+
return { refused: controller.signal.aborted ? "timed out" : error instanceof Error ? error.message : String(error) };
|
|
1973
|
+
} finally {
|
|
1974
|
+
clearTimeout(timer2);
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
function createSolanaRpc(api, fetchImpl = globalThis.fetch?.bind(globalThis), urls = BUNDLED_SOLANA_RPC) {
|
|
1978
|
+
return async (method, params) => {
|
|
1979
|
+
const payload = JSON.stringify({ jsonrpc: "2.0", id: 1, method, params });
|
|
1980
|
+
const refused = [];
|
|
1981
|
+
for (const url of urls) {
|
|
1982
|
+
const attempt = await direct(fetchImpl, url, payload);
|
|
1983
|
+
if ("body" in attempt) return unwrap(attempt.body);
|
|
1984
|
+
refused.push(`${new URL(url).host}: ${attempt.refused}`);
|
|
1985
|
+
}
|
|
1986
|
+
let relayed;
|
|
1987
|
+
try {
|
|
1988
|
+
relayed = await api.apiRequest("/solana-rpc", { method: "POST", body: payload, timeoutMs: 15e3 });
|
|
1989
|
+
} catch (error) {
|
|
1990
|
+
refused.push(`proxy: ${error instanceof Error ? error.message : String(error)}`);
|
|
1991
|
+
throw new Error(`No Solana RPC answered ${method} (${refused.join("; ")}).`);
|
|
1992
|
+
}
|
|
1993
|
+
return unwrap(relayed);
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1944
1997
|
// src/core/solana-source.ts
|
|
1945
1998
|
var CANONICAL_SOLANA_PROGRAM = "zd1E5feCJLNYaPPsBAYkCPMKGVnipYf8God9h917W33";
|
|
1946
1999
|
var MAX_ASK_OVER_FINAL_BPS = 200n;
|
|
@@ -2030,6 +2083,8 @@ function normalizePreview(request, quote, to, amount) {
|
|
|
2030
2083
|
estimatedDuration: Number(option.estimatedTimeSec || 0),
|
|
2031
2084
|
via: null,
|
|
2032
2085
|
nativeFeeRaw: String(option.gasCostSource || "0"),
|
|
2086
|
+
zeroDeltaFeeCentibips: option.zeroDeltaFeeCentibips,
|
|
2087
|
+
zeroDeltaFeeNative: option.zeroDeltaFeeNative,
|
|
2033
2088
|
quote,
|
|
2034
2089
|
option,
|
|
2035
2090
|
txData: option.txData,
|
|
@@ -2067,7 +2122,9 @@ async function previewSolanaSource(api, input) {
|
|
|
2067
2122
|
feeBps: Number(option.feeBps || 0),
|
|
2068
2123
|
estimatedDuration: Number(option.estimatedTimeSec || 0),
|
|
2069
2124
|
via: null,
|
|
2070
|
-
nativeFeeRaw: "0"
|
|
2125
|
+
nativeFeeRaw: "0",
|
|
2126
|
+
zeroDeltaFeeCentibips: option.zeroDeltaFeeCentibips,
|
|
2127
|
+
zeroDeltaFeeNative: option.zeroDeltaFeeNative
|
|
2071
2128
|
};
|
|
2072
2129
|
}
|
|
2073
2130
|
function solanaQuoteCompliance(quote) {
|
|
@@ -2186,18 +2243,6 @@ async function buildSolanaSourcePlan(api, input, quoted) {
|
|
|
2186
2243
|
});
|
|
2187
2244
|
return plan;
|
|
2188
2245
|
}
|
|
2189
|
-
function createSolanaRpc(api) {
|
|
2190
|
-
return async (method, params) => {
|
|
2191
|
-
const body = await api.apiRequest("/solana-rpc", {
|
|
2192
|
-
method: "POST",
|
|
2193
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
2194
|
-
timeoutMs: 15e3
|
|
2195
|
-
});
|
|
2196
|
-
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
2197
|
-
if (body.error || body.result === void 0) throw new Error(body.error?.message || "Invalid Solana RPC response.");
|
|
2198
|
-
return body.result;
|
|
2199
|
-
};
|
|
2200
|
-
}
|
|
2201
2246
|
var SolanaSendError = class extends Error {
|
|
2202
2247
|
constructor(message, signature, sentAt) {
|
|
2203
2248
|
super(message);
|
|
@@ -2344,6 +2389,10 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2344
2389
|
try {
|
|
2345
2390
|
solanaKeyBytes(owner);
|
|
2346
2391
|
solanaKeyBytes(mint);
|
|
2392
|
+
} catch {
|
|
2393
|
+
return void 0;
|
|
2394
|
+
}
|
|
2395
|
+
try {
|
|
2347
2396
|
const result = await rpc("getTokenAccountsByOwner", [owner, { mint }, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2348
2397
|
if (!Array.isArray(result.value)) throw new Error("Invalid token accounts.");
|
|
2349
2398
|
let total = 0n, decimals;
|
|
@@ -2354,10 +2403,30 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2354
2403
|
total += BigInt(raw(amount.amount, "token balance"));
|
|
2355
2404
|
}
|
|
2356
2405
|
return total;
|
|
2406
|
+
} catch {
|
|
2407
|
+
}
|
|
2408
|
+
try {
|
|
2409
|
+
return await associatedBalance(rpc, owner, mint);
|
|
2357
2410
|
} catch {
|
|
2358
2411
|
return void 0;
|
|
2359
2412
|
}
|
|
2360
2413
|
}
|
|
2414
|
+
async function associatedBalance(rpc, owner, mint) {
|
|
2415
|
+
const programs = [TOKEN_PROGRAM, TOKEN_2022_PROGRAM];
|
|
2416
|
+
const keys = [...programs.map((p) => associatedTokenAddress(owner, mint, p)), mint];
|
|
2417
|
+
const result = await rpc("getMultipleAccounts", [keys, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2418
|
+
const accounts = result?.value;
|
|
2419
|
+
if (!Array.isArray(accounts) || accounts.length !== keys.length) throw new Error("Invalid token accounts.");
|
|
2420
|
+
if (!accounts[2] || !programs.includes(accounts[2].owner)) throw new Error("Not a token mint.");
|
|
2421
|
+
let total = 0n;
|
|
2422
|
+
for (const [i, account] of accounts.slice(0, 2).entries()) {
|
|
2423
|
+
if (!account) continue;
|
|
2424
|
+
const info = account.data?.parsed?.info;
|
|
2425
|
+
if (account.owner !== programs[i] || info?.mint !== mint) throw new Error("Invalid token account.");
|
|
2426
|
+
total += BigInt(raw(info?.tokenAmount?.amount, "token balance"));
|
|
2427
|
+
}
|
|
2428
|
+
return total;
|
|
2429
|
+
}
|
|
2361
2430
|
function solanaLamportShortfall(logs) {
|
|
2362
2431
|
if (!Array.isArray(logs)) return null;
|
|
2363
2432
|
for (const line of logs) {
|
|
@@ -2850,6 +2919,12 @@ function humanizeComplianceReason(raw2) {
|
|
|
2850
2919
|
}
|
|
2851
2920
|
case "blocked_jurisdiction":
|
|
2852
2921
|
return `Your region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
2922
|
+
// zd-dapp src/lib/complianceReason.ts (#588): ZD Heavy's account-country and wallet-origin rules.
|
|
2923
|
+
// Without these two the payer read the raw code ("account blocked country — IR").
|
|
2924
|
+
case "account_blocked_country":
|
|
2925
|
+
return `Your account doesn't support this region (${cleanJurisdiction(detail)}).`;
|
|
2926
|
+
case "blocked_origin_jurisdiction":
|
|
2927
|
+
return `The wallet's attributed region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
2853
2928
|
case "blocked_destination_jurisdiction":
|
|
2854
2929
|
return `The destination region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
2855
2930
|
case "jurisdiction_out_of_scope":
|
|
@@ -3528,6 +3603,8 @@ async function buildRoute({
|
|
|
3528
3603
|
quote: {
|
|
3529
3604
|
bridge: quote.bridge,
|
|
3530
3605
|
feeBps: quote.feeBps,
|
|
3606
|
+
zeroDeltaFeeCentibips: quote.zeroDeltaFeeCentibips,
|
|
3607
|
+
zeroDeltaFeeNative: quote.zeroDeltaFeeNative,
|
|
3531
3608
|
estimatedDuration: quote.estimatedDuration,
|
|
3532
3609
|
gasCostSource: quote.gasCostSource,
|
|
3533
3610
|
msgValue: valueRaw.toString(),
|
|
@@ -3548,7 +3625,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
3548
3625
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
3549
3626
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
3550
3627
|
var WIDGET_CHANNEL = "widget";
|
|
3551
|
-
var WIDGET_VERSION = "4.
|
|
3628
|
+
var WIDGET_VERSION = "4.17.0" ;
|
|
3552
3629
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
3553
3630
|
function sanitizeVersion(raw2) {
|
|
3554
3631
|
const v = String(raw2).trim();
|
|
@@ -4138,6 +4215,8 @@ async function quoteSwapPreview(api, swap, owner) {
|
|
|
4138
4215
|
return {
|
|
4139
4216
|
receive: formatUnits(final, assetDecimals(destToken)),
|
|
4140
4217
|
receiveRaw: final.toString(),
|
|
4218
|
+
zeroDeltaFeeCentibips: quote.zeroDeltaFeeCentibips,
|
|
4219
|
+
zeroDeltaFeeNative: quote.zeroDeltaFeeNative,
|
|
4141
4220
|
fromAmount: v.amountIn,
|
|
4142
4221
|
fromToken: sourceToken.symbol,
|
|
4143
4222
|
toToken: destToken.symbol,
|
|
@@ -4588,7 +4667,8 @@ function createEngine(config = {}) {
|
|
|
4588
4667
|
const resolved = resolveConfig(config);
|
|
4589
4668
|
const api = createApiClient(resolved);
|
|
4590
4669
|
const verifier = createVerifier(api, resolved.fetchImpl, resolved.rpcOverrides);
|
|
4591
|
-
const
|
|
4670
|
+
const solanaOverride = resolved.rpcOverrides[SOLANA_CHAIN_ID];
|
|
4671
|
+
const solanaRpc = createSolanaRpc(api, resolved.fetchImpl, solanaOverride && /^https?:\/\//i.test(solanaOverride) ? [solanaOverride] : BUNDLED_SOLANA_RPC);
|
|
4592
4672
|
return {
|
|
4593
4673
|
api,
|
|
4594
4674
|
verifier,
|
|
@@ -5052,6 +5132,7 @@ function useFlow(args) {
|
|
|
5052
5132
|
if (busyRef.current) return;
|
|
5053
5133
|
setFieldError(null);
|
|
5054
5134
|
if (!enabled || !wallet.account) {
|
|
5135
|
+
reqId.current++;
|
|
5055
5136
|
setStatus("idle");
|
|
5056
5137
|
setPlan(null);
|
|
5057
5138
|
return;
|
|
@@ -5645,6 +5726,8 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
5645
5726
|
.sg-pk-body{display:flex;flex-direction:column;gap:8px}
|
|
5646
5727
|
.sg-pk-selected{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}
|
|
5647
5728
|
.sg-pk-cap{margin:0;font-size:12px;line-height:1.2;color:var(--sg-text-muted)}
|
|
5729
|
+
.sg-pk-cap--section{margin-top:8px}
|
|
5730
|
+
.sg-pk-bal-missing{flex:0 0 auto;font-size:13px;line-height:1.4;color:var(--sg-text-muted);text-align:right}
|
|
5648
5731
|
.sg-pk-list{display:flex;flex-direction:column;gap:4px;max-height:320px;overflow-y:auto;margin:-1px;padding:1px;scrollbar-width:thin}
|
|
5649
5732
|
.sg-pk-row{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:16px;border:none;border-radius:24px;background:color-mix(in srgb,var(--sg-accent) 4%,transparent);color:var(--sg-text);font:inherit;text-align:left;cursor:pointer;transition:background 120ms ease}
|
|
5650
5733
|
.sg-pk-row:hover{background:color-mix(in srgb,var(--sg-accent) 8%,transparent)}
|
|
@@ -6440,6 +6523,12 @@ var SOURCE_CHAIN_LABELS = {
|
|
|
6440
6523
|
98866: "Plume"
|
|
6441
6524
|
};
|
|
6442
6525
|
var CHAIN_LABELS = { ...CHAIN_DISPLAY_NAMES, ...SOURCE_CHAIN_LABELS };
|
|
6526
|
+
function chainLabel(chainId, chain2) {
|
|
6527
|
+
const pinned = SOURCE_CHAIN_LABELS[chainId];
|
|
6528
|
+
if (pinned) return pinned;
|
|
6529
|
+
const fromRegistry = typeof chain2?.displayName === "string" ? chain2.displayName.trim() : "";
|
|
6530
|
+
return fromRegistry || CHAIN_DISPLAY_NAMES[chainId] || `Chain ${chainId}`;
|
|
6531
|
+
}
|
|
6443
6532
|
var SUPPORTED_CHAINS = [1, 10, 42161, 8453, 57073, 130, 9745, 146, 98866];
|
|
6444
6533
|
var SUPPORTED_ASSETS2 = [
|
|
6445
6534
|
...EXECUTABLE_STABLE_ASSETS,
|
|
@@ -6975,7 +7064,7 @@ function TokenTile(props) {
|
|
|
6975
7064
|
/* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: props.pick.symbol, logoUrl: props.token?.logoUrl, chainId: props.pick.chainId, size: "tile" }),
|
|
6976
7065
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tile-text", children: [
|
|
6977
7066
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-sym", children: shown }),
|
|
6978
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-chain", children: CHAIN_LABELS[props.pick.chainId] || `Chain ${props.pick.chainId}` })
|
|
7067
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-chain", children: props.chainName || CHAIN_LABELS[props.pick.chainId] || `Chain ${props.pick.chainId}` })
|
|
6979
7068
|
] })
|
|
6980
7069
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6981
7070
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok-fb", children: "?" }) }),
|
|
@@ -7054,7 +7143,9 @@ function TickBadge() {
|
|
|
7054
7143
|
] }) });
|
|
7055
7144
|
}
|
|
7056
7145
|
function BalanceColumn(props) {
|
|
7057
|
-
if (props.amount == null)
|
|
7146
|
+
if (props.amount == null) {
|
|
7147
|
+
return props.walletMissing ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-missing", "data-testid": "balance-wallet-missing", children: "Wallet not connected" }) : null;
|
|
7148
|
+
}
|
|
7058
7149
|
if (props.amount === 0) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-zero", children: "0.00" });
|
|
7059
7150
|
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal", children: [
|
|
7060
7151
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-usd sg-mono", children: props.usd == null ? "\u2014" : formatBalanceUsd(props.usd) }),
|
|
@@ -7107,7 +7198,7 @@ function TokenSelect(props) {
|
|
|
7107
7198
|
const listRef = react.useRef(null);
|
|
7108
7199
|
const savedScroll = react.useRef(0);
|
|
7109
7200
|
const chainById2 = react.useMemo(() => new Map(props.chains.map((c) => [Number(c.chainId), c])), [props.chains]);
|
|
7110
|
-
const chainName3 = (chainId) =>
|
|
7201
|
+
const chainName3 = (chainId) => chainLabel(chainId, chainById2.get(chainId));
|
|
7111
7202
|
const showBalances = side === "from" && !!props.balances && Object.keys(props.balances).length > 0;
|
|
7112
7203
|
const [prices, setPrices] = react.useState({});
|
|
7113
7204
|
const symbolKey2 = react.useMemo(() => [...new Set(props.tokens.map((t) => String(t.symbol).toUpperCase()))].sort().join(","), [props.tokens]);
|
|
@@ -7153,6 +7244,15 @@ function TokenSelect(props) {
|
|
|
7153
7244
|
}, [props.tokens, props.balances, props.optionStates, showBalances, prices]);
|
|
7154
7245
|
const chainTerms = react.useMemo(() => buildChainSearchTerms(props.chains), [props.chains]);
|
|
7155
7246
|
const visible = react.useMemo(() => searchGroups(groups, query, chainTerms, prices), [groups, query, chainTerms, prices]);
|
|
7247
|
+
const { listed, other } = react.useMemo(() => {
|
|
7248
|
+
const held = [];
|
|
7249
|
+
const none = [];
|
|
7250
|
+
for (const g of visible) {
|
|
7251
|
+
const readZero = showBalances && !g.unavailable && g.deployments.length > 0 && g.deployments.every((d) => d.balance === 0);
|
|
7252
|
+
(readZero ? none : held).push(g);
|
|
7253
|
+
}
|
|
7254
|
+
return { listed: held, other: none };
|
|
7255
|
+
}, [visible, showBalances]);
|
|
7156
7256
|
const openGroup = openKey ? visible.find((g) => g.key === openKey) ?? null : null;
|
|
7157
7257
|
react.useEffect(() => {
|
|
7158
7258
|
if (openKey && !openGroup) setOpenKey(null);
|
|
@@ -7209,7 +7309,7 @@ function TokenSelect(props) {
|
|
|
7209
7309
|
d.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: d.hint }) : null
|
|
7210
7310
|
] })
|
|
7211
7311
|
] }),
|
|
7212
|
-
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: d.balance, usd: usdOf(d.balance, prices, d.token.symbol), symbol: ticker }) : null
|
|
7312
|
+
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: d.balance, usd: usdOf(d.balance, prices, d.token.symbol), symbol: ticker, walletMissing: props.walletMissing?.(d.token) }) : null
|
|
7213
7313
|
] }, d.key);
|
|
7214
7314
|
}) })
|
|
7215
7315
|
] });
|
|
@@ -7248,52 +7348,58 @@ function TokenSelect(props) {
|
|
|
7248
7348
|
) : null
|
|
7249
7349
|
] })
|
|
7250
7350
|
] }) : null,
|
|
7251
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-cap", children: side === "from" ? "Your tokens \xB7 All networks" : "Popular tokens \xB7 All networks" }),
|
|
7252
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-pk-list", ref: listRef, role: "group", "aria-label": props.title, children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-empty", children: props.loading ? "Loading the token list\u2026" : "No tokens found." }) :
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
const blocked = !!g.unavailable;
|
|
7258
|
-
const opensNetworks = multi || blocked;
|
|
7259
|
-
const zero = showBalances && g.amount === 0 || blocked;
|
|
7260
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7261
|
-
"button",
|
|
7262
|
-
{
|
|
7263
|
-
type: "button",
|
|
7264
|
-
className: "sg-pk-row",
|
|
7265
|
-
"data-testid": "token-row",
|
|
7266
|
-
"data-symbol": g.symbol,
|
|
7267
|
-
"data-networks": members.length,
|
|
7268
|
-
"data-zero": zero || void 0,
|
|
7269
|
-
"data-unavailable": blocked || void 0,
|
|
7270
|
-
onClick: () => {
|
|
7271
|
-
if (opensNetworks) {
|
|
7272
|
-
savedScroll.current = listRef.current?.scrollTop ?? 0;
|
|
7273
|
-
setOpenKey(g.key);
|
|
7274
|
-
} else pick(single.token);
|
|
7275
|
-
},
|
|
7276
|
-
children: [
|
|
7277
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
|
|
7278
|
-
/* @__PURE__ */ jsxRuntime.jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
|
|
7279
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
|
|
7280
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: label2 }),
|
|
7281
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-line", children: [
|
|
7282
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-sub", children: multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
|
|
7283
|
-
/* @__PURE__ */ jsxRuntime.jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById: chainById2, decorative: !multi }),
|
|
7284
|
-
opensNetworks && showBalances ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev sg-pk-chev--sm", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
|
|
7285
|
-
] }),
|
|
7286
|
-
!multi && single.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
|
|
7287
|
-
] })
|
|
7288
|
-
] }),
|
|
7289
|
-
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol: label2 }) : opensNetworks ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
|
|
7290
|
-
]
|
|
7291
|
-
},
|
|
7292
|
-
g.key
|
|
7293
|
-
);
|
|
7294
|
-
}) })
|
|
7351
|
+
listed.length > 0 || visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-cap", children: side === "from" ? "Your tokens \xB7 All networks" : "Popular tokens \xB7 All networks" }) : null,
|
|
7352
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-pk-list", ref: listRef, role: "group", "aria-label": props.title, children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-empty", children: props.loading ? "Loading the token list\u2026" : "No tokens found." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7353
|
+
listed.map((g) => renderRow(g, false)),
|
|
7354
|
+
other.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-cap sg-pk-cap--section", "data-testid": "other-tokens-cap", children: "Other supported tokens" }) : null,
|
|
7355
|
+
other.map((g) => renderRow(g, true))
|
|
7356
|
+
] }) })
|
|
7295
7357
|
] })
|
|
7296
7358
|
] });
|
|
7359
|
+
function renderRow(g, discovery) {
|
|
7360
|
+
const members = g.deployments;
|
|
7361
|
+
const multi = members.length > 1;
|
|
7362
|
+
const single = members[0];
|
|
7363
|
+
const label2 = multi ? g.symbol : tokenTicker(single.token);
|
|
7364
|
+
const blocked = !!g.unavailable;
|
|
7365
|
+
const opensNetworks = multi || blocked;
|
|
7366
|
+
const zero = showBalances && g.amount === 0 || blocked;
|
|
7367
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7368
|
+
"button",
|
|
7369
|
+
{
|
|
7370
|
+
type: "button",
|
|
7371
|
+
className: "sg-pk-row",
|
|
7372
|
+
"data-testid": "token-row",
|
|
7373
|
+
"data-symbol": g.symbol,
|
|
7374
|
+
"data-networks": members.length,
|
|
7375
|
+
"data-zero": zero || void 0,
|
|
7376
|
+
"data-discovery": discovery || void 0,
|
|
7377
|
+
"data-unavailable": blocked || void 0,
|
|
7378
|
+
onClick: () => {
|
|
7379
|
+
if (opensNetworks) {
|
|
7380
|
+
savedScroll.current = listRef.current?.scrollTop ?? 0;
|
|
7381
|
+
setOpenKey(g.key);
|
|
7382
|
+
} else pick(single.token);
|
|
7383
|
+
},
|
|
7384
|
+
children: [
|
|
7385
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
|
|
7386
|
+
/* @__PURE__ */ jsxRuntime.jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
|
|
7387
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
|
|
7388
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: label2 }),
|
|
7389
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-line", children: [
|
|
7390
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-sub", children: discovery ? "Available on" : multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
|
|
7391
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById: chainById2, decorative: !multi && !discovery }),
|
|
7392
|
+
opensNetworks && showBalances ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev sg-pk-chev--sm", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
|
|
7393
|
+
] }),
|
|
7394
|
+
!multi && single.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
|
|
7395
|
+
] })
|
|
7396
|
+
] }),
|
|
7397
|
+
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol: label2, walletMissing: !multi && props.walletMissing?.(single.token) }) : opensNetworks ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
|
|
7398
|
+
]
|
|
7399
|
+
},
|
|
7400
|
+
g.key
|
|
7401
|
+
);
|
|
7402
|
+
}
|
|
7297
7403
|
}
|
|
7298
7404
|
function ChevronRight({ size = 16 }) {
|
|
7299
7405
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 4l4 4-4 4", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
@@ -7370,7 +7476,7 @@ function durationLabel(seconds) {
|
|
|
7370
7476
|
}
|
|
7371
7477
|
function TokenButton(props) {
|
|
7372
7478
|
const shown = props.token ? tokenTicker(props.token) : props.symbol ?? "";
|
|
7373
|
-
const chain2 = props.chainId ? CHAIN_LABELS[props.chainId] || `Chain ${props.chainId}` : "";
|
|
7479
|
+
const chain2 = props.chainId ? props.chainName || CHAIN_LABELS[props.chainId] || `Chain ${props.chainId}` : "";
|
|
7374
7480
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7375
7481
|
"button",
|
|
7376
7482
|
{
|
|
@@ -7594,7 +7700,7 @@ function QuoteChecks({
|
|
|
7594
7700
|
compliance,
|
|
7595
7701
|
cv,
|
|
7596
7702
|
checks,
|
|
7597
|
-
direct,
|
|
7703
|
+
direct: direct2,
|
|
7598
7704
|
onViewPolicy
|
|
7599
7705
|
}) {
|
|
7600
7706
|
const allPassed = cv.tone === "ok" && checks.length > 0 && checks.every((c) => c.ok);
|
|
@@ -7623,7 +7729,7 @@ function QuoteChecks({
|
|
|
7623
7729
|
] }),
|
|
7624
7730
|
checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cp-checks", children: checks.map((check2) => /* @__PURE__ */ jsxRuntime.jsx(CheckRow, { check: check2, onViewPolicy }, check2.id)) }) : null,
|
|
7625
7731
|
orphans.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cp-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
|
|
7626
|
-
|
|
7732
|
+
direct2 && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cp-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
7627
7733
|
] }),
|
|
7628
7734
|
compliance?.flaggedCategories?.length ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cp-card", children: [
|
|
7629
7735
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cp-card-head", children: [
|
|
@@ -7835,7 +7941,7 @@ function CheckGlyph() {
|
|
|
7835
7941
|
function HistoryButton(props) {
|
|
7836
7942
|
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", ref: props.btnRef, className: "sg-hist", disabled: props.disabled, onClick: props.onClick, "aria-label": "Transaction history", title: "Transaction history", children: /* @__PURE__ */ jsxRuntime.jsx(HistoryGlyph, {}) });
|
|
7837
7943
|
}
|
|
7838
|
-
function
|
|
7944
|
+
function chainLabel2(entry) {
|
|
7839
7945
|
return entry.chainId != null && CHAIN_LABELS[entry.chainId] || entry.chainName || (entry.chainId != null ? `Chain ${entry.chainId}` : "Unknown chain");
|
|
7840
7946
|
}
|
|
7841
7947
|
function chainName(chainId, fallback) {
|
|
@@ -7968,7 +8074,7 @@ function TxHistoryList(props) {
|
|
|
7968
8074
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-txrow-when", children: [
|
|
7969
8075
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-txrow-what", children: [
|
|
7970
8076
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: e.kind === "payment" ? "Payment" : "Swap" }),
|
|
7971
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children:
|
|
8077
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: chainLabel2(e) }),
|
|
7972
8078
|
(e.legs?.length ?? 1) > 1 ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: ordersLabel(e.legs.length) }) : null
|
|
7973
8079
|
] }),
|
|
7974
8080
|
whenLabel(e.at) ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-txrow-time", children: whenLabel(e.at) }) : null
|
|
@@ -8025,7 +8131,7 @@ function TxDetail(props) {
|
|
|
8025
8131
|
] }),
|
|
8026
8132
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
|
|
8027
8133
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Signed on" }),
|
|
8028
|
-
/* @__PURE__ */ jsxRuntime.jsx("b", { children:
|
|
8134
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: chainLabel2(e) })
|
|
8029
8135
|
] }),
|
|
8030
8136
|
e.recipient ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
|
|
8031
8137
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Recipient" }),
|
|
@@ -10681,6 +10787,86 @@ function QuoteSheet(props) {
|
|
|
10681
10787
|
] })
|
|
10682
10788
|
] });
|
|
10683
10789
|
}
|
|
10790
|
+
|
|
10791
|
+
// src/react/ui/cost.ts
|
|
10792
|
+
function tenPow(d) {
|
|
10793
|
+
let x = 1n;
|
|
10794
|
+
for (let i = 0; i < d; i++) x *= 10n;
|
|
10795
|
+
return x;
|
|
10796
|
+
}
|
|
10797
|
+
function divRoundNearest(n, d) {
|
|
10798
|
+
if (d === 0n) return 0n;
|
|
10799
|
+
const sign2 = n < 0n !== d < 0n ? -1n : 1n;
|
|
10800
|
+
const an = n < 0n ? -n : n;
|
|
10801
|
+
const ad = d < 0n ? -d : d;
|
|
10802
|
+
let q = an / ad;
|
|
10803
|
+
const r = an - q * ad;
|
|
10804
|
+
if (r * 2n >= ad) q += 1n;
|
|
10805
|
+
return sign2 * q;
|
|
10806
|
+
}
|
|
10807
|
+
function parSpreadBps(fromAmountRaw, fromDecimals, toAmountRaw, toDecimals) {
|
|
10808
|
+
try {
|
|
10809
|
+
const from = BigInt(fromAmountRaw);
|
|
10810
|
+
const to = BigInt(toAmountRaw);
|
|
10811
|
+
if (from <= 0n) return null;
|
|
10812
|
+
const pFrom = tenPow(fromDecimals);
|
|
10813
|
+
const pTo = tenPow(toDecimals);
|
|
10814
|
+
const den = from * pTo;
|
|
10815
|
+
if (den === 0n) return null;
|
|
10816
|
+
return Number(divRoundNearest((den - to * pFrom) * 100000n, den)) / 10;
|
|
10817
|
+
} catch {
|
|
10818
|
+
return null;
|
|
10819
|
+
}
|
|
10820
|
+
}
|
|
10821
|
+
function totalCostBps(fromUsd, toUsd) {
|
|
10822
|
+
if (fromUsd == null || toUsd == null) return null;
|
|
10823
|
+
if (!Number.isFinite(fromUsd) || !Number.isFinite(toUsd) || fromUsd <= 0) return null;
|
|
10824
|
+
return (fromUsd - toUsd) / fromUsd * 1e4;
|
|
10825
|
+
}
|
|
10826
|
+
function costBasisFor(fromSymbol, toSymbol) {
|
|
10827
|
+
return assetClassOf(fromSymbol) === "stable" && assetClassOf(toSymbol) === "stable" ? "tokens" : "value";
|
|
10828
|
+
}
|
|
10829
|
+
function quoteCostBps(input) {
|
|
10830
|
+
if (!input.fromSymbol || !input.toSymbol) return null;
|
|
10831
|
+
if (costBasisFor(input.fromSymbol, input.toSymbol) === "value") {
|
|
10832
|
+
const usd2 = (amount, price) => price === void 0 || !amount ? null : Number(amount) * price;
|
|
10833
|
+
return totalCostBps(usd2(input.send, input.fromPrice), usd2(input.receive, input.toPrice));
|
|
10834
|
+
}
|
|
10835
|
+
try {
|
|
10836
|
+
if (!input.send || !input.receive) return null;
|
|
10837
|
+
return parSpreadBps(parseUnitsDecimal(input.send, 18).toString(), 18, parseUnitsDecimal(input.receive, 18).toString(), 18);
|
|
10838
|
+
} catch {
|
|
10839
|
+
return null;
|
|
10840
|
+
}
|
|
10841
|
+
}
|
|
10842
|
+
function statedCentibips(fee) {
|
|
10843
|
+
const c = fee?.zeroDeltaFeeCentibips;
|
|
10844
|
+
return typeof c === "number" && Number.isSafeInteger(c) && c >= 0 ? c : null;
|
|
10845
|
+
}
|
|
10846
|
+
function centibipsPct(centibips) {
|
|
10847
|
+
if (centibips === 0) return "0%";
|
|
10848
|
+
const whole = Math.floor(centibips / 1e4);
|
|
10849
|
+
const frac = String(centibips % 1e4).padStart(4, "0").replace(/0+$/, "").padEnd(2, "0");
|
|
10850
|
+
return `${whole}.${frac}%`;
|
|
10851
|
+
}
|
|
10852
|
+
function zeroDeltaFeeLabel(fee, native) {
|
|
10853
|
+
const centibips = statedCentibips(fee);
|
|
10854
|
+
if (centibips === null) return "--";
|
|
10855
|
+
const pct = centibipsPct(centibips);
|
|
10856
|
+
const raw2 = fee?.zeroDeltaFeeNative;
|
|
10857
|
+
if (typeof raw2 !== "string" || !/^\d+$/.test(raw2) || BigInt(raw2) === 0n) return pct;
|
|
10858
|
+
return `${pct} + ${formatUnits(raw2, native.decimals, 8)} ${native.symbol}`;
|
|
10859
|
+
}
|
|
10860
|
+
function formatCostBps(bps) {
|
|
10861
|
+
const rounded = Number(bps.toFixed(1));
|
|
10862
|
+
const sign2 = rounded < 0 ? "\u2212" : "+";
|
|
10863
|
+
return `${sign2}${Math.abs(rounded).toFixed(1)} bps`;
|
|
10864
|
+
}
|
|
10865
|
+
function rateImpactLabel(totalBps, fee) {
|
|
10866
|
+
if (totalBps === null) return "--";
|
|
10867
|
+
const centibips = statedCentibips(fee);
|
|
10868
|
+
return formatCostBps(totalBps - (centibips === null ? 0 : centibips / 100));
|
|
10869
|
+
}
|
|
10684
10870
|
var FIAT = [
|
|
10685
10871
|
{ code: "USD", glyph: "$", label: "US Dollar" },
|
|
10686
10872
|
{ code: "EUR", glyph: "\u20AC", label: "Euro" },
|
|
@@ -10748,6 +10934,8 @@ function ExchangeCard(props) {
|
|
|
10748
10934
|
const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
|
|
10749
10935
|
return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
|
|
10750
10936
|
}, [catalogue]);
|
|
10937
|
+
const chainRow = react.useMemo(() => new Map(chains.map((c) => [Number(c.chainId), c])), [chains]);
|
|
10938
|
+
const nameOf = (id) => id ? chainLabel(id, chainRow.get(id)) : void 0;
|
|
10751
10939
|
const tokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
|
|
10752
10940
|
const sourceTokens = react.useMemo(() => catalogue?.sources ?? [], [catalogue]);
|
|
10753
10941
|
const [view, setView] = react.useState("main");
|
|
@@ -11038,6 +11226,13 @@ function ExchangeCard(props) {
|
|
|
11038
11226
|
const complianceHasQuote = solActive ? Boolean(solFlow.plan && solFlow.status !== "quoting") : Boolean(selected && flow.status !== "loading");
|
|
11039
11227
|
const fromUsd = usdOf2(normalizedAmount, prices[from?.symbol ?? ""]);
|
|
11040
11228
|
const toUsd = usdOf2(receive, prices[to?.symbol ?? ""]);
|
|
11229
|
+
const statedFee = solActive ? solFlow.preview : addressed ? selected?.quote : preview.data;
|
|
11230
|
+
const feeNative = solActive ? { symbol: "SOL", decimals: 9 } : { symbol: nativeSymbol(from?.chainId ?? 1, chains), decimals: 18 };
|
|
11231
|
+
const feeLabel = hasQuote ? zeroDeltaFeeLabel(statedFee, feeNative) : "--";
|
|
11232
|
+
const rateImpact = hasQuote ? rateImpactLabel(
|
|
11233
|
+
quoteCostBps({ send: normalizedAmount, receive, fromSymbol: from?.symbol, toSymbol: to?.symbol, fromPrice: prices[from?.symbol ?? ""], toPrice: prices[to?.symbol ?? ""] }),
|
|
11234
|
+
statedFee
|
|
11235
|
+
) : "--";
|
|
11041
11236
|
const flippable = !rampMode && !submitting && Boolean(to && sourceTokens.some((t) => Number(t.chainId) === to.chainId && symbolKey(t.symbol) === to.symbol));
|
|
11042
11237
|
const flip = () => {
|
|
11043
11238
|
if (!flippable) return;
|
|
@@ -11128,7 +11323,8 @@ function ExchangeCard(props) {
|
|
|
11128
11323
|
{ label: "You send", value: `${normalizedAmount} ${fromTicker}` },
|
|
11129
11324
|
{ label: "You receive", value: `${receive} ${toTicker}` },
|
|
11130
11325
|
...rate ? [{ label: "Rate", value: `1 ${fromTicker} = ${rate} ${toTicker}` }] : [],
|
|
11131
|
-
{ label: "
|
|
11326
|
+
{ label: "Rate impact", value: rateImpact },
|
|
11327
|
+
{ label: "Fee", value: feeLabel },
|
|
11132
11328
|
{ label: "Network fee", value: networkFee },
|
|
11133
11329
|
...eta ? [{ label: "Estimated time", value: eta }] : []
|
|
11134
11330
|
],
|
|
@@ -11185,6 +11381,7 @@ function ExchangeCard(props) {
|
|
|
11185
11381
|
balances,
|
|
11186
11382
|
optionStates: isFrom ? void 0 : destinationStates,
|
|
11187
11383
|
loading: !catalogue?.ready,
|
|
11384
|
+
walletMissing: (t) => isSolanaChainId(t.chainId) && !solanaWallet.address,
|
|
11188
11385
|
onBack: () => closeSelector(isFrom),
|
|
11189
11386
|
onPick: (pick) => {
|
|
11190
11387
|
(isFrom ? setFrom : setTo)({ chainId: pick.chainId, symbol: symbolKey(pick.symbol) });
|
|
@@ -11237,8 +11434,8 @@ function ExchangeCard(props) {
|
|
|
11237
11434
|
] })
|
|
11238
11435
|
] });
|
|
11239
11436
|
} else {
|
|
11240
|
-
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, token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: () => setView("from") });
|
|
11241
|
-
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, token: toToken, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") });
|
|
11437
|
+
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") });
|
|
11438
|
+
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: toToken, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") });
|
|
11242
11439
|
const cta = solActive ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cta-wrap", children: [
|
|
11243
11440
|
solanaSteps,
|
|
11244
11441
|
solanaCta,
|
|
@@ -11259,9 +11456,9 @@ function ExchangeCard(props) {
|
|
|
11259
11456
|
body = wide ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
11260
11457
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-stack", children: [
|
|
11261
11458
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ft", children: [
|
|
11262
|
-
mode === "onramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatTile, { label: "From", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "From", pick: from, token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: () => setView("from") }),
|
|
11459
|
+
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: () => setView("from") }),
|
|
11263
11460
|
/* @__PURE__ */ jsxRuntime.jsx(FlipButton, { small: true, onClick: flip, disabled: !flippable }),
|
|
11264
|
-
mode === "offramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatTile, { label: "To", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "To", pick: to, token: toToken, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") })
|
|
11461
|
+
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: toToken, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") })
|
|
11265
11462
|
] }),
|
|
11266
11463
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane", "data-kind": "send", children: [
|
|
11267
11464
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane-top", children: [
|
|
@@ -11360,7 +11557,7 @@ function ExchangeCard(props) {
|
|
|
11360
11557
|
] }),
|
|
11361
11558
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv-sub", children: [
|
|
11362
11559
|
"On ",
|
|
11363
|
-
|
|
11560
|
+
nameOf(to?.chainId) ?? `Chain ${to?.chainId}`
|
|
11364
11561
|
] })
|
|
11365
11562
|
] }),
|
|
11366
11563
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-stack", children: [
|
package/dist/mount.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { M as MountConfig, t as mount } from './mount-
|
|
1
|
+
export { M as MountConfig, t as mount } from './mount-BSXfSSP2.cjs';
|
|
2
2
|
import 'react';
|
|
3
|
-
import './verify-
|
|
3
|
+
import './verify-BBREdvIM.cjs';
|
package/dist/mount.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { M as MountConfig, t as mount } from './mount-
|
|
1
|
+
export { M as MountConfig, t as mount } from './mount-BdxMZC70.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import './verify-
|
|
3
|
+
import './verify-BBREdvIM.js';
|