Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
feat(beethoven-x): Update subgraph URL and factories
Browse files Browse the repository at this point in the history
  • Loading branch information
immasandwich committed Nov 18, 2023
1 parent 5eb6765 commit 8c10d4a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
12 changes: 9 additions & 3 deletions src/apps/beethoven-x/common/beethoven-x.pool.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand All @@ -45,6 +51,7 @@ export abstract class BeethovenXPoolTokenFetcher extends BalancerV2PoolTokenFetc
const poolsResponse = await gqlFetch<GetPoolsResponse>({
endpoint: this.subgraphUrl,
query: GET_POOLS_QUERY,
variables: { network: NETWORK_TO_CHAIN_CONSTANTS[this.network] },
headers: { 'Content-Type': 'application/json' },
});

Expand All @@ -60,7 +67,6 @@ export abstract class BeethovenXPoolTokenFetcher extends BalancerV2PoolTokenFetc
multicall,
}: GetTokenPropsParams<BalancerPool, BalancerV2PoolTokenDataProps, BalancerV2PoolTokenDefinition>) {
// 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ 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',
'0xb384a86f2fd7788720db42f9daa60fc07ecbea06',
'0x44814e3a603bb7f1198617995c5696c232f6e8ed',
'0x911566c808bf00acb200b418564440a2af177548',
'0x5c3094982cf3c97a06b7d62a6f7669f14a199b19',
'0x23f03a4fb344d8b98833d2ace093cc305e03474f',
];
weightedPoolV2Factories = [
'0xb2ed595afc445b47db7043bec25e772bf0fa1fbb',
'0x8ea1c497c16726e097f62c8c9fbd944143f27090',
'0xea87f3dffc679035653c0fba70e7bfe46e3fb733',
'0xd678b6acd834cc969bb19ce82727f2a541fb7941',
'0xb841df73861e65e6d61a80f503f095a91ce75e15',
];

groupLabel = 'Pools';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
Expand Down

0 comments on commit 8c10d4a

Please sign in to comment.