@rash2x/bridge-widget 0.6.93 → 0.6.95
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 -4
- package/dist/evaa-bridge.cjs.map +1 -1
- package/dist/evaa-bridge.mjs +17 -19
- package/dist/{index-DgvHCFl2.cjs → index-CBUX3Jzi.cjs} +2 -2
- package/dist/{index-DgvHCFl2.cjs.map → index-CBUX3Jzi.cjs.map} +1 -1
- package/dist/{index-Ba3TMYQR.js → index-D8kQruAb.js} +2 -2
- package/dist/{index-Ba3TMYQR.js.map → index-D8kQruAb.js.map} +1 -1
- package/dist/{index-BDIi-D7p.js → index-UWqhEblz.js} +146 -207
- package/dist/index-UWqhEblz.js.map +1 -0
- package/dist/{index-BC-9ZbF7.cjs → index-kdPPX_i5.cjs} +131 -192
- package/dist/index-kdPPX_i5.cjs.map +1 -0
- package/dist/index.d.ts +11 -54
- package/package.json +1 -1
- package/dist/index-BC-9ZbF7.cjs.map +0 -1
- package/dist/index-BDIi-D7p.js.map +0 -1
|
@@ -35,7 +35,7 @@ const reactWindow = require("react-window");
|
|
|
35
35
|
const common$1 = { "connecting": "Connecting…", "initializing": "Initializing...", "loading": "Loading...", "paste": "paste", "close": "Close", "zeroPlaceholder": "0", "nativeToken": "Native Token" };
|
|
36
36
|
const wallets$1 = { "addTonWallet": "Add TON wallet", "addEvmWallet": "Add EVM wallet", "connectTonWallet": "Connect TON wallet", "connectEvmWallet": "Connect EVM wallet", "initializingMetamask": "Initializing MetaMask SDK...", "initializingTronlink": "Initializing TronLink...", "failedToConnectTon": "Failed to connect to TON wallet", "failedToDisconnect": "Failed to disconnect", "metamaskConnectionError": "MetaMask connection error", "failedToConnectMetamask": "Failed to connect to MetaMask", "failedToDisconnectMetamask": "Failed to disconnect from MetaMask", "selectWallet": "Select Wallet", "tonWallets": "TON", "evmWallets": "EVM", "tronWallets": "TRON", "tonconnect": "TonConnect", "metaMask": "WalletConnect", "walletConnect": "WalletConnect", "tronLink": "TronLink", "addTronWallet": "Add Tron wallet", "comingSoon": "Coming Soon", "connected": "CONNECTED", "connectedStatus": "Connected", "disconnect": "Disconnect", "chooseWallet": "Connect wallet", "oneWalletPerEnv": "You can only connect one wallet per environment.", "connect": "Connect", "connectTronWallet": "Connect Tron wallet", "connectWallet": "Connect wallet" };
|
|
37
37
|
const bridge$1 = { "max": "Max", "sourceNetwork": "Source network", "destinationNetwork": "Destination network", "selectToken": "Select token", "selectNetwork": "Select network", "selectSourceNetwork": "Select source network", "selectDestinationNetwork": "Select destination network", "searchToken": "Search token", "myTokens": "My tokens", "allTokens": "All tokens", "search": "Search", "select": "Select", "willChangeSourceChain": "Will change source network", "willChangeDestinationChain": "Will change destination network", "willChangeBothChains": "Will change both networks", "willChangeSourceNetworkAndToken": "Will change source token", "noBalancesFound": "No balances found.", "noResults": "No results", "tokenNotFound": "We couldn't find a token with that name or symbol. Please try again.", "chainNotFound": "We couldn't find a chain with that name. Please try again.", "sendToAnotherAddress": "Send to another address", "youWillReceive": "You will receive", "anotherAddressPlaceholder": "Address", "addressDoesntMatch": "Address doesn't match the {{network}} network", "checkBeforeTransfer": "Check correctness before transfer" };
|
|
38
|
-
const transaction$1 = { "enterAmount": "Enter amount", "transfer": "Transfer", "getQuote": "Get quote", "failed": "Transaction Failed", "confirm": "Confirm transaction", "signTransaction": "Sign in transaction in wallet", "quoting": "Quoting...", "inProgress": "Transaction in progress...", "checkingBalance": "Checking balance...", "insufficientBalance": "Insufficient balance", "amountTooSmall": "Min {{min}}", "amountTooLarge": "Max {{max}}", "success": "Success", "successTitle": "Success", "done": "Done", "hashCopied": "Hash copied to clipboard", "bridged": "Bridged", "transferTitle": "Transfer", "hash": "Hash", "layerzeroScan": "TxHash", "finalFee": "Final Fee", "route": "Route", "routeTooltip": "Route is the path your transfer takes between networks. The bridge is powered by LayerZero, and the specific path can affect the fee, slippage, and estimated time.", "estTime": "Est. Time", "estTimeTooltip": "Estimated time is the approximate completion time. It depends on the route and network load; actual time may vary.", "slippage": "Slippage", "slippageTooltip": "If the received amount goes below this tolerance, the transaction will be reverted.", "minimumReceived": "Minimum received", "totalFee": "Total Fee", "totalFeeTooltip": "Total fee is the estimated total cost of the transfer
|
|
38
|
+
const transaction$1 = { "enterAmount": "Enter amount", "transfer": "Transfer", "getQuote": "Get quote", "failed": "Transaction Failed", "confirm": "Confirm transaction", "signTransaction": "Sign in transaction in wallet", "quoting": "Quoting...", "inProgress": "Transaction in progress...", "checkingBalance": "Checking balance...", "insufficientBalance": "Insufficient balance", "amountTooSmall": "Min {{min}}", "amountTooLarge": "Max {{max}}", "success": "Success", "successTitle": "Success", "done": "Done", "hashCopied": "Hash copied to clipboard", "bridged": "Bridged", "transferTitle": "Transfer", "hash": "Hash", "layerzeroScan": "TxHash", "finalFee": "Final Fee", "route": "Route", "routeTooltip": "Route is the path your transfer takes between networks. The bridge is powered by LayerZero, and the specific path can affect the fee, slippage, and estimated time.", "estTime": "Est. Time", "estTimeTooltip": "Estimated time is the approximate completion time. It depends on the route and network load; actual time may vary.", "slippage": "Slippage", "slippageTooltip": "If the received amount goes below this tolerance, the transaction will be reverted.", "minimumReceived": "Minimum received", "messageFee": "Message Fee", "messageFeeTooltip": "Message fee is the LayerZero cross-chain messaging cost paid to relay your transaction between networks.", "bridgeFee": "Bridge Fee", "bridgeFeeTooltip": "Bridge fee is the difference between the amount you send and the amount you receive, charged by the bridge protocol.", "totalFee": "Total Fee", "totalFeeTooltip": "Total fee is the estimated total cost of the transfer, including message and bridge fees. The final fee may vary slightly.", "gasEstimate": "Gas: {{gas}}", "noRouteFound": "No route found", "notEnoughGas": "Not enough gas", "pasteAddressToTransfer": "Paste address to transfer", "noRouteFoundForSettings": "No route found for current settings.", "tryAdjustSettings": "Try disabling Gas on Destination, or adjust amount/networks.", "quoteError": "Quote error", "steps": { "sent": "Sent", "approving": "Approving Token", "approvingNote": "Step {{current}} of {{total}}: Confirm approval in wallet", "bridging": "Bridging", "processing": "Processing", "processingNote": "Up to 2 minutes", "completed": "Completed" } };
|
|
39
39
|
const telegram$1 = { "openWebVersion": "Open EVAA Web to Bridge", "restrictionMessage": "You can bridge between the chosen networks on EVAA web version" };
|
|
40
40
|
const app$1 = { "stargateWidgetName": "Stargate Bridge Widget", "liveWidget": "Live Widget", "getStarted": "Get Started" };
|
|
41
41
|
const settings$1 = { "title": "Settings", "gasOnDestination": "Gas on destination", "gasOnDestinationTooltip": "Adds the destination network's native token to cover fees for transactions after bridging. Increases the total fee.", "slippageTolerance": "Slippage tolerance", "slippageToleranceTooltip": "If the received amount goes below this tolerance, the transaction will be reverted.", "routePriority": "Route Priority", "routePriorityTooltip": "Select how the bridge chooses a route. Recommended balances options to find the best overall cost. Fastest prioritizes completion speed over everything else.", "highSlippageWarning": "High slippage warning", "gasPresets": { "auto": "Auto", "none": "None", "medium": "Medium", "max": "Max" }, "routePresets": { "fastest": "Fastest", "cheapest": "Cheapest", "recommended": "Recommended" } };
|
|
@@ -53,7 +53,7 @@ const en$3 = {
|
|
|
53
53
|
const common = { "connecting": "Подключение…", "initializing": "Инициализация...", "loading": "Загрузка...", "paste": "вставить", "close": "Закрыть", "zeroPlaceholder": "0", "nativeToken": "Нативный токен" };
|
|
54
54
|
const wallets = { "addTonWallet": "Добавить TON кошелёк", "addEvmWallet": "Добавить EVM кошелёк", "connectTonWallet": "Подключить TON кошелёк", "connectEvmWallet": "Подключить EVM кошелёк", "initializingMetamask": "Инициализация MetaMask SDK...", "initializingTronlink": "Инициализация TronLink...", "failedToConnectTon": "Не удалось подключиться к TON кошельку", "failedToDisconnect": "Не удалось отключиться", "metamaskConnectionError": "Ошибка подключения MetaMask", "failedToConnectMetamask": "Не удалось подключиться к MetaMask", "failedToDisconnectMetamask": "Не удалось отключиться от MetaMask", "selectWallet": "Выберите кошелёк", "tonWallets": "TON", "evmWallets": "EVM", "tronWallets": "TRON", "tonconnect": "TonConnect", "metaMask": "WalletConnect", "walletConnect": "WalletConnect", "tronLink": "TronLink", "addTronWallet": "Добавить Tron кошелёк", "comingSoon": "Скоро", "connected": "ПОДКЛЮЧЕНО", "connectedStatus": "Подключён", "disconnect": "Отключить", "chooseWallet": "Подключите кошелек", "oneWalletPerEnv": "Можно подключить только один кошелёк на окружение.", "connect": "Подключить", "connectTronWallet": "Подключить Tron кошелёк", "connectWallet": "Подключить кошелёк" };
|
|
55
55
|
const bridge = { "max": "Макс", "sourceNetwork": "Исходная сеть", "destinationNetwork": "Целевая сеть", "selectToken": "Выбрать токен", "selectNetwork": "Выбрать сеть", "selectSourceNetwork": "Выбрать исходную сеть", "selectDestinationNetwork": "Выбрать целевую сеть", "searchToken": "Поиск токена", "myTokens": "Мои токены", "allTokens": "Все токены", "search": "Поиск", "select": "Выбрать", "willChangeSourceChain": "Сменит исходную сеть", "willChangeDestinationChain": "Сменит целевую сеть", "willChangeBothChains": "Сменит обе сети", "willChangeSourceNetworkAndToken": "Сменит исходный токен", "noBalancesFound": "Балансы не найдены.", "noResults": "Нет результатов", "tokenNotFound": "Мы не смогли найти токен с таким названием или символом. Пожалуйста, попробуйте снова.", "chainNotFound": "Мы не смогли найти сеть с таким названием. Пожалуйста, попробуйте снова.", "sendToAnotherAddress": "Отправить на другой адрес", "youWillReceive": "Вы получите", "anotherAddressPlaceholder": "Адрес", "addressDoesntMatch": "Адрес не соответствует сети {{network}}", "checkBeforeTransfer": "Проверьте корректность перед переводом" };
|
|
56
|
-
const transaction = { "enterAmount": "Введите сумму", "transfer": "Перевести", "getQuote": "Получить котировку", "quoting": "Расчет котировки...", "failed": "Ошибка транзакции", "confirm": "Подтвердите транзакцию", "signTransaction": "Подпишите транзакцию в кошельке", "inProgress": "Транзакция выполняется...", "checkingBalance": "Проверка баланса...", "insufficientBalance": "Недостаточно средств", "amountTooSmall": "Минимум {{min}}", "amountTooLarge": "Максимум {{max}}", "success": "Успех", "successTitle": "Успех", "done": "Готово", "hashCopied": "Хэш скопирован в буфер обмена", "bridged": "Переведено", "transferTitle": "Перевод", "hash": "Хэш", "layerzeroScan": "TxHash", "finalFee": "Итоговая комиссия", "route": "Маршрут", "routeTooltip": "Маршрут — это путь, по которому будет выполнен перевод. Мост работает на базе LayerZero, а конкретный путь передачи между сетями может влиять на комиссию, проскальзывание и время.", "estTime": "Время", "estTimeTooltip": "Среднее время — примерное время завершения перевода. Зависит от маршрута и нагрузки сети; фактическое время может отличаться.", "slippage": "Проскальзывание", "slippageTooltip": "Если получаемая сумма окажется ниже этого допуска, транзакция будет отклонена.", "minimumReceived": "Минимум к получению", "totalFee": "Общая комиссия", "totalFeeTooltip": "Общая комиссия за
|
|
56
|
+
const transaction = { "enterAmount": "Введите сумму", "transfer": "Перевести", "getQuote": "Получить котировку", "quoting": "Расчет котировки...", "failed": "Ошибка транзакции", "confirm": "Подтвердите транзакцию", "signTransaction": "Подпишите транзакцию в кошельке", "inProgress": "Транзакция выполняется...", "checkingBalance": "Проверка баланса...", "insufficientBalance": "Недостаточно средств", "amountTooSmall": "Минимум {{min}}", "amountTooLarge": "Максимум {{max}}", "success": "Успех", "successTitle": "Успех", "done": "Готово", "hashCopied": "Хэш скопирован в буфер обмена", "bridged": "Переведено", "transferTitle": "Перевод", "hash": "Хэш", "layerzeroScan": "TxHash", "finalFee": "Итоговая комиссия", "route": "Маршрут", "routeTooltip": "Маршрут — это путь, по которому будет выполнен перевод. Мост работает на базе LayerZero, а конкретный путь передачи между сетями может влиять на комиссию, проскальзывание и время.", "estTime": "Время", "estTimeTooltip": "Среднее время — примерное время завершения перевода. Зависит от маршрута и нагрузки сети; фактическое время может отличаться.", "slippage": "Проскальзывание", "slippageTooltip": "Если получаемая сумма окажется ниже этого допуска, транзакция будет отклонена.", "minimumReceived": "Минимум к получению", "messageFee": "Комиссия сообщения", "messageFeeTooltip": "Комиссия сообщения — стоимость кросс-чейн передачи через LayerZero для ретрансляции транзакции между сетями.", "bridgeFee": "Комиссия моста", "bridgeFeeTooltip": "Комиссия моста — разница между отправленной и полученной суммой, взимаемая протоколом моста.", "totalFee": "Общая комиссия", "totalFeeTooltip": "Общая комиссия за перевод, включая комиссию сообщения и моста. Фактическая сумма может немного измениться.", "gasEstimate": "Газ: {{gas}}", "noRouteFound": "Маршрут не найден", "notEnoughGas": "Недостаточно газа", "pasteAddressToTransfer": "Укажите адрес получателя", "noRouteFoundForSettings": "Маршрут не найден для текущих настроек.", "tryAdjustSettings": "Попробуйте отключить Gas on Destination или измените сумму/сети.", "quoteError": "Ошибка котировки", "steps": { "sent": "Отправлено", "approving": "Одобрение токена", "approvingNote": "Шаг {{current}} из {{total}}: Подтвердите одобрение в кошельке", "bridging": "Перевод через мост", "processing": "Обработка", "processingNote": "До 2 минут", "completed": "Завершено" } };
|
|
57
57
|
const telegram = { "openWebVersion": "Открыть EVAA веб для трансфера", "restrictionMessage": "Трансфер между выбранными сетями доступен только в веб-версии EVAA" };
|
|
58
58
|
const app = { "stargateWidgetName": "Виджет Stargate Bridge", "liveWidget": "Живой виджет", "getStarted": "Начало работы" };
|
|
59
59
|
const settings = { "title": "Настройки", "gasOnDestination": "Газ на назначении", "gasOnDestinationTooltip": "Добавляет нативный токен целевой сети для оплаты комиссий за транзакции после бриджа. Увеличивает общую комиссию.", "slippageTolerance": "Толерантность к проскальзыванию", "slippageToleranceTooltip": "Если получаемая сумма окажется ниже этого допуска, транзакция будет отклонена.", "routePriority": "Приоритет маршрута", "routePriorityTooltip": "Выберите маршрут перевода. Рекомендуемый — подбирает самый выгодный вариант по общей стоимости. Быстрый — выбирает маршрут с приоритетом скорости, даже если это дороже.", "highSlippageWarning": "Высокое проскальзывание", "gasPresets": { "auto": "Авто", "none": "Нет", "medium": "Средний", "max": "Макс" }, "routePresets": { "fastest": "Быстрый", "cheapest": "Дешевый", "recommended": "Рекомендуемый" } };
|
|
@@ -2286,62 +2286,6 @@ function lookupTokenMeta(tokens, chains, chainKey, tokenAddr) {
|
|
|
2286
2286
|
priceUsd: void 0
|
|
2287
2287
|
};
|
|
2288
2288
|
}
|
|
2289
|
-
function computeFeesUsdFromArray(fees, tokens, chains) {
|
|
2290
|
-
const emptyResult = {
|
|
2291
|
-
usd: /* @__PURE__ */ new Map(),
|
|
2292
|
-
human: /* @__PURE__ */ new Map(),
|
|
2293
|
-
original: void 0
|
|
2294
|
-
};
|
|
2295
|
-
if (!fees?.length) return emptyResult;
|
|
2296
|
-
let totalUsd = 0;
|
|
2297
|
-
const byTypeUsd = /* @__PURE__ */ new Map();
|
|
2298
|
-
const byTypeHuman = /* @__PURE__ */ new Map();
|
|
2299
|
-
for (const f4 of fees) {
|
|
2300
|
-
let usd = Number(f4.usd ?? 0);
|
|
2301
|
-
let human = 0;
|
|
2302
|
-
const amount = String(f4.amount ?? "0");
|
|
2303
|
-
if (!usd) {
|
|
2304
|
-
const { decimals, priceUsd } = lookupTokenMeta(
|
|
2305
|
-
tokens,
|
|
2306
|
-
chains,
|
|
2307
|
-
f4.chainKey,
|
|
2308
|
-
f4.token
|
|
2309
|
-
);
|
|
2310
|
-
human = fromLD(amount, decimals);
|
|
2311
|
-
usd = (priceUsd ?? 0) * human;
|
|
2312
|
-
}
|
|
2313
|
-
totalUsd += usd;
|
|
2314
|
-
const type = (f4.type ?? "other").toLowerCase();
|
|
2315
|
-
byTypeUsd.set(type, (byTypeUsd.get(type) ?? 0) + usd);
|
|
2316
|
-
const existing = byTypeHuman.get(type);
|
|
2317
|
-
if (existing) {
|
|
2318
|
-
existing.amount += human;
|
|
2319
|
-
} else {
|
|
2320
|
-
byTypeHuman.set(type, {
|
|
2321
|
-
amount: human,
|
|
2322
|
-
token: f4.token,
|
|
2323
|
-
chainKey: f4.chainKey
|
|
2324
|
-
});
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
byTypeUsd.set("total", totalUsd);
|
|
2328
|
-
return {
|
|
2329
|
-
usd: byTypeUsd,
|
|
2330
|
-
human: byTypeHuman,
|
|
2331
|
-
original: fees
|
|
2332
|
-
};
|
|
2333
|
-
}
|
|
2334
|
-
function sumFeeByTokenLD(fees, dstTokenAddr, dstChainKey) {
|
|
2335
|
-
if (!fees?.length || !dstTokenAddr || !dstChainKey) return "0";
|
|
2336
|
-
let acc = 0n;
|
|
2337
|
-
for (const f4 of fees) {
|
|
2338
|
-
if (f4.chainKey !== dstChainKey) continue;
|
|
2339
|
-
const same = dstChainKey === "ton" ? tonNorm(f4.token) === tonNorm(dstTokenAddr) : lower(f4.token) === lower(dstTokenAddr);
|
|
2340
|
-
if (!same) continue;
|
|
2341
|
-
acc += BigInt(f4.amount ?? "0");
|
|
2342
|
-
}
|
|
2343
|
-
return acc.toString();
|
|
2344
|
-
}
|
|
2345
2289
|
function getQuoteAmounts(quote, srcToken, dstToken) {
|
|
2346
2290
|
if (!quote || !srcToken || !dstToken) {
|
|
2347
2291
|
return {
|
|
@@ -2362,48 +2306,6 @@ function getQuoteAmounts(quote, srcToken, dstToken) {
|
|
|
2362
2306
|
minReceivedHuman
|
|
2363
2307
|
};
|
|
2364
2308
|
}
|
|
2365
|
-
function getQuoteFees(quote, tokens, chains, srcToken, dstToken) {
|
|
2366
|
-
if (!quote || !tokens || !chains) {
|
|
2367
|
-
return {
|
|
2368
|
-
fees: { usd: /* @__PURE__ */ new Map(), original: /* @__PURE__ */ new Map(), formatted: /* @__PURE__ */ new Map() },
|
|
2369
|
-
inSrcToken: void 0,
|
|
2370
|
-
inDstToken: void 0
|
|
2371
|
-
};
|
|
2372
|
-
}
|
|
2373
|
-
const feeData = computeFeesUsdFromArray(quote.fees, tokens, chains);
|
|
2374
|
-
let inSrcToken = void 0;
|
|
2375
|
-
let inDstToken = void 0;
|
|
2376
|
-
if (srcToken && quote.srcChainKey) {
|
|
2377
|
-
const feeInSrcLD = sumFeeByTokenLD(
|
|
2378
|
-
quote.fees,
|
|
2379
|
-
srcToken.address,
|
|
2380
|
-
quote.srcChainKey
|
|
2381
|
-
);
|
|
2382
|
-
const feeInSrcHuman = fromLD(feeInSrcLD, srcToken.decimals);
|
|
2383
|
-
if (feeInSrcHuman > 0) {
|
|
2384
|
-
inSrcToken = Number(truncateToDecimals(feeInSrcHuman, 8));
|
|
2385
|
-
} else if ((feeData.usd.get("total") || 0) > 0 && srcToken.price?.usd) {
|
|
2386
|
-
const feeInSrcApprox = (feeData.usd.get("total") || 0) / srcToken.price.usd;
|
|
2387
|
-
inSrcToken = Number(truncateToDecimals(feeInSrcApprox, 8));
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
if (dstToken && quote.dstChainKey) {
|
|
2391
|
-
const feeInDstLD = sumFeeByTokenLD(
|
|
2392
|
-
quote.fees,
|
|
2393
|
-
dstToken.address,
|
|
2394
|
-
quote.dstChainKey
|
|
2395
|
-
);
|
|
2396
|
-
const feeInDstHuman = fromLD(feeInDstLD, dstToken.decimals);
|
|
2397
|
-
if (feeInDstHuman > 0) {
|
|
2398
|
-
inDstToken = Number(truncateToDecimals(feeInDstHuman, 8));
|
|
2399
|
-
}
|
|
2400
|
-
}
|
|
2401
|
-
return {
|
|
2402
|
-
fees: feeData,
|
|
2403
|
-
inSrcToken,
|
|
2404
|
-
inDstToken
|
|
2405
|
-
};
|
|
2406
|
-
}
|
|
2407
2309
|
function calculateMinReceived(quote, slippageBps, dstToken) {
|
|
2408
2310
|
if (!quote || !dstToken) return 0;
|
|
2409
2311
|
const dstAmountLD = BigInt(quote.dstAmount);
|
|
@@ -2412,7 +2314,7 @@ function calculateMinReceived(quote, slippageBps, dstToken) {
|
|
|
2412
2314
|
}
|
|
2413
2315
|
function getQuoteDetails(quote, srcToken, dstToken, tokens, chains, slippageBps) {
|
|
2414
2316
|
const amounts = getQuoteAmounts(quote, srcToken, dstToken);
|
|
2415
|
-
const fees =
|
|
2317
|
+
const fees = computeFeeBreakdownUsd(quote, srcToken, tokens, chains);
|
|
2416
2318
|
const minimumReceived = calculateMinReceived(quote, slippageBps, dstToken);
|
|
2417
2319
|
return {
|
|
2418
2320
|
inputAmount: amounts.inputHuman,
|
|
@@ -2432,6 +2334,28 @@ function getRouteDisplayName(route) {
|
|
|
2432
2334
|
if (routeLower.includes("v2")) return "Stargate V2";
|
|
2433
2335
|
return route.split(/[/\-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
2434
2336
|
}
|
|
2337
|
+
function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
|
|
2338
|
+
const empty = { messageFeeUsd: 0, bridgeFeeUsd: 0, totalFeeUsd: 0 };
|
|
2339
|
+
if (!quote || !srcToken) return empty;
|
|
2340
|
+
let messageFeeUsd = 0;
|
|
2341
|
+
const messageFees = quote.fees.filter((f4) => f4.type === "message");
|
|
2342
|
+
for (const f4 of messageFees) {
|
|
2343
|
+
const { decimals, priceUsd } = lookupTokenMeta(tokens, chains, f4.chainKey, f4.token);
|
|
2344
|
+
const human = fromLD(f4.amount || "0", decimals);
|
|
2345
|
+
messageFeeUsd += human * (priceUsd ?? 0);
|
|
2346
|
+
}
|
|
2347
|
+
let bridgeFeeUsd = 0;
|
|
2348
|
+
if (srcToken.price?.usd) {
|
|
2349
|
+
const srcHuman = fromLD(quote.srcAmount, srcToken.decimals);
|
|
2350
|
+
const dstHuman = fromLD(quote.dstAmount, srcToken.decimals);
|
|
2351
|
+
const diff = srcHuman - dstHuman;
|
|
2352
|
+
if (diff > 0) {
|
|
2353
|
+
bridgeFeeUsd = diff * srcToken.price.usd;
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
const totalFeeUsd = messageFeeUsd + bridgeFeeUsd;
|
|
2357
|
+
return { messageFeeUsd, bridgeFeeUsd, totalFeeUsd };
|
|
2358
|
+
}
|
|
2435
2359
|
async function addNetworkFeesToQuote(quote, chainRegistry, chains) {
|
|
2436
2360
|
if (!quote || !chains) {
|
|
2437
2361
|
return quote;
|
|
@@ -2937,79 +2861,18 @@ const TokenSymbol = ({
|
|
|
2937
2861
|
const src2 = `${BASE_URL}/${normalizedSymbol}.svg`;
|
|
2938
2862
|
return /* @__PURE__ */ jsxRuntime.jsx("img", { src: src2, alt: alt ?? symbol, className });
|
|
2939
2863
|
};
|
|
2940
|
-
function
|
|
2941
|
-
const { fromChain } = useChainsStore();
|
|
2942
|
-
const { selectedAssetSymbol } = useTokensStore();
|
|
2943
|
-
const { srcAddress } = useAddresses();
|
|
2944
|
-
const { balances, isLoading: balancesLoading } = useBalances(
|
|
2945
|
-
fromChain?.chainKey,
|
|
2946
|
-
srcAddress
|
|
2947
|
-
);
|
|
2864
|
+
function useFeeBreakdown() {
|
|
2948
2865
|
const { quote } = useBridgeQuoteStore();
|
|
2949
|
-
const
|
|
2950
|
-
const
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
return {
|
|
2960
|
-
nativeSym: "",
|
|
2961
|
-
nativeBalance: 0,
|
|
2962
|
-
requiredNative: 0,
|
|
2963
|
-
balancesKnown,
|
|
2964
|
-
isNativeSelected: false,
|
|
2965
|
-
hasEnoughGas: true
|
|
2966
|
-
};
|
|
2967
|
-
}
|
|
2968
|
-
const nativeSym = nativeCurrencySymbol.toUpperCase();
|
|
2969
|
-
const nativeBalance = nativeBalanceValue;
|
|
2970
|
-
const isNativeSelected = nativeSym === (selectedAssetSymbol || "").toUpperCase();
|
|
2971
|
-
let requiredNative = 0;
|
|
2972
|
-
let quoteFeesAvailable = false;
|
|
2973
|
-
if (quoteFees && quoteSrcChainKey === chainKey) {
|
|
2974
|
-
const fees = quoteFees;
|
|
2975
|
-
const feesInNative = fees.filter(
|
|
2976
|
-
(f4) => f4.chainKey === chainKey && f4.token === nativeCurrencyAddress
|
|
2977
|
-
).reduce(
|
|
2978
|
-
(sum, f4) => sum + BigInt(f4.amount || "0"),
|
|
2979
|
-
0n
|
|
2980
|
-
);
|
|
2981
|
-
const decimals = nativeCurrencyDecimals || 18;
|
|
2982
|
-
requiredNative = Number(feesInNative) / Math.pow(10, decimals);
|
|
2983
|
-
quoteFeesAvailable = true;
|
|
2984
|
-
}
|
|
2985
|
-
let hasEnoughGas = true;
|
|
2986
|
-
if (isNativeSelected) {
|
|
2987
|
-
hasEnoughGas = nativeBalance - (amountNum ?? 0) >= requiredNative;
|
|
2988
|
-
} else {
|
|
2989
|
-
hasEnoughGas = nativeBalance >= requiredNative;
|
|
2990
|
-
}
|
|
2991
|
-
const shouldCheckGas = balancesKnown && quoteFeesAvailable;
|
|
2992
|
-
return {
|
|
2993
|
-
nativeSym,
|
|
2994
|
-
nativeBalance,
|
|
2995
|
-
requiredNative,
|
|
2996
|
-
balancesKnown,
|
|
2997
|
-
isNativeSelected,
|
|
2998
|
-
hasEnoughGas: shouldCheckGas ? hasEnoughGas : true
|
|
2999
|
-
};
|
|
3000
|
-
}, [
|
|
3001
|
-
chainKey,
|
|
3002
|
-
nativeCurrencySymbol,
|
|
3003
|
-
nativeCurrencyAddress,
|
|
3004
|
-
nativeCurrencyDecimals,
|
|
3005
|
-
selectedAssetSymbol,
|
|
3006
|
-
quoteFees,
|
|
3007
|
-
quoteSrcChainKey,
|
|
3008
|
-
amountNum,
|
|
3009
|
-
balancesKnown,
|
|
3010
|
-
nativeBalanceValue
|
|
3011
|
-
]);
|
|
3012
|
-
return result;
|
|
2866
|
+
const { tokens, selectedAssetSymbol, assetMatrix } = useTokensStore();
|
|
2867
|
+
const { fromChain, chains } = useChainsStore();
|
|
2868
|
+
return react.useMemo(() => {
|
|
2869
|
+
const srcToken = resolveTokenOnChainFromMatrix$1(
|
|
2870
|
+
assetMatrix,
|
|
2871
|
+
selectedAssetSymbol,
|
|
2872
|
+
fromChain?.chainKey
|
|
2873
|
+
);
|
|
2874
|
+
return computeFeeBreakdownUsd(quote, srcToken, tokens, chains);
|
|
2875
|
+
}, [quote, tokens, chains, selectedAssetSymbol, assetMatrix, fromChain]);
|
|
3013
2876
|
}
|
|
3014
2877
|
function useBridgeExternalData(options) {
|
|
3015
2878
|
const selectedAssetSymbol = useTokensStore(
|
|
@@ -3149,7 +3012,7 @@ const Details = () => {
|
|
|
3149
3012
|
const { selectedAssetSymbol } = useTokensStore();
|
|
3150
3013
|
const { quote, status } = useBridgeQuoteStore();
|
|
3151
3014
|
const { slippageBps } = useSettingsStore();
|
|
3152
|
-
const
|
|
3015
|
+
const fees = useFeeBreakdown();
|
|
3153
3016
|
const bridgeData = useBridgeExternalData();
|
|
3154
3017
|
const symbol = (selectedAssetSymbol ?? bridgeData.dstToken?.symbol ?? "—").toUpperCase();
|
|
3155
3018
|
const isLoading = status === "loading";
|
|
@@ -3158,7 +3021,7 @@ const Details = () => {
|
|
|
3158
3021
|
1,
|
|
3159
3022
|
Math.round(bridgeData.quoteDetails?.etaSeconds / 60)
|
|
3160
3023
|
)}m` : "—";
|
|
3161
|
-
const totalFeeDisplay = !quote ? "—" :
|
|
3024
|
+
const totalFeeDisplay = !quote ? "—" : formatUsd(fees.totalFeeUsd);
|
|
3162
3025
|
const currentSlippageText = !quote ? "—" : formatPercentage(slippageBps);
|
|
3163
3026
|
const routeText = getRouteDisplayName(quote?.route);
|
|
3164
3027
|
return /* @__PURE__ */ jsxRuntime.jsx(accordion.Accordion, { type: "single", collapsible: true, className: "w-full border-none", children: /* @__PURE__ */ jsxRuntime.jsxs(accordion.AccordionItem, { value: "item-1", className: "bg-muted rounded-sm", children: [
|
|
@@ -3204,17 +3067,7 @@ const Details = () => {
|
|
|
3204
3067
|
{
|
|
3205
3068
|
label: t2("transaction.totalFee"),
|
|
3206
3069
|
tooltip: t2("transaction.totalFeeTooltip"),
|
|
3207
|
-
value: /* @__PURE__ */ jsxRuntime.
|
|
3208
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: totalFeeDisplay }),
|
|
3209
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3210
|
-
TokenSymbol,
|
|
3211
|
-
{
|
|
3212
|
-
symbol: gas.nativeSym,
|
|
3213
|
-
className: "w-4 h-4",
|
|
3214
|
-
alt: "token"
|
|
3215
|
-
}
|
|
3216
|
-
)
|
|
3217
|
-
] }),
|
|
3070
|
+
value: /* @__PURE__ */ jsxRuntime.jsx("strong", { children: totalFeeDisplay }),
|
|
3218
3071
|
isLoading
|
|
3219
3072
|
}
|
|
3220
3073
|
)
|
|
@@ -3608,6 +3461,93 @@ async function reportBridgeTransaction(params, config) {
|
|
|
3608
3461
|
};
|
|
3609
3462
|
}
|
|
3610
3463
|
}
|
|
3464
|
+
function useGasEstimate(amountNum) {
|
|
3465
|
+
const { fromChain } = useChainsStore();
|
|
3466
|
+
const { selectedAssetSymbol } = useTokensStore();
|
|
3467
|
+
const { srcAddress } = useAddresses();
|
|
3468
|
+
const { balances, isLoading: balancesLoading } = useBalances(
|
|
3469
|
+
fromChain?.chainKey,
|
|
3470
|
+
srcAddress
|
|
3471
|
+
);
|
|
3472
|
+
const { quote } = useBridgeQuoteStore();
|
|
3473
|
+
const balancesKnown = !balancesLoading;
|
|
3474
|
+
const chainKey = fromChain?.chainKey;
|
|
3475
|
+
const nativeCurrencySymbol = fromChain?.nativeCurrency?.symbol;
|
|
3476
|
+
const nativeCurrencyAddress = fromChain?.nativeCurrency?.address;
|
|
3477
|
+
const nativeCurrencyDecimals = fromChain?.nativeCurrency?.decimals;
|
|
3478
|
+
const quoteFees = quote?.fees;
|
|
3479
|
+
const quoteSrcChainKey = quote?.srcChainKey;
|
|
3480
|
+
const nativeBalanceValue = nativeCurrencySymbol ? Number(balances[nativeCurrencySymbol.toUpperCase()]?.balance ?? 0) : 0;
|
|
3481
|
+
const result = react.useMemo(() => {
|
|
3482
|
+
if (!chainKey || !nativeCurrencySymbol) {
|
|
3483
|
+
return {
|
|
3484
|
+
nativeSym: "",
|
|
3485
|
+
nativeBalance: 0,
|
|
3486
|
+
requiredNative: 0,
|
|
3487
|
+
gasOnlyNative: 0,
|
|
3488
|
+
gasDisplayText: "",
|
|
3489
|
+
balancesKnown,
|
|
3490
|
+
isNativeSelected: false,
|
|
3491
|
+
hasEnoughGas: true
|
|
3492
|
+
};
|
|
3493
|
+
}
|
|
3494
|
+
const nativeSym = nativeCurrencySymbol.toUpperCase();
|
|
3495
|
+
const nativeBalance = nativeBalanceValue;
|
|
3496
|
+
const isNativeSelected = nativeSym === (selectedAssetSymbol || "").toUpperCase();
|
|
3497
|
+
let requiredNative = 0;
|
|
3498
|
+
let quoteFeesAvailable = false;
|
|
3499
|
+
let gasOnlyNative = 0;
|
|
3500
|
+
if (quoteFees && quoteSrcChainKey === chainKey) {
|
|
3501
|
+
const fees = quoteFees;
|
|
3502
|
+
const feesInNative = fees.filter(
|
|
3503
|
+
(f4) => f4.chainKey === chainKey && f4.token === nativeCurrencyAddress
|
|
3504
|
+
).reduce(
|
|
3505
|
+
(sum, f4) => sum + BigInt(f4.amount || "0"),
|
|
3506
|
+
0n
|
|
3507
|
+
);
|
|
3508
|
+
const decimals = nativeCurrencyDecimals || 18;
|
|
3509
|
+
requiredNative = Number(feesInNative) / Math.pow(10, decimals);
|
|
3510
|
+
const networkFeesInNative = fees.filter(
|
|
3511
|
+
(f4) => f4.chainKey === chainKey && f4.token === nativeCurrencyAddress && f4.type === "network"
|
|
3512
|
+
).reduce(
|
|
3513
|
+
(sum, f4) => sum + BigInt(f4.amount || "0"),
|
|
3514
|
+
0n
|
|
3515
|
+
);
|
|
3516
|
+
gasOnlyNative = Number(networkFeesInNative) / Math.pow(10, decimals);
|
|
3517
|
+
quoteFeesAvailable = true;
|
|
3518
|
+
}
|
|
3519
|
+
let hasEnoughGas = true;
|
|
3520
|
+
if (isNativeSelected) {
|
|
3521
|
+
hasEnoughGas = nativeBalance - (amountNum ?? 0) >= requiredNative;
|
|
3522
|
+
} else {
|
|
3523
|
+
hasEnoughGas = nativeBalance >= requiredNative;
|
|
3524
|
+
}
|
|
3525
|
+
const shouldCheckGas = balancesKnown && quoteFeesAvailable;
|
|
3526
|
+
const gasDisplayText = gasOnlyNative > 0 ? `~${gasOnlyNative.toFixed(6).replace(/0+$/, "").replace(/\.$/, "")} ${nativeSym}` : "";
|
|
3527
|
+
return {
|
|
3528
|
+
nativeSym,
|
|
3529
|
+
nativeBalance,
|
|
3530
|
+
requiredNative,
|
|
3531
|
+
gasOnlyNative,
|
|
3532
|
+
gasDisplayText,
|
|
3533
|
+
balancesKnown,
|
|
3534
|
+
isNativeSelected,
|
|
3535
|
+
hasEnoughGas: shouldCheckGas ? hasEnoughGas : true
|
|
3536
|
+
};
|
|
3537
|
+
}, [
|
|
3538
|
+
chainKey,
|
|
3539
|
+
nativeCurrencySymbol,
|
|
3540
|
+
nativeCurrencyAddress,
|
|
3541
|
+
nativeCurrencyDecimals,
|
|
3542
|
+
selectedAssetSymbol,
|
|
3543
|
+
quoteFees,
|
|
3544
|
+
quoteSrcChainKey,
|
|
3545
|
+
amountNum,
|
|
3546
|
+
balancesKnown,
|
|
3547
|
+
nativeBalanceValue
|
|
3548
|
+
]);
|
|
3549
|
+
return result;
|
|
3550
|
+
}
|
|
3611
3551
|
function useBridgeTransaction() {
|
|
3612
3552
|
const { quote } = useBridgeQuoteStore();
|
|
3613
3553
|
const { chainRegistry } = useChainStrategies();
|
|
@@ -4138,7 +4078,8 @@ const MainButton = ({
|
|
|
4138
4078
|
className: "w-full",
|
|
4139
4079
|
children: label
|
|
4140
4080
|
}
|
|
4141
|
-
)
|
|
4081
|
+
),
|
|
4082
|
+
gas.gasDisplayText && quote && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground text-center", children: t2("transaction.gasEstimate", { gas: gas.gasDisplayText }) })
|
|
4142
4083
|
] });
|
|
4143
4084
|
};
|
|
4144
4085
|
const WalletModalButton = (props) => {
|
|
@@ -25783,7 +25724,7 @@ class WalletConnectModal {
|
|
|
25783
25724
|
}
|
|
25784
25725
|
async initUi() {
|
|
25785
25726
|
if (typeof window !== "undefined") {
|
|
25786
|
-
await Promise.resolve().then(() => require("./index-
|
|
25727
|
+
await Promise.resolve().then(() => require("./index-CBUX3Jzi.cjs"));
|
|
25787
25728
|
const modal = document.createElement("wcm-modal");
|
|
25788
25729
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25789
25730
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -26575,7 +26516,7 @@ exports.addNetworkFeesToQuote = addNetworkFeesToQuote;
|
|
|
26575
26516
|
exports.addrForApi = addrForApi;
|
|
26576
26517
|
exports.buildAssetMatrix = buildAssetMatrix;
|
|
26577
26518
|
exports.calculateMinReceived = calculateMinReceived;
|
|
26578
|
-
exports.
|
|
26519
|
+
exports.computeFeeBreakdownUsd = computeFeeBreakdownUsd;
|
|
26579
26520
|
exports.findNativeMeta = findNativeMeta;
|
|
26580
26521
|
exports.formatAddress = formatAddress;
|
|
26581
26522
|
exports.formatBalance = formatBalance;
|
|
@@ -26591,7 +26532,6 @@ exports.getDestTokens = getDestTokens;
|
|
|
26591
26532
|
exports.getEvmBalances = getEvmBalances;
|
|
26592
26533
|
exports.getQuoteAmounts = getQuoteAmounts;
|
|
26593
26534
|
exports.getQuoteDetails = getQuoteDetails;
|
|
26594
|
-
exports.getQuoteFees = getQuoteFees;
|
|
26595
26535
|
exports.getQuotesByPriority = getQuotesByPriority;
|
|
26596
26536
|
exports.getRouteDisplayName = getRouteDisplayName;
|
|
26597
26537
|
exports.getTokens = getTokens;
|
|
@@ -26607,7 +26547,6 @@ exports.pollUntilDelivered = pollUntilDelivered;
|
|
|
26607
26547
|
exports.reportBridgeTransaction = reportBridgeTransaction;
|
|
26608
26548
|
exports.resolveTokenOnChain = resolveTokenOnChain;
|
|
26609
26549
|
exports.resolveTokenOnChainFromMatrix = resolveTokenOnChainFromMatrix$1;
|
|
26610
|
-
exports.sumFeeByTokenLD = sumFeeByTokenLD;
|
|
26611
26550
|
exports.toLD = toLD;
|
|
26612
26551
|
exports.tonNorm = tonNorm;
|
|
26613
26552
|
exports.truncateToDecimals = truncateToDecimals;
|
|
@@ -26620,4 +26559,4 @@ exports.useSettingsStore = useSettingsStore;
|
|
|
26620
26559
|
exports.useSwapModel = useSwapModel;
|
|
26621
26560
|
exports.useTokensStore = useTokensStore;
|
|
26622
26561
|
exports.useTransactionStore = useTransactionStore;
|
|
26623
|
-
//# sourceMappingURL=index-
|
|
26562
|
+
//# sourceMappingURL=index-kdPPX_i5.cjs.map
|