From 4980fb9f226633edc71830f3c3a38bab40d2cef4 Mon Sep 17 00:00:00 2001 From: franz Date: Wed, 15 Jan 2025 16:55:02 +0100 Subject: [PATCH] fix pricing --- .changeset/plenty-roses-suffer.md | 5 +++++ modules/beets/beets.service.ts | 7 ------- modules/datastudio/datastudio.service.ts | 11 ++++++++--- .../get-liquidity-and-shares-at-timestamp.ts | 1 + modules/sources/subgraphs/balancer-v3-vault/index.ts | 1 + modules/subgraphs/balancer-subgraph/index.ts | 1 + 6 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 .changeset/plenty-roses-suffer.md diff --git a/.changeset/plenty-roses-suffer.md b/.changeset/plenty-roses-suffer.md new file mode 100644 index 000000000..2bee17da0 --- /dev/null +++ b/.changeset/plenty-roses-suffer.md @@ -0,0 +1,5 @@ +--- +'backend': patch +--- + +fix liquidity 24hrs ago, fix price for data studio for beets diff --git a/modules/beets/beets.service.ts b/modules/beets/beets.service.ts index cb210fa42..170957bb3 100644 --- a/modules/beets/beets.service.ts +++ b/modules/beets/beets.service.ts @@ -1,6 +1,4 @@ import { FbeetsService } from './lib/fbeets.service'; -import { tokenService } from '../token/token.service'; -import { networkContext } from '../network/network-context.service'; export class BeetsService { constructor(private readonly fBeetsService: FbeetsService) {} @@ -12,11 +10,6 @@ export class BeetsService { public async syncFbeetsRatio(): Promise { return this.fBeetsService.syncRatio(); } - - public async getBeetsPrice(): Promise { - const tokenPrices = await tokenService.getTokenPrices('FANTOM'); - return tokenService.getPriceForToken(tokenPrices, networkContext.data.beets!.address, 'FANTOM').toString(); - } } export const beetsService = new BeetsService(new FbeetsService()); diff --git a/modules/datastudio/datastudio.service.ts b/modules/datastudio/datastudio.service.ts index d14cc6c19..1ead9ac76 100644 --- a/modules/datastudio/datastudio.service.ts +++ b/modules/datastudio/datastudio.service.ts @@ -13,6 +13,7 @@ import { isComposableStablePool, isWeightedPoolV2 } from '../pool/lib/pool-utils import { networkContext } from '../network/network-context.service'; import { DeploymentEnv } from '../network/network-config-types'; import { Chain } from '@prisma/client'; +import { AllNetworkConfigsKeyedOnChain } from '../network/network-config'; export class DatastudioService { constructor(private readonly secretsManager: SecretsManager, private readonly jwtClientHelper: GoogleJwtClient) {} @@ -240,10 +241,14 @@ export class DatastudioService { for (const stake of pool.staking) { const blocksPerDay = await blocksSubgraphService.getBlocksPerDay(); const tokenPrices = await tokenService.getTokenPrices(stake.chain); - const beetsPrice = stake.farm || stake.reliquary ? await beetsService.getBeetsPrice() : '0'; + const beetsPrice = tokenService.getPriceForToken( + tokenPrices, + AllNetworkConfigsKeyedOnChain[chain].data.beets!.address, + chain, + ); if (stake.farm) { const beetsPerDay = parseFloat(stake.farm.beetsPerBlock) * blocksPerDay; - const beetsValuePerDay = parseFloat(beetsPrice) * beetsPerDay; + const beetsValuePerDay = beetsPrice * beetsPerDay; if (beetsPerDay > 0) { allEmissionDataRows.push([ endOfYesterday.format('DD MMM YYYY'), @@ -287,7 +292,7 @@ export class DatastudioService { } if (stake.reliquary) { const beetsPerDay = parseFloat(stake.reliquary.beetsPerSecond) * secondsPerDay; - const beetsValuePerDay = parseFloat(beetsPrice) * beetsPerDay; + const beetsValuePerDay = beetsPrice * beetsPerDay; if (beetsPerDay > 0) { allEmissionDataRows.push([ endOfYesterday.format('DD MMM YYYY'), diff --git a/modules/sources/enrichers/get-liquidity-and-shares-at-timestamp.ts b/modules/sources/enrichers/get-liquidity-and-shares-at-timestamp.ts index b7a70f347..2c7077b28 100644 --- a/modules/sources/enrichers/get-liquidity-and-shares-at-timestamp.ts +++ b/modules/sources/enrichers/get-liquidity-and-shares-at-timestamp.ts @@ -46,6 +46,7 @@ export const getLiquidityAndSharesAtTimestamp = async ( in: tokenAddresses, }, timestamp: roundedTimestamp, + chain: vaultClient.chain, }, }); diff --git a/modules/sources/subgraphs/balancer-v3-vault/index.ts b/modules/sources/subgraphs/balancer-v3-vault/index.ts index c0ea5420e..af0c24bd0 100644 --- a/modules/sources/subgraphs/balancer-v3-vault/index.ts +++ b/modules/sources/subgraphs/balancer-v3-vault/index.ts @@ -23,6 +23,7 @@ export function getVaultSubgraphClient(url: string, chain: Chain) { return { ...sdk, + chain: chain, async getMetadata() { return sdk.Metadata().then((response) => { if (response && response.meta) { diff --git a/modules/subgraphs/balancer-subgraph/index.ts b/modules/subgraphs/balancer-subgraph/index.ts index 66f4d556a..7f7ac4c7f 100644 --- a/modules/subgraphs/balancer-subgraph/index.ts +++ b/modules/subgraphs/balancer-subgraph/index.ts @@ -19,6 +19,7 @@ export function getV2SubgraphClient(url: string, chain: Chain) { return { ...sdk, + chain: chain, legacyService, getMetadata: legacyService.getMetadata.bind(legacyService), getAllPoolSnapshots: legacyService.getAllPoolSnapshots.bind(legacyService),