@merkl/api 0.20.88 → 0.20.89

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.
Files changed (35) hide show
  1. package/dist/src/eden/index.d.ts +18 -12
  2. package/dist/src/engine/campaignTVL/factory.d.ts +3 -0
  3. package/dist/src/engine/campaignTVL/factory.js +9 -0
  4. package/dist/src/errors/InvalidParameter.error.d.ts +4 -0
  5. package/dist/src/errors/InvalidParameter.error.js +7 -0
  6. package/dist/src/index.d.ts +6 -4
  7. package/dist/src/jobs/dynamic-data.js +7 -1
  8. package/dist/src/jobs/update-dynamic-data.js +17 -21
  9. package/dist/src/modules/v4/apr/apr.service.d.ts +3 -0
  10. package/dist/src/modules/v4/apr/apr.service.js +3 -0
  11. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +1 -1
  12. package/dist/src/modules/v4/campaign/campaign.controller.js +1 -1
  13. package/dist/src/modules/v4/campaign/campaign.test.controller.d.ts +3 -3
  14. package/dist/src/modules/v4/campaign/campaign.test.controller.js +12 -8
  15. package/dist/src/modules/v4/dynamicData/dynamicData.service.d.ts +14 -5
  16. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +187 -83
  17. package/dist/src/modules/v4/reward/reward.service.d.ts +4 -1
  18. package/dist/src/modules/v4/reward/reward.service.js +7 -5
  19. package/dist/src/modules/v4/router.d.ts +6 -4
  20. package/dist/src/modules/v4/token/token.service.d.ts +1 -1
  21. package/dist/src/modules/v4/token/token.service.js +3 -9
  22. package/dist/src/modules/v4/tvl/tvl.service.d.ts +3 -0
  23. package/dist/src/modules/v4/tvl/tvl.service.js +3 -0
  24. package/dist/src/modules/v4/user/user.controller.d.ts +2 -0
  25. package/dist/src/modules/v4/user/user.controller.js +2 -2
  26. package/dist/src/modules/v4/user/user.model.d.ts +2 -0
  27. package/dist/src/modules/v4/user/user.model.js +2 -0
  28. package/dist/tsconfig.package.tsbuildinfo +1 -1
  29. package/package.json +1 -1
  30. package/dist/src/backgroundJobs/index.d.ts +0 -1
  31. package/dist/src/backgroundJobs/index.js +0 -55
  32. package/dist/src/backgroundJobs/jobs/health.d.ts +0 -41
  33. package/dist/src/backgroundJobs/jobs/health.js +0 -15
  34. package/dist/src/backgroundJobs/jobs/opportunityUpdater.d.ts +0 -39
  35. package/dist/src/backgroundJobs/jobs/opportunityUpdater.js +0 -22
@@ -1123,7 +1123,7 @@ declare const eden: {
1123
1123
  query?: Record<string, unknown> | undefined;
1124
1124
  fetch?: RequestInit | undefined;
1125
1125
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1126
- 200: unknown[];
1126
+ 200: unknown[] | undefined;
1127
1127
  }>>;
1128
1128
  };
1129
1129
  }) & {
@@ -1526,7 +1526,7 @@ declare const eden: {
1526
1526
  query?: Record<string, unknown> | undefined;
1527
1527
  fetch?: RequestInit | undefined;
1528
1528
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1529
- 200: unknown[];
1529
+ 200: unknown[] | undefined;
1530
1530
  }>>;
1531
1531
  };
1532
1532
  }) & {
@@ -1539,7 +1539,7 @@ declare const eden: {
1539
1539
  query?: Record<string, unknown> | undefined;
1540
1540
  fetch?: RequestInit | undefined;
1541
1541
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1542
- 200: unknown[];
1542
+ 200: unknown[] | undefined;
1543
1543
  }>>;
1544
1544
  };
1545
1545
  post: (body: {
@@ -1562,7 +1562,7 @@ declare const eden: {
1562
1562
  query?: Record<string, unknown> | undefined;
1563
1563
  fetch?: RequestInit | undefined;
1564
1564
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1565
- 200: unknown[];
1565
+ 200: unknown[] | undefined;
1566
1566
  }>>;
1567
1567
  };
1568
1568
  metadata: {
@@ -2741,6 +2741,7 @@ declare const eden: {
2741
2741
  test?: boolean | undefined;
2742
2742
  chainIds?: number[] | undefined;
2743
2743
  reloadChainId?: number | undefined;
2744
+ claimableOnly?: boolean | undefined;
2744
2745
  };
2745
2746
  fetch?: RequestInit | undefined;
2746
2747
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
@@ -2849,6 +2850,7 @@ declare const eden: {
2849
2850
  query: {
2850
2851
  test?: boolean | undefined;
2851
2852
  reloadChainId?: number | undefined;
2853
+ claimableOnly?: boolean | undefined;
2852
2854
  chainId: number[];
2853
2855
  };
2854
2856
  fetch?: RequestInit | undefined;
@@ -6063,7 +6065,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6063
6065
  authorization: string;
6064
6066
  };
6065
6067
  response: {
6066
- 200: unknown[];
6068
+ 200: unknown[] | undefined;
6067
6069
  };
6068
6070
  };
6069
6071
  };
@@ -6630,7 +6632,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6630
6632
  authorization: string;
6631
6633
  };
6632
6634
  response: {
6633
- 200: unknown[];
6635
+ 200: unknown[] | undefined;
6634
6636
  };
6635
6637
  };
6636
6638
  };
@@ -6648,7 +6650,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6648
6650
  authorization: string;
6649
6651
  };
6650
6652
  response: {
6651
- 200: unknown[];
6653
+ 200: unknown[] | undefined;
6652
6654
  };
6653
6655
  };
6654
6656
  };
@@ -6678,7 +6680,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6678
6680
  authorization: string;
6679
6681
  };
6680
6682
  response: {
6681
- 200: unknown[];
6683
+ 200: unknown[] | undefined;
6682
6684
  };
6683
6685
  };
6684
6686
  };
@@ -8190,6 +8192,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
8190
8192
  test?: boolean | undefined;
8191
8193
  chainIds?: number[] | undefined;
8192
8194
  reloadChainId?: number | undefined;
8195
+ claimableOnly?: boolean | undefined;
8193
8196
  };
8194
8197
  headers: unknown;
8195
8198
  response: {
@@ -8309,6 +8312,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
8309
8312
  query: {
8310
8313
  test?: boolean | undefined;
8311
8314
  reloadChainId?: number | undefined;
8315
+ claimableOnly?: boolean | undefined;
8312
8316
  chainId: number[];
8313
8317
  };
8314
8318
  headers: unknown;
@@ -11800,7 +11804,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
11800
11804
  query?: Record<string, unknown> | undefined;
11801
11805
  fetch?: RequestInit | undefined;
11802
11806
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
11803
- 200: unknown[];
11807
+ 200: unknown[] | undefined;
11804
11808
  }>>;
11805
11809
  };
11806
11810
  }) & {
@@ -12203,7 +12207,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
12203
12207
  query?: Record<string, unknown> | undefined;
12204
12208
  fetch?: RequestInit | undefined;
12205
12209
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
12206
- 200: unknown[];
12210
+ 200: unknown[] | undefined;
12207
12211
  }>>;
12208
12212
  };
12209
12213
  }) & {
@@ -12216,7 +12220,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
12216
12220
  query?: Record<string, unknown> | undefined;
12217
12221
  fetch?: RequestInit | undefined;
12218
12222
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
12219
- 200: unknown[];
12223
+ 200: unknown[] | undefined;
12220
12224
  }>>;
12221
12225
  };
12222
12226
  post: (body: {
@@ -12239,7 +12243,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
12239
12243
  query?: Record<string, unknown> | undefined;
12240
12244
  fetch?: RequestInit | undefined;
12241
12245
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
12242
- 200: unknown[];
12246
+ 200: unknown[] | undefined;
12243
12247
  }>>;
12244
12248
  };
12245
12249
  metadata: {
@@ -13418,6 +13422,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
13418
13422
  test?: boolean | undefined;
13419
13423
  chainIds?: number[] | undefined;
13420
13424
  reloadChainId?: number | undefined;
13425
+ claimableOnly?: boolean | undefined;
13421
13426
  };
13422
13427
  fetch?: RequestInit | undefined;
13423
13428
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
@@ -13526,6 +13531,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
13526
13531
  query: {
13527
13532
  test?: boolean | undefined;
13528
13533
  reloadChainId?: number | undefined;
13534
+ claimableOnly?: boolean | undefined;
13529
13535
  chainId: number[];
13530
13536
  };
13531
13537
  fetch?: RequestInit | undefined;
@@ -0,0 +1,3 @@
1
+ import type { Campaign } from "@sdk";
2
+ import type { CampaignTVLBuilder } from "./interface";
3
+ export declare const campaignDynamicDataBuilderFactory: (campaignType: Campaign) => CampaignTVLBuilder<Campaign> | null;
@@ -0,0 +1,9 @@
1
+ // @dev Casts are made to enforce type safety
2
+ // @dev A type error must be thrown if a new campaign type is added and the corresponding builder is not implemented
3
+ const map = {};
4
+ export const campaignDynamicDataBuilderFactory = (campaignType) => {
5
+ if (!map[campaignType]) {
6
+ return null;
7
+ }
8
+ return map[campaignType];
9
+ };
@@ -0,0 +1,4 @@
1
+ import { HttpError } from "./HttpError";
2
+ export declare class InvalidParameter extends HttpError {
3
+ constructor(message?: string);
4
+ }
@@ -0,0 +1,7 @@
1
+ import { HttpError } from "./HttpError";
2
+ export class InvalidParameter extends HttpError {
3
+ constructor(message = "Invalid Parameter") {
4
+ super(message, 400);
5
+ this.name = "InvalidParameterError";
6
+ }
7
+ }
@@ -1327,7 +1327,7 @@ declare const app: Elysia<"", false, {
1327
1327
  authorization: string;
1328
1328
  };
1329
1329
  response: {
1330
- 200: unknown[];
1330
+ 200: unknown[] | undefined;
1331
1331
  };
1332
1332
  };
1333
1333
  };
@@ -1894,7 +1894,7 @@ declare const app: Elysia<"", false, {
1894
1894
  authorization: string;
1895
1895
  };
1896
1896
  response: {
1897
- 200: unknown[];
1897
+ 200: unknown[] | undefined;
1898
1898
  };
1899
1899
  };
1900
1900
  };
@@ -1912,7 +1912,7 @@ declare const app: Elysia<"", false, {
1912
1912
  authorization: string;
1913
1913
  };
1914
1914
  response: {
1915
- 200: unknown[];
1915
+ 200: unknown[] | undefined;
1916
1916
  };
1917
1917
  };
1918
1918
  };
@@ -1942,7 +1942,7 @@ declare const app: Elysia<"", false, {
1942
1942
  authorization: string;
1943
1943
  };
1944
1944
  response: {
1945
- 200: unknown[];
1945
+ 200: unknown[] | undefined;
1946
1946
  };
1947
1947
  };
1948
1948
  };
@@ -3454,6 +3454,7 @@ declare const app: Elysia<"", false, {
3454
3454
  test?: boolean | undefined;
3455
3455
  chainIds?: number[] | undefined;
3456
3456
  reloadChainId?: number | undefined;
3457
+ claimableOnly?: boolean | undefined;
3457
3458
  };
3458
3459
  headers: unknown;
3459
3460
  response: {
@@ -3573,6 +3574,7 @@ declare const app: Elysia<"", false, {
3573
3574
  query: {
3574
3575
  test?: boolean | undefined;
3575
3576
  reloadChainId?: number | undefined;
3577
+ claimableOnly?: boolean | undefined;
3576
3578
  chainId: number[];
3577
3579
  };
3578
3580
  headers: unknown;
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  /**
3
- @deprecated Used only for the v3/campaigns route
3
+ @deprecated Used only for the v3/campaigns route
4
4
  */
5
5
  import { Redis } from "@/cache";
6
6
  import { dynamicDataBuilderFactory } from "@/engine/dynamicData/factory";
@@ -19,6 +19,12 @@ if (!chainId)
19
19
  const queryCampaignTypes = process.env.CAMPAIGN_TYPES ? JSON.parse(process.env.CAMPAIGN_TYPES) : [];
20
20
  const highCampaignsChains = [ChainId.ARBITRUM, ChainId.POLYGON, ChainId.BLAST, ChainId.BASE];
21
21
  export const main = async () => {
22
+ await OpportunityConvertorService.logKeyAndTTLV3Opportunities(false, false, undefined, undefined);
23
+ await OpportunityConvertorService.setV3Opportunities(false, false, undefined, undefined);
24
+ log.info("✅ opportunity v3 cache updated successfully");
25
+ await OpportunityConvertorService.logKeyAndTTLV3Opportunities(false, true, undefined, undefined);
26
+ await OpportunityConvertorService.setV3Opportunities(false, true, undefined, undefined);
27
+ log.info("✅ opportunity v3 test cache updated successfully");
22
28
  let success = true;
23
29
  try {
24
30
  await Redis.safeSet(`MerklChainData_${chainId}`, await merklChainData(chainId));
@@ -1,6 +1,8 @@
1
1
  import { CampaignService } from "@/modules/v4/campaign";
2
2
  import { DynamicDataService } from "@/modules/v4/dynamicData/dynamicData.service";
3
3
  import { OpportunityService } from "@/modules/v4/opportunity";
4
+ import { OpportunityConvertorService } from "@/modules/v4/opportunity/opportunity.converter";
5
+ import { logger } from "@/utils/logger";
4
6
  import { Campaign as CampaignEnum } from "@sdk";
5
7
  import moment from "moment";
6
8
  // ─── Required Env Variables ──────────────────────────────────────────────────
@@ -9,24 +11,6 @@ if (!chainId)
9
11
  throw new Error("Environment variable CHAIN_ID is required.");
10
12
  // ─── Update Dynamic Data (APR / TVL / Daily Rewards) ─────────────────────────
11
13
  const main = async () => {
12
- const liveCampaigns = (await CampaignService.getLiveCampaigns({ computeChainId: chainId })).map(c => {
13
- return {
14
- amount: c.amount,
15
- campaignId: c.campaignId,
16
- mainParameter: c.Opportunity.identifier,
17
- campaignParameters: c.params,
18
- campaignSubType: c.subType,
19
- campaignType: CampaignEnum[c.type],
20
- chainId: c.distributionChainId,
21
- computeChainId: c.computeChainId,
22
- creator: c.creatorAddress,
23
- endTimestamp: Number(c.endTimestamp),
24
- rewardToken: c.RewardToken.address,
25
- startTimestamp: Number(c.startTimestamp),
26
- index: 0,
27
- };
28
- });
29
- await DynamicDataService.updateForCampaigns(liveCampaigns);
30
14
  // Update status of opportunities
31
15
  // 1. Get current live opportunities or opportunities with live campaigns
32
16
  const liveOpportunities = await OpportunityService.findLiveWithCampaigns(chainId);
@@ -48,15 +32,27 @@ const main = async () => {
48
32
  }
49
33
  if (status === "PAST" && (opportunity.apr !== 0 || opportunity.dailyRewards !== 0))
50
34
  await OpportunityService.update(opportunity.id, { status, apr: 0, dailyRewards: 0 });
51
- if (opportunity.status !== status)
35
+ if (opportunity.status !== status) {
52
36
  await OpportunityService.update(opportunity.id, { status });
37
+ }
53
38
  }
54
39
  // 3. Update the status of the opportunities associated to future campaigns
55
- const futureOpportunityIds = (await CampaignService.getFutureCampaigns({ computeChainId: chainId })).map(c => c.Opportunity.id);
40
+ const futureOpportunities = await CampaignService.getFutureCampaigns({ computeChainId: chainId });
56
41
  const liveOpportunityIds = (await CampaignService.getLiveCampaigns({ computeChainId: chainId })).map(c => c.Opportunity.id);
57
- await OpportunityService.updateMany(futureOpportunityIds?.filter(opportunityId => !liveOpportunityIds.includes(opportunityId)), { status: "SOON" });
42
+ const idToUpdate = futureOpportunities
43
+ ?.filter(c => !liveOpportunityIds.includes(c.id) && c.Opportunity.status !== "SOON")
44
+ .map(c => c.Opportunity.id);
45
+ if (idToUpdate.length > 0) {
46
+ await OpportunityService.updateMany(idToUpdate, { status: "SOON" });
47
+ logger.info(`updated ${idToUpdate.length} opportunities to SOON status.`);
48
+ }
58
49
  // 4. Update the status of the opportunities associated to live campaigns
59
50
  await OpportunityService.updateMany(liveOpportunityIds, { status: "LIVE" });
51
+ // 5. Update records for all live campaigns
52
+ const liveCampaigns = (await CampaignService.findMany({ chainId, status: "LIVE", test: true, withOpportunity: true })).map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], campaign, campaign.Opportunity.identifier));
53
+ for (const type of new Set(liveCampaigns.map(c => c.campaignType))) {
54
+ await DynamicDataService.update(chainId, type, liveCampaigns.filter(c => c.campaignType === type));
55
+ }
60
56
  };
61
57
  try {
62
58
  await main();
@@ -2,5 +2,8 @@ import { type CampaignDynamicData, Campaign as CampaignTypeV3 } from "@sdk";
2
2
  import type { AprRecord } from "./apr.model";
3
3
  export declare abstract class AprService {
4
4
  static hashId(opportunityId: string, timestamp: bigint): string;
5
+ /**
6
+ * @deprecated
7
+ */
5
8
  static extractFromDynamicData<C extends CampaignTypeV3>(type: C, campaigns: CampaignDynamicData<C>[], timestamp?: bigint): AprRecord["model"];
6
9
  }
@@ -5,6 +5,9 @@ export class AprService {
5
5
  static hashId(opportunityId, timestamp) {
6
6
  return Bun.hash(`${opportunityId}${timestamp}`).toString();
7
7
  }
8
+ /**
9
+ * @deprecated
10
+ */
8
11
  static extractFromDynamicData(type, campaigns, timestamp = BigInt(moment().unix())) {
9
12
  const typesWithoutApr = [CampaignTypeV3.INVALID, CampaignTypeV3.JSON_AIRDROP, CampaignTypeV3.ERC20_SNAPSHOT];
10
13
  if (typesWithoutApr.includes(type))
@@ -160,7 +160,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
160
160
  authorization: string;
161
161
  };
162
162
  response: {
163
- 200: unknown[];
163
+ 200: unknown[] | undefined;
164
164
  };
165
165
  };
166
166
  };
@@ -53,7 +53,7 @@ export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { t
53
53
  throw new NotFoundError();
54
54
  const campaign = await CampaignService.findUniqueOrThrow(id, true);
55
55
  const campaignV3 = OpportunityConvertorService.convertV4CampaignToV3(Campaign[campaign.type], CampaignService.format(campaign), campaign.Opportunity.identifier);
56
- return await DynamicDataService.updateForCampaigns([campaignV3]);
56
+ return await DynamicDataService.update(campaignV3.computeChainId, campaignV3.campaignType, [campaignV3]);
57
57
  }, { beforeHandle: BackOfficeGuard, headers: AuthorizationHeadersDto, detail: { hide: true } })
58
58
  // ─── Get Many Campaigns ──────────────────────────────────────────────
59
59
  .get("/", async ({ query }) => {
@@ -26,7 +26,7 @@ export declare const CampaignTestController: Elysia<"/campaigns", false, {
26
26
  authorization: string;
27
27
  };
28
28
  response: {
29
- 200: unknown[];
29
+ 200: unknown[] | undefined;
30
30
  };
31
31
  };
32
32
  };
@@ -44,7 +44,7 @@ export declare const CampaignTestController: Elysia<"/campaigns", false, {
44
44
  authorization: string;
45
45
  };
46
46
  response: {
47
- 200: unknown[];
47
+ 200: unknown[] | undefined;
48
48
  };
49
49
  };
50
50
  };
@@ -74,7 +74,7 @@ export declare const CampaignTestController: Elysia<"/campaigns", false, {
74
74
  authorization: string;
75
75
  };
76
76
  response: {
77
- 200: unknown[];
77
+ 200: unknown[] | undefined;
78
78
  };
79
79
  };
80
80
  };
@@ -1,7 +1,8 @@
1
1
  import { NotFoundError } from "@/errors";
2
+ import { InvalidParameter } from "@/errors/InvalidParameter.error";
2
3
  import { BackOfficeGuard } from "@/guards/BackOffice.guard";
3
4
  import { AuthorizationHeadersDto } from "@/guards/Engine.guard";
4
- import { Campaign } from "@sdk";
5
+ import { Campaign as CampaignEnum } from "@sdk";
5
6
  import Elysia from "elysia";
6
7
  import { DynamicDataService } from "../dynamicData/dynamicData.service";
7
8
  import { OpportunityService } from "../opportunity";
@@ -23,26 +24,29 @@ export const CampaignTestController = new Elysia({
23
24
  if (!id)
24
25
  throw new NotFoundError();
25
26
  const campaign = await CampaignService.findUniqueOrThrow(id, true);
26
- const campaignV3 = OpportunityConvertorService.convertV4CampaignToV3(Campaign[campaign.type], CampaignService.format(campaign), campaign.Opportunity.identifier);
27
- return await DynamicDataService.updateForCampaignType([campaignV3], campaignV3.campaignType, true);
27
+ const campaignV3 = OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], CampaignService.format(campaign), campaign.Opportunity.identifier);
28
+ return await DynamicDataService.update(campaignV3.computeChainId, campaignV3.campaignType, [campaignV3], true);
28
29
  })
29
30
  // ─── Test Dynamic data computation with a list of campaignId ───────────────────────
30
31
  .post("/dynamic-data/list", async ({ body }) => {
31
32
  const listCampaigns = [];
33
+ const type = undefined;
32
34
  for (const campaignId of body) {
33
35
  const id = (await CampaignService.findMany({ campaignId: campaignId, test: true }))?.[0]?.id;
34
36
  if (!id)
35
37
  throw new NotFoundError();
36
38
  const campaign = await CampaignService.findUniqueOrThrow(id, true);
37
- const campaignV3 = OpportunityConvertorService.convertV4CampaignToV3(Campaign[campaign.type], CampaignService.format(campaign), campaign.Opportunity.identifier);
39
+ const campaignV3 = OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], CampaignService.format(campaign), campaign.Opportunity.identifier);
38
40
  listCampaigns.push(campaignV3);
39
41
  }
40
- return await DynamicDataService.updateForCampaigns(listCampaigns, true);
42
+ if (!type)
43
+ throw new InvalidParameter("No campaign type found");
44
+ return await DynamicDataService.update(listCampaigns[0].computeChainId, listCampaigns[0].campaignType, listCampaigns, true);
41
45
  }, { body: CampaignsDto })
42
46
  // ─── Test Dynamic data computation with campaign config ───────────────────────
43
47
  .post("/dynamic-data", async ({ body }) => {
44
- const listCampaigns = [CampaignService.createFakeCampaign(body)];
45
- return await DynamicDataService.updateForCampaigns(listCampaigns, true);
48
+ const campaign = CampaignService.createFakeCampaign(body);
49
+ return await DynamicDataService.update(campaign.computeChainId, campaign.campaignType, [campaign], true);
46
50
  }, {
47
51
  body: CampaignConfigMinimal,
48
52
  })
@@ -64,7 +68,7 @@ export const CampaignTestController = new Elysia({
64
68
  },
65
69
  ]);
66
70
  if (!engineCampaigns.length)
67
- throw new NotFoundError("Campaign not found in engine db");
71
+ throw new NotFoundError("CampaignEnum not found in engine db");
68
72
  return await OpportunityService.createFromCampaign(engineCampaigns[0], false, false);
69
73
  }, {
70
74
  query: CampaignUniqueDto,
@@ -1,6 +1,14 @@
1
- import { Campaign, type CampaignDynamicData, type CampaignParameters, type ChainId } from "@sdk";
2
- import { Campaign as CampaignEnum } from "@sdk";
1
+ import { Campaign as CampaignEnum, type CampaignParameters, type ChainId, type MerklChainId } from "@sdk";
3
2
  export declare class DynamicDataService {
3
+ /**
4
+ * @notice Updates all records for opportunities associated to the given campaigns
5
+ *
6
+ * @dev The list must ONLY contain campaigns of the same type and the same computeChainId
7
+ */
8
+ static update(chainId: ChainId, type: CampaignEnum, campaigns: CampaignParameters<CampaignEnum>[], dryRun?: boolean): Promise<unknown[] | undefined>;
9
+ /**
10
+ * @dev Test function used to create mock ERC20 static campaigns and check tvl and metadata
11
+ */
4
12
  static queryERC20DynamicData(chainId: ChainId, tokenAddress: string, rewardTokenAddress: string, symbolRewardToken: string, decimals?: number): Promise<{
5
13
  tvl: number;
6
14
  totalSupply: number;
@@ -9,7 +17,8 @@ export declare class DynamicDataService {
9
17
  priceTargetToken: number;
10
18
  type: string;
11
19
  }>;
12
- static getDynamicData(campaigns: CampaignParameters<CampaignEnum>[], type: Campaign, chainId: number): Promise<CampaignDynamicData<CampaignEnum>[]>;
13
- static updateForCampaignType(campaigns: CampaignParameters<CampaignEnum>[], type: Campaign, dryRun?: boolean): Promise<unknown[]>;
14
- static updateForCampaigns(campaigns: CampaignParameters<CampaignEnum>[], dryRun?: boolean): Promise<unknown[]>;
20
+ /**
21
+ * @dev Recursive function to handle errors in fetching dynamic data
22
+ */
23
+ static fetchWithRecursiveErrorHandling<R>(fn: (chainId: MerklChainId, campaigns: CampaignParameters<CampaignEnum>[]) => Promise<R[]>, campaigns: CampaignParameters<CampaignEnum>[], chainId: number): Promise<R[]>;
15
24
  }