@merkl/api 0.17.27 → 0.17.29

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.
@@ -206,6 +206,21 @@ export declare abstract class CampaignService {
206
206
  address: string;
207
207
  creatorId: string | null;
208
208
  };
209
+ Opportunity: {
210
+ name: string;
211
+ type: string;
212
+ id: string;
213
+ status: import("../../../../database/api/.generated").$Enums.Status;
214
+ tags: string[];
215
+ identifier: string;
216
+ chainId: number;
217
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
218
+ depositUrl: string | null;
219
+ mainProtocolId: string | null;
220
+ tvl: number;
221
+ apr: number;
222
+ dailyRewards: number;
223
+ };
209
224
  type: string;
210
225
  id: string;
211
226
  subType: number | null;
@@ -434,6 +449,21 @@ export declare abstract class CampaignService {
434
449
  address: string;
435
450
  creatorId: string | null;
436
451
  };
452
+ Opportunity: {
453
+ name: string;
454
+ type: string;
455
+ id: string;
456
+ status: import("../../../../database/api/.generated").$Enums.Status;
457
+ tags: string[];
458
+ identifier: string;
459
+ chainId: number;
460
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
461
+ depositUrl: string | null;
462
+ mainProtocolId: string | null;
463
+ tvl: number;
464
+ apr: number;
465
+ dailyRewards: number;
466
+ };
437
467
  type: string;
438
468
  id: string;
439
469
  subType: number | null;
@@ -25,7 +25,7 @@ export declare const ClaimController: Elysia<"/claims", false, {
25
25
  headers: unknown;
26
26
  response: {
27
27
  200: (import("./claims.model").ClaimModel & {
28
- token?: Token;
28
+ token?: import("../token/token.model").Token["model"];
29
29
  })[];
30
30
  };
31
31
  };
@@ -1,5 +1,5 @@
1
1
  import type { ChainId } from "@sdk";
2
- import type { Token } from "../token";
2
+ import type { Token } from "../token/token.model";
3
3
  import type { UserUniqueModel } from "../user";
4
4
  import type { ClaimModel } from "./claims.model";
5
5
  export declare abstract class ClaimService {
@@ -217,6 +217,21 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
217
217
  address: string;
218
218
  creatorId: string | null;
219
219
  };
220
+ Opportunity: {
221
+ name: string;
222
+ type: string;
223
+ id: string;
224
+ status: import("../../../../database/api/.generated").$Enums.Status;
225
+ tags: string[];
226
+ identifier: string;
227
+ chainId: number;
228
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
229
+ depositUrl: string | null;
230
+ mainProtocolId: string | null;
231
+ tvl: number;
232
+ apr: number;
233
+ dailyRewards: number;
234
+ };
220
235
  type: string;
221
236
  id: string;
222
237
  subType: number | null;
@@ -421,6 +436,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
421
436
  params: {};
422
437
  query: {
423
438
  type?: string | undefined;
439
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
424
440
  items?: number | undefined;
425
441
  subType?: number | undefined;
426
442
  page?: number | undefined;
@@ -428,6 +444,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
428
444
  startTimestamp?: string | undefined;
429
445
  endTimestamp?: string | undefined;
430
446
  tokenAddress?: string | undefined;
447
+ types?: string[] | undefined;
431
448
  campaignId?: string | undefined;
432
449
  opportunityId?: string | undefined;
433
450
  creatorAddress?: string | undefined;
@@ -435,7 +452,9 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
435
452
  mainParameter?: string | undefined;
436
453
  test?: boolean | undefined;
437
454
  creatorTag?: string | undefined;
455
+ distributionChainIds?: number[] | undefined;
438
456
  tokenSymbol?: string | undefined;
457
+ withOpportunity?: boolean | undefined;
439
458
  };
440
459
  headers: unknown;
441
460
  response: {
@@ -1,8 +1,8 @@
1
- import { type CampaignParameters, type Opportunity as OpportunityV3, type ValidCampaign } from "@sdk";
1
+ import { Campaign as CampaignEnum, type CampaignParameters, type Opportunity as OpportunityV3 } from "@sdk";
2
2
  import { OpportunityService } from "./opportunity.service";
3
3
  export declare abstract class OpportunityConvertorService {
4
4
  #private;
5
- static convertV4CampaignToV3<C extends ValidCampaign>(campaignType: C, campaign: Exclude<Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]["campaigns"], undefined>[number], opportunity: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]): CampaignParameters<C>;
5
+ static convertV4CampaignToV3<C extends CampaignEnum>(campaignType: C, campaign: Exclude<Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]["campaigns"], undefined>[number], opportunityIdentifier: string): CampaignParameters<C>;
6
6
  static convertV4toV3(opportunity: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number], withCampaigns?: boolean): OpportunityV3;
7
7
  static setV3Opportunities(showCampaigns: boolean, test: boolean | undefined, identifier: string | undefined, chainId: string | undefined): Promise<{}>;
8
8
  static logKeyAndTTLV3Opportunities(showCampaigns: boolean, test: boolean | undefined, identifier: string | undefined, chainId: string | undefined): Promise<void>;
@@ -6,7 +6,7 @@ import { CacheService } from "../cache";
6
6
  import { TTLPresets } from "../cache/cache.model";
7
7
  import { OpportunityService } from "./opportunity.service";
8
8
  export class OpportunityConvertorService {
9
- static convertV4CampaignToV3(campaignType, campaign, opportunity) {
9
+ static convertV4CampaignToV3(campaignType, campaign, opportunityIdentifier) {
10
10
  return {
11
11
  amount: campaign.amount.toString(),
12
12
  campaignId: campaign.campaignId,
@@ -17,7 +17,7 @@ export class OpportunityConvertorService {
17
17
  chainId: campaign.distributionChain?.id ?? 0,
18
18
  creator: campaign.creator.address,
19
19
  index: 0, // DEPRECATED
20
- mainParameter: opportunity.identifier,
20
+ mainParameter: opportunityIdentifier,
21
21
  endTimestamp: Number(campaign.endTimestamp),
22
22
  startTimestamp: Number(campaign.startTimestamp),
23
23
  rewardToken: campaign.rewardToken.address,
@@ -122,12 +122,12 @@ export class OpportunityConvertorService {
122
122
  active: withCampaigns
123
123
  ? opportunity.campaigns
124
124
  ?.filter(campaign => campaign.startTimestamp < BigInt(now) && BigInt(now) < campaign.endTimestamp)
125
- .map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], campaign, opportunity))
125
+ .map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], campaign, opportunity.identifier))
126
126
  : undefined,
127
127
  inactive: withCampaigns
128
128
  ? opportunity.campaigns
129
129
  ?.filter(campaign => !(campaign.startTimestamp < BigInt(now) && BigInt(now) < campaign.endTimestamp))
130
- .map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], campaign, opportunity))
130
+ .map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], campaign, opportunity.identifier))
131
131
  : undefined,
132
132
  },
133
133
  };
@@ -504,6 +504,21 @@ export declare abstract class OpportunityService {
504
504
  address: string;
505
505
  creatorId: string | null;
506
506
  };
507
+ Opportunity: {
508
+ name: string;
509
+ type: string;
510
+ id: string;
511
+ status: import("../../../../database/api/.generated").$Enums.Status;
512
+ tags: string[];
513
+ identifier: string;
514
+ chainId: number;
515
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
516
+ depositUrl: string | null;
517
+ mainProtocolId: string | null;
518
+ tvl: number;
519
+ apr: number;
520
+ dailyRewards: number;
521
+ };
507
522
  type: string;
508
523
  id: string;
509
524
  subType: number | null;
@@ -651,6 +666,21 @@ export declare abstract class OpportunityService {
651
666
  address: string;
652
667
  creatorId: string | null;
653
668
  };
669
+ Opportunity: {
670
+ name: string;
671
+ type: string;
672
+ id: string;
673
+ status: import("../../../../database/api/.generated").$Enums.Status;
674
+ tags: string[];
675
+ identifier: string;
676
+ chainId: number;
677
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
678
+ depositUrl: string | null;
679
+ mainProtocolId: string | null;
680
+ tvl: number;
681
+ apr: number;
682
+ dailyRewards: number;
683
+ };
654
684
  type: string;
655
685
  id: string;
656
686
  subType: number | null;
@@ -794,6 +824,21 @@ export declare abstract class OpportunityService {
794
824
  address: string;
795
825
  creatorId: string | null;
796
826
  };
827
+ Opportunity: {
828
+ name: string;
829
+ type: string;
830
+ id: string;
831
+ status: import("../../../../database/api/.generated").$Enums.Status;
832
+ tags: string[];
833
+ identifier: string;
834
+ chainId: number;
835
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
836
+ depositUrl: string | null;
837
+ mainProtocolId: string | null;
838
+ tvl: number;
839
+ apr: number;
840
+ dailyRewards: number;
841
+ };
797
842
  type: string;
798
843
  id: string;
799
844
  subType: number | null;
@@ -5157,7 +5157,7 @@ const PufferInterfaceCampaigns = {
5157
5157
  hooks: [],
5158
5158
  targetToken: "0x4d1C297d39C5c1277964D0E3f8Aa901493664530",
5159
5159
  whitelist: ["0xA55eD5808aeCDF23AE3782C1443185f5D2363ce7"],
5160
- blacklist: [],
5160
+ blacklist: ["0x5be7e720e32145116f9fdcf15d709efcf66fc6e3"],
5161
5161
  url: "https://vote.puffer.fi/plugins/stake/#/",
5162
5162
  forwarders: [
5163
5163
  {
@@ -232,6 +232,21 @@ export declare const v4: Elysia<"/v4", false, {
232
232
  address: string;
233
233
  creatorId: string | null;
234
234
  };
235
+ Opportunity: {
236
+ name: string;
237
+ type: string;
238
+ id: string;
239
+ status: import("../../../database/api/.generated").$Enums.Status;
240
+ tags: string[];
241
+ identifier: string;
242
+ chainId: number;
243
+ action: import("../../../database/api/.generated").$Enums.OpportunityAction;
244
+ depositUrl: string | null;
245
+ mainProtocolId: string | null;
246
+ tvl: number;
247
+ apr: number;
248
+ dailyRewards: number;
249
+ };
235
250
  type: string;
236
251
  id: string;
237
252
  subType: number | null;
@@ -436,6 +451,7 @@ export declare const v4: Elysia<"/v4", false, {
436
451
  params: {};
437
452
  query: {
438
453
  type?: string | undefined;
454
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
439
455
  items?: number | undefined;
440
456
  subType?: number | undefined;
441
457
  page?: number | undefined;
@@ -443,6 +459,7 @@ export declare const v4: Elysia<"/v4", false, {
443
459
  startTimestamp?: string | undefined;
444
460
  endTimestamp?: string | undefined;
445
461
  tokenAddress?: string | undefined;
462
+ types?: string[] | undefined;
446
463
  campaignId?: string | undefined;
447
464
  opportunityId?: string | undefined;
448
465
  creatorAddress?: string | undefined;
@@ -450,7 +467,9 @@ export declare const v4: Elysia<"/v4", false, {
450
467
  mainParameter?: string | undefined;
451
468
  test?: boolean | undefined;
452
469
  creatorTag?: string | undefined;
470
+ distributionChainIds?: number[] | undefined;
453
471
  tokenSymbol?: string | undefined;
472
+ withOpportunity?: boolean | undefined;
454
473
  };
455
474
  headers: unknown;
456
475
  response: {
@@ -1078,6 +1097,7 @@ export declare const v4: Elysia<"/v4", false, {
1078
1097
  params: {};
1079
1098
  query: {
1080
1099
  type?: string | undefined;
1100
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
1081
1101
  items?: number | undefined;
1082
1102
  subType?: number | undefined;
1083
1103
  page?: number | undefined;
@@ -1085,6 +1105,7 @@ export declare const v4: Elysia<"/v4", false, {
1085
1105
  startTimestamp?: string | undefined;
1086
1106
  endTimestamp?: string | undefined;
1087
1107
  tokenAddress?: string | undefined;
1108
+ types?: string[] | undefined;
1088
1109
  campaignId?: string | undefined;
1089
1110
  opportunityId?: string | undefined;
1090
1111
  creatorAddress?: string | undefined;
@@ -1092,7 +1113,9 @@ export declare const v4: Elysia<"/v4", false, {
1092
1113
  mainParameter?: string | undefined;
1093
1114
  test?: boolean | undefined;
1094
1115
  creatorTag?: string | undefined;
1116
+ distributionChainIds?: number[] | undefined;
1095
1117
  tokenSymbol?: string | undefined;
1118
+ withOpportunity?: boolean | undefined;
1096
1119
  };
1097
1120
  headers: unknown;
1098
1121
  response: {
@@ -1137,6 +1160,21 @@ export declare const v4: Elysia<"/v4", false, {
1137
1160
  address: string;
1138
1161
  creatorId: string | null;
1139
1162
  };
1163
+ Opportunity: {
1164
+ name: string;
1165
+ type: string;
1166
+ id: string;
1167
+ status: import("../../../database/api/.generated").$Enums.Status;
1168
+ tags: string[];
1169
+ identifier: string;
1170
+ chainId: number;
1171
+ action: import("../../../database/api/.generated").$Enums.OpportunityAction;
1172
+ depositUrl: string | null;
1173
+ mainProtocolId: string | null;
1174
+ tvl: number;
1175
+ apr: number;
1176
+ dailyRewards: number;
1177
+ };
1140
1178
  type: string;
1141
1179
  id: string;
1142
1180
  subType: number | null;
@@ -1202,6 +1240,21 @@ export declare const v4: Elysia<"/v4", false, {
1202
1240
  address: string;
1203
1241
  creatorId: string | null;
1204
1242
  };
1243
+ Opportunity: {
1244
+ name: string;
1245
+ type: string;
1246
+ id: string;
1247
+ status: import("../../../database/api/.generated").$Enums.Status;
1248
+ tags: string[];
1249
+ identifier: string;
1250
+ chainId: number;
1251
+ action: import("../../../database/api/.generated").$Enums.OpportunityAction;
1252
+ depositUrl: string | null;
1253
+ mainProtocolId: string | null;
1254
+ tvl: number;
1255
+ apr: number;
1256
+ dailyRewards: number;
1257
+ };
1205
1258
  type: string;
1206
1259
  id: string;
1207
1260
  subType: number | null;
@@ -1223,6 +1276,7 @@ export declare const v4: Elysia<"/v4", false, {
1223
1276
  params: {};
1224
1277
  query: {
1225
1278
  type?: string | undefined;
1279
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
1226
1280
  items?: number | undefined;
1227
1281
  subType?: number | undefined;
1228
1282
  page?: number | undefined;
@@ -1230,6 +1284,7 @@ export declare const v4: Elysia<"/v4", false, {
1230
1284
  startTimestamp?: string | undefined;
1231
1285
  endTimestamp?: string | undefined;
1232
1286
  tokenAddress?: string | undefined;
1287
+ types?: string[] | undefined;
1233
1288
  campaignId?: string | undefined;
1234
1289
  opportunityId?: string | undefined;
1235
1290
  creatorAddress?: string | undefined;
@@ -1237,7 +1292,9 @@ export declare const v4: Elysia<"/v4", false, {
1237
1292
  mainParameter?: string | undefined;
1238
1293
  test?: boolean | undefined;
1239
1294
  creatorTag?: string | undefined;
1295
+ distributionChainIds?: number[] | undefined;
1240
1296
  tokenSymbol?: string | undefined;
1297
+ withOpportunity?: boolean | undefined;
1241
1298
  };
1242
1299
  headers: unknown;
1243
1300
  response: {
@@ -3485,7 +3542,7 @@ export declare const v4: Elysia<"/v4", false, {
3485
3542
  headers: unknown;
3486
3543
  response: {
3487
3544
  200: (import("./claims").ClaimModel & {
3488
- token?: Token;
3545
+ token?: import("./token/token.model").Token["model"];
3489
3546
  })[];
3490
3547
  };
3491
3548
  };
@@ -7,6 +7,14 @@ export declare const query: import("@sinclair/typebox").TObject<{
7
7
  hideTestTokens: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
8
8
  }>;
9
9
  export declare const response: import("@sinclair/typebox").TObject<{}>;
10
+ /**
11
+ * @deprecated - conversion to v4 done
12
+ *
13
+ * @dev there was a significant loss of information with the v4 conversion
14
+ * So some issues are expected
15
+ *
16
+ * v3 was returning a whole bunch of dynamic data when the v4 only has tvl and apr
17
+ */
10
18
  declare const _default: (app: Elysia) => Elysia<"", false, {
11
19
  decorator: {};
12
20
  store: {};
@@ -1,7 +1,9 @@
1
1
  import { Redis } from "../../cache";
2
2
  import { removeTestTokens } from "../../entities/campaign";
3
+ import { CampaignService } from "../../modules/v4/campaign";
4
+ import { OpportunityConvertorService } from "../../modules/v4/opportunity/opportunity.converter";
3
5
  import param from "../../types/parameters";
4
- import { ANGLE_NETWORKS, ChainId, isSupportedChain, registry, } from "@sdk";
6
+ import { ANGLE_NETWORKS, Campaign as CampaignEnum, ChainId, isSupportedChain, registry, } from "@sdk";
5
7
  import { t } from "elysia";
6
8
  import { UnsupportedNetwork } from "../../utils/error";
7
9
  export const query = t.Object({
@@ -21,6 +23,14 @@ export const response = t.Record(t.Union(ANGLE_NETWORKS.merkl.map(chain => t.Lit
21
23
  campaignParameters: t.Object({}),
22
24
  campaignType: param.Type.type,
23
25
  })))));
26
+ /**
27
+ * @deprecated - conversion to v4 done
28
+ *
29
+ * @dev there was a significant loss of information with the v4 conversion
30
+ * So some issues are expected
31
+ *
32
+ * v3 was returning a whole bunch of dynamic data when the v4 only has tvl and apr
33
+ */
24
34
  export default (app) => app.get("/campaigns", async ({ query }) => {
25
35
  let hideTestTokens = false;
26
36
  if (typeof query.hideTestTokens === "string" && query.hideTestTokens === "true") {
@@ -61,6 +71,32 @@ export default (app) => app.get("/campaigns", async ({ query }) => {
61
71
  throw new UnsupportedNetwork(chainId);
62
72
  }
63
73
  }
74
+ if (process.env.FF_OPPORTUNITY === "true") {
75
+ const campaigns = await CampaignService.findMany({
76
+ distributionChainIds: chainIds,
77
+ types: types.map(type => CampaignEnum[type]),
78
+ status: query.live ? "LIVE" : undefined,
79
+ creatorTag: query.creatorTag,
80
+ test: !hideTestTokens,
81
+ withOpportunity: true,
82
+ });
83
+ const res = {};
84
+ for (const campaign of campaigns) {
85
+ if (!res[campaign.distributionChainId]) {
86
+ res[campaign.distributionChainId] = {};
87
+ }
88
+ const opportunityIdentifier = campaign.Opportunity.identifier;
89
+ const campaignType = CampaignEnum[campaign.type];
90
+ if (!res[campaign.distributionChainId][`${campaignType}_${opportunityIdentifier}`]) {
91
+ res[campaign.distributionChainId][`${campaignType}_${opportunityIdentifier}`] = {
92
+ ...OpportunityConvertorService.convertV4CampaignToV3(campaignType, campaign, opportunityIdentifier),
93
+ apr: campaign.Opportunity.apr,
94
+ tvl: campaign.Opportunity.tvl,
95
+ };
96
+ }
97
+ }
98
+ return res;
99
+ }
64
100
  const campaignCachePrefix = query.live === true ? "LiveCampaigns" : "Campaigns";
65
101
  const dynamicData = (await Redis.getManyWithArgs(campaignCachePrefix, chainIds)).reduce((prev, allData, index) => {
66
102
  if (!!allData) {