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AAQ2P,CAAAA,EAAAA,EAAAA,EAAAA,IACRvI,EAASC,CAAAA,EAAAA,GAAAA,SAAAA,IACT,CAAE5R,WAAAA,CAAAA,CAAY,CAAGuC,WAGvB,EACS,GAAAJ,EAAAC,GAAA,EAAC6X,GAAgBA,CAAAA,GAIxB,GAAA9X,EAAAiK,IAAA,EAAC+B,EAAAA,EAAIA,CAAAA,CAAC7B,IAAK,GAAIsP,eAAe,0BAC5B,GAAAzZ,EAAAiK,IAAA,EAACoD,GAASA,CAAClD,IAAI,gBACb,GAAAnK,EAAAiK,IAAA,EAACC,EAAAA,EAAUA,CAAAA,CAACC,IAAI,gBACd,GAAAnK,EAAAC,GAAA,EAACgI,GAAQA,UAAC,eACV,GAAAjI,EAAAC,GAAA,EAACka,GAAAA,UAAS,2BAEZ,GAAAna,EAAAC,GAAA,EAACgI,GAAQA,UAAE,gLAAiMlQ,MAAA,CAbxL,yEAawL,2GAC5M,GAAAiI,EAAAC,GAAA,EAAC6N,GAAYA,CACXgB,QAAS,IAAMU,EAAO5Z,IAAI,CAAC,qBAC3BkW,MAAM,QACN+C,QAAQ,UACR8K,KACE,GAAA3Z,EAAAC,GAAA,EAACmX,GAAAA,EAAAA,CAAAA,SAAwB,EAACoD,OAAQpS,EAAMC,MAAM,CAACC,MAAM,CAACuP,OAAO,GAE/D6B,aAAa,eAEb,GAAA1Z,EAAAC,GAAA,EAACwa,EAAAA,EAAQA,CAAAA,UAAC,gCAGd,GAAAza,EAAAC,GAAA,EPnDS+O,GOmDEA,CAAAA,KAtBd,EA2BH,IAAA0L,GAAeJ","sources":["webpack://_N_E/?6b9e","webpack://_N_E/./hooks/globalState/useWarningTokens.ts","webpack://_N_E/./hooks/useFetchMarketPrice.ts","webpack://_N_E/./hooks/useFetchTokensFeeTierDistribution.ts","webpack://_N_E/./utils/calculator/coingecko.ts","webpack://_N_E/./views/Calculator/Context.tsx","webpack://_N_E/./views/Calculator/DetailContext.tsx","webpack://_N_E/./hooks/calculator/useCalculator.ts","webpack://_N_E/./views/Calculator/FeeTierSelector.tsx","webpack://_N_E/./views/Calculator/TokenPairSelector.tsx","webpack://_N_E/./views/Calculator/CalculatorInput.tsx","webpack://_N_E/./views/Calculator/Calculator.tsx","webpack://_N_E/./components/Modal/ChangePoolModal.tsx","webpack://_N_E/./views/Calculator/DepositAmount.tsx","webpack://_N_E/./components/Modal/ImpermanentLossModal.tsx","webpack://_N_E/./views/Calculator/EstimatedFees.tsx","webpack://_N_E/./views/Calculator/PriceRange.tsx","webpack://_N_E/./views/Calculator/Detail.tsx","webpack://_N_E/./pages/calculator/index.tsx","webpack://_N_E/<anon>"],"sourcesContent":["\n (window.__NEXT_P = window.__NEXT_P || []).push([\n \"/calculator\",\n function () {\n return require(\"private-next-pages/calculator/index.tsx\");\n }\n ]);\n if(module.hot) {\n module.hot.dispose(function () {\n window.__NEXT_P.push([\"/calculator\"])\n });\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 { 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","import { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { isFeeTierDistributionSupported } from \"@/utils/networkHelper\";\nimport {\n ApertureSupportedChainId,\n viem,\n} from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { AmmEnum } from \"@ui/utils\";\nimport useSWR from \"swr/immutable\";\nimport { Address } from \"viem\";\nexport function useFetchTokensFeeTierDistribution(\n tokenAAddress: string,\n tokenBAddress: string,\n ammEnum: AmmEnum = \"UNISWAP_V3\",\n networkId?: ApertureSupportedChainId\n) {\n const { networkId: currentNetworkId } = useNetwork();\n const [token0, token1] = [\n tokenAAddress.toLowerCase(),\n tokenBAddress.toLowerCase(),\n ].sort();\n // TODO: Change back when viem.getFeeTierDistribution updates\n // const shouldFetch =\n // ammEnum && [token0, token1].indexOf(\"0x\") === -1;\n\n // Temp fix: remove fee tier distribution calls for all networks except Scroll and Manta\n const shouldFetch =\n ammEnum &&\n isFeeTierDistributionSupported(networkId ?? currentNetworkId) &&\n [token0, token1].indexOf(\"0x\") === -1;\n\n return useSWR(\n shouldFetch\n ? `fee-tier-distribution-${ammEnum}-${\n networkId ?? currentNetworkId\n }-${token0}-${token1}`\n : null,\n () =>\n viem.getFeeTierDistribution(\n networkId ?? currentNetworkId,\n ammEnum,\n tokenAAddress as Address,\n tokenBAddress as Address\n )\n );\n}\n","import { PriceChart } from \"@/interfaces/calculator/coingecko.interface\";\nimport { ISubgraphToken } from \"@/interfaces/calculator/uniswap.interface\";\nimport { ChartPrice, SupportedChainId } from \"@aperture/uikitv2\";\nimport { getTokenHistoricalPricesFromCoingecko } from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { getNetworkId } from \"../networkHelper\";\nimport { getTokenFromSubgraphToken } from \"./helper\";\n\nenum QueryPeriodEnum {\n ONE_DAY = \"1\",\n ONE_WEEK = \"7\",\n ONE_MONTH = \"30\",\n THREE_MONTH = \"90\",\n ONE_YEAR = \"90\",\n MAX = \"max\",\n}\nexport const getPriceChart = async (\n token: ISubgraphToken,\n chainId: SupportedChainId,\n queryPeriod: QueryPeriodEnum = QueryPeriodEnum.ONE_MONTH\n): Promise<PriceChart | null> => {\n const networkId = getNetworkId(chainId);\n const _token = getTokenFromSubgraphToken(token, networkId);\n const marketChartRes = await getTokenHistoricalPricesFromCoingecko(\n _token,\n Number(queryPeriod)\n );\n\n const prices = marketChartRes.map(\n (d) =>\n ({\n timestamp: d[0],\n value: d[1],\n } as ChartPrice)\n );\n\n return {\n tokenId: token.id,\n tokenName: token.name,\n currentPriceUSD: prices[prices.length - 1]?.value ?? 1,\n prices,\n };\n};\n","import { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { useFetchTokenMap } from \"@/hooks/useFetchTokenMap\";\nimport { OpenPositionQueryKey as QueryKey } from \"@/utils/browserHistory\";\nimport { DEFAULT_AMM, isCalculatorAMM } from \"@/utils/calculator/helper\";\nimport { IToken } from \"@aperture/types\";\nimport { getChainInfo } from \"@aperture/uikit\";\nimport {\n AmmInfo,\n BasicInfo,\n CALC_AMM_CHAINS,\n Calculator_AMM,\n NetworkInfo,\n} from \"@aperture/uikitv2\";\nimport {\n Dispatch,\n PropsWithChildren,\n SetStateAction,\n createContext,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { useUrlQuery } from \"../NewPosition/hooks\";\n\n// TODO: remove unused\ninterface CalculatorContextType {\n selectedDex: BasicInfo;\n handleSelectedDex: (dex: BasicInfo) => void;\n selectedNetwork: NetworkInfo;\n handleSelectedNetwork: (network: NetworkInfo) => void;\n\n selectedTokenA: IToken;\n selectedTokenB: IToken;\n setSelectedToken: (\n key: QueryKey.TOKEN_A | QueryKey.TOKEN_B,\n token: IToken | null\n ) => void;\n\n tickLower: number;\n tickUpper: number;\n\n setTickUrl: (\n key: QueryKey.TICK_LOWER | QueryKey.TICK_UPPER,\n tick: number\n ) => void;\n\n isSettingChanged: boolean;\n\n poolKey: number;\n setPoolKeyUrl: (poolKey: number) => void;\n\n showDetail: boolean;\n setShowDetail: Dispatch<SetStateAction<boolean>>;\n}\n\nconst CalculatorContext = createContext<CalculatorContextType | undefined>(\n undefined\n);\n\nexport const CalculatorProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const { amm, network } = useNetwork();\n const [showDetail, setShowDetail] = useState(false);\n const { data: tokenMap } = useFetchTokenMap();\n\n const {\n calcDex,\n calcNetwork,\n setCalcDexUrl,\n setCalcNetworkUrl,\n selectedTokenA,\n selectedTokenB,\n feeTier: poolKey,\n tickLower,\n tickUpper,\n isUrlUpdated,\n setSelectedToken,\n setFeeTierUrl: setPoolKeyUrl,\n setTickUrl,\n } = useUrlQuery(tokenMap);\n\n useEffect(() => {\n const _dex = isCalculatorAMM(amm)\n ? (amm.name as Calculator_AMM)\n : DEFAULT_AMM;\n const _network = isCalculatorAMM(amm) ? network : CALC_AMM_CHAINS[_dex][0];\n if (!calcDex) {\n setCalcDexUrl(_dex);\n }\n if (!calcNetwork) {\n setCalcNetworkUrl(_network);\n }\n }, [amm, network, calcDex, calcNetwork, setCalcDexUrl, setCalcNetworkUrl]);\n\n const _dex =\n calcDex && isCalculatorAMM(AmmInfo[calcDex])\n ? calcDex\n : isCalculatorAMM(amm)\n ? (amm.name as Calculator_AMM)\n : DEFAULT_AMM;\n const _network =\n calcNetwork && CALC_AMM_CHAINS[_dex].includes(calcNetwork)\n ? calcNetwork\n : CALC_AMM_CHAINS[_dex][0];\n const selectedDex = AmmInfo[_dex];\n const selectedNetwork = getChainInfo(_network);\n\n const handleSelectedDex = (dex: BasicInfo) => {\n setCalcDexUrl(dex.name as Calculator_AMM);\n };\n const handleSelectedNetwork = (network: NetworkInfo) => {\n setCalcNetworkUrl(network.id);\n };\n\n return (\n <CalculatorContext.Provider\n value={{\n selectedDex,\n handleSelectedDex,\n selectedNetwork,\n handleSelectedNetwork,\n\n selectedTokenA,\n selectedTokenB,\n setSelectedToken,\n poolKey,\n setPoolKeyUrl,\n\n tickLower,\n tickUpper,\n setTickUrl,\n\n isSettingChanged: isUrlUpdated,\n\n showDetail,\n setShowDetail,\n }}\n >\n {children}\n </CalculatorContext.Provider>\n );\n};\n\nexport const useCalculatorContext = () => {\n const context = useContext(CalculatorContext);\n if (!context) {\n throw new Error(\n \"useCalculatorContext must be used within a CalculatorProvider\"\n );\n }\n return context;\n};\n","import { useEventCallback } from \"@/hooks/useEventCallback\";\nimport { PriceChart } from \"@/interfaces/calculator/coingecko.interface\";\nimport {\n ISubgraphToken,\n Pool,\n Tick,\n} from \"@/interfaces/calculator/uniswap.interface\";\nimport {\n ChartPrice,\n ChartVolumn,\n PositionBreakdown,\n divideArray,\n findMax,\n findMin,\n} from \"@aperture/uikitv2\";\nimport { getLogger } from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { Pool as SDKPool } from \"@aperture_finance/uniswap-v3-sdk\";\nimport {\n Dispatch,\n PropsWithChildren,\n SetStateAction,\n createContext,\n useCallback,\n useContext,\n useState,\n} from \"react\";\n\nexport interface CalculatorDetailContextType {\n isLoading: boolean;\n setIsLoading: Dispatch<SetStateAction<boolean>>;\n selectedTokens: [ISubgraphToken, ISubgraphToken];\n setSelectedTokens: Dispatch<SetStateAction<[ISubgraphToken, ISubgraphToken]>>;\n\n pool: Pool;\n sdkPool: SDKPool;\n\n volume24H: number;\n\n isPairToggled: boolean;\n isFullRange: boolean;\n handleIsPairToggled: (toggled: boolean) => void;\n handleIsFullRange: (fullRange: boolean) => void;\n\n poolTicks: Tick[] | null;\n token0PriceChart: PriceChart;\n token1PriceChart: PriceChart;\n\n token0: ISubgraphToken;\n token1: ISubgraphToken;\n setupPair: (payload: PairPayload) => void;\n\n depositAmount: string;\n setDepositAmount: Dispatch<SetStateAction<string>>;\n\n priceRangeMinValue: number;\n priceRangeMaxValue: number;\n priceAssumptionValue: number;\n handlePriceRangeMinValue: (value: number) => void;\n handlePriceRangeMaxValue: (value: number) => void;\n handlePriceAssumptionValue: (value: number) => void;\n\n poolVolumes: ChartVolumn[] | null;\n handlePoolVolumes: (volumes: ChartVolumn[]) => void;\n\n positionBreakdown: PositionBreakdown[] | null;\n handlePositionBreakdown: (volumes: PositionBreakdown[]) => void;\n\n resetData: () => void;\n togglePair: () => void;\n}\n\ntype PairPayload = {\n token0: ISubgraphToken;\n token1: ISubgraphToken;\n pool: Pool;\n sdkPool: SDKPool;\n poolTicks: Tick[];\n volume24H: number;\n poolVolumes: ChartVolumn[];\n positionBreakdown: PositionBreakdown[];\n token0PriceChart: PriceChart;\n token1PriceChart: PriceChart;\n};\n\nconst CalculatorDetailContext = createContext<\n CalculatorDetailContextType | undefined\n>(undefined);\n\nconst DEFAULT_DEPOSIT_AMT = \"1000\";\n\nexport const CalculatorDetailProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [depositAmount, setDepositAmount] = useState(DEFAULT_DEPOSIT_AMT);\n const [isPairToggled, setIsPairToggled] = useState<boolean>(false);\n const [isFullRange, setIsFullRange] = useState<boolean>(false);\n const [poolTicks, setPoolTicks] = useState<Tick[]>(null);\n const [token0PriceChart, setToken0PriceChart] = useState<PriceChart>(null);\n const [token1PriceChart, setToken1PriceChart] = useState<PriceChart>(null);\n const [priceRangeMinValue, setPriceRangeMinValue] = useState<number>(0);\n const [priceRangeMaxValue, setPriceRangeMaxValue] = useState<number>(0);\n const [priceAssumptionValue, setPriceAssumptionValue] = useState<number>(0);\n const [poolVolumes, setPoolVolumes] = useState<ChartVolumn[]>(null);\n const [positionBreakdown, setPositionBreakdown] =\n useState<PositionBreakdown[]>(null);\n const [selectedTokens, setSelectedTokens] =\n useState<[ISubgraphToken, ISubgraphToken]>();\n const [pool, setPool] = useState<Pool>();\n const [sdkPool, setSdkPool] = useState<SDKPool>();\n const [volume24H, setVolume24H] = useState<number>();\n const [isLoading, setIsLoading] = useState(false);\n const [token0, setToken0] = useState<ISubgraphToken>(null);\n const [token1, setToken1] = useState<ISubgraphToken>(null);\n\n const resetData = useCallback(() => {\n setSelectedTokens(undefined);\n setPool(undefined);\n setPoolTicks(undefined);\n }, []);\n\n const setupPair = useCallback((payload: PairPayload) => {\n const {\n token0,\n token1,\n pool,\n sdkPool,\n poolTicks,\n volume24H,\n token0PriceChart,\n token1PriceChart,\n poolVolumes,\n positionBreakdown,\n } = payload;\n setToken0(token0);\n setToken1(token1);\n setPool(pool);\n setSdkPool(sdkPool);\n setPoolTicks(poolTicks);\n setVolume24H(volume24H);\n setPoolVolumes(poolVolumes);\n setPositionBreakdown(positionBreakdown);\n setToken0PriceChart(token0PriceChart);\n setToken1PriceChart(token1PriceChart);\n setupPriceRange(pool, token0PriceChart, token1PriceChart);\n setIsPairToggled(false);\n }, []);\n\n const setupPriceRange = (\n newPool: Pool,\n newToken0PriceChart: PriceChart,\n newToken1PriceChart: PriceChart\n ) => {\n const currentPrice = Number(newPool.token0Price);\n const prices = divideArray(\n (newToken1PriceChart?.prices || []).map((p: ChartPrice) => p.value),\n (newToken0PriceChart?.prices || []).map((p: ChartPrice) => p.value)\n );\n let _min = findMin(prices);\n let _max = findMax(prices);\n if (newToken0PriceChart === null || newToken1PriceChart === null) {\n _min = currentPrice - currentPrice * 0.3;\n _max = currentPrice + currentPrice * 0.3;\n }\n setPriceAssumptionValue(currentPrice);\n setPriceRangeMinValue(_min);\n setPriceRangeMaxValue(_max);\n };\n\n const togglePair = useEventCallback(() => {\n getLogger().info(\"Calculator.TogglePair\");\n\n setIsPairToggled((prev) => !prev);\n setToken0(token1);\n setToken1(token0);\n setToken0PriceChart(token1PriceChart);\n setToken1PriceChart(token0PriceChart);\n const newPool = {\n ...pool,\n token0Price: pool.token1Price,\n token1Price: pool.token0Price,\n };\n setPool(newPool);\n setPriceAssumptionValue(\n priceAssumptionValue ? 1 / priceAssumptionValue : 0\n );\n setPriceRangeMinValue(1 / priceRangeMaxValue);\n setPriceRangeMaxValue(1 / priceRangeMinValue);\n });\n\n return (\n <CalculatorDetailContext.Provider\n value={{\n isLoading,\n setIsLoading,\n selectedTokens,\n setSelectedTokens,\n pool,\n sdkPool,\n volume24H,\n depositAmount,\n setDepositAmount,\n isPairToggled,\n isFullRange,\n handleIsPairToggled: setIsPairToggled,\n handleIsFullRange: setIsFullRange,\n poolTicks,\n token0PriceChart,\n token1PriceChart,\n token0,\n token1,\n setupPair,\n priceRangeMinValue,\n priceRangeMaxValue,\n priceAssumptionValue,\n handlePriceRangeMinValue: setPriceRangeMinValue,\n handlePriceRangeMaxValue: setPriceRangeMaxValue,\n handlePriceAssumptionValue: setPriceAssumptionValue,\n poolVolumes,\n handlePoolVolumes: setPoolVolumes,\n positionBreakdown,\n handlePositionBreakdown: setPositionBreakdown,\n resetData,\n togglePair,\n }}\n >\n {children}\n </CalculatorDetailContext.Provider>\n );\n};\n\nexport const useCalculatorDetailContext = () => {\n const context = useContext(CalculatorDetailContext);\n if (!context) {\n throw new Error(\n \"useCalculatorDetailContext must be used within a CalculatorDetailProvider\"\n );\n }\n return context;\n};\n","import { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { useSnackbarV2 } from \"@/components/SnackbarContext/SnackbarContextV2\";\nimport { useRpcSettings } from \"@/config/feature_flags\";\nimport { getPublicClient } from \"@/helper/getPublicClient\";\nimport { OpenPositionQueryKey as QueryKey } from \"@/utils/browserHistory\";\nimport { getPriceChart } from \"@/utils/calculator/coingecko\";\nimport {\n getAvgTradingVolume,\n getPoolFromPair,\n getPoolTicks,\n getPoolVolumes,\n getToken,\n} from \"@/utils/calculator/data\";\nimport {\n SubgraphURLs,\n getDefaultPoolTicks,\n sortTokens,\n} from \"@/utils/calculator/helper\";\nimport { checkAddresses } from \"@/utils/helper\";\nimport { supportedNetwork } from \"@/utils/networkHelper\";\nimport { useCalculatorContext } from \"@/views/Calculator/Context\";\nimport { useCalculatorDetailContext } from \"@/views/Calculator/DetailContext\";\nimport { IToken } from \"@aperture/types\";\nimport { getAmmEnum } from \"@aperture/uikit\";\nimport {\n BasicInfo,\n Calculator_AMM,\n NetworkInfo,\n SupportedChainId,\n getChainInfo,\n getNetworksList,\n} from \"@aperture/uikitv2\";\nimport { getLogger, viem } from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { AxiosError } from \"axios\";\nimport { useEffect, useState } from \"react\";\nimport { getAddress } from \"viem\";\n\nconst disabledTopPositionsNetworkId = [\n SupportedChainId.ARBITRUM,\n SupportedChainId.BASE,\n];\n\nexport interface ICalculatorProps {\n selectedDex: BasicInfo;\n handleSelectedDex: (dex: BasicInfo) => void;\n selectedNetwork: NetworkInfo;\n handleSelectedNetwork: (network: NetworkInfo) => void;\n tokenA: IToken;\n setTokenA: (token: IToken | null) => void;\n tokenB: IToken;\n setTokenB: (token: IToken | null) => void;\n feeTier: number;\n setFeeTier: (feeTier: number) => void;\n onCalculate: () => Promise<void>;\n isCalculating?: boolean;\n}\n\nexport const useCalculator = (\n fetchFromUrlParams: boolean\n): ICalculatorProps => {\n const { addSnackbar } = useSnackbarV2();\n const rpcSetting = useRpcSettings();\n const { amm, network } = useNetwork();\n const {\n selectedDex: currentDex,\n selectedNetwork: currentNetwork,\n selectedTokenA: currentTokenA,\n selectedTokenB: currentTokenB,\n poolKey: currentFeeTier,\n handleSelectedDex: setSelectedDex,\n handleSelectedNetwork: setSelectedNetwork,\n setSelectedToken,\n setPoolKeyUrl,\n setShowDetail,\n } = useCalculatorContext();\n const { setSelectedTokens, setupPair } = useCalculatorDetailContext();\n\n const [calcDex, setCalcDex] = useState<BasicInfo>(currentDex || amm);\n const [calcNetwork, setCalcNetwork] = useState<NetworkInfo>(\n currentNetwork || getChainInfo(network)\n );\n const [tokenA, setTokenA] = useState<IToken>();\n const [tokenB, setTokenB] = useState<IToken>();\n const [feeTier, setFeeTier] = useState<number>();\n const [isCalculating, setIsCalculating] = useState(false);\n\n useEffect(() => {\n if (!fetchFromUrlParams) return;\n setTokenA(currentTokenA);\n setTokenB(currentTokenB);\n setFeeTier(currentFeeTier);\n if (tokenA && tokenB && feeTier) {\n onCalculate();\n }\n }, [currentTokenA, currentTokenB, currentFeeTier]);\n\n // Reset tokens, fee tier when dex/network changed\n const handleReset = () => {\n setFeeTier(undefined);\n setTokenA(undefined);\n setTokenB(undefined);\n };\n\n const handleSelectedDex = (dex: BasicInfo) => {\n setCalcDex(dex);\n const defaultNetwork = getNetworksList(dex)[0];\n setCalcNetwork(defaultNetwork);\n handleReset();\n };\n const handleSelectedNetwork = (network: NetworkInfo) => {\n setCalcNetwork(network);\n handleReset();\n };\n\n const handleTokenASelected = (token: IToken) => {\n let _tokenB = tokenB;\n if (checkAddresses(token, tokenB)) {\n setTokenB(null);\n _tokenB = null;\n }\n setTokenA(token);\n setFeeTier(undefined);\n };\n const handleTokenBSelected = (token: IToken) => {\n let _tokenA = tokenA;\n if (checkAddresses(token, tokenA)) {\n setTokenA(null);\n _tokenA = null;\n }\n setTokenB(token);\n setFeeTier(undefined);\n };\n\n const subgraphEndpoint =\n SubgraphURLs[calcDex.name as Calculator_AMM]?.[calcNetwork.id];\n\n const onCalculate = async () => {\n getLogger().info(\"Calculator.ClickCalculate.Start\", {\n selectedTokenA: tokenA?.ticker,\n selectedTokenB: tokenB?.ticker,\n poolKey: feeTier,\n network: calcNetwork?.name,\n exchange: calcDex?.name,\n });\n\n setIsCalculating(true);\n\n try {\n const tokens = await Promise.all([\n getToken(subgraphEndpoint, tokenA.address),\n getToken(subgraphEndpoint, tokenB.address),\n ]);\n\n const pools = await getPoolFromPair(\n subgraphEndpoint,\n tokens[0],\n tokens[1],\n disabledTopPositionsNetworkId.includes(calcNetwork.id)\n );\n\n const selectedPool = pools.find((p) => p.feeTier === `${feeTier}`);\n\n if (!selectedPool) return;\n\n const networkId = supportedNetwork[calcNetwork.id];\n const publicClient = getPublicClient(networkId, rpcSetting);\n const [token0, token1] = sortTokens(tokens[0], tokens[1]);\n const [\n sdkPool,\n poolTicks,\n token0PriceChart,\n token1PriceChart,\n volume24H,\n poolVolumes,\n ] = await Promise.all([\n viem.getPool(\n getAddress(token0.id),\n getAddress(token1.id),\n feeTier,\n networkId,\n getAmmEnum(calcDex),\n publicClient\n ),\n getPoolTicks(subgraphEndpoint, selectedPool.id),\n getPriceChart(token0, calcNetwork.id),\n getPriceChart(token1, calcNetwork.id),\n getAvgTradingVolume(subgraphEndpoint, selectedPool.id),\n getPoolVolumes(subgraphEndpoint, selectedPool.id),\n ]);\n\n const _poolTicks = !poolTicks.length\n ? getDefaultPoolTicks(token0, token1, selectedPool)\n : poolTicks;\n\n setSelectedTokens([token0, token1]);\n setupPair({\n token0,\n token1,\n pool: selectedPool,\n sdkPool,\n poolTicks: _poolTicks,\n volume24H,\n token0PriceChart,\n token1PriceChart,\n poolVolumes,\n positionBreakdown: null,\n });\n getLogger().info(\"Calculator.ClickCalculate.Success\");\n setShowDetail(true);\n setSelectedDex(calcDex);\n setSelectedNetwork(calcNetwork);\n setSelectedToken(QueryKey.TOKEN_A, tokenA);\n setSelectedToken(QueryKey.TOKEN_B, tokenB);\n setPoolKeyUrl(feeTier);\n } catch (e) {\n const isSubgraphError = e.toString().includes(\"Subgraph Errors\");\n const isNotFound = (e as Error).message?.includes(\"404\");\n const ticker = getTicker(e, tokenA, tokenB);\n\n if (isSubgraphError) {\n addSnackbar({\n info: `${calcNetwork.name} subgraph is down, please check other networks.`,\n status: \"failed\",\n });\n } else if (isNotFound) {\n addSnackbar({\n info: `Token ${ticker} is not supported yet, please try another token.`,\n status: \"failed\",\n });\n } else {\n addSnackbar({\n info: `Something went wrong, please retry later!`,\n status: \"failed\",\n });\n }\n\n const log = isNotFound ? getLogger().warn : getLogger().error;\n log(\"Calculator.CalculateError\", {\n error: e.toString(),\n });\n } finally {\n setIsCalculating(false);\n }\n };\n\n return {\n selectedDex: calcDex,\n selectedNetwork: calcNetwork,\n tokenA,\n tokenB,\n feeTier,\n isCalculating,\n handleSelectedDex,\n handleSelectedNetwork,\n setTokenA: handleTokenASelected,\n setTokenB: handleTokenBSelected,\n setFeeTier,\n onCalculate,\n };\n};\n\nconst getTicker = (e: any, tokenA: IToken, tokenB: IToken) => {\n const regex = /contract\\/(0x[a-fA-F0-9]+)\\//;\n const url = (e as AxiosError).request?.responseURL;\n const address = url?.match(regex)?.[1];\n const ticker = checkAddresses(tokenA.address, address)\n ? `${tokenA.ticker} `\n : checkAddresses(tokenB.address, address)\n ? `${tokenB.ticker} `\n : \"\";\n return ticker;\n};\n","import { useFetchTokensFeeTierDistribution } from \"@/hooks/useFetchTokensFeeTierDistribution\";\nimport { useOnUpdateExist } from \"@/hooks/useOnUpdateExist\";\nimport { getNetworkId } from \"@/utils/networkHelper\";\nimport { IToken } from \"@aperture/types\";\nimport { SupportedFeeAmount, getAmmEnum } from \"@aperture/uikit\";\nimport {\n BasicInfo,\n FeeTier,\n FlexColumn,\n NetworkInfo,\n T3Regular,\n} from \"@aperture/uikitv2\";\nimport { memo, useMemo, useState } from \"react\";\nimport styled from \"styled-components\";\n\nconst StyledT3 = styled(T3Regular)`\n color: ${({ theme }) => theme.colors.global.text.T1};\n`;\n\ninterface IProps {\n amm: BasicInfo;\n network: NetworkInfo;\n tokenA: IToken;\n tokenB: IToken;\n poolKey: number;\n setPoolKey: (poolKey: number) => void;\n marketPrice: Record<\n number,\n {\n tokenA: string;\n tokenB: string;\n }\n >;\n marketPriceLoading: boolean;\n disabled?: boolean;\n disableClick?: boolean;\n}\n\nconst FeeTierSelectorComponent = ({\n amm,\n network,\n tokenA,\n tokenB,\n poolKey,\n setPoolKey,\n marketPrice,\n marketPriceLoading,\n disabled = false,\n disableClick = false,\n}: IProps) => {\n const ammEnum = getAmmEnum(amm);\n\n const { data: tiers } = useFetchTokensFeeTierDistribution(\n tokenA?.address ?? \"0x\",\n tokenB?.address ?? \"0x\",\n ammEnum,\n getNetworkId(network.id)\n );\n\n const _disabled = disabled || !tokenA || !tokenB || marketPriceLoading;\n const [firstLoad, setFirstLoad] = useState(true);\n\n const poolStatus = useMemo(() => {\n let statusMap: Record<number, boolean> = {};\n if (marketPrice) {\n Object.keys(marketPrice).forEach((key) => {\n statusMap[key] = !!marketPrice?.[key];\n });\n }\n\n return statusMap;\n }, [marketPrice]);\n\n // maxSelected > 0 means at least one tier is non-zero\n const getMaxSelected = (tiers) =>\n Number(\n Object.entries(tiers).reduce(\n ([maxK, maxV], [key, value]) =>\n value > maxV ? [key, value] : [maxK, maxV],\n [\"0\", 0]\n )[0]\n );\n\n useOnUpdateExist(tiers, () => {\n const maxSelected = getMaxSelected(tiers);\n if (firstLoad) {\n setFirstLoad(false);\n // if feeTier is already set in url, don't change it for first time\n if (poolKey && tiers[poolKey]) {\n return;\n }\n }\n setPoolKey(maxSelected || undefined);\n });\n\n const options = useMemo(\n () =>\n SupportedFeeAmount[ammEnum].map((fee) => ({\n key: fee,\n label: fee,\n })),\n [ammEnum]\n );\n\n if (!options?.length && poolKey) {\n // no options available\n setPoolKey(undefined);\n } else if (options?.length === 1 && poolKey !== options[0].key) {\n // only one option\n setPoolKey(options[0].key);\n }\n\n return (\n <FlexColumn gap=\"lg\">\n <StyledT3>Fee Tier</StyledT3>\n <FeeTier\n disabled={_disabled}\n disableClick={disableClick}\n tiers={tiers}\n createdStatus={poolStatus}\n selected={poolKey}\n onSelect={setPoolKey}\n disableNotCreated={true}\n options={options}\n />\n </FlexColumn>\n );\n};\n\nexport const FeeTierSelector = memo(FeeTierSelectorComponent);\n","import { getExplorerURL } from \"@/config/chain\";\nimport { useRpcSettings } from \"@/config/feature_flags\";\nimport { getPublicClient } from \"@/helper/getPublicClient\";\nimport { useMutateWarningTokens } from \"@/hooks/globalState/useWarningTokens\";\nimport { fetchUnknownToken } from \"@/hooks/useFetchTokenMap\";\nimport { getNetworkId } from \"@/utils/networkHelper\";\nimport { IToken } from \"@aperture/types\";\nimport { TokenWarningContent, getAmmEnum } from \"@aperture/uikit\";\nimport {\n BasicInfo,\n E_ModalKey,\n Flex,\n FlexColumn,\n Modal,\n NetworkInfo,\n T3Regular,\n TokenDropdownSelector,\n useModal,\n} from \"@aperture/uikitv2\";\nimport { Token } from \"@uniswap/sdk-core\";\nimport { memo, useMemo, useState } from \"react\";\nimport styled from \"styled-components\";\nimport { useAccount } from \"wagmi\";\n\nconst StyledT3 = styled(T3Regular)`\n color: ${({ theme }) => theme.colors.global.text.T1};\n`;\n\ninterface IProps {\n commonTokens: IToken[];\n selectedTokenA: IToken;\n selectedTokenB: IToken;\n handleTokenASelected: (token: IToken) => void;\n handleTokenBSelected: (token: IToken) => void;\n selectedDex: BasicInfo;\n selectedNetwork: NetworkInfo;\n disabled?: boolean;\n inModal?: boolean;\n}\ninterface ITokenWarning {\n token: IToken;\n isTokenA: boolean;\n}\n\n// TODO: refactor\nconst TokenPairSelectorComponent = ({\n commonTokens,\n selectedTokenA,\n selectedTokenB,\n handleTokenASelected,\n handleTokenBSelected,\n selectedDex,\n selectedNetwork,\n disabled = false,\n inModal = false,\n}: IProps) => {\n const { address: walletAddress } = useAccount();\n const { state, setModalState } = useModal();\n const { isOpen } = state[E_ModalKey.TOKEN_WARNING_MODAL];\n const [tokenWarning, setTokenWarning] = useState<ITokenWarning>();\n const selectedNetworkId = getNetworkId(selectedNetwork.id);\n const rpcSetting = useRpcSettings();\n const publicClient = useMemo(() => {\n return selectedNetwork && getPublicClient(selectedNetworkId, rpcSetting);\n }, [selectedNetwork, selectedNetworkId, rpcSetting]);\n\n const { mutateWarningTokens } = useMutateWarningTokens();\n const handleUnknownAddress = async (tokenAddress: string) => {\n return await fetchUnknownToken(\n tokenAddress,\n selectedNetworkId,\n publicClient,\n false,\n walletAddress\n );\n };\n\n const toggleTokenWarningModal = (open: boolean) => {\n setModalState(E_ModalKey.TOKEN_WARNING_MODAL, open);\n };\n\n const commonProps = {\n disabled,\n tokens: commonTokens,\n style: { width: 194 },\n inModal,\n handleUnknownAddress,\n };\n\n return (\n <>\n <FlexColumn gap=\"lg\">\n <StyledT3>Select Pair</StyledT3>\n <Flex gap=\"lg\">\n <TokenDropdownSelector\n key={`select-token-A-${selectedTokenA?.ticker}`}\n selectedToken={selectedTokenA}\n onSelectToken={handleTokenASelected}\n onSelectUnknownToken={(token: IToken) => {\n setTokenWarning({ token, isTokenA: true });\n toggleTokenWarningModal(true);\n }}\n {...commonProps}\n />\n <TokenDropdownSelector\n key={`select-token-B-${selectedTokenB?.ticker}`}\n selectedToken={selectedTokenB}\n onSelectToken={handleTokenBSelected}\n dropdownContainerStyles={{ left: \"unset\", right: 0 }}\n onSelectUnknownToken={(token: IToken) => {\n setTokenWarning({ token, isTokenA: false });\n toggleTokenWarningModal(true);\n }}\n {...commonProps}\n />\n </Flex>\n </FlexColumn>\n <Modal\n isModalOpen={isOpen}\n onClose={() => toggleTokenWarningModal(false)}\n closeIcon={false}\n >\n <TokenWarningContent\n {...{\n amm: getAmmEnum(selectedDex),\n token: tokenWarning?.token,\n exploreURL: getExplorerURL(selectedNetworkId),\n cancelClick: () => toggleTokenWarningModal(false),\n confirmClick: (token: IToken) => {\n tokenWarning?.isTokenA\n ? handleTokenASelected(token)\n : handleTokenBSelected(token);\n // Add new warning token with the useLocalStorageState in the web app\n mutateWarningTokens(\n selectedNetworkId,\n new Token(\n selectedNetworkId,\n token.address,\n token.decimals,\n token.ticker,\n token.name\n )\n );\n toggleTokenWarningModal(false);\n },\n }}\n />\n </Modal>\n </>\n );\n};\n\nexport const TokenPairSelector = memo(TokenPairSelectorComponent);\n","import { ICalculatorProps } from \"@/hooks/calculator/useCalculator\";\nimport { useFetchMarketPrice } from \"@/hooks/useFetchMarketPrice\";\nimport { useFetchTokenMap } from \"@/hooks/useFetchTokenMap\";\nimport { getNetworkId } from \"@/utils/networkHelper\";\nimport {\n Button,\n CalculatorAmmInfo,\n DexDropdownSelector,\n FlexColumn,\n H2,\n NetworkDropdownSelector,\n getNetworksList,\n} from \"@aperture/uikitv2\";\nimport { Spinner } from \"@ui/components\";\nimport { getAmmEnum } from \"@ui/utils\";\nimport bigDecimal from \"js-big-decimal\";\nimport { useMemo } from \"react\";\nimport styled from \"styled-components\";\nimport { FeeTierSelector } from \"./FeeTierSelector\";\nimport { TokenPairSelector } from \"./TokenPairSelector\";\n\nconst Container = styled(FlexColumn)`\n width: 380px;\n`;\nconst StyledH2 = styled(H2)`\n color: ${({ theme }) => theme.colors.global.text.T1};\n`;\nconst CalculatorContainer = styled(Container)<{ isModal?: boolean }>`\n width: 400px;\n margin-top: ${({ isModal }) => `${isModal ? 0 : 26}px`};\n padding: ${({ theme, isModal }) => (isModal ? 0 : theme.spacing.xl)};\n border-radius: 15px;\n border: ${({ theme, isModal }) =>\n isModal ? \"none\" : `1px solid ${theme.colors.global.line.Line1}`};\n`;\nconst StyledButton = styled(Button)`\n svg {\n width: 16px;\n height: 16px;\n }\n`;\nexport interface ICalculatorInputProps extends ICalculatorProps {\n isBtnDisabled?: boolean;\n isModal?: boolean;\n}\n\nexport const CalculatorInput = ({\n selectedDex,\n handleSelectedDex,\n selectedNetwork,\n handleSelectedNetwork,\n tokenA,\n setTokenA,\n tokenB,\n setTokenB,\n feeTier,\n setFeeTier,\n onCalculate,\n isCalculating = false,\n isBtnDisabled = false,\n isModal = false,\n}: ICalculatorInputProps) => {\n const dexList = Object.values(CalculatorAmmInfo);\n const networksList = useMemo(\n () => getNetworksList(selectedDex),\n [selectedDex]\n );\n\n const { data: tokenMap } = useFetchTokenMap(getNetworkId(selectedNetwork.id));\n const commonTokens = useMemo(\n () =>\n Object.values(tokenMap ?? {}).sort((a, b) =>\n bigDecimal.compareTo(b.amount, a.amount)\n ),\n [tokenMap]\n );\n\n const { data: marketPrice, isLoading: marketPriceLoading } =\n useFetchMarketPrice(\n getAmmEnum(selectedDex),\n getNetworkId(selectedNetwork.id),\n tokenA?.address ?? null,\n tokenB?.address ?? null\n );\n\n return (\n <CalculatorContainer gap=\"3xl\" isModal={isModal}>\n <StyledH2>{isModal ? \"Change Pool\" : \"Aperture Calculator\"}</StyledH2>\n <DexDropdownSelector\n disabled={isCalculating}\n options={dexList}\n selectedOption={selectedDex}\n onSelect={handleSelectedDex}\n inModal={isModal}\n />\n <NetworkDropdownSelector\n disabled={isCalculating}\n options={networksList}\n selectedOption={selectedNetwork}\n onSelect={handleSelectedNetwork}\n inModal={isModal}\n />\n <TokenPairSelector\n disabled={isCalculating}\n commonTokens={commonTokens}\n selectedTokenA={tokenA}\n selectedTokenB={tokenB}\n handleTokenASelected={setTokenA}\n handleTokenBSelected={setTokenB}\n inModal={isModal}\n selectedDex={selectedDex}\n selectedNetwork={selectedNetwork}\n />\n <FeeTierSelector\n disabled={isCalculating}\n amm={selectedDex}\n network={selectedNetwork}\n tokenA={tokenA}\n tokenB={tokenB}\n poolKey={feeTier}\n setPoolKey={setFeeTier}\n marketPrice={marketPrice}\n marketPriceLoading={marketPriceLoading}\n />\n <StyledButton\n width=\"100%\"\n variant=\"primary\"\n onClick={onCalculate}\n disabled={isBtnDisabled || isCalculating}\n >\n {isCalculating ? <Spinner /> : \"Calculate\"}\n </StyledButton>\n </CalculatorContainer>\n );\n};\n","import { useCalculator } from \"@/hooks/calculator/useCalculator\";\nimport { CalculatorInput } from \"./CalculatorInput\";\nimport { useCalculatorContext } from \"./Context\";\n\nconst Calculator = () => {\n const {\n selectedTokenA: currentTokenA,\n selectedTokenB: currentTokenB,\n poolKey: currentPoolKey,\n } = useCalculatorContext();\n const fetchFromUrlParams =\n !!currentTokenA && !!currentTokenB && !!currentPoolKey;\n const { tokenA, tokenB, feeTier, ...props } =\n useCalculator(fetchFromUrlParams);\n\n const isBtnDisabled = !tokenA || !tokenB || !feeTier || fetchFromUrlParams;\n\n return (\n <CalculatorInput\n {...{\n ...props,\n tokenA,\n tokenB,\n feeTier,\n isBtnDisabled,\n }}\n />\n );\n};\n\nexport default Calculator;\n","import { useCalculator } from \"@/hooks/calculator/useCalculator\";\nimport { CalculatorInput } from \"@/views/Calculator/CalculatorInput\";\nimport { useCalculatorContext } from \"@/views/Calculator/Context\";\n\nexport const ChangePoolModal = ({ onClose }: { onClose: () => void }) => {\n const {\n selectedDex: currentDex,\n selectedNetwork: currentNetwork,\n selectedTokenA: currentTokenA,\n selectedTokenB: currentTokenB,\n poolKey: currentPoolKey,\n } = useCalculatorContext();\n const {\n selectedDex,\n selectedNetwork,\n tokenA,\n tokenB,\n feeTier,\n onCalculate,\n isCalculating,\n ...props\n } = useCalculator(true);\n\n const isUnchanged =\n currentDex.name === selectedDex.name &&\n currentNetwork.id === selectedNetwork.id &&\n currentTokenA?.address === tokenA?.address &&\n currentTokenB?.address === tokenB?.address &&\n currentPoolKey === feeTier;\n const isDisabled = !tokenA || !tokenB || !feeTier;\n\n return (\n <CalculatorInput\n isModal={true}\n {...{\n ...props,\n selectedDex,\n selectedNetwork,\n tokenA,\n tokenB,\n feeTier,\n isCalculating,\n }}\n onCalculate={() => onCalculate().then(() => onClose())}\n isBtnDisabled={isDisabled || isUnchanged}\n />\n );\n};\n","import { useConnectStore } from \"@/components/GlobalStore\";\nimport { WrongNetworkModal } from \"@/components/Modal/WrongNetworkModal\";\nimport { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { useSnackbarV2 } from \"@/components/SnackbarContext/SnackbarContextV2\";\nimport { OpenPositionQueryKey as QueryKey } from \"@/utils/browserHistory\";\nimport { getTokensAmountFromDepositAmountUSD } from \"@/utils/calculator/math\";\nimport { checkAddresses } from \"@/utils/helper\";\nimport { getNetworkId, getSwitchNetworkError } from \"@/utils/networkHelper\";\nimport {\n E_ModalKey,\n Modal,\n PureDepositAmount,\n useModal,\n} from \"@aperture/uikitv2\";\nimport { getLogger } from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { useRouter } from \"next/router\";\nimport { useSwitchChain } from \"wagmi\";\nimport { useCalculatorContext } from \"./Context\";\nimport { useCalculatorDetailContext } from \"./DetailContext\";\n\nexport const DepositAmount = () => {\n const { state, setModalState } = useModal();\n const { isOpen } = state[E_ModalKey.SWITCH_NETWORK_MODAL];\n const router = useRouter();\n const {\n token0,\n isFullRange,\n poolTicks,\n depositAmount,\n priceAssumptionValue,\n priceRangeMaxValue,\n priceRangeMinValue,\n token0PriceChart,\n token1PriceChart,\n setDepositAmount,\n } = useCalculatorDetailContext();\n\n const {\n selectedTokenA,\n selectedTokenB,\n poolKey,\n selectedDex,\n selectedNetwork,\n } = useCalculatorContext();\n const { amm, network } = useNetwork();\n const { connectType } = useConnectStore();\n const { switchChain } = useSwitchChain();\n const { addSnackbar } = useSnackbarV2();\n\n const P = priceAssumptionValue;\n let Pl = priceRangeMinValue;\n let Pu = priceRangeMaxValue;\n\n const priceUSDX = token1PriceChart?.currentPriceUSD || 1;\n const priceUSDY = token0PriceChart?.currentPriceUSD || 1;\n const depositAmountUSD = Number(depositAmount);\n\n if (isFullRange && poolTicks) {\n const firstTick = poolTicks[0];\n const lastTick = poolTicks[poolTicks.length - 1];\n Pl = Number(firstTick.price0);\n Pu = Number(lastTick.price0);\n }\n\n const { amount0, amount1 } = getTokensAmountFromDepositAmountUSD(\n P,\n Pl,\n Pu,\n priceUSDX,\n priceUSDY,\n depositAmountUSD\n );\n\n const tokenAValue = amount1 * priceUSDY;\n const tokenBValue = amount0 * priceUSDX;\n\n const tokens = checkAddresses(token0?.id, selectedTokenA?.address)\n ? [selectedTokenA, selectedTokenB]\n : [selectedTokenB, selectedTokenA];\n\n const toggleModal = (open: boolean) => {\n setModalState(E_ModalKey.SWITCH_NETWORK_MODAL, open);\n };\n\n const goToOpenPosition = () => {\n router.push({\n pathname: \"/new-position\",\n query: {\n [QueryKey.TOKEN_A]: `${selectedTokenA?.address}-${selectedTokenA?.native}`,\n [QueryKey.TOKEN_B]: `${selectedTokenB?.address}-${selectedTokenB?.native}`,\n [QueryKey.FEE_TIER]: poolKey,\n },\n });\n };\n\n const handleCreatePosition = () => {\n if (!selectedTokenA || !selectedTokenB) return;\n getLogger().info(\"Calculator.ClickCreatePosition\");\n const isCurrentNetwork = network === selectedNetwork.id;\n const isCurrentAmm = amm.name === selectedDex.name;\n if (!isCurrentNetwork || !isCurrentAmm) {\n toggleModal(true);\n } else {\n goToOpenPosition();\n }\n };\n\n return (\n <>\n <PureDepositAmount\n defaultAmount={depositAmount}\n tokens={[\n {\n ticker: tokens[0]?.ticker,\n Icon: tokens[0]?.Icon,\n value: tokenAValue.toFixed(2),\n percentage: (depositAmountUSD > 0\n ? (tokenAValue / depositAmountUSD) * 100\n : 0\n ).toFixed(2),\n },\n {\n ticker: tokens[1]?.ticker,\n Icon: tokens[1]?.Icon,\n value: tokenBValue.toFixed(2),\n percentage: (depositAmountUSD > 0\n ? (tokenBValue / depositAmountUSD) * 100\n : 0\n ).toFixed(2),\n },\n ]}\n onInputChange={setDepositAmount}\n onClick={handleCreatePosition}\n />\n <Modal isModalOpen={isOpen} onClose={() => toggleModal(false)}>\n <WrongNetworkModal\n switchToChain={selectedNetwork.id}\n onclose={() => {\n toggleModal(false);\n switchChain?.(\n {\n chainId: getNetworkId(selectedNetwork.id),\n },\n {\n onSuccess: () => goToOpenPosition(),\n onError: (switchChainErrorMsg) => {\n getLogger().error(\"Calculator.SwitchNetworkError\", {\n error: switchChainErrorMsg.toString(),\n });\n addSnackbar({\n info: getSwitchNetworkError(connectType),\n status: \"failed\",\n });\n },\n }\n );\n }}\n />\n </Modal>\n </>\n );\n};\n","import {\n estimateFee,\n getLiquidityDelta,\n getLiquidityFromTick,\n getTickFromPrice,\n getTokensAmountFromDepositAmountUSD,\n} from \"@/utils/calculator/math\";\nimport { checkAddresses } from \"@/utils/helper\";\nimport { useCalculatorContext } from \"@/views/Calculator/Context\";\nimport {\n CalculatorDetailContextType,\n useCalculatorDetailContext,\n} from \"@/views/Calculator/DetailContext\";\nimport {\n FlexColumn,\n IForm,\n ImpermanentLossContent,\n PureImpermanentLossForm,\n} from \"@aperture/uikitv2\";\n\nimport { useCallback, useState } from \"react\";\n\nexport const ImpermanentLossModal = () => {\n const state = useCalculatorDetailContext();\n const { selectedTokenA, selectedTokenB } = useCalculatorContext();\n\n const { token0, token0PriceChart, token1PriceChart } = state;\n\n const { form, handleInputChange } = useForm({\n activeDays: \"0\",\n tokenACurrentPrice: String(token0PriceChart?.currentPriceUSD || \"0\"),\n tokenBCurrentPrice: String(token1PriceChart?.currentPriceUSD || \"0\"),\n tokenAFuturePrice: String(token0PriceChart?.currentPriceUSD || \"0\"),\n tokenBFuturePrice: String(token1PriceChart?.currentPriceUSD || \"0\"),\n });\n\n const {\n strategyA,\n strategyB,\n impermanentLoss,\n PnL,\n days: daysRequired,\n } = getPropsFromState(form, state);\n\n const tokens = checkAddresses(token0.id, selectedTokenA?.address)\n ? [selectedTokenA, selectedTokenB]\n : [selectedTokenB, selectedTokenA];\n\n return (\n <FlexColumn gap=\"lg\">\n <ImpermanentLossContent\n {...{\n tokenA: tokens[0],\n tokenB: tokens[1],\n strategyA,\n strategyB,\n impermanentLoss,\n PnL,\n days: Number(form.activeDays),\n }}\n />\n <PureImpermanentLossForm\n form={form}\n tokenA={tokens[0]}\n tokenB={tokens[1]}\n daysRequired={daysRequired}\n handleInputChange={handleInputChange}\n />\n </FlexColumn>\n );\n};\n\nconst getPropsFromState = (form: IForm, state: CalculatorDetailContextType) => {\n const {\n pool,\n volume24H,\n isPairToggled,\n token0,\n token1,\n priceRangeMaxValue,\n priceRangeMinValue,\n depositAmount,\n isFullRange,\n poolTicks,\n token1PriceChart,\n token0PriceChart,\n } = state;\n\n const priceRangeValue = [priceRangeMinValue, priceRangeMaxValue];\n\n const currentPrice = [\n Number(form.tokenACurrentPrice),\n Number(form.tokenBCurrentPrice),\n ];\n const futurePrice = [\n Number(form.tokenAFuturePrice),\n Number(form.tokenBFuturePrice),\n ];\n\n const daysInPosition = Number(form.activeDays);\n\n const depositAmountUSD = Number(depositAmount);\n const calculateTokensAmount = (pricesUSD: number[]) => {\n const P = pricesUSD[1] / pricesUSD[0];\n let Pl = priceRangeValue[0];\n let Pu = priceRangeValue[1];\n\n if (isFullRange && poolTicks) {\n const firstTick = poolTicks[0];\n const lastTick = poolTicks[poolTicks.length - 1];\n Pl = Number(firstTick.price0);\n Pu = Number(lastTick.price0);\n }\n\n const { amount0, amount1, liquidityDelta } =\n getTokensAmountFromDepositAmountUSD(\n P,\n Pl,\n Pu,\n pricesUSD[1],\n pricesUSD[0],\n depositAmountUSD\n );\n\n return { price: P, amount0, amount1, liquidityDelta };\n };\n\n const current = calculateTokensAmount(currentPrice);\n\n // Calculate future price based on liquidityDelta\n const liquidityDelta = current.liquidityDelta;\n const future = (() => {\n let P = futurePrice[1] / futurePrice[0];\n let Pl = priceRangeValue[0];\n let Pu = priceRangeValue[1];\n\n if (P < Pl) P = Pl;\n if (P > Pu) P = Pu;\n\n let deltaY = liquidityDelta * (Math.sqrt(P) - Math.sqrt(Pl));\n if (deltaY * futurePrice[0] < 0) deltaY = 0;\n if (P < Pl) deltaY = 0;\n\n let deltaX = liquidityDelta * (1 / Math.sqrt(P) - 1 / Math.sqrt(Pu));\n if (deltaX * futurePrice[1] < 0) deltaX = 0;\n\n return { price: P, amount0: deltaX, amount1: deltaY };\n })();\n\n // TODO: current don't need this in our design, but just leave it here for now\n // const futurePrice0Percentage =\n // (100 * (futurePrice[0] - currentPrice[0])) / currentPrice[0];\n // const futurePrice1Percentage =\n // (100 * (futurePrice[1] - currentPrice[1])) / currentPrice[1];\n\n // Strategy A\n const valueUSDToken0A = current.amount1 * futurePrice[0];\n const valueUSDToken1A = current.amount0 * futurePrice[1];\n const totalValueA = valueUSDToken0A + valueUSDToken1A;\n const percentageA =\n depositAmountUSD > 0\n ? (100 * (totalValueA - depositAmountUSD)) / depositAmountUSD\n : 0;\n\n // Strategy B\n const token0AmountB = future.amount1;\n const token1AmountB = future.amount0;\n const valueUSDToken0B = token0AmountB * futurePrice[0];\n const valueUSDToken1B = token1AmountB * futurePrice[1];\n\n const P = current.price;\n let Pl = priceRangeValue[0];\n let Pu = priceRangeValue[1];\n const priceUSDX = token1PriceChart?.currentPriceUSD || 1;\n const priceUSDY = token0PriceChart?.currentPriceUSD || 1;\n\n if (isFullRange && poolTicks) {\n const firstTick = poolTicks[0];\n const lastTick = poolTicks[poolTicks.length - 1];\n Pl = Number(firstTick.price0);\n Pu = Number(lastTick.price0);\n }\n\n const { amount0, amount1 } = getTokensAmountFromDepositAmountUSD(\n P,\n Pl,\n Pu,\n priceUSDX,\n priceUSDY,\n depositAmountUSD\n );\n\n const deltaL = getLiquidityDelta(\n P,\n Pl,\n Pu,\n amount0,\n amount1,\n Number(token0?.decimals || 18),\n Number(token1?.decimals || 18)\n );\n\n let currentTick = getTickFromPrice(\n P,\n token0?.decimals || 18,\n token1?.decimals || 18\n );\n\n if (isPairToggled) currentTick = -currentTick;\n\n // TODO: check if need useMemo\n // const L = useMemo(\n // () => getLiquidityFromTick(poolTicks || [], currentTick),\n // [poolTicks, currentTick]\n // );\n const L = getLiquidityFromTick(poolTicks || [], currentTick);\n\n const feeTier = pool?.feeTier || \"\";\n const estimatedFee =\n P >= Pl && P <= Pu ? estimateFee(deltaL, L, volume24H, feeTier) : 0;\n\n const estimatedYield = estimatedFee * daysInPosition;\n const yieldPercentage = (100 * estimatedYield) / depositAmountUSD;\n\n const totalValueB = valueUSDToken0B + valueUSDToken1B + estimatedYield;\n const percentageB =\n depositAmountUSD > 0\n ? (100 * (totalValueB - depositAmountUSD)) / depositAmountUSD\n : 0;\n\n // Summary\n const IL = Math.abs(totalValueA - (valueUSDToken0B + valueUSDToken1B));\n const ILPercentage = Math.abs((100 * IL) / totalValueA);\n\n const PnL = totalValueB - totalValueA;\n const PnLPercentage = (100 * PnL) / totalValueA;\n\n const minDaysToProfit = estimatedFee > 0 ? IL / estimatedFee : 0;\n\n return {\n strategyA: {\n title: \"Strategy A: HODL\",\n amountUSD: totalValueA,\n strategyPL: percentageA,\n tokenA: {\n amt: current.amount1,\n amtUSD: valueUSDToken0A,\n },\n tokenB: {\n amt: current.amount0,\n amtUSD: valueUSDToken1A,\n },\n },\n strategyB: {\n title: \"Strategy B: LP\",\n amountUSD: totalValueB,\n strategyPL: percentageB,\n tokenA: {\n amt: token0AmountB,\n amtUSD: valueUSDToken0B,\n },\n tokenB: {\n amt: token1AmountB,\n amtUSD: valueUSDToken1B,\n },\n lpYield: {\n percentage: yieldPercentage,\n amountUSD: estimatedYield,\n },\n },\n impermanentLoss: {\n percentage: ILPercentage,\n amountUSD: IL,\n },\n PnL: {\n percentage: PnLPercentage,\n amountUSD: PnL,\n },\n days: minDaysToProfit,\n };\n};\n\nconst useForm = (initialState: IForm) => {\n const [form, setForm] = useState<IForm>(initialState);\n\n const handleInputChange = useCallback((key: keyof IForm, value: string) => {\n setForm((prevForm) => ({\n ...prevForm,\n [key]: value,\n }));\n }, []);\n\n return { form, handleInputChange };\n};\n","import { ImpermanentLossModal } from \"@/components/Modal/ImpermanentLossModal\";\nimport {\n estimateFee,\n getLiquidityDelta,\n getLiquidityFromTick,\n getTickFromPrice,\n getTokensAmountFromDepositAmountUSD,\n} from \"@/utils/calculator/math\";\nimport {\n E_ModalKey,\n Modal,\n PureEstimatedFees,\n useModal,\n} from \"@aperture/uikitv2\";\nimport { getLogger } from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { useMemo } from \"react\";\nimport { useCalculatorContext } from \"./Context\";\nimport { useCalculatorDetailContext } from \"./DetailContext\";\n\nexport const EstimatedFees = () => {\n const { state, setModalState } = useModal();\n const { isOpen } = state[E_ModalKey.IMPERMANENT_LOSS_MODAL];\n const {\n priceAssumptionValue,\n priceRangeMinValue,\n priceRangeMaxValue,\n depositAmount,\n isFullRange,\n poolTicks,\n token0PriceChart,\n token1PriceChart,\n isPairToggled,\n volume24H,\n pool,\n token0,\n token1,\n } = useCalculatorDetailContext();\n const { selectedTokenA, selectedTokenB } = useCalculatorContext();\n\n const P = priceAssumptionValue;\n let Pl = priceRangeMinValue;\n let Pu = priceRangeMaxValue;\n const priceUSDX = token1PriceChart?.currentPriceUSD || 1;\n const priceUSDY = token0PriceChart?.currentPriceUSD || 1;\n const depositAmountUSD = Number(depositAmount);\n\n if (isFullRange && poolTicks) {\n const firstTick = poolTicks[0];\n const lastTick = poolTicks[poolTicks.length - 1];\n Pl = Number(firstTick.price0);\n Pu = Number(lastTick.price0);\n }\n\n const { amount0, amount1 } = getTokensAmountFromDepositAmountUSD(\n P,\n Pl,\n Pu,\n priceUSDX,\n priceUSDY,\n depositAmountUSD\n );\n\n const deltaL = getLiquidityDelta(\n P,\n Pl,\n Pu,\n amount0,\n amount1,\n Number(token0?.decimals || 18),\n Number(token1?.decimals || 18)\n );\n\n let currentTick = getTickFromPrice(\n P,\n token0?.decimals || 18,\n token1?.decimals || 18\n );\n\n if (isPairToggled) currentTick = -currentTick;\n\n const L = useMemo(\n () => getLiquidityFromTick(poolTicks || [], currentTick),\n [poolTicks, currentTick]\n );\n const feeTier = pool?.feeTier || \"\";\n\n const estimatedFee =\n P >= Pl && P <= Pu ? estimateFee(deltaL, L, volume24H, feeTier) : 0;\n\n const toggleModal = (open: boolean) => {\n setModalState(E_ModalKey.IMPERMANENT_LOSS_MODAL, open);\n };\n\n return (\n <>\n <PureEstimatedFees\n amount={estimatedFee.toFixed(2)}\n monthly={{\n value: (estimatedFee * 30).toFixed(2),\n percentage: (depositAmountUSD > 0\n ? (100 * (estimatedFee * 30)) / depositAmountUSD\n : 0\n ).toFixed(2),\n }}\n yearly={{\n value: (estimatedFee * 365).toFixed(2),\n percentage: (depositAmountUSD\n ? (100 * (estimatedFee * 365)) / depositAmountUSD\n : 0\n ).toFixed(2),\n }}\n onClick={() => {\n if (!selectedTokenA || !selectedTokenB) return;\n toggleModal(true);\n getLogger().info(\"Calculator.ClickImpermanentLoss\");\n }}\n />\n\n <Modal\n disableBackgroundOnClose={true}\n isModalOpen={isOpen}\n onClose={() => toggleModal(false)}\n padding={16}\n >\n <ImpermanentLossModal />\n </Modal>\n </>\n );\n};\n","import {\n ChartPrice,\n divideArray,\n findMax,\n findMin,\n PurePriceRange,\n} from \"@aperture/uikitv2\";\nimport { getLogger } from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { useCalculatorDetailContext } from \"./DetailContext\";\n\nexport const PriceRange = () => {\n const {\n pool,\n isFullRange,\n token0PriceChart,\n token1PriceChart,\n priceAssumptionValue,\n priceRangeMinValue,\n token0,\n token1,\n priceRangeMaxValue,\n handleIsFullRange,\n handlePriceAssumptionValue,\n handlePriceRangeMaxValue,\n handlePriceRangeMinValue,\n } = useCalculatorDetailContext();\n\n const prices = divideArray(\n (token1PriceChart?.prices || []).map((p: ChartPrice) => p.value),\n (token0PriceChart?.prices || []).map((p: ChartPrice) => p.value)\n );\n const currentPrice = Number(pool?.token0Price || NaN);\n let _min = findMin(prices);\n let _max = findMax(prices);\n if (token0PriceChart === null || token1PriceChart === null) {\n _min = currentPrice - currentPrice * 0.3;\n _max = currentPrice + currentPrice * 0.3;\n }\n const margin = _max - _min;\n const min = Math.max(0, _min - margin);\n const max = _max + margin;\n\n return (\n <PurePriceRange\n min={min}\n max={max}\n token0Ticker={token0.symbol}\n token1Ticker={token1.symbol}\n isFullRange={isFullRange}\n minValue={priceRangeMinValue}\n maxValue={priceRangeMaxValue}\n assumptionValue={priceAssumptionValue}\n onFullRangeToggle={(v) => {\n handleIsFullRange(v);\n getLogger().info(\"Calculator.PriceRange.ToggleFullRange\", { value: v });\n }}\n updateMinValue={handlePriceRangeMinValue}\n updateMaxValue={handlePriceRangeMaxValue}\n updateAssumptionValue={handlePriceAssumptionValue}\n />\n );\n};\n","import { ChangePoolModal } from \"@/components/Modal/ChangePoolModal\";\nimport { OpenPositionQueryKey as QueryKey } from \"@/utils/browserHistory\";\nimport { getPositionBreakdown } from \"@/utils/calculator/data\";\nimport { convertToChartToken } from \"@/utils/calculator/helper\";\nimport { checkAddresses } from \"@/utils/helper\";\nimport { supportedNetwork } from \"@/utils/networkHelper\";\nimport { AccessoryIcons } from \"@aperture/assetkit\";\nimport { ITokenTickerIconPair } from \"@aperture/types\";\nimport { PositionInfoTitle } from \"@aperture/uikit\";\nimport {\n Button,\n CorrelationChart,\n E_ModalKey,\n Flex,\n FlexColumn,\n LinearLoader,\n LiquidityPositionChart,\n Modal,\n PositionBreakdownChart,\n useModal,\n} from \"@aperture/uikitv2\";\nimport { getLogger } from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { useSearchParams } from \"next/navigation\";\nimport { useEffect, useMemo } from \"react\";\nimport styled, { useTheme } from \"styled-components\";\nimport { useCalculatorContext } from \"./Context\";\nimport { DepositAmount } from \"./DepositAmount\";\nimport { useCalculatorDetailContext } from \"./DetailContext\";\nimport { EstimatedFees } from \"./EstimatedFees\";\nimport { PriceRange } from \"./PriceRange\";\n\nconst TogglePairIcon = styled(AccessoryIcons.ExchangeIcon2)`\n transform: rotate(-90deg);\n path {\n fill: ${({ theme }) => theme.colors.global.textAlt.T1};\n }\n`;\nconst StyledChangeIcon = styled(AccessoryIcons.ChangeIcon)`\n path,\n circle {\n stroke: ${({ theme }) => theme.colors.global.textAlt.T1};\n }\n`;\nconst IconWrapper = styled.div`\n height: 28px;\n width: 28px;\n svg {\n height: 28px;\n width: 28px;\n }\n`;\nconst StyledButton = styled(Button)`\n width: 178px;\n height: 44px;\n`;\nconst TitleWrapper = styled(Flex)`\n padding-block: 8px;\n align-items: center;\n`;\nconst TitleTag = styled.div`\n padding-inline: 8px;\n height: fit-content;\n font-size: 12px;\n line-height: 20px;\n border-radius: ${({ theme }) => theme.radii.sm};\n color: ${({ theme }) => theme.colors.global.textAlt.T1};\n background-color: ${({ theme }) => theme.colors.global.primary};\n`;\n\nexport const CalculatorDetail = () => {\n const theme = useTheme();\n const { state, setModalState } = useModal();\n const { isOpen } = state[E_ModalKey.CHANGE_POOL_MODAL];\n const {\n selectedDex,\n selectedNetwork,\n poolKey,\n handleSelectedDex,\n handleSelectedNetwork,\n setPoolKeyUrl,\n selectedTokenA,\n selectedTokenB,\n setSelectedToken,\n showDetail,\n setShowDetail,\n } = useCalculatorContext();\n const {\n togglePair,\n token0,\n token1,\n isPairToggled,\n isFullRange,\n sdkPool,\n poolTicks,\n token0PriceChart,\n token1PriceChart,\n priceRangeMinValue,\n priceRangeMaxValue,\n priceAssumptionValue,\n depositAmount,\n poolVolumes,\n positionBreakdown,\n handlePositionBreakdown,\n resetData,\n } = useCalculatorDetailContext();\n\n const convertedPoolTicks = useMemo(\n () =>\n poolTicks.map((tick) => ({\n ...tick,\n tickIdx: Number(tick.tickIdx),\n liquidityNet: Number(tick.liquidityNet),\n })),\n [poolTicks]\n );\n\n useEffect(() => {\n getPositionBreakdown(\n supportedNetwork[selectedNetwork.id],\n sdkPool,\n priceAssumptionValue,\n isFullRange ? 0 : priceRangeMinValue,\n isFullRange ? 1e18 : priceRangeMaxValue,\n token0PriceChart?.currentPriceUSD || 1,\n token1PriceChart?.currentPriceUSD || 1,\n depositAmount,\n token0,\n token1\n ).then((positionBreakdown) => {\n handlePositionBreakdown(positionBreakdown);\n });\n }, [\n isFullRange,\n priceRangeMinValue,\n priceRangeMaxValue,\n priceAssumptionValue,\n ]);\n\n const searchParams = useSearchParams();\n const calc_network = searchParams.get(QueryKey.CALC_NETWORK);\n const calc_dex = searchParams.get(QueryKey.CALC_DEX);\n\n if (showDetail && (!calc_dex || !calc_network)) {\n setShowDetail(false);\n handleSelectedDex(selectedDex);\n handleSelectedNetwork(selectedNetwork);\n setSelectedToken(QueryKey.TOKEN_A, null);\n setSelectedToken(QueryKey.TOKEN_B, null);\n setPoolKeyUrl(undefined);\n resetData();\n return undefined;\n }\n\n const _token0 = convertToChartToken(token0, token0PriceChart);\n const _token1 = convertToChartToken(token1, token1PriceChart);\n\n // token1 / token0\n const tokens: ITokenTickerIconPair = checkAddresses(\n token0.id,\n selectedTokenA?.address\n )\n ? [selectedTokenB, selectedTokenA]\n : [selectedTokenA, selectedTokenB];\n\n const toggleModal = (open: boolean) => {\n setModalState(E_ModalKey.CHANGE_POOL_MODAL, open);\n };\n\n const isTitleLoading = !selectedTokenA || !selectedTokenB;\n const { Icon: DexIcon } = selectedDex;\n return (\n <>\n <Flex gap=\"7xl\">\n <FlexColumn gap={20}>\n <TitleWrapper gap=\"md\">\n <Flex gap=\"sm2\" alignItems=\"center\">\n {isTitleLoading ? (\n <LinearLoader size=\"180px\" height=\"28.13px\" />\n ) : (\n <PositionInfoTitle\n tokens={tokens}\n feeTier={poolKey}\n size={28}\n titleSize=\"lg2\"\n padding=\"0px 8px\"\n fontSize=\"12px\"\n lineHeight=\"20px\"\n iconGap={12}\n tagGap={20}\n color={theme.colors.global.textAlt.T1}\n />\n )}\n <TitleTag>{selectedNetwork.name}</TitleTag>\n </Flex>\n <IconWrapper>\n <DexIcon />\n </IconWrapper>\n </TitleWrapper>\n <EstimatedFees />\n <DepositAmount />\n <PriceRange />\n </FlexColumn>\n <FlexColumn gap={20}>\n <Flex gap=\"lg\" justifyContent=\"flex-end\">\n <StyledButton\n variant=\"primary\"\n size=\"lg\"\n iconGap={10}\n iconPosition=\"start\"\n icon={<TogglePairIcon />}\n onClick={togglePair}\n >\n Toggle Pair\n </StyledButton>\n <StyledButton\n variant=\"secondary\"\n size=\"lg\"\n iconGap={10}\n iconPosition=\"start\"\n icon={<StyledChangeIcon />}\n onClick={() => {\n toggleModal(true);\n getLogger().info(\"Calculator.ClickChangePool\");\n }}\n >\n Change Pool\n </StyledButton>\n </Flex>\n <LiquidityPositionChart\n isPairToggled={isPairToggled}\n isFullRange={isFullRange}\n poolTicks={convertedPoolTicks}\n token0={_token0}\n token1={_token1}\n token0PriceChart={token0PriceChart.prices}\n token1PriceChart={token1PriceChart.prices}\n priceRangeValue={[priceRangeMinValue, priceRangeMaxValue]}\n priceAssumptionValue={priceAssumptionValue}\n />\n <CorrelationChart\n isFullRange={isFullRange}\n token0={_token0}\n token1={_token1}\n token0PriceChart={token0PriceChart.prices}\n token1PriceChart={token1PriceChart.prices}\n priceRangeValue={[priceRangeMinValue, priceRangeMaxValue]}\n priceAssumptionValue={priceAssumptionValue}\n poolDayDatas={poolVolumes}\n />\n <PositionBreakdownChart\n isFullRange={isFullRange}\n token0={_token0}\n token1={_token1}\n token0PriceChart={token0PriceChart.prices}\n token1PriceChart={token1PriceChart.prices}\n priceRangeValue={[priceRangeMinValue, priceRangeMaxValue]}\n priceAssumptionValue={priceAssumptionValue}\n positionBreakDown={positionBreakdown}\n />\n </FlexColumn>\n </Flex>\n <Modal\n disableBackgroundOnClose={true}\n isModalOpen={isOpen}\n onClose={() => toggleModal(false)}\n padding={16}\n >\n <ChangePoolModal {...{ onClose: () => toggleModal(false) }} />\n </Modal>\n </>\n );\n};\n","import Calculator from \"@/views/Calculator/Calculator\";\nimport {\n CalculatorProvider,\n useCalculatorContext,\n} from \"@/views/Calculator/Context\";\nimport { CalculatorDetail } from \"@/views/Calculator/Detail\";\nimport { CalculatorDetailProvider } from \"@/views/Calculator/DetailContext\";\nimport { PageContainer } from \"@/views/style\";\nimport { AccessoryIcons } from \"@aperture/assetkit\";\nimport {\n Button,\n Flex,\n FlexColumn,\n H1,\n T3Medium,\n T3Regular,\n} from \"@aperture/uikitv2\";\nimport { useRouter } from \"next/navigation\";\nimport styled, { useTheme } from \"styled-components\";\n\nconst StyledPageContainer = styled(PageContainer)`\n max-width: 1080px;\n margin-top: 20px;\n`;\nconst StyledH1 = styled(H1)`\n color: ${({ theme }) => theme.colors.global.text.T1};\n`;\nconst StyledT3 = styled(T3Regular)`\n white-space: pre-line;\n color: ${({ theme }) => theme.colors.global.text.T2};\n`;\nconst Container = styled(FlexColumn)`\n width: 380px;\n`;\nconst StyledButton = styled(Button)`\n svg {\n width: 16px;\n height: 16px;\n }\n`;\n\nconst ApertureCalculator = () => (\n <CalculatorProvider>\n <CalculatorDetailProvider>\n <StyledPageContainer>\n <CalculatorContent />\n </StyledPageContainer>\n </CalculatorDetailProvider>\n </CalculatorProvider>\n);\n\nconst CalculatorContent = () => {\n const theme = useTheme();\n const router = useRouter();\n const { showDetail } = useCalculatorContext();\n const poolOverviewText = `\\n\\nHead to our Pool Discovery page to find the best performing pools.`;\n\n if (showDetail) {\n return <CalculatorDetail />;\n }\n\n return (\n <Flex gap={60} justifyContent=\"space-between\">\n <Container gap=\"3xl\">\n <FlexColumn gap=\"md2\">\n <StyledT3>Welcome to</StyledT3>\n <StyledH1>Aperture Calculator</StyledH1>\n </FlexColumn>\n <StyledT3>{`Aperture Calculator is your one-stop solution for simulating Concentrated Liquidity positions, allowing you to calculate, analyze, manage, and track everything in one place.${poolOverviewText}\\n\\nReady to dive in? Start by selecting an exchange, network, pair, and fee tier then hit calculate.`}</StyledT3>\n <StyledButton\n onClick={() => router.push(\"/calculator/pools\")}\n width=\"224px\"\n variant=\"default\"\n icon={\n <AccessoryIcons.LinkIcon2 stroke={theme.colors.global.primary} />\n }\n iconPosition=\"end\"\n >\n <T3Medium>ApertureSwap Top Pools</T3Medium>\n </StyledButton>\n </Container>\n <Calculator />\n </Flex>\n );\n};\n\nexport default ApertureCalculator;\n"],"names":["window","__NEXT_P","push","__webpack_require__","useMutateWarningTokens","networkId","useNetwork","mutate","tokenBalanceMutate","useFetchUserTokensBalance","updateTokenMap","useAllChainStateStore","mutateWarningTokens","useEventCallback","chainId","token","tokens","Array","isArray","mutateWarningTokensByAddress","tokenAddress","addresses","viem","getPublicClient","undefined","useFetchCurrentChainMarketPrice","tokenAAddress","tokenBAddress","publicClient","poolKeys","isSupported","ammEnum","SupportedFeeAmount","shouldFetch","chain","id","useSWR","concat","getFetchMarketPrice","refreshInterval","useFetchMarketPrice","rpcSetting","useRpcSettings","client","length","batchProcessor","MarketPriceBatchProcessor","getInstance","addRequest","tokenA","tokenB","instance","request","queueKey","batchQueues","has","set","requests","pendingPromises","queue","get","Promise","resolve","BATCH_SIZE","processBatchQueue","timer","setTimeout","BATCH_TIMEOUT","clearTimeout","delete","poolRequests","flatMap","map","feeOrTickSpacing","poolKey","pools","pricesList","forEach","pool","index","tokenKey","prices","token0","address","token0Price","toFixed","token1Price","key","tickSpacing","fee","param","error","console","warn","constructor","Map","useFetchTokensFeeTierDistribution","currentNetworkId","token1","toLowerCase","sort","isFeeTierDistributionSupported","indexOf","QueryPeriodEnum","ONE_DAY","ONE_WEEK","ONE_MONTH","THREE_MONTH","ONE_YEAR","MAX","getPriceChart","queryPeriod","getNetworkId","_token","getTokenFromSubgraphToken","marketChartRes","getTokenHistoricalPricesFromCoingecko","Number","timestamp","d","value","tokenId","tokenName","name","currentPriceUSD","CalculatorContext","createContext","CalculatorProvider","children","amm","network","showDetail","setShowDetail","useState","data","tokenMap","useFetchTokenMap","calcDex","calcNetwork","setCalcDexUrl","setCalcNetworkUrl","selectedTokenA","selectedTokenB","feeTier","tickLower","tickUpper","isUrlUpdated","setSelectedToken","setFeeTierUrl","setPoolKeyUrl","setTickUrl","useUrlQuery","useEffect","_dex","isCalculatorAMM","DEFAULT_AMM","_network","CALC_AMM_CHAINS","AmmInfo","includes","selectedDex","selectedNetwork","getChainInfo","handleSelectedDex","dex","handleSelectedNetwork","jsx_runtime","jsx","Provider","isSettingChanged","useCalculatorContext","context","useContext","CalculatorDetailContext","CalculatorDetailProvider","depositAmount","setDepositAmount","isPairToggled","setIsPairToggled","isFullRange","setIsFullRange","poolTicks","setPoolTicks","token0PriceChart","setToken0PriceChart","token1PriceChart","setToken1PriceChart","priceRangeMinValue","setPriceRangeMinValue","priceRangeMaxValue","setPriceRangeMaxValue","priceAssumptionValue","setPriceAssumptionValue","poolVolumes","setPoolVolumes","positionBreakdown","setPositionBreakdown","selectedTokens","setSelectedTokens","setPool","sdkPool","setSdkPool","volume24H","setVolume24H","isLoading","setIsLoading","setToken0","setToken1","resetData","useCallback","setupPair","payload","setupPriceRange","newPool","newToken0PriceChart","newToken1PriceChart","currentPrice","divideArray","p","_min","findMin","_max","findMax","togglePair","getLogger","info","prev","handleIsPairToggled","handleIsFullRange","handlePriceRangeMinValue","handlePriceRangeMaxValue","handlePriceAssumptionValue","handlePoolVolumes","handlePositionBreakdown","useCalculatorDetailContext","disabledTopPositionsNetworkId","SupportedChainId","useCalculator","SubgraphURLs","addSnackbar","useSnackbarV2","currentDex","currentNetwork","currentTokenA","currentTokenB","currentFeeTier","setSelectedDex","setSelectedNetwork","setCalcDex","setCalcNetwork","setTokenA","setTokenB","setFeeTier","isCalculating","setIsCalculating","fetchFromUrlParams","onCalculate","handleReset","defaultNetwork","getNetworksList","handleTokenASelected","checkAddresses","handleTokenBSelected","subgraphEndpoint","ticker","exchange","all","getToken","getPoolFromPair","selectedPool","find","supportedNetwork","sortTokens","getAddress","getAmmEnum","getPoolTicks","getAvgTradingVolume","getPoolVolumes","_poolTicks","getDefaultPoolTicks","QueryKey","e","_e_message","isSubgraphError","toString","isNotFound","message","getTicker","status","log","_e_request","url","responseURL","regex","match","StyledT3","styled","T3Regular","theme","colors","global","text","T1","FeeTierSelectorComponent","setPoolKey","marketPrice","marketPriceLoading","disabled","disableClick","tiers","firstLoad","setFirstLoad","poolStatus","useMemo","statusMap","Object","keys","getMaxSelected","entries","reduce","param1","maxK","maxV","useOnUpdateExist","maxSelected","options","label","jsxs","FlexColumn","gap","FeeTier","createdStatus","selected","onSelect","disableNotCreated","FeeTierSelector","memo","TokenPairSelectorComponent","commonTokens","inModal","walletAddress","useAccount","state","setModalState","useModal","isOpen","E_ModalKey","tokenWarning","setTokenWarning","selectedNetworkId","handleUnknownAddress","fetchUnknownToken","toggleTokenWarningModal","open","commonProps","style","width","Fragment","Flex","TokenDropdownSelector","selectedToken","onSelectToken","onSelectUnknownToken","isTokenA","dropdownContainerStyles","left","right","Modal","isModalOpen","onClose","closeIcon","TokenWarningContent","exploreURL","getExplorerURL","cancelClick","confirmClick","Token","decimals","TokenPairSelector","Container","StyledH2","H2","CalculatorContainer","isModal","spacing","xl","line","Line1","StyledButton","Button","CalculatorInput","isBtnDisabled","dexList","values","CalculatorAmmInfo","networksList","a","b","bigDecimal","amount","DexDropdownSelector","selectedOption","NetworkDropdownSelector","variant","onClick","Spinner","Calculator","currentPoolKey","props","ChangePoolModal","isUnchanged","then","isDisabled","DepositAmount","router","useRouter","connectType","useConnectStore","switchChain","useSwitchChain","Pl","Pu","priceUSDX","priceUSDY","depositAmountUSD","firstTick","lastTick","price0","amount0","amount1","getTokensAmountFromDepositAmountUSD","tokenAValue","tokenBValue","toggleModal","goToOpenPosition","pathname","query","native","handleCreatePosition","isCurrentNetwork","isCurrentAmm","PureDepositAmount","defaultAmount","Icon","percentage","onInputChange","WrongNetworkModal","switchToChain","onclose","onSuccess","onError","switchChainErrorMsg","getSwitchNetworkError","ImpermanentLossModal","form","handleInputChange","useForm","activeDays","tokenACurrentPrice","String","tokenBCurrentPrice","tokenAFuturePrice","tokenBFuturePrice","strategyA","strategyB","impermanentLoss","PnL","days","daysRequired","getPropsFromState","ImpermanentLossContent","PureImpermanentLossForm","P","deltaY","deltaX","priceRangeValue","futurePrice","daysInPosition","current","calculateTokensAmount","pricesUSD","liquidityDelta","price","future","Math","sqrt","valueUSDToken0A","valueUSDToken1A","totalValueA","token0AmountB","token1AmountB","valueUSDToken0B","valueUSDToken1B","deltaL","getLiquidityDelta","currentTick","getTickFromPrice","L","getLiquidityFromTick","estimatedFee","estimateFee","estimatedYield","totalValueB","IL","abs","title","amountUSD","strategyPL","amt","amtUSD","lpYield","setForm","initialState","prevForm","EstimatedFees","PureEstimatedFees","monthly","yearly","disableBackgroundOnClose","padding","PriceRange","NaN","margin","min","max","PurePriceRange","token0Ticker","symbol","token1Ticker","minValue","maxValue","assumptionValue","onFullRangeToggle","v","updateMinValue","updateMaxValue","updateAssumptionValue","TogglePairIcon","AccessoryIcons","withConfig","textAlt","StyledChangeIcon","IconWrapper","TitleWrapper","TitleTag","radii","sm","primary","CalculatorDetail","useTheme","convertedPoolTicks","tick","tickIdx","liquidityNet","getPositionBreakdown","searchParams","useSearchParams","calc_network","calc_dex","_token0","convertToChartToken","_token1","DexIcon","alignItems","isTitleLoading","PositionInfoTitle","size","titleSize","fontSize","lineHeight","iconGap","tagGap","color","LinearLoader","height","justifyContent","iconPosition","icon","LiquidityPositionChart","CorrelationChart","poolDayDatas","PositionBreakdownChart","positionBreakDown","StyledPageContainer","PageContainer","StyledH1","H1","T2","ApertureCalculator","CalculatorContent","stroke","T3Medium","calculator"],"sourceRoot":""}