diff --git a/.gitignore b/.gitignore index 7994124d26..4242966f71 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ pnpm-debug.log* # tokenlists /src/assets/data/tokenlists.json /src/assets/data/tokenlists/*.json +/src/assets/data/pools/**/*.json #test coverage /coverage diff --git a/package.json b/package.json index 07ccc34291..b2accce474 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ }, "scripts": { "vite": "vite", - "dev": "npm run generate:tokenlists && vite", + "dev": "npm run generate:tokenlists && npm run generate:metadata && vite", "serve": "npm run dev", - "build": "npm run generate:tokenlists && vite build", + "build": "npm run generate:tokenlists && npm run generate:metadata && vite build", "build:witChunkSizeCheck": "node ./scripts/buildWithChunkSizeCheck.mjs", "build:analyze": "BUILD_ANALIZE=true npm run build", "build:docker": "export NODE_OPTIONS=--max-old-space-size=8192 && npm run build", @@ -35,6 +35,7 @@ "tailwind:view": "tailwind-config-viewer -o", "generate:contract-addresses": "NODE_ENV=development npx vite-node ./src/lib/scripts/contract-addresses.generator.ts", "generate:tokenlists": "NODE_ENV=development npx vite-node --options.deps.inline=@ethersproject/basex --options.deps.inline=@ethersproject/signing-key --options.deps.inline=@balancer-labs/sdk ./src/lib/scripts/tokenlists.generator.ts", + "generate:metadata": "NODE_ENV=development npx vite-node ./src/lib/scripts/metadata.generator.ts", "generate:api": "graphql-codegen --config codegen.yml -r dotenv/config", "typecheck": "vue-tsc --noEmit" }, diff --git a/src/assets/data/pools/.gitkeep b/src/assets/data/pools/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/components/inputs/PoolFeatureSelect.vue b/src/components/inputs/PoolFeatureSelect.vue index 4791735d21..203fe870e4 100644 --- a/src/components/inputs/PoolFeatureSelect.vue +++ b/src/components/inputs/PoolFeatureSelect.vue @@ -19,6 +19,7 @@ const options = [ PoolTypeFilter.Stable, PoolTypeFilter.CLP, PoolTypeFilter.LBP, + PoolTypeFilter.LRT, ]; const attributeOptions = [PoolAttributeFilter.New]; diff --git a/src/composables/usePoolGroups.ts b/src/composables/usePoolGroups.ts new file mode 100644 index 0000000000..6086c51716 --- /dev/null +++ b/src/composables/usePoolGroups.ts @@ -0,0 +1,23 @@ +import { ref, onBeforeMount } from 'vue'; + +const lrtPools = ref([]); + +const chainIdToNetworkFileMap = { + 1: 'mainnet', + 1101: 'zkevm', +}; + +export function usePoolGroups(chainId: string | number) { + const fileName = chainIdToNetworkFileMap[chainId] || 'mainnet'; + + onBeforeMount(async () => { + const module = await import(`@/assets/data/pools/${fileName}.json`); + const pools = module.default; + + lrtPools.value = pools + .filter(pool => pool.categories.includes('lrt')) + .map(pool => pool.id); + }); + + return { lrtPools }; +} diff --git a/src/lib/scripts/metadata.generator.ts b/src/lib/scripts/metadata.generator.ts new file mode 100644 index 0000000000..93255e3fd7 --- /dev/null +++ b/src/lib/scripts/metadata.generator.ts @@ -0,0 +1,25 @@ +import axios from 'axios'; + +const fs = require('fs'); + +const baseUrl = 'https://raw.githubusercontent.com/balancer/metadata/main'; +const filesToFetch = ['/pools/mainnet.json', '/pools/zkevm.json']; + +async function generate() { + filesToFetch.forEach(async file => { + console.log(`Generating metadata for file ${file}...`); + const { data } = await axios(baseUrl + file); + fs.writeFileSync(`./src/assets/data${file}`, JSON.stringify(data, null, 2)); + }); +} + +(async () => { + try { + console.log('⏳ Generating metadata...'); + await generate(); + console.log('✅ Generated metadata at /src/assets/data/*'); + } catch (error) { + console.error('Failed to generate metadata:', error); + process.exit(1); + } +})(); diff --git a/src/pages/index.vue b/src/pages/index.vue index e3aef44c36..2919837b5e 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -17,6 +17,7 @@ import PoolFeatureSelect from '@/components/inputs/PoolFeatureSelect.vue'; import { useTokens } from '@/providers/tokens.provider'; import { PoolAttributeFilter, PoolTypeFilter } from '@/types/pools'; import UserInvestedInAffectedPoolAlert from '@/pages/recovery-exit/UserInvestedInAffectedPoolAlert.vue'; +import { usePoolGroups } from '@/composables/usePoolGroups'; const featuredProtocolsSentinel = ref(null); const isFeaturedProtocolsVisible = ref(false); @@ -59,6 +60,7 @@ const { pools, isLoading, isFetchingNextPage, loadMorePools } = usePools({ const { upToSmallBreakpoint } = useBreakpoints(); const { networkSlug, networkConfig } = useNetwork(); +const { lrtPools } = usePoolGroups(networkConfig.chainId); const isPaginated = computed(() => pools.value.length >= 10); @@ -97,6 +99,10 @@ function updatePoolFilters(feature: PoolTypeFilter | undefined) { filterPoolIds.value = []; filterPoolTypes.value = [PoolType.LiquidityBootstrapping]; break; + case PoolTypeFilter.LRT: + filterPoolIds.value = lrtPools.value; + filterPoolTypes.value = []; + break; default: filterPoolIds.value = []; filterPoolTypes.value = []; diff --git a/src/types/pools.ts b/src/types/pools.ts index ca6908c0ec..5901121ad9 100644 --- a/src/types/pools.ts +++ b/src/types/pools.ts @@ -6,6 +6,7 @@ export enum PoolTypeFilter { Stable = 'Stable', CLP = 'CLP', LBP = 'LBP', + LRT = 'LRT', } export enum PoolAttributeFilter {