From 37ca90a095d8c931a4f0d3fb376a8e2e66ee5709 Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Thu, 24 Aug 2023 18:06:36 +1000 Subject: [PATCH] Add fetching single pools from API --- src/composables/queries/usePoolQuery.ts | 39 +- .../api/graphql/generated/api-schema.graphql | 1 + .../api/graphql/generated/api-types.ts | 2518 +++++++++++++++++ src/services/api/graphql/pool.graphql | 450 ++- src/services/api/graphql/pools.graphql | 116 + .../balancer/api/entities/pool/index.ts | 142 +- .../balancer/api/entities/pools/index.ts | 9 +- 7 files changed, 3096 insertions(+), 179 deletions(-) create mode 100644 src/services/api/graphql/pools.graphql diff --git a/src/composables/queries/usePoolQuery.ts b/src/composables/queries/usePoolQuery.ts index 51f39b6dfd..956d4b827a 100644 --- a/src/composables/queries/usePoolQuery.ts +++ b/src/composables/queries/usePoolQuery.ts @@ -1,20 +1,15 @@ import { QueryObserverOptions, useQuery } from '@tanstack/vue-query'; import { computed, reactive, Ref, ref } from 'vue'; -import { GraphQLArgs } from '@balancer-labs/sdk'; - import QUERY_KEYS from '@/constants/queryKeys'; import { useTokens } from '@/providers/tokens.provider'; -import { poolsStoreService } from '@/services/pool/pools-store.service'; import { Pool } from '@/services/pool/types'; import { tokensListExclBpt, tokenTreeLeafs } from '../usePoolHelpers'; -import { POOLS } from '@/constants/pools'; -import { configService } from '@/services/config/config.service'; import { PoolDecorator } from '@/services/pool/decorators/pool.decorator'; -import PoolRepository from '@/services/pool/pool.repository'; +import { balancerAPIService } from '@/services/balancer/api/balancer-api.service'; type QueryOptions = QueryObserverOptions; @@ -23,53 +18,23 @@ export default function usePoolQuery( isEnabled: Ref = ref(true), options: QueryOptions = {} ) { - /** - * If pool is already downloaded, we can use it instantly - * it may be if user came to pool page from home page - */ - const poolInfo = poolsStoreService.findPool(id); - /** * COMPOSABLES */ const { injectTokens, tokens } = useTokens(); - const poolRepository = new PoolRepository(tokens); - /** * COMPUTED */ const enabled = computed(() => isEnabled.value); - /** - * METHODS - */ - - function getQueryArgs(): GraphQLArgs { - const queryArgs: GraphQLArgs = { - chainId: configService.network.chainId, - where: { - id: { eq: id?.toLowerCase() }, - totalShares: { gt: -1 }, // Avoid the filtering for low liquidity pools - poolType: { in: POOLS.IncludedPoolTypes }, - }, - }; - return queryArgs; - } - /** * QUERY INPUTS */ const queryKey = QUERY_KEYS.Pools.Current(id); const queryFn = async () => { - let pool: Pool; - if (poolInfo) { - pool = poolInfo; - } else { - pool = await poolRepository.fetch(getQueryArgs()); - } - + let pool: Pool = await await balancerAPIService.pool.get({ id }); if (!pool) throw new Error('Pool does not exist'); // If the pool is cached from homepage it may not have onchain set, so update it diff --git a/src/services/api/graphql/generated/api-schema.graphql b/src/services/api/graphql/generated/api-schema.graphql index 950985f22e..29d97c3e13 100644 --- a/src/services/api/graphql/generated/api-schema.graphql +++ b/src/services/api/graphql/generated/api-schema.graphql @@ -948,6 +948,7 @@ input GqlUserSwapVolumeFilter { type GqlVotingGauge { addedTimestamp: Int address: Bytes! + childGaugeAddress: Bytes isKilled: Boolean! relativeWeightCap: String } diff --git a/src/services/api/graphql/generated/api-types.ts b/src/services/api/graphql/generated/api-types.ts index 776c711cfd..2bc8791c1c 100644 --- a/src/services/api/graphql/generated/api-types.ts +++ b/src/services/api/graphql/generated/api-types.ts @@ -1047,6 +1047,7 @@ export type GqlVotingGauge = { __typename?: 'GqlVotingGauge'; addedTimestamp?: Maybe; address: Scalars['Bytes']; + childGaugeAddress?: Maybe; isKilled: Scalars['Boolean']; relativeWeightCap?: Maybe; }; @@ -1356,6 +1357,2142 @@ export type QueryUserGetSwapsArgs = { skip?: InputMaybe; }; +export type GetPoolQueryVariables = Exact<{ + id: Scalars['String']; +}>; + +export type GetPoolQuery = { + __typename?: 'Query'; + pool: + | { + __typename?: 'GqlPoolElement'; + unitSeconds: string; + principalToken: string; + baseToken: string; + id: string; + address: string; + name: string; + chain: GqlChain; + owner: string; + decimals: number; + factory?: string | null; + symbol: string; + createTime: number; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + dynamicData: { + __typename?: 'GqlPoolDynamicData'; + poolId: string; + swapEnabled: boolean; + totalLiquidity: string; + totalLiquidity24hAgo: string; + totalShares: string; + totalShares24hAgo: string; + fees24h: string; + swapFee: string; + volume24h: string; + fees48h: string; + volume48h: string; + lifetimeVolume: string; + lifetimeSwapFees: string; + holdersCount: string; + swapsCount: string; + sharePriceAth: string; + sharePriceAthTimestamp: number; + sharePriceAtl: string; + sharePriceAtlTimestamp: number; + totalLiquidityAth: string; + totalLiquidityAthTimestamp: number; + totalLiquidityAtl: string; + totalLiquidityAtlTimestamp: number; + volume24hAth: string; + volume24hAthTimestamp: number; + volume24hAtl: string; + volume24hAtlTimestamp: number; + fees24hAth: string; + fees24hAthTimestamp: number; + fees24hAtl: string; + fees24hAtlTimestamp: number; + apr: { + __typename?: 'GqlPoolApr'; + hasRewardApr: boolean; + swapApr: string; + thirdPartyApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + nativeRewardApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + items: Array<{ + __typename?: 'GqlBalancePoolAprItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + subItems?: Array<{ + __typename?: 'GqlBalancePoolAprSubItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + }> | null; + }>; + }; + }; + allTokens: Array<{ + __typename?: 'GqlPoolTokenExpanded'; + id: string; + address: string; + name: string; + symbol: string; + decimals: number; + isNested: boolean; + isPhantomBpt: boolean; + }>; + displayTokens: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + nestedTokens?: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + }> | null; + }>; + staking?: { + __typename?: 'GqlPoolStaking'; + id: string; + type: GqlPoolStakingType; + address: string; + gauge?: { + __typename?: 'GqlPoolStakingGauge'; + id: string; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + otherGauges?: Array<{ + __typename?: 'GqlPoolStakingOtherGauge'; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + id: string; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + tokenAddress: string; + rewardPerSecond: string; + }>; + }> | null; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + rewardPerSecond: string; + tokenAddress: string; + }>; + } | null; + } | null; + investConfig: { + __typename?: 'GqlPoolInvestConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolInvestOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + withdrawConfig: { + __typename?: 'GqlPoolWithdrawConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolWithdrawOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + } + | { + __typename?: 'GqlPoolGyro'; + alpha: string; + beta: string; + type: string; + nestingType: GqlPoolNestingType; + id: string; + address: string; + name: string; + chain: GqlChain; + owner: string; + decimals: number; + factory?: string | null; + symbol: string; + createTime: number; + tokens: Array< + | { + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + } + | { __typename?: 'GqlPoolTokenLinear' } + | { __typename?: 'GqlPoolTokenPhantomStable' } + >; + dynamicData: { + __typename?: 'GqlPoolDynamicData'; + poolId: string; + swapEnabled: boolean; + totalLiquidity: string; + totalLiquidity24hAgo: string; + totalShares: string; + totalShares24hAgo: string; + fees24h: string; + swapFee: string; + volume24h: string; + fees48h: string; + volume48h: string; + lifetimeVolume: string; + lifetimeSwapFees: string; + holdersCount: string; + swapsCount: string; + sharePriceAth: string; + sharePriceAthTimestamp: number; + sharePriceAtl: string; + sharePriceAtlTimestamp: number; + totalLiquidityAth: string; + totalLiquidityAthTimestamp: number; + totalLiquidityAtl: string; + totalLiquidityAtlTimestamp: number; + volume24hAth: string; + volume24hAthTimestamp: number; + volume24hAtl: string; + volume24hAtlTimestamp: number; + fees24hAth: string; + fees24hAthTimestamp: number; + fees24hAtl: string; + fees24hAtlTimestamp: number; + apr: { + __typename?: 'GqlPoolApr'; + hasRewardApr: boolean; + swapApr: string; + thirdPartyApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + nativeRewardApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + items: Array<{ + __typename?: 'GqlBalancePoolAprItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + subItems?: Array<{ + __typename?: 'GqlBalancePoolAprSubItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + }> | null; + }>; + }; + }; + allTokens: Array<{ + __typename?: 'GqlPoolTokenExpanded'; + id: string; + address: string; + name: string; + symbol: string; + decimals: number; + isNested: boolean; + isPhantomBpt: boolean; + }>; + displayTokens: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + nestedTokens?: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + }> | null; + }>; + staking?: { + __typename?: 'GqlPoolStaking'; + id: string; + type: GqlPoolStakingType; + address: string; + gauge?: { + __typename?: 'GqlPoolStakingGauge'; + id: string; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + otherGauges?: Array<{ + __typename?: 'GqlPoolStakingOtherGauge'; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + id: string; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + tokenAddress: string; + rewardPerSecond: string; + }>; + }> | null; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + rewardPerSecond: string; + tokenAddress: string; + }>; + } | null; + } | null; + investConfig: { + __typename?: 'GqlPoolInvestConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolInvestOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + withdrawConfig: { + __typename?: 'GqlPoolWithdrawConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolWithdrawOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + } + | { + __typename?: 'GqlPoolLinear'; + mainIndex: number; + wrappedIndex: number; + lowerTarget: string; + upperTarget: string; + id: string; + address: string; + name: string; + chain: GqlChain; + owner: string; + decimals: number; + factory?: string | null; + symbol: string; + createTime: number; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + dynamicData: { + __typename?: 'GqlPoolDynamicData'; + poolId: string; + swapEnabled: boolean; + totalLiquidity: string; + totalLiquidity24hAgo: string; + totalShares: string; + totalShares24hAgo: string; + fees24h: string; + swapFee: string; + volume24h: string; + fees48h: string; + volume48h: string; + lifetimeVolume: string; + lifetimeSwapFees: string; + holdersCount: string; + swapsCount: string; + sharePriceAth: string; + sharePriceAthTimestamp: number; + sharePriceAtl: string; + sharePriceAtlTimestamp: number; + totalLiquidityAth: string; + totalLiquidityAthTimestamp: number; + totalLiquidityAtl: string; + totalLiquidityAtlTimestamp: number; + volume24hAth: string; + volume24hAthTimestamp: number; + volume24hAtl: string; + volume24hAtlTimestamp: number; + fees24hAth: string; + fees24hAthTimestamp: number; + fees24hAtl: string; + fees24hAtlTimestamp: number; + apr: { + __typename?: 'GqlPoolApr'; + hasRewardApr: boolean; + swapApr: string; + thirdPartyApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + nativeRewardApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + items: Array<{ + __typename?: 'GqlBalancePoolAprItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + subItems?: Array<{ + __typename?: 'GqlBalancePoolAprSubItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + }> | null; + }>; + }; + }; + allTokens: Array<{ + __typename?: 'GqlPoolTokenExpanded'; + id: string; + address: string; + name: string; + symbol: string; + decimals: number; + isNested: boolean; + isPhantomBpt: boolean; + }>; + displayTokens: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + nestedTokens?: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + }> | null; + }>; + staking?: { + __typename?: 'GqlPoolStaking'; + id: string; + type: GqlPoolStakingType; + address: string; + gauge?: { + __typename?: 'GqlPoolStakingGauge'; + id: string; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + otherGauges?: Array<{ + __typename?: 'GqlPoolStakingOtherGauge'; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + id: string; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + tokenAddress: string; + rewardPerSecond: string; + }>; + }> | null; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + rewardPerSecond: string; + tokenAddress: string; + }>; + } | null; + } | null; + investConfig: { + __typename?: 'GqlPoolInvestConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolInvestOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + withdrawConfig: { + __typename?: 'GqlPoolWithdrawConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolWithdrawOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + } + | { + __typename?: 'GqlPoolLiquidityBootstrapping'; + name: string; + nestingType: GqlPoolNestingType; + id: string; + address: string; + chain: GqlChain; + owner: string; + decimals: number; + factory?: string | null; + symbol: string; + createTime: number; + tokens: Array< + | { + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + } + | { + __typename?: 'GqlPoolTokenLinear'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + mainTokenBalance: string; + wrappedTokenBalance: string; + totalMainTokenBalance: string; + totalBalance: string; + pool: { + __typename?: 'GqlPoolLinearNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + wrappedIndex: number; + mainIndex: number; + upperTarget: string; + lowerTarget: string; + totalShares: string; + totalLiquidity: string; + bptPriceRate: string; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }; + } + | { + __typename?: 'GqlPoolTokenPhantomStable'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + weight?: string | null; + priceRate: string; + decimals: number; + totalBalance: string; + pool: { + __typename?: 'GqlPoolPhantomStableNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + totalShares: string; + totalLiquidity: string; + nestingType: GqlPoolNestingType; + swapFee: string; + amp: string; + tokens: Array< + | { + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + } + | { + __typename?: 'GqlPoolTokenLinear'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + mainTokenBalance: string; + wrappedTokenBalance: string; + totalMainTokenBalance: string; + totalBalance: string; + pool: { + __typename?: 'GqlPoolLinearNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + wrappedIndex: number; + mainIndex: number; + upperTarget: string; + lowerTarget: string; + totalShares: string; + totalLiquidity: string; + bptPriceRate: string; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }; + } + >; + }; + } + >; + dynamicData: { + __typename?: 'GqlPoolDynamicData'; + poolId: string; + swapEnabled: boolean; + totalLiquidity: string; + totalLiquidity24hAgo: string; + totalShares: string; + totalShares24hAgo: string; + fees24h: string; + swapFee: string; + volume24h: string; + fees48h: string; + volume48h: string; + lifetimeVolume: string; + lifetimeSwapFees: string; + holdersCount: string; + swapsCount: string; + sharePriceAth: string; + sharePriceAthTimestamp: number; + sharePriceAtl: string; + sharePriceAtlTimestamp: number; + totalLiquidityAth: string; + totalLiquidityAthTimestamp: number; + totalLiquidityAtl: string; + totalLiquidityAtlTimestamp: number; + volume24hAth: string; + volume24hAthTimestamp: number; + volume24hAtl: string; + volume24hAtlTimestamp: number; + fees24hAth: string; + fees24hAthTimestamp: number; + fees24hAtl: string; + fees24hAtlTimestamp: number; + apr: { + __typename?: 'GqlPoolApr'; + hasRewardApr: boolean; + swapApr: string; + thirdPartyApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + nativeRewardApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + items: Array<{ + __typename?: 'GqlBalancePoolAprItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + subItems?: Array<{ + __typename?: 'GqlBalancePoolAprSubItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + }> | null; + }>; + }; + }; + allTokens: Array<{ + __typename?: 'GqlPoolTokenExpanded'; + id: string; + address: string; + name: string; + symbol: string; + decimals: number; + isNested: boolean; + isPhantomBpt: boolean; + }>; + displayTokens: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + nestedTokens?: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + }> | null; + }>; + staking?: { + __typename?: 'GqlPoolStaking'; + id: string; + type: GqlPoolStakingType; + address: string; + gauge?: { + __typename?: 'GqlPoolStakingGauge'; + id: string; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + otherGauges?: Array<{ + __typename?: 'GqlPoolStakingOtherGauge'; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + id: string; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + tokenAddress: string; + rewardPerSecond: string; + }>; + }> | null; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + rewardPerSecond: string; + tokenAddress: string; + }>; + } | null; + } | null; + investConfig: { + __typename?: 'GqlPoolInvestConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolInvestOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + withdrawConfig: { + __typename?: 'GqlPoolWithdrawConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolWithdrawOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + } + | { + __typename?: 'GqlPoolMetaStable'; + amp: string; + id: string; + address: string; + name: string; + chain: GqlChain; + owner: string; + decimals: number; + factory?: string | null; + symbol: string; + createTime: number; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + dynamicData: { + __typename?: 'GqlPoolDynamicData'; + poolId: string; + swapEnabled: boolean; + totalLiquidity: string; + totalLiquidity24hAgo: string; + totalShares: string; + totalShares24hAgo: string; + fees24h: string; + swapFee: string; + volume24h: string; + fees48h: string; + volume48h: string; + lifetimeVolume: string; + lifetimeSwapFees: string; + holdersCount: string; + swapsCount: string; + sharePriceAth: string; + sharePriceAthTimestamp: number; + sharePriceAtl: string; + sharePriceAtlTimestamp: number; + totalLiquidityAth: string; + totalLiquidityAthTimestamp: number; + totalLiquidityAtl: string; + totalLiquidityAtlTimestamp: number; + volume24hAth: string; + volume24hAthTimestamp: number; + volume24hAtl: string; + volume24hAtlTimestamp: number; + fees24hAth: string; + fees24hAthTimestamp: number; + fees24hAtl: string; + fees24hAtlTimestamp: number; + apr: { + __typename?: 'GqlPoolApr'; + hasRewardApr: boolean; + swapApr: string; + thirdPartyApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + nativeRewardApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + items: Array<{ + __typename?: 'GqlBalancePoolAprItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + subItems?: Array<{ + __typename?: 'GqlBalancePoolAprSubItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + }> | null; + }>; + }; + }; + allTokens: Array<{ + __typename?: 'GqlPoolTokenExpanded'; + id: string; + address: string; + name: string; + symbol: string; + decimals: number; + isNested: boolean; + isPhantomBpt: boolean; + }>; + displayTokens: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + nestedTokens?: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + }> | null; + }>; + staking?: { + __typename?: 'GqlPoolStaking'; + id: string; + type: GqlPoolStakingType; + address: string; + gauge?: { + __typename?: 'GqlPoolStakingGauge'; + id: string; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + otherGauges?: Array<{ + __typename?: 'GqlPoolStakingOtherGauge'; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + id: string; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + tokenAddress: string; + rewardPerSecond: string; + }>; + }> | null; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + rewardPerSecond: string; + tokenAddress: string; + }>; + } | null; + } | null; + investConfig: { + __typename?: 'GqlPoolInvestConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolInvestOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + withdrawConfig: { + __typename?: 'GqlPoolWithdrawConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolWithdrawOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + } + | { + __typename?: 'GqlPoolPhantomStable'; + amp: string; + nestingType: GqlPoolNestingType; + id: string; + address: string; + name: string; + chain: GqlChain; + owner: string; + decimals: number; + factory?: string | null; + symbol: string; + createTime: number; + tokens: Array< + | { + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + } + | { + __typename?: 'GqlPoolTokenLinear'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + mainTokenBalance: string; + wrappedTokenBalance: string; + totalMainTokenBalance: string; + totalBalance: string; + pool: { + __typename?: 'GqlPoolLinearNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + wrappedIndex: number; + mainIndex: number; + upperTarget: string; + lowerTarget: string; + totalShares: string; + totalLiquidity: string; + bptPriceRate: string; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }; + } + | { + __typename?: 'GqlPoolTokenPhantomStable'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + weight?: string | null; + priceRate: string; + decimals: number; + totalBalance: string; + pool: { + __typename?: 'GqlPoolPhantomStableNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + totalShares: string; + totalLiquidity: string; + nestingType: GqlPoolNestingType; + swapFee: string; + amp: string; + tokens: Array< + | { + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + } + | { + __typename?: 'GqlPoolTokenLinear'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + mainTokenBalance: string; + wrappedTokenBalance: string; + totalMainTokenBalance: string; + totalBalance: string; + pool: { + __typename?: 'GqlPoolLinearNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + wrappedIndex: number; + mainIndex: number; + upperTarget: string; + lowerTarget: string; + totalShares: string; + totalLiquidity: string; + bptPriceRate: string; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }; + } + >; + }; + } + >; + dynamicData: { + __typename?: 'GqlPoolDynamicData'; + poolId: string; + swapEnabled: boolean; + totalLiquidity: string; + totalLiquidity24hAgo: string; + totalShares: string; + totalShares24hAgo: string; + fees24h: string; + swapFee: string; + volume24h: string; + fees48h: string; + volume48h: string; + lifetimeVolume: string; + lifetimeSwapFees: string; + holdersCount: string; + swapsCount: string; + sharePriceAth: string; + sharePriceAthTimestamp: number; + sharePriceAtl: string; + sharePriceAtlTimestamp: number; + totalLiquidityAth: string; + totalLiquidityAthTimestamp: number; + totalLiquidityAtl: string; + totalLiquidityAtlTimestamp: number; + volume24hAth: string; + volume24hAthTimestamp: number; + volume24hAtl: string; + volume24hAtlTimestamp: number; + fees24hAth: string; + fees24hAthTimestamp: number; + fees24hAtl: string; + fees24hAtlTimestamp: number; + apr: { + __typename?: 'GqlPoolApr'; + hasRewardApr: boolean; + swapApr: string; + thirdPartyApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + nativeRewardApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + items: Array<{ + __typename?: 'GqlBalancePoolAprItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + subItems?: Array<{ + __typename?: 'GqlBalancePoolAprSubItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + }> | null; + }>; + }; + }; + allTokens: Array<{ + __typename?: 'GqlPoolTokenExpanded'; + id: string; + address: string; + name: string; + symbol: string; + decimals: number; + isNested: boolean; + isPhantomBpt: boolean; + }>; + displayTokens: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + nestedTokens?: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + }> | null; + }>; + staking?: { + __typename?: 'GqlPoolStaking'; + id: string; + type: GqlPoolStakingType; + address: string; + gauge?: { + __typename?: 'GqlPoolStakingGauge'; + id: string; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + otherGauges?: Array<{ + __typename?: 'GqlPoolStakingOtherGauge'; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + id: string; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + tokenAddress: string; + rewardPerSecond: string; + }>; + }> | null; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + rewardPerSecond: string; + tokenAddress: string; + }>; + } | null; + } | null; + investConfig: { + __typename?: 'GqlPoolInvestConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolInvestOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + withdrawConfig: { + __typename?: 'GqlPoolWithdrawConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolWithdrawOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + } + | { + __typename?: 'GqlPoolStable'; + amp: string; + id: string; + address: string; + name: string; + chain: GqlChain; + owner: string; + decimals: number; + factory?: string | null; + symbol: string; + createTime: number; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + dynamicData: { + __typename?: 'GqlPoolDynamicData'; + poolId: string; + swapEnabled: boolean; + totalLiquidity: string; + totalLiquidity24hAgo: string; + totalShares: string; + totalShares24hAgo: string; + fees24h: string; + swapFee: string; + volume24h: string; + fees48h: string; + volume48h: string; + lifetimeVolume: string; + lifetimeSwapFees: string; + holdersCount: string; + swapsCount: string; + sharePriceAth: string; + sharePriceAthTimestamp: number; + sharePriceAtl: string; + sharePriceAtlTimestamp: number; + totalLiquidityAth: string; + totalLiquidityAthTimestamp: number; + totalLiquidityAtl: string; + totalLiquidityAtlTimestamp: number; + volume24hAth: string; + volume24hAthTimestamp: number; + volume24hAtl: string; + volume24hAtlTimestamp: number; + fees24hAth: string; + fees24hAthTimestamp: number; + fees24hAtl: string; + fees24hAtlTimestamp: number; + apr: { + __typename?: 'GqlPoolApr'; + hasRewardApr: boolean; + swapApr: string; + thirdPartyApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + nativeRewardApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + items: Array<{ + __typename?: 'GqlBalancePoolAprItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + subItems?: Array<{ + __typename?: 'GqlBalancePoolAprSubItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + }> | null; + }>; + }; + }; + allTokens: Array<{ + __typename?: 'GqlPoolTokenExpanded'; + id: string; + address: string; + name: string; + symbol: string; + decimals: number; + isNested: boolean; + isPhantomBpt: boolean; + }>; + displayTokens: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + nestedTokens?: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + }> | null; + }>; + staking?: { + __typename?: 'GqlPoolStaking'; + id: string; + type: GqlPoolStakingType; + address: string; + gauge?: { + __typename?: 'GqlPoolStakingGauge'; + id: string; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + otherGauges?: Array<{ + __typename?: 'GqlPoolStakingOtherGauge'; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + id: string; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + tokenAddress: string; + rewardPerSecond: string; + }>; + }> | null; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + rewardPerSecond: string; + tokenAddress: string; + }>; + } | null; + } | null; + investConfig: { + __typename?: 'GqlPoolInvestConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolInvestOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + withdrawConfig: { + __typename?: 'GqlPoolWithdrawConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolWithdrawOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + } + | { + __typename?: 'GqlPoolWeighted'; + nestingType: GqlPoolNestingType; + id: string; + address: string; + name: string; + chain: GqlChain; + owner: string; + decimals: number; + factory?: string | null; + symbol: string; + createTime: number; + tokens: Array< + | { + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + } + | { + __typename?: 'GqlPoolTokenLinear'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + mainTokenBalance: string; + wrappedTokenBalance: string; + totalMainTokenBalance: string; + totalBalance: string; + pool: { + __typename?: 'GqlPoolLinearNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + wrappedIndex: number; + mainIndex: number; + upperTarget: string; + lowerTarget: string; + totalShares: string; + totalLiquidity: string; + bptPriceRate: string; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }; + } + | { + __typename?: 'GqlPoolTokenPhantomStable'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + weight?: string | null; + priceRate: string; + decimals: number; + totalBalance: string; + pool: { + __typename?: 'GqlPoolPhantomStableNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + totalShares: string; + totalLiquidity: string; + nestingType: GqlPoolNestingType; + swapFee: string; + amp: string; + tokens: Array< + | { + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + } + | { + __typename?: 'GqlPoolTokenLinear'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + mainTokenBalance: string; + wrappedTokenBalance: string; + totalMainTokenBalance: string; + totalBalance: string; + pool: { + __typename?: 'GqlPoolLinearNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + wrappedIndex: number; + mainIndex: number; + upperTarget: string; + lowerTarget: string; + totalShares: string; + totalLiquidity: string; + bptPriceRate: string; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }; + } + >; + }; + } + >; + dynamicData: { + __typename?: 'GqlPoolDynamicData'; + poolId: string; + swapEnabled: boolean; + totalLiquidity: string; + totalLiquidity24hAgo: string; + totalShares: string; + totalShares24hAgo: string; + fees24h: string; + swapFee: string; + volume24h: string; + fees48h: string; + volume48h: string; + lifetimeVolume: string; + lifetimeSwapFees: string; + holdersCount: string; + swapsCount: string; + sharePriceAth: string; + sharePriceAthTimestamp: number; + sharePriceAtl: string; + sharePriceAtlTimestamp: number; + totalLiquidityAth: string; + totalLiquidityAthTimestamp: number; + totalLiquidityAtl: string; + totalLiquidityAtlTimestamp: number; + volume24hAth: string; + volume24hAthTimestamp: number; + volume24hAtl: string; + volume24hAtlTimestamp: number; + fees24hAth: string; + fees24hAthTimestamp: number; + fees24hAtl: string; + fees24hAtlTimestamp: number; + apr: { + __typename?: 'GqlPoolApr'; + hasRewardApr: boolean; + swapApr: string; + thirdPartyApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + nativeRewardApr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + items: Array<{ + __typename?: 'GqlBalancePoolAprItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + subItems?: Array<{ + __typename?: 'GqlBalancePoolAprSubItem'; + id: string; + title: string; + apr: + | { __typename?: 'GqlPoolAprRange'; min: string; max: string } + | { __typename?: 'GqlPoolAprTotal'; total: string }; + }> | null; + }>; + }; + }; + allTokens: Array<{ + __typename?: 'GqlPoolTokenExpanded'; + id: string; + address: string; + name: string; + symbol: string; + decimals: number; + isNested: boolean; + isPhantomBpt: boolean; + }>; + displayTokens: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + nestedTokens?: Array<{ + __typename?: 'GqlPoolTokenDisplay'; + id: string; + address: string; + name: string; + weight?: string | null; + symbol: string; + }> | null; + }>; + staking?: { + __typename?: 'GqlPoolStaking'; + id: string; + type: GqlPoolStakingType; + address: string; + gauge?: { + __typename?: 'GqlPoolStakingGauge'; + id: string; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + otherGauges?: Array<{ + __typename?: 'GqlPoolStakingOtherGauge'; + gaugeAddress: string; + version: number; + status: GqlPoolStakingGaugeStatus; + id: string; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + tokenAddress: string; + rewardPerSecond: string; + }>; + }> | null; + rewards: Array<{ + __typename?: 'GqlPoolStakingGaugeReward'; + id: string; + rewardPerSecond: string; + tokenAddress: string; + }>; + } | null; + } | null; + investConfig: { + __typename?: 'GqlPoolInvestConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolInvestOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + withdrawConfig: { + __typename?: 'GqlPoolWithdrawConfig'; + singleAssetEnabled: boolean; + proportionalEnabled: boolean; + options: Array<{ + __typename?: 'GqlPoolWithdrawOption'; + poolTokenIndex: number; + poolTokenAddress: string; + tokenOptions: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }>; + }; + }; +}; + +export type GqlPoolTokenFragment = { + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; +}; + +export type GqlPoolTokenLinearFragment = { + __typename?: 'GqlPoolTokenLinear'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + mainTokenBalance: string; + wrappedTokenBalance: string; + totalMainTokenBalance: string; + totalBalance: string; + pool: { + __typename?: 'GqlPoolLinearNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + wrappedIndex: number; + mainIndex: number; + upperTarget: string; + lowerTarget: string; + totalShares: string; + totalLiquidity: string; + bptPriceRate: string; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }; +}; + +export type GqlPoolTokenPhantomStableFragment = { + __typename?: 'GqlPoolTokenPhantomStable'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + weight?: string | null; + priceRate: string; + decimals: number; + totalBalance: string; + pool: { + __typename?: 'GqlPoolPhantomStableNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + totalShares: string; + totalLiquidity: string; + nestingType: GqlPoolNestingType; + swapFee: string; + amp: string; + tokens: Array< + | { + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + } + | { + __typename?: 'GqlPoolTokenLinear'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + mainTokenBalance: string; + wrappedTokenBalance: string; + totalMainTokenBalance: string; + totalBalance: string; + pool: { + __typename?: 'GqlPoolLinearNested'; + id: string; + name: string; + symbol: string; + address: string; + owner: string; + factory?: string | null; + createTime: number; + wrappedIndex: number; + mainIndex: number; + upperTarget: string; + lowerTarget: string; + totalShares: string; + totalLiquidity: string; + bptPriceRate: string; + tokens: Array<{ + __typename?: 'GqlPoolToken'; + id: string; + index: number; + name: string; + symbol: string; + balance: string; + address: string; + priceRate: string; + decimals: number; + weight?: string | null; + totalBalance: string; + }>; + }; + } + >; + }; +}; + export type GetPoolsQueryVariables = Exact<{ first?: InputMaybe; skip?: InputMaybe; @@ -1494,6 +3631,373 @@ export type VeBalGetVotingListQuery = { }>; }; +export const GqlPoolTokenFragmentDoc = gql` + fragment GqlPoolToken on GqlPoolToken { + id + index + name + symbol + balance + address + priceRate + decimals + weight + totalBalance + } +`; +export const GqlPoolTokenLinearFragmentDoc = gql` + fragment GqlPoolTokenLinear on GqlPoolTokenLinear { + id + index + name + symbol + balance + address + priceRate + decimals + weight + mainTokenBalance + wrappedTokenBalance + totalMainTokenBalance + totalBalance + pool { + id + name + symbol + address + owner + factory + createTime + wrappedIndex + mainIndex + upperTarget + lowerTarget + totalShares + totalLiquidity + bptPriceRate + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + } + ${GqlPoolTokenFragmentDoc} +`; +export const GqlPoolTokenPhantomStableFragmentDoc = gql` + fragment GqlPoolTokenPhantomStable on GqlPoolTokenPhantomStable { + id + index + name + symbol + balance + address + weight + priceRate + decimals + totalBalance + pool { + id + name + symbol + address + owner + factory + createTime + totalShares + totalLiquidity + nestingType + swapFee + amp + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + ... on GqlPoolTokenLinear { + ...GqlPoolTokenLinear + } + } + } + } + ${GqlPoolTokenFragmentDoc} + ${GqlPoolTokenLinearFragmentDoc} +`; +export const GetPoolDocument = gql` + query GetPool($id: String!) { + pool: poolGetPool(id: $id) { + id + address + name + chain + owner + decimals + factory + symbol + createTime + dynamicData { + poolId + swapEnabled + totalLiquidity + totalLiquidity24hAgo + totalShares + totalShares24hAgo + fees24h + swapFee + volume24h + fees48h + volume48h + lifetimeVolume + lifetimeSwapFees + holdersCount + swapsCount + sharePriceAth + sharePriceAthTimestamp + sharePriceAtl + sharePriceAtlTimestamp + totalLiquidityAth + totalLiquidityAthTimestamp + totalLiquidityAtl + totalLiquidityAtlTimestamp + volume24hAth + volume24hAthTimestamp + volume24hAtl + volume24hAtlTimestamp + fees24hAth + fees24hAthTimestamp + fees24hAtl + fees24hAtlTimestamp + apr { + hasRewardApr + thirdPartyApr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + nativeRewardApr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + swapApr + apr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + items { + id + title + apr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + subItems { + id + title + apr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + } + } + } + } + allTokens { + id + address + name + symbol + decimals + isNested + isPhantomBpt + } + displayTokens { + id + address + name + weight + symbol + nestedTokens { + id + address + name + weight + symbol + } + } + staking { + id + type + address + gauge { + id + gaugeAddress + version + status + otherGauges { + gaugeAddress + version + status + id + rewards { + id + tokenAddress + rewardPerSecond + } + } + rewards { + id + rewardPerSecond + tokenAddress + } + } + } + investConfig { + singleAssetEnabled + proportionalEnabled + options { + poolTokenIndex + poolTokenAddress + tokenOptions { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + } + withdrawConfig { + singleAssetEnabled + proportionalEnabled + options { + poolTokenIndex + poolTokenAddress + tokenOptions { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + } + ... on GqlPoolWeighted { + nestingType + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + ... on GqlPoolTokenLinear { + ...GqlPoolTokenLinear + } + ... on GqlPoolTokenPhantomStable { + ...GqlPoolTokenPhantomStable + } + } + } + ... on GqlPoolStable { + amp + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + ... on GqlPoolMetaStable { + amp + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + ... on GqlPoolElement { + unitSeconds + principalToken + baseToken + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + ... on GqlPoolPhantomStable { + amp + nestingType + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + ... on GqlPoolTokenLinear { + ...GqlPoolTokenLinear + } + ... on GqlPoolTokenPhantomStable { + ...GqlPoolTokenPhantomStable + } + } + } + ... on GqlPoolLinear { + mainIndex + wrappedIndex + lowerTarget + upperTarget + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + ... on GqlPoolLiquidityBootstrapping { + name + nestingType + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + ... on GqlPoolTokenLinear { + ...GqlPoolTokenLinear + } + ... on GqlPoolTokenPhantomStable { + ...GqlPoolTokenPhantomStable + } + } + } + ... on GqlPoolGyro { + alpha + beta + type + nestingType + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + } + } + ${GqlPoolTokenFragmentDoc} + ${GqlPoolTokenLinearFragmentDoc} + ${GqlPoolTokenPhantomStableFragmentDoc} +`; export const GetPoolsDocument = gql` query GetPools( $first: Int @@ -1666,6 +4170,20 @@ export function getSdk( withWrapper: SdkFunctionWrapper = defaultWrapper ) { return { + GetPool( + variables: GetPoolQueryVariables, + requestHeaders?: Dom.RequestInit['headers'] + ): Promise { + return withWrapper( + wrappedRequestHeaders => + client.request(GetPoolDocument, variables, { + ...requestHeaders, + ...wrappedRequestHeaders, + }), + 'GetPool', + 'query' + ); + }, GetPools( variables?: GetPoolsQueryVariables, requestHeaders?: Dom.RequestInit['headers'] diff --git a/src/services/api/graphql/pool.graphql b/src/services/api/graphql/pool.graphql index 05ed8b7420..87914a31aa 100644 --- a/src/services/api/graphql/pool.graphql +++ b/src/services/api/graphql/pool.graphql @@ -1,115 +1,359 @@ -query GetPools( - $first: Int - $skip: Int - $orderBy: GqlPoolOrderBy - $orderDirection: GqlPoolOrderDirection - $where: GqlPoolFilter +query GetPool( + $id: String! ) { - pools: poolGetPools (first: $first, skip: $skip, orderBy: $orderBy, orderDirection: $orderDirection, where: $where) { + pool: poolGetPool (id: $id) { + id + address + name + chain + owner + decimals + factory + symbol + createTime + dynamicData { + poolId + swapEnabled + totalLiquidity + totalLiquidity24hAgo + totalShares + totalShares24hAgo + fees24h + swapFee + volume24h + fees48h + volume48h + lifetimeVolume + lifetimeSwapFees + holdersCount + swapsCount + sharePriceAth + sharePriceAthTimestamp + sharePriceAtl + sharePriceAtlTimestamp + totalLiquidityAth + totalLiquidityAthTimestamp + totalLiquidityAtl + totalLiquidityAtlTimestamp + volume24hAth + volume24hAthTimestamp + volume24hAtl + volume24hAtlTimestamp + fees24hAth + fees24hAthTimestamp + fees24hAtl + fees24hAtlTimestamp + apr { + hasRewardApr + thirdPartyApr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + nativeRewardApr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + swapApr + apr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + items { + id + title + apr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + subItems { + id + title + apr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + } + } + } + } + allTokens { + id + address + name + symbol + decimals + isNested + isPhantomBpt + } + displayTokens { + id + address + name + weight + symbol + nestedTokens { + id + address + name + weight + symbol + } + } + staking { + id + type + address + gauge { + id + gaugeAddress + version + status + otherGauges { + gaugeAddress + version + status + id + rewards { + id + tokenAddress + rewardPerSecond + } + } + rewards { + id + rewardPerSecond + tokenAddress + } + } + } + investConfig { + singleAssetEnabled + proportionalEnabled + options { + poolTokenIndex + poolTokenAddress + tokenOptions { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + } + withdrawConfig { + singleAssetEnabled + proportionalEnabled + options { + poolTokenIndex + poolTokenAddress + tokenOptions { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + } + ... on GqlPoolWeighted { + nestingType + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + ... on GqlPoolTokenLinear { + ...GqlPoolTokenLinear + } + ... on GqlPoolTokenPhantomStable { + ...GqlPoolTokenPhantomStable + } + } + } + ... on GqlPoolStable { + amp + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + ... on GqlPoolMetaStable { + amp + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + ... on GqlPoolElement { + unitSeconds + principalToken + baseToken + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + ... on GqlPoolPhantomStable { + amp + nestingType + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + ... on GqlPoolTokenLinear { + ...GqlPoolTokenLinear + } + ... on GqlPoolTokenPhantomStable { + ...GqlPoolTokenPhantomStable + } + } + } + ... on GqlPoolLinear { + mainIndex + wrappedIndex + lowerTarget + upperTarget + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + ... on GqlPoolLiquidityBootstrapping { + name + nestingType + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + ... on GqlPoolTokenLinear { + ...GqlPoolTokenLinear + } + ... on GqlPoolTokenPhantomStable { + ...GqlPoolTokenPhantomStable + } + } + } + ... on GqlPoolGyro { + alpha + beta + type + nestingType + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + } + } + } +} + + +fragment GqlPoolToken on GqlPoolToken { id - chain - address + index name symbol - type - version - owner - factory + balance + address + priceRate + decimals + weight + totalBalance +} + +fragment GqlPoolTokenLinear on GqlPoolTokenLinear { + id + index + name symbol - createTime - dynamicData { - totalLiquidity - totalShares - fees24h - swapFee - lifetimeSwapFees - swapEnabled - volume24h - lifetimeVolume - apr { - hasRewardApr - thirdPartyApr { - ... on GqlPoolAprTotal { - total - } - ... on GqlPoolAprRange { - min - max - } - } - nativeRewardApr { - ... on GqlPoolAprTotal { - total - } - ... on GqlPoolAprRange { - min - max - } - } - swapApr - apr { - ... on GqlPoolAprTotal { - total - } - ... on GqlPoolAprRange { - min - max - } - } - items { - id - title - apr { - ... on GqlPoolAprTotal { - total - } - ... on GqlPoolAprRange { - min - max - } - } - subItems { - id - title - apr { - ... on GqlPoolAprTotal { - total - } - ... on GqlPoolAprRange { - min - max - } + balance + address + priceRate + decimals + weight + mainTokenBalance + wrappedTokenBalance + totalMainTokenBalance + totalBalance + pool { + id + name + symbol + address + owner + factory + createTime + wrappedIndex + mainIndex + upperTarget + lowerTarget + totalShares + totalLiquidity + bptPriceRate + tokens { + ... on GqlPoolToken { + ...GqlPoolToken } - } } - } } - allTokens { - id - address - isNested - isPhantomBpt - weight - symbol - } - displayTokens { - id - address - name - weight - symbol - nestedTokens { +} + +fragment GqlPoolTokenPhantomStable on GqlPoolTokenPhantomStable { + id + index + name + symbol + balance + address + weight + priceRate + decimals + totalBalance + pool { id - address name - weight symbol - } - } - staking { - id - type - address + address + owner + factory + createTime + totalShares + totalLiquidity + nestingType + swapFee + amp + tokens { + ... on GqlPoolToken { + ...GqlPoolToken + } + ... on GqlPoolTokenLinear { + ...GqlPoolTokenLinear + } + } } - } -} +} \ No newline at end of file diff --git a/src/services/api/graphql/pools.graphql b/src/services/api/graphql/pools.graphql new file mode 100644 index 0000000000..794c0e7d96 --- /dev/null +++ b/src/services/api/graphql/pools.graphql @@ -0,0 +1,116 @@ + +query GetPools( + $first: Int + $skip: Int + $orderBy: GqlPoolOrderBy + $orderDirection: GqlPoolOrderDirection + $where: GqlPoolFilter +) { + pools: poolGetPools (first: $first, skip: $skip, orderBy: $orderBy, orderDirection: $orderDirection, where: $where) { + id + chain + address + name + symbol + type + version + owner + factory + symbol + createTime + dynamicData { + totalLiquidity + totalShares + fees24h + swapFee + lifetimeSwapFees + swapEnabled + volume24h + lifetimeVolume + apr { + hasRewardApr + thirdPartyApr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + nativeRewardApr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + swapApr + apr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + items { + id + title + apr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + subItems { + id + title + apr { + ... on GqlPoolAprTotal { + total + } + ... on GqlPoolAprRange { + min + max + } + } + } + } + } + } + allTokens { + id + address + isNested + isPhantomBpt + weight + symbol + } + displayTokens { + id + address + name + weight + symbol + nestedTokens { + id + address + name + weight + symbol + } + } + staking { + id + type + address + } + } +} diff --git a/src/services/balancer/api/entities/pool/index.ts b/src/services/balancer/api/entities/pool/index.ts index ad52389989..5cc48e82f7 100644 --- a/src/services/balancer/api/entities/pool/index.ts +++ b/src/services/balancer/api/entities/pool/index.ts @@ -1,42 +1,122 @@ -import { configService } from '@/services/config/config.service'; -import { Pool } from '@/services/pool/types'; -import { PoolsQueryBuilder } from '@/types/subgraph'; -import { GraphQLArgs, GraphQLQuery } from '@balancer-labs/sdk'; -import axios from 'axios'; +import { getApi } from '@/dependencies/balancer-api'; +import { Pool, PoolToken } from '@/services/pool/types'; import Service from '../../balancer-api.service'; -import queryBuilder from './query'; +import { + GetPoolQuery, + GqlPoolApr, + GqlPoolTokenUnion, +} from '@/services/api/graphql/generated/api-types'; +import { mapApiChain } from '@/lib/utils/api'; +import { AprBreakdown, PoolType } from '@balancer-labs/sdk'; + +export type ApiPool = GetPoolQuery['pool']; + +export interface ApiArgs { + id: string; +} export default class SinglePool { service: Service; - queryBuilder: PoolsQueryBuilder; - lastQuery?: GraphQLQuery; - constructor( - service: Service, - _queryBuilder: PoolsQueryBuilder = queryBuilder - ) { + constructor(service: Service) { this.service = service; - this.queryBuilder = _queryBuilder; } - public async get( - args: GraphQLArgs = {}, - attrs: any = {} - ): Promise { - const query = this.queryBuilder(args, attrs); - if (!query.args.chainId) { - throw new Error('Invalid query - missing chainId'); - } - if (!query.args.where?.id?.eq) { - throw new Error('Invalid query - missing pool id'); - } - - const chainId: number = query.args.chainId; - const poolId: string = query.args.where.id.eq; - const url = `${configService.network.balancerApi}/pools/${chainId}/${poolId}`; - - const { data } = await axios.get(url); - return data; + public async get(args: ApiArgs): Promise { + const api = getApi(); + const id = args.id; + + console.log('Getting pool from API'); + const response = await api.GetPool({ id }); + const pool: ApiPool = response.pool; + console.log('Got pool from API: ', pool); + + const convertedPool: Pool = this.mapPool(pool); + + return convertedPool; + } + + mapPool(apiPool: ApiPool): Pool { + const converted: Pool = { + id: apiPool.id, + name: apiPool.name || '', + address: apiPool.address, + chainId: mapApiChain(apiPool.chain), + poolType: PoolType.Weighted, // mapApiPoolType(apiPool.type) || PoolType.Weighted,, + poolTypeVersion: 1, // apiPool.version || 1, + swapFee: apiPool.dynamicData.swapFee, + swapEnabled: apiPool.dynamicData.swapEnabled, + protocolYieldFeeCache: '0.5', // Default protocol yield fee + protocolSwapFeeCache: '0.5', // Default protocol swap fee + // amp: apiPool.amp ?? undefined, + owner: apiPool.owner ?? undefined, + factory: apiPool.factory ?? undefined, + symbol: apiPool.symbol ?? undefined, + tokens: ((apiPool.tokens as GqlPoolTokenUnion[]) || []) + .map(this.mapToken) + .filter(token => token.address !== apiPool.address), + tokensList: (apiPool.allTokens || []) + .map(t => t.address) + .filter(address => address !== apiPool.address), + tokenAddresses: (apiPool.allTokens || []) + .map(t => t.address) + .filter(address => address !== apiPool.address), + totalLiquidity: apiPool.dynamicData.totalLiquidity, + totalShares: apiPool.dynamicData.totalShares, + totalSwapFee: apiPool.dynamicData.lifetimeSwapFees, + totalSwapVolume: apiPool.dynamicData.lifetimeVolume, + apr: this.mapApr(apiPool.dynamicData.apr), + // priceRateProviders: apiPool.priceRateProviders ?? undefined, + // onchain: subgraphPool.onchain, + createTime: apiPool.createTime, + // mainIndex: apiPool.mainIndex ?? undefined, + // wrappedIndex: apiPool.wrappedIndex ?? undefined, + // mainTokens: subgraphPool.mainTokens, + // wrappedTokens: subgraphPool.wrappedTokens, + // unwrappedTokens: subgraphPool.unwrappedTokens, + // isNew: subgraphPool.isNew, + volumeSnapshot: apiPool.dynamicData.volume24h, + feesSnapshot: apiPool.dynamicData.fees24h, + // boost: subgraphPool.boost, + totalWeight: '1', + lowerTarget: '0', + upperTarget: '0', + // isInRecoveryMode: apiPool.isInRecoveryMode ?? false, + // isPaused: apiPool.isPaused ?? false, + }; + + return converted; + } + + private mapToken(apiToken: GqlPoolTokenUnion): PoolToken { + return { + address: apiToken.address, + balance: apiToken.balance, + priceRate: apiToken.priceRate, + weight: apiToken.weight, + }; + } + + private mapApr(apiApr: GqlPoolApr): AprBreakdown { + console.log('Converting apr: ', apiApr); + return { + swapFees: Number(apiApr.swapApr) * 100, + tokenAprs: { + total: 0, + breakdown: {}, + }, + stakingApr: { + min: 0, + max: 0, + }, + rewardAprs: { + total: 0, + breakdown: {}, + }, + protocolApr: 0, + min: Number(apiApr.apr) * 100, + max: Number(apiApr.apr) * 100, + }; } } diff --git a/src/services/balancer/api/entities/pools/index.ts b/src/services/balancer/api/entities/pools/index.ts index 3e1b27c685..383dbc2693 100644 --- a/src/services/balancer/api/entities/pools/index.ts +++ b/src/services/balancer/api/entities/pools/index.ts @@ -9,7 +9,6 @@ import { GqlPoolOrderDirection, GqlPoolTokenExpanded, } from '@/services/api/graphql/generated/api-types'; -import { PoolsQueryBuilder } from '@/types/subgraph'; import { AprBreakdown, GraphQLQuery, @@ -20,7 +19,6 @@ import { import { Network } from '@/lib/config'; import Service from '../../balancer-api.service'; -import queryBuilder from './query'; import { mapApiChain, mapApiPoolType } from '@/lib/utils/api'; export type ApiPools = GetPoolsQuery['pools']; @@ -36,16 +34,11 @@ export interface ApiArgs { export default class Pools { service: Service; - queryBuilder: PoolsQueryBuilder; lastQuery?: GraphQLQuery; repository?: PoolsBalancerAPIRepository; - constructor( - service: Service, - _queryBuilder: PoolsQueryBuilder = queryBuilder - ) { + constructor(service: Service) { this.service = service; - this.queryBuilder = _queryBuilder; } public async get(args: ApiArgs = {}): Promise {