Skip to content

Commit

Permalink
add nestedPool list when creating new pools
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbronco committed Jan 11, 2024
1 parent f09f5b1 commit 31a7c21
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions modules/pool/lib/pool-creator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,22 @@ export class PoolCreatorService {
const sortedSubgraphPools = this.sortSubgraphPools(subgraphPools);
const poolIds = new Set<string>();

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);
}
Expand Down Expand Up @@ -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 || [];

Expand Down

0 comments on commit 31a7c21

Please sign in to comment.