@merkl/api 0.20.167 → 0.20.169

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 (31) hide show
  1. package/dist/database/index.js +1 -1
  2. package/dist/src/eden/index.d.ts +300 -56
  3. package/dist/src/engine/deprecated/dynamicData/factory.js +3 -1
  4. package/dist/src/engine/metadata/factory.js +2 -0
  5. package/dist/src/index.d.ts +112 -18
  6. package/dist/src/jobs/update-analytics.js +79 -75
  7. package/dist/src/modules/v4/apr/apr.model.d.ts +2 -6
  8. package/dist/src/modules/v4/apr/apr.model.js +1 -3
  9. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +25 -0
  10. package/dist/src/modules/v4/campaign/campaign.controller.js +8 -1
  11. package/dist/src/modules/v4/campaign/campaign.repository.d.ts +16 -0
  12. package/dist/src/modules/v4/campaign/campaign.repository.js +18 -0
  13. package/dist/src/modules/v4/campaign/campaign.service.d.ts +10 -0
  14. package/dist/src/modules/v4/campaign/campaign.service.js +7 -0
  15. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +87 -18
  16. package/dist/src/modules/v4/opportunity/opportunity.controller.js +8 -2
  17. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +4 -12
  18. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +0 -20
  19. package/dist/src/modules/v4/opportunity/opportunity.repository.js +10 -2
  20. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +14 -27
  21. package/dist/src/modules/v4/opportunity/opportunity.service.js +62 -1
  22. package/dist/src/modules/v4/programPayload/programPayload.service.js +3 -0
  23. package/dist/src/modules/v4/reward/reward.controller.js +1 -1
  24. package/dist/src/modules/v4/reward/reward.service.d.ts +1 -7
  25. package/dist/src/modules/v4/reward/reward.service.js +1 -1
  26. package/dist/src/modules/v4/router.d.ts +112 -18
  27. package/dist/src/modules/v4/token/token.controller.js +6 -1
  28. package/dist/src/modules/v4/tvl/tvl.model.d.ts +2 -6
  29. package/dist/src/modules/v4/tvl/tvl.model.js +1 -3
  30. package/dist/tsconfig.package.tsbuildinfo +1 -1
  31. package/package.json +1 -1
@@ -14,16 +14,12 @@ export declare abstract class RewardService {
14
14
  cumulated: number;
15
15
  timestamp: bigint;
16
16
  breakdowns: ({
17
- id: string;
18
17
  value: number;
19
- aprRecordId: string;
20
18
  distributionType: import("@db/api").$Enums.DistributionType;
21
19
  identifier: string;
22
20
  type: "CAMPAIGN";
23
21
  } | {
24
- id: string;
25
22
  value: number;
26
- aprRecordId: string;
27
23
  identifier: string;
28
24
  type: import("@db/api").$Enums.AprType;
29
25
  })[];
@@ -34,10 +30,8 @@ export declare abstract class RewardService {
34
30
  timestamp: bigint;
35
31
  breakdowns: {
36
32
  type: import("@db/api").$Enums.TvlType;
37
- id: string;
38
33
  identifier: string;
39
34
  value: number;
40
- tvlRecordId: string;
41
35
  }[];
42
36
  };
43
37
  rewardsRecord: {
@@ -192,7 +186,7 @@ export declare abstract class RewardService {
192
186
  dailyRewards: number;
193
187
  }, number>>;
194
188
  static getTotalDistributed(since: number): Promise<number>;
195
- static getTotalDistributedByChains(since: number): Promise<any>;
189
+ static getTotalDistributedByChain(since: number): Promise<any>;
196
190
  static getTotalDistributedByProtocol(since: number): Promise<any>;
197
191
  static getTotalDistributedByType(since: number): Promise<any>;
198
192
  /**
@@ -44,7 +44,7 @@ export class RewardService {
44
44
  const oppToDailyRewards = await RewardService.getTotalDistributedByOpportunities(since);
45
45
  return oppToDailyRewards.values().reduce((prev, curr) => prev + curr, 0);
46
46
  }
47
- static async getTotalDistributedByChains(since) {
47
+ static async getTotalDistributedByChain(since) {
48
48
  const oppToDailyRewards = await RewardService.getTotalDistributedByOpportunities(since);
49
49
  const chainsToDailyRewards = new Map();
50
50
  for (const [opp, dr] of oppToDailyRewards.entries()) {
@@ -371,16 +371,12 @@ export declare const v4: Elysia<"/v4", false, {
371
371
  cumulated: number;
372
372
  timestamp: bigint;
373
373
  breakdowns: ({
374
- id: string;
375
374
  value: number;
376
- aprRecordId: string;
377
375
  distributionType: import("@db/api").$Enums.DistributionType;
378
376
  identifier: string;
379
377
  type: "CAMPAIGN";
380
378
  } | {
381
- id: string;
382
379
  value: number;
383
- aprRecordId: string;
384
380
  identifier: string;
385
381
  type: import("@db/api").$Enums.AprType;
386
382
  })[];
@@ -391,10 +387,8 @@ export declare const v4: Elysia<"/v4", false, {
391
387
  timestamp: bigint;
392
388
  breakdowns: {
393
389
  type: import("@db/api").$Enums.TvlType;
394
- id: string;
395
390
  identifier: string;
396
391
  value: number;
397
- tvlRecordId: string;
398
392
  }[];
399
393
  };
400
394
  rewardsRecord: {
@@ -588,6 +582,93 @@ export declare const v4: Elysia<"/v4", false, {
588
582
  };
589
583
  };
590
584
  };
585
+ } & {
586
+ opportunities: {
587
+ bins: {
588
+ apr: {
589
+ get: {
590
+ body: unknown;
591
+ params: {};
592
+ query: {
593
+ status?: string | undefined;
594
+ search?: string | undefined;
595
+ sort?: string | undefined;
596
+ type?: string | undefined;
597
+ name?: string | undefined;
598
+ tokens?: string | undefined;
599
+ items?: number | undefined;
600
+ tags?: string | undefined;
601
+ identifier?: string | undefined;
602
+ page?: number | undefined;
603
+ action?: string | undefined;
604
+ campaignId?: string | undefined;
605
+ creatorAddress?: string | undefined;
606
+ chainId?: string | undefined;
607
+ mainProtocolId?: string | undefined;
608
+ campaigns?: boolean | undefined;
609
+ point?: boolean | undefined;
610
+ rewardTokenSymbol?: string | undefined;
611
+ order?: string | undefined;
612
+ test?: boolean | undefined;
613
+ minimumTvl?: number | undefined;
614
+ };
615
+ headers: unknown;
616
+ response: {
617
+ 200: {
618
+ min: number;
619
+ max: number;
620
+ overThreshold: number;
621
+ binWidth: number;
622
+ bins: any[];
623
+ };
624
+ };
625
+ };
626
+ };
627
+ };
628
+ };
629
+ } & {
630
+ opportunities: {
631
+ bins: {
632
+ tvl: {
633
+ get: {
634
+ body: unknown;
635
+ params: {};
636
+ query: {
637
+ status?: string | undefined;
638
+ search?: string | undefined;
639
+ sort?: string | undefined;
640
+ type?: string | undefined;
641
+ name?: string | undefined;
642
+ tokens?: string | undefined;
643
+ items?: number | undefined;
644
+ tags?: string | undefined;
645
+ identifier?: string | undefined;
646
+ page?: number | undefined;
647
+ action?: string | undefined;
648
+ campaignId?: string | undefined;
649
+ creatorAddress?: string | undefined;
650
+ chainId?: string | undefined;
651
+ mainProtocolId?: string | undefined;
652
+ campaigns?: boolean | undefined;
653
+ point?: boolean | undefined;
654
+ rewardTokenSymbol?: string | undefined;
655
+ order?: string | undefined;
656
+ test?: boolean | undefined;
657
+ minimumTvl?: number | undefined;
658
+ };
659
+ headers: unknown;
660
+ response: {
661
+ 200: {
662
+ min: number;
663
+ max: number;
664
+ binWidth: number;
665
+ bins: any[];
666
+ };
667
+ };
668
+ };
669
+ };
670
+ };
671
+ };
591
672
  } & {
592
673
  opportunities: {
593
674
  ":id": {
@@ -619,10 +700,8 @@ export declare const v4: Elysia<"/v4", false, {
619
700
  cumulated: number;
620
701
  breakdowns: {
621
702
  type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
622
- id: string;
623
703
  identifier: string;
624
704
  value: number;
625
- aprRecordId: string;
626
705
  }[];
627
706
  } | undefined;
628
707
  tvlRecord?: {
@@ -630,10 +709,8 @@ export declare const v4: Elysia<"/v4", false, {
630
709
  timestamp: string | bigint;
631
710
  breakdowns: {
632
711
  type: "TOKEN" | "PROTOCOL";
633
- id: string;
634
712
  identifier: string;
635
713
  value: number;
636
- tvlRecordId: string;
637
714
  }[];
638
715
  } | undefined;
639
716
  rewardsRecord?: {
@@ -758,10 +835,8 @@ export declare const v4: Elysia<"/v4", false, {
758
835
  cumulated: number;
759
836
  breakdowns: {
760
837
  type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
761
- id: string;
762
838
  identifier: string;
763
839
  value: number;
764
- aprRecordId: string;
765
840
  }[];
766
841
  } | undefined;
767
842
  tvlRecord?: {
@@ -769,10 +844,8 @@ export declare const v4: Elysia<"/v4", false, {
769
844
  timestamp: string | bigint;
770
845
  breakdowns: {
771
846
  type: "TOKEN" | "PROTOCOL";
772
- id: string;
773
847
  identifier: string;
774
848
  value: number;
775
- tvlRecordId: string;
776
849
  }[];
777
850
  } | undefined;
778
851
  rewardsRecord?: {
@@ -934,10 +1007,8 @@ export declare const v4: Elysia<"/v4", false, {
934
1007
  cumulated: number;
935
1008
  breakdowns: {
936
1009
  type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
937
- id: string;
938
1010
  identifier: string;
939
1011
  value: number;
940
- aprRecordId: string;
941
1012
  }[];
942
1013
  } | undefined;
943
1014
  tvlRecord?: {
@@ -945,10 +1016,8 @@ export declare const v4: Elysia<"/v4", false, {
945
1016
  timestamp: string | bigint;
946
1017
  breakdowns: {
947
1018
  type: "TOKEN" | "PROTOCOL";
948
- id: string;
949
1019
  identifier: string;
950
1020
  value: number;
951
- tvlRecordId: string;
952
1021
  }[];
953
1022
  } | undefined;
954
1023
  rewardsRecord?: {
@@ -1641,6 +1710,31 @@ export declare const v4: Elysia<"/v4", false, {
1641
1710
  };
1642
1711
  };
1643
1712
  };
1713
+ } & {
1714
+ ":id": {
1715
+ timeseries: {
1716
+ get: {
1717
+ body: unknown;
1718
+ params: {
1719
+ id: string;
1720
+ };
1721
+ query: unknown;
1722
+ headers: unknown;
1723
+ response: {
1724
+ 200: {
1725
+ tvlRecords: {
1726
+ total: number;
1727
+ timestamp: bigint;
1728
+ }[];
1729
+ aprRecords: {
1730
+ timestamp: bigint;
1731
+ cumulated: number;
1732
+ }[];
1733
+ };
1734
+ };
1735
+ };
1736
+ };
1737
+ };
1644
1738
  } & {
1645
1739
  "campaigns-to-process": {
1646
1740
  index: {
@@ -1,7 +1,7 @@
1
1
  import { NotFoundError } from "@/errors/NotFound.error";
2
2
  import { AuthorizationHeadersDto, BackOfficeGuard } from "@/guards/BackOffice.guard";
3
3
  import { getUserAllowance } from "@/libs/tokens/allowances";
4
- import { throwOnInvalidRequiredAddress, throwOnUnsupportedChainId } from "@/utils/throw";
4
+ import { throwOnInvalidAddress, throwOnInvalidRequiredAddress, throwOnUnsupportedChainId } from "@/utils/throw";
5
5
  import Elysia, { t } from "elysia";
6
6
  import { CreateTokenDto, FindUniqueTokenAllowanceDto, FindUniqueTokenDto, GetTokenBalanceDto, GetTokenQueryDto, NotionWebhookAddTokenDto, TokenIdDto, UpdateTokenDto, } from "./token.model";
7
7
  import { TokenService } from "./token.service";
@@ -65,6 +65,11 @@ export const TokenController = new Elysia({ prefix: "/tokens", detail: { tags: [
65
65
  return await TokenService.fetchTokensAndBalances(chainId, userAddress, [tokenAddress].concat(additionalTokenAddresses ?? []));
66
66
  return await TokenService.fetchVerifiedAndNativeBalances(chainId, userAddress, additionalTokenAddresses);
67
67
  }, {
68
+ beforeHandle: ({ query }) => {
69
+ throwOnUnsupportedChainId(query.chainId);
70
+ query.userAddress = throwOnInvalidRequiredAddress(query.userAddress);
71
+ query.tokenAddress = throwOnInvalidAddress(query.tokenAddress);
72
+ },
68
73
  query: GetTokenBalanceDto,
69
74
  detail: {
70
75
  hide: true,
@@ -14,26 +14,22 @@ export type TvlRecord = Resource<"TVLRecord", "id" | "opportunityId", {
14
14
  */
15
15
  export type TvlBreakdown = Resource<"TVLBreakdown", "id" | "tvlRecordId">;
16
16
  export declare const TvlBreakdownResourceDto: import("@sinclair/typebox").TObject<{
17
- id: import("@sinclair/typebox").TString;
17
+ identifier: import("@sinclair/typebox").TString;
18
18
  type: import("@sinclair/typebox").TEnum<{
19
19
  TOKEN: "TOKEN";
20
20
  PROTOCOL: "PROTOCOL";
21
21
  }>;
22
- identifier: import("@sinclair/typebox").TString;
23
22
  value: import("@sinclair/typebox").TNumber;
24
- tvlRecordId: import("@sinclair/typebox").TString;
25
23
  }>;
26
24
  export declare const TvlRecordResourceDto: import("@sinclair/typebox").TObject<{
27
25
  total: import("@sinclair/typebox").TNumber;
28
26
  timestamp: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBigInt, import("@sinclair/typebox").TString]>;
29
27
  breakdowns: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
30
- id: import("@sinclair/typebox").TString;
28
+ identifier: import("@sinclair/typebox").TString;
31
29
  type: import("@sinclair/typebox").TEnum<{
32
30
  TOKEN: "TOKEN";
33
31
  PROTOCOL: "PROTOCOL";
34
32
  }>;
35
- identifier: import("@sinclair/typebox").TString;
36
33
  value: import("@sinclair/typebox").TNumber;
37
- tvlRecordId: import("@sinclair/typebox").TString;
38
34
  }>>;
39
35
  }>;
@@ -2,11 +2,9 @@ import { TvlType } from "@db/api";
2
2
  import { t } from "elysia";
3
3
  // ─── Dtos ────────────────────────────────────────────────────────────────────
4
4
  export const TvlBreakdownResourceDto = t.Object({
5
- id: t.String(),
6
- type: t.Enum(TvlType),
7
5
  identifier: t.String(),
6
+ type: t.Enum(TvlType),
8
7
  value: t.Number(),
9
- tvlRecordId: t.String(),
10
8
  });
11
9
  export const TvlRecordResourceDto = t.Object({
12
10
  total: t.Number(),