@merkl/api 0.16.34 → 0.16.35

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 (75) hide show
  1. package/dist/src/backgroundJobs/index.js +0 -4
  2. package/dist/src/backgroundJobs/jobs/opportunityUpdater.js +3 -0
  3. package/dist/src/eden/index.d.ts +657 -444
  4. package/dist/src/entities/opportunity.d.ts +3 -1
  5. package/dist/src/index.d.ts +136 -117
  6. package/dist/src/jobs/etl/prices.js +9 -2
  7. package/dist/src/libs/deprecated-merklv3/index.js +1 -1
  8. package/dist/src/modules/v4/boost/boost.controller.js +1 -1
  9. package/dist/src/modules/v4/cache/cache.repository.d.ts +1 -0
  10. package/dist/src/modules/v4/cache/cache.repository.js +19 -0
  11. package/dist/src/modules/v4/campaign/campaign.service.d.ts +0 -5
  12. package/dist/src/modules/v4/campaign/campaign.service.js +0 -5
  13. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +120 -57
  14. package/dist/src/modules/v4/opportunity/opportunity.controller.js +1 -1
  15. package/dist/src/modules/v4/opportunity/opportunity.converter.d.ts +9 -0
  16. package/dist/src/modules/v4/opportunity/opportunity.converter.js +153 -0
  17. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +3 -1
  18. package/dist/src/modules/v4/opportunity/opportunity.model.js +2 -0
  19. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +18 -210
  20. package/dist/src/modules/v4/opportunity/opportunity.repository.js +76 -113
  21. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +219 -64
  22. package/dist/src/modules/v4/opportunity/opportunity.service.js +19 -21
  23. package/dist/src/modules/v4/reward/{subservices/converter.d.ts → reward.converter.d.ts} +3 -3
  24. package/dist/src/modules/v4/reward/{subservices/converter.js → reward.converter.js} +1 -1
  25. package/dist/src/modules/v4/router.d.ts +120 -57
  26. package/dist/src/routes/v3/app.js +1 -0
  27. package/dist/src/routes/v3/blacklist.js +1 -0
  28. package/dist/src/routes/v3/campaign/delay.js +1 -0
  29. package/dist/src/routes/v3/campaignClaims.d.ts +3 -1
  30. package/dist/src/routes/v3/campaignClaims.js +4 -13
  31. package/dist/src/routes/v3/campaignUnclaimed.js +1 -0
  32. package/dist/src/routes/v3/campaignsForMainParameter.d.ts +9 -1
  33. package/dist/src/routes/v3/campaignsForMainParameter.js +17 -7
  34. package/dist/src/routes/v3/campaignsRewardsReport.js +1 -0
  35. package/dist/src/routes/v3/claims.d.ts +3 -1
  36. package/dist/src/routes/v3/claims.js +4 -33
  37. package/dist/src/routes/v3/opportunity.d.ts +7 -7
  38. package/dist/src/routes/v3/opportunity.js +12 -13
  39. package/dist/src/routes/v3/recipients.js +1 -0
  40. package/dist/src/routes/v3/rewards.js +2 -1
  41. package/dist/src/routes/v3/rewardsReport.js +1 -0
  42. package/dist/src/routes/v3/router.d.ts +16 -60
  43. package/dist/src/routes/v3/router.js +0 -6
  44. package/dist/src/routes/v3/userRewards.js +2 -1
  45. package/dist/src/types/returnTypes.d.ts +0 -8
  46. package/dist/src/utils/camelToKebabCase.d.ts +2 -0
  47. package/dist/src/utils/camelToKebabCase.js +9 -0
  48. package/dist/tsconfig.package.tsbuildinfo +1 -1
  49. package/package.json +1 -1
  50. package/dist/src/backgroundJobs/jobs/priceUpdater.d.ts +0 -37
  51. package/dist/src/backgroundJobs/jobs/priceUpdater.js +0 -21
  52. package/dist/src/backgroundJobs/jobs/sync.d.ts +0 -40
  53. package/dist/src/backgroundJobs/jobs/sync.js +0 -33
  54. package/dist/src/routes/v3/campaignReport.d.ts +0 -43
  55. package/dist/src/routes/v3/campaignReport.js +0 -22
  56. package/dist/src/routes/v3/campaignsInfo.d.ts +0 -41
  57. package/dist/src/routes/v3/campaignsInfo.js +0 -54
  58. package/dist/src/routes/v3/exports/campaigns.d.ts +0 -43
  59. package/dist/src/routes/v3/exports/campaigns.js +0 -28
  60. package/dist/src/routes/v3/tokenUnclaimed.d.ts +0 -44
  61. package/dist/src/routes/v3/tokenUnclaimed.js +0 -24
  62. package/dist/src/utils/queries/campaignsForMainParameter.d.ts +0 -2
  63. package/dist/src/utils/queries/campaignsForMainParameter.js +0 -23
  64. package/dist/src/utils/queries/claimsOverTime.d.ts +0 -8
  65. package/dist/src/utils/queries/claimsOverTime.js +0 -111
  66. package/dist/src/utils/queries/endingCampaigns.d.ts +0 -10
  67. package/dist/src/utils/queries/endingCampaigns.js +0 -21
  68. package/dist/src/utils/queries/futureCampaigns.d.ts +0 -3
  69. package/dist/src/utils/queries/futureCampaigns.js +0 -19
  70. package/dist/src/utils/queries/mainParameterCampaigns.d.ts +0 -5
  71. package/dist/src/utils/queries/mainParameterCampaigns.js +0 -11
  72. package/dist/src/utils/queries/rewardsAmount.d.ts +0 -10
  73. package/dist/src/utils/queries/rewardsAmount.js +0 -106
  74. package/dist/src/utils/queries/unclaimed.d.ts +0 -11
  75. package/dist/src/utils/queries/unclaimed.js +0 -81
@@ -122,45 +122,41 @@ export declare abstract class OpportunityService {
122
122
  * @param where
123
123
  * @returns opportunities
124
124
  */
125
- static getManyByCampaigns(where: GetCampaignQueryModel): Promise<({
126
- protocol?: {
127
- name: string;
128
- url: string;
129
- description: string;
130
- id: string;
131
- tags: string[];
132
- icon: string;
133
- } | null | undefined;
134
- depositUrl?: string | undefined;
135
- aprRecord?: {
136
- timestamp: string | bigint;
125
+ static findManyByCampaigns(where: GetCampaignQueryModel): Promise<{
126
+ apr: number;
127
+ aprRecord: {
137
128
  cumulated: number;
129
+ timestamp: bigint;
138
130
  breakdowns: {
139
- type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
131
+ type: import("../../../../database/api/.generated").$Enums.AprType;
140
132
  id: number;
141
133
  identifier: string;
142
134
  value: number;
143
135
  aprRecordId: string;
144
136
  }[];
145
- } | undefined;
146
- tvlRecord?: {
137
+ };
138
+ tvlRecord: {
139
+ id: string;
147
140
  total: number;
148
- timestamp: string | bigint;
141
+ timestamp: bigint;
149
142
  breakdowns: {
150
- type: "TOKEN" | "PROTOCOL";
143
+ type: import("../../../../database/api/.generated").$Enums.TvlType;
151
144
  id: number;
152
145
  identifier: string;
153
146
  value: number;
154
147
  tvlRecordId: string;
155
148
  }[];
156
- } | undefined;
157
- rewardsRecord?: {
158
- total: number;
149
+ };
150
+ rewardsRecord: {
159
151
  id: string;
160
- timestamp: string | bigint;
152
+ total: number;
153
+ timestamp: bigint;
161
154
  breakdowns: {
155
+ id: number;
156
+ value: number;
157
+ campaignId: string;
158
+ dailyRewardsRecordId: string;
162
159
  token: {
163
- price?: number | null | undefined;
164
160
  symbol: string;
165
161
  name: string | null;
166
162
  id: string;
@@ -168,45 +164,14 @@ export declare abstract class OpportunityService {
168
164
  chainId: number;
169
165
  address: string;
170
166
  decimals: number;
167
+ displaySymbol: string;
171
168
  verified: boolean;
172
169
  isTest: boolean;
170
+ price: number | null;
173
171
  };
174
- id: number;
175
- value: number;
176
- campaignId: string;
177
- amount: string | bigint;
178
- dailyRewardsRecordId: string;
172
+ amount: bigint;
179
173
  }[];
180
- } | undefined;
181
- name: string;
182
- type: string;
183
- tokens: {
184
- price?: number | null | undefined;
185
- symbol: string;
186
- name: string | null;
187
- id: string;
188
- icon: string;
189
- chainId: number;
190
- address: string;
191
- decimals: number;
192
- verified: boolean;
193
- isTest: boolean;
194
- }[];
195
- id: string;
196
- status: string;
197
- tags: string[];
198
- identifier: string;
199
- chain: {
200
- name: string;
201
- id: number;
202
- icon: string;
203
174
  };
204
- chainId: number;
205
- action: string;
206
- tvl: number;
207
- apr: number;
208
- dailyRewards: number;
209
- } & {
210
175
  campaigns: {
211
176
  params: any;
212
177
  chain: {
@@ -258,7 +223,44 @@ export declare abstract class OpportunityService {
258
223
  amount: string;
259
224
  opportunityId: string;
260
225
  }[];
261
- })[]>;
226
+ id: string;
227
+ depositUrl: string | undefined;
228
+ tokens: ({
229
+ symbol: string;
230
+ name: string | null;
231
+ id: string;
232
+ icon: string;
233
+ chainId: number;
234
+ address: string;
235
+ decimals: number;
236
+ verified: boolean;
237
+ isTest: boolean;
238
+ } & {
239
+ price?: number | null | undefined;
240
+ })[];
241
+ chain: {
242
+ name: string;
243
+ id: number;
244
+ icon: string;
245
+ };
246
+ protocol: {
247
+ name: string;
248
+ url: string;
249
+ description: string;
250
+ id: string;
251
+ tags: string[];
252
+ icon: string;
253
+ } | undefined;
254
+ name: string;
255
+ type: string;
256
+ status: import("../../../../database/api/.generated").$Enums.Status;
257
+ tags: string[];
258
+ identifier: string;
259
+ chainId: number;
260
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
261
+ tvl: number;
262
+ dailyRewards: number;
263
+ }[]>;
262
264
  static getUniqueWithCampaignsOrThrow(opportunityId: string | OpportunityUnique, withTest?: boolean): Promise<OpportunityWithCampaignsResourceModel>;
263
265
  static getUniqueOrThrow(opportunityId: string | OpportunityUnique, withTest?: boolean): Promise<OpportunityResourceModel>;
264
266
  /**
@@ -316,6 +318,57 @@ export declare abstract class OpportunityService {
316
318
  amount: bigint;
317
319
  }[];
318
320
  };
321
+ campaigns: {
322
+ params: any;
323
+ chain: {
324
+ name: string;
325
+ id: number;
326
+ icon: string;
327
+ };
328
+ rewardToken: {
329
+ symbol: string;
330
+ name: string | null;
331
+ id: string;
332
+ icon: string;
333
+ chainId: number;
334
+ address: string;
335
+ decimals: number;
336
+ verified: boolean;
337
+ isTest: boolean;
338
+ } & {
339
+ price?: number | null | undefined;
340
+ };
341
+ distributionChain: {
342
+ name: string;
343
+ id: number;
344
+ icon: string;
345
+ } | undefined;
346
+ campaignStatus: {
347
+ error: string;
348
+ details: Prisma.JsonValue;
349
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
350
+ campaignId: string;
351
+ computedUntil: bigint;
352
+ processingStarted: bigint;
353
+ };
354
+ creatorAddress: string;
355
+ Creator: {
356
+ tags: string[];
357
+ address: string;
358
+ creatorId: string | null;
359
+ };
360
+ type: string;
361
+ id: string;
362
+ subType: number | null;
363
+ startTimestamp: bigint;
364
+ endTimestamp: bigint;
365
+ computeChainId: number;
366
+ distributionChainId: number;
367
+ campaignId: string;
368
+ rewardTokenId: string;
369
+ amount: string;
370
+ opportunityId: string;
371
+ }[];
319
372
  id: string;
320
373
  depositUrl: string | undefined;
321
374
  tokens: ({
@@ -354,6 +407,13 @@ export declare abstract class OpportunityService {
354
407
  tvl: number;
355
408
  dailyRewards: number;
356
409
  }[]>;
410
+ /**
411
+ * Counts the number of opportunities that complies to query
412
+ * @description used for pagination purposes
413
+ * @param query
414
+ * @returns the number of opportunities
415
+ */
416
+ static countMany(query: GetOpportunitiesQueryModel): Promise<number>;
357
417
  static findLiveWithFirstCampaign(chainId: MerklChainId): Promise<({
358
418
  apr: number;
359
419
  aprRecord: {
@@ -404,6 +464,57 @@ export declare abstract class OpportunityService {
404
464
  amount: bigint;
405
465
  }[];
406
466
  };
467
+ campaigns: {
468
+ params: any;
469
+ chain: {
470
+ name: string;
471
+ id: number;
472
+ icon: string;
473
+ };
474
+ rewardToken: {
475
+ symbol: string;
476
+ name: string | null;
477
+ id: string;
478
+ icon: string;
479
+ chainId: number;
480
+ address: string;
481
+ decimals: number;
482
+ verified: boolean;
483
+ isTest: boolean;
484
+ } & {
485
+ price?: number | null | undefined;
486
+ };
487
+ distributionChain: {
488
+ name: string;
489
+ id: number;
490
+ icon: string;
491
+ } | undefined;
492
+ campaignStatus: {
493
+ error: string;
494
+ details: Prisma.JsonValue;
495
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
496
+ campaignId: string;
497
+ computedUntil: bigint;
498
+ processingStarted: bigint;
499
+ };
500
+ creatorAddress: string;
501
+ Creator: {
502
+ tags: string[];
503
+ address: string;
504
+ creatorId: string | null;
505
+ };
506
+ type: string;
507
+ id: string;
508
+ subType: number | null;
509
+ startTimestamp: bigint;
510
+ endTimestamp: bigint;
511
+ computeChainId: number;
512
+ distributionChainId: number;
513
+ campaignId: string;
514
+ rewardTokenId: string;
515
+ amount: string;
516
+ opportunityId: string;
517
+ }[];
407
518
  id: string;
408
519
  depositUrl: string | undefined;
409
520
  tokens: ({
@@ -497,13 +608,6 @@ export declare abstract class OpportunityService {
497
608
  static getAllIds(): Promise<{
498
609
  id: string;
499
610
  }[]>;
500
- /**
501
- * Counts the number of opportunities that complies to query
502
- * @description used for pagination purposes
503
- * @param query
504
- * @returns the number of opportunities
505
- */
506
- static countMany(query: GetOpportunitiesQueryModel): Promise<number>;
507
611
  static formatResponse(opportunity: Awaited<ReturnType<typeof OpportunityRepository.findUniqueOrThrow>>): {
508
612
  apr: number;
509
613
  aprRecord: {
@@ -554,6 +658,57 @@ export declare abstract class OpportunityService {
554
658
  amount: bigint;
555
659
  }[];
556
660
  };
661
+ campaigns: {
662
+ params: any;
663
+ chain: {
664
+ name: string;
665
+ id: number;
666
+ icon: string;
667
+ };
668
+ rewardToken: {
669
+ symbol: string;
670
+ name: string | null;
671
+ id: string;
672
+ icon: string;
673
+ chainId: number;
674
+ address: string;
675
+ decimals: number;
676
+ verified: boolean;
677
+ isTest: boolean;
678
+ } & {
679
+ price?: number | null | undefined;
680
+ };
681
+ distributionChain: {
682
+ name: string;
683
+ id: number;
684
+ icon: string;
685
+ } | undefined;
686
+ campaignStatus: {
687
+ error: string;
688
+ details: Prisma.JsonValue;
689
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
690
+ campaignId: string;
691
+ computedUntil: bigint;
692
+ processingStarted: bigint;
693
+ };
694
+ creatorAddress: string;
695
+ Creator: {
696
+ tags: string[];
697
+ address: string;
698
+ creatorId: string | null;
699
+ };
700
+ type: string;
701
+ id: string;
702
+ subType: number | null;
703
+ startTimestamp: bigint;
704
+ endTimestamp: bigint;
705
+ computeChainId: number;
706
+ distributionChainId: number;
707
+ campaignId: string;
708
+ rewardTokenId: string;
709
+ amount: string;
710
+ opportunityId: string;
711
+ }[];
557
712
  id: string;
558
713
  depositUrl: string | undefined;
559
714
  tokens: ({
@@ -221,8 +221,9 @@ export class OpportunityService {
221
221
  }
222
222
  static async updateMetadata(chain) {
223
223
  try {
224
- const opportunities = await OpportunityRepository.findManyWithCampaigns({
225
- where: { chainId: chain },
224
+ const opportunities = await OpportunityRepository.findMany({
225
+ chainId: chain.toString(),
226
+ campaigns: true,
226
227
  });
227
228
  // ─── Check And Update Opportunity Status ─────────────
228
229
  for (const opp of opportunities) {
@@ -246,20 +247,16 @@ export class OpportunityService {
246
247
  * @param where
247
248
  * @returns opportunities
248
249
  */
249
- static async getManyByCampaigns(where) {
250
+ static async findManyByCampaigns(where) {
250
251
  const opportunities = await OpportunityRepository.findManyByCampaigns(CampaignRepository.transformQueryToPrismaFilters(where).where);
251
- const formatted = opportunities.map(({ Campaigns, ...o }) => {
252
- const opportunity = OpportunityService.formatResponse(o);
253
- const campaigns = Campaigns.map(CampaignService.format);
254
- return Object.assign(opportunity, { campaigns });
252
+ return opportunities.map(o => {
253
+ return OpportunityService.formatResponse(o);
255
254
  });
256
- return formatted;
257
255
  }
258
256
  static async getUniqueWithCampaignsOrThrow(opportunityId, withTest = false) {
259
257
  const id = typeof opportunityId === "string" ? opportunityId : OpportunityService.hashId(opportunityId);
260
- const { Campaigns, ...opportunity } = await OpportunityRepository.findUniqueOrThrowWithCampaigns(id, withTest);
261
- const formatted = OpportunityService.formatResponse(opportunity);
262
- return Object.assign(formatted, { campaigns: Campaigns.map(CampaignService.format) });
258
+ const opportunity = await OpportunityRepository.findUniqueOrThrow(id, withTest, true);
259
+ return OpportunityService.formatResponse(opportunity);
263
260
  }
264
261
  static async getUniqueOrThrow(opportunityId, withTest = false) {
265
262
  const id = typeof opportunityId === "string" ? opportunityId : OpportunityService.hashId(opportunityId);
@@ -277,6 +274,15 @@ export class OpportunityService {
277
274
  return opportunities.map(OpportunityService.formatResponse);
278
275
  }, query);
279
276
  }
277
+ /**
278
+ * Counts the number of opportunities that complies to query
279
+ * @description used for pagination purposes
280
+ * @param query
281
+ * @returns the number of opportunities
282
+ */
283
+ static async countMany(query) {
284
+ return await OpportunityRepository.countMany(query);
285
+ }
280
286
  static async findLiveWithFirstCampaign(chainId) {
281
287
  return record("data-layer.access", async () => {
282
288
  return await CacheService.wrap(TTLPresets.MIN_10, async (chainId) => {
@@ -291,17 +297,8 @@ export class OpportunityService {
291
297
  static async getAllIds() {
292
298
  return await OpportunityRepository.getAllIdsForDynamicOpp();
293
299
  }
294
- /**
295
- * Counts the number of opportunities that complies to query
296
- * @description used for pagination purposes
297
- * @param query
298
- * @returns the number of opportunities
299
- */
300
- static async countMany(query) {
301
- return await OpportunityRepository.countMany(query);
302
- }
303
300
  static formatResponse(opportunity) {
304
- const { DailyRewardsRecords, AprRecords, TvlRecords, ...opp } = opportunity;
301
+ const { DailyRewardsRecords, AprRecords, TvlRecords, Campaigns, ...opp } = opportunity;
305
302
  return {
306
303
  ...OpportunityService.formatResponseBase(opp),
307
304
  apr: opp.status === "LIVE" ? opp.apr : 0,
@@ -336,6 +333,7 @@ export class OpportunityService {
336
333
  };
337
334
  }),
338
335
  }))?.[0] ?? undefined,
336
+ campaigns: Campaigns?.map(c => CampaignService.format(c)),
339
337
  //TODO: change this to accomodate all return types
340
338
  };
341
339
  }
@@ -1,7 +1,7 @@
1
1
  import type { MerklAPIType, MerklChainId } from "@sdk";
2
- import type { RewardV3Model, UserRewardV3Model } from "../reward.model";
3
- import { RewardService } from "../reward.service";
4
- export declare abstract class RewardConvertorService {
2
+ import type { RewardV3Model, UserRewardV3Model } from "./reward.model";
3
+ import { RewardService } from "./reward.service";
4
+ export declare class RewardConvertorService {
5
5
  /**
6
6
  * Convert the v4 reward data to the v3 model used in the v3/userRewards route
7
7
  */
@@ -1,4 +1,4 @@
1
- import { RewardService } from "../reward.service";
1
+ import { RewardService } from "./reward.service";
2
2
  export class RewardConvertorService {
3
3
  /**
4
4
  * Convert the v4 reward data to the v3 model used in the v3/userRewards route