@rash2x/bridge-widget 0.6.62 → 0.6.63
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 +2 -1
- package/dist/evaa-bridge.cjs.map +1 -1
- package/dist/evaa-bridge.mjs +28 -27
- package/dist/{index-Dwxz-LHk.cjs → index-CSE-oDw8.cjs} +2 -2
- package/dist/{index-Dwxz-LHk.cjs.map → index-CSE-oDw8.cjs.map} +1 -1
- package/dist/{index-CAc7tJ3r.cjs → index-CpKOf8oF.cjs} +192 -190
- package/dist/index-CpKOf8oF.cjs.map +1 -0
- package/dist/{index-CcNV1b5l.js → index-DEi2-2_y.js} +2 -2
- package/dist/{index-CcNV1b5l.js.map → index-DEi2-2_y.js.map} +1 -1
- package/dist/{index-C0BTirT_.js → index-HznPfOtP.js} +218 -216
- package/dist/index-HznPfOtP.js.map +1 -0
- package/dist/index.d.ts +80 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/index-C0BTirT_.js.map +0 -1
- package/dist/index-CAc7tJ3r.cjs.map +0 -1
|
@@ -940,6 +940,179 @@ function useChainStrategies() {
|
|
|
940
940
|
}
|
|
941
941
|
return context;
|
|
942
942
|
}
|
|
943
|
+
const truncateToDecimals = (num, decimals) => {
|
|
944
|
+
if (!isFinite(num) || isNaN(num)) return "0";
|
|
945
|
+
const multiplier = Math.pow(10, decimals);
|
|
946
|
+
const truncated = Math.floor(num * multiplier) / multiplier;
|
|
947
|
+
return truncated.toFixed(decimals).replace(/\.?0+$/, "");
|
|
948
|
+
};
|
|
949
|
+
const formatTokenAmount = (amount, symbol, options) => {
|
|
950
|
+
const normalizedSymbol = (symbol ?? "").toUpperCase();
|
|
951
|
+
if (["USDT", "USDC", "DAI", "BUSD"].includes(normalizedSymbol) && amount >= 1) {
|
|
952
|
+
return `${Math.floor(amount)} ${normalizedSymbol}`;
|
|
953
|
+
}
|
|
954
|
+
if (options?.decimals !== void 0) {
|
|
955
|
+
return `${amount.toFixed(options.decimals)} ${normalizedSymbol}`;
|
|
956
|
+
}
|
|
957
|
+
if (amount >= 1) {
|
|
958
|
+
return `${amount.toFixed(0)} ${normalizedSymbol}`;
|
|
959
|
+
} else if (amount >= 1e-3) {
|
|
960
|
+
return `${amount.toFixed(3)} ${normalizedSymbol}`;
|
|
961
|
+
} else {
|
|
962
|
+
return `${amount.toFixed(6)} ${normalizedSymbol}`;
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
const formatUsd = (value) => {
|
|
966
|
+
if (!value || !isFinite(value)) return "$0";
|
|
967
|
+
if (value >= 1) return `$${value.toFixed(2)}`;
|
|
968
|
+
return `$${value.toFixed(6).replace(/0+$/, "").replace(/\.$/, "")}`;
|
|
969
|
+
};
|
|
970
|
+
const formatPercentage = (bps, decimals = 2) => {
|
|
971
|
+
return `${(bps / 100).toFixed(decimals).replace(/0+$/, "").replace(/\.$/, "")}%`;
|
|
972
|
+
};
|
|
973
|
+
const formatBalance = (amount, decimals = 2) => {
|
|
974
|
+
if (!isFinite(amount) || isNaN(amount) || amount <= 0) {
|
|
975
|
+
return "0.00";
|
|
976
|
+
}
|
|
977
|
+
return amount.toFixed(decimals);
|
|
978
|
+
};
|
|
979
|
+
const formatHash = (hash, startChars = 4, endChars = 4) => {
|
|
980
|
+
if (!hash) return "";
|
|
981
|
+
if (hash.length <= startChars + endChars) return hash;
|
|
982
|
+
return `${hash.slice(0, startChars)}...${hash.slice(-endChars)}`;
|
|
983
|
+
};
|
|
984
|
+
const formatAddress = formatHash;
|
|
985
|
+
function getQuoteAmounts(quote, srcToken, dstToken) {
|
|
986
|
+
if (!quote || !srcToken || !dstToken) {
|
|
987
|
+
return {
|
|
988
|
+
inputHuman: 0,
|
|
989
|
+
outputHuman: 0,
|
|
990
|
+
outputHumanRounded: "0",
|
|
991
|
+
minReceivedHuman: 0
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
const inputHuman = fromLD(quote.srcAmount, srcToken.decimals);
|
|
995
|
+
const outputHuman = fromLD(quote.dstAmount, dstToken.decimals);
|
|
996
|
+
const outputHumanRounded = truncateToDecimals(outputHuman, 2);
|
|
997
|
+
const minReceivedHuman = fromLD(quote.dstAmountMin || "0", dstToken.decimals);
|
|
998
|
+
return {
|
|
999
|
+
inputHuman,
|
|
1000
|
+
outputHuman,
|
|
1001
|
+
outputHumanRounded,
|
|
1002
|
+
minReceivedHuman
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
function getQuoteFees(quote, tokens, chains, srcToken, dstToken) {
|
|
1006
|
+
if (!quote || !tokens || !chains) {
|
|
1007
|
+
return {
|
|
1008
|
+
fees: { usd: /* @__PURE__ */ new Map(), original: /* @__PURE__ */ new Map(), formatted: /* @__PURE__ */ new Map() },
|
|
1009
|
+
inSrcToken: void 0,
|
|
1010
|
+
inDstToken: void 0
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
const feeData = computeFeesUsdFromArray(quote.fees, tokens, chains);
|
|
1014
|
+
let inSrcToken = void 0;
|
|
1015
|
+
let inDstToken = void 0;
|
|
1016
|
+
if (srcToken && quote.srcChainKey) {
|
|
1017
|
+
const feeInSrcLD = sumFeeByTokenLD(
|
|
1018
|
+
quote.fees,
|
|
1019
|
+
srcToken.address,
|
|
1020
|
+
quote.srcChainKey
|
|
1021
|
+
);
|
|
1022
|
+
const feeInSrcHuman = fromLD(feeInSrcLD, srcToken.decimals);
|
|
1023
|
+
if (feeInSrcHuman > 0) {
|
|
1024
|
+
inSrcToken = Number(truncateToDecimals(feeInSrcHuman, 8));
|
|
1025
|
+
} else if ((feeData.usd.get("total") || 0) > 0 && srcToken.price?.usd) {
|
|
1026
|
+
const feeInSrcApprox = (feeData.usd.get("total") || 0) / srcToken.price.usd;
|
|
1027
|
+
inSrcToken = Number(truncateToDecimals(feeInSrcApprox, 8));
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
if (dstToken && quote.dstChainKey) {
|
|
1031
|
+
const feeInDstLD = sumFeeByTokenLD(
|
|
1032
|
+
quote.fees,
|
|
1033
|
+
dstToken.address,
|
|
1034
|
+
quote.dstChainKey
|
|
1035
|
+
);
|
|
1036
|
+
const feeInDstHuman = fromLD(feeInDstLD, dstToken.decimals);
|
|
1037
|
+
if (feeInDstHuman > 0) {
|
|
1038
|
+
inDstToken = Number(truncateToDecimals(feeInDstHuman, 8));
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
return {
|
|
1042
|
+
fees: feeData,
|
|
1043
|
+
inSrcToken,
|
|
1044
|
+
inDstToken
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
function calculateMinReceived(quote, slippageBps, dstToken) {
|
|
1048
|
+
if (!quote || !dstToken) return 0;
|
|
1049
|
+
const dstAmountLD = BigInt(quote.dstAmount);
|
|
1050
|
+
const minAmountLD = dstAmountLD * BigInt(1e4 - slippageBps) / BigInt(1e4);
|
|
1051
|
+
return fromLD(minAmountLD.toString(), dstToken.decimals);
|
|
1052
|
+
}
|
|
1053
|
+
function getQuoteDetails(quote, srcToken, dstToken, tokens, chains, slippageBps) {
|
|
1054
|
+
const amounts = getQuoteAmounts(quote, srcToken, dstToken);
|
|
1055
|
+
const fees = getQuoteFees(quote, tokens, chains, srcToken, dstToken);
|
|
1056
|
+
const minimumReceived = calculateMinReceived(quote, slippageBps, dstToken);
|
|
1057
|
+
return {
|
|
1058
|
+
inputAmount: amounts.inputHuman,
|
|
1059
|
+
outputAmount: amounts.outputHuman,
|
|
1060
|
+
outputAmountRounded: amounts.outputHumanRounded,
|
|
1061
|
+
minimumReceived,
|
|
1062
|
+
etaSeconds: quote?.duration?.estimated,
|
|
1063
|
+
fees
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
function getRouteDisplayName(route) {
|
|
1067
|
+
if (!route) return "Stargate Bridge";
|
|
1068
|
+
const routeLower = route.toLowerCase();
|
|
1069
|
+
if (routeLower.includes("taxi")) return "Stargate V2 Fast";
|
|
1070
|
+
if (routeLower.includes("bus")) return "Stargate V2 Economy";
|
|
1071
|
+
if (routeLower.includes("oft")) return "OFT Bridge";
|
|
1072
|
+
if (routeLower.includes("v2")) return "Stargate V2";
|
|
1073
|
+
return route.split(/[/\-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
1074
|
+
}
|
|
1075
|
+
async function addNetworkFeesToQuote(quote, chainRegistry, chains) {
|
|
1076
|
+
if (!quote || !chains) {
|
|
1077
|
+
return quote;
|
|
1078
|
+
}
|
|
1079
|
+
const chainKeys = /* @__PURE__ */ new Set();
|
|
1080
|
+
quote.steps.forEach((step) => {
|
|
1081
|
+
if (step.chainKey) {
|
|
1082
|
+
chainKeys.add(step.chainKey);
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
const networkFees = [];
|
|
1086
|
+
for (const chainKey of chainKeys) {
|
|
1087
|
+
const strategy = chainRegistry.getStrategy(chainKey);
|
|
1088
|
+
if (!strategy) continue;
|
|
1089
|
+
const chain2 = chains.find((c2) => c2.chainKey === chainKey);
|
|
1090
|
+
if (!chain2) continue;
|
|
1091
|
+
const stepsForChain = quote.steps.filter((step) => step.chainKey === chainKey);
|
|
1092
|
+
if (!stepsForChain.length) continue;
|
|
1093
|
+
try {
|
|
1094
|
+
const networkFeeHuman = await strategy.estimateNetworkFee(stepsForChain);
|
|
1095
|
+
if (networkFeeHuman > 0) {
|
|
1096
|
+
const networkFeeLD = toLD(
|
|
1097
|
+
networkFeeHuman.toString(),
|
|
1098
|
+
chain2.nativeCurrency.decimals
|
|
1099
|
+
);
|
|
1100
|
+
networkFees.push({
|
|
1101
|
+
token: chain2.nativeCurrency.address,
|
|
1102
|
+
chainKey,
|
|
1103
|
+
amount: networkFeeLD,
|
|
1104
|
+
type: "network"
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
} catch (error) {
|
|
1108
|
+
console.warn(`Failed to estimate network fee for chain ${chainKey}:`, error);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
return {
|
|
1112
|
+
...quote,
|
|
1113
|
+
fees: [...quote.fees, ...networkFees]
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
943
1116
|
const toSharedDecimals = (amount, fromDecimals, toDecimals) => {
|
|
944
1117
|
const value = BigInt(amount);
|
|
945
1118
|
const diff = BigInt(toDecimals) - BigInt(fromDecimals);
|
|
@@ -1062,7 +1235,13 @@ function useBridgeQuote() {
|
|
|
1062
1235
|
return;
|
|
1063
1236
|
}
|
|
1064
1237
|
if (cancelled) return;
|
|
1065
|
-
|
|
1238
|
+
const quoteWithNetworkFees = await addNetworkFeesToQuote(
|
|
1239
|
+
quoteRoute,
|
|
1240
|
+
chainRegistry,
|
|
1241
|
+
chains
|
|
1242
|
+
);
|
|
1243
|
+
if (cancelled) return;
|
|
1244
|
+
setQuote(quoteWithNetworkFees);
|
|
1066
1245
|
} catch {
|
|
1067
1246
|
if (!cancelled) {
|
|
1068
1247
|
resetUi();
|
|
@@ -2261,48 +2440,6 @@ const useWalletSelectModal = create((set2) => ({
|
|
|
2261
2440
|
onOpen: (addressType) => set2({ isOpen: true, addressType }),
|
|
2262
2441
|
onClose: () => set2({ isOpen: false, addressType: void 0 })
|
|
2263
2442
|
}));
|
|
2264
|
-
const truncateToDecimals = (num, decimals) => {
|
|
2265
|
-
if (!isFinite(num) || isNaN(num)) return "0";
|
|
2266
|
-
const multiplier = Math.pow(10, decimals);
|
|
2267
|
-
const truncated = Math.floor(num * multiplier) / multiplier;
|
|
2268
|
-
return truncated.toFixed(decimals).replace(/\.?0+$/, "");
|
|
2269
|
-
};
|
|
2270
|
-
const formatTokenAmount = (amount, symbol, options) => {
|
|
2271
|
-
const normalizedSymbol = (symbol ?? "").toUpperCase();
|
|
2272
|
-
if (["USDT", "USDC", "DAI", "BUSD"].includes(normalizedSymbol) && amount >= 1) {
|
|
2273
|
-
return `${Math.floor(amount)} ${normalizedSymbol}`;
|
|
2274
|
-
}
|
|
2275
|
-
if (options?.decimals !== void 0) {
|
|
2276
|
-
return `${amount.toFixed(options.decimals)} ${normalizedSymbol}`;
|
|
2277
|
-
}
|
|
2278
|
-
if (amount >= 1) {
|
|
2279
|
-
return `${amount.toFixed(0)} ${normalizedSymbol}`;
|
|
2280
|
-
} else if (amount >= 1e-3) {
|
|
2281
|
-
return `${amount.toFixed(3)} ${normalizedSymbol}`;
|
|
2282
|
-
} else {
|
|
2283
|
-
return `${amount.toFixed(6)} ${normalizedSymbol}`;
|
|
2284
|
-
}
|
|
2285
|
-
};
|
|
2286
|
-
const formatUsd = (value) => {
|
|
2287
|
-
if (!value || !isFinite(value)) return "$0";
|
|
2288
|
-
if (value >= 1) return `$${value.toFixed(2)}`;
|
|
2289
|
-
return `$${value.toFixed(6).replace(/0+$/, "").replace(/\.$/, "")}`;
|
|
2290
|
-
};
|
|
2291
|
-
const formatPercentage = (bps, decimals = 2) => {
|
|
2292
|
-
return `${(bps / 100).toFixed(decimals).replace(/0+$/, "").replace(/\.$/, "")}%`;
|
|
2293
|
-
};
|
|
2294
|
-
const formatBalance = (amount, decimals = 2) => {
|
|
2295
|
-
if (!isFinite(amount) || isNaN(amount) || amount <= 0) {
|
|
2296
|
-
return "0.00";
|
|
2297
|
-
}
|
|
2298
|
-
return amount.toFixed(decimals);
|
|
2299
|
-
};
|
|
2300
|
-
const formatHash = (hash, startChars = 4, endChars = 4) => {
|
|
2301
|
-
if (!hash) return "";
|
|
2302
|
-
if (hash.length <= startChars + endChars) return hash;
|
|
2303
|
-
return `${hash.slice(0, startChars)}...${hash.slice(-endChars)}`;
|
|
2304
|
-
};
|
|
2305
|
-
const formatAddress = formatHash;
|
|
2306
2443
|
const EditIcon = (props) => {
|
|
2307
2444
|
return /* @__PURE__ */ jsxs(
|
|
2308
2445
|
"svg",
|
|
@@ -2752,96 +2889,6 @@ const TokenSymbol = ({
|
|
|
2752
2889
|
const src2 = `${BASE_URL}/${normalizedSymbol}.svg`;
|
|
2753
2890
|
return /* @__PURE__ */ jsx("img", { src: src2, alt: alt ?? symbol, className });
|
|
2754
2891
|
};
|
|
2755
|
-
function getQuoteAmounts(quote, srcToken, dstToken) {
|
|
2756
|
-
if (!quote || !srcToken || !dstToken) {
|
|
2757
|
-
return {
|
|
2758
|
-
inputHuman: 0,
|
|
2759
|
-
outputHuman: 0,
|
|
2760
|
-
outputHumanRounded: "0",
|
|
2761
|
-
minReceivedHuman: 0
|
|
2762
|
-
};
|
|
2763
|
-
}
|
|
2764
|
-
const inputHuman = fromLD(quote.srcAmount, srcToken.decimals);
|
|
2765
|
-
const outputHuman = fromLD(quote.dstAmount, dstToken.decimals);
|
|
2766
|
-
const outputHumanRounded = truncateToDecimals(outputHuman, 2);
|
|
2767
|
-
const minReceivedHuman = fromLD(quote.dstAmountMin || "0", dstToken.decimals);
|
|
2768
|
-
return {
|
|
2769
|
-
inputHuman,
|
|
2770
|
-
outputHuman,
|
|
2771
|
-
outputHumanRounded,
|
|
2772
|
-
minReceivedHuman
|
|
2773
|
-
};
|
|
2774
|
-
}
|
|
2775
|
-
function getQuoteFees(quote, tokens, chains, srcToken, dstToken) {
|
|
2776
|
-
if (!quote || !tokens || !chains) {
|
|
2777
|
-
return {
|
|
2778
|
-
fees: { usd: /* @__PURE__ */ new Map(), original: /* @__PURE__ */ new Map(), formatted: /* @__PURE__ */ new Map() },
|
|
2779
|
-
inSrcToken: void 0,
|
|
2780
|
-
inDstToken: void 0
|
|
2781
|
-
};
|
|
2782
|
-
}
|
|
2783
|
-
const feeData = computeFeesUsdFromArray(quote.fees, tokens, chains);
|
|
2784
|
-
let inSrcToken = void 0;
|
|
2785
|
-
let inDstToken = void 0;
|
|
2786
|
-
if (srcToken && quote.srcChainKey) {
|
|
2787
|
-
const feeInSrcLD = sumFeeByTokenLD(
|
|
2788
|
-
quote.fees,
|
|
2789
|
-
srcToken.address,
|
|
2790
|
-
quote.srcChainKey
|
|
2791
|
-
);
|
|
2792
|
-
const feeInSrcHuman = fromLD(feeInSrcLD, srcToken.decimals);
|
|
2793
|
-
if (feeInSrcHuman > 0) {
|
|
2794
|
-
inSrcToken = Number(truncateToDecimals(feeInSrcHuman, 8));
|
|
2795
|
-
} else if ((feeData.usd.get("total") || 0) > 0 && srcToken.price?.usd) {
|
|
2796
|
-
const feeInSrcApprox = (feeData.usd.get("total") || 0) / srcToken.price.usd;
|
|
2797
|
-
inSrcToken = Number(truncateToDecimals(feeInSrcApprox, 8));
|
|
2798
|
-
}
|
|
2799
|
-
}
|
|
2800
|
-
if (dstToken && quote.dstChainKey) {
|
|
2801
|
-
const feeInDstLD = sumFeeByTokenLD(
|
|
2802
|
-
quote.fees,
|
|
2803
|
-
dstToken.address,
|
|
2804
|
-
quote.dstChainKey
|
|
2805
|
-
);
|
|
2806
|
-
const feeInDstHuman = fromLD(feeInDstLD, dstToken.decimals);
|
|
2807
|
-
if (feeInDstHuman > 0) {
|
|
2808
|
-
inDstToken = Number(truncateToDecimals(feeInDstHuman, 8));
|
|
2809
|
-
}
|
|
2810
|
-
}
|
|
2811
|
-
return {
|
|
2812
|
-
fees: feeData,
|
|
2813
|
-
inSrcToken,
|
|
2814
|
-
inDstToken
|
|
2815
|
-
};
|
|
2816
|
-
}
|
|
2817
|
-
function calculateMinReceived(quote, slippageBps, dstToken) {
|
|
2818
|
-
if (!quote || !dstToken) return 0;
|
|
2819
|
-
const dstAmountLD = BigInt(quote.dstAmount);
|
|
2820
|
-
const minAmountLD = dstAmountLD * BigInt(1e4 - slippageBps) / BigInt(1e4);
|
|
2821
|
-
return fromLD(minAmountLD.toString(), dstToken.decimals);
|
|
2822
|
-
}
|
|
2823
|
-
function getQuoteDetails(quote, srcToken, dstToken, tokens, chains, slippageBps) {
|
|
2824
|
-
const amounts = getQuoteAmounts(quote, srcToken, dstToken);
|
|
2825
|
-
const fees = getQuoteFees(quote, tokens, chains, srcToken, dstToken);
|
|
2826
|
-
const minimumReceived = calculateMinReceived(quote, slippageBps, dstToken);
|
|
2827
|
-
return {
|
|
2828
|
-
inputAmount: amounts.inputHuman,
|
|
2829
|
-
outputAmount: amounts.outputHuman,
|
|
2830
|
-
outputAmountRounded: amounts.outputHumanRounded,
|
|
2831
|
-
minimumReceived,
|
|
2832
|
-
etaSeconds: quote?.duration?.estimated,
|
|
2833
|
-
fees
|
|
2834
|
-
};
|
|
2835
|
-
}
|
|
2836
|
-
function getRouteDisplayName(route) {
|
|
2837
|
-
if (!route) return "Stargate Bridge";
|
|
2838
|
-
const routeLower = route.toLowerCase();
|
|
2839
|
-
if (routeLower.includes("taxi")) return "Stargate V2 Fast";
|
|
2840
|
-
if (routeLower.includes("bus")) return "Stargate V2 Economy";
|
|
2841
|
-
if (routeLower.includes("oft")) return "OFT Bridge";
|
|
2842
|
-
if (routeLower.includes("v2")) return "Stargate V2";
|
|
2843
|
-
return route.split(/[/\-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
2844
|
-
}
|
|
2845
2892
|
function useGasEstimate(amountNum) {
|
|
2846
2893
|
const { fromChain } = useChainsStore();
|
|
2847
2894
|
const { selectedAssetSymbol } = useTokensStore();
|
|
@@ -2851,9 +2898,6 @@ function useGasEstimate(amountNum) {
|
|
|
2851
2898
|
srcAddress
|
|
2852
2899
|
);
|
|
2853
2900
|
const { quote } = useBridgeQuoteStore();
|
|
2854
|
-
const { chainRegistry } = useChainStrategies();
|
|
2855
|
-
const [networkFeeEstimate, setNetworkFeeEstimate] = useState(0);
|
|
2856
|
-
const [networkFeeKnown, setNetworkFeeKnown] = useState(false);
|
|
2857
2901
|
const balancesKnown = !balancesLoading;
|
|
2858
2902
|
const chainKey = fromChain?.chainKey;
|
|
2859
2903
|
const nativeCurrencySymbol = fromChain?.nativeCurrency?.symbol;
|
|
@@ -2862,44 +2906,6 @@ function useGasEstimate(amountNum) {
|
|
|
2862
2906
|
const quoteFees = quote?.fees;
|
|
2863
2907
|
const quoteSrcChainKey = quote?.srcChainKey;
|
|
2864
2908
|
const nativeBalanceValue = nativeCurrencySymbol ? Number(balances[nativeCurrencySymbol.toUpperCase()]?.balance ?? 0) : 0;
|
|
2865
|
-
useEffect(() => {
|
|
2866
|
-
let cancelled = false;
|
|
2867
|
-
const estimate = async () => {
|
|
2868
|
-
setNetworkFeeEstimate(0);
|
|
2869
|
-
setNetworkFeeKnown(false);
|
|
2870
|
-
if (!chainKey || !quote?.steps?.length) {
|
|
2871
|
-
return;
|
|
2872
|
-
}
|
|
2873
|
-
const strategy = chainRegistry.getStrategy(chainKey);
|
|
2874
|
-
if (!strategy) {
|
|
2875
|
-
setNetworkFeeKnown(true);
|
|
2876
|
-
return;
|
|
2877
|
-
}
|
|
2878
|
-
const steps = quote.steps.filter((step) => step.chainKey === chainKey);
|
|
2879
|
-
if (!steps.length) {
|
|
2880
|
-
setNetworkFeeKnown(true);
|
|
2881
|
-
return;
|
|
2882
|
-
}
|
|
2883
|
-
try {
|
|
2884
|
-
const estimateValue = await strategy.estimateNetworkFee(steps);
|
|
2885
|
-
if (cancelled) return;
|
|
2886
|
-
setNetworkFeeEstimate(
|
|
2887
|
-
Number.isFinite(estimateValue) ? estimateValue : 0
|
|
2888
|
-
);
|
|
2889
|
-
} catch {
|
|
2890
|
-
if (cancelled) return;
|
|
2891
|
-
setNetworkFeeEstimate(0);
|
|
2892
|
-
} finally {
|
|
2893
|
-
if (!cancelled) {
|
|
2894
|
-
setNetworkFeeKnown(true);
|
|
2895
|
-
}
|
|
2896
|
-
}
|
|
2897
|
-
};
|
|
2898
|
-
void estimate();
|
|
2899
|
-
return () => {
|
|
2900
|
-
cancelled = true;
|
|
2901
|
-
};
|
|
2902
|
-
}, [chainKey, quote?.steps, chainRegistry]);
|
|
2903
2909
|
const result = useMemo(() => {
|
|
2904
2910
|
if (!chainKey || !nativeCurrencySymbol) {
|
|
2905
2911
|
return {
|
|
@@ -2928,16 +2934,13 @@ function useGasEstimate(amountNum) {
|
|
|
2928
2934
|
requiredNative = Number(feesInNative) / Math.pow(10, decimals);
|
|
2929
2935
|
quoteFeesAvailable = true;
|
|
2930
2936
|
}
|
|
2931
|
-
if (networkFeeKnown) {
|
|
2932
|
-
requiredNative += networkFeeEstimate;
|
|
2933
|
-
}
|
|
2934
2937
|
let hasEnoughGas = true;
|
|
2935
2938
|
if (isNativeSelected) {
|
|
2936
2939
|
hasEnoughGas = nativeBalance - (amountNum ?? 0) >= requiredNative;
|
|
2937
2940
|
} else {
|
|
2938
2941
|
hasEnoughGas = nativeBalance >= requiredNative;
|
|
2939
2942
|
}
|
|
2940
|
-
const shouldCheckGas = balancesKnown && quoteFeesAvailable
|
|
2943
|
+
const shouldCheckGas = balancesKnown && quoteFeesAvailable;
|
|
2941
2944
|
return {
|
|
2942
2945
|
nativeSym,
|
|
2943
2946
|
nativeBalance,
|
|
@@ -2956,9 +2959,7 @@ function useGasEstimate(amountNum) {
|
|
|
2956
2959
|
quoteSrcChainKey,
|
|
2957
2960
|
amountNum,
|
|
2958
2961
|
balancesKnown,
|
|
2959
|
-
nativeBalanceValue
|
|
2960
|
-
networkFeeEstimate,
|
|
2961
|
-
networkFeeKnown
|
|
2962
|
+
nativeBalanceValue
|
|
2962
2963
|
]);
|
|
2963
2964
|
return result;
|
|
2964
2965
|
}
|
|
@@ -4238,7 +4239,7 @@ const ProgressStep = ({
|
|
|
4238
4239
|
title: t2("transaction.steps.completed")
|
|
4239
4240
|
}
|
|
4240
4241
|
];
|
|
4241
|
-
return /* @__PURE__ */ jsx(DialogContent, { showCloseButton: false, className: "overflow-hidden md:max-w-[420px] p-0", children: /* @__PURE__ */ jsxs("div", { className: "flex relative flex-col gap-6 flex-1 items-center justify-start text-center bg-background noise p-10", children: [
|
|
4242
|
+
return /* @__PURE__ */ jsx(DialogContent, { showCloseButton: false, className: "overflow-hidden md:max-w-[420px] p-0 fixed top-0 left-0 right-0 bottom-0 translate-x-0 translate-y-0 md:left-[50%] md:top-[50%] md:translate-x-[-50%] md:translate-y-[-50%] rounded-none md:rounded-lg", children: /* @__PURE__ */ jsxs("div", { className: "flex relative flex-col gap-6 flex-1 items-center justify-center md:justify-start text-center bg-background noise p-10", children: [
|
|
4242
4243
|
icon,
|
|
4243
4244
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 pt-4 pb-2 text-center", children: /* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.inProgress") }) }),
|
|
4244
4245
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
@@ -4265,8 +4266,8 @@ const FailedStep = ({
|
|
|
4265
4266
|
}) => {
|
|
4266
4267
|
const { current, reset } = useTransactionStore();
|
|
4267
4268
|
const { t: t2 } = useBridgeTranslation();
|
|
4268
|
-
return /* @__PURE__ */ jsxs(DialogContent, { showCloseButton: true, className: "overflow-hidden md:max-w-[420px] p-0", children: [
|
|
4269
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col relative gap-4 flex-1 items-center justify-start text-center noise p-10 pb-0", children: [
|
|
4269
|
+
return /* @__PURE__ */ jsxs(DialogContent, { showCloseButton: true, className: "overflow-hidden md:max-w-[420px] p-0 fixed top-0 left-0 right-0 bottom-0 translate-x-0 translate-y-0 md:left-[50%] md:top-[50%] md:translate-x-[-50%] md:translate-y-[-50%] rounded-none md:rounded-lg", children: [
|
|
4270
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col relative gap-4 flex-1 items-center justify-center md:justify-start text-center noise p-10 pb-0", children: [
|
|
4270
4271
|
icon,
|
|
4271
4272
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 pt-4 pb-2 text-center", children: [
|
|
4272
4273
|
/* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.failed") }),
|
|
@@ -4457,9 +4458,9 @@ const SuccessStep = ({
|
|
|
4457
4458
|
DialogContent,
|
|
4458
4459
|
{
|
|
4459
4460
|
showCloseButton: true,
|
|
4460
|
-
className: "overflow-hidden md:max-w-[420px] p-0",
|
|
4461
|
+
className: "overflow-hidden md:max-w-[420px] p-0 fixed top-0 left-0 right-0 bottom-0 translate-x-0 translate-y-0 md:left-[50%] md:top-[50%] md:translate-x-[-50%] md:translate-y-[-50%] rounded-none md:rounded-lg",
|
|
4461
4462
|
children: [
|
|
4462
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 flex-1 justify-start items-center text-center bg-background noise p-10 pb-0", children: [
|
|
4463
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 flex-1 justify-center md:justify-start items-center text-center bg-background noise p-10 pb-0", children: [
|
|
4463
4464
|
icon,
|
|
4464
4465
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 pt-4 text-center", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-[28px]", children: t2("transaction.success") }) }),
|
|
4465
4466
|
/* @__PURE__ */ jsxs("div", { className: "w-full space-y-2 mt-3 relative z-10 pb-14", children: [
|
|
@@ -4544,7 +4545,7 @@ const ConfirmStep = ({
|
|
|
4544
4545
|
}) => {
|
|
4545
4546
|
const { t: t2 } = useBridgeTranslation();
|
|
4546
4547
|
const { formatTime } = useCountdown(90);
|
|
4547
|
-
return /* @__PURE__ */ jsx(DialogContent, {
|
|
4548
|
+
return /* @__PURE__ */ jsx(DialogContent, { className: "overflow-hidden md:max-w-[420px] p-0 fixed top-0 left-0 right-0 bottom-0 translate-x-0 translate-y-0 md:left-[50%] md:top-[50%] md:translate-x-[-50%] md:translate-y-[-50%] rounded-none md:rounded-lg", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col relative gap-4 flex-1 items-center justify-center md:justify-start text-center noise p-10", children: [
|
|
4548
4549
|
icon,
|
|
4549
4550
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 pt-4 pb-2 text-center", children: [
|
|
4550
4551
|
/* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.confirm") }),
|
|
@@ -6939,7 +6940,7 @@ const TokenSelectModal = ({
|
|
|
6939
6940
|
return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && handleClose(), children: /* @__PURE__ */ jsxs(
|
|
6940
6941
|
DialogContent,
|
|
6941
6942
|
{
|
|
6942
|
-
className: "md:max-h-[90dvh] md:h-[90dvh] overflow-hidden flex flex-col fixed top-0 left-0 right-0 bottom-0 translate-x-0 translate-y-0 md:left-[50%] md:top-[50%] md:translate-x-[-50%] md:translate-y-[-50%] p-6 md:p-10 md:pt-8
|
|
6943
|
+
className: "md:max-h-[90dvh] md:h-[90dvh] overflow-hidden flex flex-col fixed top-0 left-0 right-0 bottom-0 translate-x-0 translate-y-0 md:left-[50%] md:top-[50%] md:translate-x-[-50%] md:translate-y-[-50%] rounded-none md:rounded-lg p-6 md:p-10 md:pt-8",
|
|
6943
6944
|
closeButtonClassName: "right-6 md:right-10",
|
|
6944
6945
|
children: [
|
|
6945
6946
|
/* @__PURE__ */ jsx(DialogHeader, { className: "text-left pb-2", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-2xl leading-8", children: t2("bridge.selectToken") }) }),
|
|
@@ -25822,7 +25823,7 @@ class WalletConnectModal {
|
|
|
25822
25823
|
}
|
|
25823
25824
|
async initUi() {
|
|
25824
25825
|
if (typeof window !== "undefined") {
|
|
25825
|
-
await import("./index-
|
|
25826
|
+
await import("./index-DEi2-2_y.js");
|
|
25826
25827
|
const modal = document.createElement("wcm-modal");
|
|
25827
25828
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25828
25829
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -26529,41 +26530,42 @@ async function pollUntilDelivered(args) {
|
|
|
26529
26530
|
}
|
|
26530
26531
|
}
|
|
26531
26532
|
export {
|
|
26532
|
-
|
|
26533
|
+
getDestTokens as $,
|
|
26533
26534
|
getQuoteDetails as A,
|
|
26534
26535
|
getRouteDisplayName as B,
|
|
26535
26536
|
ConfigCtrl as C,
|
|
26536
|
-
|
|
26537
|
+
addNetworkFeesToQuote as D,
|
|
26537
26538
|
EventsCtrl as E,
|
|
26538
|
-
|
|
26539
|
-
|
|
26540
|
-
|
|
26541
|
-
|
|
26542
|
-
|
|
26543
|
-
|
|
26544
|
-
|
|
26539
|
+
toLD as F,
|
|
26540
|
+
fromLD as G,
|
|
26541
|
+
buildAssetMatrix as H,
|
|
26542
|
+
listAssetsForSelect as I,
|
|
26543
|
+
resolveTokenOnChain as J,
|
|
26544
|
+
resolveTokenOnChainFromMatrix$2 as K,
|
|
26545
|
+
DEFAULT_SLIPPAGE_BPS as L,
|
|
26545
26546
|
ModalCtrl as M,
|
|
26546
|
-
|
|
26547
|
+
tonNorm as N,
|
|
26547
26548
|
OptionsCtrl as O,
|
|
26548
|
-
|
|
26549
|
-
|
|
26549
|
+
isZeroAddr as P,
|
|
26550
|
+
addrForApi as Q,
|
|
26550
26551
|
RouterCtrl as R,
|
|
26551
|
-
|
|
26552
|
+
isNativeAddrEqual as S,
|
|
26552
26553
|
ToastCtrl as T,
|
|
26553
|
-
|
|
26554
|
-
|
|
26555
|
-
|
|
26556
|
-
|
|
26557
|
-
|
|
26558
|
-
|
|
26559
|
-
|
|
26554
|
+
findNativeMeta as U,
|
|
26555
|
+
lookupTokenMeta as V,
|
|
26556
|
+
computeFeesUsdFromArray as W,
|
|
26557
|
+
sumFeeByTokenLD as X,
|
|
26558
|
+
normalizeTickerSymbol$1 as Y,
|
|
26559
|
+
getChains as Z,
|
|
26560
|
+
getTokens as _,
|
|
26560
26561
|
ThemeCtrl as a,
|
|
26561
|
-
|
|
26562
|
-
|
|
26563
|
-
|
|
26564
|
-
|
|
26565
|
-
|
|
26566
|
-
|
|
26562
|
+
getQuotesByPriority as a0,
|
|
26563
|
+
isNativeAddress as a1,
|
|
26564
|
+
getEvmBalances as a2,
|
|
26565
|
+
getTonBalances as a3,
|
|
26566
|
+
getTronBalances as a4,
|
|
26567
|
+
getDeliveryStatus as a5,
|
|
26568
|
+
pollUntilDelivered as a6,
|
|
26567
26569
|
ExplorerCtrl as b,
|
|
26568
26570
|
CoreUtil as c,
|
|
26569
26571
|
EvaaBridge as d,
|
|
@@ -26590,4 +26592,4 @@ export {
|
|
|
26590
26592
|
getQuoteFees as y,
|
|
26591
26593
|
calculateMinReceived as z
|
|
26592
26594
|
};
|
|
26593
|
-
//# sourceMappingURL=index-
|
|
26595
|
+
//# sourceMappingURL=index-HznPfOtP.js.map
|