@rash2x/bridge-widget 0.5.9 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/evaa-bridge.cjs +2 -1
- package/dist/evaa-bridge.cjs.map +1 -1
- package/dist/evaa-bridge.mjs +43 -42
- package/dist/{index-Bdh_cEEE.cjs → index-BYtzp04q.cjs} +2 -2
- package/dist/{index-Bdh_cEEE.cjs.map → index-BYtzp04q.cjs.map} +1 -1
- package/dist/{index-BXdYB1Ge.js → index-BwXs7MXT.js} +202 -43
- package/dist/index-BwXs7MXT.js.map +1 -0
- package/dist/{index-CphEQoZi.cjs → index-DSWwK-TL.cjs} +161 -2
- package/dist/{index-BXdYB1Ge.js.map → index-DSWwK-TL.cjs.map} +1 -1
- package/dist/{index-Ciui5BKt.js → index-UecTcXLf.js} +2 -2
- package/dist/{index-Ciui5BKt.js.map → index-UecTcXLf.js.map} +1 -1
- package/dist/index.d.ts +101 -0
- package/package.json +1 -1
- package/dist/index-CphEQoZi.cjs.map +0 -1
|
@@ -25809,7 +25809,7 @@ class WalletConnectModal {
|
|
|
25809
25809
|
}
|
|
25810
25810
|
async initUi() {
|
|
25811
25811
|
if (typeof window !== "undefined") {
|
|
25812
|
-
await Promise.resolve().then(() => require("./index-
|
|
25812
|
+
await Promise.resolve().then(() => require("./index-BYtzp04q.cjs"));
|
|
25813
25813
|
const modal = document.createElement("wcm-modal");
|
|
25814
25814
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25815
25815
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -26501,6 +26501,164 @@ async function pollUntilDelivered(args) {
|
|
|
26501
26501
|
await new Promise((r2) => setTimeout(r2, intervalMs));
|
|
26502
26502
|
}
|
|
26503
26503
|
}
|
|
26504
|
+
const TOKEN_ICON_BASE_URL = "https://icons-ckg.pages.dev/stargate-light/tokens";
|
|
26505
|
+
const NETWORK_ICON_BASE_URL = "https://icons-ckg.pages.dev/stargate-light/networks";
|
|
26506
|
+
function getTokenIconUrl(symbol) {
|
|
26507
|
+
const normalizedSymbol = normalizeTickerSymbol$1(symbol).toLowerCase();
|
|
26508
|
+
return `${TOKEN_ICON_BASE_URL}/${normalizedSymbol}.svg`;
|
|
26509
|
+
}
|
|
26510
|
+
function getNetworkIconUrl(chainKey) {
|
|
26511
|
+
const normalizedChainKey = chainKey.toLowerCase();
|
|
26512
|
+
return `${NETWORK_ICON_BASE_URL}/${normalizedChainKey}.svg`;
|
|
26513
|
+
}
|
|
26514
|
+
function formatEstimatedTime(seconds) {
|
|
26515
|
+
if (seconds < 60) {
|
|
26516
|
+
return `~${seconds}s`;
|
|
26517
|
+
}
|
|
26518
|
+
const minutes = Math.round(seconds / 60);
|
|
26519
|
+
if (minutes === 1) {
|
|
26520
|
+
return "~1 min";
|
|
26521
|
+
}
|
|
26522
|
+
if (minutes < 60) {
|
|
26523
|
+
return `~${minutes} min`;
|
|
26524
|
+
}
|
|
26525
|
+
const hours = Math.round(minutes / 60);
|
|
26526
|
+
return `~${hours}h`;
|
|
26527
|
+
}
|
|
26528
|
+
function parseRouteType(route) {
|
|
26529
|
+
if (!route) return "STARGATE_V2_FAST";
|
|
26530
|
+
const routeUpper = route.toUpperCase();
|
|
26531
|
+
if (routeUpper.includes("STARGATE_V2") || routeUpper.includes("STARGATEV2")) {
|
|
26532
|
+
return "STARGATE_V2_FAST";
|
|
26533
|
+
}
|
|
26534
|
+
if (routeUpper.includes("OFT")) {
|
|
26535
|
+
return "OFT";
|
|
26536
|
+
}
|
|
26537
|
+
if (routeUpper.includes("STARGATE_V1") || routeUpper.includes("STARGATEV1")) {
|
|
26538
|
+
return "STARGATE_V1";
|
|
26539
|
+
}
|
|
26540
|
+
return "STARGATE_V2_FAST";
|
|
26541
|
+
}
|
|
26542
|
+
function useBridgeData() {
|
|
26543
|
+
const { quote, status, error, noRoute } = useBridgeQuoteStore();
|
|
26544
|
+
const { selectedAssetSymbol, assetMatrix, tokens } = useTokensStore();
|
|
26545
|
+
const { chains } = useChainsStore();
|
|
26546
|
+
const { slippageBps } = useSettingsStore();
|
|
26547
|
+
return react.useMemo(() => {
|
|
26548
|
+
if (!quote || !chains || !tokens) {
|
|
26549
|
+
return {
|
|
26550
|
+
token: null,
|
|
26551
|
+
sourceNetwork: null,
|
|
26552
|
+
destinationNetwork: null,
|
|
26553
|
+
gateway: null,
|
|
26554
|
+
amounts: null,
|
|
26555
|
+
fees: null,
|
|
26556
|
+
estimatedTime: null,
|
|
26557
|
+
status,
|
|
26558
|
+
isReady: false,
|
|
26559
|
+
error,
|
|
26560
|
+
noRoute
|
|
26561
|
+
};
|
|
26562
|
+
}
|
|
26563
|
+
const sourceChain = chains.find(
|
|
26564
|
+
(c2) => c2.chainKey.toLowerCase() === quote.srcChainKey.toLowerCase()
|
|
26565
|
+
);
|
|
26566
|
+
const destinationChain = chains.find(
|
|
26567
|
+
(c2) => c2.chainKey.toLowerCase() === quote.dstChainKey.toLowerCase()
|
|
26568
|
+
);
|
|
26569
|
+
const srcToken = resolveTokenOnChainFromMatrix$2(
|
|
26570
|
+
assetMatrix,
|
|
26571
|
+
selectedAssetSymbol,
|
|
26572
|
+
quote.srcChainKey
|
|
26573
|
+
);
|
|
26574
|
+
const dstToken = resolveTokenOnChainFromMatrix$2(
|
|
26575
|
+
assetMatrix,
|
|
26576
|
+
selectedAssetSymbol,
|
|
26577
|
+
quote.dstChainKey
|
|
26578
|
+
);
|
|
26579
|
+
const amounts = getQuoteAmounts(quote, srcToken, dstToken);
|
|
26580
|
+
const minReceived = calculateMinReceived(quote, slippageBps, dstToken);
|
|
26581
|
+
const feeData = getQuoteFees(quote, tokens, chains, srcToken, dstToken);
|
|
26582
|
+
const fees = {
|
|
26583
|
+
source: feeData.inSrcToken && srcToken ? {
|
|
26584
|
+
amount: feeData.inSrcToken,
|
|
26585
|
+
symbol: srcToken.symbol,
|
|
26586
|
+
usd: feeData.inSrcToken * (srcToken.price?.usd || 0)
|
|
26587
|
+
} : null,
|
|
26588
|
+
destination: feeData.inDstToken && dstToken ? {
|
|
26589
|
+
amount: feeData.inDstToken,
|
|
26590
|
+
symbol: dstToken.symbol,
|
|
26591
|
+
usd: feeData.inDstToken * (dstToken.price?.usd || 0)
|
|
26592
|
+
} : null,
|
|
26593
|
+
protocol: feeData.protocolFeeUsd ? { usd: feeData.protocolFeeUsd } : null,
|
|
26594
|
+
message: feeData.messageFeeUsd ? { usd: feeData.messageFeeUsd } : null,
|
|
26595
|
+
service: feeData.serviceUsd ? { usd: feeData.serviceUsd } : null,
|
|
26596
|
+
blockchain: feeData.blockchainUsd ? { usd: feeData.blockchainUsd } : null,
|
|
26597
|
+
total: {
|
|
26598
|
+
usd: feeData.totalUsd
|
|
26599
|
+
}
|
|
26600
|
+
};
|
|
26601
|
+
const estimatedTime = quote.duration?.estimated ? {
|
|
26602
|
+
seconds: quote.duration.estimated,
|
|
26603
|
+
formatted: formatEstimatedTime(quote.duration.estimated)
|
|
26604
|
+
} : null;
|
|
26605
|
+
const token = srcToken ? {
|
|
26606
|
+
symbol: srcToken.symbol,
|
|
26607
|
+
address: srcToken.address,
|
|
26608
|
+
decimals: srcToken.decimals,
|
|
26609
|
+
name: srcToken.name,
|
|
26610
|
+
iconUrl: getTokenIconUrl(srcToken.symbol)
|
|
26611
|
+
} : null;
|
|
26612
|
+
const sourceNetwork = sourceChain ? {
|
|
26613
|
+
chainKey: sourceChain.chainKey,
|
|
26614
|
+
name: sourceChain.name,
|
|
26615
|
+
chainId: sourceChain.chainId,
|
|
26616
|
+
chainType: sourceChain.chainType,
|
|
26617
|
+
iconUrl: getNetworkIconUrl(sourceChain.chainKey)
|
|
26618
|
+
} : null;
|
|
26619
|
+
const destinationNetwork = destinationChain ? {
|
|
26620
|
+
chainKey: destinationChain.chainKey,
|
|
26621
|
+
name: destinationChain.name,
|
|
26622
|
+
chainId: destinationChain.chainId,
|
|
26623
|
+
chainType: destinationChain.chainType,
|
|
26624
|
+
iconUrl: getNetworkIconUrl(destinationChain.chainKey)
|
|
26625
|
+
} : null;
|
|
26626
|
+
const gateway = {
|
|
26627
|
+
route: quote.route,
|
|
26628
|
+
routeType: parseRouteType(quote.route)
|
|
26629
|
+
};
|
|
26630
|
+
return {
|
|
26631
|
+
token,
|
|
26632
|
+
sourceNetwork,
|
|
26633
|
+
destinationNetwork,
|
|
26634
|
+
gateway,
|
|
26635
|
+
amounts: {
|
|
26636
|
+
input: quote.srcAmount,
|
|
26637
|
+
inputHuman: amounts.inputHuman,
|
|
26638
|
+
output: quote.dstAmount,
|
|
26639
|
+
outputHuman: amounts.outputHuman,
|
|
26640
|
+
outputRounded: amounts.outputHumanRounded,
|
|
26641
|
+
minimumReceived: minReceived
|
|
26642
|
+
},
|
|
26643
|
+
fees,
|
|
26644
|
+
estimatedTime,
|
|
26645
|
+
status,
|
|
26646
|
+
isReady: status === "success" && !!quote && !noRoute,
|
|
26647
|
+
error,
|
|
26648
|
+
noRoute
|
|
26649
|
+
};
|
|
26650
|
+
}, [
|
|
26651
|
+
quote,
|
|
26652
|
+
chains,
|
|
26653
|
+
tokens,
|
|
26654
|
+
selectedAssetSymbol,
|
|
26655
|
+
assetMatrix,
|
|
26656
|
+
slippageBps,
|
|
26657
|
+
status,
|
|
26658
|
+
error,
|
|
26659
|
+
noRoute
|
|
26660
|
+
]);
|
|
26661
|
+
}
|
|
26504
26662
|
exports.ConfigCtrl = ConfigCtrl;
|
|
26505
26663
|
exports.CoreUtil = CoreUtil;
|
|
26506
26664
|
exports.DEFAULT_SLIPPAGE_BPS = DEFAULT_SLIPPAGE_BPS;
|
|
@@ -26556,6 +26714,7 @@ exports.sumFeeByTokenLD = sumFeeByTokenLD;
|
|
|
26556
26714
|
exports.toLD = toLD;
|
|
26557
26715
|
exports.tonNorm = tonNorm;
|
|
26558
26716
|
exports.truncateToDecimals = truncateToDecimals;
|
|
26717
|
+
exports.useBridgeData = useBridgeData;
|
|
26559
26718
|
exports.useBridgeQuoteStore = useBridgeQuoteStore;
|
|
26560
26719
|
exports.useChainsStore = useChainsStore;
|
|
26561
26720
|
exports.useConnectedWalletsStore = useConnectedWalletsStore;
|
|
@@ -26564,4 +26723,4 @@ exports.useSettingsStore = useSettingsStore;
|
|
|
26564
26723
|
exports.useSwapModel = useSwapModel;
|
|
26565
26724
|
exports.useTokensStore = useTokensStore;
|
|
26566
26725
|
exports.useTransactionStore = useTransactionStore;
|
|
26567
|
-
//# sourceMappingURL=index-
|
|
26726
|
+
//# sourceMappingURL=index-DSWwK-TL.cjs.map
|