From c177c31d9692e9b7619a5acb3fd7a56fc72e7bde Mon Sep 17 00:00:00 2001 From: gmbronco <83549293+gmbronco@users.noreply.github.com> Date: Thu, 19 Oct 2023 07:09:10 +0200 Subject: [PATCH] Revert "YB tokens refactor, new Maker on Gnosis source" (#488) Revert "YB tokens refactor, new Maker on Gnosis source (#487)" This reverts commit a6c186702f714ada1783c24826fc37a5b3bd4a0c. --- .gitignore | 2 +- modules/network/arbitrum.ts | 9 +- modules/network/avalanche.ts | 9 +- modules/network/base.ts | 7 +- modules/network/fantom.ts | 9 +- modules/network/gnosis.ts | 9 +- modules/network/mainnet.ts | 9 +- modules/network/optimism.ts | 9 +- modules/network/polygon.ts | 9 +- modules/network/zkevm.ts | 9 +- .../ib-linear-apr-handlers.ts | 222 +++++++++++------- .../sources/aave-apr-handler.ts | 9 +- .../sources/ankr-apr-handler.ts | 14 +- .../sources/beefy-apr-handler.ts | 25 +- .../sources/bloom-apr-handler.ts | 16 +- .../sources/default-apr-handler.ts | 12 +- .../sources/euler-apr-handler.ts | 1 - .../sources/gearbox-apr-handler.ts | 6 +- .../sources/idle-apr-handler.ts | 6 +- .../ib-linear-apr-handlers/sources/index.ts | 16 -- .../sources/maker-apr-handler.ts | 12 +- .../sources/maker-gnosis-apr-handler.ts | 36 --- .../sources/ovix-apr-handler.ts | 1 - .../sources/reaper-crypt-apr-handler.ts | 8 +- .../sources/tessera-apr-handler.ts | 6 +- .../sources/tetu-apr-handler.ts | 1 - .../sources/tranchess-apr-handler.ts | 6 +- .../sources/yearn-apr-handler.ts | 8 +- .../apr-data-sources/ib-tokens-apr.service.ts | 22 +- .../phantom-stable-apr.service.ts | 14 +- tsconfig.json | 6 +- 31 files changed, 212 insertions(+), 316 deletions(-) delete mode 100644 modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/index.ts delete mode 100644 modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/maker-gnosis-apr-handler.ts diff --git a/.gitignore b/.gitignore index 709b8be0b..f570c71dc 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,9 @@ node_modules/ *-error.log **/generated/* -debug debug.ts schema.ts +debug.ts graphql_schema_generated*.ts i18n/* google-service-account.json diff --git a/modules/network/arbitrum.ts b/modules/network/arbitrum.ts index a4de660bb..2b933ed32 100644 --- a/modules/network/arbitrum.ts +++ b/modules/network/arbitrum.ts @@ -225,13 +225,8 @@ export const arbitrumNetworkConfig: NetworkConfig = { contentService: new GithubContentService(), provider: new ethers.providers.JsonRpcProvider({ url: arbitrumNetworkData.rpcUrl, timeout: 60000 }), poolAprServices: [ - new IbTokensAprService( - arbitrumNetworkData.ibAprConfig, - arbitrumNetworkData.chain.prismaId, - arbitrumNetworkData.balancer.yieldProtocolFeePercentage, - arbitrumNetworkData.balancer.swapProtocolFeePercentage - ), - new PhantomStableAprService(arbitrumNetworkData.chain.prismaId, arbitrumNetworkData.balancer.yieldProtocolFeePercentage), + new IbTokensAprService(arbitrumNetworkData.ibAprConfig), + new PhantomStableAprService(), new BoostedPoolAprService(), new SwapFeeAprService(arbitrumNetworkData.balancer.swapProtocolFeePercentage), new GaugeAprService(tokenService, [arbitrumNetworkData.bal!.address]), diff --git a/modules/network/avalanche.ts b/modules/network/avalanche.ts index 814cae39f..fb0b432fa 100644 --- a/modules/network/avalanche.ts +++ b/modules/network/avalanche.ts @@ -217,13 +217,8 @@ export const avalancheNetworkConfig: NetworkConfig = { contentService: new GithubContentService(), provider: new ethers.providers.JsonRpcProvider({ url: avalancheNetworkData.rpcUrl, timeout: 60000 }), poolAprServices: [ - new IbTokensAprService( - avalancheNetworkData.ibAprConfig, - avalancheNetworkData.chain.prismaId, - avalancheNetworkData.balancer.yieldProtocolFeePercentage, - avalancheNetworkData.balancer.swapProtocolFeePercentage - ), - new PhantomStableAprService(avalancheNetworkData.chain.prismaId, avalancheNetworkData.balancer.yieldProtocolFeePercentage), + new IbTokensAprService(avalancheNetworkData.ibAprConfig), + new PhantomStableAprService(), new BoostedPoolAprService(), new SwapFeeAprService(avalancheNetworkData.balancer.swapProtocolFeePercentage), new GaugeAprService(tokenService, [avalancheNetworkData.bal!.address]), diff --git a/modules/network/base.ts b/modules/network/base.ts index d50b492e8..e7f00f4d8 100644 --- a/modules/network/base.ts +++ b/modules/network/base.ts @@ -119,12 +119,7 @@ export const baseNetworkConfig: NetworkConfig = { contentService: new GithubContentService(), provider: new ethers.providers.JsonRpcProvider({ url: baseNetworkData.rpcUrl, timeout: 60000 }), poolAprServices: [ - new IbTokensAprService( - baseNetworkData.ibAprConfig, - baseNetworkData.chain.prismaId, - baseNetworkData.balancer.yieldProtocolFeePercentage, - baseNetworkData.balancer.swapProtocolFeePercentage - ), + new IbTokensAprService(baseNetworkData.ibAprConfig), new BoostedPoolAprService(), new SwapFeeAprService(baseNetworkData.balancer.swapProtocolFeePercentage), new GaugeAprService(tokenService, [baseNetworkData.bal!.address]), diff --git a/modules/network/fantom.ts b/modules/network/fantom.ts index c0846e05d..16d4a7d56 100644 --- a/modules/network/fantom.ts +++ b/modules/network/fantom.ts @@ -300,14 +300,9 @@ export const fantomNetworkConfig: NetworkConfig = { contentService: new SanityContentService(), provider: new ethers.providers.JsonRpcProvider({ url: fantomNetworkData.rpcUrl, timeout: 60000 }), poolAprServices: [ - new IbTokensAprService( - fantomNetworkData.ibAprConfig, - fantomNetworkData.chain.prismaId, - fantomNetworkData.balancer.yieldProtocolFeePercentage, - fantomNetworkData.balancer.swapProtocolFeePercentage - ), + new IbTokensAprService(fantomNetworkData.ibAprConfig), // new SpookySwapAprService(tokenService, fantomNetworkData.spooky!.xBooContract), - new PhantomStableAprService(fantomNetworkData.chain.prismaId, fantomNetworkData.balancer.yieldProtocolFeePercentage), + new PhantomStableAprService(), new BoostedPoolAprService(), new SwapFeeAprService(fantomNetworkData.balancer.swapProtocolFeePercentage), new MasterchefFarmAprService(fantomNetworkData.beets!.address), diff --git a/modules/network/gnosis.ts b/modules/network/gnosis.ts index 20ff09076..f5780ac4f 100644 --- a/modules/network/gnosis.ts +++ b/modules/network/gnosis.ts @@ -143,13 +143,8 @@ export const gnosisNetworkConfig: NetworkConfig = { contentService: new GithubContentService(), provider: new ethers.providers.JsonRpcProvider({ url: gnosisNetworkData.rpcUrl, timeout: 60000 }), poolAprServices: [ - new IbTokensAprService( - gnosisNetworkData.ibAprConfig, - gnosisNetworkData.chain.prismaId, - gnosisNetworkData.balancer.yieldProtocolFeePercentage, - gnosisNetworkData.balancer.swapProtocolFeePercentage, - ), - new PhantomStableAprService(gnosisNetworkData.chain.prismaId, gnosisNetworkData.balancer.yieldProtocolFeePercentage), + new IbTokensAprService(gnosisNetworkData.ibAprConfig), + new PhantomStableAprService(), new BoostedPoolAprService(), new SwapFeeAprService(gnosisNetworkData.balancer.swapProtocolFeePercentage), new GaugeAprService(tokenService, [gnosisNetworkData.bal!.address]), diff --git a/modules/network/mainnet.ts b/modules/network/mainnet.ts index 11911007b..c41b220c5 100644 --- a/modules/network/mainnet.ts +++ b/modules/network/mainnet.ts @@ -364,13 +364,8 @@ export const mainnetNetworkConfig: NetworkConfig = { contentService: new GithubContentService(), provider: new ethers.providers.JsonRpcProvider({ url: mainnetNetworkData.rpcUrl, timeout: 60000 }), poolAprServices: [ - new IbTokensAprService( - mainnetNetworkData.ibAprConfig, - mainnetNetworkData.chain.prismaId, - mainnetNetworkData.balancer.yieldProtocolFeePercentage, - mainnetNetworkData.balancer.swapProtocolFeePercentage - ), - new PhantomStableAprService(mainnetNetworkData.chain.prismaId, mainnetNetworkData.balancer.yieldProtocolFeePercentage), + new IbTokensAprService(mainnetNetworkData.ibAprConfig), + new PhantomStableAprService(), new BoostedPoolAprService(), new SwapFeeAprService(mainnetNetworkData.balancer.swapProtocolFeePercentage), new GaugeAprService(tokenService, [mainnetNetworkData.bal!.address]), diff --git a/modules/network/optimism.ts b/modules/network/optimism.ts index d122e7a5f..730d8e55e 100644 --- a/modules/network/optimism.ts +++ b/modules/network/optimism.ts @@ -258,13 +258,8 @@ export const optimismNetworkConfig: NetworkConfig = { contentService: new SanityContentService(), provider: new ethers.providers.JsonRpcProvider({ url: optimismNetworkData.rpcUrl, timeout: 60000 }), poolAprServices: [ - new IbTokensAprService( - optimismNetworkData.ibAprConfig, - optimismNetworkData.chain.prismaId, - optimismNetworkData.balancer.yieldProtocolFeePercentage, - optimismNetworkData.balancer.swapProtocolFeePercentage, - ), - new PhantomStableAprService(optimismNetworkData.chain.prismaId, optimismNetworkData.balancer.yieldProtocolFeePercentage), + new IbTokensAprService(optimismNetworkData.ibAprConfig), + new PhantomStableAprService(), new BoostedPoolAprService(), new SwapFeeAprService(optimismNetworkData.balancer.swapProtocolFeePercentage), new GaugeAprService(tokenService, [ diff --git a/modules/network/polygon.ts b/modules/network/polygon.ts index 38ccc9889..f5041268b 100644 --- a/modules/network/polygon.ts +++ b/modules/network/polygon.ts @@ -262,13 +262,8 @@ export const polygonNetworkConfig: NetworkConfig = { contentService: new GithubContentService(), provider: new ethers.providers.JsonRpcProvider({ url: polygonNetworkData.rpcUrl, timeout: 60000 }), poolAprServices: [ - new IbTokensAprService( - polygonNetworkData.ibAprConfig, - polygonNetworkData.chain.prismaId, - polygonNetworkData.balancer.yieldProtocolFeePercentage, - polygonNetworkData.balancer.swapProtocolFeePercentage - ), - new PhantomStableAprService(polygonNetworkData.chain.prismaId, polygonNetworkData.balancer.yieldProtocolFeePercentage), + new IbTokensAprService(polygonNetworkData.ibAprConfig), + new PhantomStableAprService(), new BoostedPoolAprService(), new SwapFeeAprService(polygonNetworkData.balancer.swapProtocolFeePercentage), new GaugeAprService(tokenService, [polygonNetworkData.bal!.address]), diff --git a/modules/network/zkevm.ts b/modules/network/zkevm.ts index 2f976e611..b87b04156 100644 --- a/modules/network/zkevm.ts +++ b/modules/network/zkevm.ts @@ -162,13 +162,8 @@ export const zkevmNetworkConfig: NetworkConfig = { contentService: new GithubContentService(), provider: new ethers.providers.JsonRpcProvider({ url: zkevmNetworkData.rpcUrl, timeout: 60000 }), poolAprServices: [ - new IbTokensAprService( - zkevmNetworkData.ibAprConfig, - zkevmNetworkData.chain.prismaId, - zkevmNetworkData.balancer.yieldProtocolFeePercentage, - zkevmNetworkData.balancer.swapProtocolFeePercentage, - ), - new PhantomStableAprService(zkevmNetworkData.chain.prismaId, zkevmNetworkData.balancer.yieldProtocolFeePercentage), + new IbTokensAprService(zkevmNetworkData.ibAprConfig), + new PhantomStableAprService(), new BoostedPoolAprService(), new SwapFeeAprService(zkevmNetworkData.balancer.swapProtocolFeePercentage), new GaugeAprService(tokenService, [zkevmNetworkData.bal!.address]), diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/ib-linear-apr-handlers.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/ib-linear-apr-handlers.ts index 4f399d649..6b3ae0816 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/ib-linear-apr-handlers.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/ib-linear-apr-handlers.ts @@ -1,113 +1,169 @@ -import * as sources from './sources'; +import { AaveAprHandler } from './sources/aave-apr-handler'; +import { AnkrAprHandler } from './sources/ankr-apr-handler'; +import { DefaultAprHandler } from './sources/default-apr-handler'; +import { EulerAprHandler } from './sources/euler-apr-handler'; +import { GearboxAprHandler } from './sources/gearbox-apr-handler'; +import { IdleAprHandler } from './sources/idle-apr-handler'; +import { OvixAprHandler } from './sources/ovix-apr-handler'; +import { TesseraAprHandler } from './sources/tessera-apr-handler'; +import { TetuAprHandler } from './sources/tetu-apr-handler'; +import { TranchessAprHandler } from './sources/tranchess-apr-handler'; +import { YearnAprHandler } from './sources/yearn-apr-handler'; +import { ReaperCryptAprHandler } from './sources/reaper-crypt-apr-handler'; +import { BeefyAprHandler } from './sources/beefy-apr-handler'; import { IbAprConfig } from '../../../../network/apr-config-types'; -import { Chain } from '@prisma/client'; - -const sourceToHandler = { - aave: sources.AaveAprHandler, - ankr: sources.AnkrAprHandler, - beefy: sources.BeefyAprHandler, - bloom: sources.BloomAprHandler, - euler: sources.EulerAprHandler, - gearbox: sources.GearboxAprHandler, - idle: sources.IdleAprHandler, - maker: sources.MakerAprHandler, - ovix: sources.OvixAprHandler, - reaper: sources.ReaperCryptAprHandler, - tessera: sources.TesseraAprHandler, - tetu: sources.TetuAprHandler, - tranchess: sources.TranchessAprHandler, - yearn: sources.YearnAprHandler, - defaultHandlers: sources.DefaultAprHandler, -} +import { MakerAprHandler } from './sources/maker-apr-handler'; +import { BloomAprHandler } from './sources/bloom-apr-handler'; export class IbLinearAprHandlers { private handlers: AprHandler[] = []; fixedAprTokens?: { [tokenName: string]: { address: string; apr: number; group?: string; isIbYield?: boolean } }; - constructor(aprConfig: IbAprConfig, private chain?: Chain) { - const { fixedAprHandler, ...config } = aprConfig; - this.handlers = this.buildAprHandlers(config); - this.fixedAprTokens = fixedAprHandler; + constructor(aprConfig: IbAprConfig) { + this.handlers = this.buildAprHandlers(aprConfig); + this.fixedAprTokens = aprConfig.fixedAprHandler; } - private buildAprHandlers(aprConfig: IbAprConfig) { + buildAprHandlers(aprConfig: IbAprConfig) { const handlers: AprHandler[] = []; - - // Add handlers from global configuration - for (const [source, config] of Object.entries(aprConfig)) { - const Handler = sourceToHandler[source as keyof typeof sourceToHandler]; - - // Handle nested configs - if (source === 'aave' || source === 'defaultHandlers') { - for (const nestedConfig of Object.values(config)) { - handlers.push(new Handler(nestedConfig as any)); - } - } else { - handlers.push(new Handler(config)); + if (aprConfig.aave) { + for (const config of Object.values(aprConfig.aave)) { + const aaveHandler = new AaveAprHandler(config); + handlers.push(aaveHandler); + } + } + if (aprConfig.ankr) { + const ankrHandler = new AnkrAprHandler(aprConfig.ankr); + handlers.push(ankrHandler); + } + if (aprConfig.beefy) { + const beefyHandler = new BeefyAprHandler(aprConfig.beefy); + handlers.push(beefyHandler); + } + if (aprConfig.bloom) { + const bloomAprHandler = new BloomAprHandler(aprConfig.bloom); + handlers.push(bloomAprHandler); + } + if (aprConfig.euler) { + const eulerHandler = new EulerAprHandler(aprConfig.euler); + handlers.push(eulerHandler); + } + if (aprConfig.gearbox) { + const gearboxHandler = new GearboxAprHandler(aprConfig.gearbox); + handlers.push(gearboxHandler); + } + if (aprConfig.idle) { + const idleHandler = new IdleAprHandler(aprConfig.idle); + handlers.push(idleHandler); + } + if (aprConfig.maker) { + const makerHandler = new MakerAprHandler(aprConfig.maker); + handlers.push(makerHandler); + } + if (aprConfig.ovix) { + const ovixHandler = new OvixAprHandler({ + ...aprConfig.ovix, + }); + handlers.push(ovixHandler); + } + if (aprConfig.reaper) { + const reaperCryptHandler = new ReaperCryptAprHandler({ ...aprConfig.reaper }); + handlers.push(reaperCryptHandler); + } + if (aprConfig.tessera) { + const tesseraHandler = new TesseraAprHandler({ + ...aprConfig.tessera, + }); + handlers.push(tesseraHandler); + } + if (aprConfig.tetu) { + const tetuHandler = new TetuAprHandler(aprConfig.tetu); + handlers.push(tetuHandler); + } + if (aprConfig.tranchess) { + const tranchessHandler = new TranchessAprHandler(aprConfig.tranchess); + handlers.push(tranchessHandler); + } + if (aprConfig.yearn) { + const yearnHandler = new YearnAprHandler(aprConfig.yearn); + handlers.push(yearnHandler); + } + if (aprConfig.defaultHandlers) { + for (const handlerConfig of Object.values(aprConfig.defaultHandlers)) { + const handler = new DefaultAprHandler(handlerConfig); + handlers.push(handler); } } - - // Add handlers from self-configured sources - Object.values(sources as unknown as any[]) - .filter((source): source is { chains: Chain[], Handler: AprHandlerConstructor } => 'chains' in source) - .filter((source) => this.chain && source.chains.includes(this.chain)) - .forEach((source) => { - handlers.push(new source.Handler()); - }); - return handlers; } - async fetchAprsFromAllHandlers(): Promise { - let aprs: TokenApr[] = this.fixedAprTokens - ? Object.values(this.fixedAprTokens).map(({ address, apr, isIbYield, group }) => ({ - apr, - address, - isIbYield: isIbYield ?? false, - group - })) - : []; + // Any IB Yield tokens (such as rETH, wstETH) need to be added here. Linear Wrapped Tokens must NOT be added here. + buildIbYieldTokens(aprConfig: IbAprConfig): string[] { + const ibYieldTokenNamesForDefaultHandler = [ + 'rEth', + 'stETH', + 'wstETH', + 'cbETH', + 'sfrxETH', + 'USDR', + 'swETH', + 'wjAURA', + 'qETH', + 'ankrETH', + 'ankrFTM', + 'sFTMx', + 'stMATIC', + 'MATICX', + 'wbETH', + 'ETHx', + ].map((token) => token.toLowerCase()); - const results = await Promise.allSettled(this.handlers.map((handler) => handler.getAprs(this.chain))); + return [ + ...Object.values(aprConfig?.ankr?.tokens || {}).map((token) => token.address), + ...Object.keys(aprConfig?.defaultHandlers || {}).filter((handler) => + ibYieldTokenNamesForDefaultHandler.includes(handler.toLowerCase()), + ), + ...Object.keys(aprConfig?.fixedAprHandler || {}).filter((handler) => + ibYieldTokenNamesForDefaultHandler.includes(handler.toLowerCase()), + ), + ]; + } - for (const result of results) { - if (result.status === 'fulfilled') { - aprs = aprs.concat( - Object.entries(result.value).map(([address, { apr, isIbYield, group }]) => ({ - apr, - address, - isIbYield, - group - })), - ); - } else { - console.error('Failed to fetch APRs from handler', result.reason); + async fetchAprsFromAllHandlers(): Promise { + let aprs: TokenApr[] = []; + for (const handler of this.handlers) { + const fetchedResponse: { [key: string]: { apr: number; isIbYield: boolean } } = await handler.getAprs(); + for (const [address, { apr, isIbYield }] of Object.entries(fetchedResponse)) { + aprs.push({ + apr, + isIbYield, + group: handler.group, + address, + }); + } + } + if (this.fixedAprTokens) { + for (const { address, apr, isIbYield, group } of Object.values(this.fixedAprTokens)) { + aprs.push({ + apr, + isIbYield: isIbYield ?? false, + group, + address, + }); } } - return aprs; } } -interface AprHandlerConstructor { - new (config?: any): AprHandler; -} - export interface AprHandler { - group?: string; - getAprs(chain?: Chain): Promise<{ - [tokenAddress: string]: { - /** Defined as float, eg: 0.01 is 1% */ - apr: number; - isIbYield: boolean - group?: string; - } - }>; + group: string | undefined; + getAprs(): Promise<{ [tokenAddress: string]: { apr: number; isIbYield: boolean } }>; } export type TokenApr = { apr: number; address: string; - isIbYield: boolean; group?: string; + isIbYield: boolean; }; diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/aave-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/aave-apr-handler.ts index 5312b1985..f2b72156b 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/aave-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/aave-apr-handler.ts @@ -14,7 +14,8 @@ export class AaveAprHandler implements AprHandler { }; }; subgraphUrl: string; - group = 'AAVE'; + + readonly group = 'AAVE'; readonly query = `query getReserves($aTokens: [String!], $underlyingAssets: [Bytes!]) { reserves( @@ -80,11 +81,7 @@ export class AaveAprHandler implements AprHandler { .map(({ wrappedTokens, underlyingAssetAddress, isIbYield }) => { const apr = aprsByUnderlyingAddress[underlyingAssetAddress]; return Object.values(wrappedTokens).map((wrappedTokenAddress) => ({ - [wrappedTokenAddress]: { - apr, - isIbYield: isIbYield ?? false, - group: this.group, - }, + [wrappedTokenAddress]: { apr, isIbYield: isIbYield ?? false }, })); }) .flat() diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/ankr-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/ankr-apr-handler.ts index 86c4e446d..2f89875ed 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/ankr-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/ankr-apr-handler.ts @@ -12,13 +12,14 @@ export class AnkrAprHandler implements AprHandler { }; }; url: string; + readonly group = undefined; - constructor(config: AnkrAprConfig) { - this.tokens = config.tokens; - this.url = config.sourceUrl; + constructor(aprHandlerConfig: AnkrAprConfig) { + this.tokens = aprHandlerConfig.tokens; + this.url = aprHandlerConfig.sourceUrl; } - async getAprs() { + async getAprs(): Promise<{ [tokenAddress: string]: { apr: number; isIbYield: boolean } }> { try { const { data } = await axios.get(this.url); const services = (data as { services: { serviceName: string; apy: string }[] }).services; @@ -28,10 +29,7 @@ export class AnkrAprHandler implements AprHandler { if (!service) { return [address, 0]; } - return [address, { - apr: parseFloat(service.apy) / 1e2, - isIbYield: isIbYield ?? false, - }]; + return [address, { apr: parseFloat(service.apy) / 1e2, isIbYield: isIbYield ?? false }]; }), ); return aprs; diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/beefy-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/beefy-apr-handler.ts index 98e44bea3..1a6e50fef 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/beefy-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/beefy-apr-handler.ts @@ -12,27 +12,20 @@ export class BeefyAprHandler implements AprHandler { }; }; sourceUrl: string; - group = 'BEEFY'; + group: string | undefined = 'BEEFY'; - constructor(config: BeefyAprConfig) { - this.tokens = config.tokens; - this.sourceUrl = config.sourceUrl; + constructor(aprConfig: BeefyAprConfig) { + this.tokens = aprConfig.tokens; + this.sourceUrl = aprConfig.sourceUrl; } - async getAprs() { + async getAprs(): Promise<{ [p: string]: { apr: number; isIbYield: boolean } }> { try { const { data: aprData } = await axios.get(this.sourceUrl); - const aprs = Object.values(this.tokens).map(({ address, vaultId, isIbYield }) => { - const apr = aprData[vaultId]?.vaultApr ?? 0; - return { - [address]: { - apr, - isIbYield: isIbYield ?? false, - group: this.group - } - }; - }); - + const aprs: { [tokenAddress: string]: { apr: number; isIbYield: boolean } } = {}; + for (const { address, vaultId, isIbYield } of Object.values(this.tokens)) { + aprs[address] = { apr: aprData[vaultId].vaultApr, isIbYield: isIbYield ?? false }; + } return aprs; } catch (error) { console.error(`Beefy IB APR hanlder failed: `, error); diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/bloom-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/bloom-apr-handler.ts index 3f7e352ed..fed2cc55c 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/bloom-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/bloom-apr-handler.ts @@ -5,16 +5,16 @@ import { abi as bloomBpsFeed } from './abis/bloom-bps-feed'; import * as Sentry from '@sentry/node'; export class BloomAprHandler implements AprHandler { - group = "BLOOM"; + group: string | undefined; tokens: BloomAprConfig['tokens']; - constructor(config: BloomAprConfig) { - this.tokens = config.tokens; + constructor(aprConfig: BloomAprConfig) { + this.tokens = aprConfig.tokens; } - async getAprs() { - const aprs: { [p: string]: { apr: number; isIbYield: boolean, group?: string } } = {}; + async getAprs(): Promise<{ [p: string]: { apr: number; isIbYield: boolean } }> { + const aprs: { [p: string]: { apr: number; isIbYield: boolean } } = {}; for (const { address, feedAddress, isIbYield } of Object.values(this.tokens)) { try { const feedContract = getContractAt(feedAddress, bloomBpsFeed); @@ -23,11 +23,7 @@ export class BloomAprHandler implements AprHandler { continue; } const tokenApr = (Number(currentRate) - 10000) / 10000; - aprs[address] = { - apr: tokenApr, - isIbYield: isIbYield ?? false, - group: this.group - }; + aprs[address] = { apr: tokenApr, isIbYield: isIbYield ?? false }; } catch (error) { console.error(`Bloom APR Failed for token ${address}: `, error); Sentry.captureException(`Bloom APR Failed for token ${address}: ${error}`); diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/default-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/default-apr-handler.ts index 3e393f780..e48dc0b4e 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/default-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/default-apr-handler.ts @@ -8,8 +8,8 @@ export class DefaultAprHandler implements AprHandler { url: string; path: string; scale: number; - group?: string; - isIbYield?: boolean; + group: string | undefined = undefined; + isIbYield: boolean | undefined; constructor(aprHandlerConfig: { sourceUrl: string; @@ -33,13 +33,7 @@ export class DefaultAprHandler implements AprHandler { const value = this.path === '' ? data : this.getValueFromPath(data, this.path); const scaledValue = parseFloat(value) / this.scale; - return { - [this.tokenAddress]: { - apr: scaledValue, - isIbYield: this.isIbYield ?? false, - group: this.group - } - }; + return { [this.tokenAddress]: { apr: scaledValue, isIbYield: this.isIbYield ?? false } }; } catch (error) { console.error(`Failed to fetch APRs in url ${this.url}:`, error); Sentry.captureException(`Failed to fetch default IB APRs in url ${this.url}: ${error}`); diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/euler-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/euler-apr-handler.ts index 960954f78..f6edc5479 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/euler-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/euler-apr-handler.ts @@ -60,7 +60,6 @@ export class EulerAprHandler implements AprHandler { Object.values(this.tokens).find( ({ address }) => address.toLowerCase() === eTokenAddress.toLowerCase(), )?.isIbYield ?? false, - group: this.group, }, ]); diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/gearbox-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/gearbox-apr-handler.ts index 490d6f441..96e77624d 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/gearbox-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/gearbox-apr-handler.ts @@ -31,11 +31,7 @@ export class GearboxAprHandler implements AprHandler { ); return [ dieselToken, - { - apr: Number(depositAPY_RAY.slice(0, 27)) / 1e27, - isIbYield: tokenObj?.isIbYield ?? false, - group: this.group, - }, + { apr: Number(depositAPY_RAY.slice(0, 27)) / 1e27, isIbYield: tokenObj?.isIbYield ?? false }, ]; }); return Object.fromEntries(aprEntries); diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/idle-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/idle-apr-handler.ts index 24857b410..3782bf6e4 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/idle-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/idle-apr-handler.ts @@ -32,11 +32,7 @@ export class IdleAprHandler implements AprHandler { }); const [json] = data as { idleRate: string }[]; const value = Number(json.idleRate) / 1e20; - return [wrapped4626Address, { - apr: value, - isIbYield: isIbYield ?? false, - group: this.group, - }]; + return [wrapped4626Address, { apr: value, isIbYield: isIbYield ?? false }]; }); const res = Array(Object.keys(this.tokens).length); for (const [index, aprPromise] of aprPromises.entries()) { diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/index.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/index.ts deleted file mode 100644 index 94a5dff90..000000000 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export * from './aave-apr-handler'; -export * from './ankr-apr-handler'; -export * from './default-apr-handler'; -export * from './euler-apr-handler'; -export * from './gearbox-apr-handler'; -export * from './idle-apr-handler'; -export * from './ovix-apr-handler'; -export * from './tessera-apr-handler'; -export * from './tetu-apr-handler'; -export * from './tranchess-apr-handler'; -export * from './yearn-apr-handler'; -export * from './reaper-crypt-apr-handler'; -export * from './beefy-apr-handler'; -export * from './maker-apr-handler'; -export * as MakerGnosis from './maker-gnosis-apr-handler'; -export * from './bloom-apr-handler'; diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/maker-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/maker-apr-handler.ts index 0b47bf9be..20220f187 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/maker-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/maker-apr-handler.ts @@ -5,7 +5,7 @@ import { abi as makerPotAbi } from './abis/maker-pot'; import * as Sentry from '@sentry/node'; export class MakerAprHandler implements AprHandler { - group = 'MAKER'; + group: string | undefined; tokens: { [tokenName: string]: { address: string; @@ -18,8 +18,8 @@ export class MakerAprHandler implements AprHandler { this.tokens = aprConfig.tokens; } - async getAprs() { - const aprs: { [p: string]: { apr: number; isIbYield: boolean, group: string } } = {}; + async getAprs(): Promise<{ [p: string]: { apr: number; isIbYield: boolean } }> { + const aprs: { [p: string]: { apr: number; isIbYield: boolean } } = {}; for (const { address, potAddress, isIbYield } of Object.values(this.tokens)) { try { const potContract = getContractAt(potAddress, makerPotAbi); @@ -28,11 +28,7 @@ export class MakerAprHandler implements AprHandler { continue; } const tokenApr = (Number(dsr) * 10 ** -27 - 1) * 365 * 24 * 60 * 60; - aprs[address] = { - apr: tokenApr, - isIbYield: isIbYield ?? false, - group: this.group - }; + aprs[address] = { apr: tokenApr, isIbYield: isIbYield ?? false }; } catch (error) { console.error(`Maker APR Failed for token ${address}: `, error); Sentry.captureException(`Maker APR Failed for token ${address}: ${error}`); diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/maker-gnosis-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/maker-gnosis-apr-handler.ts deleted file mode 100644 index a89220193..000000000 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/maker-gnosis-apr-handler.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { AprHandler } from '../ib-linear-apr-handlers'; -import { getContractAt } from '../../../../../web3/contract'; -import { Chain } from '@prisma/client'; - -const helperAbi = ['function vaultAPY() view returns (uint256)']; - -/** Sets the config data used internally */ -const config = { - "GNOSIS": { - sdaiAddress: '0xaf204776c7245bf4147c2612bf6e5972ee483701', - helperAddress: '0xd499b51fcfc66bd31248ef4b28d656d67e591a94', - } -} - -/** Makes handler callable by chain */ -export const chains = Object.keys(config) as Chain[]; - -export class Handler implements AprHandler { - async getAprs(chain: Chain) { - if (chain !== 'GNOSIS') { - throw `Handler supports GNOSIS only, but called for ${chain}` - } - - const helper = getContractAt(config[chain].helperAddress, helperAbi); - const vaultAPY = await helper.vaultAPY(); - const apr = Number(vaultAPY) * (10 ** -18); - - return { - [config[chain].sdaiAddress]: { - apr, - isIbYield: true, - group: 'MAKER' - } - } - } -} diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/ovix-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/ovix-apr-handler.ts index a8206b52d..3f3d0a7e1 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/ovix-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/ovix-apr-handler.ts @@ -30,7 +30,6 @@ export class OvixAprHandler implements AprHandler { { apr: Math.pow(1 + (borrowRate as BigNumber).toNumber() / 1e18, 365 * 24 * 60 * 60) - 1, isIbYield: isIbYield ?? false, - group: this.group, }, ]; }); diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/reaper-crypt-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/reaper-crypt-apr-handler.ts index 6acf75005..a9d0196d7 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/reaper-crypt-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/reaper-crypt-apr-handler.ts @@ -45,7 +45,7 @@ export class ReaperCryptAprHandler implements AprHandler { this.averageAPRAcrossLastNHarvests = aprConfig.onchainSource?.averageAPRAcrossLastNHarvests; } - async getAprs() { + async getAprs(): Promise<{ [p: string]: { apr: number; isIbYield: boolean } }> { let multiStrategyAprs = {}; let singleStrategyAprs = {}; this.wstETHBaseApr = await this.getWstEthBaseApr(); @@ -122,11 +122,7 @@ export class ReaperCryptAprHandler implements AprHandler { } return { ...acc, - [id]: { - apr: tokenApr, - isIbYield: token.isIbYield ?? false, - group: this.group, - }, + [id]: { apr: tokenApr, isIbYield: token.isIbYield ?? false }, }; }, {}); } catch (error) { diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tessera-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tessera-apr-handler.ts index f1d67f18f..ccdce1f15 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tessera-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tessera-apr-handler.ts @@ -31,11 +31,7 @@ export class TesseraAprHandler implements AprHandler { const staked = BigInt(pool.stakedAmount); const reward = BigInt(pool.currentTimeRange.rewardsPerHour) * BigInt(24 * 365); const apr = Number(reward.toString()) / Number(staked.toString()); - aprEntries.push([tokenAddress, { - apr, - isIbYield: isIbYield ?? false, - group: this.group - }]); + aprEntries.push([tokenAddress, { apr, isIbYield: isIbYield ?? false }]); } catch (error) { console.error('Failed to fetch Tessera Ape Coin APR:', error); Sentry.captureException(`Tessera IB APR handler failed: ${error}`); diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tetu-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tetu-apr-handler.ts index d42480aac..2db4746f9 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tetu-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tetu-apr-handler.ts @@ -35,7 +35,6 @@ export class TetuAprHandler implements AprHandler { apr: t.apr / 100, isIbYield: Object.values(this.tokens).find(({ address }) => address === t.vault)?.isIbYield ?? false, - group: this.group, }, ]); return Object.fromEntries(aprs); diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tranchess-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tranchess-apr-handler.ts index aec8047ee..37bea641d 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tranchess-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/tranchess-apr-handler.ts @@ -30,11 +30,7 @@ export class TranchessAprHandler implements AprHandler { ).filter(({ name }) => name === underlyingAssetName)[0].weeklyAveragePnlPercentage; return [ address, - { - apr: (365 * Number(weeklyAveragePnlPercentage)) / 1e18, - isIbYield: isIbYield ?? false, - group: this.group - }, + { apr: (365 * Number(weeklyAveragePnlPercentage)) / 1e18, isIbYield: isIbYield ?? false }, ]; }); // The key weeklyAveragePnlPercentage is the daily yield of qETH in 18 decimals, timing 365 should give you the APR. diff --git a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/yearn-apr-handler.ts b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/yearn-apr-handler.ts index ac519fad0..1451b2f3d 100644 --- a/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/yearn-apr-handler.ts +++ b/modules/pool/lib/apr-data-sources/ib-linear-apr-handlers/sources/yearn-apr-handler.ts @@ -12,16 +12,12 @@ export class YearnAprHandler implements AprHandler { this.sourceUrl = aprHandlerConfig.sourceUrl; this.isIbYield = aprHandlerConfig.isIbYield; } - async getAprs() { + async getAprs(): Promise<{ [p: string]: { apr: number; isIbYield: boolean } }> { try { const { data } = await axios.get(this.sourceUrl); const aprs = Object.fromEntries( data.map(({ address, apy: { net_apy } }) => { - return [address.toLowerCase(), { - apr: net_apy, - isIbYield: this.isIbYield ?? false, - group: this.group - }]; + return [address.toLowerCase(), { apr: net_apy, isIbYield: this.isIbYield ?? false }]; }), ); return aprs; diff --git a/modules/pool/lib/apr-data-sources/ib-tokens-apr.service.ts b/modules/pool/lib/apr-data-sources/ib-tokens-apr.service.ts index d689eecd7..dc3dda53c 100644 --- a/modules/pool/lib/apr-data-sources/ib-tokens-apr.service.ts +++ b/modules/pool/lib/apr-data-sources/ib-tokens-apr.service.ts @@ -1,8 +1,9 @@ import { PoolAprService } from '../../pool-types'; import { PrismaPoolWithTokens } from '../../../../prisma/prisma-types'; import { prisma } from '../../../../prisma/prisma-client'; +import { networkContext } from '../../../network/network-context.service'; import { prismaBulkExecuteOperations } from '../../../../prisma/prisma-util'; -import { Chain, PrismaPoolAprItemGroup, PrismaPoolAprType, PrismaPoolLinearData } from '@prisma/client'; +import { PrismaPoolAprItemGroup, PrismaPoolAprType, PrismaPoolLinearData } from '@prisma/client'; import { IbLinearAprHandlers as IbTokensAprHandlers, TokenApr } from './ib-linear-apr-handlers/ib-linear-apr-handlers'; import { tokenService } from '../../../token/token.service'; import { collectsYieldFee } from '../pool-utils'; @@ -11,13 +12,8 @@ import { IbAprConfig } from '../../../network/apr-config-types'; export class IbTokensAprService implements PoolAprService { private ibTokensAprHandlers: IbTokensAprHandlers; - constructor( - aprConfig: IbAprConfig, - private chain: Chain, - private defaultYieldFee: number, - private defaultSwapFee: number - ) { - this.ibTokensAprHandlers = new IbTokensAprHandlers(aprConfig, chain); + constructor(aprConfig: IbAprConfig) { + this.ibTokensAprHandlers = new IbTokensAprHandlers(aprConfig); } getAprServiceName(): string { @@ -37,7 +33,7 @@ export class IbTokensAprService implements PoolAprService { }); const poolsWithIbTokensExpanded = await prisma.prismaPool.findMany({ - where: { chain: this.chain, id: { in: poolsWithIbTokens.map((pool) => pool.id) } }, + where: { chain: networkContext.chain, id: { in: poolsWithIbTokens.map((pool) => pool.id) } }, include: { dynamicData: true, tokens: { @@ -80,10 +76,10 @@ export class IbTokensAprService implements PoolAprService { if (collectsYieldFee(pool) && token.dynamicData && token.dynamicData.priceRate !== '1.0') { const protocolYieldFeePercentage = pool.dynamicData?.protocolYieldFee ? parseFloat(pool.dynamicData.protocolYieldFee) - : this.defaultYieldFee; + : networkContext.data.balancer.yieldProtocolFeePercentage; aprInPoolAfterFees = pool.type === 'META_STABLE' - ? aprInPoolAfterFees * (1 - this.defaultSwapFee) + ? aprInPoolAfterFees * (1 - networkContext.data.balancer.swapProtocolFeePercentage) : aprInPoolAfterFees * (1 - protocolYieldFeePercentage); } @@ -94,7 +90,7 @@ export class IbTokensAprService implements PoolAprService { const data = { id: itemId, - chain: this.chain, + chain: networkContext.chain, poolId: pool.id, title: `${token.token.symbol} APR`, apr: aprInPoolAfterFees, @@ -104,7 +100,7 @@ export class IbTokensAprService implements PoolAprService { operations.push( prisma.prismaPoolAprItem.upsert({ - where: { id_chain: { id: itemId, chain: this.chain } }, + where: { id_chain: { id: itemId, chain: networkContext.chain } }, create: data, update: data, }), diff --git a/modules/pool/lib/apr-data-sources/phantom-stable-apr.service.ts b/modules/pool/lib/apr-data-sources/phantom-stable-apr.service.ts index fff2dc917..06f738c6b 100644 --- a/modules/pool/lib/apr-data-sources/phantom-stable-apr.service.ts +++ b/modules/pool/lib/apr-data-sources/phantom-stable-apr.service.ts @@ -2,11 +2,9 @@ import { PoolAprService } from '../../pool-types'; import { PrismaPoolWithTokens, prismaPoolWithExpandedNesting } from '../../../../prisma/prisma-types'; import { prisma } from '../../../../prisma/prisma-client'; import { collectsYieldFee } from '../pool-utils'; -import { Chain } from '@prisma/client'; +import { networkContext } from '../../../network/network-context.service'; export class PhantomStableAprService implements PoolAprService { - constructor(private chain: Chain, private defaultProtocolFee: number) {} - public getAprServiceName(): string { return 'PhantomStableAprService'; } @@ -16,17 +14,17 @@ export class PhantomStableAprService implements PoolAprService { const phantomStablePoolsExpanded = await prisma.prismaPool.findMany({ ...prismaPoolWithExpandedNesting, - where: { chain: this.chain, id: { in: phantomStablePools.map((pool) => pool.id) } }, + where: { chain: networkContext.chain, id: { in: phantomStablePools.map((pool) => pool.id) } }, }); for (const pool of phantomStablePoolsExpanded) { const protocolYieldFeePercentage = pool.dynamicData?.protocolYieldFee ? parseFloat(pool.dynamicData.protocolYieldFee) - : this.defaultProtocolFee; + : networkContext.data.balancer.yieldProtocolFeePercentage; const linearPoolTokens = pool.tokens.filter((token) => token.nestedPool?.type === 'LINEAR'); const linearPoolIds = linearPoolTokens.map((token) => token.nestedPool?.id || ''); const aprItems = await prisma.prismaPoolAprItem.findMany({ - where: { poolId: { in: linearPoolIds }, type: 'LINEAR_BOOSTED', chain: this.chain }, + where: { poolId: { in: linearPoolIds }, type: 'LINEAR_BOOSTED', chain: networkContext.chain }, }); for (const token of linearPoolTokens) { @@ -38,10 +36,10 @@ export class PhantomStableAprService implements PoolAprService { const userApr = collectsYieldFee(pool) ? apr * (1 - protocolYieldFeePercentage) : apr; await prisma.prismaPoolAprItem.upsert({ - where: { id_chain: { id: itemId, chain: this.chain } }, + where: { id_chain: { id: itemId, chain: networkContext.chain } }, create: { id: itemId, - chain: this.chain, + chain: networkContext.chain, poolId: pool.id, apr: userApr, title: aprItem.title, diff --git a/tsconfig.json b/tsconfig.json index c4157392a..d95f5a8e4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,9 +10,5 @@ "resolveJsonModule": true, "outDir": "./dist", "skipLibCheck": true - }, - "exclude": [ - "node_modules", - "debug" - ] + } }