From 31a7c21d6af1d377f93814c733323bcb555d2e42 Mon Sep 17 00:00:00 2001 From: gmbronco <83549293+gmbronco@users.noreply.github.com> Date: Thu, 11 Jan 2024 18:20:01 +0100 Subject: [PATCH] add nestedPool list when creating new pools --- modules/pool/lib/pool-creator.service.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/pool/lib/pool-creator.service.ts b/modules/pool/lib/pool-creator.service.ts index a8bc5ca2b..d7d2eea66 100644 --- a/modules/pool/lib/pool-creator.service.ts +++ b/modules/pool/lib/pool-creator.service.ts @@ -68,11 +68,22 @@ export class PoolCreatorService { const sortedSubgraphPools = this.sortSubgraphPools(subgraphPools); const poolIds = new Set(); + const allNestedTypePools = [ + ...(await prisma.prismaPool.findMany({ + where: { + chain: this.chain, + type: { in: [PrismaPoolType.LINEAR, PrismaPoolType.COMPOSABLE_STABLE] }, + }, + select: { id: true, address: true }, + })), + ...sortedSubgraphPools.map((pool) => ({ id: pool.id, address: pool.address })), + ]; + for (const subgraphPool of sortedSubgraphPools) { const existsInDb = !!existingPools.find((pool) => pool.id === subgraphPool.id); if (!existsInDb) { - await this.createPoolRecord(subgraphPool, blockNumber); + await this.createPoolRecord(subgraphPool, blockNumber, allNestedTypePools); poolIds.add(subgraphPool.id); } @@ -135,7 +146,7 @@ export class PoolCreatorService { private async createPoolRecord( pool: BalancerPoolFragment, blockNumber: number, - nestedPools: { id: string; address: string }[] = [], + nestedPools: { id: string; address: string }[], ) { const poolTokens = pool.tokens || [];