Skip to content

Commit

Permalink
fix: getLegacyFarmConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ChefMomota committed Oct 17, 2024
1 parent f7bb9b9 commit 0505126
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion apps/web/src/state/farmsV4/state/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const parseFarmPools = async (
options: { isFarming?: boolean } = {},
): Promise<PoolInfo[]> => {
const fetchFarmConfig = await fetchAllUniversalFarms()
console.log('sss', fetchFarmConfig)

return data.map((pool) => {
let stableSwapAddress: Address | undefined
Expand Down
9 changes: 5 additions & 4 deletions packages/farms/src/getLegacyFarmConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ChainId, getChainName } from '@pancakeswap/chains'
import { getStableSwapPools } from '@pancakeswap/stable-swap-sdk'
import { isAddressEqual } from 'viem'
import { supportedChainIdV4 } from './const'
import { fetchUniversalFarms } from './fetchUniversalFarms'
import { SerializedFarmConfig, SerializedFarmPublicData, UniversalFarmConfig } from './types'

/**
Expand All @@ -12,18 +13,18 @@ export async function getLegacyFarmConfig(chainId?: ChainId): Promise<Serialized
const chainName = getChainName(chainId)
try {
const config = await import(`./farms/${chainName}.ts`)
let universalConfig: UniversalFarmConfig[] = config.default
let universalConfig: UniversalFarmConfig[] = await fetchUniversalFarms(chainId)
// eslint-disable-next-line prefer-destructuring
const legacyFarmConfig: SerializedFarmConfig[] = config.legacyFarmConfig
if (legacyFarmConfig && legacyFarmConfig.length > 0) {
universalConfig = universalConfig.filter((f) => {
universalConfig = universalConfig?.filter((f) => {
return !!f.pid && !legacyFarmConfig.some((legacy) => isAddressEqual(legacy.lpAddress, f.lpAddress))
})
}

const transformedFarmConfig: SerializedFarmConfig[] = universalConfig
.filter((f) => f.pid && (f.protocol === 'v2' || f.protocol === 'stable'))
.map((farm) => {
?.filter((f) => f.pid && (f.protocol === 'v2' || f.protocol === 'stable'))
?.map((farm) => {
const stablePair =
farm.protocol === 'stable'
? getStableSwapPools(chainId).find((s) => {
Expand Down

0 comments on commit 0505126

Please sign in to comment.