@rash2x/bridge-widget 0.6.61 → 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-Bl9Q1m-4.cjs → index-CSE-oDw8.cjs} +2 -2
- package/dist/{index-Bl9Q1m-4.cjs.map → index-CSE-oDw8.cjs.map} +1 -1
- package/dist/{index-rAch8BQe.cjs → index-CpKOf8oF.cjs} +196 -193
- package/dist/index-CpKOf8oF.cjs.map +1 -0
- package/dist/{index-yQkayDGz.js → index-DEi2-2_y.js} +2 -2
- package/dist/{index-yQkayDGz.js.map → index-DEi2-2_y.js.map} +1 -1
- package/dist/{index-D0OSdsmf.js → index-HznPfOtP.js} +222 -219
- 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-D0OSdsmf.js.map +0 -1
- package/dist/index-rAch8BQe.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();
|
|
@@ -2028,16 +2207,17 @@ const SearchInput = ({
|
|
|
2028
2207
|
placeholder,
|
|
2029
2208
|
value,
|
|
2030
2209
|
onChange,
|
|
2031
|
-
className
|
|
2210
|
+
className,
|
|
2211
|
+
rootClassName
|
|
2032
2212
|
}) => {
|
|
2033
|
-
return /* @__PURE__ */ jsxs("div", { className: cn$2("rounded-xs relative"), children: [
|
|
2213
|
+
return /* @__PURE__ */ jsxs("div", { className: cn$2("rounded-xs relative", rootClassName), children: [
|
|
2034
2214
|
/* @__PURE__ */ jsx(SearchIcon, { className: "w-6 h-6 absolute z-10 left-5 top-0 bottom-0 my-auto text-foreground" }),
|
|
2035
2215
|
/* @__PURE__ */ jsx(
|
|
2036
2216
|
Input,
|
|
2037
2217
|
{
|
|
2038
2218
|
placeholder,
|
|
2039
2219
|
className: cn$2(
|
|
2040
|
-
"w-full outline-none px-5 py-4 relative pl-16 bg-input border transition-all border-transparent rounded-xs ring-0 leading-0 h-13 text-base
|
|
2220
|
+
"w-full outline-none px-5 py-4 relative pl-16 bg-input border transition-all border-transparent rounded-xs ring-0 leading-0 h-13 text-base",
|
|
2041
2221
|
value && "pr-16",
|
|
2042
2222
|
className
|
|
2043
2223
|
),
|
|
@@ -2260,48 +2440,6 @@ const useWalletSelectModal = create((set2) => ({
|
|
|
2260
2440
|
onOpen: (addressType) => set2({ isOpen: true, addressType }),
|
|
2261
2441
|
onClose: () => set2({ isOpen: false, addressType: void 0 })
|
|
2262
2442
|
}));
|
|
2263
|
-
const truncateToDecimals = (num, decimals) => {
|
|
2264
|
-
if (!isFinite(num) || isNaN(num)) return "0";
|
|
2265
|
-
const multiplier = Math.pow(10, decimals);
|
|
2266
|
-
const truncated = Math.floor(num * multiplier) / multiplier;
|
|
2267
|
-
return truncated.toFixed(decimals).replace(/\.?0+$/, "");
|
|
2268
|
-
};
|
|
2269
|
-
const formatTokenAmount = (amount, symbol, options) => {
|
|
2270
|
-
const normalizedSymbol = (symbol ?? "").toUpperCase();
|
|
2271
|
-
if (["USDT", "USDC", "DAI", "BUSD"].includes(normalizedSymbol) && amount >= 1) {
|
|
2272
|
-
return `${Math.floor(amount)} ${normalizedSymbol}`;
|
|
2273
|
-
}
|
|
2274
|
-
if (options?.decimals !== void 0) {
|
|
2275
|
-
return `${amount.toFixed(options.decimals)} ${normalizedSymbol}`;
|
|
2276
|
-
}
|
|
2277
|
-
if (amount >= 1) {
|
|
2278
|
-
return `${amount.toFixed(0)} ${normalizedSymbol}`;
|
|
2279
|
-
} else if (amount >= 1e-3) {
|
|
2280
|
-
return `${amount.toFixed(3)} ${normalizedSymbol}`;
|
|
2281
|
-
} else {
|
|
2282
|
-
return `${amount.toFixed(6)} ${normalizedSymbol}`;
|
|
2283
|
-
}
|
|
2284
|
-
};
|
|
2285
|
-
const formatUsd = (value) => {
|
|
2286
|
-
if (!value || !isFinite(value)) return "$0";
|
|
2287
|
-
if (value >= 1) return `$${value.toFixed(2)}`;
|
|
2288
|
-
return `$${value.toFixed(6).replace(/0+$/, "").replace(/\.$/, "")}`;
|
|
2289
|
-
};
|
|
2290
|
-
const formatPercentage = (bps, decimals = 2) => {
|
|
2291
|
-
return `${(bps / 100).toFixed(decimals).replace(/0+$/, "").replace(/\.$/, "")}%`;
|
|
2292
|
-
};
|
|
2293
|
-
const formatBalance = (amount, decimals = 2) => {
|
|
2294
|
-
if (!isFinite(amount) || isNaN(amount) || amount <= 0) {
|
|
2295
|
-
return "0.00";
|
|
2296
|
-
}
|
|
2297
|
-
return amount.toFixed(decimals);
|
|
2298
|
-
};
|
|
2299
|
-
const formatHash = (hash, startChars = 4, endChars = 4) => {
|
|
2300
|
-
if (!hash) return "";
|
|
2301
|
-
if (hash.length <= startChars + endChars) return hash;
|
|
2302
|
-
return `${hash.slice(0, startChars)}...${hash.slice(-endChars)}`;
|
|
2303
|
-
};
|
|
2304
|
-
const formatAddress = formatHash;
|
|
2305
2443
|
const EditIcon = (props) => {
|
|
2306
2444
|
return /* @__PURE__ */ jsxs(
|
|
2307
2445
|
"svg",
|
|
@@ -2751,96 +2889,6 @@ const TokenSymbol = ({
|
|
|
2751
2889
|
const src2 = `${BASE_URL}/${normalizedSymbol}.svg`;
|
|
2752
2890
|
return /* @__PURE__ */ jsx("img", { src: src2, alt: alt ?? symbol, className });
|
|
2753
2891
|
};
|
|
2754
|
-
function getQuoteAmounts(quote, srcToken, dstToken) {
|
|
2755
|
-
if (!quote || !srcToken || !dstToken) {
|
|
2756
|
-
return {
|
|
2757
|
-
inputHuman: 0,
|
|
2758
|
-
outputHuman: 0,
|
|
2759
|
-
outputHumanRounded: "0",
|
|
2760
|
-
minReceivedHuman: 0
|
|
2761
|
-
};
|
|
2762
|
-
}
|
|
2763
|
-
const inputHuman = fromLD(quote.srcAmount, srcToken.decimals);
|
|
2764
|
-
const outputHuman = fromLD(quote.dstAmount, dstToken.decimals);
|
|
2765
|
-
const outputHumanRounded = truncateToDecimals(outputHuman, 2);
|
|
2766
|
-
const minReceivedHuman = fromLD(quote.dstAmountMin || "0", dstToken.decimals);
|
|
2767
|
-
return {
|
|
2768
|
-
inputHuman,
|
|
2769
|
-
outputHuman,
|
|
2770
|
-
outputHumanRounded,
|
|
2771
|
-
minReceivedHuman
|
|
2772
|
-
};
|
|
2773
|
-
}
|
|
2774
|
-
function getQuoteFees(quote, tokens, chains, srcToken, dstToken) {
|
|
2775
|
-
if (!quote || !tokens || !chains) {
|
|
2776
|
-
return {
|
|
2777
|
-
fees: { usd: /* @__PURE__ */ new Map(), original: /* @__PURE__ */ new Map(), formatted: /* @__PURE__ */ new Map() },
|
|
2778
|
-
inSrcToken: void 0,
|
|
2779
|
-
inDstToken: void 0
|
|
2780
|
-
};
|
|
2781
|
-
}
|
|
2782
|
-
const feeData = computeFeesUsdFromArray(quote.fees, tokens, chains);
|
|
2783
|
-
let inSrcToken = void 0;
|
|
2784
|
-
let inDstToken = void 0;
|
|
2785
|
-
if (srcToken && quote.srcChainKey) {
|
|
2786
|
-
const feeInSrcLD = sumFeeByTokenLD(
|
|
2787
|
-
quote.fees,
|
|
2788
|
-
srcToken.address,
|
|
2789
|
-
quote.srcChainKey
|
|
2790
|
-
);
|
|
2791
|
-
const feeInSrcHuman = fromLD(feeInSrcLD, srcToken.decimals);
|
|
2792
|
-
if (feeInSrcHuman > 0) {
|
|
2793
|
-
inSrcToken = Number(truncateToDecimals(feeInSrcHuman, 8));
|
|
2794
|
-
} else if ((feeData.usd.get("total") || 0) > 0 && srcToken.price?.usd) {
|
|
2795
|
-
const feeInSrcApprox = (feeData.usd.get("total") || 0) / srcToken.price.usd;
|
|
2796
|
-
inSrcToken = Number(truncateToDecimals(feeInSrcApprox, 8));
|
|
2797
|
-
}
|
|
2798
|
-
}
|
|
2799
|
-
if (dstToken && quote.dstChainKey) {
|
|
2800
|
-
const feeInDstLD = sumFeeByTokenLD(
|
|
2801
|
-
quote.fees,
|
|
2802
|
-
dstToken.address,
|
|
2803
|
-
quote.dstChainKey
|
|
2804
|
-
);
|
|
2805
|
-
const feeInDstHuman = fromLD(feeInDstLD, dstToken.decimals);
|
|
2806
|
-
if (feeInDstHuman > 0) {
|
|
2807
|
-
inDstToken = Number(truncateToDecimals(feeInDstHuman, 8));
|
|
2808
|
-
}
|
|
2809
|
-
}
|
|
2810
|
-
return {
|
|
2811
|
-
fees: feeData,
|
|
2812
|
-
inSrcToken,
|
|
2813
|
-
inDstToken
|
|
2814
|
-
};
|
|
2815
|
-
}
|
|
2816
|
-
function calculateMinReceived(quote, slippageBps, dstToken) {
|
|
2817
|
-
if (!quote || !dstToken) return 0;
|
|
2818
|
-
const dstAmountLD = BigInt(quote.dstAmount);
|
|
2819
|
-
const minAmountLD = dstAmountLD * BigInt(1e4 - slippageBps) / BigInt(1e4);
|
|
2820
|
-
return fromLD(minAmountLD.toString(), dstToken.decimals);
|
|
2821
|
-
}
|
|
2822
|
-
function getQuoteDetails(quote, srcToken, dstToken, tokens, chains, slippageBps) {
|
|
2823
|
-
const amounts = getQuoteAmounts(quote, srcToken, dstToken);
|
|
2824
|
-
const fees = getQuoteFees(quote, tokens, chains, srcToken, dstToken);
|
|
2825
|
-
const minimumReceived = calculateMinReceived(quote, slippageBps, dstToken);
|
|
2826
|
-
return {
|
|
2827
|
-
inputAmount: amounts.inputHuman,
|
|
2828
|
-
outputAmount: amounts.outputHuman,
|
|
2829
|
-
outputAmountRounded: amounts.outputHumanRounded,
|
|
2830
|
-
minimumReceived,
|
|
2831
|
-
etaSeconds: quote?.duration?.estimated,
|
|
2832
|
-
fees
|
|
2833
|
-
};
|
|
2834
|
-
}
|
|
2835
|
-
function getRouteDisplayName(route) {
|
|
2836
|
-
if (!route) return "Stargate Bridge";
|
|
2837
|
-
const routeLower = route.toLowerCase();
|
|
2838
|
-
if (routeLower.includes("taxi")) return "Stargate V2 Fast";
|
|
2839
|
-
if (routeLower.includes("bus")) return "Stargate V2 Economy";
|
|
2840
|
-
if (routeLower.includes("oft")) return "OFT Bridge";
|
|
2841
|
-
if (routeLower.includes("v2")) return "Stargate V2";
|
|
2842
|
-
return route.split(/[/\-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
2843
|
-
}
|
|
2844
2892
|
function useGasEstimate(amountNum) {
|
|
2845
2893
|
const { fromChain } = useChainsStore();
|
|
2846
2894
|
const { selectedAssetSymbol } = useTokensStore();
|
|
@@ -2850,9 +2898,6 @@ function useGasEstimate(amountNum) {
|
|
|
2850
2898
|
srcAddress
|
|
2851
2899
|
);
|
|
2852
2900
|
const { quote } = useBridgeQuoteStore();
|
|
2853
|
-
const { chainRegistry } = useChainStrategies();
|
|
2854
|
-
const [networkFeeEstimate, setNetworkFeeEstimate] = useState(0);
|
|
2855
|
-
const [networkFeeKnown, setNetworkFeeKnown] = useState(false);
|
|
2856
2901
|
const balancesKnown = !balancesLoading;
|
|
2857
2902
|
const chainKey = fromChain?.chainKey;
|
|
2858
2903
|
const nativeCurrencySymbol = fromChain?.nativeCurrency?.symbol;
|
|
@@ -2861,44 +2906,6 @@ function useGasEstimate(amountNum) {
|
|
|
2861
2906
|
const quoteFees = quote?.fees;
|
|
2862
2907
|
const quoteSrcChainKey = quote?.srcChainKey;
|
|
2863
2908
|
const nativeBalanceValue = nativeCurrencySymbol ? Number(balances[nativeCurrencySymbol.toUpperCase()]?.balance ?? 0) : 0;
|
|
2864
|
-
useEffect(() => {
|
|
2865
|
-
let cancelled = false;
|
|
2866
|
-
const estimate = async () => {
|
|
2867
|
-
setNetworkFeeEstimate(0);
|
|
2868
|
-
setNetworkFeeKnown(false);
|
|
2869
|
-
if (!chainKey || !quote?.steps?.length) {
|
|
2870
|
-
return;
|
|
2871
|
-
}
|
|
2872
|
-
const strategy = chainRegistry.getStrategy(chainKey);
|
|
2873
|
-
if (!strategy) {
|
|
2874
|
-
setNetworkFeeKnown(true);
|
|
2875
|
-
return;
|
|
2876
|
-
}
|
|
2877
|
-
const steps = quote.steps.filter((step) => step.chainKey === chainKey);
|
|
2878
|
-
if (!steps.length) {
|
|
2879
|
-
setNetworkFeeKnown(true);
|
|
2880
|
-
return;
|
|
2881
|
-
}
|
|
2882
|
-
try {
|
|
2883
|
-
const estimateValue = await strategy.estimateNetworkFee(steps);
|
|
2884
|
-
if (cancelled) return;
|
|
2885
|
-
setNetworkFeeEstimate(
|
|
2886
|
-
Number.isFinite(estimateValue) ? estimateValue : 0
|
|
2887
|
-
);
|
|
2888
|
-
} catch {
|
|
2889
|
-
if (cancelled) return;
|
|
2890
|
-
setNetworkFeeEstimate(0);
|
|
2891
|
-
} finally {
|
|
2892
|
-
if (!cancelled) {
|
|
2893
|
-
setNetworkFeeKnown(true);
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
};
|
|
2897
|
-
void estimate();
|
|
2898
|
-
return () => {
|
|
2899
|
-
cancelled = true;
|
|
2900
|
-
};
|
|
2901
|
-
}, [chainKey, quote?.steps, chainRegistry]);
|
|
2902
2909
|
const result = useMemo(() => {
|
|
2903
2910
|
if (!chainKey || !nativeCurrencySymbol) {
|
|
2904
2911
|
return {
|
|
@@ -2927,16 +2934,13 @@ function useGasEstimate(amountNum) {
|
|
|
2927
2934
|
requiredNative = Number(feesInNative) / Math.pow(10, decimals);
|
|
2928
2935
|
quoteFeesAvailable = true;
|
|
2929
2936
|
}
|
|
2930
|
-
if (networkFeeKnown) {
|
|
2931
|
-
requiredNative += networkFeeEstimate;
|
|
2932
|
-
}
|
|
2933
2937
|
let hasEnoughGas = true;
|
|
2934
2938
|
if (isNativeSelected) {
|
|
2935
2939
|
hasEnoughGas = nativeBalance - (amountNum ?? 0) >= requiredNative;
|
|
2936
2940
|
} else {
|
|
2937
2941
|
hasEnoughGas = nativeBalance >= requiredNative;
|
|
2938
2942
|
}
|
|
2939
|
-
const shouldCheckGas = balancesKnown && quoteFeesAvailable
|
|
2943
|
+
const shouldCheckGas = balancesKnown && quoteFeesAvailable;
|
|
2940
2944
|
return {
|
|
2941
2945
|
nativeSym,
|
|
2942
2946
|
nativeBalance,
|
|
@@ -2955,9 +2959,7 @@ function useGasEstimate(amountNum) {
|
|
|
2955
2959
|
quoteSrcChainKey,
|
|
2956
2960
|
amountNum,
|
|
2957
2961
|
balancesKnown,
|
|
2958
|
-
nativeBalanceValue
|
|
2959
|
-
networkFeeEstimate,
|
|
2960
|
-
networkFeeKnown
|
|
2962
|
+
nativeBalanceValue
|
|
2961
2963
|
]);
|
|
2962
2964
|
return result;
|
|
2963
2965
|
}
|
|
@@ -4237,7 +4239,7 @@ const ProgressStep = ({
|
|
|
4237
4239
|
title: t2("transaction.steps.completed")
|
|
4238
4240
|
}
|
|
4239
4241
|
];
|
|
4240
|
-
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: [
|
|
4241
4243
|
icon,
|
|
4242
4244
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 pt-4 pb-2 text-center", children: /* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.inProgress") }) }),
|
|
4243
4245
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
@@ -4264,8 +4266,8 @@ const FailedStep = ({
|
|
|
4264
4266
|
}) => {
|
|
4265
4267
|
const { current, reset } = useTransactionStore();
|
|
4266
4268
|
const { t: t2 } = useBridgeTranslation();
|
|
4267
|
-
return /* @__PURE__ */ jsxs(DialogContent, { showCloseButton: true, className: "overflow-hidden md:max-w-[420px] p-0", children: [
|
|
4268
|
-
/* @__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: [
|
|
4269
4271
|
icon,
|
|
4270
4272
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 pt-4 pb-2 text-center", children: [
|
|
4271
4273
|
/* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.failed") }),
|
|
@@ -4456,9 +4458,9 @@ const SuccessStep = ({
|
|
|
4456
4458
|
DialogContent,
|
|
4457
4459
|
{
|
|
4458
4460
|
showCloseButton: true,
|
|
4459
|
-
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",
|
|
4460
4462
|
children: [
|
|
4461
|
-
/* @__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: [
|
|
4462
4464
|
icon,
|
|
4463
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") }) }),
|
|
4464
4466
|
/* @__PURE__ */ jsxs("div", { className: "w-full space-y-2 mt-3 relative z-10 pb-14", children: [
|
|
@@ -4543,7 +4545,7 @@ const ConfirmStep = ({
|
|
|
4543
4545
|
}) => {
|
|
4544
4546
|
const { t: t2 } = useBridgeTranslation();
|
|
4545
4547
|
const { formatTime } = useCountdown(90);
|
|
4546
|
-
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: [
|
|
4547
4549
|
icon,
|
|
4548
4550
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 pt-4 pb-2 text-center", children: [
|
|
4549
4551
|
/* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.confirm") }),
|
|
@@ -6938,7 +6940,7 @@ const TokenSelectModal = ({
|
|
|
6938
6940
|
return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && handleClose(), children: /* @__PURE__ */ jsxs(
|
|
6939
6941
|
DialogContent,
|
|
6940
6942
|
{
|
|
6941
|
-
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",
|
|
6942
6944
|
closeButtonClassName: "right-6 md:right-10",
|
|
6943
6945
|
children: [
|
|
6944
6946
|
/* @__PURE__ */ jsx(DialogHeader, { className: "text-left pb-2", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-2xl leading-8", children: t2("bridge.selectToken") }) }),
|
|
@@ -25821,7 +25823,7 @@ class WalletConnectModal {
|
|
|
25821
25823
|
}
|
|
25822
25824
|
async initUi() {
|
|
25823
25825
|
if (typeof window !== "undefined") {
|
|
25824
|
-
await import("./index-
|
|
25826
|
+
await import("./index-DEi2-2_y.js");
|
|
25825
25827
|
const modal = document.createElement("wcm-modal");
|
|
25826
25828
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25827
25829
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -26528,41 +26530,42 @@ async function pollUntilDelivered(args) {
|
|
|
26528
26530
|
}
|
|
26529
26531
|
}
|
|
26530
26532
|
export {
|
|
26531
|
-
|
|
26533
|
+
getDestTokens as $,
|
|
26532
26534
|
getQuoteDetails as A,
|
|
26533
26535
|
getRouteDisplayName as B,
|
|
26534
26536
|
ConfigCtrl as C,
|
|
26535
|
-
|
|
26537
|
+
addNetworkFeesToQuote as D,
|
|
26536
26538
|
EventsCtrl as E,
|
|
26537
|
-
|
|
26538
|
-
|
|
26539
|
-
|
|
26540
|
-
|
|
26541
|
-
|
|
26542
|
-
|
|
26543
|
-
|
|
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,
|
|
26544
26546
|
ModalCtrl as M,
|
|
26545
|
-
|
|
26547
|
+
tonNorm as N,
|
|
26546
26548
|
OptionsCtrl as O,
|
|
26547
|
-
|
|
26548
|
-
|
|
26549
|
+
isZeroAddr as P,
|
|
26550
|
+
addrForApi as Q,
|
|
26549
26551
|
RouterCtrl as R,
|
|
26550
|
-
|
|
26552
|
+
isNativeAddrEqual as S,
|
|
26551
26553
|
ToastCtrl as T,
|
|
26552
|
-
|
|
26553
|
-
|
|
26554
|
-
|
|
26555
|
-
|
|
26556
|
-
|
|
26557
|
-
|
|
26558
|
-
|
|
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 _,
|
|
26559
26561
|
ThemeCtrl as a,
|
|
26560
|
-
|
|
26561
|
-
|
|
26562
|
-
|
|
26563
|
-
|
|
26564
|
-
|
|
26565
|
-
|
|
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,
|
|
26566
26569
|
ExplorerCtrl as b,
|
|
26567
26570
|
CoreUtil as c,
|
|
26568
26571
|
EvaaBridge as d,
|
|
@@ -26589,4 +26592,4 @@ export {
|
|
|
26589
26592
|
getQuoteFees as y,
|
|
26590
26593
|
calculateMinReceived as z
|
|
26591
26594
|
};
|
|
26592
|
-
//# sourceMappingURL=index-
|
|
26595
|
+
//# sourceMappingURL=index-HznPfOtP.js.map
|