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