@rash2x/bridge-widget 0.6.10 → 0.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/evaa-bridge.cjs +1 -1
- package/dist/evaa-bridge.mjs +1 -1
- package/dist/{index-Nq5DhIqK.cjs → index-BaoPDmAJ.cjs} +173 -214
- package/dist/index-BaoPDmAJ.cjs.map +1 -0
- package/dist/{index-BXVbiGox.js → index-Cef9fWsE.js} +2 -2
- package/dist/{index-BXVbiGox.js.map → index-Cef9fWsE.js.map} +1 -1
- package/dist/{index-DJC9_woN.cjs → index-OkGSl_M4.cjs} +2 -2
- package/dist/{index-DJC9_woN.cjs.map → index-OkGSl_M4.cjs.map} +1 -1
- package/dist/{index-TVRvbmLN.js → index-Tq5ST0yd.js} +173 -214
- package/dist/index-Tq5ST0yd.js.map +1 -0
- package/dist/index.d.ts +38 -23
- package/package.json +1 -1
- package/dist/index-Nq5DhIqK.cjs.map +0 -1
- package/dist/index-TVRvbmLN.js.map +0 -1
package/dist/evaa-bridge.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-BaoPDmAJ.cjs");
|
|
4
4
|
exports.DEFAULT_SLIPPAGE_BPS = index.DEFAULT_SLIPPAGE_BPS;
|
|
5
5
|
exports.EvaaBridge = index.EvaaBridge;
|
|
6
6
|
exports.RoutePriority = index.RoutePriority;
|
package/dist/evaa-bridge.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U, d, f, e, H, B, F, X, N, z, $, G, A, D, Z, w, s, v, r, p, q, L, a2, a9, a4, a6, x, I, y, a5, J, a3, a7, a8, Y, W, P, _, a1, aa, Q, S, a0, K, V, t, o, i, u, l, m, j, n, h, k } from "./index-
|
|
1
|
+
import { U, d, f, e, H, B, F, X, N, z, $, G, A, D, Z, w, s, v, r, p, q, L, a2, a9, a4, a6, x, I, y, a5, J, a3, a7, a8, Y, W, P, _, a1, aa, Q, S, a0, K, V, t, o, i, u, l, m, j, n, h, k } from "./index-Tq5ST0yd.js";
|
|
2
2
|
export {
|
|
3
3
|
U as DEFAULT_SLIPPAGE_BPS,
|
|
4
4
|
d as EvaaBridge,
|
|
@@ -718,7 +718,7 @@ function selectQuoteByPriority(routes, priority) {
|
|
|
718
718
|
});
|
|
719
719
|
}
|
|
720
720
|
return routes.reduce(
|
|
721
|
-
(best, cur) => BigInt(cur
|
|
721
|
+
(best, cur) => BigInt(cur?.dstAmount ?? "0") > BigInt(best?.dstAmount ?? "0") ? cur : best
|
|
722
722
|
);
|
|
723
723
|
}
|
|
724
724
|
async function getQuotesByPriority(req) {
|
|
@@ -806,13 +806,19 @@ function lookupTokenMeta(tokens, chains, chainKey, tokenAddr) {
|
|
|
806
806
|
return { decimals: chainKey === "ton" ? 9 : 18, priceUsd: void 0 };
|
|
807
807
|
}
|
|
808
808
|
function computeFeesUsdFromArray(fees, tokens, chains) {
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
809
|
+
const emptyResult = {
|
|
810
|
+
usd: /* @__PURE__ */ new Map(),
|
|
811
|
+
human: /* @__PURE__ */ new Map(),
|
|
812
|
+
original: void 0
|
|
813
|
+
};
|
|
814
|
+
if (!fees?.length) return emptyResult;
|
|
815
|
+
let totalUsd = 0;
|
|
816
|
+
const byTypeUsd = /* @__PURE__ */ new Map();
|
|
817
|
+
const byTypeHuman = /* @__PURE__ */ new Map();
|
|
814
818
|
for (const f4 of fees) {
|
|
815
819
|
let usd = Number(f4.usd ?? 0);
|
|
820
|
+
let human = 0;
|
|
821
|
+
const amount = String(f4.amount ?? "0");
|
|
816
822
|
if (!usd) {
|
|
817
823
|
const { decimals, priceUsd } = lookupTokenMeta(
|
|
818
824
|
tokens,
|
|
@@ -820,26 +826,28 @@ function computeFeesUsdFromArray(fees, tokens, chains) {
|
|
|
820
826
|
f4.chainKey,
|
|
821
827
|
f4.token
|
|
822
828
|
);
|
|
823
|
-
|
|
829
|
+
human = fromLD(amount, decimals);
|
|
824
830
|
usd = (priceUsd ?? 0) * human;
|
|
825
831
|
}
|
|
826
|
-
|
|
832
|
+
totalUsd += usd;
|
|
827
833
|
const type = (f4.type ?? "other").toLowerCase();
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
834
|
+
byTypeUsd.set(type, (byTypeUsd.get(type) ?? 0) + usd);
|
|
835
|
+
const existing = byTypeHuman.get(type);
|
|
836
|
+
if (existing) {
|
|
837
|
+
existing.amount += human;
|
|
838
|
+
} else {
|
|
839
|
+
byTypeHuman.set(type, {
|
|
840
|
+
amount: human,
|
|
841
|
+
token: f4.token,
|
|
842
|
+
chainKey: f4.chainKey
|
|
843
|
+
});
|
|
833
844
|
}
|
|
834
845
|
}
|
|
835
|
-
|
|
836
|
-
const blockchainUsd = byType.get("gas") ?? byType.get("network") ?? byType.get("message") ?? void 0;
|
|
846
|
+
byTypeUsd.set("total", totalUsd);
|
|
837
847
|
return {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
serviceUsd,
|
|
842
|
-
blockchainUsd
|
|
848
|
+
usd: byTypeUsd,
|
|
849
|
+
human: byTypeHuman,
|
|
850
|
+
original: fees
|
|
843
851
|
};
|
|
844
852
|
}
|
|
845
853
|
function sumFeeByTokenLD(fees, dstTokenAddr, dstChainKey) {
|
|
@@ -998,10 +1006,7 @@ function getQuoteAmounts(quote, srcToken, dstToken) {
|
|
|
998
1006
|
const inputHuman = fromLD(quote.srcAmount, srcToken.decimals);
|
|
999
1007
|
const outputHuman = fromLD(quote.dstAmount, dstToken.decimals);
|
|
1000
1008
|
const outputHumanRounded = truncateToDecimals(outputHuman, 2);
|
|
1001
|
-
const minReceivedHuman = fromLD(
|
|
1002
|
-
quote.dstAmountMin || "0",
|
|
1003
|
-
dstToken.decimals
|
|
1004
|
-
);
|
|
1009
|
+
const minReceivedHuman = fromLD(quote.dstAmountMin || "0", dstToken.decimals);
|
|
1005
1010
|
return {
|
|
1006
1011
|
inputHuman,
|
|
1007
1012
|
outputHuman,
|
|
@@ -1012,11 +1017,7 @@ function getQuoteAmounts(quote, srcToken, dstToken) {
|
|
|
1012
1017
|
function getQuoteFees(quote, tokens, chains, srcToken, dstToken) {
|
|
1013
1018
|
if (!quote || !tokens || !chains) {
|
|
1014
1019
|
return {
|
|
1015
|
-
|
|
1016
|
-
protocolFeeUsd: void 0,
|
|
1017
|
-
messageFeeUsd: void 0,
|
|
1018
|
-
serviceUsd: void 0,
|
|
1019
|
-
blockchainUsd: void 0,
|
|
1020
|
+
fees: { usd: /* @__PURE__ */ new Map(), original: /* @__PURE__ */ new Map(), formatted: /* @__PURE__ */ new Map() },
|
|
1020
1021
|
inSrcToken: void 0,
|
|
1021
1022
|
inDstToken: void 0
|
|
1022
1023
|
};
|
|
@@ -1033,8 +1034,8 @@ function getQuoteFees(quote, tokens, chains, srcToken, dstToken) {
|
|
|
1033
1034
|
const feeInSrcHuman = fromLD(feeInSrcLD, srcToken.decimals);
|
|
1034
1035
|
if (feeInSrcHuman > 0) {
|
|
1035
1036
|
inSrcToken = Number(truncateToDecimals(feeInSrcHuman, 8));
|
|
1036
|
-
} else if (feeData.
|
|
1037
|
-
const feeInSrcApprox = feeData.
|
|
1037
|
+
} else if ((feeData.usd.get("total") || 0) > 0 && srcToken.price?.usd) {
|
|
1038
|
+
const feeInSrcApprox = (feeData.usd.get("total") || 0) / srcToken.price.usd;
|
|
1038
1039
|
inSrcToken = Number(truncateToDecimals(feeInSrcApprox, 8));
|
|
1039
1040
|
}
|
|
1040
1041
|
}
|
|
@@ -1050,11 +1051,7 @@ function getQuoteFees(quote, tokens, chains, srcToken, dstToken) {
|
|
|
1050
1051
|
}
|
|
1051
1052
|
}
|
|
1052
1053
|
return {
|
|
1053
|
-
|
|
1054
|
-
protocolFeeUsd: feeData.protocolFeeUsd,
|
|
1055
|
-
messageFeeUsd: feeData.messageFeeUsd,
|
|
1056
|
-
serviceUsd: feeData.serviceUsd,
|
|
1057
|
-
blockchainUsd: feeData.blockchainUsd,
|
|
1054
|
+
fees: feeData,
|
|
1058
1055
|
inSrcToken,
|
|
1059
1056
|
inDstToken
|
|
1060
1057
|
};
|
|
@@ -1113,9 +1110,7 @@ function addTonNetworkFee(quote, chains, estimatedFee) {
|
|
|
1113
1110
|
if (!quote || quote.srcChainKey.toLowerCase() !== "ton") {
|
|
1114
1111
|
return quote;
|
|
1115
1112
|
}
|
|
1116
|
-
const tonChain = chains?.find(
|
|
1117
|
-
(c2) => c2.chainKey.toLowerCase() === "ton"
|
|
1118
|
-
);
|
|
1113
|
+
const tonChain = chains?.find((c2) => c2.chainKey.toLowerCase() === "ton");
|
|
1119
1114
|
if (!tonChain?.nativeCurrency?.address) {
|
|
1120
1115
|
console.warn("Could not find TON native currency address");
|
|
1121
1116
|
return quote;
|
|
@@ -1181,9 +1176,7 @@ function addTronNetworkFee(quote, chains, estimatedFee) {
|
|
|
1181
1176
|
if (!quote || quote.srcChainKey.toLowerCase() !== "tron") {
|
|
1182
1177
|
return quote;
|
|
1183
1178
|
}
|
|
1184
|
-
const tronChain = chains?.find(
|
|
1185
|
-
(c2) => c2.chainKey.toLowerCase() === "tron"
|
|
1186
|
-
);
|
|
1179
|
+
const tronChain = chains?.find((c2) => c2.chainKey.toLowerCase() === "tron");
|
|
1187
1180
|
if (!tronChain?.nativeCurrency?.address) {
|
|
1188
1181
|
console.warn("Could not find TRON native currency address");
|
|
1189
1182
|
return quote;
|
|
@@ -1222,9 +1215,6 @@ async function estimateEvmNetworkFee(publicClient, quote, chainKey) {
|
|
|
1222
1215
|
totalGasLimit = totalGasLimit * BigInt(Math.floor(EVM_CONFIG.gasBuffer * 100)) / 100n;
|
|
1223
1216
|
const gasPrice = await publicClient.getGasPrice();
|
|
1224
1217
|
const totalCostWei = totalGasLimit * gasPrice;
|
|
1225
|
-
console.log(
|
|
1226
|
-
`EVM gas estimate: ${totalGasLimit} gas × ${gasPrice} Wei/gas = ${totalCostWei} Wei`
|
|
1227
|
-
);
|
|
1228
1218
|
return totalCostWei.toString();
|
|
1229
1219
|
} catch (error) {
|
|
1230
1220
|
console.warn("Failed to estimate EVM gas fee:", error);
|
|
@@ -1253,7 +1243,6 @@ function addEvmNetworkFee(quote, chains, estimatedFee) {
|
|
|
1253
1243
|
token: srcChain.nativeCurrency.address,
|
|
1254
1244
|
chainKey: quote.srcChainKey,
|
|
1255
1245
|
amount: estimatedFee || "10000000000000000",
|
|
1256
|
-
// 0.01 ETH fallback
|
|
1257
1246
|
type: "network"
|
|
1258
1247
|
};
|
|
1259
1248
|
return {
|
|
@@ -1392,7 +1381,6 @@ function useBridgeQuote() {
|
|
|
1392
1381
|
try {
|
|
1393
1382
|
const estimatedFee = estimateTonNetworkFee(quoteRoute);
|
|
1394
1383
|
quoteWithFees = addTonNetworkFee(quoteRoute, chains, estimatedFee);
|
|
1395
|
-
console.log("TON network fee estimated for quote:", estimatedFee);
|
|
1396
1384
|
} catch (error) {
|
|
1397
1385
|
console.warn("Failed to estimate TON fee, using fallback:", error);
|
|
1398
1386
|
quoteWithFees = addTonNetworkFee(quoteRoute, chains);
|
|
@@ -1415,10 +1403,6 @@ function useBridgeQuote() {
|
|
|
1415
1403
|
chains,
|
|
1416
1404
|
estimatedFee
|
|
1417
1405
|
);
|
|
1418
|
-
console.log(
|
|
1419
|
-
"TRON network fee estimated for quote:",
|
|
1420
|
-
estimatedFee
|
|
1421
|
-
);
|
|
1422
1406
|
} catch (error) {
|
|
1423
1407
|
console.warn(
|
|
1424
1408
|
"Failed to estimate TRON fee, using fallback:",
|
|
@@ -1456,7 +1440,6 @@ function useBridgeQuote() {
|
|
|
1456
1440
|
chains,
|
|
1457
1441
|
estimatedFee
|
|
1458
1442
|
);
|
|
1459
|
-
console.log("EVM network fee estimated for quote:", estimatedFee);
|
|
1460
1443
|
} catch (error) {
|
|
1461
1444
|
console.warn(
|
|
1462
1445
|
"Failed to estimate EVM fee, using fallback:",
|
|
@@ -3095,7 +3078,7 @@ function useGasEstimate(amountNum) {
|
|
|
3095
3078
|
const nativeCurrencySymbol = fromChain?.nativeCurrency?.symbol;
|
|
3096
3079
|
const nativeCurrencyAddress = fromChain?.nativeCurrency?.address;
|
|
3097
3080
|
const nativeCurrencyDecimals = fromChain?.nativeCurrency?.decimals;
|
|
3098
|
-
const quoteFees = quote?.fees
|
|
3081
|
+
const quoteFees = quote?.fees;
|
|
3099
3082
|
const quoteSrcChainKey = quote?.srcChainKey;
|
|
3100
3083
|
const nativeBalanceValue = nativeCurrencySymbol ? Number(balances[nativeCurrencySymbol.toUpperCase()]?.balance ?? 0) : 0;
|
|
3101
3084
|
const result = react.useMemo(() => {
|
|
@@ -3114,7 +3097,7 @@ function useGasEstimate(amountNum) {
|
|
|
3114
3097
|
const isNativeSelected = nativeSym === (selectedAssetSymbol || "").toUpperCase();
|
|
3115
3098
|
let requiredNative = 0;
|
|
3116
3099
|
if (quoteFees && quoteSrcChainKey === chainKey) {
|
|
3117
|
-
const fees =
|
|
3100
|
+
const fees = quoteFees;
|
|
3118
3101
|
const feesInNative = fees.filter(
|
|
3119
3102
|
(f4) => f4.chainKey === chainKey && f4.token === nativeCurrencyAddress
|
|
3120
3103
|
).reduce(
|
|
@@ -3154,35 +3137,153 @@ function useGasEstimate(amountNum) {
|
|
|
3154
3137
|
]);
|
|
3155
3138
|
return result;
|
|
3156
3139
|
}
|
|
3157
|
-
|
|
3158
|
-
const
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
const
|
|
3162
|
-
const
|
|
3163
|
-
const
|
|
3164
|
-
const
|
|
3140
|
+
function useBridgeExternalData(options) {
|
|
3141
|
+
const selectedAssetSymbol = useTokensStore(
|
|
3142
|
+
(state2) => state2.selectedAssetSymbol
|
|
3143
|
+
);
|
|
3144
|
+
const assetMatrix = useTokensStore((state2) => state2.assetMatrix);
|
|
3145
|
+
const tokens = useTokensStore((state2) => state2.tokens);
|
|
3146
|
+
const fromChain = useChainsStore((state2) => state2.fromChain);
|
|
3147
|
+
const toChain = useChainsStore((state2) => state2.toChain);
|
|
3148
|
+
const chains = useChainsStore((state2) => state2.chains);
|
|
3149
|
+
const inputAmount = useBridgeQuoteStore((state2) => state2.inputAmount);
|
|
3150
|
+
const quote = useBridgeQuoteStore((state2) => state2.quote);
|
|
3151
|
+
const slippageBps = useSettingsStore((state2) => state2.slippageBps);
|
|
3152
|
+
const data = react.useMemo(
|
|
3153
|
+
() => buildBridgeExternalData({
|
|
3154
|
+
amount: inputAmount,
|
|
3155
|
+
selectedAssetSymbol,
|
|
3156
|
+
srcChain: fromChain,
|
|
3157
|
+
dstChain: toChain,
|
|
3158
|
+
assetMatrix,
|
|
3159
|
+
chains,
|
|
3160
|
+
tokens,
|
|
3161
|
+
quote,
|
|
3162
|
+
slippageBps
|
|
3163
|
+
}),
|
|
3164
|
+
[
|
|
3165
|
+
inputAmount,
|
|
3166
|
+
selectedAssetSymbol,
|
|
3167
|
+
fromChain,
|
|
3168
|
+
toChain,
|
|
3169
|
+
assetMatrix,
|
|
3170
|
+
chains,
|
|
3171
|
+
tokens,
|
|
3172
|
+
quote,
|
|
3173
|
+
slippageBps
|
|
3174
|
+
]
|
|
3175
|
+
);
|
|
3176
|
+
const lastSerializedRef = react.useRef(void 0);
|
|
3177
|
+
react.useEffect(() => {
|
|
3178
|
+
const callback = options?.onDataUpdate;
|
|
3179
|
+
if (!callback) return;
|
|
3180
|
+
const serialized = serializeBridgeDataForCache(data);
|
|
3181
|
+
if (serialized === lastSerializedRef.current) {
|
|
3182
|
+
return;
|
|
3183
|
+
}
|
|
3184
|
+
lastSerializedRef.current = serialized;
|
|
3185
|
+
callback(data);
|
|
3186
|
+
}, [data, options?.onDataUpdate]);
|
|
3187
|
+
return data;
|
|
3188
|
+
}
|
|
3189
|
+
function buildBridgeExternalData({
|
|
3190
|
+
amount,
|
|
3191
|
+
selectedAssetSymbol,
|
|
3192
|
+
srcChain: fromChain,
|
|
3193
|
+
dstChain: toChain,
|
|
3194
|
+
assetMatrix,
|
|
3195
|
+
chains,
|
|
3196
|
+
tokens,
|
|
3197
|
+
quote,
|
|
3198
|
+
slippageBps
|
|
3199
|
+
}) {
|
|
3200
|
+
const normalizedAmount = amount?.trim() || "";
|
|
3201
|
+
const urlParams = {
|
|
3202
|
+
srcToken: selectedAssetSymbol || void 0,
|
|
3203
|
+
srcChain: fromChain?.chainKey,
|
|
3204
|
+
dstChain: toChain?.chainKey,
|
|
3205
|
+
amount: normalizedAmount || void 0
|
|
3206
|
+
};
|
|
3207
|
+
const sourceToken = resolveTokenOnChainFromMatrix$2(
|
|
3165
3208
|
assetMatrix,
|
|
3166
3209
|
selectedAssetSymbol,
|
|
3167
|
-
|
|
3210
|
+
fromChain?.chainKey
|
|
3168
3211
|
);
|
|
3169
|
-
const
|
|
3212
|
+
const destinationToken = resolveTokenOnChainFromMatrix$2(
|
|
3170
3213
|
assetMatrix,
|
|
3171
3214
|
selectedAssetSymbol,
|
|
3172
|
-
|
|
3215
|
+
toChain?.chainKey
|
|
3173
3216
|
);
|
|
3174
3217
|
const quoteDetails = getQuoteDetails(
|
|
3175
3218
|
quote,
|
|
3176
|
-
|
|
3177
|
-
|
|
3219
|
+
sourceToken,
|
|
3220
|
+
destinationToken,
|
|
3178
3221
|
tokens,
|
|
3179
3222
|
chains,
|
|
3180
3223
|
slippageBps
|
|
3181
3224
|
);
|
|
3182
|
-
const symbol = (selectedAssetSymbol ?? dstToken?.symbol ?? "—").toUpperCase();
|
|
3183
|
-
const isLoading = status === "loading";
|
|
3184
|
-
const receiveText = quoteDetails.outputAmount != null ? Number(quoteDetails.outputAmount).toFixed(quote ? 6 : 2) : "0.00";
|
|
3185
3225
|
const etaText = quoteDetails.etaSeconds != null ? `≈ ${Math.max(1, Math.round(quoteDetails.etaSeconds / 60))}m` : "—";
|
|
3226
|
+
const currentSlippageText = !quote ? "—" : formatPercentage(slippageBps);
|
|
3227
|
+
const routeText = getRouteDisplayName(quote?.route);
|
|
3228
|
+
return {
|
|
3229
|
+
amount: normalizedAmount || void 0,
|
|
3230
|
+
urlParams,
|
|
3231
|
+
srcChain: fromChain,
|
|
3232
|
+
dstChain: toChain,
|
|
3233
|
+
tokenSymbol: selectedAssetSymbol,
|
|
3234
|
+
srcToken: sourceToken,
|
|
3235
|
+
dstToken: destinationToken,
|
|
3236
|
+
quoteDetails,
|
|
3237
|
+
quote,
|
|
3238
|
+
eta: etaText,
|
|
3239
|
+
currentSlippageText,
|
|
3240
|
+
routeText
|
|
3241
|
+
};
|
|
3242
|
+
}
|
|
3243
|
+
function serializeBridgeDataForCache(data) {
|
|
3244
|
+
return JSON.stringify({
|
|
3245
|
+
amount: data.amount ?? "",
|
|
3246
|
+
urlParams: {
|
|
3247
|
+
amount: data.urlParams.amount ?? "",
|
|
3248
|
+
srcToken: data.urlParams.srcToken ?? "",
|
|
3249
|
+
srcChain: data.urlParams.srcChain ?? "",
|
|
3250
|
+
dstChain: data.urlParams.dstChain ?? ""
|
|
3251
|
+
},
|
|
3252
|
+
srcChain: data.srcChain?.chainKey ?? "",
|
|
3253
|
+
dstChain: data.dstChain?.chainKey ?? "",
|
|
3254
|
+
tokenSymbol: data.tokenSymbol ?? "",
|
|
3255
|
+
srcToken: data.srcToken ? {
|
|
3256
|
+
chainKey: data.srcToken.chainKey,
|
|
3257
|
+
address: data.srcToken.address
|
|
3258
|
+
} : null,
|
|
3259
|
+
dstToken: data.dstToken ? {
|
|
3260
|
+
chainKey: data.dstToken.chainKey,
|
|
3261
|
+
address: data.dstToken.address
|
|
3262
|
+
} : null,
|
|
3263
|
+
quoteDetails: data.quoteDetails ? {
|
|
3264
|
+
inputAmount: data.quoteDetails.inputAmount,
|
|
3265
|
+
outputAmount: data.quoteDetails.outputAmount,
|
|
3266
|
+
outputAmountRounded: data.quoteDetails.outputAmountRounded,
|
|
3267
|
+
minimumReceived: data.quoteDetails.minimumReceived,
|
|
3268
|
+
etaSeconds: data.quoteDetails.etaSeconds,
|
|
3269
|
+
fees: data.quoteDetails.fees
|
|
3270
|
+
} : null
|
|
3271
|
+
});
|
|
3272
|
+
}
|
|
3273
|
+
const Details = () => {
|
|
3274
|
+
const { t: t2 } = useBridgeTranslation();
|
|
3275
|
+
const { selectedAssetSymbol } = useTokensStore();
|
|
3276
|
+
const { quote, status } = useBridgeQuoteStore();
|
|
3277
|
+
const { slippageBps } = useSettingsStore();
|
|
3278
|
+
const gas = useGasEstimate();
|
|
3279
|
+
const bridgeData = useBridgeExternalData();
|
|
3280
|
+
const symbol = (selectedAssetSymbol ?? bridgeData.dstToken?.symbol ?? "—").toUpperCase();
|
|
3281
|
+
const isLoading = status === "loading";
|
|
3282
|
+
const receiveText = bridgeData.quoteDetails?.outputAmount != null ? Number(bridgeData.quoteDetails?.outputAmount).toFixed(quote ? 6 : 2) : "0.00";
|
|
3283
|
+
const etaText = bridgeData.quoteDetails?.etaSeconds != null ? `≈ ${Math.max(
|
|
3284
|
+
1,
|
|
3285
|
+
Math.round(bridgeData.quoteDetails?.etaSeconds / 60)
|
|
3286
|
+
)}m` : "—";
|
|
3186
3287
|
const totalFeeDisplay = !quote ? "—" : gas.requiredNative > 0 ? `${gas.requiredNative.toFixed(6)} ${gas.nativeSym}` : "—";
|
|
3187
3288
|
const currentSlippageText = !quote ? "—" : formatPercentage(slippageBps);
|
|
3188
3289
|
const routeText = getRouteDisplayName(quote?.route);
|
|
@@ -25818,7 +25919,7 @@ class WalletConnectModal {
|
|
|
25818
25919
|
}
|
|
25819
25920
|
async initUi() {
|
|
25820
25921
|
if (typeof window !== "undefined") {
|
|
25821
|
-
await Promise.resolve().then(() => require("./index-
|
|
25922
|
+
await Promise.resolve().then(() => require("./index-OkGSl_M4.cjs"));
|
|
25822
25923
|
const modal = document.createElement("wcm-modal");
|
|
25823
25924
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25824
25925
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -26069,148 +26170,6 @@ function updateBridgeUrlNative(params) {
|
|
|
26069
26170
|
const newUrl = `${window.location.pathname}${queryString}${window.location.hash}`;
|
|
26070
26171
|
window.history.replaceState(null, "", newUrl);
|
|
26071
26172
|
}
|
|
26072
|
-
function useBridgeExternalData(options) {
|
|
26073
|
-
const selectedAssetSymbol = useTokensStore(
|
|
26074
|
-
(state2) => state2.selectedAssetSymbol
|
|
26075
|
-
);
|
|
26076
|
-
const assetMatrix = useTokensStore((state2) => state2.assetMatrix);
|
|
26077
|
-
const tokens = useTokensStore((state2) => state2.tokens);
|
|
26078
|
-
const fromChain = useChainsStore((state2) => state2.fromChain);
|
|
26079
|
-
const toChain = useChainsStore((state2) => state2.toChain);
|
|
26080
|
-
const chains = useChainsStore((state2) => state2.chains);
|
|
26081
|
-
const inputAmount = useBridgeQuoteStore((state2) => state2.inputAmount);
|
|
26082
|
-
const quote = useBridgeQuoteStore((state2) => state2.quote);
|
|
26083
|
-
const slippageBps = useSettingsStore((state2) => state2.slippageBps);
|
|
26084
|
-
const data = react.useMemo(
|
|
26085
|
-
() => buildBridgeExternalData({
|
|
26086
|
-
amount: inputAmount,
|
|
26087
|
-
selectedAssetSymbol,
|
|
26088
|
-
srcChain: fromChain,
|
|
26089
|
-
dstChain: toChain,
|
|
26090
|
-
assetMatrix,
|
|
26091
|
-
chains,
|
|
26092
|
-
tokens,
|
|
26093
|
-
quote,
|
|
26094
|
-
slippageBps
|
|
26095
|
-
// gas,
|
|
26096
|
-
}),
|
|
26097
|
-
[
|
|
26098
|
-
inputAmount,
|
|
26099
|
-
selectedAssetSymbol,
|
|
26100
|
-
fromChain,
|
|
26101
|
-
toChain,
|
|
26102
|
-
assetMatrix,
|
|
26103
|
-
chains,
|
|
26104
|
-
tokens,
|
|
26105
|
-
quote,
|
|
26106
|
-
slippageBps
|
|
26107
|
-
// gas,
|
|
26108
|
-
]
|
|
26109
|
-
);
|
|
26110
|
-
const lastSerializedRef = react.useRef(void 0);
|
|
26111
|
-
react.useEffect(() => {
|
|
26112
|
-
const callback = options?.onDataUpdate;
|
|
26113
|
-
if (!callback) return;
|
|
26114
|
-
const serialized = serializeBridgeDataForCache(data);
|
|
26115
|
-
if (serialized === lastSerializedRef.current) {
|
|
26116
|
-
return;
|
|
26117
|
-
}
|
|
26118
|
-
lastSerializedRef.current = serialized;
|
|
26119
|
-
callback(data);
|
|
26120
|
-
}, [data, options?.onDataUpdate]);
|
|
26121
|
-
return data;
|
|
26122
|
-
}
|
|
26123
|
-
function buildBridgeExternalData({
|
|
26124
|
-
amount,
|
|
26125
|
-
selectedAssetSymbol,
|
|
26126
|
-
srcChain: fromChain,
|
|
26127
|
-
dstChain: toChain,
|
|
26128
|
-
assetMatrix,
|
|
26129
|
-
chains,
|
|
26130
|
-
tokens,
|
|
26131
|
-
quote,
|
|
26132
|
-
slippageBps
|
|
26133
|
-
// gas,
|
|
26134
|
-
}) {
|
|
26135
|
-
const normalizedAmount = amount?.trim() || "";
|
|
26136
|
-
const urlParams = {
|
|
26137
|
-
srcToken: selectedAssetSymbol || void 0,
|
|
26138
|
-
srcChain: fromChain?.chainKey,
|
|
26139
|
-
dstChain: toChain?.chainKey,
|
|
26140
|
-
amount: normalizedAmount || void 0
|
|
26141
|
-
};
|
|
26142
|
-
const sourceToken = resolveTokenOnChainFromMatrix$2(
|
|
26143
|
-
assetMatrix,
|
|
26144
|
-
selectedAssetSymbol,
|
|
26145
|
-
fromChain?.chainKey
|
|
26146
|
-
);
|
|
26147
|
-
const destinationToken = resolveTokenOnChainFromMatrix$2(
|
|
26148
|
-
assetMatrix,
|
|
26149
|
-
selectedAssetSymbol,
|
|
26150
|
-
toChain?.chainKey
|
|
26151
|
-
);
|
|
26152
|
-
const quoteDetails = getQuoteDetails(
|
|
26153
|
-
quote,
|
|
26154
|
-
sourceToken,
|
|
26155
|
-
destinationToken,
|
|
26156
|
-
tokens,
|
|
26157
|
-
chains,
|
|
26158
|
-
slippageBps
|
|
26159
|
-
);
|
|
26160
|
-
const etaText = quoteDetails.etaSeconds != null ? `≈ ${Math.max(1, Math.round(quoteDetails.etaSeconds / 60))}m` : "—";
|
|
26161
|
-
const totalFeeDisplay = !quote ? "—" : (
|
|
26162
|
-
// gas.requiredNative > 0
|
|
26163
|
-
// ? `${gas.requiredNative.toFixed(6)} ${gas.nativeSym}`
|
|
26164
|
-
// : "—";
|
|
26165
|
-
"—"
|
|
26166
|
-
);
|
|
26167
|
-
const currentSlippageText = !quote ? "—" : formatPercentage(slippageBps);
|
|
26168
|
-
const routeText = getRouteDisplayName(quote?.route);
|
|
26169
|
-
return {
|
|
26170
|
-
amount: normalizedAmount || void 0,
|
|
26171
|
-
urlParams,
|
|
26172
|
-
srcChain: fromChain,
|
|
26173
|
-
dstChain: toChain,
|
|
26174
|
-
tokenSymbol: selectedAssetSymbol,
|
|
26175
|
-
srcToken: sourceToken,
|
|
26176
|
-
dstToken: destinationToken,
|
|
26177
|
-
quoteDetails,
|
|
26178
|
-
eta: etaText,
|
|
26179
|
-
totalFeeDisplay,
|
|
26180
|
-
currentSlippageText,
|
|
26181
|
-
routeText
|
|
26182
|
-
};
|
|
26183
|
-
}
|
|
26184
|
-
function serializeBridgeDataForCache(data) {
|
|
26185
|
-
return JSON.stringify({
|
|
26186
|
-
amount: data.amount ?? "",
|
|
26187
|
-
urlParams: {
|
|
26188
|
-
amount: data.urlParams.amount ?? "",
|
|
26189
|
-
srcToken: data.urlParams.srcToken ?? "",
|
|
26190
|
-
srcChain: data.urlParams.srcChain ?? "",
|
|
26191
|
-
dstChain: data.urlParams.dstChain ?? ""
|
|
26192
|
-
},
|
|
26193
|
-
srcChain: data.srcChain?.chainKey ?? "",
|
|
26194
|
-
dstChain: data.dstChain?.chainKey ?? "",
|
|
26195
|
-
tokenSymbol: data.tokenSymbol ?? "",
|
|
26196
|
-
srcToken: data.srcToken ? {
|
|
26197
|
-
chainKey: data.srcToken.chainKey,
|
|
26198
|
-
address: data.srcToken.address
|
|
26199
|
-
} : null,
|
|
26200
|
-
dstToken: data.dstToken ? {
|
|
26201
|
-
chainKey: data.dstToken.chainKey,
|
|
26202
|
-
address: data.dstToken.address
|
|
26203
|
-
} : null,
|
|
26204
|
-
quoteDetails: data.quoteDetails ? {
|
|
26205
|
-
inputAmount: data.quoteDetails.inputAmount,
|
|
26206
|
-
outputAmount: data.quoteDetails.outputAmount,
|
|
26207
|
-
outputAmountRounded: data.quoteDetails.outputAmountRounded,
|
|
26208
|
-
minimumReceived: data.quoteDetails.minimumReceived,
|
|
26209
|
-
etaSeconds: data.quoteDetails.etaSeconds,
|
|
26210
|
-
fees: data.quoteDetails.fees
|
|
26211
|
-
} : null
|
|
26212
|
-
});
|
|
26213
|
-
}
|
|
26214
26173
|
function useUrlSync(options) {
|
|
26215
26174
|
const {
|
|
26216
26175
|
enabled = true,
|
|
@@ -26709,4 +26668,4 @@ exports.useSettingsStore = useSettingsStore;
|
|
|
26709
26668
|
exports.useSwapModel = useSwapModel;
|
|
26710
26669
|
exports.useTokensStore = useTokensStore;
|
|
26711
26670
|
exports.useTransactionStore = useTransactionStore;
|
|
26712
|
-
//# sourceMappingURL=index-
|
|
26671
|
+
//# sourceMappingURL=index-BaoPDmAJ.cjs.map
|