Skip to content

Commit

Permalink
pass chain as param
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbronco committed Mar 1, 2024
1 parent a8bc572 commit c71fcef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
15 changes: 6 additions & 9 deletions modules/datastudio/datastudio.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { oneDayInSeconds, secondsPerDay } from '../common/time';
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';

export class DatastudioService {
constructor(private readonly secretsManager: SecretsManager, private readonly jwtClientHelper: GoogleJwtClient) {}

public async feedPoolData() {
public async feedPoolData(chain: Chain) {
const privateKey = await this.secretsManager.getSecret('backend-v3-datafeed-privatekey');
const jwtClient = await this.jwtClientHelper.getAuthorizedSheetsClient(privateKey);

Expand Down Expand Up @@ -89,7 +90,7 @@ export class DatastudioService {
dynamicData: {
totalLiquidity: { gte: 5000 },
},
chain: networkContext.chain,
chain: chain,
},
include: {
dynamicData: true,
Expand Down Expand Up @@ -265,11 +266,8 @@ export class DatastudioService {
}
const rewardsPerDay = parseFloat(rewarder.rewardPerSecond) * secondsPerDay;
const rewardsValuePerDay =
tokenService.getPriceForToken(
tokenPrices,
rewarder.tokenAddress,
networkContext.chain,
) * rewardsPerDay;
tokenService.getPriceForToken(tokenPrices, rewarder.tokenAddress, chain) *
rewardsPerDay;
if (rewardsPerDay > 0) {
allEmissionDataRows.push([
endOfYesterday.format('DD MMM YYYY'),
Expand Down Expand Up @@ -313,8 +311,7 @@ export class DatastudioService {
}
const rewardsPerDay = parseFloat(reward.rewardPerSecond) * secondsPerDay;
const rewardsValuePerDay =
tokenService.getPriceForToken(tokenPrices, reward.tokenAddress, networkContext.chain) *
rewardsPerDay;
tokenService.getPriceForToken(tokenPrices, reward.tokenAddress, chain) * rewardsPerDay;
if (rewardsPerDay > 0) {
allEmissionDataRows.push([
endOfYesterday.format('DD MMM YYYY'),
Expand Down
12 changes: 11 additions & 1 deletion worker/job-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { syncLatestFXPrices } from '../modules/token/latest-fx-price';
import { AllNetworkConfigs } from '../modules/network/network-config';
import { sftmxService } from '../modules/sftmx/sftmx.service';
import { JobsController } from '../modules/controllers/jobs-controller';
import { chainIdToChain } from '../modules/network/chain-id-to-chain';

const runningJobs: Set<string> = new Set();

Expand Down Expand Up @@ -282,7 +283,16 @@ export function configureWorkerRoutes(app: Express) {
);
break;
case 'feed-data-to-datastudio':
await runIfNotAlreadyRunning(job.name, chainId, () => datastudioService.feedPoolData(), res, next);
await runIfNotAlreadyRunning(
job.name,
chainId,
() => {
const chain = chainIdToChain[chainId];
return datastudioService.feedPoolData(chain);
},
res,
next,
);
break;
case 'sync-latest-reliquary-snapshots':
await runIfNotAlreadyRunning(
Expand Down

0 comments on commit c71fcef

Please sign in to comment.