@merkl/api 0.20.14 → 0.20.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,6 +39,7 @@ async function computeEventBasedPoolTVLFromMostRecentStateSave(chainId, campaign
39
39
  // Bucket service
40
40
  let tvl = 0;
41
41
  try {
42
+ console.log("BUCKET NAME:", bucketName);
42
43
  const bucket = new BucketService(bucketName, "merkl-production");
43
44
  const storedStates = JSON.parse(await bucket.pull(fileName));
44
45
  for (const [_, { value, params: _params }] of Object.entries(storedStates)) {
@@ -43,6 +43,7 @@ async function computeUniV4PoolTVLFromMostRecentStateSave(chainId, poolID, price
43
43
  let amount0 = 0;
44
44
  let amount1 = 0;
45
45
  try {
46
+ console.log("BUCKET NAME:", bucketName);
46
47
  const bucket = new BucketService(bucketName, "merkl-production");
47
48
  const storedStates = JSON.parse(await bucket.pull(fileName));
48
49
  for (const [_, { value, params: _params }] of Object.entries(storedStates)) {
@@ -1,3 +1,4 @@
1
+ import type { DynamicDataBuilder } from "@/engine/dynamicData/interface";
1
2
  import { Campaign, type CampaignParameters, type ChainId } from "@sdk";
2
3
  import { Campaign as CampaignEnum } from "@sdk";
3
4
  export declare class DynamicDataService {
@@ -9,6 +10,7 @@ export declare class DynamicDataService {
9
10
  priceTargetToken: number;
10
11
  type: string;
11
12
  }>;
13
+ static getDynamicData(campaigns: CampaignParameters<CampaignEnum>[], type: Campaign, chainId: number): Promise<DynamicDataBuilder<typeof type>[]>;
12
14
  static updateForCampaignType(campaigns: CampaignParameters<CampaignEnum>[], type: Campaign, dryRun?: boolean): Promise<unknown[]>;
13
15
  static updateForCampaigns(campaigns: CampaignParameters<CampaignEnum>[], dryRun?: boolean): Promise<unknown[]>;
14
16
  }
@@ -52,10 +52,37 @@ export class DynamicDataService {
52
52
  type: result[0]?.type ?? "defaultType",
53
53
  };
54
54
  }
55
+ static async getDynamicData(campaigns, type, chainId) {
56
+ try {
57
+ const dynamicData = await dynamicDataBuilderFactory(typeof type === "number" ? type : Campaign[type]).build(chainId, campaigns);
58
+ return dynamicData;
59
+ }
60
+ catch (_err) {
61
+ console.log("Failed to get dynamic data");
62
+ const firstHalf = campaigns.splice(0, Math.ceil(campaigns.length / 2));
63
+ console.log("firstHalf", firstHalf);
64
+ const secondHalf = campaigns;
65
+ if (firstHalf.length > 1 || secondHalf.length > 1)
66
+ return [
67
+ ...(await DynamicDataService.getDynamicData(firstHalf, type, chainId)),
68
+ ...(await DynamicDataService.getDynamicData(secondHalf, type, chainId)),
69
+ ];
70
+ if (firstHalf.length <= 1)
71
+ console.error(`Failed to get dynamic data for ${firstHalf[0]}`);
72
+ if (secondHalf.length <= 1)
73
+ console.error(`Failed to get dynamic data for ${secondHalf[0]}`);
74
+ return [];
75
+ }
76
+ }
55
77
  static async updateForCampaignType(campaigns, type, dryRun = false) {
56
78
  const chainId = campaigns[0].computeChainId;
57
79
  const dynamicDataArray = [];
58
80
  const dynamicData = await dynamicDataBuilderFactory(typeof type === "number" ? type : Campaign[type]).build(chainId, campaigns);
81
+ // const dynamicData = await DynamicDataService.getDynamicData(
82
+ // campaigns,
83
+ // typeof type === "number" ? type : Campaign[type as keyof typeof Campaign],
84
+ // chainId
85
+ // );
59
86
  const oppMap = {};
60
87
  for (const data of dynamicData) {
61
88
  if (!!data) {