diff --git a/apps/web/src/hooks/v3/usePoolTickData.ts b/apps/web/src/hooks/v3/usePoolTickData.ts index c2aa91f7d9ba3..bf513c17f3447 100644 --- a/apps/web/src/hooks/v3/usePoolTickData.ts +++ b/apps/web/src/hooks/v3/usePoolTickData.ts @@ -29,13 +29,19 @@ function useTicksFromSubgraph( } // Fetches all ticks for a given pool -export function useAllV3Ticks( - currencyA: Currency | undefined | null, - currencyB: Currency | undefined | null, - feeAmount: FeeAmount | undefined, - activeTick: number | undefined, +export function useAllV3Ticks({ + currencyA, + currencyB, + feeAmount, + activeTick, enabled = true, -): { +}: { + currencyA?: Currency | null + currencyB?: Currency | null + feeAmount?: FeeAmount + activeTick?: number + enabled?: boolean +}): { isLoading: boolean error: unknown ticks: TickData[] | undefined @@ -64,7 +70,7 @@ export function usePoolActiveLiquidity( // Find nearest valid tick for pool in case tick is not initialized. const activeTick = useMemo(() => getActiveTick(pool[1]?.tickCurrent, feeAmount), [pool, feeAmount]) - const { isLoading, error, ticks } = useAllV3Ticks(currencyA, currencyB, activeTick, feeAmount) + const { isLoading, error, ticks } = useAllV3Ticks({ currencyA, currencyB, feeAmount, activeTick }) return useMemo(() => { if ( diff --git a/apps/web/src/views/AddLiquidityV3/components/AprCalculator.tsx b/apps/web/src/views/AddLiquidityV3/components/AprCalculator.tsx index 7d106bb45953b..0c39086103f39 100644 --- a/apps/web/src/views/AddLiquidityV3/components/AprCalculator.tsx +++ b/apps/web/src/views/AddLiquidityV3/components/AprCalculator.tsx @@ -114,7 +114,7 @@ export function AprCalculator({ [sqrtRatioX96], ) const activeTick = useMemo(() => getActiveTick(tickCurrent, feeAmount), [tickCurrent, feeAmount]) - const { ticks: data } = useAllV3Ticks(baseCurrency, quoteCurrency, activeTick, feeAmount) + const { ticks: data } = useAllV3Ticks({ currencyA: baseCurrency, currencyB: quoteCurrency, feeAmount, activeTick }) const volume24H = usePoolAvgTradingVolume({ address: poolAddress, chainId: pool?.token0.chainId, diff --git a/apps/web/src/views/Farms/components/FarmCard/V3/FarmV3ApyButton.tsx b/apps/web/src/views/Farms/components/FarmCard/V3/FarmV3ApyButton.tsx index 776e01d93416b..7a8905b68414f 100644 --- a/apps/web/src/views/Farms/components/FarmCard/V3/FarmV3ApyButton.tsx +++ b/apps/web/src/views/Farms/components/FarmCard/V3/FarmV3ApyButton.tsx @@ -120,7 +120,13 @@ function FarmV3ApyButton_({ [sqrtRatioX96], ) const activeTick = useMemo(() => getActiveTick(tickCurrent, feeAmount), [tickCurrent, feeAmount]) - const { ticks: data } = useAllV3Ticks(baseCurrency, quoteCurrency, feeAmount, activeTick, roiModal.isOpen) + const { ticks: data } = useAllV3Ticks({ + currencyA: baseCurrency, + currencyB: quoteCurrency, + feeAmount, + activeTick, + enabled: roiModal.isOpen, + }) const cakePrice = useCakePrice() diff --git a/apps/web/src/views/universalFarms/components/PoolAprButton/V3PoolAprModal.tsx b/apps/web/src/views/universalFarms/components/PoolAprButton/V3PoolAprModal.tsx index 2aa9f10da7482..996418285705c 100644 --- a/apps/web/src/views/universalFarms/components/PoolAprButton/V3PoolAprModal.tsx +++ b/apps/web/src/views/universalFarms/components/PoolAprButton/V3PoolAprModal.tsx @@ -53,13 +53,13 @@ const AprModal: React.FC = ({ modal, poolInfo, userPosition [sqrtRatioX96], ) const activeTick = useMemo(() => getActiveTick(tickCurrent, poolInfo.feeTier), [tickCurrent, poolInfo.feeTier]) - const { ticks: ticksData } = useAllV3Ticks( - poolInfo.token0, - poolInfo.token1, - poolInfo.feeTier, + const { ticks: ticksData } = useAllV3Ticks({ + currencyA: poolInfo.token0, + currencyB: poolInfo.token1, + feeAmount: poolInfo.feeTier, activeTick, - modal.isOpen, - ) + enabled: modal.isOpen, + }) const prices = usePairTokensPrice(poolInfo?.lpAddress, priceTimeWindow, poolInfo?.chainId, modal.isOpen) const depositUsdAsBN = useMemo( () =>