From c0f20a172d3ce915070c42326936d29ebfe77377 Mon Sep 17 00:00:00 2001 From: memoyil <2213635+memoyil@users.noreply.github.com> Date: Tue, 31 Dec 2024 09:33:34 +0100 Subject: [PATCH] fix: Merkl tag on farms --- .../web/src/components/Merkl/MerklSection.tsx | 1 - apps/web/src/hooks/useMerkl.tsx | 62 ++++++++++--------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/apps/web/src/components/Merkl/MerklSection.tsx b/apps/web/src/components/Merkl/MerklSection.tsx index 588a5c4ed7191..e41150a21486f 100644 --- a/apps/web/src/components/Merkl/MerklSection.tsx +++ b/apps/web/src/components/Merkl/MerklSection.tsx @@ -61,7 +61,6 @@ export function MerklSection({ }: { poolAddress?: `0x${string}` chainId?: ChainId - tokenId?: bigint notEnoughLiquidity: boolean outRange: boolean disabled: boolean diff --git a/apps/web/src/hooks/useMerkl.tsx b/apps/web/src/hooks/useMerkl.tsx index 1d6e6eac846a9..0603f98f02e78 100644 --- a/apps/web/src/hooks/useMerkl.tsx +++ b/apps/web/src/hooks/useMerkl.tsx @@ -116,36 +116,38 @@ export function useMerklInfo(poolAddress?: string): { const { pools } = data - const hasLive = pools.some((pool) => { - const hasMeanAPR = pool.status === 'LIVE' && pool.apr > 0 - - if (!hasMeanAPR) return false - - const hasLiveDistribution = Boolean( - pool.campaigns?.some((campaign) => { - const { startTimestamp, endTimestamp, whitelist, blacklist } = campaign - const startTimestampNumber = Number(startTimestamp) - const endTimestampNumber = Number(endTimestamp) - const isLive = startTimestampNumber <= currentTimestamp && currentTimestamp <= endTimestampNumber - if (!isLive) return false - const whitelistValid = - !whitelist || - whitelist.length === 0 || - whitelist.includes(account) || - whitelist.includes(masterChefV3Address) - - const blacklistValid = - !blacklist || - blacklist.length === 0 || - !blacklist.includes(account) || - !blacklist.includes(masterChefV3Address) - - return whitelistValid && blacklistValid - }), - ) - - return hasLiveDistribution - }) + const hasLive = pools + .filter((pool) => isAddressEqual(pool.identifier, poolAddress)) + .some((pool) => { + const hasMeanAPR = pool.status === 'LIVE' && pool.apr > 0 + + if (!hasMeanAPR) return false + + const hasLiveDistribution = Boolean( + pool.campaigns?.some((campaign) => { + const { startTimestamp, endTimestamp, whitelist, blacklist } = campaign + const startTimestampNumber = Number(startTimestamp) + const endTimestampNumber = Number(endTimestamp) + const isLive = startTimestampNumber <= currentTimestamp && currentTimestamp <= endTimestampNumber + if (!isLive) return false + const whitelistValid = + !whitelist || + whitelist.length === 0 || + whitelist.includes(account) || + whitelist.includes(masterChefV3Address) + + const blacklistValid = + !blacklist || + blacklist.length === 0 || + !blacklist.includes(account) || + !blacklist.includes(masterChefV3Address) + + return whitelistValid && blacklistValid + }), + ) + + return hasLiveDistribution + }) const rewardsPerTokenObject = userData?.rewards?.filter((reward) => { const { amount, claimed } = reward || {}