@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/index.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;
|
|
@@ -874,6 +874,7 @@ var BUNDLED_RPC = {
|
|
|
874
874
|
42161: "https://arb1.arbitrum.io/rpc",
|
|
875
875
|
98866: "https://rpc.plume.org"
|
|
876
876
|
};
|
|
877
|
+
var BUNDLED_SOLANA_RPC = ["https://solana-rpc.publicnode.com", "https://api.mainnet-beta.solana.com"];
|
|
877
878
|
var CHAIN_DISPLAY_NAMES = Object.freeze({
|
|
878
879
|
1: "Ethereum",
|
|
879
880
|
10: "Optimism",
|
|
@@ -913,7 +914,9 @@ var CHAIN_DISPLAY_NAMES = Object.freeze({
|
|
|
913
914
|
9745: "Plasma",
|
|
914
915
|
34443: "Mode",
|
|
915
916
|
42161: "Arbitrum One",
|
|
916
|
-
|
|
917
|
+
// "Avalanche", as the dApp prints it since zd-dapp#582 (from ZD Heavy's /chains). The widget's
|
|
918
|
+
// registry read lists no row for a payout-only chain, so this table is what names it here.
|
|
919
|
+
43114: "Avalanche",
|
|
917
920
|
48900: "Zircuit",
|
|
918
921
|
57073: "Ink",
|
|
919
922
|
59144: "Linea",
|
|
@@ -1910,7 +1913,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1910
1913
|
if (refusal(token)) continue;
|
|
1911
1914
|
seen.add(key);
|
|
1912
1915
|
const payKey = symbolKey(token.symbol);
|
|
1913
|
-
const
|
|
1916
|
+
const direct2 = chainId === invoiceChain && payKey === invoiceKey;
|
|
1914
1917
|
options.push({
|
|
1915
1918
|
symbol: token.symbol,
|
|
1916
1919
|
symbolKey: payKey,
|
|
@@ -1923,7 +1926,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1923
1926
|
logoUrl: token.logoUrl,
|
|
1924
1927
|
bridge: routeBridge.get(`${payKey}:${chainId}`) || token.bridge,
|
|
1925
1928
|
sameChain: chainId === invoiceChain,
|
|
1926
|
-
direct
|
|
1929
|
+
direct: direct2
|
|
1927
1930
|
});
|
|
1928
1931
|
}
|
|
1929
1932
|
options.sort((a, b) => {
|
|
@@ -1944,6 +1947,56 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1944
1947
|
return options;
|
|
1945
1948
|
}
|
|
1946
1949
|
|
|
1950
|
+
// src/core/solana-rpc.ts
|
|
1951
|
+
var ATTEMPT_TIMEOUT_MS = 12e3;
|
|
1952
|
+
var REFUSAL_CODES = /* @__PURE__ */ new Set([-32005, -32029, -32052, 403, 429]);
|
|
1953
|
+
function refusesService(body) {
|
|
1954
|
+
const error = body.error;
|
|
1955
|
+
if (!error) return false;
|
|
1956
|
+
if (REFUSAL_CODES.has(error.code)) return true;
|
|
1957
|
+
return error.code === -32602 && /personal token/i.test(String(error.message ?? ""));
|
|
1958
|
+
}
|
|
1959
|
+
function unwrap(body) {
|
|
1960
|
+
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
1961
|
+
if (body.error || body.result === void 0) throw new Error(String(body.error?.message || "Invalid Solana RPC response."));
|
|
1962
|
+
return body.result;
|
|
1963
|
+
}
|
|
1964
|
+
async function direct(fetchImpl, url, payload) {
|
|
1965
|
+
const controller = new AbortController();
|
|
1966
|
+
const timer2 = setTimeout(() => controller.abort(), ATTEMPT_TIMEOUT_MS);
|
|
1967
|
+
try {
|
|
1968
|
+
const response = await fetchImpl(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: payload, signal: controller.signal });
|
|
1969
|
+
if (!response.ok) return { refused: `HTTP ${response.status}` };
|
|
1970
|
+
const body = await response.json().catch(() => null);
|
|
1971
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return { refused: "not a JSON-RPC body" };
|
|
1972
|
+
if (refusesService(body)) return { refused: `refused (${String(body.error?.code)})` };
|
|
1973
|
+
return { body };
|
|
1974
|
+
} catch (error) {
|
|
1975
|
+
return { refused: controller.signal.aborted ? "timed out" : error instanceof Error ? error.message : String(error) };
|
|
1976
|
+
} finally {
|
|
1977
|
+
clearTimeout(timer2);
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
function createSolanaRpc(api, fetchImpl = globalThis.fetch?.bind(globalThis), urls = BUNDLED_SOLANA_RPC) {
|
|
1981
|
+
return async (method, params) => {
|
|
1982
|
+
const payload = JSON.stringify({ jsonrpc: "2.0", id: 1, method, params });
|
|
1983
|
+
const refused = [];
|
|
1984
|
+
for (const url of urls) {
|
|
1985
|
+
const attempt = await direct(fetchImpl, url, payload);
|
|
1986
|
+
if ("body" in attempt) return unwrap(attempt.body);
|
|
1987
|
+
refused.push(`${new URL(url).host}: ${attempt.refused}`);
|
|
1988
|
+
}
|
|
1989
|
+
let relayed;
|
|
1990
|
+
try {
|
|
1991
|
+
relayed = await api.apiRequest("/solana-rpc", { method: "POST", body: payload, timeoutMs: 15e3 });
|
|
1992
|
+
} catch (error) {
|
|
1993
|
+
refused.push(`proxy: ${error instanceof Error ? error.message : String(error)}`);
|
|
1994
|
+
throw new Error(`No Solana RPC answered ${method} (${refused.join("; ")}).`);
|
|
1995
|
+
}
|
|
1996
|
+
return unwrap(relayed);
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
|
|
1947
2000
|
// src/core/solana-source.ts
|
|
1948
2001
|
var CANONICAL_SOLANA_PROGRAM = "zd1E5feCJLNYaPPsBAYkCPMKGVnipYf8God9h917W33";
|
|
1949
2002
|
var MAX_ASK_OVER_FINAL_BPS = 200n;
|
|
@@ -2033,6 +2086,8 @@ function normalizePreview(request, quote, to, amount) {
|
|
|
2033
2086
|
estimatedDuration: Number(option.estimatedTimeSec || 0),
|
|
2034
2087
|
via: null,
|
|
2035
2088
|
nativeFeeRaw: String(option.gasCostSource || "0"),
|
|
2089
|
+
zeroDeltaFeeCentibips: option.zeroDeltaFeeCentibips,
|
|
2090
|
+
zeroDeltaFeeNative: option.zeroDeltaFeeNative,
|
|
2036
2091
|
quote,
|
|
2037
2092
|
option,
|
|
2038
2093
|
txData: option.txData,
|
|
@@ -2070,7 +2125,9 @@ async function previewSolanaSource(api, input) {
|
|
|
2070
2125
|
feeBps: Number(option.feeBps || 0),
|
|
2071
2126
|
estimatedDuration: Number(option.estimatedTimeSec || 0),
|
|
2072
2127
|
via: null,
|
|
2073
|
-
nativeFeeRaw: "0"
|
|
2128
|
+
nativeFeeRaw: "0",
|
|
2129
|
+
zeroDeltaFeeCentibips: option.zeroDeltaFeeCentibips,
|
|
2130
|
+
zeroDeltaFeeNative: option.zeroDeltaFeeNative
|
|
2074
2131
|
};
|
|
2075
2132
|
}
|
|
2076
2133
|
function solanaQuoteCompliance(quote) {
|
|
@@ -2189,18 +2246,6 @@ async function buildSolanaSourcePlan(api, input, quoted) {
|
|
|
2189
2246
|
});
|
|
2190
2247
|
return plan;
|
|
2191
2248
|
}
|
|
2192
|
-
function createSolanaRpc(api) {
|
|
2193
|
-
return async (method, params) => {
|
|
2194
|
-
const body = await api.apiRequest("/solana-rpc", {
|
|
2195
|
-
method: "POST",
|
|
2196
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
2197
|
-
timeoutMs: 15e3
|
|
2198
|
-
});
|
|
2199
|
-
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
2200
|
-
if (body.error || body.result === void 0) throw new Error(body.error?.message || "Invalid Solana RPC response.");
|
|
2201
|
-
return body.result;
|
|
2202
|
-
};
|
|
2203
|
-
}
|
|
2204
2249
|
var SolanaSendError = class extends Error {
|
|
2205
2250
|
constructor(message, signature, sentAt) {
|
|
2206
2251
|
super(message);
|
|
@@ -2347,6 +2392,10 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2347
2392
|
try {
|
|
2348
2393
|
solanaKeyBytes(owner);
|
|
2349
2394
|
solanaKeyBytes(mint);
|
|
2395
|
+
} catch {
|
|
2396
|
+
return void 0;
|
|
2397
|
+
}
|
|
2398
|
+
try {
|
|
2350
2399
|
const result = await rpc("getTokenAccountsByOwner", [owner, { mint }, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2351
2400
|
if (!Array.isArray(result.value)) throw new Error("Invalid token accounts.");
|
|
2352
2401
|
let total = 0n, decimals;
|
|
@@ -2357,10 +2406,30 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2357
2406
|
total += BigInt(raw(amount.amount, "token balance"));
|
|
2358
2407
|
}
|
|
2359
2408
|
return total;
|
|
2409
|
+
} catch {
|
|
2410
|
+
}
|
|
2411
|
+
try {
|
|
2412
|
+
return await associatedBalance(rpc, owner, mint);
|
|
2360
2413
|
} catch {
|
|
2361
2414
|
return void 0;
|
|
2362
2415
|
}
|
|
2363
2416
|
}
|
|
2417
|
+
async function associatedBalance(rpc, owner, mint) {
|
|
2418
|
+
const programs = [TOKEN_PROGRAM, TOKEN_2022_PROGRAM];
|
|
2419
|
+
const keys = [...programs.map((p) => associatedTokenAddress(owner, mint, p)), mint];
|
|
2420
|
+
const result = await rpc("getMultipleAccounts", [keys, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2421
|
+
const accounts = result?.value;
|
|
2422
|
+
if (!Array.isArray(accounts) || accounts.length !== keys.length) throw new Error("Invalid token accounts.");
|
|
2423
|
+
if (!accounts[2] || !programs.includes(accounts[2].owner)) throw new Error("Not a token mint.");
|
|
2424
|
+
let total = 0n;
|
|
2425
|
+
for (const [i, account] of accounts.slice(0, 2).entries()) {
|
|
2426
|
+
if (!account) continue;
|
|
2427
|
+
const info = account.data?.parsed?.info;
|
|
2428
|
+
if (account.owner !== programs[i] || info?.mint !== mint) throw new Error("Invalid token account.");
|
|
2429
|
+
total += BigInt(raw(info?.tokenAmount?.amount, "token balance"));
|
|
2430
|
+
}
|
|
2431
|
+
return total;
|
|
2432
|
+
}
|
|
2364
2433
|
function solanaLamportShortfall(logs) {
|
|
2365
2434
|
if (!Array.isArray(logs)) return null;
|
|
2366
2435
|
for (const line of logs) {
|
|
@@ -2853,6 +2922,12 @@ function humanizeComplianceReason(raw2) {
|
|
|
2853
2922
|
}
|
|
2854
2923
|
case "blocked_jurisdiction":
|
|
2855
2924
|
return `Your region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
2925
|
+
// zd-dapp src/lib/complianceReason.ts (#588): ZD Heavy's account-country and wallet-origin rules.
|
|
2926
|
+
// Without these two the payer read the raw code ("account blocked country — IR").
|
|
2927
|
+
case "account_blocked_country":
|
|
2928
|
+
return `Your account doesn't support this region (${cleanJurisdiction(detail)}).`;
|
|
2929
|
+
case "blocked_origin_jurisdiction":
|
|
2930
|
+
return `The wallet's attributed region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
2856
2931
|
case "blocked_destination_jurisdiction":
|
|
2857
2932
|
return `The destination region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
2858
2933
|
case "jurisdiction_out_of_scope":
|
|
@@ -3547,6 +3622,8 @@ async function buildRoute({
|
|
|
3547
3622
|
quote: {
|
|
3548
3623
|
bridge: quote.bridge,
|
|
3549
3624
|
feeBps: quote.feeBps,
|
|
3625
|
+
zeroDeltaFeeCentibips: quote.zeroDeltaFeeCentibips,
|
|
3626
|
+
zeroDeltaFeeNative: quote.zeroDeltaFeeNative,
|
|
3550
3627
|
estimatedDuration: quote.estimatedDuration,
|
|
3551
3628
|
gasCostSource: quote.gasCostSource,
|
|
3552
3629
|
msgValue: valueRaw.toString(),
|
|
@@ -3567,7 +3644,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
3567
3644
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
3568
3645
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
3569
3646
|
var WIDGET_CHANNEL = "widget";
|
|
3570
|
-
var WIDGET_VERSION = "4.
|
|
3647
|
+
var WIDGET_VERSION = "4.17.0" ;
|
|
3571
3648
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
3572
3649
|
function sanitizeVersion(raw2) {
|
|
3573
3650
|
const v = String(raw2).trim();
|
|
@@ -4157,6 +4234,8 @@ async function quoteSwapPreview(api, swap, owner) {
|
|
|
4157
4234
|
return {
|
|
4158
4235
|
receive: formatUnits(final, assetDecimals(destToken)),
|
|
4159
4236
|
receiveRaw: final.toString(),
|
|
4237
|
+
zeroDeltaFeeCentibips: quote.zeroDeltaFeeCentibips,
|
|
4238
|
+
zeroDeltaFeeNative: quote.zeroDeltaFeeNative,
|
|
4160
4239
|
fromAmount: v.amountIn,
|
|
4161
4240
|
fromToken: sourceToken.symbol,
|
|
4162
4241
|
toToken: destToken.symbol,
|
|
@@ -4607,7 +4686,8 @@ function createEngine(config = {}) {
|
|
|
4607
4686
|
const resolved = resolveConfig(config);
|
|
4608
4687
|
const api = createApiClient(resolved);
|
|
4609
4688
|
const verifier = createVerifier(api, resolved.fetchImpl, resolved.rpcOverrides);
|
|
4610
|
-
const
|
|
4689
|
+
const solanaOverride = resolved.rpcOverrides[SOLANA_CHAIN_ID];
|
|
4690
|
+
const solanaRpc = createSolanaRpc(api, resolved.fetchImpl, solanaOverride && /^https?:\/\//i.test(solanaOverride) ? [solanaOverride] : BUNDLED_SOLANA_RPC);
|
|
4611
4691
|
return {
|
|
4612
4692
|
api,
|
|
4613
4693
|
verifier,
|
|
@@ -5071,6 +5151,7 @@ function useFlow(args) {
|
|
|
5071
5151
|
if (busyRef.current) return;
|
|
5072
5152
|
setFieldError(null);
|
|
5073
5153
|
if (!enabled || !wallet.account) {
|
|
5154
|
+
reqId.current++;
|
|
5074
5155
|
setStatus("idle");
|
|
5075
5156
|
setPlan(null);
|
|
5076
5157
|
return;
|
|
@@ -5664,6 +5745,8 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
5664
5745
|
.sg-pk-body{display:flex;flex-direction:column;gap:8px}
|
|
5665
5746
|
.sg-pk-selected{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}
|
|
5666
5747
|
.sg-pk-cap{margin:0;font-size:12px;line-height:1.2;color:var(--sg-text-muted)}
|
|
5748
|
+
.sg-pk-cap--section{margin-top:8px}
|
|
5749
|
+
.sg-pk-bal-missing{flex:0 0 auto;font-size:13px;line-height:1.4;color:var(--sg-text-muted);text-align:right}
|
|
5667
5750
|
.sg-pk-list{display:flex;flex-direction:column;gap:4px;max-height:320px;overflow-y:auto;margin:-1px;padding:1px;scrollbar-width:thin}
|
|
5668
5751
|
.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}
|
|
5669
5752
|
.sg-pk-row:hover{background:color-mix(in srgb,var(--sg-accent) 8%,transparent)}
|
|
@@ -6459,6 +6542,12 @@ var SOURCE_CHAIN_LABELS = {
|
|
|
6459
6542
|
98866: "Plume"
|
|
6460
6543
|
};
|
|
6461
6544
|
var CHAIN_LABELS = { ...CHAIN_DISPLAY_NAMES, ...SOURCE_CHAIN_LABELS };
|
|
6545
|
+
function chainLabel(chainId, chain2) {
|
|
6546
|
+
const pinned = SOURCE_CHAIN_LABELS[chainId];
|
|
6547
|
+
if (pinned) return pinned;
|
|
6548
|
+
const fromRegistry = typeof chain2?.displayName === "string" ? chain2.displayName.trim() : "";
|
|
6549
|
+
return fromRegistry || CHAIN_DISPLAY_NAMES[chainId] || `Chain ${chainId}`;
|
|
6550
|
+
}
|
|
6462
6551
|
var SUPPORTED_CHAINS = [1, 10, 42161, 8453, 57073, 130, 9745, 146, 98866];
|
|
6463
6552
|
var SUPPORTED_ASSETS2 = [
|
|
6464
6553
|
...EXECUTABLE_STABLE_ASSETS,
|
|
@@ -6994,7 +7083,7 @@ function TokenTile(props) {
|
|
|
6994
7083
|
/* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: props.pick.symbol, logoUrl: props.token?.logoUrl, chainId: props.pick.chainId, size: "tile" }),
|
|
6995
7084
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tile-text", children: [
|
|
6996
7085
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-sym", children: shown }),
|
|
6997
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-chain", children: CHAIN_LABELS[props.pick.chainId] || `Chain ${props.pick.chainId}` })
|
|
7086
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-chain", children: props.chainName || CHAIN_LABELS[props.pick.chainId] || `Chain ${props.pick.chainId}` })
|
|
6998
7087
|
] })
|
|
6999
7088
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7000
7089
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok-fb", children: "?" }) }),
|
|
@@ -7073,7 +7162,9 @@ function TickBadge() {
|
|
|
7073
7162
|
] }) });
|
|
7074
7163
|
}
|
|
7075
7164
|
function BalanceColumn(props) {
|
|
7076
|
-
if (props.amount == null)
|
|
7165
|
+
if (props.amount == null) {
|
|
7166
|
+
return props.walletMissing ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-missing", "data-testid": "balance-wallet-missing", children: "Wallet not connected" }) : null;
|
|
7167
|
+
}
|
|
7077
7168
|
if (props.amount === 0) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-zero", children: "0.00" });
|
|
7078
7169
|
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal", children: [
|
|
7079
7170
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-usd sg-mono", children: props.usd == null ? "\u2014" : formatBalanceUsd(props.usd) }),
|
|
@@ -7126,7 +7217,7 @@ function TokenSelect(props) {
|
|
|
7126
7217
|
const listRef = react.useRef(null);
|
|
7127
7218
|
const savedScroll = react.useRef(0);
|
|
7128
7219
|
const chainById2 = react.useMemo(() => new Map(props.chains.map((c) => [Number(c.chainId), c])), [props.chains]);
|
|
7129
|
-
const chainName3 = (chainId) =>
|
|
7220
|
+
const chainName3 = (chainId) => chainLabel(chainId, chainById2.get(chainId));
|
|
7130
7221
|
const showBalances = side === "from" && !!props.balances && Object.keys(props.balances).length > 0;
|
|
7131
7222
|
const [prices, setPrices] = react.useState({});
|
|
7132
7223
|
const symbolKey2 = react.useMemo(() => [...new Set(props.tokens.map((t) => String(t.symbol).toUpperCase()))].sort().join(","), [props.tokens]);
|
|
@@ -7172,6 +7263,15 @@ function TokenSelect(props) {
|
|
|
7172
7263
|
}, [props.tokens, props.balances, props.optionStates, showBalances, prices]);
|
|
7173
7264
|
const chainTerms = react.useMemo(() => buildChainSearchTerms(props.chains), [props.chains]);
|
|
7174
7265
|
const visible = react.useMemo(() => searchGroups(groups, query, chainTerms, prices), [groups, query, chainTerms, prices]);
|
|
7266
|
+
const { listed, other } = react.useMemo(() => {
|
|
7267
|
+
const held = [];
|
|
7268
|
+
const none = [];
|
|
7269
|
+
for (const g of visible) {
|
|
7270
|
+
const readZero = showBalances && !g.unavailable && g.deployments.length > 0 && g.deployments.every((d) => d.balance === 0);
|
|
7271
|
+
(readZero ? none : held).push(g);
|
|
7272
|
+
}
|
|
7273
|
+
return { listed: held, other: none };
|
|
7274
|
+
}, [visible, showBalances]);
|
|
7175
7275
|
const openGroup = openKey ? visible.find((g) => g.key === openKey) ?? null : null;
|
|
7176
7276
|
react.useEffect(() => {
|
|
7177
7277
|
if (openKey && !openGroup) setOpenKey(null);
|
|
@@ -7228,7 +7328,7 @@ function TokenSelect(props) {
|
|
|
7228
7328
|
d.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: d.hint }) : null
|
|
7229
7329
|
] })
|
|
7230
7330
|
] }),
|
|
7231
|
-
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: d.balance, usd: usdOf(d.balance, prices, d.token.symbol), symbol: ticker }) : null
|
|
7331
|
+
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: d.balance, usd: usdOf(d.balance, prices, d.token.symbol), symbol: ticker, walletMissing: props.walletMissing?.(d.token) }) : null
|
|
7232
7332
|
] }, d.key);
|
|
7233
7333
|
}) })
|
|
7234
7334
|
] });
|
|
@@ -7267,52 +7367,58 @@ function TokenSelect(props) {
|
|
|
7267
7367
|
) : null
|
|
7268
7368
|
] })
|
|
7269
7369
|
] }) : null,
|
|
7270
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-cap", children: side === "from" ? "Your tokens \xB7 All networks" : "Popular tokens \xB7 All networks" }),
|
|
7271
|
-
/* @__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." }) :
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
const blocked = !!g.unavailable;
|
|
7277
|
-
const opensNetworks = multi || blocked;
|
|
7278
|
-
const zero = showBalances && g.amount === 0 || blocked;
|
|
7279
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7280
|
-
"button",
|
|
7281
|
-
{
|
|
7282
|
-
type: "button",
|
|
7283
|
-
className: "sg-pk-row",
|
|
7284
|
-
"data-testid": "token-row",
|
|
7285
|
-
"data-symbol": g.symbol,
|
|
7286
|
-
"data-networks": members.length,
|
|
7287
|
-
"data-zero": zero || void 0,
|
|
7288
|
-
"data-unavailable": blocked || void 0,
|
|
7289
|
-
onClick: () => {
|
|
7290
|
-
if (opensNetworks) {
|
|
7291
|
-
savedScroll.current = listRef.current?.scrollTop ?? 0;
|
|
7292
|
-
setOpenKey(g.key);
|
|
7293
|
-
} else pick(single.token);
|
|
7294
|
-
},
|
|
7295
|
-
children: [
|
|
7296
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
|
|
7297
|
-
/* @__PURE__ */ jsxRuntime.jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
|
|
7298
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
|
|
7299
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: label2 }),
|
|
7300
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-line", children: [
|
|
7301
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-sub", children: multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
|
|
7302
|
-
/* @__PURE__ */ jsxRuntime.jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById: chainById2, decorative: !multi }),
|
|
7303
|
-
opensNetworks && showBalances ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev sg-pk-chev--sm", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
|
|
7304
|
-
] }),
|
|
7305
|
-
!multi && single.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
|
|
7306
|
-
] })
|
|
7307
|
-
] }),
|
|
7308
|
-
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
|
|
7309
|
-
]
|
|
7310
|
-
},
|
|
7311
|
-
g.key
|
|
7312
|
-
);
|
|
7313
|
-
}) })
|
|
7370
|
+
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,
|
|
7371
|
+
/* @__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: [
|
|
7372
|
+
listed.map((g) => renderRow(g, false)),
|
|
7373
|
+
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,
|
|
7374
|
+
other.map((g) => renderRow(g, true))
|
|
7375
|
+
] }) })
|
|
7314
7376
|
] })
|
|
7315
7377
|
] });
|
|
7378
|
+
function renderRow(g, discovery) {
|
|
7379
|
+
const members = g.deployments;
|
|
7380
|
+
const multi = members.length > 1;
|
|
7381
|
+
const single = members[0];
|
|
7382
|
+
const label2 = multi ? g.symbol : tokenTicker(single.token);
|
|
7383
|
+
const blocked = !!g.unavailable;
|
|
7384
|
+
const opensNetworks = multi || blocked;
|
|
7385
|
+
const zero = showBalances && g.amount === 0 || blocked;
|
|
7386
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7387
|
+
"button",
|
|
7388
|
+
{
|
|
7389
|
+
type: "button",
|
|
7390
|
+
className: "sg-pk-row",
|
|
7391
|
+
"data-testid": "token-row",
|
|
7392
|
+
"data-symbol": g.symbol,
|
|
7393
|
+
"data-networks": members.length,
|
|
7394
|
+
"data-zero": zero || void 0,
|
|
7395
|
+
"data-discovery": discovery || void 0,
|
|
7396
|
+
"data-unavailable": blocked || void 0,
|
|
7397
|
+
onClick: () => {
|
|
7398
|
+
if (opensNetworks) {
|
|
7399
|
+
savedScroll.current = listRef.current?.scrollTop ?? 0;
|
|
7400
|
+
setOpenKey(g.key);
|
|
7401
|
+
} else pick(single.token);
|
|
7402
|
+
},
|
|
7403
|
+
children: [
|
|
7404
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
|
|
7405
|
+
/* @__PURE__ */ jsxRuntime.jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
|
|
7406
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
|
|
7407
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: label2 }),
|
|
7408
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-line", children: [
|
|
7409
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-sub", children: discovery ? "Available on" : multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
|
|
7410
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById: chainById2, decorative: !multi && !discovery }),
|
|
7411
|
+
opensNetworks && showBalances ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev sg-pk-chev--sm", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
|
|
7412
|
+
] }),
|
|
7413
|
+
!multi && single.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
|
|
7414
|
+
] })
|
|
7415
|
+
] }),
|
|
7416
|
+
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
|
|
7417
|
+
]
|
|
7418
|
+
},
|
|
7419
|
+
g.key
|
|
7420
|
+
);
|
|
7421
|
+
}
|
|
7316
7422
|
}
|
|
7317
7423
|
function ChevronRight({ size = 16 }) {
|
|
7318
7424
|
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" }) });
|
|
@@ -7389,7 +7495,7 @@ function durationLabel(seconds) {
|
|
|
7389
7495
|
}
|
|
7390
7496
|
function TokenButton(props) {
|
|
7391
7497
|
const shown = props.token ? tokenTicker(props.token) : props.symbol ?? "";
|
|
7392
|
-
const chain2 = props.chainId ? CHAIN_LABELS[props.chainId] || `Chain ${props.chainId}` : "";
|
|
7498
|
+
const chain2 = props.chainId ? props.chainName || CHAIN_LABELS[props.chainId] || `Chain ${props.chainId}` : "";
|
|
7393
7499
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7394
7500
|
"button",
|
|
7395
7501
|
{
|
|
@@ -7613,7 +7719,7 @@ function QuoteChecks({
|
|
|
7613
7719
|
compliance,
|
|
7614
7720
|
cv,
|
|
7615
7721
|
checks,
|
|
7616
|
-
direct,
|
|
7722
|
+
direct: direct2,
|
|
7617
7723
|
onViewPolicy
|
|
7618
7724
|
}) {
|
|
7619
7725
|
const allPassed = cv.tone === "ok" && checks.length > 0 && checks.every((c) => c.ok);
|
|
@@ -7642,7 +7748,7 @@ function QuoteChecks({
|
|
|
7642
7748
|
] }),
|
|
7643
7749
|
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,
|
|
7644
7750
|
orphans.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cp-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
|
|
7645
|
-
|
|
7751
|
+
direct2 && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cp-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
7646
7752
|
] }),
|
|
7647
7753
|
compliance?.flaggedCategories?.length ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cp-card", children: [
|
|
7648
7754
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cp-card-head", children: [
|
|
@@ -7854,7 +7960,7 @@ function CheckGlyph() {
|
|
|
7854
7960
|
function HistoryButton(props) {
|
|
7855
7961
|
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, {}) });
|
|
7856
7962
|
}
|
|
7857
|
-
function
|
|
7963
|
+
function chainLabel2(entry) {
|
|
7858
7964
|
return entry.chainId != null && CHAIN_LABELS[entry.chainId] || entry.chainName || (entry.chainId != null ? `Chain ${entry.chainId}` : "Unknown chain");
|
|
7859
7965
|
}
|
|
7860
7966
|
function chainName(chainId, fallback) {
|
|
@@ -7987,7 +8093,7 @@ function TxHistoryList(props) {
|
|
|
7987
8093
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-txrow-when", children: [
|
|
7988
8094
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-txrow-what", children: [
|
|
7989
8095
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: e.kind === "payment" ? "Payment" : "Swap" }),
|
|
7990
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children:
|
|
8096
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: chainLabel2(e) }),
|
|
7991
8097
|
(e.legs?.length ?? 1) > 1 ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: ordersLabel(e.legs.length) }) : null
|
|
7992
8098
|
] }),
|
|
7993
8099
|
whenLabel(e.at) ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-txrow-time", children: whenLabel(e.at) }) : null
|
|
@@ -8044,7 +8150,7 @@ function TxDetail(props) {
|
|
|
8044
8150
|
] }),
|
|
8045
8151
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
|
|
8046
8152
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Signed on" }),
|
|
8047
|
-
/* @__PURE__ */ jsxRuntime.jsx("b", { children:
|
|
8153
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: chainLabel2(e) })
|
|
8048
8154
|
] }),
|
|
8049
8155
|
e.recipient ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
|
|
8050
8156
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Recipient" }),
|
|
@@ -10700,6 +10806,86 @@ function QuoteSheet(props) {
|
|
|
10700
10806
|
] })
|
|
10701
10807
|
] });
|
|
10702
10808
|
}
|
|
10809
|
+
|
|
10810
|
+
// src/react/ui/cost.ts
|
|
10811
|
+
function tenPow(d) {
|
|
10812
|
+
let x = 1n;
|
|
10813
|
+
for (let i = 0; i < d; i++) x *= 10n;
|
|
10814
|
+
return x;
|
|
10815
|
+
}
|
|
10816
|
+
function divRoundNearest(n, d) {
|
|
10817
|
+
if (d === 0n) return 0n;
|
|
10818
|
+
const sign2 = n < 0n !== d < 0n ? -1n : 1n;
|
|
10819
|
+
const an = n < 0n ? -n : n;
|
|
10820
|
+
const ad = d < 0n ? -d : d;
|
|
10821
|
+
let q = an / ad;
|
|
10822
|
+
const r = an - q * ad;
|
|
10823
|
+
if (r * 2n >= ad) q += 1n;
|
|
10824
|
+
return sign2 * q;
|
|
10825
|
+
}
|
|
10826
|
+
function parSpreadBps(fromAmountRaw, fromDecimals, toAmountRaw, toDecimals) {
|
|
10827
|
+
try {
|
|
10828
|
+
const from = BigInt(fromAmountRaw);
|
|
10829
|
+
const to = BigInt(toAmountRaw);
|
|
10830
|
+
if (from <= 0n) return null;
|
|
10831
|
+
const pFrom = tenPow(fromDecimals);
|
|
10832
|
+
const pTo = tenPow(toDecimals);
|
|
10833
|
+
const den = from * pTo;
|
|
10834
|
+
if (den === 0n) return null;
|
|
10835
|
+
return Number(divRoundNearest((den - to * pFrom) * 100000n, den)) / 10;
|
|
10836
|
+
} catch {
|
|
10837
|
+
return null;
|
|
10838
|
+
}
|
|
10839
|
+
}
|
|
10840
|
+
function totalCostBps(fromUsd, toUsd) {
|
|
10841
|
+
if (fromUsd == null || toUsd == null) return null;
|
|
10842
|
+
if (!Number.isFinite(fromUsd) || !Number.isFinite(toUsd) || fromUsd <= 0) return null;
|
|
10843
|
+
return (fromUsd - toUsd) / fromUsd * 1e4;
|
|
10844
|
+
}
|
|
10845
|
+
function costBasisFor(fromSymbol, toSymbol) {
|
|
10846
|
+
return assetClassOf(fromSymbol) === "stable" && assetClassOf(toSymbol) === "stable" ? "tokens" : "value";
|
|
10847
|
+
}
|
|
10848
|
+
function quoteCostBps(input) {
|
|
10849
|
+
if (!input.fromSymbol || !input.toSymbol) return null;
|
|
10850
|
+
if (costBasisFor(input.fromSymbol, input.toSymbol) === "value") {
|
|
10851
|
+
const usd2 = (amount, price) => price === void 0 || !amount ? null : Number(amount) * price;
|
|
10852
|
+
return totalCostBps(usd2(input.send, input.fromPrice), usd2(input.receive, input.toPrice));
|
|
10853
|
+
}
|
|
10854
|
+
try {
|
|
10855
|
+
if (!input.send || !input.receive) return null;
|
|
10856
|
+
return parSpreadBps(parseUnitsDecimal(input.send, 18).toString(), 18, parseUnitsDecimal(input.receive, 18).toString(), 18);
|
|
10857
|
+
} catch {
|
|
10858
|
+
return null;
|
|
10859
|
+
}
|
|
10860
|
+
}
|
|
10861
|
+
function statedCentibips(fee) {
|
|
10862
|
+
const c = fee?.zeroDeltaFeeCentibips;
|
|
10863
|
+
return typeof c === "number" && Number.isSafeInteger(c) && c >= 0 ? c : null;
|
|
10864
|
+
}
|
|
10865
|
+
function centibipsPct(centibips) {
|
|
10866
|
+
if (centibips === 0) return "0%";
|
|
10867
|
+
const whole = Math.floor(centibips / 1e4);
|
|
10868
|
+
const frac = String(centibips % 1e4).padStart(4, "0").replace(/0+$/, "").padEnd(2, "0");
|
|
10869
|
+
return `${whole}.${frac}%`;
|
|
10870
|
+
}
|
|
10871
|
+
function zeroDeltaFeeLabel(fee, native) {
|
|
10872
|
+
const centibips = statedCentibips(fee);
|
|
10873
|
+
if (centibips === null) return "--";
|
|
10874
|
+
const pct = centibipsPct(centibips);
|
|
10875
|
+
const raw2 = fee?.zeroDeltaFeeNative;
|
|
10876
|
+
if (typeof raw2 !== "string" || !/^\d+$/.test(raw2) || BigInt(raw2) === 0n) return pct;
|
|
10877
|
+
return `${pct} + ${formatUnits(raw2, native.decimals, 8)} ${native.symbol}`;
|
|
10878
|
+
}
|
|
10879
|
+
function formatCostBps(bps) {
|
|
10880
|
+
const rounded = Number(bps.toFixed(1));
|
|
10881
|
+
const sign2 = rounded < 0 ? "\u2212" : "+";
|
|
10882
|
+
return `${sign2}${Math.abs(rounded).toFixed(1)} bps`;
|
|
10883
|
+
}
|
|
10884
|
+
function rateImpactLabel(totalBps, fee) {
|
|
10885
|
+
if (totalBps === null) return "--";
|
|
10886
|
+
const centibips = statedCentibips(fee);
|
|
10887
|
+
return formatCostBps(totalBps - (centibips === null ? 0 : centibips / 100));
|
|
10888
|
+
}
|
|
10703
10889
|
var FIAT = [
|
|
10704
10890
|
{ code: "USD", glyph: "$", label: "US Dollar" },
|
|
10705
10891
|
{ code: "EUR", glyph: "\u20AC", label: "Euro" },
|
|
@@ -10767,6 +10953,8 @@ function ExchangeCard(props) {
|
|
|
10767
10953
|
const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
|
|
10768
10954
|
return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
|
|
10769
10955
|
}, [catalogue]);
|
|
10956
|
+
const chainRow = react.useMemo(() => new Map(chains.map((c) => [Number(c.chainId), c])), [chains]);
|
|
10957
|
+
const nameOf = (id) => id ? chainLabel(id, chainRow.get(id)) : void 0;
|
|
10770
10958
|
const tokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
|
|
10771
10959
|
const sourceTokens = react.useMemo(() => catalogue?.sources ?? [], [catalogue]);
|
|
10772
10960
|
const [view, setView] = react.useState("main");
|
|
@@ -11057,6 +11245,13 @@ function ExchangeCard(props) {
|
|
|
11057
11245
|
const complianceHasQuote = solActive ? Boolean(solFlow.plan && solFlow.status !== "quoting") : Boolean(selected && flow.status !== "loading");
|
|
11058
11246
|
const fromUsd = usdOf2(normalizedAmount, prices[from?.symbol ?? ""]);
|
|
11059
11247
|
const toUsd = usdOf2(receive, prices[to?.symbol ?? ""]);
|
|
11248
|
+
const statedFee = solActive ? solFlow.preview : addressed ? selected?.quote : preview.data;
|
|
11249
|
+
const feeNative = solActive ? { symbol: "SOL", decimals: 9 } : { symbol: nativeSymbol(from?.chainId ?? 1, chains), decimals: 18 };
|
|
11250
|
+
const feeLabel = hasQuote ? zeroDeltaFeeLabel(statedFee, feeNative) : "--";
|
|
11251
|
+
const rateImpact = hasQuote ? rateImpactLabel(
|
|
11252
|
+
quoteCostBps({ send: normalizedAmount, receive, fromSymbol: from?.symbol, toSymbol: to?.symbol, fromPrice: prices[from?.symbol ?? ""], toPrice: prices[to?.symbol ?? ""] }),
|
|
11253
|
+
statedFee
|
|
11254
|
+
) : "--";
|
|
11060
11255
|
const flippable = !rampMode && !submitting && Boolean(to && sourceTokens.some((t) => Number(t.chainId) === to.chainId && symbolKey(t.symbol) === to.symbol));
|
|
11061
11256
|
const flip = () => {
|
|
11062
11257
|
if (!flippable) return;
|
|
@@ -11147,7 +11342,8 @@ function ExchangeCard(props) {
|
|
|
11147
11342
|
{ label: "You send", value: `${normalizedAmount} ${fromTicker}` },
|
|
11148
11343
|
{ label: "You receive", value: `${receive} ${toTicker}` },
|
|
11149
11344
|
...rate ? [{ label: "Rate", value: `1 ${fromTicker} = ${rate} ${toTicker}` }] : [],
|
|
11150
|
-
{ label: "
|
|
11345
|
+
{ label: "Rate impact", value: rateImpact },
|
|
11346
|
+
{ label: "Fee", value: feeLabel },
|
|
11151
11347
|
{ label: "Network fee", value: networkFee },
|
|
11152
11348
|
...eta ? [{ label: "Estimated time", value: eta }] : []
|
|
11153
11349
|
],
|
|
@@ -11204,6 +11400,7 @@ function ExchangeCard(props) {
|
|
|
11204
11400
|
balances,
|
|
11205
11401
|
optionStates: isFrom ? void 0 : destinationStates,
|
|
11206
11402
|
loading: !catalogue?.ready,
|
|
11403
|
+
walletMissing: (t) => isSolanaChainId(t.chainId) && !solanaWallet.address,
|
|
11207
11404
|
onBack: () => closeSelector(isFrom),
|
|
11208
11405
|
onPick: (pick) => {
|
|
11209
11406
|
(isFrom ? setFrom : setTo)({ chainId: pick.chainId, symbol: symbolKey(pick.symbol) });
|
|
@@ -11256,8 +11453,8 @@ function ExchangeCard(props) {
|
|
|
11256
11453
|
] })
|
|
11257
11454
|
] });
|
|
11258
11455
|
} else {
|
|
11259
|
-
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") });
|
|
11260
|
-
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") });
|
|
11456
|
+
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") });
|
|
11457
|
+
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") });
|
|
11261
11458
|
const cta = solActive ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cta-wrap", children: [
|
|
11262
11459
|
solanaSteps,
|
|
11263
11460
|
solanaCta,
|
|
@@ -11278,9 +11475,9 @@ function ExchangeCard(props) {
|
|
|
11278
11475
|
body = wide ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
11279
11476
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-stack", children: [
|
|
11280
11477
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ft", children: [
|
|
11281
|
-
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") }),
|
|
11478
|
+
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") }),
|
|
11282
11479
|
/* @__PURE__ */ jsxRuntime.jsx(FlipButton, { small: true, onClick: flip, disabled: !flippable }),
|
|
11283
|
-
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") })
|
|
11480
|
+
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") })
|
|
11284
11481
|
] }),
|
|
11285
11482
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane", "data-kind": "send", children: [
|
|
11286
11483
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane-top", children: [
|
|
@@ -11379,7 +11576,7 @@ function ExchangeCard(props) {
|
|
|
11379
11576
|
] }),
|
|
11380
11577
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv-sub", children: [
|
|
11381
11578
|
"On ",
|
|
11382
|
-
|
|
11579
|
+
nameOf(to?.chainId) ?? `Chain ${to?.chainId}`
|
|
11383
11580
|
] })
|
|
11384
11581
|
] }),
|
|
11385
11582
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-stack", children: [
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { B as BankPayoutAccount, E as Eip1193Provider, a as ExchangeInput, b as ExchangeMode, L as LinkIdentity, M as MountConfig, P as PaymentIsland, c as PaymentIslandKind, d as PaymentIslandProps, e as PillOpenAs, S as SettlementMethod, f as StableGenieConfig, g as StableGenieExchange, h as StableGenieExchangeProps, i as StableGeniePay, j as StableGeniePayProps, k as StableGenieProvider, l as StableGenieRwaExchange, m as StableGenieSwap, n as StableGenieSwapProps, o as StableGenieTheme, p as SuccessInfo, q as SupportedAsset, r as darkTheme, s as lightTheme, t as mount, u as resolveTheme } from './mount-
|
|
1
|
+
export { B as BankPayoutAccount, E as Eip1193Provider, a as ExchangeInput, b as ExchangeMode, L as LinkIdentity, M as MountConfig, P as PaymentIsland, c as PaymentIslandKind, d as PaymentIslandProps, e as PillOpenAs, S as SettlementMethod, f as StableGenieConfig, g as StableGenieExchange, h as StableGenieExchangeProps, i as StableGeniePay, j as StableGeniePayProps, k as StableGenieProvider, l as StableGenieRwaExchange, m as StableGenieSwap, n as StableGenieSwapProps, o as StableGenieTheme, p as SuccessInfo, q as SupportedAsset, r as darkTheme, s as lightTheme, t as mount, u as resolveTheme } from './mount-BSXfSSP2.cjs';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { C as Compliance } from './verify-
|
|
4
|
-
export { A as Availability, B as BrokenLane, a as Catalogue, b as Chain, c as ComplianceCheck, d as ComplianceTone, e as ComplianceView, E as EngineConfig, f as ExchangeProduct, L as LaneLimit, P as Plan, R as Route, g as RouteLeg, h as RouteResult, S as SanitizedTxEntry, T as Token, i as TxHistoryEntry, V as VerifyResult, W as WalletScreen, j as assetClassOf, k as brokenLaneReason, l as complianceChecks, m as complianceControlsLine, n as complianceView, o as counterpartTokens, p as destinationAvailability, q as formatJurisdiction, r as humanizeComplianceReason } from './verify-
|
|
3
|
+
import { C as Compliance } from './verify-BBREdvIM.cjs';
|
|
4
|
+
export { A as Availability, B as BrokenLane, a as Catalogue, b as Chain, c as ComplianceCheck, d as ComplianceTone, e as ComplianceView, E as EngineConfig, f as ExchangeProduct, L as LaneLimit, P as Plan, R as Route, g as RouteLeg, h as RouteResult, S as SanitizedTxEntry, T as Token, i as TxHistoryEntry, V as VerifyResult, W as WalletScreen, j as assetClassOf, k as brokenLaneReason, l as complianceChecks, m as complianceControlsLine, n as complianceView, o as counterpartTokens, p as destinationAvailability, q as formatJurisdiction, r as humanizeComplianceReason } from './verify-BBREdvIM.cjs';
|
|
5
5
|
export { EXECUTABLE_STABLE_ASSETS, Engine, STABLE_ASSETS, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, createEngine, symbolKey } from './core/index.cjs';
|
|
6
6
|
|
|
7
7
|
interface SolanaWalletInfo {
|