@metamask/bridge-controller 65.3.0 → 66.1.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/dist/bridge-controller.cjs +2 -1
  3. package/dist/bridge-controller.cjs.map +1 -1
  4. package/dist/bridge-controller.d.cts +2 -2
  5. package/dist/bridge-controller.d.cts.map +1 -1
  6. package/dist/bridge-controller.d.mts +2 -2
  7. package/dist/bridge-controller.d.mts.map +1 -1
  8. package/dist/bridge-controller.mjs +2 -1
  9. package/dist/bridge-controller.mjs.map +1 -1
  10. package/dist/index.cjs +3 -2
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +1 -1
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +1 -1
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +1 -1
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/selectors.cjs +50 -23
  19. package/dist/selectors.cjs.map +1 -1
  20. package/dist/selectors.d.cts +59 -59
  21. package/dist/selectors.d.cts.map +1 -1
  22. package/dist/selectors.d.mts +59 -59
  23. package/dist/selectors.d.mts.map +1 -1
  24. package/dist/selectors.mjs +51 -24
  25. package/dist/selectors.mjs.map +1 -1
  26. package/dist/utils/caip-formatters.cjs +18 -8
  27. package/dist/utils/caip-formatters.cjs.map +1 -1
  28. package/dist/utils/caip-formatters.d.cts +2 -2
  29. package/dist/utils/caip-formatters.d.cts.map +1 -1
  30. package/dist/utils/caip-formatters.d.mts +2 -2
  31. package/dist/utils/caip-formatters.d.mts.map +1 -1
  32. package/dist/utils/caip-formatters.mjs +20 -10
  33. package/dist/utils/caip-formatters.mjs.map +1 -1
  34. package/dist/utils/metrics/constants.cjs +8 -1
  35. package/dist/utils/metrics/constants.cjs.map +1 -1
  36. package/dist/utils/metrics/constants.d.cts +6 -1
  37. package/dist/utils/metrics/constants.d.cts.map +1 -1
  38. package/dist/utils/metrics/constants.d.mts +6 -1
  39. package/dist/utils/metrics/constants.d.mts.map +1 -1
  40. package/dist/utils/metrics/constants.mjs +7 -0
  41. package/dist/utils/metrics/constants.mjs.map +1 -1
  42. package/dist/utils/metrics/types.cjs.map +1 -1
  43. package/dist/utils/metrics/types.d.cts +7 -1
  44. package/dist/utils/metrics/types.d.cts.map +1 -1
  45. package/dist/utils/metrics/types.d.mts +7 -1
  46. package/dist/utils/metrics/types.d.mts.map +1 -1
  47. package/dist/utils/metrics/types.mjs.map +1 -1
  48. package/dist/utils/quote.cjs +6 -5
  49. package/dist/utils/quote.cjs.map +1 -1
  50. package/dist/utils/quote.d.cts +2 -2
  51. package/dist/utils/quote.d.cts.map +1 -1
  52. package/dist/utils/quote.d.mts +2 -2
  53. package/dist/utils/quote.d.mts.map +1 -1
  54. package/dist/utils/quote.mjs +6 -5
  55. package/dist/utils/quote.mjs.map +1 -1
  56. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAAA,wDAAuD;AAQvD,2CAAoD;AACpD,+CAAyC;AACzC,mCAAiC;AACjC,uCAGkB;AAElB,mDAAmE;AAQnE,uCAAmD;AACnD,+CAKwB;AACxB,iEAIiC;AACjC,6DAA4D;AAC5D,6CAYuB;AACvB,mDAAgE;AAsBhE;;GAEG;AACH,MAAM,8BAA8B,GAClC,mCAAyB,CAAC,SAAS,EAAkB,CAAC;AACxD;;GAEG;AACH,MAAM,oBAAoB,GAAG,yBAAe,CAAC,SAAS,EAAkB,CAAC;AASzE,MAAM,0BAA0B,GAC9B,yBAAe,CAAC,SAAS,EAAoC,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;GAoBG;AACU,QAAA,wBAAwB,GAAG,0BAA0B,CAChE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAClD,CAAC,YAAqB,EAAE,EAAE,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,EACrB,EAAE,CACF,IAAI,wBAAS,CAAC,KAAK,CAAC,wCAAwC,IAAI,CAAC,CAAC;KAC/D,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;KACZ,QAAQ,EAAE,CAAC;AALH,QAAA,yCAAyC,6CAKtC;AAEH,QAAA,+BAA+B,GAAG,oBAAoB,CACjE;IACE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,gCAAwB,EAAC,KAAK,CAAC,CAAC,MAAM;IACjD,CAAC,CAAC,EAAE,cAAkE,EAAE,EAAE,CACxE,cAAc,CAAC,eAAe;IAChC,CAAC,CAAC,EAAE,cAAkE,EAAE,EAAE,CACxE,cAAc,CAAC,gBAAgB;IACjC,CAAC,CAAC,EAAE,cAAkE,EAAE,EAAE,CACxE,cAAc,CAAC,UAAU;QACvB,CAAC,CAAC,IAAA,qCAAmB,EAAC,cAAc,CAAC,UAAU,CAAC;QAChD,CAAC,CAAC,SAAS;IACf,CAAC,CAAC,EAAE,cAAkE,EAAE,EAAE,CACxE,cAAc,CAAC,WAAW;QACxB,CAAC,CAAC,IAAA,qCAAmB,EAAC,cAAc,CAAC,WAAW,CAAC;QACjD,CAAC,CAAC,SAAS;CAChB,EACD,CACE,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,EAAE;IACF,OAAO,IAAA,uCAA4B,EACjC;QACE,eAAe;QACf,gBAAgB;QAChB,UAAU;QACV,WAAW;KACZ,EACD,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,EACrE,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,CACxE,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { AddressZero } from '@ethersproject/constants';\nimport type {\n CurrencyRateState,\n MultichainAssetsRatesControllerState,\n TokenRatesControllerState,\n} from '@metamask/assets-controllers';\nimport type { GasFeeEstimates } from '@metamask/gas-fee-controller';\nimport type { CaipAssetType } from '@metamask/utils';\nimport { isStrictHexString } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\nimport { orderBy } from 'lodash';\nimport {\n createSelector as createSelector_,\n createStructuredSelector as createStructuredSelector_,\n} from 'reselect';\n\nimport { BRIDGE_PREFERRED_GAS_ESTIMATE } from './constants/bridge';\nimport type {\n BridgeControllerState,\n ExchangeRate,\n GenericQuoteRequest,\n QuoteMetadata,\n QuoteResponse,\n} from './types';\nimport { RequestStatus, SortOrder } from './types';\nimport {\n getNativeAssetForChainId,\n isEvmQuoteResponse,\n isNativeAddress,\n isNonEvmChainId,\n} from './utils/bridge';\nimport {\n formatAddressToAssetId,\n formatChainIdToCaip,\n formatChainIdToHex,\n} from './utils/caip-formatters';\nimport { processFeatureFlags } from './utils/feature-flags';\nimport {\n calcAdjustedReturn,\n calcCost,\n calcEstimatedAndMaxTotalGasFee,\n calcIncludedTxFees,\n calcRelayerFee,\n calcSentAmount,\n calcNonEvmTotalNetworkFee,\n calcSwapRate,\n calcToAmount,\n calcTotalEstimatedNetworkFee,\n calcTotalMaxNetworkFee,\n} from './utils/quote';\nimport { getDefaultSlippagePercentage } from './utils/slippage';\n\n/**\n * The controller states that provide exchange rates\n */\ntype ExchangeRateControllerState = MultichainAssetsRatesControllerState &\n TokenRatesControllerState &\n CurrencyRateState &\n Pick<BridgeControllerState, 'assetExchangeRates'>;\n/**\n * The state of the bridge controller and all its dependency controllers\n */\ntype RemoteFeatureFlagControllerState = {\n remoteFeatureFlags: {\n bridgeConfig: unknown;\n };\n};\nexport type BridgeAppState = BridgeControllerState & {\n gasFeeEstimates: GasFeeEstimates;\n} & ExchangeRateControllerState & {\n participateInMetaMetrics: boolean;\n } & RemoteFeatureFlagControllerState;\n/**\n * Creates a structured selector for the bridge controller\n */\nconst createStructuredBridgeSelector =\n createStructuredSelector_.withTypes<BridgeAppState>();\n/**\n * Creates a typed selector for the bridge controller\n */\nconst createBridgeSelector = createSelector_.withTypes<BridgeAppState>();\n/**\n * Required parameters that clients must provide for the bridge quotes selector\n */\ntype BridgeQuotesClientParams = {\n sortOrder: SortOrder;\n selectedQuote: (QuoteResponse & QuoteMetadata) | null;\n};\n\nconst createFeatureFlagsSelector =\n createSelector_.withTypes<RemoteFeatureFlagControllerState>();\n\n/**\n * Selects the bridge feature flags\n *\n * @param state - The state of the bridge controller\n * @returns The bridge feature flags\n *\n * @example\n * ```ts\n * const featureFlags = useSelector(state => selectBridgeFeatureFlags(state));\n *\n * Or\n *\n * export const selectBridgeFeatureFlags = createSelector(\n * selectRemoteFeatureFlags,\n * (remoteFeatureFlags) =>\n * selectBridgeFeatureFlagsBase({\n * bridgeConfig: remoteFeatureFlags.bridgeConfig,\n * }),\n * );\n * ```\n */\nexport const selectBridgeFeatureFlags = createFeatureFlagsSelector(\n [(state) => state.remoteFeatureFlags.bridgeConfig],\n (bridgeConfig: unknown) => processFeatureFlags(bridgeConfig),\n);\n\nconst getExchangeRateByChainIdAndAddress = (\n exchangeRateSources: ExchangeRateControllerState,\n chainId?: GenericQuoteRequest['srcChainId'],\n address?: GenericQuoteRequest['srcTokenAddress'],\n): ExchangeRate => {\n if (!chainId || !address) {\n return {};\n }\n // TODO return usd exchange rate if user has opted into metrics\n const assetId = formatAddressToAssetId(address, chainId);\n if (!assetId) {\n return {};\n }\n\n const { assetExchangeRates, currencyRates, marketData, conversionRates } =\n exchangeRateSources;\n\n // If the asset exchange rate is available in the bridge controller, use it\n // This is defined if the token's rate is not available from the assets controllers\n const bridgeControllerRate =\n assetExchangeRates?.[assetId] ??\n assetExchangeRates?.[assetId.toLowerCase() as CaipAssetType];\n if (bridgeControllerRate?.exchangeRate) {\n return bridgeControllerRate;\n }\n // If the chain is a non-EVM chain, use the conversion rate from the multichain assets controller\n if (isNonEvmChainId(chainId)) {\n const multichainAssetExchangeRate = conversionRates?.[assetId];\n if (multichainAssetExchangeRate) {\n return {\n exchangeRate: multichainAssetExchangeRate.rate,\n usdExchangeRate: undefined,\n };\n }\n return {};\n }\n // If the chain is an EVM chain, use the conversion rate from the currency rates controller\n if (isNativeAddress(address)) {\n const { symbol } = getNativeAssetForChainId(chainId);\n const evmNativeExchangeRate = currencyRates?.[symbol];\n if (evmNativeExchangeRate) {\n return {\n exchangeRate: evmNativeExchangeRate?.conversionRate?.toString(),\n usdExchangeRate: evmNativeExchangeRate?.usdConversionRate?.toString(),\n };\n }\n return {};\n }\n // If the chain is an EVM chain and the asset is not the native asset, use the conversion rate from the token rates controller\n if (!isNonEvmChainId(chainId)) {\n const evmTokenExchangeRates = marketData?.[formatChainIdToHex(chainId)];\n const evmTokenExchangeRateForAddress = isStrictHexString(address)\n ? evmTokenExchangeRates?.[address]\n : null;\n const nativeCurrencyRate = evmTokenExchangeRateForAddress\n ? currencyRates[evmTokenExchangeRateForAddress?.currency]\n : undefined;\n if (evmTokenExchangeRateForAddress && nativeCurrencyRate) {\n return {\n exchangeRate: new BigNumber(evmTokenExchangeRateForAddress.price)\n .multipliedBy(nativeCurrencyRate.conversionRate ?? 0)\n .toString(),\n usdExchangeRate: new BigNumber(evmTokenExchangeRateForAddress.price)\n .multipliedBy(nativeCurrencyRate.usdConversionRate ?? 0)\n .toString(),\n };\n }\n }\n\n return {};\n};\n\n/**\n * Selects the asset exchange rate for a given chain and address\n *\n * @param state The state of the bridge controller and its dependency controllers\n * @param chainId The chain ID of the asset\n * @param address The address of the asset\n * @returns The asset exchange rate for the given chain and address\n */\nexport const selectExchangeRateByChainIdAndAddress = (\n state: BridgeAppState,\n chainId?: GenericQuoteRequest['srcChainId'],\n address?: GenericQuoteRequest['srcTokenAddress'],\n) => {\n return getExchangeRateByChainIdAndAddress(state, chainId, address);\n};\n\n/**\n * Checks whether an exchange rate is available for a given chain and address\n *\n * @param params The parameters to pass to {@link getExchangeRateByChainIdAndAddress}\n * @returns Whether an exchange rate is available for the given chain and address\n */\nexport const selectIsAssetExchangeRateInState = (\n ...params: Parameters<typeof getExchangeRateByChainIdAndAddress>\n) =>\n Boolean(getExchangeRateByChainIdAndAddress(...params)?.exchangeRate) &&\n Boolean(getExchangeRateByChainIdAndAddress(...params)?.usdExchangeRate);\n\n/**\n * Selects the gas fee estimates from the gas fee controller. All potential networks\n * support EIP1559 gas fees so assume that gasFeeEstimates is of type GasFeeEstimates\n *\n * @returns The gas fee estimates in decGWEI\n */\nconst selectBridgeFeesPerGas = createStructuredBridgeSelector({\n estimatedBaseFeeInDecGwei: ({ gasFeeEstimates }) =>\n gasFeeEstimates?.estimatedBaseFee,\n feePerGasInDecGwei: ({ gasFeeEstimates }) =>\n gasFeeEstimates?.[BRIDGE_PREFERRED_GAS_ESTIMATE]?.suggestedMaxFeePerGas,\n maxFeePerGasInDecGwei: ({ gasFeeEstimates }) =>\n gasFeeEstimates?.high?.suggestedMaxFeePerGas,\n});\n\n// Selects cross-chain swap quotes including their metadata\nconst selectBridgeQuotesWithMetadata = createBridgeSelector(\n [\n ({ quotes }) => quotes,\n selectBridgeFeesPerGas,\n createBridgeSelector(\n [\n (state) => state,\n ({ quoteRequest: { srcChainId } }) => srcChainId,\n ({ quoteRequest: { srcTokenAddress } }) => srcTokenAddress,\n ],\n selectExchangeRateByChainIdAndAddress,\n ),\n createBridgeSelector(\n [\n (state) => state,\n ({ quoteRequest: { destChainId } }) => destChainId,\n ({ quoteRequest: { destTokenAddress } }) => destTokenAddress,\n ],\n selectExchangeRateByChainIdAndAddress,\n ),\n createBridgeSelector(\n [(state) => state, ({ quoteRequest: { srcChainId } }) => srcChainId],\n (state, chainId) =>\n selectExchangeRateByChainIdAndAddress(state, chainId, AddressZero),\n ),\n ],\n (\n quotes,\n bridgeFeesPerGas,\n srcTokenExchangeRate,\n destTokenExchangeRate,\n nativeExchangeRate,\n ) => {\n const newQuotes = quotes.map((quote) => {\n const sentAmount = calcSentAmount(quote.quote, srcTokenExchangeRate);\n const toTokenAmount = calcToAmount(\n quote.quote.destTokenAmount,\n quote.quote.destAsset,\n destTokenExchangeRate,\n );\n const minToTokenAmount = calcToAmount(\n quote.quote.minDestTokenAmount,\n quote.quote.destAsset,\n destTokenExchangeRate,\n );\n\n const includedTxFees = calcIncludedTxFees(\n quote.quote,\n srcTokenExchangeRate,\n destTokenExchangeRate,\n );\n\n let totalEstimatedNetworkFee,\n totalMaxNetworkFee,\n relayerFee,\n gasFee: QuoteMetadata['gasFee'];\n\n if (!isEvmQuoteResponse(quote)) {\n // Use the new generic function for all non-EVM chains\n totalEstimatedNetworkFee = calcNonEvmTotalNetworkFee(\n quote,\n nativeExchangeRate,\n );\n gasFee = {\n effective: totalEstimatedNetworkFee,\n total: totalEstimatedNetworkFee,\n max: totalEstimatedNetworkFee,\n };\n totalMaxNetworkFee = totalEstimatedNetworkFee;\n } else {\n relayerFee = calcRelayerFee(quote, nativeExchangeRate);\n gasFee = calcEstimatedAndMaxTotalGasFee({\n bridgeQuote: quote,\n ...bridgeFeesPerGas,\n ...nativeExchangeRate,\n });\n // Uses effectiveGasFee to calculate the total estimated network fee\n totalEstimatedNetworkFee = calcTotalEstimatedNetworkFee(\n gasFee,\n relayerFee,\n );\n totalMaxNetworkFee = calcTotalMaxNetworkFee(gasFee, relayerFee);\n }\n\n const adjustedReturn = calcAdjustedReturn(\n toTokenAmount,\n totalEstimatedNetworkFee,\n quote.quote,\n );\n const cost = calcCost(adjustedReturn, sentAmount);\n\n return {\n ...quote,\n // QuoteMetadata fields\n sentAmount,\n toTokenAmount,\n minToTokenAmount,\n swapRate: calcSwapRate(sentAmount.amount, toTokenAmount.amount),\n /**\n This is the amount required to submit the transactions\n Includes the relayer fee or other native fees\n Should be used for balance checks and tx submission.\n */\n totalNetworkFee: totalEstimatedNetworkFee,\n totalMaxNetworkFee,\n /**\n This contains gas fee estimates for the bridge transaction\n Does not include the relayer fee (if needed), just the gasLimit and effectiveGas returned by the bridge API\n Should only be used for display purposes.\n */\n gasFee,\n adjustedReturn,\n cost,\n includedTxFees,\n };\n });\n\n return newQuotes;\n },\n);\n\nconst selectSortedBridgeQuotes = createBridgeSelector(\n [\n selectBridgeQuotesWithMetadata,\n (_, { sortOrder }: BridgeQuotesClientParams) => sortOrder,\n ],\n (quotesWithMetadata, sortOrder): (QuoteResponse & QuoteMetadata)[] => {\n switch (sortOrder) {\n case SortOrder.ETA_ASC:\n return orderBy(\n quotesWithMetadata,\n (quote) => quote.estimatedProcessingTimeInSeconds,\n 'asc',\n );\n default:\n return orderBy(\n quotesWithMetadata,\n ({ cost }) =>\n cost.valueInCurrency ? Number(cost.valueInCurrency) : 0,\n 'asc',\n );\n }\n },\n);\n\nconst selectRecommendedQuote = createBridgeSelector(\n [selectSortedBridgeQuotes],\n (quotes) => (quotes.length > 0 ? quotes[0] : null),\n);\n\nconst selectActiveQuote = createBridgeSelector(\n [\n selectRecommendedQuote,\n (_, { selectedQuote }: BridgeQuotesClientParams) => selectedQuote,\n ],\n (recommendedQuote, selectedQuote) => selectedQuote ?? recommendedQuote,\n);\n\nconst selectIsQuoteGoingToRefresh = createBridgeSelector(\n [\n selectBridgeFeatureFlags,\n (state) => state.quoteRequest.insufficientBal,\n (state) => state.quotesRefreshCount,\n ],\n (featureFlags, insufficientBal, quotesRefreshCount) =>\n insufficientBal ? false : featureFlags.maxRefreshCount > quotesRefreshCount,\n);\n\nconst selectQuoteRefreshRate = createBridgeSelector(\n [selectBridgeFeatureFlags, (state) => state.quoteRequest.srcChainId],\n (featureFlags, srcChainId) =>\n (srcChainId\n ? featureFlags.chains[formatChainIdToCaip(srcChainId)]?.refreshRate\n : featureFlags.refreshRate) ?? featureFlags.refreshRate,\n);\n\nexport const selectIsQuoteExpired = createBridgeSelector(\n [\n selectIsQuoteGoingToRefresh,\n ({ quotesLastFetched }) => quotesLastFetched,\n selectQuoteRefreshRate,\n (_, __, currentTimeInMs: number) => currentTimeInMs,\n ],\n (isQuoteGoingToRefresh, quotesLastFetched, refreshRate, currentTimeInMs) =>\n Boolean(\n !isQuoteGoingToRefresh &&\n quotesLastFetched &&\n currentTimeInMs - quotesLastFetched > refreshRate,\n ),\n);\n\n/**\n * Selects sorted cross-chain swap quotes. By default, the quotes are sorted by cost in ascending order.\n *\n * @param state - The state of the bridge controller and its dependency controllers\n * @param sortOrder - The sort order of the quotes\n * @param selectedQuote - The quote that is currently selected by the user, should be cleared by clients when the req params change\n * @returns The activeQuote, recommendedQuote, sortedQuotes, and other quote fetching metadata\n *\n * @example\n * ```ts\n * const quotes = useSelector(state => selectBridgeQuotes(\n * { ...state.metamask, bridgeConfig: remoteFeatureFlags.bridgeConfig },\n * {\n * sortOrder: state.bridge.sortOrder,\n * selectedQuote: state.bridge.selectedQuote,\n * }\n * ));\n * ```\n */\nexport const selectBridgeQuotes = createStructuredBridgeSelector({\n sortedQuotes: selectSortedBridgeQuotes,\n recommendedQuote: selectRecommendedQuote,\n activeQuote: selectActiveQuote,\n quotesLastFetchedMs: (state) => state.quotesLastFetched,\n isLoading: (state) => state.quotesLoadingStatus === RequestStatus.LOADING,\n quoteFetchError: (state) => state.quoteFetchError,\n quotesRefreshCount: (state) => state.quotesRefreshCount,\n quotesInitialLoadTimeMs: (state) => state.quotesInitialLoadTime,\n isQuoteGoingToRefresh: selectIsQuoteGoingToRefresh,\n});\n\nexport const selectMinimumBalanceForRentExemptionInSOL = (\n state: BridgeAppState,\n) =>\n new BigNumber(state.minimumBalanceForRentExemptionInLamports ?? 0)\n .div(10 ** 9)\n .toString();\n\nexport const selectDefaultSlippagePercentage = createBridgeSelector(\n [\n (state) => selectBridgeFeatureFlags(state).chains,\n (_, slippageParams: Parameters<typeof getDefaultSlippagePercentage>[0]) =>\n slippageParams.srcTokenAddress,\n (_, slippageParams: Parameters<typeof getDefaultSlippagePercentage>[0]) =>\n slippageParams.destTokenAddress,\n (_, slippageParams: Parameters<typeof getDefaultSlippagePercentage>[0]) =>\n slippageParams.srcChainId\n ? formatChainIdToCaip(slippageParams.srcChainId)\n : undefined,\n (_, slippageParams: Parameters<typeof getDefaultSlippagePercentage>[0]) =>\n slippageParams.destChainId\n ? formatChainIdToCaip(slippageParams.destChainId)\n : undefined,\n ],\n (\n featureFlagsByChain,\n srcTokenAddress,\n destTokenAddress,\n srcChainId,\n destChainId,\n ) => {\n return getDefaultSlippagePercentage(\n {\n srcTokenAddress,\n destTokenAddress,\n srcChainId,\n destChainId,\n },\n srcChainId ? featureFlagsByChain[srcChainId]?.stablecoins : undefined,\n destChainId ? featureFlagsByChain[destChainId]?.stablecoins : undefined,\n );\n },\n);\n"]}
1
+ {"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,wDAAuD;AAWvD,2CAAoD;AACpD,+CAAyC;AACzC,mCAAiC;AACjC,uCAGkB;AAElB,mDAAmE;AAQnE,uCAAmD;AACnD,+CAKwB;AACxB,iEAKiC;AACjC,6DAA4D;AAC5D,6CAYuB;AACvB,mDAAgE;AAsBhE;;GAEG;AACH,MAAM,8BAA8B,GAClC,mCAAyB,CAAC,SAAS,EAAkB,CAAC;AACxD;;GAEG;AACH,MAAM,oBAAoB,GAAG,yBAAe,CAAC,SAAS,EAAkB,CAAC;AASzE,MAAM,0BAA0B,GAC9B,yBAAe,CAAC,SAAS,EAAoC,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;GAoBG;AACU,QAAA,wBAAwB,GAAG,0BAA0B,CAChE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAClD,CAAC,YAAqB,EAAE,EAAE,CAAC,IAAA,mCAAmB,EAAC,YAAY,CAAC,CAC7D,CAAC;AAEF,MAAM,kCAAkC,GAAG,CACzC,mBAAgD,EAChD,OAA2C,EAC3C,UAAmD,EACrC,EAAE;IAChB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,OAAO,GAAG,IAAA,8CAA4B,EAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IAC/D,MAAM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QACvB,CAAC,CAAC,IAAA,qCAAmB,EAAC,cAAc,CAAC,UAAU,CAAC;QAChD,CAAC,CAAC,SAAS;IACf,CAAC,CAAC,EAAE,cAAkE,EAAE,EAAE,CACxE,cAAc,CAAC,WAAW;QACxB,CAAC,CAAC,IAAA,qCAAmB,EAAC,cAAc,CAAC,WAAW,CAAC;QACjD,CAAC,CAAC,SAAS;CAChB,EACD,CACE,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,EAAE;IACF,OAAO,IAAA,uCAA4B,EACjC;QACE,eAAe;QACf,gBAAgB;QAChB,UAAU;QACV,WAAW;KACZ,EACD,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,EACrE,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,CACxE,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport { AddressZero } from '@ethersproject/constants';\nimport type {\n CurrencyRateState,\n MultichainAssetsRatesControllerState,\n TokenRatesControllerState,\n} from '@metamask/assets-controllers';\nimport type {\n GasFeeEstimates,\n GasFeeEstimatesByChainId,\n} from '@metamask/gas-fee-controller';\nimport type { CaipAssetType } from '@metamask/utils';\nimport { isStrictHexString } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\nimport { orderBy } from 'lodash';\nimport {\n createSelector as createSelector_,\n createStructuredSelector as createStructuredSelector_,\n} from 'reselect';\n\nimport { BRIDGE_PREFERRED_GAS_ESTIMATE } from './constants/bridge';\nimport type {\n BridgeControllerState,\n ExchangeRate,\n GenericQuoteRequest,\n QuoteMetadata,\n QuoteResponse,\n} from './types';\nimport { RequestStatus, SortOrder } from './types';\nimport {\n getNativeAssetForChainId,\n isEvmQuoteResponse,\n isNativeAddress,\n isNonEvmChainId,\n} from './utils/bridge';\nimport {\n formatAddressToAssetId,\n formatAddressToCaipReference,\n formatChainIdToCaip,\n formatChainIdToHex,\n} from './utils/caip-formatters';\nimport { processFeatureFlags } from './utils/feature-flags';\nimport {\n calcAdjustedReturn,\n calcCost,\n calcEstimatedAndMaxTotalGasFee,\n calcIncludedTxFees,\n calcRelayerFee,\n calcSentAmount,\n calcNonEvmTotalNetworkFee,\n calcSwapRate,\n calcToAmount,\n calcTotalEstimatedNetworkFee,\n calcTotalMaxNetworkFee,\n} from './utils/quote';\nimport { getDefaultSlippagePercentage } from './utils/slippage';\n\n/**\n * The controller states that provide exchange rates\n */\ntype ExchangeRateControllerState = MultichainAssetsRatesControllerState &\n TokenRatesControllerState &\n CurrencyRateState &\n Pick<BridgeControllerState, 'assetExchangeRates'>;\n/**\n * The state of the bridge controller and all its dependency controllers\n */\ntype RemoteFeatureFlagControllerState = {\n remoteFeatureFlags: {\n bridgeConfig: unknown;\n };\n};\nexport type BridgeAppState = BridgeControllerState & {\n gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;\n} & ExchangeRateControllerState & {\n participateInMetaMetrics: boolean;\n } & RemoteFeatureFlagControllerState;\n/**\n * Creates a structured selector for the bridge controller\n */\nconst createStructuredBridgeSelector =\n createStructuredSelector_.withTypes<BridgeAppState>();\n/**\n * Creates a typed selector for the bridge controller\n */\nconst createBridgeSelector = createSelector_.withTypes<BridgeAppState>();\n/**\n * Required parameters that clients must provide for the bridge quotes selector\n */\ntype BridgeQuotesClientParams = {\n sortOrder: SortOrder;\n selectedQuote: (QuoteResponse & QuoteMetadata) | null;\n};\n\nconst createFeatureFlagsSelector =\n createSelector_.withTypes<RemoteFeatureFlagControllerState>();\n\n/**\n * Selects the bridge feature flags\n *\n * @param state - The state of the bridge controller\n * @returns The bridge feature flags\n *\n * @example\n * ```ts\n * const featureFlags = useSelector(state => selectBridgeFeatureFlags(state));\n *\n * Or\n *\n * export const selectBridgeFeatureFlags = createSelector(\n * selectRemoteFeatureFlags,\n * (remoteFeatureFlags) =>\n * selectBridgeFeatureFlagsBase({\n * bridgeConfig: remoteFeatureFlags.bridgeConfig,\n * }),\n * );\n * ```\n */\nexport const selectBridgeFeatureFlags = createFeatureFlagsSelector(\n [(state) => state.remoteFeatureFlags.bridgeConfig],\n (bridgeConfig: unknown) => processFeatureFlags(bridgeConfig),\n);\n\nconst getExchangeRateByChainIdAndAddress = (\n exchangeRateSources: ExchangeRateControllerState,\n chainId?: GenericQuoteRequest['srcChainId'],\n rawAddress?: GenericQuoteRequest['srcTokenAddress'],\n): ExchangeRate => {\n if (!chainId) {\n return {};\n }\n const address = formatAddressToCaipReference(rawAddress ?? '');\n const assetId = formatAddressToAssetId(address, chainId);\n if (!assetId) {\n return {};\n }\n\n const { assetExchangeRates, currencyRates, marketData, conversionRates } =\n exchangeRateSources;\n\n // If the asset exchange rate is available in the bridge controller, use it\n // This is defined if the token's rate is not available from the assets controllers\n const bridgeControllerRate =\n assetExchangeRates?.[assetId.toLowerCase() as CaipAssetType] ??\n assetExchangeRates?.[assetId];\n if (\n bridgeControllerRate?.exchangeRate &&\n bridgeControllerRate?.usdExchangeRate\n ) {\n return bridgeControllerRate;\n }\n // If the chain is a non-EVM chain, use the conversion rate from the multichain assets controller\n if (isNonEvmChainId(chainId)) {\n const multichainAssetExchangeRate = conversionRates?.[assetId];\n if (multichainAssetExchangeRate) {\n return {\n exchangeRate: multichainAssetExchangeRate.rate,\n usdExchangeRate: undefined,\n };\n }\n return {};\n }\n // If the chain is an EVM chain, use the conversion rate from the currency rates controller\n if (isNativeAddress(address)) {\n const { symbol } = getNativeAssetForChainId(chainId);\n const evmNativeExchangeRate = currencyRates?.[symbol];\n if (evmNativeExchangeRate) {\n return {\n exchangeRate: evmNativeExchangeRate?.conversionRate?.toString(),\n usdExchangeRate: evmNativeExchangeRate?.usdConversionRate?.toString(),\n };\n }\n return {};\n }\n // If the chain is an EVM chain and the asset is not the native asset, use the conversion rate from the token rates controller\n if (!isNonEvmChainId(chainId)) {\n const evmTokenExchangeRates = marketData?.[formatChainIdToHex(chainId)];\n const evmTokenExchangeRateForAddress = isStrictHexString(address)\n ? evmTokenExchangeRates?.[address]\n : null;\n const nativeCurrencyRate = evmTokenExchangeRateForAddress\n ? currencyRates[evmTokenExchangeRateForAddress?.currency]\n : undefined;\n if (evmTokenExchangeRateForAddress && nativeCurrencyRate) {\n return {\n exchangeRate: new BigNumber(evmTokenExchangeRateForAddress.price)\n .multipliedBy(nativeCurrencyRate.conversionRate ?? 0)\n .toString(),\n usdExchangeRate: new BigNumber(evmTokenExchangeRateForAddress.price)\n .multipliedBy(nativeCurrencyRate.usdConversionRate ?? 0)\n .toString(),\n };\n }\n }\n\n return {};\n};\n\n/**\n * Selects the asset exchange rate for a given chain and address\n *\n * @param state The state of the bridge controller and its dependency controllers\n * @param chainId The chain ID of the asset\n * @param address The address of the asset\n * @returns The asset exchange rate for the given chain and address\n */\nexport const selectExchangeRateByChainIdAndAddress = (\n state: BridgeAppState,\n chainId?: GenericQuoteRequest['srcChainId'],\n address?: GenericQuoteRequest['srcTokenAddress'],\n) => {\n return getExchangeRateByChainIdAndAddress(state, chainId, address);\n};\n\n/**\n * Checks whether an exchange rate is available for a given chain and address\n *\n * @param params The parameters to pass to {@link getExchangeRateByChainIdAndAddress}\n * @returns Whether an exchange rate is available for the given chain and address\n */\nexport const selectIsAssetExchangeRateInState = (\n ...params: Parameters<typeof getExchangeRateByChainIdAndAddress>\n) =>\n Boolean(getExchangeRateByChainIdAndAddress(...params)?.exchangeRate) &&\n Boolean(getExchangeRateByChainIdAndAddress(...params)?.usdExchangeRate);\n\n/**\n * Selects the gas fee estimates from the gas fee controller. All potential networks\n * support EIP1559 gas fees so assume that gasFeeEstimates is of type GasFeeEstimates\n *\n * @param state - The state of the bridge controller and its dependency controllers\n * @param state.gasFeeEstimatesByChainId - gasEstimates by Hex ChainId\n * @param state.quotes - Fetched bridge/swap quotes\n * @returns The gas fee estimates in decGWEI\n */\nconst selectBridgeFeesPerGas = createBridgeSelector(\n [\n (state) => state.gasFeeEstimatesByChainId,\n (state) => state.quotes?.[0]?.quote.srcChainId,\n ],\n (gasFeeEstimatesByChainId, srcChainId) => {\n if (!srcChainId) {\n return null;\n }\n if (isNonEvmChainId(srcChainId)) {\n return null;\n }\n // @ts-expect-error - all supported networks use this type of estimates\n const gasFeeEstimates: GasFeeEstimates | undefined =\n gasFeeEstimatesByChainId?.[\n formatChainIdToHex(srcChainId) as keyof typeof gasFeeEstimatesByChainId\n ]?.gasFeeEstimates;\n if (!gasFeeEstimates) {\n return null;\n }\n return {\n estimatedBaseFeeInDecGwei: gasFeeEstimates.estimatedBaseFee,\n feePerGasInDecGwei:\n gasFeeEstimates[BRIDGE_PREFERRED_GAS_ESTIMATE]?.suggestedMaxFeePerGas,\n maxFeePerGasInDecGwei: gasFeeEstimates.high?.suggestedMaxFeePerGas,\n };\n },\n);\n\n// Selects cross-chain swap quotes including their metadata\nconst selectBridgeQuotesWithMetadata = createBridgeSelector(\n [\n ({ quotes }) => quotes,\n selectBridgeFeesPerGas,\n createBridgeSelector(\n [\n (state) => state,\n ({ quoteRequest: { srcChainId } }) => srcChainId,\n ({ quoteRequest: { srcTokenAddress } }) => srcTokenAddress,\n ],\n selectExchangeRateByChainIdAndAddress,\n ),\n createBridgeSelector(\n [\n (state) => state,\n ({ quoteRequest: { destChainId } }) => destChainId,\n ({ quoteRequest: { destTokenAddress } }) => destTokenAddress,\n ],\n selectExchangeRateByChainIdAndAddress,\n ),\n createBridgeSelector(\n [(state) => state, ({ quoteRequest: { srcChainId } }) => srcChainId],\n (state, chainId) =>\n selectExchangeRateByChainIdAndAddress(state, chainId, AddressZero),\n ),\n ],\n (\n quotes,\n bridgeFeesPerGas,\n srcTokenExchangeRate,\n destTokenExchangeRate,\n nativeExchangeRate,\n ) => {\n const newQuotes = quotes.map((quote) => {\n const sentAmount = calcSentAmount(quote.quote, srcTokenExchangeRate);\n const toTokenAmount = calcToAmount(\n quote.quote.destTokenAmount,\n quote.quote.destAsset,\n destTokenExchangeRate,\n );\n const minToTokenAmount = calcToAmount(\n quote.quote.minDestTokenAmount,\n quote.quote.destAsset,\n destTokenExchangeRate,\n );\n\n const includedTxFees = calcIncludedTxFees(\n quote.quote,\n srcTokenExchangeRate,\n destTokenExchangeRate,\n );\n\n let totalEstimatedNetworkFee,\n totalMaxNetworkFee,\n relayerFee,\n gasFee: QuoteMetadata['gasFee'];\n\n if (isEvmQuoteResponse(quote)) {\n relayerFee = calcRelayerFee(quote, nativeExchangeRate);\n gasFee = calcEstimatedAndMaxTotalGasFee({\n bridgeQuote: quote,\n ...bridgeFeesPerGas,\n ...nativeExchangeRate,\n });\n // Uses effectiveGasFee to calculate the total estimated network fee\n totalEstimatedNetworkFee = calcTotalEstimatedNetworkFee(\n gasFee,\n relayerFee,\n );\n totalMaxNetworkFee = calcTotalMaxNetworkFee(gasFee, relayerFee);\n } else {\n // Use the new generic function for all non-EVM chains\n totalEstimatedNetworkFee = calcNonEvmTotalNetworkFee(\n quote,\n nativeExchangeRate,\n );\n gasFee = {\n effective: totalEstimatedNetworkFee,\n total: totalEstimatedNetworkFee,\n max: totalEstimatedNetworkFee,\n };\n totalMaxNetworkFee = totalEstimatedNetworkFee;\n }\n\n const adjustedReturn = calcAdjustedReturn(\n toTokenAmount,\n totalEstimatedNetworkFee,\n quote.quote,\n );\n const cost = calcCost(adjustedReturn, sentAmount);\n\n return {\n ...quote,\n // QuoteMetadata fields\n sentAmount,\n toTokenAmount,\n minToTokenAmount,\n swapRate: calcSwapRate(sentAmount.amount, toTokenAmount.amount),\n /**\n This is the amount required to submit the transactions\n Includes the relayer fee or other native fees\n Should be used for balance checks and tx submission.\n */\n totalNetworkFee: totalEstimatedNetworkFee,\n totalMaxNetworkFee,\n /**\n This contains gas fee estimates for the bridge transaction\n Does not include the relayer fee (if needed), just the gasLimit and effectiveGas returned by the bridge API\n Should only be used for display purposes.\n */\n gasFee,\n adjustedReturn,\n cost,\n includedTxFees,\n };\n });\n\n return newQuotes;\n },\n);\n\nconst selectSortedBridgeQuotes = createBridgeSelector(\n [\n selectBridgeQuotesWithMetadata,\n (_, { sortOrder }: BridgeQuotesClientParams) => sortOrder,\n ],\n (quotesWithMetadata, sortOrder): (QuoteResponse & QuoteMetadata)[] => {\n switch (sortOrder) {\n case SortOrder.ETA_ASC:\n return orderBy(\n quotesWithMetadata,\n (quote) => quote.estimatedProcessingTimeInSeconds,\n 'asc',\n );\n default:\n if (quotesWithMetadata.every((quote) => quote.cost.valueInCurrency)) {\n return orderBy(\n quotesWithMetadata,\n ({ cost }) => Number(cost.valueInCurrency),\n 'asc',\n );\n }\n if (\n quotesWithMetadata.every(\n (quote) => quote.quote.priceData?.priceImpact,\n )\n ) {\n return orderBy(\n quotesWithMetadata,\n ({ quote }) => Number(quote.priceData?.priceImpact),\n 'asc',\n );\n }\n return orderBy(\n quotesWithMetadata,\n ({ quote }) => Number(quote.destTokenAmount),\n 'desc',\n );\n }\n },\n);\n\nconst selectRecommendedQuote = createBridgeSelector(\n [selectSortedBridgeQuotes],\n (quotes) => (quotes.length > 0 ? quotes[0] : null),\n);\n\nconst selectActiveQuote = createBridgeSelector(\n [\n selectRecommendedQuote,\n (_, { selectedQuote }: BridgeQuotesClientParams) => selectedQuote,\n ],\n (recommendedQuote, selectedQuote) => selectedQuote ?? recommendedQuote,\n);\n\nconst selectIsQuoteGoingToRefresh = createBridgeSelector(\n [\n selectBridgeFeatureFlags,\n (state) => state.quoteRequest.insufficientBal,\n (state) => state.quotesRefreshCount,\n ],\n (featureFlags, insufficientBal, quotesRefreshCount) =>\n insufficientBal ? false : featureFlags.maxRefreshCount > quotesRefreshCount,\n);\n\nconst selectQuoteRefreshRate = createBridgeSelector(\n [selectBridgeFeatureFlags, (state) => state.quoteRequest.srcChainId],\n (featureFlags, srcChainId) =>\n (srcChainId\n ? featureFlags.chains[formatChainIdToCaip(srcChainId)]?.refreshRate\n : featureFlags.refreshRate) ?? featureFlags.refreshRate,\n);\n\nexport const selectIsQuoteExpired = createBridgeSelector(\n [\n selectIsQuoteGoingToRefresh,\n ({ quotesLastFetched }) => quotesLastFetched,\n selectQuoteRefreshRate,\n (_, _ignoredParam, currentTimeInMs: number) => currentTimeInMs,\n ],\n (isQuoteGoingToRefresh, quotesLastFetched, refreshRate, currentTimeInMs) =>\n Boolean(\n !isQuoteGoingToRefresh &&\n quotesLastFetched &&\n currentTimeInMs - quotesLastFetched > refreshRate,\n ),\n);\n\n/**\n * Selects sorted cross-chain swap quotes. By default, the quotes are sorted by cost in ascending order.\n *\n * @param state - The state of the bridge controller and its dependency controllers\n * @param sortOrder - The sort order of the quotes\n * @param selectedQuote - The quote that is currently selected by the user, should be cleared by clients when the req params change\n * @returns The activeQuote, recommendedQuote, sortedQuotes, and other quote fetching metadata\n *\n * @example\n * ```ts\n * const quotes = useSelector(state => selectBridgeQuotes(\n * { ...state.metamask, bridgeConfig: remoteFeatureFlags.bridgeConfig },\n * {\n * sortOrder: state.bridge.sortOrder,\n * selectedQuote: state.bridge.selectedQuote,\n * }\n * ));\n * ```\n */\nexport const selectBridgeQuotes = createStructuredBridgeSelector({\n sortedQuotes: selectSortedBridgeQuotes,\n recommendedQuote: selectRecommendedQuote,\n activeQuote: selectActiveQuote,\n quotesLastFetchedMs: (state) => state.quotesLastFetched,\n isLoading: (state) => state.quotesLoadingStatus === RequestStatus.LOADING,\n quoteFetchError: (state) => state.quoteFetchError,\n quotesRefreshCount: (state) => state.quotesRefreshCount,\n quotesInitialLoadTimeMs: (state) => state.quotesInitialLoadTime,\n isQuoteGoingToRefresh: selectIsQuoteGoingToRefresh,\n});\n\nexport const selectMinimumBalanceForRentExemptionInSOL = (\n state: BridgeAppState,\n) =>\n new BigNumber(state.minimumBalanceForRentExemptionInLamports ?? 0)\n .div(10 ** 9)\n .toString();\n\nexport const selectDefaultSlippagePercentage = createBridgeSelector(\n [\n (state) => selectBridgeFeatureFlags(state).chains,\n (_, slippageParams: Parameters<typeof getDefaultSlippagePercentage>[0]) =>\n slippageParams.srcTokenAddress,\n (_, slippageParams: Parameters<typeof getDefaultSlippagePercentage>[0]) =>\n slippageParams.destTokenAddress,\n (_, slippageParams: Parameters<typeof getDefaultSlippagePercentage>[0]) =>\n slippageParams.srcChainId\n ? formatChainIdToCaip(slippageParams.srcChainId)\n : undefined,\n (_, slippageParams: Parameters<typeof getDefaultSlippagePercentage>[0]) =>\n slippageParams.destChainId\n ? formatChainIdToCaip(slippageParams.destChainId)\n : undefined,\n ],\n (\n featureFlagsByChain,\n srcTokenAddress,\n destTokenAddress,\n srcChainId,\n destChainId,\n ) => {\n return getDefaultSlippagePercentage(\n {\n srcTokenAddress,\n destTokenAddress,\n srcChainId,\n destChainId,\n },\n srcChainId ? featureFlagsByChain[srcChainId]?.stablecoins : undefined,\n destChainId ? featureFlagsByChain[destChainId]?.stablecoins : undefined,\n );\n },\n);\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { CurrencyRateState, MultichainAssetsRatesControllerState, TokenRatesControllerState } from "@metamask/assets-controllers";
2
- import type { GasFeeEstimates } from "@metamask/gas-fee-controller";
2
+ import type { GasFeeEstimatesByChainId } from "@metamask/gas-fee-controller";
3
3
  import type { BridgeControllerState, ExchangeRate, GenericQuoteRequest, QuoteMetadata, QuoteResponse } from "./types.cjs";
4
4
  import { SortOrder } from "./types.cjs";
5
5
  import { getDefaultSlippagePercentage } from "./utils/slippage.cjs";
@@ -16,7 +16,7 @@ type RemoteFeatureFlagControllerState = {
16
16
  };
17
17
  };
18
18
  export type BridgeAppState = BridgeControllerState & {
19
- gasFeeEstimates: GasFeeEstimates;
19
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
20
20
  } & ExchangeRateControllerState & {
21
21
  participateInMetaMetrics: boolean;
22
22
  } & RemoteFeatureFlagControllerState;
@@ -248,12 +248,12 @@ export declare const selectExchangeRateByChainIdAndAddress: (state: BridgeAppSta
248
248
  * @param params The parameters to pass to {@link getExchangeRateByChainIdAndAddress}
249
249
  * @returns Whether an exchange rate is available for the given chain and address
250
250
  */
251
- export declare const selectIsAssetExchangeRateInState: (exchangeRateSources: ExchangeRateControllerState, chainId?: string | number | undefined, address?: string | undefined) => boolean;
251
+ export declare const selectIsAssetExchangeRateInState: (exchangeRateSources: ExchangeRateControllerState, chainId?: string | number | undefined, rawAddress?: string | undefined) => boolean;
252
252
  export declare const selectIsQuoteExpired: ((state: RemoteFeatureFlagControllerState & BridgeControllerState & {
253
- gasFeeEstimates: GasFeeEstimates;
253
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
254
254
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
255
255
  participateInMetaMetrics: boolean;
256
- }, __: any, currentTimeInMs: number) => boolean) & {
256
+ }, _ignoredParam: any, currentTimeInMs: number) => boolean) & {
257
257
  clearCache: () => void;
258
258
  resultsCount: () => number;
259
259
  resetResultsCount: () => void;
@@ -266,7 +266,7 @@ export declare const selectIsQuoteExpired: ((state: RemoteFeatureFlagControllerS
266
266
  };
267
267
  lastResult: () => boolean;
268
268
  dependencies: [((state: RemoteFeatureFlagControllerState & BridgeControllerState & {
269
- gasFeeEstimates: GasFeeEstimates;
269
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
270
270
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
271
271
  participateInMetaMetrics: boolean;
272
272
  }) => boolean) & {
@@ -556,7 +556,7 @@ export declare const selectIsQuoteExpired: ((state: RemoteFeatureFlagControllerS
556
556
  memoize: typeof import("reselect").weakMapMemoize;
557
557
  argsMemoize: typeof import("reselect").weakMapMemoize;
558
558
  }, ({ quotesLastFetched }: BridgeAppState) => number | null, ((state: RemoteFeatureFlagControllerState & BridgeControllerState & {
559
- gasFeeEstimates: GasFeeEstimates;
559
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
560
560
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
561
561
  participateInMetaMetrics: boolean;
562
562
  }) => number) & {
@@ -845,7 +845,7 @@ export declare const selectIsQuoteExpired: ((state: RemoteFeatureFlagControllerS
845
845
  } & {
846
846
  memoize: typeof import("reselect").weakMapMemoize;
847
847
  argsMemoize: typeof import("reselect").weakMapMemoize;
848
- }, (_: BridgeAppState, __: any, currentTimeInMs: number) => number];
848
+ }, (_: BridgeAppState, _ignoredParam: any, currentTimeInMs: number) => number];
849
849
  recomputations: () => number;
850
850
  resetRecomputations: () => void;
851
851
  dependencyRecomputations: () => number;
@@ -874,7 +874,7 @@ export declare const selectIsQuoteExpired: ((state: RemoteFeatureFlagControllerS
874
874
  * ```
875
875
  */
876
876
  export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
877
- gasFeeEstimates: GasFeeEstimates;
877
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
878
878
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
879
879
  participateInMetaMetrics: boolean;
880
880
  } & RemoteFeatureFlagControllerState, params_0: BridgeQuotesClientParams) => {
@@ -5322,7 +5322,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
5322
5322
  isQuoteGoingToRefresh: boolean;
5323
5323
  };
5324
5324
  dependencies: [(state: BridgeAppState) => string | null, (state: BridgeAppState) => number, ((state: BridgeControllerState & {
5325
- gasFeeEstimates: GasFeeEstimates;
5325
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
5326
5326
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
5327
5327
  participateInMetaMetrics: boolean;
5328
5328
  } & RemoteFeatureFlagControllerState, params_0: BridgeQuotesClientParams) => ({
@@ -6826,7 +6826,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
6826
6826
  } | undefined;
6827
6827
  } & QuoteMetadata)[];
6828
6828
  dependencies: [((state: BridgeControllerState & {
6829
- gasFeeEstimates: GasFeeEstimates;
6829
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
6830
6830
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
6831
6831
  participateInMetaMetrics: boolean;
6832
6832
  } & RemoteFeatureFlagControllerState) => {
@@ -7338,7 +7338,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
7338
7338
  estimatedBaseFeeInDecGwei: string;
7339
7339
  feePerGasInDecGwei: string;
7340
7340
  maxFeePerGasInDecGwei: string;
7341
- }, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
7341
+ } | null, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
7342
7342
  sentAmount: {
7343
7343
  amount: string;
7344
7344
  valueInCurrency: string | null;
@@ -7843,7 +7843,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
7843
7843
  estimatedBaseFeeInDecGwei: string;
7844
7844
  feePerGasInDecGwei: string;
7845
7845
  maxFeePerGasInDecGwei: string;
7846
- }, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
7846
+ } | null, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
7847
7847
  sentAmount: {
7848
7848
  amount: string;
7849
7849
  valueInCurrency: string | null;
@@ -8606,28 +8606,28 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
8606
8606
  effectiveGas?: number | undefined;
8607
8607
  } | undefined;
8608
8608
  } & import("./types.cjs").L1GasFees & import("./types.cjs").NonEvmFees)[], ((state: BridgeControllerState & {
8609
- gasFeeEstimates: GasFeeEstimates;
8609
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
8610
8610
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
8611
8611
  participateInMetaMetrics: boolean;
8612
8612
  } & RemoteFeatureFlagControllerState) => {
8613
8613
  estimatedBaseFeeInDecGwei: string;
8614
8614
  feePerGasInDecGwei: string;
8615
8615
  maxFeePerGasInDecGwei: string;
8616
- }) & {
8616
+ } | null) & {
8617
8617
  clearCache: () => void;
8618
8618
  resultsCount: () => number;
8619
8619
  resetResultsCount: () => void;
8620
8620
  } & {
8621
- resultFunc: (resultFuncArgs_0: string, resultFuncArgs_1: string, resultFuncArgs_2: string) => {
8621
+ resultFunc: (resultFuncArgs_0: GasFeeEstimatesByChainId, resultFuncArgs_1: number) => {
8622
8622
  estimatedBaseFeeInDecGwei: string;
8623
8623
  feePerGasInDecGwei: string;
8624
8624
  maxFeePerGasInDecGwei: string;
8625
- };
8626
- memoizedResultFunc: ((resultFuncArgs_0: string, resultFuncArgs_1: string, resultFuncArgs_2: string) => {
8625
+ } | null;
8626
+ memoizedResultFunc: ((resultFuncArgs_0: GasFeeEstimatesByChainId, resultFuncArgs_1: number) => {
8627
8627
  estimatedBaseFeeInDecGwei: string;
8628
8628
  feePerGasInDecGwei: string;
8629
8629
  maxFeePerGasInDecGwei: string;
8630
- }) & {
8630
+ } | null) & {
8631
8631
  clearCache: () => void;
8632
8632
  resultsCount: () => number;
8633
8633
  resetResultsCount: () => void;
@@ -8636,8 +8636,8 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
8636
8636
  estimatedBaseFeeInDecGwei: string;
8637
8637
  feePerGasInDecGwei: string;
8638
8638
  maxFeePerGasInDecGwei: string;
8639
- };
8640
- dependencies: [({ gasFeeEstimates }: BridgeAppState) => string, ({ gasFeeEstimates }: BridgeAppState) => string, ({ gasFeeEstimates }: BridgeAppState) => string];
8639
+ } | null;
8640
+ dependencies: [(state: BridgeAppState) => GasFeeEstimatesByChainId, (state: BridgeAppState) => number];
8641
8641
  recomputations: () => number;
8642
8642
  resetRecomputations: () => void;
8643
8643
  dependencyRecomputations: () => number;
@@ -8646,7 +8646,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
8646
8646
  memoize: typeof import("reselect").weakMapMemoize;
8647
8647
  argsMemoize: typeof import("reselect").weakMapMemoize;
8648
8648
  }, ((state: BridgeControllerState & {
8649
- gasFeeEstimates: GasFeeEstimates;
8649
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
8650
8650
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
8651
8651
  participateInMetaMetrics: boolean;
8652
8652
  } & RemoteFeatureFlagControllerState) => ExchangeRate) & {
@@ -8670,7 +8670,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
8670
8670
  memoize: typeof import("reselect").weakMapMemoize;
8671
8671
  argsMemoize: typeof import("reselect").weakMapMemoize;
8672
8672
  }, ((state: BridgeControllerState & {
8673
- gasFeeEstimates: GasFeeEstimates;
8673
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
8674
8674
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
8675
8675
  participateInMetaMetrics: boolean;
8676
8676
  } & RemoteFeatureFlagControllerState) => ExchangeRate) & {
@@ -8694,7 +8694,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
8694
8694
  memoize: typeof import("reselect").weakMapMemoize;
8695
8695
  argsMemoize: typeof import("reselect").weakMapMemoize;
8696
8696
  }, ((state: BridgeControllerState & {
8697
- gasFeeEstimates: GasFeeEstimates;
8697
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
8698
8698
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
8699
8699
  participateInMetaMetrics: boolean;
8700
8700
  } & RemoteFeatureFlagControllerState) => ExchangeRate) & {
@@ -8734,7 +8734,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
8734
8734
  memoize: typeof import("reselect").weakMapMemoize;
8735
8735
  argsMemoize: typeof import("reselect").weakMapMemoize;
8736
8736
  }, ((state: BridgeControllerState & {
8737
- gasFeeEstimates: GasFeeEstimates;
8737
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
8738
8738
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
8739
8739
  participateInMetaMetrics: boolean;
8740
8740
  } & RemoteFeatureFlagControllerState, params_0: BridgeQuotesClientParams) => ({
@@ -10214,7 +10214,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
10214
10214
  } | undefined;
10215
10215
  } & QuoteMetadata) | null;
10216
10216
  dependencies: [((state: BridgeControllerState & {
10217
- gasFeeEstimates: GasFeeEstimates;
10217
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
10218
10218
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
10219
10219
  participateInMetaMetrics: boolean;
10220
10220
  } & RemoteFeatureFlagControllerState, params_0: BridgeQuotesClientParams) => ({
@@ -11718,7 +11718,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
11718
11718
  } | undefined;
11719
11719
  } & QuoteMetadata)[];
11720
11720
  dependencies: [((state: BridgeControllerState & {
11721
- gasFeeEstimates: GasFeeEstimates;
11721
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
11722
11722
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
11723
11723
  participateInMetaMetrics: boolean;
11724
11724
  } & RemoteFeatureFlagControllerState) => {
@@ -12230,7 +12230,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
12230
12230
  estimatedBaseFeeInDecGwei: string;
12231
12231
  feePerGasInDecGwei: string;
12232
12232
  maxFeePerGasInDecGwei: string;
12233
- }, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
12233
+ } | null, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
12234
12234
  sentAmount: {
12235
12235
  amount: string;
12236
12236
  valueInCurrency: string | null;
@@ -12735,7 +12735,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
12735
12735
  estimatedBaseFeeInDecGwei: string;
12736
12736
  feePerGasInDecGwei: string;
12737
12737
  maxFeePerGasInDecGwei: string;
12738
- }, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
12738
+ } | null, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
12739
12739
  sentAmount: {
12740
12740
  amount: string;
12741
12741
  valueInCurrency: string | null;
@@ -13498,28 +13498,28 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
13498
13498
  effectiveGas?: number | undefined;
13499
13499
  } | undefined;
13500
13500
  } & import("./types.cjs").L1GasFees & import("./types.cjs").NonEvmFees)[], ((state: BridgeControllerState & {
13501
- gasFeeEstimates: GasFeeEstimates;
13501
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
13502
13502
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
13503
13503
  participateInMetaMetrics: boolean;
13504
13504
  } & RemoteFeatureFlagControllerState) => {
13505
13505
  estimatedBaseFeeInDecGwei: string;
13506
13506
  feePerGasInDecGwei: string;
13507
13507
  maxFeePerGasInDecGwei: string;
13508
- }) & {
13508
+ } | null) & {
13509
13509
  clearCache: () => void;
13510
13510
  resultsCount: () => number;
13511
13511
  resetResultsCount: () => void;
13512
13512
  } & {
13513
- resultFunc: (resultFuncArgs_0: string, resultFuncArgs_1: string, resultFuncArgs_2: string) => {
13513
+ resultFunc: (resultFuncArgs_0: GasFeeEstimatesByChainId, resultFuncArgs_1: number) => {
13514
13514
  estimatedBaseFeeInDecGwei: string;
13515
13515
  feePerGasInDecGwei: string;
13516
13516
  maxFeePerGasInDecGwei: string;
13517
- };
13518
- memoizedResultFunc: ((resultFuncArgs_0: string, resultFuncArgs_1: string, resultFuncArgs_2: string) => {
13517
+ } | null;
13518
+ memoizedResultFunc: ((resultFuncArgs_0: GasFeeEstimatesByChainId, resultFuncArgs_1: number) => {
13519
13519
  estimatedBaseFeeInDecGwei: string;
13520
13520
  feePerGasInDecGwei: string;
13521
13521
  maxFeePerGasInDecGwei: string;
13522
- }) & {
13522
+ } | null) & {
13523
13523
  clearCache: () => void;
13524
13524
  resultsCount: () => number;
13525
13525
  resetResultsCount: () => void;
@@ -13528,8 +13528,8 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
13528
13528
  estimatedBaseFeeInDecGwei: string;
13529
13529
  feePerGasInDecGwei: string;
13530
13530
  maxFeePerGasInDecGwei: string;
13531
- };
13532
- dependencies: [({ gasFeeEstimates }: BridgeAppState) => string, ({ gasFeeEstimates }: BridgeAppState) => string, ({ gasFeeEstimates }: BridgeAppState) => string];
13531
+ } | null;
13532
+ dependencies: [(state: BridgeAppState) => GasFeeEstimatesByChainId, (state: BridgeAppState) => number];
13533
13533
  recomputations: () => number;
13534
13534
  resetRecomputations: () => void;
13535
13535
  dependencyRecomputations: () => number;
@@ -13538,7 +13538,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
13538
13538
  memoize: typeof import("reselect").weakMapMemoize;
13539
13539
  argsMemoize: typeof import("reselect").weakMapMemoize;
13540
13540
  }, ((state: BridgeControllerState & {
13541
- gasFeeEstimates: GasFeeEstimates;
13541
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
13542
13542
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
13543
13543
  participateInMetaMetrics: boolean;
13544
13544
  } & RemoteFeatureFlagControllerState) => ExchangeRate) & {
@@ -13562,7 +13562,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
13562
13562
  memoize: typeof import("reselect").weakMapMemoize;
13563
13563
  argsMemoize: typeof import("reselect").weakMapMemoize;
13564
13564
  }, ((state: BridgeControllerState & {
13565
- gasFeeEstimates: GasFeeEstimates;
13565
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
13566
13566
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
13567
13567
  participateInMetaMetrics: boolean;
13568
13568
  } & RemoteFeatureFlagControllerState) => ExchangeRate) & {
@@ -13586,7 +13586,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
13586
13586
  memoize: typeof import("reselect").weakMapMemoize;
13587
13587
  argsMemoize: typeof import("reselect").weakMapMemoize;
13588
13588
  }, ((state: BridgeControllerState & {
13589
- gasFeeEstimates: GasFeeEstimates;
13589
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
13590
13590
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
13591
13591
  participateInMetaMetrics: boolean;
13592
13592
  } & RemoteFeatureFlagControllerState) => ExchangeRate) & {
@@ -13634,7 +13634,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
13634
13634
  memoize: typeof import("reselect").weakMapMemoize;
13635
13635
  argsMemoize: typeof import("reselect").weakMapMemoize;
13636
13636
  }, ((state: BridgeControllerState & {
13637
- gasFeeEstimates: GasFeeEstimates;
13637
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
13638
13638
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
13639
13639
  participateInMetaMetrics: boolean;
13640
13640
  } & RemoteFeatureFlagControllerState, params_0: BridgeQuotesClientParams) => ({
@@ -15602,7 +15602,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
15602
15602
  } | undefined;
15603
15603
  } & QuoteMetadata) | null;
15604
15604
  dependencies: [((state: BridgeControllerState & {
15605
- gasFeeEstimates: GasFeeEstimates;
15605
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
15606
15606
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
15607
15607
  participateInMetaMetrics: boolean;
15608
15608
  } & RemoteFeatureFlagControllerState, params_0: BridgeQuotesClientParams) => ({
@@ -17082,7 +17082,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
17082
17082
  } | undefined;
17083
17083
  } & QuoteMetadata) | null;
17084
17084
  dependencies: [((state: BridgeControllerState & {
17085
- gasFeeEstimates: GasFeeEstimates;
17085
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
17086
17086
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
17087
17087
  participateInMetaMetrics: boolean;
17088
17088
  } & RemoteFeatureFlagControllerState, params_0: BridgeQuotesClientParams) => ({
@@ -18586,7 +18586,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
18586
18586
  } | undefined;
18587
18587
  } & QuoteMetadata)[];
18588
18588
  dependencies: [((state: BridgeControllerState & {
18589
- gasFeeEstimates: GasFeeEstimates;
18589
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
18590
18590
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
18591
18591
  participateInMetaMetrics: boolean;
18592
18592
  } & RemoteFeatureFlagControllerState) => {
@@ -19098,7 +19098,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
19098
19098
  estimatedBaseFeeInDecGwei: string;
19099
19099
  feePerGasInDecGwei: string;
19100
19100
  maxFeePerGasInDecGwei: string;
19101
- }, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
19101
+ } | null, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
19102
19102
  sentAmount: {
19103
19103
  amount: string;
19104
19104
  valueInCurrency: string | null;
@@ -19603,7 +19603,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
19603
19603
  estimatedBaseFeeInDecGwei: string;
19604
19604
  feePerGasInDecGwei: string;
19605
19605
  maxFeePerGasInDecGwei: string;
19606
- }, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
19606
+ } | null, resultFuncArgs_2: ExchangeRate, resultFuncArgs_3: ExchangeRate, resultFuncArgs_4: ExchangeRate) => {
19607
19607
  sentAmount: {
19608
19608
  amount: string;
19609
19609
  valueInCurrency: string | null;
@@ -20366,28 +20366,28 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
20366
20366
  effectiveGas?: number | undefined;
20367
20367
  } | undefined;
20368
20368
  } & import("./types.cjs").L1GasFees & import("./types.cjs").NonEvmFees)[], ((state: BridgeControllerState & {
20369
- gasFeeEstimates: GasFeeEstimates;
20369
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
20370
20370
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
20371
20371
  participateInMetaMetrics: boolean;
20372
20372
  } & RemoteFeatureFlagControllerState) => {
20373
20373
  estimatedBaseFeeInDecGwei: string;
20374
20374
  feePerGasInDecGwei: string;
20375
20375
  maxFeePerGasInDecGwei: string;
20376
- }) & {
20376
+ } | null) & {
20377
20377
  clearCache: () => void;
20378
20378
  resultsCount: () => number;
20379
20379
  resetResultsCount: () => void;
20380
20380
  } & {
20381
- resultFunc: (resultFuncArgs_0: string, resultFuncArgs_1: string, resultFuncArgs_2: string) => {
20381
+ resultFunc: (resultFuncArgs_0: GasFeeEstimatesByChainId, resultFuncArgs_1: number) => {
20382
20382
  estimatedBaseFeeInDecGwei: string;
20383
20383
  feePerGasInDecGwei: string;
20384
20384
  maxFeePerGasInDecGwei: string;
20385
- };
20386
- memoizedResultFunc: ((resultFuncArgs_0: string, resultFuncArgs_1: string, resultFuncArgs_2: string) => {
20385
+ } | null;
20386
+ memoizedResultFunc: ((resultFuncArgs_0: GasFeeEstimatesByChainId, resultFuncArgs_1: number) => {
20387
20387
  estimatedBaseFeeInDecGwei: string;
20388
20388
  feePerGasInDecGwei: string;
20389
20389
  maxFeePerGasInDecGwei: string;
20390
- }) & {
20390
+ } | null) & {
20391
20391
  clearCache: () => void;
20392
20392
  resultsCount: () => number;
20393
20393
  resetResultsCount: () => void;
@@ -20396,8 +20396,8 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
20396
20396
  estimatedBaseFeeInDecGwei: string;
20397
20397
  feePerGasInDecGwei: string;
20398
20398
  maxFeePerGasInDecGwei: string;
20399
- };
20400
- dependencies: [({ gasFeeEstimates }: BridgeAppState) => string, ({ gasFeeEstimates }: BridgeAppState) => string, ({ gasFeeEstimates }: BridgeAppState) => string];
20399
+ } | null;
20400
+ dependencies: [(state: BridgeAppState) => GasFeeEstimatesByChainId, (state: BridgeAppState) => number];
20401
20401
  recomputations: () => number;
20402
20402
  resetRecomputations: () => void;
20403
20403
  dependencyRecomputations: () => number;
@@ -20406,7 +20406,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
20406
20406
  memoize: typeof import("reselect").weakMapMemoize;
20407
20407
  argsMemoize: typeof import("reselect").weakMapMemoize;
20408
20408
  }, ((state: BridgeControllerState & {
20409
- gasFeeEstimates: GasFeeEstimates;
20409
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
20410
20410
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
20411
20411
  participateInMetaMetrics: boolean;
20412
20412
  } & RemoteFeatureFlagControllerState) => ExchangeRate) & {
@@ -20430,7 +20430,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
20430
20430
  memoize: typeof import("reselect").weakMapMemoize;
20431
20431
  argsMemoize: typeof import("reselect").weakMapMemoize;
20432
20432
  }, ((state: BridgeControllerState & {
20433
- gasFeeEstimates: GasFeeEstimates;
20433
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
20434
20434
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
20435
20435
  participateInMetaMetrics: boolean;
20436
20436
  } & RemoteFeatureFlagControllerState) => ExchangeRate) & {
@@ -20454,7 +20454,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
20454
20454
  memoize: typeof import("reselect").weakMapMemoize;
20455
20455
  argsMemoize: typeof import("reselect").weakMapMemoize;
20456
20456
  }, ((state: BridgeControllerState & {
20457
- gasFeeEstimates: GasFeeEstimates;
20457
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
20458
20458
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
20459
20459
  participateInMetaMetrics: boolean;
20460
20460
  } & RemoteFeatureFlagControllerState) => ExchangeRate) & {
@@ -20754,7 +20754,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
20754
20754
  memoize: typeof import("reselect").weakMapMemoize;
20755
20755
  argsMemoize: typeof import("reselect").weakMapMemoize;
20756
20756
  }, (state: BridgeAppState) => number | null, (state: BridgeAppState) => boolean, (state: BridgeAppState) => number | null, ((state: RemoteFeatureFlagControllerState & BridgeControllerState & {
20757
- gasFeeEstimates: GasFeeEstimates;
20757
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
20758
20758
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
20759
20759
  participateInMetaMetrics: boolean;
20760
20760
  }) => boolean) & {
@@ -21054,7 +21054,7 @@ export declare const selectBridgeQuotes: ((state: BridgeControllerState & {
21054
21054
  };
21055
21055
  export declare const selectMinimumBalanceForRentExemptionInSOL: (state: BridgeAppState) => string;
21056
21056
  export declare const selectDefaultSlippagePercentage: ((state: BridgeControllerState & {
21057
- gasFeeEstimates: GasFeeEstimates;
21057
+ gasFeeEstimatesByChainId: GasFeeEstimatesByChainId;
21058
21058
  } & MultichainAssetsRatesControllerState & TokenRatesControllerState & CurrencyRateState & Pick<BridgeControllerState, "assetExchangeRates"> & {
21059
21059
  participateInMetaMetrics: boolean;
21060
21060
  } & RemoteFeatureFlagControllerState, slippageParams: Partial<Pick<GenericQuoteRequest, "srcChainId" | "destChainId" | "srcTokenAddress" | "destTokenAddress">>) => 0.5 | 2 | undefined) & {