Skip to content

Commit

Permalink
fix pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
franzns committed Jan 15, 2025
1 parent 89ab674 commit 4980fb9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-roses-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

fix liquidity 24hrs ago, fix price for data studio for beets
7 changes: 0 additions & 7 deletions modules/beets/beets.service.ts
Original file line number Diff line number Diff line change
@@ -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) {}
Expand All @@ -12,11 +10,6 @@ export class BeetsService {
public async syncFbeetsRatio(): Promise<void> {
return this.fBeetsService.syncRatio();
}

public async getBeetsPrice(): Promise<string> {
const tokenPrices = await tokenService.getTokenPrices('FANTOM');
return tokenService.getPriceForToken(tokenPrices, networkContext.data.beets!.address, 'FANTOM').toString();
}
}

export const beetsService = new BeetsService(new FbeetsService());
11 changes: 8 additions & 3 deletions modules/datastudio/datastudio.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const getLiquidityAndSharesAtTimestamp = async (
in: tokenAddresses,
},
timestamp: roundedTimestamp,
chain: vaultClient.chain,
},
});

Expand Down
1 change: 1 addition & 0 deletions modules/sources/subgraphs/balancer-v3-vault/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions modules/subgraphs/balancer-subgraph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 4980fb9

Please sign in to comment.