Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add LRT pool filter #5254

Merged
merged 7 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
Empty file.
1 change: 1 addition & 0 deletions src/components/inputs/PoolFeatureSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const options = [
PoolTypeFilter.Stable,
PoolTypeFilter.CLP,
PoolTypeFilter.LBP,
PoolTypeFilter.LRT,
];

const attributeOptions = [PoolAttributeFilter.New];
Expand Down
17 changes: 17 additions & 0 deletions src/composables/usePoolGroups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ref, onBeforeMount } from 'vue';

const lrtPools = ref<string[]>([]);

const lrtPoolsPromise = import('@/assets/data/pools/groups/LRT.json');

Check failure on line 5 in src/composables/usePoolGroups.ts

View workflow job for this annotation

GitHub Actions / Test

Cannot find module '@/assets/data/pools/groups/LRT.json' or its corresponding type declarations.

export function usePoolGroups(chainId: string | number) {
onBeforeMount(async () => {
const module = await lrtPoolsPromise;

lrtPools.value = module.default[chainId.toString()]?.map(
pool => pool.poolId
) || ['0x'];
});

return { lrtPools };
}
25 changes: 25 additions & 0 deletions src/lib/scripts/metadata.generator.ts
Original file line number Diff line number Diff line change
@@ -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);
}
})();
6 changes: 6 additions & 0 deletions src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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<HTMLDivElement | null>(null);
const isFeaturedProtocolsVisible = ref(false);
Expand Down Expand Up @@ -59,6 +60,7 @@

const { upToSmallBreakpoint } = useBreakpoints();
const { networkSlug, networkConfig } = useNetwork();
const { lrtPools } = usePoolGroups(networkConfig.chainId);

const isPaginated = computed(() => pools.value.length >= 10);

Expand Down Expand Up @@ -97,6 +99,10 @@
filterPoolIds.value = [];
filterPoolTypes.value = [PoolType.LiquidityBootstrapping];
break;
case PoolTypeFilter.LRT:
filterPoolIds.value = lrtPools;

Check failure on line 103 in src/pages/index.vue

View workflow job for this annotation

GitHub Actions / Test

Type 'Ref<string[]>' is missing the following properties from type 'string[]': length, pop, push, concat, and 29 more.
garethfuller marked this conversation as resolved.
Show resolved Hide resolved
filterPoolTypes.value = [];
break;
default:
filterPoolIds.value = [];
filterPoolTypes.value = [];
Expand Down
1 change: 1 addition & 0 deletions src/types/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum PoolTypeFilter {
Stable = 'Stable',
CLP = 'CLP',
LBP = 'LBP',
LRT = 'LRT',
}

export enum PoolAttributeFilter {
Expand Down
Loading