From 8c10d4a6a6df34ed6f918b48b20bb681d1d7fd53 Mon Sep 17 00:00:00 2001 From: Karan Shahani Date: Sat, 18 Nov 2023 16:17:29 -0500 Subject: [PATCH] feat(beethoven-x): Update subgraph URL and factories --- .../common/beethoven-x.pool.token-fetcher.ts | 12 +++++++++--- .../fantom/beethoven-x.pool.token-fetcher.ts | 4 +++- .../optimism/beethoven-x.pool.token-fetcher.ts | 7 ++++--- .../contract-position.template.position-fetcher.ts | 4 ++-- ...om-contract-position.template.position-fetcher.ts | 4 ++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/apps/beethoven-x/common/beethoven-x.pool.token-fetcher.ts b/src/apps/beethoven-x/common/beethoven-x.pool.token-fetcher.ts index 521f6945d..327af0a17 100644 --- a/src/apps/beethoven-x/common/beethoven-x.pool.token-fetcher.ts +++ b/src/apps/beethoven-x/common/beethoven-x.pool.token-fetcher.ts @@ -8,6 +8,7 @@ import { } from '~apps/balancer-v2/common/balancer-v2.pool.token-fetcher'; import { BalancerPool } from '~apps/balancer-v2/contracts/viem'; import { GetDisplayPropsParams, GetTokenPropsParams } from '~position/template/app-token.template.types'; +import { Network } from '~types'; type GetPoolsResponse = { poolGetPools: { @@ -22,9 +23,14 @@ type GetPoolsResponse = { }[]; }; +const NETWORK_TO_CHAIN_CONSTANTS = { + [Network.FANTOM_OPERA_MAINNET]: 'FANTOM', + [Network.OPTIMISM_MAINNET]: 'OPTIMISM', +}; + const GET_POOLS_QUERY = gql` - query { - poolGetPools(first: 1000, orderBy: totalLiquidity, orderDirection: desc) { + query GetPools($network: GqlChain!) { + poolGetPools(first: 1000, orderBy: totalLiquidity, orderDirection: desc, where: { chainIn: [$network] }) { id name address @@ -45,6 +51,7 @@ export abstract class BeethovenXPoolTokenFetcher extends BalancerV2PoolTokenFetc const poolsResponse = await gqlFetch({ endpoint: this.subgraphUrl, query: GET_POOLS_QUERY, + variables: { network: NETWORK_TO_CHAIN_CONSTANTS[this.network] }, headers: { 'Content-Type': 'application/json' }, }); @@ -60,7 +67,6 @@ export abstract class BeethovenXPoolTokenFetcher extends BalancerV2PoolTokenFetc multicall, }: GetTokenPropsParams) { // Logic derived from https://github.com/beethovenxfi/beethovenx-backend/blob/v2-main/modules/pool/lib/pool-on-chain-data.service.ts#L157-L172 - if ( (definition.poolType === 'PHANTOM_STABLE' && this.composablePoolFactories.includes(definition.factory)) || (definition.poolType === 'WEIGHTED' && this.weightedPoolV2Factories.includes(definition.factory)) diff --git a/src/apps/beethoven-x/fantom/beethoven-x.pool.token-fetcher.ts b/src/apps/beethoven-x/fantom/beethoven-x.pool.token-fetcher.ts index e10d204a3..2a9d00066 100644 --- a/src/apps/beethoven-x/fantom/beethoven-x.pool.token-fetcher.ts +++ b/src/apps/beethoven-x/fantom/beethoven-x.pool.token-fetcher.ts @@ -4,7 +4,7 @@ import { BeethovenXPoolTokenFetcher } from '../common/beethoven-x.pool.token-fet @PositionTemplate() export class FantomBeethovenXPoolTokenFetcher extends BeethovenXPoolTokenFetcher { - subgraphUrl = 'https://backend-v2.beets-ftm-node.com/graphql'; + subgraphUrl = 'https://backend-v3.beets-ftm-node.com/graphql'; vaultAddress = '0x20dd72ed959b6147912c2e529f0a0c651c33c9ce'; composablePoolFactories = [ '0x5adaf6509bcec3219455348ac45d6d3261b1a990', @@ -12,12 +12,14 @@ export class FantomBeethovenXPoolTokenFetcher extends BeethovenXPoolTokenFetcher '0x44814e3a603bb7f1198617995c5696c232f6e8ed', '0x911566c808bf00acb200b418564440a2af177548', '0x5c3094982cf3c97a06b7d62a6f7669f14a199b19', + '0x23f03a4fb344d8b98833d2ace093cc305e03474f', ]; weightedPoolV2Factories = [ '0xb2ed595afc445b47db7043bec25e772bf0fa1fbb', '0x8ea1c497c16726e097f62c8c9fbd944143f27090', '0xea87f3dffc679035653c0fba70e7bfe46e3fb733', '0xd678b6acd834cc969bb19ce82727f2a541fb7941', + '0xb841df73861e65e6d61a80f503f095a91ce75e15', ]; groupLabel = 'Pools'; diff --git a/src/apps/beethoven-x/optimism/beethoven-x.pool.token-fetcher.ts b/src/apps/beethoven-x/optimism/beethoven-x.pool.token-fetcher.ts index a5e6382b8..8f705834a 100644 --- a/src/apps/beethoven-x/optimism/beethoven-x.pool.token-fetcher.ts +++ b/src/apps/beethoven-x/optimism/beethoven-x.pool.token-fetcher.ts @@ -4,17 +4,18 @@ import { BeethovenXPoolTokenFetcher } from '../common/beethoven-x.pool.token-fet @PositionTemplate() export class OptimismBeethovenXPoolTokenFetcher extends BeethovenXPoolTokenFetcher { - subgraphUrl = 'https://backend-optimism-v2.beets-ftm-node.com/'; + subgraphUrl = 'https://backend-v3.beets-ftm-node.com/'; vaultAddress = '0xba12222222228d8ba445958a75a0704d566bf2c8'; composablePoolFactories = [ '0xf145cafb67081895ee80eb7c04a30cf87f07b745', '0xe2e901ab09f37884ba31622df3ca7fc19aa443be', - '0xe2e901ab09f37884ba31622df3ca7fc19aa443be', + '0x1802953277fd955f9a254b80aa0582f193cf1d77', + '0x043a2dad730d585c44fb79d2614f295d2d625412', ]; weightedPoolV2Factories = [ '0xad901309d9e9dbc5df19c84f729f429f0189a633', '0xa0dabebaad1b243bbb243f933013d560819eb66f', - '0xa0dabebaad1b243bbb243f933013d560819eb66f', + '0x230a59f4d9adc147480f03b0d3fffecd56c3289a', ]; groupLabel = 'Pools'; diff --git a/src/position/template/contract-position.template.position-fetcher.ts b/src/position/template/contract-position.template.position-fetcher.ts index 147b03738..a6533f607 100644 --- a/src/position/template/contract-position.template.position-fetcher.ts +++ b/src/position/template/contract-position.template.position-fetcher.ts @@ -1,6 +1,7 @@ import { Inject } from '@nestjs/common'; -import { BigNumberish, Contract } from 'ethers/lib/ethers'; +import { BigNumberish } from 'ethers/lib/ethers'; import _, { compact, sumBy } from 'lodash'; +import { Abi, GetContractReturnType, PublicClient } from 'viem'; import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; import { ZERO_ADDRESS } from '~app-toolkit/constants/address'; @@ -28,7 +29,6 @@ import { UnderlyingTokenDefinition, } from './contract-position.template.types'; import { PositionFetcherTemplateCommons } from './position-fetcher.template.types'; -import { Abi, GetContractReturnType, PublicClient } from 'viem'; export abstract class ContractPositionTemplatePositionFetcher< T extends Abi, diff --git a/src/position/template/custom-contract-position.template.position-fetcher.ts b/src/position/template/custom-contract-position.template.position-fetcher.ts index 271825b6c..4f63275d6 100644 --- a/src/position/template/custom-contract-position.template.position-fetcher.ts +++ b/src/position/template/custom-contract-position.template.position-fetcher.ts @@ -1,6 +1,7 @@ import { Inject } from '@nestjs/common'; -import { BigNumberish, Contract } from 'ethers/lib/ethers'; +import { BigNumberish } from 'ethers/lib/ethers'; import { compact } from 'lodash'; +import { Abi, GetContractReturnType, PublicClient } from 'viem'; import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; import { @@ -26,7 +27,6 @@ import { UnderlyingTokenDefinition, } from './contract-position.template.types'; import { PositionFetcherTemplateCommons } from './position-fetcher.template.types'; -import { Abi, GetContractReturnType, PublicClient } from 'viem'; export abstract class CustomContractPositionTemplatePositionFetcher< T extends Abi,