Skip to content

Commit

Permalink
Merge pull request #489 from balancer/488-refactor-nested-pool-tokens
Browse files Browse the repository at this point in the history
Refactor nestedPoolState logic to fetch mainTokens from api
  • Loading branch information
brunoguerios authored Nov 14, 2024
2 parents c892033 + f105cbb commit 0117f7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-coins-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@balancer/sdk": patch
---

Refactor nestedPoolState logic to fetch mainTokens from api
22 changes: 4 additions & 18 deletions src/data/providers/balancer-api/modules/nested-pool-state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ export type PoolGetPool = {
protocolVersion: 1 | 2 | 3;
address: Address;
type: string;
allTokens: {
address: Address;
decimals: number;
isMainToken: boolean;
}[];
poolTokens: Token[];
};

Expand Down Expand Up @@ -48,11 +43,6 @@ export class NestedPools {
protocolVersion
address
type
allTokens {
address
decimals
isMainToken
}
poolTokens {
index
address
Expand Down Expand Up @@ -258,14 +248,10 @@ export function mapPoolToNestedPoolStateV2(pool: PoolGetPool): NestedPoolState {
});
});

const mainTokens = pool.allTokens
.filter((t) => t.isMainToken)
.map((t) => {
return {
address: t.address,
decimals: t.decimals,
};
});
// mainTokens are pool tokens filtering out nested pools and phantomBPTs
const mainTokens = pools
.flatMap((p) => p.tokens)
.filter((t) => !pools.find((p) => p.address === t.address));

return {
protocolVersion: 2,
Expand Down

0 comments on commit 0117f7b

Please sign in to comment.