From 6394c985472dad36c1db6f24238ae5d656f454fa Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 12 Feb 2024 21:28:49 +0000 Subject: [PATCH 1/7] feat: init --- package.json | 5 ++-- src/assets/data/pools/groups/LRT.json | 28 +++++++++++++++++++++ src/components/inputs/PoolFeatureSelect.vue | 1 + src/composables/usePoolGroups.ts | 9 +++++++ src/lib/scripts/metadata.generator.ts | 25 ++++++++++++++++++ src/pages/index.vue | 8 ++++++ src/types/pools.ts | 1 + 7 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 src/assets/data/pools/groups/LRT.json create mode 100644 src/composables/usePoolGroups.ts create mode 100644 src/lib/scripts/metadata.generator.ts 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/groups/LRT.json b/src/assets/data/pools/groups/LRT.json new file mode 100644 index 0000000000..7abfc4c353 --- /dev/null +++ b/src/assets/data/pools/groups/LRT.json @@ -0,0 +1,28 @@ +{ + "1": [ + { + "label": "weETH/rETH", + "poolId": "0x05ff47afada98a98982113758878f9a8b9fdda0a000000000000000000000645" + }, + { + "label": "ezETH/ETH", + "poolId": "0x596192bb6e41802428ac943d2f1476c1af25cc0e000000000000000000000659" + }, + { + "label": "weETH/ezETH/rswETH", + "poolId": "0x848a5564158d84b8a8fb68ab5d004fae11619a5400000000000000000000066a" + }, + { + "label": "rsETH/ETHx", + "poolId": "0x7761b6e0daa04e70637d81f1da7d186c205c2ade00000000000000000000065d" + }, + { + "label": "vETH/wstETH", + "poolId": "0xd3f8ab9c5928fdf53153e7757131ad7815fe3146000000000000000000000661" + }, + { + "label": "svETH/wstETH", + "poolId": "0xdedb11a6a23263469567c2881a9b9f8629ee0041000000000000000000000669" + } + ] +} 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..81dc583773 --- /dev/null +++ b/src/composables/usePoolGroups.ts @@ -0,0 +1,9 @@ +import lrtPoolGroups from '@/assets/data/pools/groups/LRT.json'; + +export function usePoolGroups(chainId: string | number) { + const lrtPools: string[] = lrtPoolGroups[chainId.toString()]?.map( + pool => pool.poolId + ) || ['0x']; + + return { lrtPools }; +} diff --git a/src/lib/scripts/metadata.generator.ts b/src/lib/scripts/metadata.generator.ts new file mode 100644 index 0000000000..a56af75bef --- /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/groups/LRT.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..33490fc22c 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,12 @@ function updatePoolFilters(feature: PoolTypeFilter | undefined) { filterPoolIds.value = []; filterPoolTypes.value = [PoolType.LiquidityBootstrapping]; break; + case PoolTypeFilter.LRT: + console.log('lrtPools', lrtPools); + + filterPoolIds.value = lrtPools; + 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 { From 632afd618ad49b0a6b8dd28f9d539919255e9b68 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 12 Feb 2024 21:32:37 +0000 Subject: [PATCH 2/7] chore: delete generated file --- src/assets/data/pools/groups/LRT.json | 28 --------------------------- 1 file changed, 28 deletions(-) delete mode 100644 src/assets/data/pools/groups/LRT.json diff --git a/src/assets/data/pools/groups/LRT.json b/src/assets/data/pools/groups/LRT.json deleted file mode 100644 index 7abfc4c353..0000000000 --- a/src/assets/data/pools/groups/LRT.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "1": [ - { - "label": "weETH/rETH", - "poolId": "0x05ff47afada98a98982113758878f9a8b9fdda0a000000000000000000000645" - }, - { - "label": "ezETH/ETH", - "poolId": "0x596192bb6e41802428ac943d2f1476c1af25cc0e000000000000000000000659" - }, - { - "label": "weETH/ezETH/rswETH", - "poolId": "0x848a5564158d84b8a8fb68ab5d004fae11619a5400000000000000000000066a" - }, - { - "label": "rsETH/ETHx", - "poolId": "0x7761b6e0daa04e70637d81f1da7d186c205c2ade00000000000000000000065d" - }, - { - "label": "vETH/wstETH", - "poolId": "0xd3f8ab9c5928fdf53153e7757131ad7815fe3146000000000000000000000661" - }, - { - "label": "svETH/wstETH", - "poolId": "0xdedb11a6a23263469567c2881a9b9f8629ee0041000000000000000000000669" - } - ] -} From a20494bc02984c915148e9a98f21758c9474428b Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 12 Feb 2024 21:32:57 +0000 Subject: [PATCH 3/7] chore: Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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 From b6b9ccbbca0c8e54b17c21b91290d9f25bd5ed8a Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 12 Feb 2024 21:34:05 +0000 Subject: [PATCH 4/7] chore: Remove log --- src/pages/index.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/index.vue b/src/pages/index.vue index 33490fc22c..3807e78cd9 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -100,8 +100,6 @@ function updatePoolFilters(feature: PoolTypeFilter | undefined) { filterPoolTypes.value = [PoolType.LiquidityBootstrapping]; break; case PoolTypeFilter.LRT: - console.log('lrtPools', lrtPools); - filterPoolIds.value = lrtPools; filterPoolTypes.value = []; break; From aa0899806cd3f2f205e0b00eeb0b855e6813fdb7 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 12 Feb 2024 21:51:48 +0000 Subject: [PATCH 5/7] fix: module import --- src/composables/usePoolGroups.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/composables/usePoolGroups.ts b/src/composables/usePoolGroups.ts index 81dc583773..e2aacc7227 100644 --- a/src/composables/usePoolGroups.ts +++ b/src/composables/usePoolGroups.ts @@ -1,9 +1,17 @@ -import lrtPoolGroups from '@/assets/data/pools/groups/LRT.json'; +import { ref, onBeforeMount } from 'vue'; + +const lrtPools = ref([]); + +const lrtPoolsPromise = import('@/assets/data/pools/groups/LRT.json'); export function usePoolGroups(chainId: string | number) { - const lrtPools: string[] = lrtPoolGroups[chainId.toString()]?.map( - pool => pool.poolId - ) || ['0x']; + onBeforeMount(async () => { + const module = await lrtPoolsPromise; + + lrtPools.value = module.default[chainId.toString()]?.map( + pool => pool.poolId + ) || ['0x']; + }); return { lrtPools }; } From b6d8e6bb67da78c78670bf6e23f43237783f0dd6 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 12 Feb 2024 22:03:15 +0000 Subject: [PATCH 6/7] chore: Keep required folder --- src/assets/data/pools/groups/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/assets/data/pools/groups/.gitkeep diff --git a/src/assets/data/pools/groups/.gitkeep b/src/assets/data/pools/groups/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 From 2b97f42fd7b7b74eaad22256ae33d851aa5045bf Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Tue, 13 Feb 2024 10:42:27 +0000 Subject: [PATCH 7/7] chore: Update schema --- src/assets/data/pools/{groups => }/.gitkeep | 0 src/composables/usePoolGroups.ts | 16 +++++++++++----- src/lib/scripts/metadata.generator.ts | 2 +- src/pages/index.vue | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) rename src/assets/data/pools/{groups => }/.gitkeep (100%) diff --git a/src/assets/data/pools/groups/.gitkeep b/src/assets/data/pools/.gitkeep similarity index 100% rename from src/assets/data/pools/groups/.gitkeep rename to src/assets/data/pools/.gitkeep diff --git a/src/composables/usePoolGroups.ts b/src/composables/usePoolGroups.ts index e2aacc7227..6086c51716 100644 --- a/src/composables/usePoolGroups.ts +++ b/src/composables/usePoolGroups.ts @@ -2,15 +2,21 @@ import { ref, onBeforeMount } from 'vue'; const lrtPools = ref([]); -const lrtPoolsPromise = import('@/assets/data/pools/groups/LRT.json'); +const chainIdToNetworkFileMap = { + 1: 'mainnet', + 1101: 'zkevm', +}; export function usePoolGroups(chainId: string | number) { + const fileName = chainIdToNetworkFileMap[chainId] || 'mainnet'; + onBeforeMount(async () => { - const module = await lrtPoolsPromise; + const module = await import(`@/assets/data/pools/${fileName}.json`); + const pools = module.default; - lrtPools.value = module.default[chainId.toString()]?.map( - pool => pool.poolId - ) || ['0x']; + 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 index a56af75bef..93255e3fd7 100644 --- a/src/lib/scripts/metadata.generator.ts +++ b/src/lib/scripts/metadata.generator.ts @@ -3,7 +3,7 @@ import axios from 'axios'; const fs = require('fs'); const baseUrl = 'https://raw.githubusercontent.com/balancer/metadata/main'; -const filesToFetch = ['/pools/groups/LRT.json']; +const filesToFetch = ['/pools/mainnet.json', '/pools/zkevm.json']; async function generate() { filesToFetch.forEach(async file => { diff --git a/src/pages/index.vue b/src/pages/index.vue index 3807e78cd9..2919837b5e 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -100,7 +100,7 @@ function updatePoolFilters(feature: PoolTypeFilter | undefined) { filterPoolTypes.value = [PoolType.LiquidityBootstrapping]; break; case PoolTypeFilter.LRT: - filterPoolIds.value = lrtPools; + filterPoolIds.value = lrtPools.value; filterPoolTypes.value = []; break; default: