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ack://_N_E/./helper/fetchHelper/getAllChainInfo.ts","webpack://_N_E/./helper/liquiditySelectorHelper.ts","webpack://_N_E/./hooks/globalState/useOnNetworkAccountChange.ts","webpack://_N_E/./hooks/globalState/useWarningTokens.ts","webpack://_N_E/./hooks/useCurrentChainPositions.ts","webpack://_N_E/./hooks/useFetch/useChainsWithNonEmptyPositions.ts","webpack://_N_E/./hooks/useFetchAllChainUserTriggers.ts","webpack://_N_E/./hooks/useFetchAllChainsPositions.ts","webpack://_N_E/./hooks/useFetchMarketPrice.ts","webpack://_N_E/<anon>"],"sourcesContent":["import { ApertureSupportedChainId } from \"@aperture_finance/uniswap-v3-automation-sdk\";\n\nexport async function fetchInfoForAllChains<T>(\n  chains: Iterable<number | string>,\n  fetchPositionCallback: (chainId: ApertureSupportedChainId) => Promise<T>\n): Promise<{ [chainId: number]: T }> {\n  const allInfo: { [chainId: number]: T } = {};\n  await Promise.all(\n    Array.from(chains).map(async (chainId) => {\n      const parsedChainId = parseInt(chainId.toString());\n      try {\n        allInfo[parsedChainId] = await fetchPositionCallback(\n          parsedChainId as ApertureSupportedChainId\n        );\n      } catch (e) {\n        console.error(\n          `Error: Failed to fetch data for chain ${parsedChainId}:`,\n          (e as Error).message\n        );\n      }\n    })\n  );\n  return allInfo;\n}\n","import { Pool, TickMath } from \"@aperture_finance/uniswap-v3-sdk\";\n\nexport type plusOrMinusType =\n  | \"getDecrementLower\"\n  | \"getIncrementLower\"\n  | \"getDecrementUpper\"\n  | \"getIncrementUpper\";\n\nexport function plusOrMinusTick(\n  actionType: plusOrMinusType,\n  tickLower: number | undefined | null,\n  tickUpper: number | undefined | null,\n  invert: boolean,\n  tickSpacing: number | undefined,\n  pool?: Pool | undefined | null\n) {\n  switch (actionType) {\n    case \"getDecrementLower\":\n      return invert\n        ? getNewTick(tickUpper, \"Increment\", tickSpacing, pool)\n        : getNewTick(tickLower, \"Decrement\", tickSpacing, pool);\n    case \"getIncrementLower\":\n      return invert\n        ? getNewTick(tickUpper, \"Decrement\", tickSpacing, pool)\n        : getNewTick(tickLower, \"Increment\", tickSpacing, pool);\n    case \"getDecrementUpper\":\n      return invert\n        ? getNewTick(tickLower, \"Increment\", tickSpacing, pool)\n        : getNewTick(tickUpper, \"Decrement\", tickSpacing, pool);\n    case \"getIncrementUpper\":\n      return invert\n        ? getNewTick(tickLower, \"Decrement\", tickSpacing, pool)\n        : getNewTick(tickUpper, \"Increment\", tickSpacing, pool);\n    default:\n      return null;\n  }\n}\n\nexport function getNewTick(\n  tickValue: number | undefined | null,\n  type: \"Decrement\" | \"Increment\",\n  tickSpacing: number | undefined,\n  pool?: Pool | undefined | null,\n  rangeWidth: number = 1\n) {\n  if (pool && tickSpacing) {\n    const startingTick =\n      typeof tickValue === \"number\" ? tickValue : pool.tickCurrent;\n    let newTick =\n      startingTick +\n      (type === \"Decrement\" ? -1 : 1) * tickSpacing * Math.ceil(rangeWidth / 2);\n\n    if (newTick < TickMath.MIN_TICK) newTick += tickSpacing;\n    else if (newTick > TickMath.MAX_TICK) newTick -= tickSpacing;\n\n    return newTick;\n  }\n  return null;\n}\n\nexport const TICK_MULTIPLIER = 1.0001;\n\nexport function percentageToOffsetTick(\n  percentage: number,\n  minPercentage: number,\n  maxPercentage?: number\n) {\n  percentage = Math.round(percentage * 100) / 100;\n  let target = 0;\n  if (percentage <= minPercentage) {\n    target = Math.round((100 + minPercentage) * 100) / 1e4 + 1 / 10e6;\n  } else if (maxPercentage !== undefined && percentage >= maxPercentage) {\n    target = Math.round((100 + maxPercentage) * 100) / 1e4;\n  } else {\n    target = Math.round((100 + percentage) * 100) / 1e4;\n  }\n\n  return Math.round(Math.log(target) / Math.log(TICK_MULTIPLIER));\n}\n\nexport function offsetTickToPercentage(offsetTick: number, abs?: boolean) {\n  let target = TICK_MULTIPLIER ** offsetTick * 1e4 - 1e4;\n  if (abs) {\n    target = Math.abs(target);\n  }\n  return (Math.round(target) / 100).toFixed(2);\n}\n","import { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { useEventCallback } from \"@/hooks/useEventCallback\";\nimport { useUpdateEffect } from \"ahooks\";\nimport { useEffect } from \"react\";\nimport { useAccount } from \"wagmi\";\n\nexport const useOnNetworkAccountChange = (callback: () => void) => {\n  const { address } = useAccount();\n  const { ammEnum, networkId, isChainSupported } = useNetwork();\n  const cb = useEventCallback(callback);\n  useUpdateEffect(() => {\n    cb();\n  }, [address, networkId, ammEnum]);\n\n  useEffect(() => {\n    if (!isChainSupported) {\n      cb();\n    }\n  }, [cb, isChainSupported]);\n};\n","import { useAllChainStateStore } from \"@/components/GlobalStore\";\nimport { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { getPublicClient } from \"@/helper/getPublicClient\";\nimport { viem } from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { Token } from \"@uniswap/sdk-core\";\nimport { Address } from \"viem\";\nimport { useEventCallback } from \"../useEventCallback\";\nimport { useFetchUserTokensBalance } from \"../useFetchUserTokensBalance\";\n\nexport type TMutateWarningTokens = (\n  chainId: number,\n  warningTokens: Token | Token[]\n) => Promise<void>;\n\nexport const useMutateWarningTokens = () => {\n  const { networkId } = useNetwork();\n  const { mutate: tokenBalanceMutate } = useFetchUserTokensBalance();\n  const { updateTokenMap } = useAllChainStateStore();\n\n  const mutateWarningTokens: TMutateWarningTokens = useEventCallback(\n    async (chainId, token) => {\n      const tokens = Array.isArray(token) ? token : [token];\n\n      updateTokenMap({\n        chainId: chainId,\n        tokens,\n      });\n\n      if (chainId === networkId) {\n        await tokenBalanceMutate();\n      }\n    }\n  );\n\n  const mutateWarningTokensByAddress = useEventCallback(\n    async (chainId: number, tokenAddress: Address | Address[]) => {\n      const addresses = Array.isArray(tokenAddress)\n        ? tokenAddress\n        : [tokenAddress];\n\n      const tokens = await viem.getBulkTokens(\n        addresses,\n        chainId,\n        getPublicClient(chainId),\n        undefined,\n        true\n      );\n\n      return mutateWarningTokens(chainId, tokens);\n    }\n  );\n\n  return {\n    mutateWarningTokens,\n    mutateWarningTokensByAddress,\n  };\n};\n","import { useAllChainStateStore } from \"@/components/GlobalStore\";\nimport { IRawTokenMap } from \"@/components/GlobalStore/allChain/types\";\nimport { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { sortActivePositions } from \"@/helper/positionHelper\";\nimport { AmmEnum } from \"@ui/index\";\nimport { useCallback, useEffect, useMemo } from \"react\";\nimport { Address } from \"viem\";\nimport { useAccount } from \"wagmi\";\nimport { useCurrentChainToken } from \"./globalState/useCurrentChainToken\";\nimport { useMutateWarningTokens } from \"./globalState/useWarningTokens\";\nimport { getMissingTokens } from \"./useFetchAllChainsPositions\";\n\nexport const useCurrentChainPositions = (walletAddress: Address) => {\n  const { networkId, ammEnum } = useNetwork();\n  const { currentTokenMap } = useCurrentChainToken();\n\n  const {\n    state: { activePositionMap },\n  } = useAllChainStateStore();\n\n  const currentActivePositionMap = activePositionMap[networkId];\n\n  const { positionInitializer } = usePositionInitializer();\n\n  // initialize current position map\n  useEffect(() => {\n    positionInitializer(ammEnum, networkId, walletAddress, currentTokenMap);\n  }, [networkId, ammEnum, walletAddress, positionInitializer, currentTokenMap]);\n\n  return useMemo(() => {\n    if (!currentActivePositionMap)\n      return {\n        positionMap: {},\n        positionList: [],\n        isLoading: true,\n      };\n\n    const positionList = sortActivePositions(\n      Object.values(currentActivePositionMap)\n    );\n    return {\n      positionMap: currentActivePositionMap,\n      positionList,\n      isLoading: false,\n    };\n  }, [currentActivePositionMap]);\n};\n\nexport const useMutatePositionMap = () => {\n  const { networkId, ammEnum } = useNetwork();\n  const { address: walletAddress } = useAccount();\n  const { updatePositionMap } = useAllChainStateStore();\n\n  const mutatePositionMap = useCallback(() => {\n    updatePositionMap({\n      amm: ammEnum,\n      chainId: networkId,\n      walletAddress,\n    });\n  }, [ammEnum, networkId, updatePositionMap, walletAddress]);\n\n  return {\n    mutatePositionMap,\n  };\n};\n\nexport const usePositionInitializer = () => {\n  const { mutateWarningTokensByAddress } = useMutateWarningTokens();\n  const { updatePositionMap } = useAllChainStateStore();\n\n  const positionInitializer = useCallback(\n    async (\n      amm: AmmEnum,\n      chainId: number,\n      walletAddress: Address,\n      currentTokenMap: IRawTokenMap\n    ) => {\n      if (!amm || !chainId || !walletAddress || !currentTokenMap) return;\n\n      const positionMap = await updatePositionMap({\n        amm,\n        chainId,\n        walletAddress,\n        isInitialization: true,\n      });\n\n      if (!positionMap) return; // already initialized\n\n      const missingTokenAddresses = getMissingTokens(\n        positionMap,\n        currentTokenMap\n      );\n\n      if (missingTokenAddresses.length > 0) {\n        mutateWarningTokensByAddress(chainId, missingTokenAddresses);\n      }\n    },\n    [mutateWarningTokensByAddress, updatePositionMap]\n  );\n\n  return {\n    positionInitializer,\n  };\n};\n","import { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\n\nimport { fetchInfoForAllChains } from \"@/helper/fetchHelper/getAllChainInfo\";\nimport { getNetworkId, getValidChains } from \"@/utils/networkHelper\";\nimport {\n  ApertureSupportedChainId,\n  viem,\n} from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { getAmmEnum, getSupportedChainsByAmm } from \"@ui/utils\";\nimport useSWR from \"swr/immutable\";\nimport { Address } from \"viem\";\n\nexport function useChainsWithNonEmptyPositions(walletAddress: Address) {\n  const { data, isLoading } = useFetchAllChainsNumberOfPositions(walletAddress);\n  const validChains = getValidChains();\n  const chainsWithPositions: ApertureSupportedChainId[] =\n    !isLoading && data\n      ? Object.entries(data)\n          .reduce((acc, [chainId, positionNumber]) => {\n            if (validChains.includes(parseInt(chainId)) && positionNumber > 0)\n              acc.push(parseInt(chainId));\n            return acc;\n          }, [])\n          .flat()\n      : undefined;\n  return {\n    data: chainsWithPositions,\n    isLoading: isLoading || !chainsWithPositions,\n  };\n}\n\nfunction useFetchAllChainsNumberOfPositions(walletAddress: Address) {\n  const { amm, isChainSupported } = useNetwork();\n  const showFetch = amm && walletAddress && isChainSupported;\n\n  return useSWR(\n    showFetch\n      ? `user-chains-with-positions-number-${amm.name}-${walletAddress}`\n      : null,\n    () => {\n      const chainIdsList = getSupportedChainsByAmm(amm).map((chain) =>\n        getNetworkId(chain)\n      );\n\n      return fetchInfoForAllChains(chainIdsList, async (chainId) => {\n        return viem.getNumberOfPositionsOwnedByOwner(\n          walletAddress,\n          chainId,\n          getAmmEnum(amm)\n        );\n      });\n    }\n  );\n}\n","import { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { getTriggers } from \"@/helper/triggerHelper\";\nimport {\n  ApertureSupportedChainId,\n  ListTriggerResponse,\n} from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { BasicInfo, getAmmEnum } from \"@ui/utils\";\nimport useSWR from \"swr/immutable\";\nimport { Address } from \"viem\";\nimport { useAccount } from \"wagmi\";\nimport { useChainsWithNonEmptyPositions } from \"./useFetch/useChainsWithNonEmptyPositions\";\n\nexport function useFetchAllChainUserTriggers(limitOrder?: boolean) {\n  const { address: walletAddress, isConnected } = useAccount();\n  const { amm, isChainSupported, networkId } = useNetwork();\n  const { data: chainsWithPositions } =\n    useChainsWithNonEmptyPositions(walletAddress);\n\n  const showFetch =\n    isConnected &&\n    amm &&\n    walletAddress &&\n    isChainSupported &&\n    chainsWithPositions?.length > 0;\n\n  const key = showFetch\n    ? `user-all-chains-triggers-${\n        amm.name\n      }-${walletAddress}-${chainsWithPositions.join(\"-\")}-lo:${!!limitOrder}`\n    : null;\n\n  return useSWR(\n    key,\n    async () => {\n      // First fetch current chain data\n      let initialData: { [chainId: number]: ListTriggerResponse } = {};\n\n      if (\n        networkId &&\n        chainsWithPositions?.includes(networkId as ApertureSupportedChainId)\n      ) {\n        try {\n          const currentChainTriggers = await getTriggers(\n            getAmmEnum(amm),\n            walletAddress!,\n            networkId as ApertureSupportedChainId,\n            !!limitOrder\n          );\n          initialData[networkId] = currentChainTriggers;\n        } catch (e) {\n          console.log(\n            \"Error: Failed to fetch current chain triggers \",\n            (e as Error).message\n          );\n        }\n      }\n\n      // Return current chain data immediately\n      const otherChainIds =\n        chainsWithPositions?.filter((id) => id !== networkId) ?? [];\n\n      // Fetch other chains in the background\n      getAllOtherChainTriggers(\n        amm,\n        walletAddress!,\n        otherChainIds,\n        !!limitOrder,\n        key,\n        initialData\n      );\n\n      return initialData;\n    },\n    {\n      // Keep previous data while revalidating\n      keepPreviousData: true,\n    }\n  );\n}\n\nconst getAllOtherChainTriggers = async (\n  amm: BasicInfo,\n  walletAddress: Address,\n  chainIds: ApertureSupportedChainId[],\n  isLimitOrder: boolean,\n  cacheKey: string,\n  initialData: { [chainId: number]: ListTriggerResponse }\n) => {\n  try {\n    const otherChainsData = await Promise.all(\n      chainIds.map(async (chainId) => {\n        try {\n          const triggers = await getTriggers(\n            getAmmEnum(amm),\n            walletAddress,\n            chainId,\n            isLimitOrder\n          );\n          return { chainId, triggers };\n        } catch (e) {\n          console.log(\n            \"Error: Failed to fetch triggers for chain\",\n            chainId,\n            (e as Error).message\n          );\n          return { chainId, triggers: null };\n        }\n      })\n    );\n\n    // Merge current chain data with other chains data\n    const allData = { ...initialData };\n    otherChainsData.forEach(({ chainId, triggers }) => {\n      if (triggers) {\n        allData[chainId] = triggers;\n      }\n    });\n\n    // Update the SWR cache with all data\n    if (typeof window !== \"undefined\") {\n      const { cache } = require(\"swr\");\n      cache?.set(cacheKey, allData);\n    }\n  } catch (e) {\n    console.log(\n      \"Error: Failed to fetch other chain triggers \",\n      (e as Error).message\n    );\n  }\n};\n","import { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\n\nimport { useAllChainStateStore } from \"@/components/GlobalStore\";\nimport {\n  IActivePositionMap,\n  IPositionMap,\n  IRawTokenMap,\n} from \"@/components/GlobalStore/allChain/types\";\nimport { AmmEnum } from \"@ui/utils\";\nimport { useEffect } from \"react\";\nimport { Address } from \"viem\";\nimport {\n  useCurrentChainPositions,\n  usePositionInitializer,\n} from \"./useCurrentChainPositions\";\nimport { useChainsWithNonEmptyPositions } from \"./useFetch/useChainsWithNonEmptyPositions\";\n\nexport function useFetchAllChainsPositions(walletAddress: Address): {\n  data: IActivePositionMap;\n  isLoading: boolean;\n  isAllLoaded: boolean;\n} {\n  const { ammEnum } = useNetwork();\n  const { data: chainIdList } = useChainsWithNonEmptyPositions(walletAddress);\n  const { isLoading: currentPositionLoading } =\n    useCurrentChainPositions(walletAddress);\n\n  const {\n    state: { rawAllPositionMap, rawAllTokenMap, activePositionMap },\n  } = useAllChainStateStore();\n\n  useInitializeChainPositions(ammEnum, walletAddress, !currentPositionLoading);\n\n  const allChainsPositionMap = rawAllPositionMap?.[walletAddress]?.[ammEnum];\n\n  // if confirmed no position, then don't show loading\n  const hasNoPosition = chainIdList ? chainIdList.length === 0 : false;\n  const isLoading =\n    currentPositionLoading ||\n    (!hasNoPosition && (!allChainsPositionMap || !rawAllTokenMap));\n\n  const isAllLoaded = !!chainIdList?.every(\n    (chainId) => activePositionMap?.[chainId]\n  );\n\n  return {\n    data: activePositionMap,\n    isLoading,\n    isAllLoaded,\n  };\n}\n\nconst useInitializeChainPositions = (\n  amm: AmmEnum,\n  walletAddress: Address,\n  isCriticalDataLoaded: boolean = false\n) => {\n  const {\n    state: { rawAllTokenMap },\n  } = useAllChainStateStore();\n  const { data: chainIdList } = useChainsWithNonEmptyPositions(walletAddress);\n  const { positionInitializer } = usePositionInitializer();\n\n  useEffect(() => {\n    if (\n      !amm ||\n      !walletAddress ||\n      !isCriticalDataLoaded ||\n      !rawAllTokenMap ||\n      !chainIdList\n    ) {\n      return;\n    }\n\n    chainIdList.forEach((chainId) => {\n      positionInitializer(amm, chainId, walletAddress, rawAllTokenMap[chainId]);\n    });\n  }, [\n    amm,\n    chainIdList,\n    walletAddress,\n    isCriticalDataLoaded,\n    rawAllTokenMap,\n    positionInitializer,\n  ]);\n};\n\nexport const getMissingTokens = (\n  positionMap: IPositionMap,\n  tokenMap: IRawTokenMap\n) => {\n  const missingAddresses = new Set<string>();\n\n  for (const position of Object.values(positionMap)) {\n    const { token0, token1 } = position.pool;\n    [token0.address, token1.address].forEach((address) => {\n      if (!tokenMap?.[address] && !missingAddresses.has(address)) {\n        missingAddresses.add(address);\n      }\n    });\n  }\n\n  return Array.from(missingAddresses) as Address[];\n};\n","import { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { useRpcSettings } from \"@/config/feature_flags\";\nimport { getPublicClient } from \"@/helper/getPublicClient\";\nimport { AmmEnum, SupportedFeeAmount } from \"@aperture/uikitv2\";\nimport {\n  ApertureSupportedChainId,\n  viem,\n} from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport useSWR from \"swr/immutable\";\nimport { PublicClient } from \"viem\";\n\ntype BatchRequest = {\n  tokenA: string;\n  tokenB: string;\n  poolKeys: number[];\n};\n\ntype BatchResult = Record<string, { tokenA: string; tokenB: string }>;\n\nexport function useFetchCurrentChainMarketPrice(\n  tokenAAddress: string | null,\n  tokenBAddress: string | null,\n  poolKeys: number[] = [],\n  isSupported: boolean = true\n) {\n  const { ammEnum, networkId, publicClient } = useNetwork();\n  if (ammEnum !== \"SLIPSTREAM\") {\n    poolKeys = SupportedFeeAmount[ammEnum];\n  }\n  const shouldFetch =\n    tokenAAddress &&\n    tokenBAddress &&\n    ammEnum &&\n    isSupported &&\n    networkId === publicClient.chain?.id;\n\n  return useSWR(\n    shouldFetch\n      ? `tokens-market-price-${ammEnum}-${networkId}-${tokenAAddress}-${tokenBAddress}`\n      : null,\n    () =>\n      getFetchMarketPrice(\n        ammEnum,\n        networkId,\n        tokenAAddress!,\n        tokenBAddress!,\n        poolKeys,\n        publicClient\n      ),\n    { refreshInterval: 30_000 }\n  );\n}\n\nexport function useFetchMarketPrice(\n  ammEnum: AmmEnum,\n  networkId: ApertureSupportedChainId,\n  tokenAAddress: string | null,\n  tokenBAddress: string | null,\n  poolKeys: number[] = [],\n  isSupported: boolean = true\n) {\n  const rpcSetting = useRpcSettings();\n  const publicClient = getPublicClient(networkId, rpcSetting);\n\n  if (ammEnum !== \"SLIPSTREAM\") {\n    poolKeys = SupportedFeeAmount[ammEnum];\n  }\n  const shouldFetch =\n    tokenAAddress &&\n    tokenBAddress &&\n    ammEnum &&\n    isSupported &&\n    networkId === publicClient.chain?.id;\n\n  return useSWR(\n    shouldFetch\n      ? `calc-tokens-market-price-${ammEnum}-${networkId}-${tokenAAddress}-${tokenBAddress}`\n      : null,\n    () =>\n      getFetchMarketPrice(\n        ammEnum,\n        networkId,\n        tokenAAddress!,\n        tokenBAddress!,\n        poolKeys,\n        publicClient\n      ),\n    { refreshInterval: 30_000 }\n  );\n}\n\nasync function getFetchMarketPrice(\n  ammEnum: AmmEnum,\n  chainId: ApertureSupportedChainId,\n  tokenAAddress: string,\n  tokenBAddress: string,\n  poolKeys: number[],\n  client: PublicClient\n) {\n  if (poolKeys.length === 0) return {};\n\n  const batchProcessor = MarketPriceBatchProcessor.getInstance();\n  return batchProcessor.addRequest(ammEnum, chainId, client, {\n    tokenA: tokenAAddress,\n    tokenB: tokenBAddress,\n    poolKeys,\n  });\n}\n\nclass MarketPriceBatchProcessor {\n  private static instance: MarketPriceBatchProcessor;\n  private batchQueues: Map<\n    string,\n    {\n      ammEnum: AmmEnum;\n      chainId: ApertureSupportedChainId;\n      client: PublicClient;\n      requests: BatchRequest[];\n      timer?: NodeJS.Timeout;\n      pendingPromises: { resolve: (result: BatchResult) => void }[];\n    }\n  >;\n  private readonly BATCH_SIZE = 10;\n  private readonly BATCH_TIMEOUT = 500; // ms\n\n  private constructor() {\n    this.batchQueues = new Map();\n  }\n\n  static getInstance(): MarketPriceBatchProcessor {\n    if (!MarketPriceBatchProcessor.instance) {\n      MarketPriceBatchProcessor.instance = new MarketPriceBatchProcessor();\n    }\n    return MarketPriceBatchProcessor.instance;\n  }\n\n  async addRequest(\n    ammEnum: AmmEnum,\n    chainId: ApertureSupportedChainId,\n    client: PublicClient,\n    request: BatchRequest\n  ): Promise<BatchResult> {\n    const queueKey = `${ammEnum}-${chainId}`;\n\n    // Create queue if it doesn't exist\n    if (!this.batchQueues.has(queueKey)) {\n      this.batchQueues.set(queueKey, {\n        ammEnum,\n        chainId,\n        client,\n        requests: [],\n        pendingPromises: [],\n      });\n    }\n\n    const queue = this.batchQueues.get(queueKey)!;\n    queue.requests.push(request);\n\n    return new Promise((resolve) => {\n      queue.pendingPromises.push({ resolve });\n\n      if (queue.requests.length >= this.BATCH_SIZE) {\n        this.processBatchQueue(queueKey);\n      } else if (!queue.timer) {\n        queue.timer = setTimeout(() => {\n          this.processBatchQueue(queueKey);\n        }, this.BATCH_TIMEOUT);\n      }\n    });\n  }\n\n  private async processBatchQueue(queueKey: string): Promise<void> {\n    const queue = this.batchQueues.get(queueKey);\n    if (!queue || queue.requests.length === 0) return;\n\n    // Clear timeout if it exists\n    if (queue.timer) {\n      clearTimeout(queue.timer);\n      queue.timer = undefined;\n    }\n\n    const { ammEnum, chainId, client, requests, pendingPromises } = queue;\n    this.batchQueues.delete(queueKey);\n\n    const poolRequests = requests.flatMap((request) =>\n      request.poolKeys.map((poolKey) => ({\n        tokenA: request.tokenA,\n        tokenB: request.tokenB,\n        feeOrTickSpacing: poolKey,\n      }))\n    );\n\n    try {\n      const pools = await viem.getBulkPools(\n        poolRequests,\n        chainId,\n        ammEnum,\n        client\n      );\n      const pricesList: Record<\n        string,\n        Record<string, { tokenA: string; tokenB: string }>\n      > = {};\n\n      pools.forEach((pool, index) => {\n        if (!pool) return;\n\n        const request = poolRequests[index];\n        const tokenKey = `${poolRequests[index].tokenA}-${poolRequests[index].tokenB}`;\n        const prices =\n          pool.token0.address === request.tokenA\n            ? {\n                tokenA: pool.token0Price.toFixed(18),\n                tokenB: pool.token1Price.toFixed(18),\n              }\n            : {\n                tokenA: pool.token1Price.toFixed(18),\n                tokenB: pool.token0Price.toFixed(18),\n              };\n        const key = ammEnum === \"SLIPSTREAM\" ? pool.tickSpacing : pool.fee;\n        if (!pricesList[tokenKey]) {\n          pricesList[tokenKey] = {};\n        }\n        pricesList[tokenKey][key] = prices;\n      });\n\n      // Resolve all pending promises with the result\n      pendingPromises.forEach(({ resolve }, index) => {\n        const tokenKey = `${requests[index].tokenA}-${requests[index].tokenB}`;\n        resolve(pricesList[tokenKey]);\n      });\n    } catch (error) {\n      console.warn(\"Error fetching market price\", error);\n      pendingPromises.forEach(({ resolve }) => resolve({}));\n    }\n  }\n}\n"],"names":["fetchInfoForAllChains","chains","fetchPositionCallback","allInfo","Promise","all","Array","from","map","chainId","parsedChainId","parseInt","toString","e","console","error","concat","message","plusOrMinusTick","actionType","tickLower","tickUpper","invert","tickSpacing","pool","getNewTick","tickValue","type","rangeWidth","startingTick","tickCurrent","newTick","Math","ceil","TickMath","percentageToOffsetTick","percentage","minPercentage","maxPercentage","round","log","undefined","offsetTickToPercentage","offsetTick","abs","target","TICK_MULTIPLIER","toFixed","useOnNetworkAccountChange","address","useAccount","ammEnum","networkId","isChainSupported","useNetwork","cb","useEventCallback","callback","useUpdateEffect","useEffect","useMutateWarningTokens","mutate","tokenBalanceMutate","useFetchUserTokensBalance","updateTokenMap","useAllChainStateStore","mutateWarningTokens","token","tokens","isArray","mutateWarningTokensByAddress","tokenAddress","addresses","viem","getPublicClient","useCurrentChainPositions","currentTokenMap","useCurrentChainToken","state","activePositionMap","currentActivePositionMap","positionInitializer","usePositionInitializer","walletAddress","useMemo","positionMap","positionList","isLoading","sortActivePositions","Object","values","useMutatePositionMap","updatePositionMap","mutatePositionMap","useCallback","amm","isInitialization","missingTokenAddresses","getMissingTokens","length","useChainsWithNonEmptyPositions","data","useFetchAllChainsNumberOfPositions","useSWR","showFetch","name","chainIdsList","getSupportedChainsByAmm","getNetworkId","chain","getAmmEnum","validChains","getValidChains","chainsWithPositions","entries","reduce","acc","positionNumber","param","includes","push","flat","useFetchAllChainUserTriggers","limitOrder","isConnected","key","join","initialData","currentChainTriggers","getTriggers","otherChainIds","filter","id","getAllOtherChainTriggers","keepPreviousData","chainIds","isLimitOrder","cacheKey","otherChainsData","triggers","allData","forEach","cache","require","set","useFetchAllChainsPositions","rawAllPositionMap","chainIdList","currentPositionLoading","rawAllTokenMap","useInitializeChainPositions","allChainsPositionMap","hasNoPosition","isAllLoaded","every","isCriticalDataLoaded","tokenMap","missingAddresses","Set","position","token0","token1","has","add","useFetchCurrentChainMarketPrice","tokenAAddress","tokenBAddress","publicClient","poolKeys","isSupported","SupportedFeeAmount","shouldFetch","getFetchMarketPrice","refreshInterval","useFetchMarketPrice","rpcSetting","useRpcSettings","client","batchProcessor","MarketPriceBatchProcessor","getInstance","addRequest","tokenA","tokenB","instance","request","queueKey","batchQueues","requests","pendingPromises","queue","get","resolve","BATCH_SIZE","processBatchQueue","timer","setTimeout","BATCH_TIMEOUT","clearTimeout","delete","poolRequests","flatMap","feeOrTickSpacing","poolKey","pools","pricesList","index","tokenKey","prices","token0Price","token1Price","fee","warn","constructor","Map"],"sourceRoot":""}