@merkl/api 1.0.46 → 1.0.48

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.
@@ -1,16 +1,12 @@
1
1
  import { type CampaignParameters, Campaign as CampaignType, type ChainId } from "@angleprotocol/sdk/ts";
2
2
  import type { CampaignManualOverride } from "@package/databases/api";
3
- import type { CampaignConfigMinimalModel, CampaignUnique, CampaignWithParams, CreateCampaignModel, GetCampaignQueryModel, TransactionModel, UpdateCampaignCreatorModel, UpdateCampaignModel, UpdateMetaDataCampaignModel } from "../../../modules/v4/campaign/campaign.model";
3
+ import type { CampaignConfigMinimalModel, CampaignUnique, CreateCampaignModel, FindCampaignModel, TransactionModel, UpdateCampaignCreatorModel, UpdateCampaignModel, UpdateMetaDataCampaignModel, findCampaignWithStatusModel } from "../../../modules/v4/campaign/campaign.model";
4
4
  import type { GetCampaignComputedValueModel } from "../computedValue/computedValue.model";
5
- import { CampaignRepository } from "./campaign.repository";
6
- export declare abstract class CampaignService {
5
+ import { CampaignFormatter } from "./campaign.formatter";
6
+ export declare abstract class CampaignService extends CampaignFormatter {
7
7
  static hashId(campaign: CampaignUnique): string;
8
8
  static splitIdOrThrow(chainAndCampaignId: `${number}-${string}` | string): CampaignUnique;
9
- static getPastCampaigns(query?: {
10
- computeChainId?: number;
11
- type?: string;
12
- creatorAddress?: string;
13
- }): Promise<({
9
+ static getPastCampaigns(query?: findCampaignWithStatusModel): Promise<({
14
10
  Opportunity: {
15
11
  name: string;
16
12
  apr: number;
@@ -52,11 +48,7 @@ export declare abstract class CampaignService {
52
48
  rootCampaignId: string | null;
53
49
  parentCampaignId: string | null;
54
50
  })[]>;
55
- static getFutureCampaigns(query?: {
56
- computeChainId?: number;
57
- type?: string;
58
- creatorAddress?: string;
59
- }): Promise<({
51
+ static getFutureCampaigns(query?: findCampaignWithStatusModel): Promise<({
60
52
  Opportunity: {
61
53
  name: string;
62
54
  apr: number;
@@ -98,12 +90,7 @@ export declare abstract class CampaignService {
98
90
  rootCampaignId: string | null;
99
91
  parentCampaignId: string | null;
100
92
  })[]>;
101
- static getLiveCampaigns(query?: {
102
- distributionChainId?: number;
103
- computeChainId?: number;
104
- type?: string;
105
- creatorAddress?: string;
106
- }): Promise<({
93
+ static getLiveCampaigns(query?: findCampaignWithStatusModel): Promise<({
107
94
  RewardToken: {
108
95
  symbol: string;
109
96
  name: string | null;
@@ -183,11 +170,7 @@ export declare abstract class CampaignService {
183
170
  rootCampaignId: string | null;
184
171
  parentCampaignId: string | null;
185
172
  })[]>;
186
- static countLives(query?: {
187
- distributionChainId?: number;
188
- computeChainId?: number;
189
- type?: string;
190
- }): Promise<number>;
173
+ static countLives(query?: findCampaignWithStatusModel): Promise<number>;
191
174
  static create(body: Omit<CreateCampaignModel, "id">, dryRun?: boolean): Promise<{
192
175
  campaignId: string;
193
176
  description: string | null;
@@ -324,7 +307,7 @@ export declare abstract class CampaignService {
324
307
  * @param query
325
308
  * @returns A list of campaigns
326
309
  */
327
- static findMany(query: GetCampaignQueryModel): Promise<{
310
+ static findMany(query: FindCampaignModel): Promise<{
328
311
  params: any;
329
312
  chain: {
330
313
  name: string;
@@ -405,7 +388,7 @@ export declare abstract class CampaignService {
405
388
  subType: number | null;
406
389
  rewardTokenId: string;
407
390
  }[]>;
408
- static findFirst(query: Omit<GetCampaignQueryModel, "page" | "items">): Promise<{
391
+ static findFirst(query: Omit<FindCampaignModel, "page" | "items">): Promise<{
409
392
  params: any;
410
393
  chain: {
411
394
  name: string;
@@ -486,7 +469,7 @@ export declare abstract class CampaignService {
486
469
  subType: number | null;
487
470
  rewardTokenId: string;
488
471
  } | null>;
489
- static findAndGroupByChains(query: Omit<GetCampaignQueryModel, "page" | "items">): Promise<Map<number, {
472
+ static findAndGroupByChains(query: Omit<FindCampaignModel, "page" | "items">): Promise<Map<number, {
490
473
  params: any;
491
474
  chain: {
492
475
  name: string;
@@ -567,8 +550,8 @@ export declare abstract class CampaignService {
567
550
  subType: number | null;
568
551
  rewardTokenId: string;
569
552
  }[]>>;
570
- static countByChains(query: Omit<GetCampaignQueryModel, "page" | "items">): Promise<Record<string, number>>;
571
- static findAndGroupByTypes(query: Omit<GetCampaignQueryModel, "page" | "items">): Promise<Map<string, {
553
+ static countByChains(query: Omit<FindCampaignModel, "page" | "items">): Promise<Record<string, number>>;
554
+ static findAndGroupByTypes(query: Omit<FindCampaignModel, "page" | "items">): Promise<Map<string, {
572
555
  params: any;
573
556
  chain: {
574
557
  name: string;
@@ -649,8 +632,8 @@ export declare abstract class CampaignService {
649
632
  subType: number | null;
650
633
  rewardTokenId: string;
651
634
  }[]>>;
652
- static countByTypes(query: Omit<GetCampaignQueryModel, "page" | "items">): Promise<Record<string, number>>;
653
- static findAndGroupByProtocols(query: Omit<GetCampaignQueryModel, "page" | "items">): Promise<Map<string | null, {
635
+ static countByTypes(query: Omit<FindCampaignModel, "page" | "items">): Promise<Record<string, number>>;
636
+ static findAndGroupByProtocols(query: Omit<FindCampaignModel, "page" | "items">): Promise<Map<string | null, {
654
637
  params: any;
655
638
  chain: {
656
639
  name: string;
@@ -731,7 +714,7 @@ export declare abstract class CampaignService {
731
714
  subType: number | null;
732
715
  rewardTokenId: string;
733
716
  }[]>>;
734
- static countByProtocols(query: Omit<GetCampaignQueryModel, "page" | "items">): Promise<Record<string, number>>;
717
+ static countByProtocols(query: Omit<FindCampaignModel, "page" | "items">): Promise<Record<string, number>>;
735
718
  static countBy<T>(campaignsMap: Map<T, ReturnType<(typeof CampaignService)["format"]>[]>): Record<string, number>;
736
719
  /**
737
720
  * Counts the number of campaigns that complies to query
@@ -739,7 +722,7 @@ export declare abstract class CampaignService {
739
722
  * @param query
740
723
  * @returns the number of campaigns
741
724
  */
742
- static countMany(query: Omit<GetCampaignQueryModel, "page" | "items">): Promise<number>;
725
+ static countMany(query: Omit<FindCampaignModel, "page" | "items">): Promise<number>;
743
726
  static checkIfExist(campaign: CampaignUnique | string): Promise<boolean>;
744
727
  static findUnique(campaign: CampaignUnique | string): Promise<({
745
728
  ComputeChain: {
@@ -948,97 +931,6 @@ export declare abstract class CampaignService {
948
931
  live: C[];
949
932
  soon: C[];
950
933
  };
951
- /**
952
- * Convert raw
953
- * @param query
954
- * @returns A list of opportunities
955
- * TODO: remove CampaignService function in favor of prisma client extensions
956
- */
957
- static format(campaign: NonNullable<Awaited<ReturnType<(typeof CampaignRepository)["findMany"]>>>[number]): {
958
- params: any;
959
- chain: {
960
- name: string;
961
- id: number;
962
- icon: string;
963
- };
964
- endTimestamp: number;
965
- startTimestamp: number;
966
- rewardToken: {
967
- symbol: string;
968
- name: string | null;
969
- decimals: number;
970
- address: string;
971
- id: string;
972
- chainId: number;
973
- icon: string;
974
- isNative: boolean;
975
- isPoint: boolean;
976
- isPreTGE: boolean;
977
- isTest: boolean;
978
- verified: boolean;
979
- } & {
980
- price?: number | null | undefined;
981
- isTokenWrapper?: boolean | undefined;
982
- tokenWrapperAddress?: string | undefined;
983
- };
984
- distributionChain: {
985
- name: string;
986
- id: number;
987
- icon: string;
988
- } | undefined;
989
- campaignStatus: {
990
- computedUntil: number;
991
- processingStarted: number;
992
- campaignId: string;
993
- error: string;
994
- status: import("@package/databases").RunStatus;
995
- details: import("@prisma/client/runtime/library").JsonValue;
996
- } | undefined;
997
- creatorAddress: string;
998
- creator: {
999
- address: string;
1000
- tags: string[];
1001
- creatorId: string | null;
1002
- };
1003
- createdAt: string;
1004
- description: string | undefined;
1005
- parentCampaignId: string | undefined;
1006
- rootCampaignId: string | undefined;
1007
- Opportunity: {
1008
- name: string;
1009
- apr: number;
1010
- tvl: number;
1011
- description: string;
1012
- id: string;
1013
- status: import("@package/databases").Status;
1014
- chainId: number;
1015
- action: import("@package/databases").OpportunityAction;
1016
- type: string;
1017
- depositUrl: string | null;
1018
- explorerAddress: string | null;
1019
- howToSteps: string[];
1020
- mainProtocolId: string | null;
1021
- manualOverrides: import("@package/databases").OpportunityManualOverride[];
1022
- identifier: string;
1023
- dailyRewards: number;
1024
- tags: string[];
1025
- lastCampaignCreatedAt: Date;
1026
- };
1027
- campaignId: string;
1028
- id: string;
1029
- amount: string;
1030
- type: string;
1031
- computeChainId: number;
1032
- distributionChainId: number;
1033
- opportunityId: string;
1034
- distributionType: import("@package/databases").DistributionType;
1035
- subType: number | null;
1036
- rewardTokenId: string;
1037
- };
1038
- /**
1039
- * @deprecated Used only in tentative position fetcher
1040
- */
1041
- static formatAsCampaignParameters<C extends CampaignType>(campaign: CampaignWithParams): CampaignParameters<C>;
1042
934
  /**
1043
935
  * Shortcut to get daily amount from total
1044
936
  * @param start timestamp
@@ -1059,90 +1059,6 @@ export declare const OpportunityController: Elysia<"/opportunities", {
1059
1059
  };
1060
1060
  };
1061
1061
  };
1062
- } & {
1063
- opportunities: {
1064
- post: {
1065
- body: {
1066
- name?: string | undefined;
1067
- description?: string | undefined;
1068
- depositUrl?: string | undefined;
1069
- explorerAddress?: string | undefined;
1070
- howToSteps?: string[] | undefined;
1071
- tags?: string[] | undefined;
1072
- protocols?: string[] | undefined;
1073
- mainProtocol?: string | undefined;
1074
- tokens: {
1075
- address: string;
1076
- chainId: number;
1077
- }[];
1078
- status: "NONE" | "PAST" | "LIVE" | "SOON";
1079
- chainId: number;
1080
- action: "POOL" | "INVALID" | "HOLD" | "DROP" | "LEND" | "BORROW" | "LONG" | "SHORT" | "SWAP";
1081
- type: string;
1082
- identifier: string;
1083
- };
1084
- params: {};
1085
- query: unknown;
1086
- headers: {
1087
- authorization: string;
1088
- };
1089
- response: {
1090
- 200: {
1091
- Tokens: {
1092
- symbol: string;
1093
- name: string | null;
1094
- decimals: number;
1095
- price: number | null;
1096
- address: string;
1097
- id: string;
1098
- chainId: number;
1099
- icon: string;
1100
- isNative: boolean;
1101
- isPoint: boolean;
1102
- isPreTGE: boolean;
1103
- isTest: boolean;
1104
- verified: boolean;
1105
- displaySymbol: string;
1106
- }[];
1107
- Protocols: {
1108
- name: string;
1109
- description: string;
1110
- id: string;
1111
- url: string;
1112
- icon: string;
1113
- tags: string[];
1114
- }[];
1115
- name: string;
1116
- apr: number;
1117
- tvl: number;
1118
- description: string;
1119
- id: string;
1120
- status: import("@package/databases").Status;
1121
- chainId: number;
1122
- action: import("@package/databases").OpportunityAction;
1123
- type: string;
1124
- depositUrl: string | null;
1125
- explorerAddress: string | null;
1126
- howToSteps: string[];
1127
- mainProtocolId: string | null;
1128
- manualOverrides: import("@package/databases").OpportunityManualOverride[];
1129
- identifier: string;
1130
- dailyRewards: number;
1131
- tags: string[];
1132
- lastCampaignCreatedAt: Date;
1133
- };
1134
- 422: {
1135
- type: "validation";
1136
- on: string;
1137
- summary?: string;
1138
- message?: string;
1139
- found?: unknown;
1140
- property?: string;
1141
- expected?: string;
1142
- };
1143
- };
1144
- };
1145
- };
1146
1062
  } & {
1147
1063
  opportunities: {
1148
1064
  ":id": {
@@ -1,10 +1,6 @@
1
- import { type CampaignParameters, Campaign as CampaignType, type Opportunity as OpportunityV3 } from "@angleprotocol/sdk/ts";
2
- import type { CampaignWithParams } from "../../../modules/v4/campaign/campaign.model";
3
- import { OpportunityService } from "../../../modules/v4/opportunity/opportunity.service";
4
- export declare abstract class OpportunityConvertorService {
1
+ import { type Opportunity as OpportunityV3 } from "@angleprotocol/sdk/ts";
2
+ export declare abstract class OpportunityConvertor {
5
3
  #private;
6
- static convertV4CampaignToV3<C extends CampaignType>(campaignType: C, campaign: Exclude<Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]["campaigns"], undefined>[number] | Omit<CampaignWithParams<C>, "manualOverrides">, opportunityIdentifier: string): CampaignParameters<C>;
7
- static convertV4toV3(opportunity: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number], withCampaigns?: boolean): OpportunityV3;
8
4
  static setV3Opportunities(showCampaigns: boolean, test: boolean | undefined, identifier: string | undefined, chainId: string | undefined): Promise<{
9
5
  [id: `0_${string}`]: OpportunityV3;
10
6
  [id: `1_${string}`]: OpportunityV3;
@@ -0,0 +1,236 @@
1
+ import type { LightOpportunityFromDB } from "./opportunity.model";
2
+ import type { OpportunityRepository } from "./opportunity.repository";
3
+ export declare abstract class OpportunityFormatter {
4
+ static format(opportunity: Awaited<ReturnType<typeof OpportunityRepository.findUniqueOrThrow>>): {
5
+ aprRecord: {
6
+ cumulated: number;
7
+ timestamp: bigint;
8
+ breakdowns: ({
9
+ value: number;
10
+ distributionType: import("@package/databases").DistributionType;
11
+ identifier: string;
12
+ type: "CAMPAIGN";
13
+ } | {
14
+ value: number;
15
+ identifier: string;
16
+ type: import("@package/databases").AprType;
17
+ })[];
18
+ };
19
+ tvlRecord: {
20
+ id: string;
21
+ total: number;
22
+ timestamp: bigint;
23
+ breakdowns: {
24
+ value: number;
25
+ type: import("@package/databases").TvlType;
26
+ identifier: string;
27
+ }[];
28
+ };
29
+ rewardsRecord: {
30
+ id: string;
31
+ total: number;
32
+ timestamp: bigint;
33
+ breakdowns: {
34
+ campaignId: string;
35
+ id: string;
36
+ dailyRewardsRecordId: string;
37
+ token: {
38
+ symbol: string;
39
+ name: string | null;
40
+ decimals: number;
41
+ price: number | null;
42
+ address: string;
43
+ id: string;
44
+ chainId: number;
45
+ icon: string;
46
+ isNative: boolean;
47
+ isPoint: boolean;
48
+ isPreTGE: boolean;
49
+ isTest: boolean;
50
+ verified: boolean;
51
+ displaySymbol: string;
52
+ };
53
+ amount: bigint;
54
+ value: number;
55
+ distributionType: import("@package/databases").DistributionType;
56
+ }[];
57
+ };
58
+ campaigns: {
59
+ params: any;
60
+ chain: {
61
+ name: string;
62
+ id: number;
63
+ icon: string;
64
+ };
65
+ endTimestamp: number;
66
+ startTimestamp: number;
67
+ rewardToken: {
68
+ symbol: string;
69
+ name: string | null;
70
+ decimals: number;
71
+ address: string;
72
+ id: string;
73
+ chainId: number;
74
+ icon: string;
75
+ isNative: boolean;
76
+ isPoint: boolean;
77
+ isPreTGE: boolean;
78
+ isTest: boolean;
79
+ verified: boolean;
80
+ } & {
81
+ price?: number | null | undefined;
82
+ isTokenWrapper?: boolean | undefined;
83
+ tokenWrapperAddress?: string | undefined;
84
+ };
85
+ distributionChain: {
86
+ name: string;
87
+ id: number;
88
+ icon: string;
89
+ } | undefined;
90
+ campaignStatus: {
91
+ computedUntil: number;
92
+ processingStarted: number;
93
+ campaignId: string;
94
+ error: string;
95
+ status: import("@package/databases").RunStatus;
96
+ details: import("@prisma/client/runtime/library").JsonValue;
97
+ } | undefined;
98
+ creatorAddress: string;
99
+ creator: {
100
+ address: string;
101
+ tags: string[];
102
+ creatorId: string | null;
103
+ };
104
+ createdAt: string;
105
+ description: string | undefined;
106
+ parentCampaignId: string | undefined;
107
+ rootCampaignId: string | undefined;
108
+ Opportunity: {
109
+ name: string;
110
+ apr: number;
111
+ tvl: number;
112
+ description: string;
113
+ id: string;
114
+ status: import("@package/databases").Status;
115
+ chainId: number;
116
+ action: import("@package/databases").OpportunityAction;
117
+ type: string;
118
+ depositUrl: string | null;
119
+ explorerAddress: string | null;
120
+ howToSteps: string[];
121
+ mainProtocolId: string | null;
122
+ manualOverrides: import("@package/databases").OpportunityManualOverride[];
123
+ identifier: string;
124
+ dailyRewards: number;
125
+ tags: string[];
126
+ lastCampaignCreatedAt: Date;
127
+ };
128
+ campaignId: string;
129
+ id: string;
130
+ amount: string;
131
+ type: string;
132
+ computeChainId: number;
133
+ distributionChainId: number;
134
+ opportunityId: string;
135
+ distributionType: import("@package/databases").DistributionType;
136
+ subType: number | null;
137
+ rewardTokenId: string;
138
+ }[] | undefined;
139
+ id: string;
140
+ depositUrl: string | undefined;
141
+ explorerAddress: string | undefined;
142
+ lastCampaignCreatedAt: string;
143
+ tokens: ({
144
+ symbol: string;
145
+ name: string | null;
146
+ decimals: number;
147
+ address: string;
148
+ id: string;
149
+ chainId: number;
150
+ icon: string;
151
+ isNative: boolean;
152
+ isPoint: boolean;
153
+ isPreTGE: boolean;
154
+ isTest: boolean;
155
+ verified: boolean;
156
+ } & {
157
+ price?: number | null | undefined;
158
+ isTokenWrapper?: boolean | undefined;
159
+ tokenWrapperAddress?: string | undefined;
160
+ })[];
161
+ chain: {
162
+ name: string;
163
+ id: number;
164
+ icon: string;
165
+ };
166
+ protocol: {
167
+ name: string;
168
+ description: string;
169
+ id: string;
170
+ url: string;
171
+ icon: string;
172
+ tags: string[];
173
+ } | undefined;
174
+ name: string;
175
+ apr: number;
176
+ tvl: number;
177
+ description: string;
178
+ status: import("@package/databases").Status;
179
+ chainId: number;
180
+ action: import("@package/databases").OpportunityAction;
181
+ type: string;
182
+ howToSteps: string[];
183
+ identifier: string;
184
+ dailyRewards: number;
185
+ tags: string[];
186
+ };
187
+ static formatWithoutRecords(opportunity: LightOpportunityFromDB): {
188
+ id: string;
189
+ depositUrl: string | undefined;
190
+ explorerAddress: string | undefined;
191
+ lastCampaignCreatedAt: string;
192
+ tokens: ({
193
+ symbol: string;
194
+ name: string | null;
195
+ decimals: number;
196
+ address: string;
197
+ id: string;
198
+ chainId: number;
199
+ icon: string;
200
+ isNative: boolean;
201
+ isPoint: boolean;
202
+ isPreTGE: boolean;
203
+ isTest: boolean;
204
+ verified: boolean;
205
+ } & {
206
+ price?: number | null | undefined;
207
+ isTokenWrapper?: boolean | undefined;
208
+ tokenWrapperAddress?: string | undefined;
209
+ })[];
210
+ chain: {
211
+ name: string;
212
+ id: number;
213
+ icon: string;
214
+ };
215
+ protocol: {
216
+ name: string;
217
+ description: string;
218
+ id: string;
219
+ url: string;
220
+ icon: string;
221
+ tags: string[];
222
+ } | undefined;
223
+ name: string;
224
+ apr: number;
225
+ tvl: number;
226
+ description: string;
227
+ status: import("@package/databases").Status;
228
+ chainId: number;
229
+ action: import("@package/databases").OpportunityAction;
230
+ type: string;
231
+ howToSteps: string[];
232
+ identifier: string;
233
+ dailyRewards: number;
234
+ tags: string[];
235
+ };
236
+ }
@@ -368,9 +368,7 @@ export declare abstract class OpportunityRepository {
368
368
  lastCampaignCreatedAt: Date;
369
369
  }>;
370
370
  /**
371
- * Gets opportunities and campaigns for which filtered on campaigns
372
- * @param filters
373
- * @returns
371
+ * Gets opportunities and campaigns based on a campaign filter
374
372
  */
375
373
  static findManyByCampaigns(where: Campaign["action"]["findMany"]["args"]["where"]): Promise<({
376
374
  Campaigns: ({
@@ -729,6 +727,7 @@ export declare abstract class OpportunityRepository {
729
727
  tags: string[];
730
728
  lastCampaignCreatedAt: Date;
731
729
  })[]>;
730
+ static countMany(query: GetOpportunitiesQueryModel): Promise<number>;
732
731
  /**
733
732
  * @dev Live campaigns here can be:
734
733
  * 1. Opportunities with status LIVE
@@ -938,7 +937,6 @@ export declare abstract class OpportunityRepository {
938
937
  tags: string[];
939
938
  lastCampaignCreatedAt: Date;
940
939
  })[]>;
941
- static countMany(query: GetOpportunitiesQueryModel): Promise<number>;
942
940
  /**
943
941
  * Updates Apr, Tvl and DailyRewards records
944
942
  * @param opportunityId