@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
@@ -14,4 +14,6 @@ export declare const extractOpportunities: {
14
14
  */
15
15
  export declare function fillCampaigns(opportunities: {
16
16
  [id: OpportunityId]: Opportunity;
17
- }, onlyCampaignIds?: boolean, showTest?: boolean): Promise<{}>;
17
+ }, onlyCampaignIds?: boolean, showTest?: boolean): Promise<{
18
+ [id: OpportunityId]: Opportunity;
19
+ }>;
@@ -258,11 +258,13 @@ declare const app: Elysia<"", false, {
258
258
  status?: string | undefined;
259
259
  items?: number | undefined;
260
260
  tags?: string | undefined;
261
+ identifier?: string | undefined;
261
262
  page?: number | undefined;
262
263
  chainId?: string | undefined;
263
264
  action?: string | undefined;
264
265
  creatorAddress?: string | undefined;
265
266
  mainProtocolId?: string | undefined;
267
+ campaigns?: boolean | undefined;
266
268
  order?: string | undefined;
267
269
  test?: boolean | undefined;
268
270
  minimumTvl?: number | undefined;
@@ -319,6 +321,57 @@ declare const app: Elysia<"", false, {
319
321
  amount: bigint;
320
322
  }[];
321
323
  };
324
+ campaigns: {
325
+ params: any;
326
+ chain: {
327
+ name: string;
328
+ id: number;
329
+ icon: string;
330
+ };
331
+ rewardToken: {
332
+ symbol: string;
333
+ name: string | null;
334
+ id: string;
335
+ icon: string;
336
+ chainId: number;
337
+ address: string;
338
+ decimals: number;
339
+ verified: boolean;
340
+ isTest: boolean;
341
+ } & {
342
+ price?: number | null | undefined;
343
+ };
344
+ distributionChain: {
345
+ name: string;
346
+ id: number;
347
+ icon: string;
348
+ } | undefined;
349
+ campaignStatus: {
350
+ error: string;
351
+ details: import("database/api/.generated/runtime/library").JsonValue;
352
+ status: import("../database/api/.generated").$Enums.RunStatus;
353
+ campaignId: string;
354
+ computedUntil: bigint;
355
+ processingStarted: bigint;
356
+ };
357
+ creatorAddress: string;
358
+ Creator: {
359
+ tags: string[];
360
+ address: string;
361
+ creatorId: string | null;
362
+ };
363
+ type: string;
364
+ id: string;
365
+ subType: number | null;
366
+ startTimestamp: bigint;
367
+ endTimestamp: bigint;
368
+ computeChainId: number;
369
+ distributionChainId: number;
370
+ campaignId: string;
371
+ rewardTokenId: string;
372
+ amount: string;
373
+ opportunityId: string;
374
+ }[];
322
375
  id: string;
323
376
  depositUrl: string | undefined;
324
377
  tokens: ({
@@ -375,11 +428,13 @@ declare const app: Elysia<"", false, {
375
428
  status?: string | undefined;
376
429
  items?: number | undefined;
377
430
  tags?: string | undefined;
431
+ identifier?: string | undefined;
378
432
  page?: number | undefined;
379
433
  chainId?: string | undefined;
380
434
  action?: string | undefined;
381
435
  creatorAddress?: string | undefined;
382
436
  mainProtocolId?: string | undefined;
437
+ campaigns?: boolean | undefined;
383
438
  order?: string | undefined;
384
439
  test?: boolean | undefined;
385
440
  minimumTvl?: number | undefined;
@@ -528,45 +583,41 @@ declare const app: Elysia<"", false, {
528
583
  };
529
584
  headers: unknown;
530
585
  response: {
531
- 200: ({
532
- protocol?: {
533
- name: string;
534
- url: string;
535
- description: string;
536
- id: string;
537
- tags: string[];
538
- icon: string;
539
- } | null | undefined;
540
- depositUrl?: string | undefined;
541
- aprRecord?: {
542
- timestamp: string | bigint;
586
+ 200: {
587
+ apr: number;
588
+ aprRecord: {
543
589
  cumulated: number;
590
+ timestamp: bigint;
544
591
  breakdowns: {
545
- type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
592
+ type: import("../database/api/.generated").$Enums.AprType;
546
593
  id: number;
547
594
  identifier: string;
548
595
  value: number;
549
596
  aprRecordId: string;
550
597
  }[];
551
- } | undefined;
552
- tvlRecord?: {
598
+ };
599
+ tvlRecord: {
600
+ id: string;
553
601
  total: number;
554
- timestamp: string | bigint;
602
+ timestamp: bigint;
555
603
  breakdowns: {
556
- type: "TOKEN" | "PROTOCOL";
604
+ type: import("../database/api/.generated").$Enums.TvlType;
557
605
  id: number;
558
606
  identifier: string;
559
607
  value: number;
560
608
  tvlRecordId: string;
561
609
  }[];
562
- } | undefined;
563
- rewardsRecord?: {
564
- total: number;
610
+ };
611
+ rewardsRecord: {
565
612
  id: string;
566
- timestamp: string | bigint;
613
+ total: number;
614
+ timestamp: bigint;
567
615
  breakdowns: {
616
+ id: number;
617
+ value: number;
618
+ campaignId: string;
619
+ dailyRewardsRecordId: string;
568
620
  token: {
569
- price?: number | null | undefined;
570
621
  symbol: string;
571
622
  name: string | null;
572
623
  id: string;
@@ -574,45 +625,14 @@ declare const app: Elysia<"", false, {
574
625
  chainId: number;
575
626
  address: string;
576
627
  decimals: number;
628
+ displaySymbol: string;
577
629
  verified: boolean;
578
630
  isTest: boolean;
631
+ price: number | null;
579
632
  };
580
- id: number;
581
- value: number;
582
- campaignId: string;
583
- amount: string | bigint;
584
- dailyRewardsRecordId: string;
633
+ amount: bigint;
585
634
  }[];
586
- } | undefined;
587
- name: string;
588
- type: string;
589
- tokens: {
590
- price?: number | null | undefined;
591
- symbol: string;
592
- name: string | null;
593
- id: string;
594
- icon: string;
595
- chainId: number;
596
- address: string;
597
- decimals: number;
598
- verified: boolean;
599
- isTest: boolean;
600
- }[];
601
- id: string;
602
- status: string;
603
- tags: string[];
604
- identifier: string;
605
- chain: {
606
- name: string;
607
- id: number;
608
- icon: string;
609
635
  };
610
- chainId: number;
611
- action: string;
612
- tvl: number;
613
- apr: number;
614
- dailyRewards: number;
615
- } & {
616
636
  campaigns: {
617
637
  params: any;
618
638
  chain: {
@@ -664,7 +684,44 @@ declare const app: Elysia<"", false, {
664
684
  amount: string;
665
685
  opportunityId: string;
666
686
  }[];
667
- })[];
687
+ id: string;
688
+ depositUrl: string | undefined;
689
+ tokens: ({
690
+ symbol: string;
691
+ name: string | null;
692
+ id: string;
693
+ icon: string;
694
+ chainId: number;
695
+ address: string;
696
+ decimals: number;
697
+ verified: boolean;
698
+ isTest: boolean;
699
+ } & {
700
+ price?: number | null | undefined;
701
+ })[];
702
+ chain: {
703
+ name: string;
704
+ id: number;
705
+ icon: string;
706
+ };
707
+ protocol: {
708
+ name: string;
709
+ url: string;
710
+ description: string;
711
+ id: string;
712
+ tags: string[];
713
+ icon: string;
714
+ } | undefined;
715
+ name: string;
716
+ type: string;
717
+ status: import("../database/api/.generated").$Enums.Status;
718
+ tags: string[];
719
+ identifier: string;
720
+ chainId: number;
721
+ action: import("../database/api/.generated").$Enums.OpportunityAction;
722
+ tvl: number;
723
+ dailyRewards: number;
724
+ }[];
668
725
  readonly 404: {
669
726
  message: string;
670
727
  name: string;
@@ -853,11 +910,13 @@ declare const app: Elysia<"", false, {
853
910
  status?: string | undefined;
854
911
  items?: number | undefined;
855
912
  tags?: string | undefined;
913
+ identifier?: string | undefined;
856
914
  page?: number | undefined;
857
915
  chainId?: string | undefined;
858
916
  action?: string | undefined;
859
917
  creatorAddress?: string | undefined;
860
918
  mainProtocolId?: string | undefined;
919
+ campaigns?: boolean | undefined;
861
920
  order?: string | undefined;
862
921
  test?: boolean | undefined;
863
922
  minimumTvl?: number | undefined;
@@ -890,11 +949,13 @@ declare const app: Elysia<"", false, {
890
949
  status?: string | undefined;
891
950
  items?: number | undefined;
892
951
  tags?: string | undefined;
952
+ identifier?: string | undefined;
893
953
  page?: number | undefined;
894
954
  chainId?: string | undefined;
895
955
  action?: string | undefined;
896
956
  creatorAddress?: string | undefined;
897
957
  mainProtocolId?: string | undefined;
958
+ campaigns?: boolean | undefined;
898
959
  order?: string | undefined;
899
960
  test?: boolean | undefined;
900
961
  minimumTvl?: number | undefined;
@@ -928,11 +989,13 @@ declare const app: Elysia<"", false, {
928
989
  status?: string | undefined;
929
990
  items?: number | undefined;
930
991
  tags?: string | undefined;
992
+ identifier?: string | undefined;
931
993
  page?: number | undefined;
932
994
  chainId?: string | undefined;
933
995
  action?: string | undefined;
934
996
  creatorAddress?: string | undefined;
935
997
  mainProtocolId?: string | undefined;
998
+ campaigns?: boolean | undefined;
936
999
  order?: string | undefined;
937
1000
  test?: boolean | undefined;
938
1001
  minimumTvl?: number | undefined;
@@ -4201,24 +4264,9 @@ declare const app: Elysia<"", false, {
4201
4264
  };
4202
4265
  headers: unknown;
4203
4266
  response: {
4204
- 200: unknown;
4205
- };
4206
- };
4207
- };
4208
- };
4209
- } & {
4210
- v3: {
4211
- campaignReport: {
4212
- get: {
4213
- body: unknown;
4214
- params: {};
4215
- query: {
4216
- chainId: number;
4217
- campaignId: string;
4218
- };
4219
- headers: unknown;
4220
- response: {
4221
- 200: import("./utils/queries/rewardsAmount").RewardsAmountQueryOutput;
4267
+ 200: {
4268
+ message: string;
4269
+ };
4222
4270
  };
4223
4271
  };
4224
4272
  };
@@ -4255,28 +4303,16 @@ declare const app: Elysia<"", false, {
4255
4303
  mainParameter: string;
4256
4304
  };
4257
4305
  headers: unknown;
4258
- response: {
4259
- 200: import("./types/returnTypes").CampaignsForMainParameterReturnType;
4260
- };
4261
- };
4262
- };
4263
- };
4264
- } & {
4265
- v3: {
4266
- campaignInfo: {
4267
- post: {
4268
- body: {
4269
- [x: string]: string[];
4270
- };
4271
- params: {};
4272
- query: unknown;
4273
- headers: unknown;
4274
4306
  response: {
4275
4307
  200: {
4276
- [x: string]: Record<string, any>;
4277
- } | {
4278
- error: string;
4279
- };
4308
+ campaignId: string;
4309
+ campaignType: number;
4310
+ rewardToken: string;
4311
+ rewardTokenSymbol: string;
4312
+ amountDecimal: number;
4313
+ startTimestamp: number;
4314
+ endTimestamp: number;
4315
+ }[];
4280
4316
  };
4281
4317
  };
4282
4318
  };
@@ -4332,7 +4368,9 @@ declare const app: Elysia<"", false, {
4332
4368
  };
4333
4369
  headers: unknown;
4334
4370
  response: {
4335
- 200: unknown;
4371
+ 200: {
4372
+ message: string;
4373
+ };
4336
4374
  };
4337
4375
  };
4338
4376
  };
@@ -4553,9 +4591,9 @@ declare const app: Elysia<"", false, {
4553
4591
  body: unknown;
4554
4592
  params: {};
4555
4593
  query: {
4556
- type?: undefined;
4594
+ type?: number | undefined;
4557
4595
  tag?: string | undefined;
4558
- chainId?: undefined;
4596
+ chainId?: number | undefined;
4559
4597
  action?: undefined;
4560
4598
  campaigns?: boolean | undefined;
4561
4599
  mainParameter?: string | undefined;
@@ -4839,25 +4877,6 @@ declare const app: Elysia<"", false, {
4839
4877
  };
4840
4878
  };
4841
4879
  };
4842
- } & {
4843
- v3: {
4844
- tokenUnclaimed: {
4845
- get: {
4846
- body: unknown;
4847
- params: {};
4848
- query: {
4849
- token: string;
4850
- chainId: number;
4851
- };
4852
- headers: unknown;
4853
- response: {
4854
- 200: {
4855
- message: string;
4856
- };
4857
- };
4858
- };
4859
- };
4860
- };
4861
4880
  } & {
4862
4881
  v3: {
4863
4882
  updates: {
@@ -1,3 +1,10 @@
1
- import { updatePrices } from "../../backgroundJobs/jobs/priceUpdater";
2
- await updatePrices();
1
+ import { TokenService } from "../../modules/v4/token/token.service";
2
+ import { log } from "../../utils/logger";
3
+ import { Pricer } from "../../utils/pricer";
4
+ const pricer = await Pricer.load();
5
+ const prices = await pricer.update();
6
+ log.info(`✅ ${Object.keys(prices).length} prices cache updated successfully`);
7
+ log.info("⏳ Updating API database...");
8
+ await TokenService.updatePrices(pricer);
9
+ log.info("✅ API database updated successfully!");
3
10
  process.exit(0);
@@ -1,5 +1,5 @@
1
1
  import { Redis } from "../../cache";
2
- import { RewardConvertorService } from "../../modules/v4/reward/subservices/converter";
2
+ import { RewardConvertorService } from "../../modules/v4/reward/reward.converter";
3
3
  import { AMM, ANGLE_NETWORKS, Campaign, NETWORK_LABELS, } from "@sdk";
4
4
  import Big from "big.js";
5
5
  import { utils } from "ethers";
@@ -3,7 +3,7 @@ import { getEulerBoostBody, getZksyncBoost } from "./boost.model";
3
3
  import { BoostService } from "./boost.service";
4
4
  export const BoostController = new Elysia({ prefix: "/boosts", detail: { tags: ["Boosts"], hide: true } })
5
5
  // ─── Get Euler Boost ─────────────────────────────────────────────────
6
- .post("/euler", async ({ body }) => BoostService.getEulerBoost(), {
6
+ .post("/euler", async () => BoostService.getEulerBoost(), {
7
7
  body: getEulerBoostBody,
8
8
  detail: { hide: true },
9
9
  })
@@ -1,4 +1,5 @@
1
1
  export declare abstract class CacheRepository {
2
2
  static set(ttl: number, key: string, value: string): Promise<void>;
3
+ static ttl(key: string): Promise<number>;
3
4
  static get(key: string): Promise<string | null>;
4
5
  }
@@ -21,6 +21,25 @@ export class CacheRepository {
21
21
  }
22
22
  });
23
23
  }
24
+ static async ttl(key) {
25
+ return await record("redis.ttl", async (span) => {
26
+ span.setAttribute("db.system", "redis");
27
+ span.setAttribute("net.transport", "ip_tcp");
28
+ span.setAttribute("db.statement", `get ${key}`);
29
+ const startTime = Date.now();
30
+ try {
31
+ const result = await withRetry(withTimeout, [redisClient.ttl(key), REDIS_READ_TIMEOUT], REDIS_RETRIES);
32
+ span.setAttribute("db.redis.response_time", Date.now() - startTime);
33
+ return result;
34
+ }
35
+ catch (error) {
36
+ span.setStatus({ code: 2 }); // OpenTelemetry StatusCode.ERROR
37
+ span.setAttribute("error.message", error.message);
38
+ span.recordException(error);
39
+ throw error;
40
+ }
41
+ });
42
+ }
24
43
  static async get(key) {
25
44
  return await record("redis.get", async (span) => {
26
45
  span.setAttribute("db.system", "redis");
@@ -46,11 +46,6 @@ export declare abstract class CampaignService {
46
46
  * @dev back-office function
47
47
  */
48
48
  static moveToOpportunity(campaign: Omit<UpdateCampaignModel, "id">, upsert?: boolean): Promise<string>;
49
- /**
50
- * Get the list of campaigns satisfying the query
51
- * @param query
52
- * @returns A list of campaigns
53
- */
54
49
  static findMany(query: GetCampaignQueryModel): Promise<{
55
50
  params: any;
56
51
  chain: {
@@ -115,11 +115,6 @@ export class CampaignService {
115
115
  // Return new opportunityId
116
116
  return (await CampaignService.findUniqueOrThrow(campaign)).opportunityId;
117
117
  }
118
- /**
119
- * Get the list of campaigns satisfying the query
120
- * @param query
121
- * @returns A list of campaigns
122
- */
123
118
  static async findMany(query) {
124
119
  if (query.subType && !query.type) {
125
120
  throw new HttpError("Bad Request: Cannot specify a subType without a type", 400);