Skip to content

Commit

Permalink
fix: Merkl tag on farms
Browse files Browse the repository at this point in the history
  • Loading branch information
memoyil committed Dec 31, 2024
1 parent fde3167 commit c0f20a1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
1 change: 0 additions & 1 deletion apps/web/src/components/Merkl/MerklSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export function MerklSection({
}: {
poolAddress?: `0x${string}`
chainId?: ChainId
tokenId?: bigint
notEnoughLiquidity: boolean
outRange: boolean
disabled: boolean
Expand Down
62 changes: 32 additions & 30 deletions apps/web/src/hooks/useMerkl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {}
Expand Down

0 comments on commit c0f20a1

Please sign in to comment.