@merkl/api 0.20.105 → 0.20.106

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.
@@ -3,19 +3,16 @@ import { computeSubTypes } from "./computeSubTypes";
3
3
  import { erc20SubTypeTVLBuilderFactory } from "./factory";
4
4
  export class Erc20CampaignTVLBuilder {
5
5
  async build(chainId, campaigns) {
6
- console.log("START");
7
6
  const subTypes = await computeSubTypes(chainId, campaigns);
8
- console.log(subTypes);
9
- const dynamicDataList = await new Erc20DynamicData().build(chainId, campaigns);
10
- console.log(dynamicDataList.map(d => d.typeInfo.type));
11
7
  let tvls = [];
12
- for (const subtype of new Set(subTypes)) {
13
- const builder = erc20SubTypeTVLBuilderFactory(subtype);
8
+ const promises = [];
9
+ const processSubtype = async (subType) => {
10
+ const builder = erc20SubTypeTVLBuilderFactory(subType);
14
11
  if (!!builder) {
15
- tvls = tvls.concat(await builder.build(chainId, campaigns.filter((_campaign, index) => subTypes[index] === subtype)));
12
+ tvls = tvls.concat(await builder.build(chainId, campaigns.filter((_campaign, index) => subTypes[index] === subType)));
16
13
  }
17
14
  else {
18
- console.log(`building TVLs for subtype ${subtype}`);
15
+ console.log(`building TVLs for subtype ${subType}`);
19
16
  // @deprecated In case we don't have the new builder, use the old erc20 dynamic data
20
17
  const dynamicDataList = await new Erc20DynamicData().build(chainId, campaigns);
21
18
  for (const [index, dynamicData] of dynamicDataList.entries()) {
@@ -26,7 +23,12 @@ export class Erc20CampaignTVLBuilder {
26
23
  });
27
24
  }
28
25
  }
26
+ return;
27
+ };
28
+ for (const subType of new Set(subTypes)) {
29
+ promises.push(processSubtype(subType));
29
30
  }
31
+ await Promise.allSettled(promises);
30
32
  return tvls;
31
33
  }
32
34
  }
@@ -53,9 +53,11 @@ const main = async () => {
53
53
  await OpportunityService.updateMany(liveOpportunityIds, { status: "LIVE" });
54
54
  // 5. Update records for all live campaigns
55
55
  const liveCampaigns = (await CampaignService.findMany({ chainId, status: "LIVE", test: true, withOpportunity: true, items: 10_000 })).map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], campaign, campaign.Opportunity.identifier));
56
+ const promises = [];
56
57
  for (const type of new Set(liveCampaigns.map(c => c.campaignType))) {
57
- await DynamicDataService.update(chainId, type, liveCampaigns.filter(c => c.campaignType === type));
58
+ promises.push(DynamicDataService.update(chainId, type, liveCampaigns.filter(c => c.campaignType === type)));
58
59
  }
60
+ await Promise.allSettled(promises);
59
61
  };
60
62
  try {
61
63
  await main();