@merkl/api 0.10.253 → 0.10.255

Sign up to get free protection for your applications and to get access to all the features.
@@ -107,7 +107,7 @@ declare const eden: {
107
107
  200: {
108
108
  id: string;
109
109
  chainId: number;
110
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
110
+ type: import("../../database/api/.generated").$Enums.CampaignType;
111
111
  identifier: string;
112
112
  name: string;
113
113
  status: "PAST" | "LIVE" | "SOON";
@@ -593,12 +593,12 @@ declare const eden: {
593
593
  }) & {};
594
594
  };
595
595
  campaigns: {
596
- index: {
596
+ engine: {
597
597
  post: (body: {
598
598
  tags?: string[] | undefined;
599
599
  identifier?: string | undefined;
600
600
  subType?: number | undefined;
601
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
601
+ type: number;
602
602
  params: string;
603
603
  creator: string;
604
604
  chainId: number;
@@ -632,6 +632,8 @@ declare const eden: {
632
632
  creatorAddress: string;
633
633
  } | undefined;
634
634
  }>>;
635
+ };
636
+ index: {
635
637
  get: (options: {
636
638
  headers?: Record<string, unknown> | undefined;
637
639
  query: {
@@ -2970,7 +2972,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
2970
2972
  200: {
2971
2973
  id: string;
2972
2974
  chainId: number;
2973
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
2975
+ type: import("../../database/api/.generated").$Enums.CampaignType;
2974
2976
  identifier: string;
2975
2977
  name: string;
2976
2978
  status: "PAST" | "LIVE" | "SOON";
@@ -3480,13 +3482,13 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3480
3482
  } & {
3481
3483
  v4: {
3482
3484
  campaigns: {
3483
- index: {
3485
+ engine: {
3484
3486
  post: {
3485
3487
  body: {
3486
3488
  tags?: string[] | undefined;
3487
3489
  identifier?: string | undefined;
3488
3490
  subType?: number | undefined;
3489
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
3491
+ type: number;
3490
3492
  params: string;
3491
3493
  creator: string;
3492
3494
  chainId: number;
@@ -6386,7 +6388,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6386
6388
  200: {
6387
6389
  id: string;
6388
6390
  chainId: number;
6389
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
6391
+ type: import("../../database/api/.generated").$Enums.CampaignType;
6390
6392
  identifier: string;
6391
6393
  name: string;
6392
6394
  status: "PAST" | "LIVE" | "SOON";
@@ -6872,12 +6874,12 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6872
6874
  }) & {};
6873
6875
  };
6874
6876
  campaigns: {
6875
- index: {
6877
+ engine: {
6876
6878
  post: (body: {
6877
6879
  tags?: string[] | undefined;
6878
6880
  identifier?: string | undefined;
6879
6881
  subType?: number | undefined;
6880
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
6882
+ type: number;
6881
6883
  params: string;
6882
6884
  creator: string;
6883
6885
  chainId: number;
@@ -6911,6 +6913,8 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6911
6913
  creatorAddress: string;
6912
6914
  } | undefined;
6913
6915
  }>>;
6916
+ };
6917
+ index: {
6914
6918
  get: (options: {
6915
6919
  headers?: Record<string, unknown> | undefined;
6916
6920
  query: {
@@ -189,7 +189,7 @@ declare const app: Elysia<"", false, {
189
189
  200: {
190
190
  id: string;
191
191
  chainId: number;
192
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
192
+ type: import("../database/api/.generated").$Enums.CampaignType;
193
193
  identifier: string;
194
194
  name: string;
195
195
  status: "PAST" | "LIVE" | "SOON";
@@ -699,13 +699,13 @@ declare const app: Elysia<"", false, {
699
699
  } & {
700
700
  v4: {
701
701
  campaigns: {
702
- index: {
702
+ engine: {
703
703
  post: {
704
704
  body: {
705
705
  tags?: string[] | undefined;
706
706
  identifier?: string | undefined;
707
707
  subType?: number | undefined;
708
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
708
+ type: number;
709
709
  params: string;
710
710
  creator: string;
711
711
  chainId: number;
@@ -13,13 +13,13 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
13
13
  macroFn: {};
14
14
  }, {
15
15
  campaigns: {
16
- index: {
16
+ engine: {
17
17
  post: {
18
18
  body: {
19
19
  tags?: string[] | undefined;
20
20
  identifier?: string | undefined;
21
21
  subType?: number | undefined;
22
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
22
+ type: number;
23
23
  params: string;
24
24
  creator: string;
25
25
  chainId: number;
@@ -7,7 +7,7 @@ import { CampaignService } from "./campaign.service";
7
7
  // ─── Campaigns Controller ────────────────────────────────────────────────────
8
8
  export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { tags: ["Campaigns"] } })
9
9
  // ─── Create A Campaign ───────────────────────────────────────────────
10
- .post("/", async ({ body }) => await CampaignService.create(body), {
10
+ .post("/engine", async ({ body }) => await CampaignService.create(body), {
11
11
  beforeHandle: EngineGuard,
12
12
  headers: AuthorizationHeadersDto,
13
13
  body: CreateCampaignDto,
@@ -92,24 +92,7 @@ export declare const CreateCampaignDto: import("@sinclair/typebox").TObject<{
92
92
  campaignId: import("@sinclair/typebox").TString;
93
93
  identifier: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
94
94
  creator: import("@sinclair/typebox").TString;
95
- type: import("@sinclair/typebox").TEnum<{
96
- INVALID: "INVALID";
97
- ERC20: "ERC20";
98
- CLAMM: "CLAMM";
99
- ERC20_SNAPSHOT: "ERC20_SNAPSHOT";
100
- JSON_AIRDROP: "JSON_AIRDROP";
101
- SILO: "SILO";
102
- RADIANT: "RADIANT";
103
- MORPHO: "MORPHO";
104
- DOLOMITE: "DOLOMITE";
105
- BADGER: "BADGER";
106
- COMPOUND: "COMPOUND";
107
- AJNA: "AJNA";
108
- EULER: "EULER";
109
- UNISWAP_V4: "UNISWAP_V4";
110
- ION: "ION";
111
- EIGENLAYER: "EIGENLAYER";
112
- }>;
95
+ type: import("@sinclair/typebox").TNumber;
113
96
  subType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
114
97
  rewardTokenAddress: import("@sinclair/typebox").TString;
115
98
  amount: import("@sinclair/typebox").TString;
@@ -53,7 +53,7 @@ export const CreateCampaignDto = t.Object({
53
53
  campaignId: t.String(),
54
54
  identifier: t.Optional(t.String()),
55
55
  creator: t.String(),
56
- type: t.Enum(CampaignType),
56
+ type: t.Numeric(),
57
57
  subType: t.Optional(t.Number()),
58
58
  rewardTokenAddress: t.String(),
59
59
  amount: t.String(),
@@ -44,6 +44,7 @@ export class CampaignRepository {
44
44
  }
45
45
  // ─── Public Methods ──────────────────────────────────────────────────
46
46
  static async upsert(campaign) {
47
+ const campaignType = CampaignService.getTypeFromV3(campaign.type);
47
48
  try {
48
49
  const [rewardToken] = await TokenService.getManyOrCreate([
49
50
  { chainId: campaign.chainId, address: campaign.rewardTokenAddress },
@@ -55,7 +56,7 @@ export class CampaignRepository {
55
56
  const opportunityId = OpportunityService.hashId({
56
57
  chainId: campaign.computeChainId,
57
58
  identifier: campaign.opportunityIdentifier,
58
- type: campaign.type,
59
+ type: campaignType,
59
60
  });
60
61
  const data = {
61
62
  id: campaign.id,
@@ -64,7 +65,7 @@ export class CampaignRepository {
64
65
  endTimestamp: BigInt(campaign.endTimestamp),
65
66
  params,
66
67
  startTimestamp: BigInt(campaign.startTimestamp),
67
- type: campaign.type,
68
+ type: campaignType,
68
69
  ComputeChain: {
69
70
  connect: {
70
71
  id: campaign.computeChainId,
@@ -100,6 +101,7 @@ export class CampaignRepository {
100
101
  }
101
102
  }
102
103
  static async upsertMany(campaigns) {
104
+ const campaignType = CampaignService.getTypeFromV3(campaigns[0].type);
103
105
  const data = [];
104
106
  for (const campaign of campaigns) {
105
107
  const [rewardToken] = await TokenService.getManyOrCreate([
@@ -108,7 +110,7 @@ export class CampaignRepository {
108
110
  const opportunityId = OpportunityService.hashId({
109
111
  chainId: campaign.computeChainId,
110
112
  identifier: campaign.opportunityIdentifier,
111
- type: campaign.type,
113
+ type: campaignType,
112
114
  });
113
115
  data.push({
114
116
  id: campaign.id,
@@ -117,7 +119,7 @@ export class CampaignRepository {
117
119
  endTimestamp: BigInt(campaign.endTimestamp),
118
120
  params: JSON.parse(campaign.params),
119
121
  startTimestamp: BigInt(campaign.startTimestamp),
120
- type: campaign.type,
122
+ type: campaignType,
121
123
  ComputeChain: {
122
124
  connect: {
123
125
  id: campaign.computeChainId,
@@ -106,7 +106,7 @@ export class CampaignService {
106
106
  params: JSON.stringify(campaign.campaignParameters),
107
107
  rewardTokenAddress: campaign.rewardToken,
108
108
  startTimestamp: campaign.startTimestamp.toString(),
109
- type: CampaignService.getTypeFromV3(campaign.campaignType),
109
+ type: campaign.campaignType,
110
110
  subType: campaign.campaignSubType,
111
111
  };
112
112
  }));
@@ -58,7 +58,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
58
58
  200: {
59
59
  id: string;
60
60
  chainId: number;
61
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
61
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
62
62
  identifier: string;
63
63
  name: string;
64
64
  status: "PAST" | "LIVE" | "SOON";
@@ -14,7 +14,7 @@ export declare abstract class OpportunityService {
14
14
  static createFromCampaign(campaign: Omit<CreateCampaignModel, "id">): Promise<{
15
15
  id: string;
16
16
  chainId: number;
17
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
17
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
18
18
  identifier: string;
19
19
  name: string;
20
20
  status: "PAST" | "LIVE" | "SOON";
@@ -42,7 +42,7 @@ export declare abstract class OpportunityService {
42
42
  static recreate(opportunityId: string | OpportunityUnique): Promise<{
43
43
  id: string;
44
44
  chainId: number;
45
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
45
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
46
46
  identifier: string;
47
47
  name: string;
48
48
  status: "PAST" | "LIVE" | "SOON";
@@ -1,5 +1,5 @@
1
1
  import { NotFoundError } from "../../../errors";
2
- import { CampaignService } from "../campaign";
2
+ import { CampaignService, campaignTypeToEnumMap } from "../campaign";
3
3
  import { log } from "../../../utils/logger";
4
4
  import { OpportunityAction, Prisma, Status } from "../../../../database/api/.generated";
5
5
  import { record } from "@elysiajs/opentelemetry";
@@ -35,19 +35,20 @@ export class OpportunityService {
35
35
  return await OpportunityRepository.upsert({ ...newOpp, id });
36
36
  }
37
37
  static async createFromCampaign(campaign) {
38
+ const campaignType = CampaignService.getTypeFromV3(campaign.type);
38
39
  const metadata = await OpportunityService.getMetadata(campaign);
39
40
  metadata.tags = [...((await UserService.findUnique(campaign.creator))?.tags ?? []), ...(campaign?.tags ?? [])];
40
41
  const opportunityId = OpportunityService.hashId({
41
42
  chainId: campaign.computeChainId,
42
43
  identifier: campaign.opportunityIdentifier,
43
- type: campaign.type,
44
+ type: campaignType,
44
45
  });
45
46
  const tokens = (await TokenService.getManyOrCreate(metadata.tokens)).filter(t => t !== undefined);
46
47
  const params = JSON.parse(campaign.params);
47
48
  const opportunity = {
48
49
  id: opportunityId,
49
50
  chainId: campaign.computeChainId,
50
- type: campaign.type,
51
+ type: campaignType,
51
52
  identifier: campaign.opportunityIdentifier, // mainParameter
52
53
  name: metadata.name,
53
54
  status: +campaign.startTimestamp >= new Date().getTime() * 1000
@@ -75,6 +76,7 @@ export class OpportunityService {
75
76
  const firstCampaign = opportunity?.Campaigns[0];
76
77
  return await OpportunityService.createFromCampaign({
77
78
  ...firstCampaign,
79
+ type: campaignTypeToEnumMap[firstCampaign.type],
78
80
  chainId: firstCampaign.distributionChainId,
79
81
  creator: firstCampaign.creatorAddress,
80
82
  rewardTokenAddress: firstCampaign.RewardToken.address,
@@ -91,9 +93,10 @@ export class OpportunityService {
91
93
  * @returns {OpportunityMetadata}
92
94
  */
93
95
  static async getMetadata(campaign) {
96
+ const campaignType = CampaignService.getTypeFromV3(campaign.type);
94
97
  const campaignParams = JSON.parse(campaign.params);
95
98
  const chainId = campaign.computeChainId === 0 ? campaign.chainId : campaign.computeChainId;
96
- switch (campaign.type) {
99
+ switch (campaignType) {
97
100
  case "CLAMM":
98
101
  return getClammMetadata(chainId, campaignParams);
99
102
  case "ERC20":
@@ -43,6 +43,15 @@ export const getErc20Metadata = async (chainId, campaignId, rewardToken, amount,
43
43
  tokens.push({ chainId, address: dynamicData.typeInfo.token0 });
44
44
  tokens.push({ chainId, address: dynamicData.typeInfo.token1 });
45
45
  }
46
+ // Case of tripools
47
+ if (!!dynamicData &&
48
+ !!dynamicData.typeInfo?.token0Address &&
49
+ !!dynamicData.typeInfo?.token1Address &&
50
+ !!dynamicData.typeInfo?.token2Address) {
51
+ tokens.push({ chainId, address: dynamicData.typeInfo.token0Address });
52
+ tokens.push({ chainId, address: dynamicData.typeInfo.token1Address });
53
+ tokens.push({ chainId, address: dynamicData.typeInfo.token2Address });
54
+ }
46
55
  }
47
56
  catch {
48
57
  log.warn(`failed to fetch dynamic data for ERC20 campaign ${campaignId}`);
@@ -67,7 +67,7 @@ export declare const v4: Elysia<"/v4", false, {
67
67
  200: {
68
68
  id: string;
69
69
  chainId: number;
70
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
70
+ type: import("../../../database/api/.generated").$Enums.CampaignType;
71
71
  identifier: string;
72
72
  name: string;
73
73
  status: "PAST" | "LIVE" | "SOON";
@@ -577,13 +577,13 @@ export declare const v4: Elysia<"/v4", false, {
577
577
  } & {
578
578
  v4: {
579
579
  campaigns: {
580
- index: {
580
+ engine: {
581
581
  post: {
582
582
  body: {
583
583
  tags?: string[] | undefined;
584
584
  identifier?: string | undefined;
585
585
  subType?: number | undefined;
586
- type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
586
+ type: number;
587
587
  params: string;
588
588
  creator: string;
589
589
  chainId: number;