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

Exclude phantom bpt #1409

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/violet-insects-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

dont display phantom BPT as nested pool in pool tokens
17 changes: 7 additions & 10 deletions modules/pool/lib/pool-gql-loader.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export class PoolGqlLoaderService {
dynamicData: this.getPoolDynamicData(pool),
allTokens: this.mapAllTokens(pool),
displayTokens: this.mapDisplayTokens(pool),
poolTokens: pool.tokens.map((token) => this.mapPoolToken(token, token.nestedPool !== null)),
poolTokens: pool.tokens.map((token) => this.mapPoolToken(token)),
staking: this.getStakingData(pool),
userBalance: this.getUserBalance(pool, userWalletbalances, userStakedBalances),
categories: pool.categories as GqlPoolFilterCategory[],
Expand Down Expand Up @@ -623,7 +623,7 @@ export class PoolGqlLoaderService {
const mappedData = {
decimals: 18,
dynamicData: this.getPoolDynamicData(pool),
poolTokens: pool.tokens.map((token) => this.mapPoolToken(token, token.nestedPool !== null)),
poolTokens: pool.tokens.map((token) => this.mapPoolToken(token)),
vaultVersion: poolWithoutTypeData.protocolVersion,
liquidityManagement: (pool.liquidityManagement as LiquidityManagement) || undefined,
hook: pool.hook as HookData as GqlHook,
Expand Down Expand Up @@ -700,7 +700,7 @@ export class PoolGqlLoaderService {
tokens: pool.tokens.map((token) => this.mapPoolTokenToGqlUnion(token)), // TODO DEPRECATE
allTokens: this.mapAllTokens(pool),
displayTokens: this.mapDisplayTokens(pool),
poolTokens: pool.tokens.map((token) => this.mapPoolToken(token, token.nestedPool !== null)),
poolTokens: pool.tokens.map((token) => this.mapPoolToken(token)),
userBalance: this.getUserBalance(pool, userWalletbalances, userStakedBalances),
vaultVersion: poolWithoutTypeData.protocolVersion,
categories: pool.categories as GqlPoolFilterCategory[],
Expand Down Expand Up @@ -831,13 +831,11 @@ export class PoolGqlLoaderService {
});
}

private mapPoolToken(
poolToken: PrismaPoolTokenWithExpandedNesting,
hasNestedPool: boolean,
nestedPercentage = 1,
): GqlPoolTokenDetail {
private mapPoolToken(poolToken: PrismaPoolTokenWithExpandedNesting, nestedPercentage = 1): GqlPoolTokenDetail {
const { nestedPool } = poolToken;

const hasNestedPool = nestedPool !== null && nestedPool.id !== poolToken.poolId;

return {
id: `${poolToken.poolId}-${poolToken.token.address}`,
...poolToken.token,
Expand All @@ -848,7 +846,7 @@ export class PoolGqlLoaderService {
priceRateProvider: poolToken.priceRateProvider,
weight: poolToken.weight,
hasNestedPool: hasNestedPool,
nestedPool: nestedPool ? this.mapNestedPool(nestedPool, poolToken.balance || '0') : undefined,
nestedPool: hasNestedPool ? this.mapNestedPool(nestedPool, poolToken.balance || '0') : undefined,
isAllowed: poolToken.token.types.some(
(type) => type.type === 'WHITE_LISTED' || type.type === 'PHANTOM_BPT' || type.type === 'BPT',
),
Expand Down Expand Up @@ -880,7 +878,6 @@ export class PoolGqlLoaderService {
...token,
nestedPool: null,
},
token.nestedPool !== null,
percentOfSupplyNested,
),
),
Expand Down
16 changes: 6 additions & 10 deletions modules/pool/pool-debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,15 @@ describe('pool debugging', () => {
// await PoolController().reloadPoolsV3('SEPOLIA');

// const allPools = await poolService.getGqlPools({ where: { chainIn: ['SEPOLIA'], protocolVersionIn: [3] } });
await PoolController().syncOnchainDataForPoolsV2('FANTOM', [
'0x593000b762de3c465855336e95c8bb46080af064000000000000000000000760',
]);
const stablev3 = (await poolService.getGqlPool(
'0x711fd80b36723bce3b42ad6622903e1e39d911dd',
'SEPOLIA',
)) as GqlPoolStable;
// await PoolController().syncOnchainDataForPoolsV2('FANTOM', [
// '0x593000b762de3c465855336e95c8bb46080af064000000000000000000000760',
// ]);
const stablev2 = (await poolService.getGqlPool(
'0x593000b762de3c465855336e95c8bb46080af064000000000000000000000760',
'FANTOM',
'0x5f8893506ddc4c271837187d14a9c87964a074dc000000000000000000000106',
'OPTIMISM',
)) as GqlPoolComposableStable;

console.log(stablev3.bptPriceRate);
// console.log(stablev3.bptPriceRate);
console.log(stablev2.bptPriceRate);

// const poolAfterNewSync = await poolService.getGqlPool('0x8fc07bcf9b88ace84c7523248dc4a85f638c9536', 'SEPOLIA');
Expand Down
Loading