@0xsquid/react-hooks 6.7.0-pre-post-hooks-beta.0 → 6.7.0-rollup-beta.1

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.
Files changed (258) hide show
  1. package/dist/core/queries/queries-keys.d.ts +2 -2
  2. package/dist/core/types/config.d.ts +0 -2
  3. package/dist/core/types/event.d.ts +0 -5
  4. package/dist/hooks/index.d.ts +5 -5
  5. package/dist/hooks/transaction/useGetRoute.d.ts +0 -3
  6. package/dist/index.esm.js +16892 -0
  7. package/dist/index.esm.js.map +1 -0
  8. package/dist/index.js +17096 -6
  9. package/dist/index.js.map +1 -1
  10. package/dist/{services/external/secretService.js → secretService-Cnn1_HQT.js} +37 -8
  11. package/dist/secretService-Cnn1_HQT.js.map +1 -0
  12. package/dist/secretService-DW4QetNp.js +162 -0
  13. package/dist/secretService-DW4QetNp.js.map +1 -0
  14. package/dist/services/internal/eventService.d.ts +0 -5
  15. package/package.json +18 -4
  16. package/dist/core/abis/ics20.json +0 -128
  17. package/dist/core/connectors/bitcoin/errors/index.js +0 -22
  18. package/dist/core/connectors/bitcoin/errors/index.js.map +0 -1
  19. package/dist/core/connectors/bitcoin/helpers.js +0 -86
  20. package/dist/core/connectors/bitcoin/helpers.js.map +0 -1
  21. package/dist/core/connectors/bitcoin/index.js +0 -2
  22. package/dist/core/connectors/bitcoin/index.js.map +0 -1
  23. package/dist/core/connectors/bitcoin/wallets/index.js +0 -4
  24. package/dist/core/connectors/bitcoin/wallets/index.js.map +0 -1
  25. package/dist/core/connectors/bitcoin/wallets/keplr.js +0 -28
  26. package/dist/core/connectors/bitcoin/wallets/keplr.js.map +0 -1
  27. package/dist/core/connectors/bitcoin/wallets/phantom.js +0 -56
  28. package/dist/core/connectors/bitcoin/wallets/phantom.js.map +0 -1
  29. package/dist/core/connectors/bitcoin/wallets/unisat.js +0 -28
  30. package/dist/core/connectors/bitcoin/wallets/unisat.js.map +0 -1
  31. package/dist/core/constants.js +0 -144
  32. package/dist/core/constants.js.map +0 -1
  33. package/dist/core/externalLinks.js +0 -21
  34. package/dist/core/externalLinks.js.map +0 -1
  35. package/dist/core/index.js +0 -4
  36. package/dist/core/index.js.map +0 -1
  37. package/dist/core/multicall3.js +0 -442
  38. package/dist/core/multicall3.js.map +0 -1
  39. package/dist/core/providers/CosmosProvider.js +0 -13
  40. package/dist/core/providers/CosmosProvider.js.map +0 -1
  41. package/dist/core/providers/SolanaProvider.js +0 -15
  42. package/dist/core/providers/SolanaProvider.js.map +0 -1
  43. package/dist/core/providers/SuiProvider.js +0 -15
  44. package/dist/core/providers/SuiProvider.js.map +0 -1
  45. package/dist/core/queries/queries-keys.js +0 -206
  46. package/dist/core/queries/queries-keys.js.map +0 -1
  47. package/dist/core/queries/react-query-config.js +0 -11
  48. package/dist/core/queries/react-query-config.js.map +0 -1
  49. package/dist/core/types/config.js +0 -2
  50. package/dist/core/types/config.js.map +0 -1
  51. package/dist/core/types/dex.js +0 -33
  52. package/dist/core/types/dex.js.map +0 -1
  53. package/dist/core/types/error.js +0 -12
  54. package/dist/core/types/error.js.map +0 -1
  55. package/dist/core/types/event.js +0 -2
  56. package/dist/core/types/event.js.map +0 -1
  57. package/dist/core/types/index.js +0 -2
  58. package/dist/core/types/index.js.map +0 -1
  59. package/dist/core/types/rpc.js +0 -2
  60. package/dist/core/types/rpc.js.map +0 -1
  61. package/dist/core/types/sui.js +0 -2
  62. package/dist/core/types/sui.js.map +0 -1
  63. package/dist/core/types/swap.js +0 -2
  64. package/dist/core/types/swap.js.map +0 -1
  65. package/dist/core/types/tokens.js +0 -2
  66. package/dist/core/types/tokens.js.map +0 -1
  67. package/dist/core/types/transaction.js +0 -41
  68. package/dist/core/types/transaction.js.map +0 -1
  69. package/dist/core/types/wallet.js +0 -26
  70. package/dist/core/types/wallet.js.map +0 -1
  71. package/dist/core/wagmiConfig.js +0 -60
  72. package/dist/core/wagmiConfig.js.map +0 -1
  73. package/dist/core/wallets.js +0 -549
  74. package/dist/core/wallets.js.map +0 -1
  75. package/dist/hooks/analytics/useTrackSearchEmpty.d.ts +0 -12
  76. package/dist/hooks/analytics/useTrackSearchEmpty.js +0 -22
  77. package/dist/hooks/analytics/useTrackSearchEmpty.js.map +0 -1
  78. package/dist/hooks/chains/useSquidChains.js +0 -107
  79. package/dist/hooks/chains/useSquidChains.js.map +0 -1
  80. package/dist/hooks/client/useClient.js +0 -6
  81. package/dist/hooks/client/useClient.js.map +0 -1
  82. package/dist/hooks/cosmos/useCosmos.js +0 -172
  83. package/dist/hooks/cosmos/useCosmos.js.map +0 -1
  84. package/dist/hooks/cosmos/useCosmosForChain.js +0 -33
  85. package/dist/hooks/cosmos/useCosmosForChain.js.map +0 -1
  86. package/dist/hooks/index.js +0 -45
  87. package/dist/hooks/index.js.map +0 -1
  88. package/dist/hooks/navigation/useKeyboardNavigation.js +0 -67
  89. package/dist/hooks/navigation/useKeyboardNavigation.js.map +0 -1
  90. package/dist/hooks/query/useSquidQueryClient.js +0 -23
  91. package/dist/hooks/query/useSquidQueryClient.js.map +0 -1
  92. package/dist/hooks/solana/useSolana.js +0 -104
  93. package/dist/hooks/solana/useSolana.js.map +0 -1
  94. package/dist/hooks/squid/useSquid.js +0 -55
  95. package/dist/hooks/squid/useSquid.js.map +0 -1
  96. package/dist/hooks/store/useAddressBookStore.js +0 -26
  97. package/dist/hooks/store/useAddressBookStore.js.map +0 -1
  98. package/dist/hooks/store/useAssetsColorsStore.js +0 -7
  99. package/dist/hooks/store/useAssetsColorsStore.js.map +0 -1
  100. package/dist/hooks/store/useDepositAddressStore.js +0 -12
  101. package/dist/hooks/store/useDepositAddressStore.js.map +0 -1
  102. package/dist/hooks/store/useFavoriteTokensStore.js +0 -28
  103. package/dist/hooks/store/useFavoriteTokensStore.js.map +0 -1
  104. package/dist/hooks/store/useHistoryStore.js +0 -41
  105. package/dist/hooks/store/useHistoryStore.js.map +0 -1
  106. package/dist/hooks/store/useSquidStore.js +0 -56
  107. package/dist/hooks/store/useSquidStore.js.map +0 -1
  108. package/dist/hooks/store/useWalletStore.js +0 -42
  109. package/dist/hooks/store/useWalletStore.js.map +0 -1
  110. package/dist/hooks/sui/useSui.js +0 -28
  111. package/dist/hooks/sui/useSui.js.map +0 -1
  112. package/dist/hooks/sui/useSuiClient.js +0 -16
  113. package/dist/hooks/sui/useSuiClient.js.map +0 -1
  114. package/dist/hooks/sui/useSuiWallets.js +0 -42
  115. package/dist/hooks/sui/useSuiWallets.js.map +0 -1
  116. package/dist/hooks/swap/useDepositAddress.js +0 -63
  117. package/dist/hooks/swap/useDepositAddress.js.map +0 -1
  118. package/dist/hooks/swap/useSwap.js +0 -209
  119. package/dist/hooks/swap/useSwap.js.map +0 -1
  120. package/dist/hooks/tokens/useAllConnectedWalletBalances.js +0 -103
  121. package/dist/hooks/tokens/useAllConnectedWalletBalances.js.map +0 -1
  122. package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.js +0 -119
  123. package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.js.map +0 -1
  124. package/dist/hooks/tokens/useBalance.js +0 -136
  125. package/dist/hooks/tokens/useBalance.js.map +0 -1
  126. package/dist/hooks/tokens/useMultiChainBalance.js +0 -68
  127. package/dist/hooks/tokens/useMultiChainBalance.js.map +0 -1
  128. package/dist/hooks/tokens/useMultipleTokenPrices.js +0 -46
  129. package/dist/hooks/tokens/useMultipleTokenPrices.js.map +0 -1
  130. package/dist/hooks/tokens/useNativeBalance.js +0 -217
  131. package/dist/hooks/tokens/useNativeBalance.js.map +0 -1
  132. package/dist/hooks/tokens/useNativeTokenForChain.js +0 -28
  133. package/dist/hooks/tokens/useNativeTokenForChain.js.map +0 -1
  134. package/dist/hooks/tokens/useSingleTokenPrice.js +0 -38
  135. package/dist/hooks/tokens/useSingleTokenPrice.js.map +0 -1
  136. package/dist/hooks/tokens/useSquidTokens.js +0 -80
  137. package/dist/hooks/tokens/useSquidTokens.js.map +0 -1
  138. package/dist/hooks/tokens/useTokenHistoricalData.js +0 -23
  139. package/dist/hooks/tokens/useTokenHistoricalData.js.map +0 -1
  140. package/dist/hooks/transaction/useAllTransactionsStatus.js +0 -68
  141. package/dist/hooks/transaction/useAllTransactionsStatus.js.map +0 -1
  142. package/dist/hooks/transaction/useApproval.js +0 -223
  143. package/dist/hooks/transaction/useApproval.js.map +0 -1
  144. package/dist/hooks/transaction/useErc20Allowance.js +0 -43
  145. package/dist/hooks/transaction/useErc20Allowance.js.map +0 -1
  146. package/dist/hooks/transaction/useEstimate.js +0 -118
  147. package/dist/hooks/transaction/useEstimate.js.map +0 -1
  148. package/dist/hooks/transaction/useEstimatePriceImpact.js +0 -31
  149. package/dist/hooks/transaction/useEstimatePriceImpact.js.map +0 -1
  150. package/dist/hooks/transaction/useExecuteTransaction.js +0 -605
  151. package/dist/hooks/transaction/useExecuteTransaction.js.map +0 -1
  152. package/dist/hooks/transaction/useGetRoute.js +0 -230
  153. package/dist/hooks/transaction/useGetRoute.js.map +0 -1
  154. package/dist/hooks/transaction/useIcs20Allowance.js +0 -40
  155. package/dist/hooks/transaction/useIcs20Allowance.js.map +0 -1
  156. package/dist/hooks/transaction/useRouteWarnings.js +0 -19
  157. package/dist/hooks/transaction/useRouteWarnings.js.map +0 -1
  158. package/dist/hooks/transaction/useSingleTransaction.js +0 -91
  159. package/dist/hooks/transaction/useSingleTransaction.js.map +0 -1
  160. package/dist/hooks/user/useAvatar.js +0 -34
  161. package/dist/hooks/user/useAvatar.js.map +0 -1
  162. package/dist/hooks/user/useHistory.js +0 -106
  163. package/dist/hooks/user/useHistory.js.map +0 -1
  164. package/dist/hooks/user/useUserParams.js +0 -33
  165. package/dist/hooks/user/useUserParams.js.map +0 -1
  166. package/dist/hooks/wallet/useAddToken.js +0 -49
  167. package/dist/hooks/wallet/useAddToken.js.map +0 -1
  168. package/dist/hooks/wallet/useAutoConnect.js +0 -74
  169. package/dist/hooks/wallet/useAutoConnect.js.map +0 -1
  170. package/dist/hooks/wallet/useEns.js +0 -69
  171. package/dist/hooks/wallet/useEns.js.map +0 -1
  172. package/dist/hooks/wallet/useGnosisContext.js +0 -78
  173. package/dist/hooks/wallet/useGnosisContext.js.map +0 -1
  174. package/dist/hooks/wallet/useIntegratorContext.js +0 -39
  175. package/dist/hooks/wallet/useIntegratorContext.js.map +0 -1
  176. package/dist/hooks/wallet/useMultiChainWallet.js +0 -175
  177. package/dist/hooks/wallet/useMultiChainWallet.js.map +0 -1
  178. package/dist/hooks/wallet/useSigner.js +0 -76
  179. package/dist/hooks/wallet/useSigner.js.map +0 -1
  180. package/dist/hooks/wallet/useWallet.js +0 -206
  181. package/dist/hooks/wallet/useWallet.js.map +0 -1
  182. package/dist/hooks/wallet/useWallets.js +0 -36
  183. package/dist/hooks/wallet/useWallets.js.map +0 -1
  184. package/dist/provider/index.js +0 -113
  185. package/dist/provider/index.js.map +0 -1
  186. package/dist/services/external/ens.js +0 -66
  187. package/dist/services/external/ens.js.map +0 -1
  188. package/dist/services/external/rpcService.js +0 -421
  189. package/dist/services/external/rpcService.js.map +0 -1
  190. package/dist/services/external/secretService.js.map +0 -1
  191. package/dist/services/external/suiRpcClient.js +0 -80
  192. package/dist/services/external/suiRpcClient.js.map +0 -1
  193. package/dist/services/external/tokenDataService.js +0 -108
  194. package/dist/services/external/tokenDataService.js.map +0 -1
  195. package/dist/services/index.js +0 -16
  196. package/dist/services/index.js.map +0 -1
  197. package/dist/services/internal/apiService.js +0 -21
  198. package/dist/services/internal/apiService.js.map +0 -1
  199. package/dist/services/internal/assetsService.js +0 -586
  200. package/dist/services/internal/assetsService.js.map +0 -1
  201. package/dist/services/internal/bitcoinService.js +0 -51
  202. package/dist/services/internal/bitcoinService.js.map +0 -1
  203. package/dist/services/internal/configService.js +0 -218
  204. package/dist/services/internal/configService.js.map +0 -1
  205. package/dist/services/internal/cosmosService.js +0 -141
  206. package/dist/services/internal/cosmosService.js.map +0 -1
  207. package/dist/services/internal/errorService.js +0 -188
  208. package/dist/services/internal/errorService.js.map +0 -1
  209. package/dist/services/internal/estimateService.js +0 -221
  210. package/dist/services/internal/estimateService.js.map +0 -1
  211. package/dist/services/internal/eventService.js +0 -163
  212. package/dist/services/internal/eventService.js.map +0 -1
  213. package/dist/services/internal/evmService.js +0 -42
  214. package/dist/services/internal/evmService.js.map +0 -1
  215. package/dist/services/internal/numberService.js +0 -171
  216. package/dist/services/internal/numberService.js.map +0 -1
  217. package/dist/services/internal/priceService.js +0 -53
  218. package/dist/services/internal/priceService.js.map +0 -1
  219. package/dist/services/internal/searchService.js +0 -98
  220. package/dist/services/internal/searchService.js.map +0 -1
  221. package/dist/services/internal/solanaService.js +0 -109
  222. package/dist/services/internal/solanaService.js.map +0 -1
  223. package/dist/services/internal/suiService.js +0 -119
  224. package/dist/services/internal/suiService.js.map +0 -1
  225. package/dist/services/internal/transactionService.js +0 -207
  226. package/dist/services/internal/transactionService.js.map +0 -1
  227. package/dist/services/internal/transactionStatusService.js +0 -315
  228. package/dist/services/internal/transactionStatusService.js.map +0 -1
  229. package/dist/services/internal/walletService.js +0 -464
  230. package/dist/services/internal/walletService.js.map +0 -1
  231. package/dist/tests/apiService.test.js +0 -40
  232. package/dist/tests/apiService.test.js.map +0 -1
  233. package/dist/tests/assetsService.test.js +0 -500
  234. package/dist/tests/assetsService.test.js.map +0 -1
  235. package/dist/tests/configService.test.js +0 -673
  236. package/dist/tests/configService.test.js.map +0 -1
  237. package/dist/tests/estimateService.test.js +0 -355
  238. package/dist/tests/estimateService.test.js.map +0 -1
  239. package/dist/tests/fetchSquidData.js +0 -36
  240. package/dist/tests/fetchSquidData.js.map +0 -1
  241. package/dist/tests/jest-svg-transform.d.ts +0 -0
  242. package/dist/tests/jest-svg-transform.js +0 -21
  243. package/dist/tests/jest-svg-transform.js.map +0 -1
  244. package/dist/tests/numberService.test.js +0 -135
  245. package/dist/tests/numberService.test.js.map +0 -1
  246. package/dist/tests/priceService.test.js +0 -38
  247. package/dist/tests/priceService.test.js.map +0 -1
  248. package/dist/tests/sample.json +0 -0
  249. package/dist/tests/searchService.test.js +0 -92
  250. package/dist/tests/searchService.test.js.map +0 -1
  251. package/dist/tests/swapConfig.test.js +0 -332
  252. package/dist/tests/swapConfig.test.js.map +0 -1
  253. package/dist/tests/transactionService.test.js +0 -53
  254. package/dist/tests/transactionService.test.js.map +0 -1
  255. package/dist/tests/transactionStatusService.test.js +0 -165
  256. package/dist/tests/transactionStatusService.test.js.map +0 -1
  257. package/dist/tests/walletService.test.js +0 -264
  258. package/dist/tests/walletService.test.js.map +0 -1
@@ -1,221 +0,0 @@
1
- import { ChainType } from "@0xsquid/squid-types";
2
- import { convertTokenAmountToUSD, findNativeToken, findToken, formatSeconds, isCoralBridgeAction, } from "..";
3
- import { gasRefundMultiplier } from "../../core/constants";
4
- import { formatBNToReadable } from "./numberService";
5
- export const formatAmount = (amountInWei, decimals) => (amountInWei ? formatBNToReadable(amountInWei, decimals) : "");
6
- export const parseToAmountUSD = (toAmountUSD) => toAmountUSD ? parseFloat(toAmountUSD.replace(/,/g, "")) : 0;
7
- /**
8
- * Calculates the expected gas refund
9
- *
10
- * Currently we only refund when source chain is EVM
11
- * There's no refund for Cosmos or Coral routes
12
- */
13
- export const calculateExpectedGasRefundCost = (firstFeeCost, fromChainType, actions) => {
14
- if (fromChainType !== ChainType.EVM) {
15
- return BigInt(0);
16
- }
17
- const isCoralRoute = actions?.some((action) => isCoralBridgeAction(action));
18
- if (isCoralRoute) {
19
- return BigInt(0);
20
- }
21
- const amount = BigInt(firstFeeCost?.amount ?? "0");
22
- const refundMultiplier = BigInt(gasRefundMultiplier);
23
- return (amount * refundMultiplier) / BigInt(100);
24
- };
25
- export const calculateTotalNativeFees = ({ expressFeeCost, firstFeeCost, firstGasCost, sameTokenBetweenFees, }) => BigInt(expressFeeCost?.amount ?? "0") +
26
- (sameTokenBetweenFees
27
- ? BigInt(firstFeeCost?.amount ?? "0") + BigInt(firstGasCost?.amount ?? "0")
28
- : BigInt(firstGasCost?.amount ?? "0"));
29
- export const isFromBalanceEnoughToSwap = ({ isFromTokenNative, fromAmount, totalFeesInNativeTokenPlusRatio, nativeTokenBalanceFromChainWei, }) => {
30
- const fromAmountBigInt = BigInt(fromAmount ?? "0");
31
- const totalFeesInNativeTokenPlusRatioBigInt = totalFeesInNativeTokenPlusRatio;
32
- const nativeTokenBalanceFromChainWeiBigInt = nativeTokenBalanceFromChainWei;
33
- return isFromTokenNative
34
- ? fromAmountBigInt + totalFeesInNativeTokenPlusRatioBigInt <=
35
- nativeTokenBalanceFromChainWeiBigInt
36
- : totalFeesInNativeTokenPlusRatioBigInt <=
37
- nativeTokenBalanceFromChainWeiBigInt;
38
- };
39
- export const calculateMinAmountValueWarnMsg = ({ isFromTokenNative, nativeTokenBalanceFromChainWei, sourceChainNativeTokenDecimals, totalFeesInNativeTokenPlusRatio, }) => isFromTokenNative
40
- ? (() => {
41
- const minAmount = nativeTokenBalanceFromChainWei - totalFeesInNativeTokenPlusRatio;
42
- return minAmount > BigInt(0)
43
- ? formatBNToReadable(minAmount, sourceChainNativeTokenDecimals)
44
- : "0";
45
- })()
46
- : undefined;
47
- /**
48
- * Calculates the estimated duration of a route
49
- *
50
- * @param {number} estimatedRouteDuration - The estimated route duration in seconds
51
- * @param {boolean} isSingleChainRoute - Flag indicating whether the route is single chain
52
- *
53
- * @returns {Object} An object containing the estimated duration and a formatter function
54
- */
55
- export const formatEstimatedRouteDuration = ({ estimatedRouteDuration, isSingleChainRoute, }) => {
56
- const fallbackDuration = 20;
57
- let durationInSeconds = fallbackDuration;
58
- if (estimatedRouteDuration) {
59
- durationInSeconds = Math.round(estimatedRouteDuration);
60
- }
61
- else if (isSingleChainRoute) {
62
- durationInSeconds = 1;
63
- }
64
- else {
65
- durationInSeconds = fallbackDuration;
66
- }
67
- return {
68
- seconds: durationInSeconds,
69
- format: (sTemplate = "s", mTemplate = "m", hTemplate = "h") => formatSeconds(durationInSeconds, sTemplate, mTemplate, hTemplate),
70
- };
71
- };
72
- /**
73
- * Calculates and formats various estimate results based on the provided Squid route and additional parameters.
74
- *
75
- * @param {RouteResponse["route"]} squidRoute - The Squid route containing estimate information.
76
- * @param {Token[]} tokens - An array of token objects.
77
- * @param {ChainData} fromChain - The source chain object.
78
- * @param {ChainData} toChain - The destination chain object.
79
- * @param {boolean} collectFees - Flag indicating whether to collect fees.
80
- * @param {string} nativeTokenBalanceFromChain - The native token balance on the source chain.
81
- * @param {boolean} expressActivatedUI - Flag indicating whether express mode is activated in the UI.
82
- * @returns {Object} An object containing various estimate results and calculations, including token information,
83
- * amounts, fees, gas costs, and other relevant data for the transaction.
84
- */
85
- export const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees, nativeTokenBalanceFromChainWei, }) => {
86
- const fromToken = findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken);
87
- const fromAmount = squidRoute?.estimate?.fromAmount;
88
- const fromAmountFormatted = formatAmount(fromAmount, fromToken?.decimals);
89
- const sourceChainNativeToken = findNativeToken(tokens, fromChain);
90
- const destChainNativeToken = findNativeToken(tokens, toChain);
91
- const toAmountUSD = squidRoute?.estimate?.toAmountUSD;
92
- const toAmountUSDFloat = parseToAmountUSD(toAmountUSD);
93
- const exchangeRate = squidRoute?.estimate.exchangeRate ?? "0";
94
- const toAmountMinUSD = squidRoute?.estimate.toAmountMinUSD ?? "0";
95
- const toAmountMin = formatBNToReadable(squidRoute?.estimate.toAmountMin ?? "0", squidRoute?.estimate.toToken.decimals);
96
- const toAmount = formatBNToReadable(squidRoute?.estimate.toAmount ?? "0", squidRoute?.estimate.toToken.decimals);
97
- const estimate = squidRoute?.estimate;
98
- const allFeeCosts = estimate?.feeCosts ?? [];
99
- const allGasCosts = estimate?.gasCosts ?? [];
100
- const firstFeeCost = allFeeCosts.length > 0 ? allFeeCosts[0] : undefined;
101
- const firstGasCost = allGasCosts.length > 0 ? allGasCosts[0] : undefined;
102
- const expressFeeCost = allFeeCosts.find((f) => f.name === "Boost fee");
103
- const integratorFeeCost = allFeeCosts.length > 0 && collectFees
104
- ? allFeeCosts.find((f) => f.name === "Integrator fee")
105
- : undefined;
106
- const expectedGasRefundCost = calculateExpectedGasRefundCost(firstFeeCost, fromChain?.chainType, estimate?.actions);
107
- const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
108
- const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
109
- firstFeeCost?.token.chainId === firstGasCost?.token.chainId;
110
- const isFromTokenNative =
111
- // TODO: temporary fix, currently nativeCurrency.symbol is not always in uppercase
112
- fromToken?.symbol.toUpperCase() ===
113
- fromChain?.nativeCurrency.symbol.toUpperCase();
114
- const totalNativeFees = calculateTotalNativeFees({
115
- expressFeeCost,
116
- firstFeeCost,
117
- firstGasCost,
118
- sameTokenBetweenFees,
119
- });
120
- const totalFeesInNativeTokenPlusRatio = (totalNativeFees * BigInt(110)) / BigInt(100);
121
- const fromBalanceEnoughToSwap = isFromBalanceEnoughToSwap({
122
- isFromTokenNative,
123
- fromAmount,
124
- fromTokenDecimals: fromToken?.decimals,
125
- totalFeesInNativeTokenPlusRatio,
126
- nativeTokenBalanceFromChainWei,
127
- });
128
- const minAmountValueWarnMsg = calculateMinAmountValueWarnMsg({
129
- isFromTokenNative,
130
- nativeTokenBalanceFromChainWei,
131
- sourceChainNativeTokenDecimals: sourceChainNativeToken?.decimals,
132
- totalFeesInNativeTokenPlusRatio,
133
- });
134
- const isSingleChainRoute = fromChain?.chainId === toChain?.chainId;
135
- const estimatedRouteDuration = formatEstimatedRouteDuration({
136
- estimatedRouteDuration: squidRoute?.estimate?.estimatedRouteDuration,
137
- isSingleChainRoute,
138
- });
139
- return {
140
- fromToken,
141
- fromAmount,
142
- fromAmountFormatted,
143
- sourceChainNativeToken,
144
- destChainNativeToken,
145
- toAmountUSD,
146
- toAmountUSDFloat,
147
- exchangeRate,
148
- toAmountMinUSD,
149
- toAmountMin,
150
- toAmount,
151
- allFeeCosts,
152
- allGasCosts,
153
- firstFeeCost,
154
- firstGasCost,
155
- expressFeeCost,
156
- integratorFeeCost,
157
- expectedGasRefundCost,
158
- expectedGasRefundCostUSD,
159
- sameTokenBetweenFees,
160
- isFromTokenNative,
161
- totalNativeFees,
162
- totalFeesInNativeTokenPlusRatio,
163
- fromBalanceEnoughToSwap,
164
- minAmountValueWarnMsg,
165
- estimatedRouteDuration,
166
- };
167
- };
168
- /**
169
- * Calculates the total estimate with refund for a transaction.
170
- *
171
- * @param allFeeCosts - Total fee costs of the transaction
172
- * @param expectedGasRefundCost - The expected gas refund cost as a bigint.
173
- * @param getUSDValue - A function to convert an amount to its USD value.
174
- * @returns An object containing the total amount, total amount in USD, and the fee token.
175
- */
176
- export const calculateTotalWithRefundEstimate = (allFeeCosts, expectedGasRefundCost, getUSDValue) => {
177
- const initialTotalFees = {
178
- totalFeeAmount: BigInt(0),
179
- totalFeeUsd: 0,
180
- };
181
- const { totalFeeAmount, totalFeeUsd } = allFeeCosts?.reduce((totalFees, currentFee) => {
182
- return {
183
- totalFeeAmount: BigInt(totalFees.totalFeeAmount) + BigInt(currentFee.amount),
184
- totalFeeUsd: Number(totalFees.totalFeeUsd) + Number(currentFee.amountUsd),
185
- };
186
- }, initialTotalFees) ?? initialTotalFees;
187
- const totalFeeAmountMinusRefund = totalFeeAmount - expectedGasRefundCost;
188
- const firstFeeCost = allFeeCosts?.[0];
189
- const totalFeeAmountMinusRefundBn = formatBNToReadable(totalFeeAmountMinusRefund, firstFeeCost?.token?.decimals ?? 18);
190
- const formattedRefundCost = formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18);
191
- const formattedRefundCostUsd = getUSDValue(formattedRefundCost);
192
- const totalFeeUsdMinusRefund = totalFeeUsd - Number(formattedRefundCostUsd ?? 0);
193
- return {
194
- totalAmount: totalFeeAmountMinusRefundBn,
195
- totalAmountUSD: totalFeeUsdMinusRefund,
196
- feeToken: firstFeeCost?.token,
197
- };
198
- };
199
- /**
200
- * Calculates the proposed gas amount for the destination chain.
201
- *
202
- * @param destChainNativeToken - The symbol of the native token for the destination chain.
203
- * @returns An object containing the proposed gas amount value and the currency symbol.
204
- */
205
- export const getProposedGasDestinationAmount = (destChainNativeToken) => {
206
- const gasAmounts = {
207
- GLMR: 5.289,
208
- ETH: 0.0009,
209
- AVAX: 0.115,
210
- BNB: 0.00425,
211
- FTM: 4.45,
212
- CELO: 3.052,
213
- KAVA: 2.339,
214
- MATIC: 1.795,
215
- };
216
- return {
217
- value: gasAmounts[destChainNativeToken ?? ""] ?? 0,
218
- currency: destChainNativeToken,
219
- };
220
- };
221
- //# sourceMappingURL=estimateService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"estimateService.js","sourceRoot":"","sources":["../../../src/services/internal/estimateService.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,SAAS,EACT,aAAa,EACb,mBAAmB,GACpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAMrD,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,WAA+B,EAC/B,QAA4B,EAC5B,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAA+B,EAAE,EAAE,CAClE,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,YAAwC,EACxC,aAAoC,EACpC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AI;QACT,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,KAAK;KACb,CAAC;IACF,OAAO;QACL,KAAK,EAAE,UAAU,CAAC,oBAAoB,IAAI,EAAE,CAAC,IAAI,CAAC;QAClD,QAAQ,EAAE,oBAAoB;KAC/B,CAAC;AACJ,CAAC,CAAC"}
@@ -1,163 +0,0 @@
1
- import { formatAmount } from "./estimateService";
2
- /**
3
- * Creates a hash string from quote request parameters to track changes
4
- */
5
- export const createQuoteRequestParamsHash = (params) => {
6
- return [
7
- params.fromAddress || "",
8
- params.toAddress || "",
9
- params.fromChain,
10
- params.toChain,
11
- `${params.fromToken}_${params.fromChain}`,
12
- `${params.toToken}_${params.toChain}`,
13
- params.fromAmount,
14
- ].join("|");
15
- };
16
- /**
17
- * Formats the amount based on token details
18
- * @param data Event parameters containing fromToken, fromChain, and fromAmount
19
- * @param findToken Function to find token details
20
- * @returns Original data with formatted amount
21
- */
22
- const formatTokenAmount = (data, findToken) => {
23
- const fromToken = findToken(data.fromToken, data.fromChain);
24
- const formattedFromAmount = formatAmount(data.fromAmount, fromToken?.decimals);
25
- // Rewrite the fromAmount with the formatted amount
26
- // Example: 1000000000000000000 -> 1 with decimals 18
27
- // For readability of the event data
28
- return {
29
- ...data,
30
- fromAmount: formattedFromAmount,
31
- };
32
- };
33
- export class WidgetEvents extends EventTarget {
34
- static instance;
35
- constructor() {
36
- super();
37
- }
38
- // Singleton, because we need to access this service outside the widget
39
- static getInstance() {
40
- if (!WidgetEvents.instance) {
41
- WidgetEvents.instance = new WidgetEvents();
42
- }
43
- return WidgetEvents.instance;
44
- }
45
- /**
46
- * Overriding the addEventListener method to make it easier to use with typescript
47
- * @param type
48
- * @param listener
49
- * @param options
50
- */
51
- listenToWidget(type, listener, options) {
52
- super.addEventListener(type, listener, options);
53
- }
54
- /**
55
- * Overriding the removeEventListener method to make it easier to use with typescript
56
- * @param type
57
- * @param listener
58
- * @param options
59
- */
60
- removeWidgetListener(type, listener, options) {
61
- super.removeEventListener(type, listener, options);
62
- }
63
- /**
64
- * Dispatch an event of the widget
65
- * To be listened from an integrator website
66
- * For example to display a success message when transaction is done
67
- * @param name
68
- * @param data
69
- */
70
- dispatch(name, data) {
71
- this.dispatchEvent(new CustomEvent(name, { detail: data }));
72
- }
73
- /**
74
- * Will dispatch the main axelar status of transaction
75
- * This will be called every time the status is received by backend
76
- * (Using interval to check status)
77
- * @param status
78
- */
79
- dispatchSwapStatus(status) {
80
- this.dispatch("swapStatus", { status });
81
- }
82
- /**
83
- * Dispatch event when user executes a swap
84
- * Only when we have the tx hash received
85
- * @param route
86
- */
87
- dispatchSwapExecuteCall(route, txHash) {
88
- this.dispatch("swap", { route, txHash });
89
- }
90
- /**
91
- * Dispatch event when user changes chain/token
92
- * @param swapParams
93
- */
94
- dispatchSwapParamsChanged(swapParams) {
95
- this.dispatch("swapParamsChanged", { ...swapParams });
96
- }
97
- /**
98
- * Dispatch event when we are waiting for the user to sign the swap transaction
99
- * @param data
100
- */
101
- dispatchSwapTxSignatureRequested(data) {
102
- this.dispatch("swapTxSignatureRequested", data);
103
- }
104
- /**
105
- * Dispatch event when there's an error while executing the swap route
106
- * @param data
107
- */
108
- dispatchSwapRouteExecutionError(data) {
109
- this.dispatch("swapRouteExecutionError", data);
110
- }
111
- /**
112
- * Dispatch event when requesting a quote for swap
113
- * @param data Quote request parameters
114
- */
115
- dispatchRequestQuote(data) {
116
- this.dispatch("requestQuote", data);
117
- }
118
- /**
119
- * Dispatch event before swap execution
120
- * @param data Pre-swap parameters
121
- * @param findToken Function to find token details
122
- */
123
- dispatchPreSwap(data, findToken) {
124
- this.dispatch("preSwap", formatTokenAmount(data, findToken));
125
- }
126
- /**
127
- * Dispatch event after swap execution
128
- * @param data Post-swap parameters including transaction hash
129
- * @param findToken Function to find token details
130
- */
131
- dispatchPostSwap(data, findToken) {
132
- this.dispatch("postSwap", formatTokenAmount(data, findToken));
133
- }
134
- /**
135
- * Dispatch event when wallet is successfully connected
136
- * @param data Wallet connection details
137
- */
138
- dispatchWalletConnect(data) {
139
- this.dispatch("walletConnect", data);
140
- }
141
- /**
142
- * Dispatch event when wallet connection is rejected
143
- * @param data Wallet rejection details
144
- */
145
- dispatchWalletReject(data) {
146
- this.dispatch("walletReject", data);
147
- }
148
- /**
149
- * Dispatch event when onchain transaction is rejected
150
- * @param data Onchain rejection details
151
- */
152
- dispatchOnchainReject(data) {
153
- this.dispatch("onchainReject", data);
154
- }
155
- /**
156
- * Dispatch event when the search query has no results
157
- * @param data Empty search details
158
- */
159
- dispatchSearchEmpty(data) {
160
- this.dispatch("searchEmpty", data);
161
- }
162
- }
163
- //# sourceMappingURL=eventService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventService.js","sourceRoot":"","sources":["../../../src/services/internal/eventService.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOjD;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,MAAoB,EAAU,EAAE;IAC3E,OAAO;QACL,MAAM,CAAC,WAAW,IAAI,EAAE;QACxB,MAAM,CAAC,SAAS,IAAI,EAAE;QACtB,MAAM,CAAC,SAAS;QAChB,MAAM,CAAC,OAAO;QACd,GAAG,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE;QACzC,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE;QACrC,MAAM,CAAC,UAAU;KAClB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAGxB,IAAO,EACP,SAA0B,EACvB,EAAE;IACL,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5D,MAAM,mBAAmB,GAAG,YAAY,CACtC,IAAI,CAAC,UAAU,EACf,SAAS,EAAE,QAAQ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F"}
@@ -1,42 +0,0 @@
1
- import { isAddress as isEvmAddress, } from "viem";
2
- export const EvmNetworkNotSupportedErrorCode = 4902;
3
- export async function addEthereumChain({ chain, provider, }) {
4
- const chainName = chain.rpc.includes("tenderly")
5
- ? `${chain.networkName} Tenderly fork`
6
- : chain.networkName;
7
- const chainParameters = {
8
- chainId: `0x${parseInt(chain.chainId, 10).toString(16)}`,
9
- chainName,
10
- nativeCurrency: chain.nativeCurrency,
11
- rpcUrls: [chain.rpc],
12
- blockExplorerUrls: chain.blockExplorerUrls,
13
- iconUrls: [chain.chainIconURI],
14
- };
15
- try {
16
- return provider.request({
17
- method: "wallet_addEthereumChain",
18
- params: [chainParameters],
19
- });
20
- }
21
- catch (error) {
22
- console.debug("Error adding chain:", error);
23
- }
24
- }
25
- export const connectEvmWallet = async (wallet, { connectEvmAsync, }) => {
26
- if (!wallet.connector) {
27
- throw new Error("Wallet connector is undefined");
28
- }
29
- const evmConnectionResult = await connectEvmAsync({
30
- connector: wallet.connector(),
31
- });
32
- return {
33
- wallet,
34
- address: evmConnectionResult.accounts?.[0] ?? "",
35
- };
36
- };
37
- export const parseEvmAddress = (address) => {
38
- if (address && isEvmAddress(address)) {
39
- return address;
40
- }
41
- };
42
- //# sourceMappingURL=evmService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evmService.js","sourceRoot":"","sources":["../../../src/services/internal/evmService.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,SAAS,IAAI,YAAY,GAC1B,MAAM,MAAM,CAAC;AAKd,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EACrC,KAAK,EACL,QAAQ,GAIT;IACC,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC9C,CAAC,CAAC,GAAG,KAAK,CAAC,WAAW,gBAAgB;QACtC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC;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While from "lodash/takeWhile";
4
- import { formatUnits, parseUnits } from "viem";
5
- import { DEFAULT_LOCALE } from "../../core/constants";
6
- // =====================================================
7
- // NOTE: We wrap viem utility method here
8
- // So that in the future we can change the implementation
9
- // if we want to use something else than viem formatters
10
- // =====================================================
11
- /**
12
- * Parses a value to a bigint
13
- * @param value - The value to parse
14
- * @param decimals - The number of decimals
15
- * @returns The parsed bigint
16
- * @throws Error if parsing fails
17
- */
18
- export const parseToBigInt = (value, decimals = 18) => {
19
- try {
20
- return parseUnits(value.toString(), decimals);
21
- }
22
- catch (error) {
23
- const errorMessage = error instanceof Error ? error.message : String(error);
24
- throw new Error(`Failed to parse value to BigInt: ${errorMessage}`);
25
- }
26
- };
27
- /**
28
- * Formats a value to a readable string
29
- * @param value - The value to format (bigint or string)
30
- * @param decimals - The number of decimals
31
- * @returns The formatted string
32
- * @throws Error if formatting fails
33
- */
34
- export const formatBNToReadable = (value, decimals = 18) => {
35
- try {
36
- return formatUnits(BigInt(value), decimals);
37
- }
38
- catch (error) {
39
- const errorMessage = error instanceof Error ? error.message : String(error);
40
- throw new Error(`Failed to format value: ${errorMessage}`);
41
- }
42
- };
43
- export const roundNumericValue = (value = "0", precision = 2, useComaEvery3Digits = true, significantFigures = 0) => {
44
- let newValue = value;
45
- const temp = newValue?.toString() ?? "";
46
- let [integers, decimals] = temp.split(".");
47
- // toLocaleString is supported on all modern browsers
48
- // We might monitor and have a polyfill if some people are not
49
- // Seeing the comas.
50
- if (useComaEvery3Digits && integers !== "0") {
51
- integers = parseInt(integers, 10).toLocaleString(DEFAULT_LOCALE).toString();
52
- }
53
- if (significantFigures && decimals) {
54
- const zeros = takeWhile(decimals?.toString(), (c) => c === "0").length;
55
- return `${integers}.${take(decimals, zeros + significantFigures).join("")}`;
56
- }
57
- return decimals
58
- ? `${integers}.${take(decimals, precision).join("")}`
59
- : integers;
60
- };
61
- const MAX_TOKEN_DECIMALS = 8;
62
- const TOKEN_EXACT_AMOUNT_FORMATTER = new Intl.NumberFormat(DEFAULT_LOCALE, {
63
- minimumFractionDigits: 0,
64
- maximumFractionDigits: MAX_TOKEN_DECIMALS,
65
- });
66
- const TOKEN_ROUNDED_AMOUNT_FORMATTER = new Intl.NumberFormat(DEFAULT_LOCALE, {
67
- minimumFractionDigits: 0,
68
- maximumFractionDigits: MAX_TOKEN_DECIMALS,
69
- minimumSignificantDigits: 2,
70
- maximumSignificantDigits: 4,
71
- });
72
- const TOKEN_SIMPLIFIED_AMOUNT_FORMATTER = new Intl.NumberFormat(DEFAULT_LOCALE, {
73
- maximumSignificantDigits: 2,
74
- });
75
- export function formatTokenAmount(amount, { exact = true, simplified = false } = {}) {
76
- const numericAmount = parseFloat(amount || "0");
77
- if (numericAmount <= 0) {
78
- return "0";
79
- }
80
- // Check if numericAmount is less than the smallest displayable amount
81
- if (numericAmount < Math.pow(10, -MAX_TOKEN_DECIMALS)) {
82
- return `<${Math.pow(10, -MAX_TOKEN_DECIMALS).toFixed(MAX_TOKEN_DECIMALS)}`;
83
- }
84
- if (simplified) {
85
- return TOKEN_SIMPLIFIED_AMOUNT_FORMATTER.format(numericAmount);
86
- }
87
- if (exact) {
88
- return TOKEN_EXACT_AMOUNT_FORMATTER.format(numericAmount);
89
- }
90
- return TOKEN_ROUNDED_AMOUNT_FORMATTER.format(numericAmount);
91
- }
92
- // For values below 100,000, use exact integer precision
93
- // e.g 1,234.56, 98,765.43
94
- const STANDARD_USD_INTL_FORMATTER = new Intl.NumberFormat(DEFAULT_LOCALE, {
95
- style: "currency",
96
- currency: "USD",
97
- minimumFractionDigits: 2,
98
- maximumFractionDigits: 2,
99
- });
100
- // For values above 100,000, use compact notation
101
- // e.g $12,34K, $98,765.43M
102
- const COMPACT_USD_INTL_FORMATTER = new Intl.NumberFormat(DEFAULT_LOCALE, {
103
- style: "currency",
104
- currency: "USD",
105
- notation: "compact",
106
- compactDisplay: "short",
107
- minimumFractionDigits: 2,
108
- maximumFractionDigits: 2,
109
- });
110
- // For small amounts where decimal precision is important
111
- // e.g $0.00045, $1,231.3209, $57.00002
112
- const PRECISE_USD_INTL_FORMATTER = new Intl.NumberFormat(DEFAULT_LOCALE, {
113
- style: "currency",
114
- currency: "USD",
115
- minimumFractionDigits: 2,
116
- maximumFractionDigits: 5,
117
- });
118
- const DECIMAL_PRECISION_THRESHOLD = 1;
119
- export function formatUsdAmount(amount = "0", { includeSign = true, decimalPrecision = false } = {}) {
120
- const parsedAmount = Number(amount);
121
- if (parsedAmount < 0.01 && parsedAmount > 0 && !decimalPrecision) {
122
- return includeSign ? "<$0.01" : "<0.01";
123
- }
124
- // Handle amounts 100,000 or above using compact notation
125
- if (parsedAmount >= 100_000) {
126
- return COMPACT_USD_INTL_FORMATTER.format(parsedAmount).replace(/^\$/, includeSign ? "$" : "");
127
- }
128
- // Handle small amounts with decimal precision
129
- // We don't care about decimal precision for big amounts
130
- if (decimalPrecision && parsedAmount < DECIMAL_PRECISION_THRESHOLD) {
131
- return PRECISE_USD_INTL_FORMATTER.format(parsedAmount).replace(/^\$/, includeSign ? "$" : "");
132
- }
133
- // Handle amounts less than 100,000 with exact integer precision
134
- return STANDARD_USD_INTL_FORMATTER.format(parsedAmount).replace(/^\$/, includeSign ? "$" : "");
135
- }
136
- export function trimExtraDecimals(value, maxDecimals) {
137
- const [integerPart, decimalPart] = value.split(".");
138
- // Return just the integer part if maxDecimals is zero
139
- if (maxDecimals === 0) {
140
- return integerPart;
141
- }
142
- // Process decimals if present and maxDecimals is not zero
143
- if (decimalPart &&
144
- maxDecimals !== undefined &&
145
- decimalPart.length > maxDecimals) {
146
- return `${integerPart}.${decimalPart.slice(0, maxDecimals)}`;
147
- }
148
- // Return the original value if there are no excess decimals or maxDecimals is undefined
149
- return value;
150
- }
151
- export const getNumericValue = ({ value, precision, useComaEvery3Digits = true, hideIfZero = false, currency, significantFigures, formatIfVerySmall, wrapInParens = false, isNegative = false, }) => {
152
- const roundedValue = value !== undefined && value !== ""
153
- ? roundNumericValue(value, precision, useComaEvery3Digits, significantFigures)
154
- : undefined;
155
- if (hideIfZero && (value === "0" || value === "0.0")) {
156
- return null;
157
- }
158
- const isVerySmall = formatIfVerySmall !== undefined &&
159
- +(value ?? "0") !== 0 &&
160
- +(value ?? "0") < formatIfVerySmall;
161
- const prefix = `${isVerySmall ? "<" : ""}${currency && currency.symbol && currency.symbolPosition === "before"
162
- ? currency.symbol
163
- : ""}`;
164
- const suffix = `${currency && currency.symbol && currency.symbolPosition === "after"
165
- ? currency.symbol
166
- : ""}`;
167
- const formattedIfVerySmall = roundedValue && isVerySmall ? formatIfVerySmall?.toString() : roundedValue;
168
- const finalValue = `${isNegative ? "-" : ""}${prefix}${formattedIfVerySmall}${suffix ? ` ${suffix}` : ""}`;
169
- return wrapInParens ? `(${finalValue})` : finalValue;
170
- };
171
- //# sourceMappingURL=numberService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"numberService.js","sourceRoot":"","sources":["../../../src/services/internal/numberService.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,wDAAwD;AACxD,yCAAyC;AACzC,yDAAyD;AACzD,wDAAwD;AACxD,wDAAwD;AACxD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,WAAmB,EAAE,EAAU,EAAE;IAC5E,IAAI;QACF,OAAO,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;KAC/C;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,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