@merkl/api 0.10.252 → 0.10.253

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 (23) hide show
  1. package/dist/src/eden/index.d.ts +123 -9
  2. package/dist/src/index.d.ts +47 -3
  3. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/RfxProcessor.js +1 -0
  4. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +1 -1
  5. package/dist/src/modules/v4/campaign/campaign.model.d.ts +18 -1
  6. package/dist/src/modules/v4/campaign/campaign.model.js +1 -1
  7. package/dist/src/modules/v4/campaign/campaign.repository.d.ts +2 -3
  8. package/dist/src/modules/v4/campaign/campaign.repository.js +9 -70
  9. package/dist/src/modules/v4/campaign/campaign.service.js +6 -23
  10. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +46 -2
  11. package/dist/src/modules/v4/opportunity/opportunity.controller.js +23 -0
  12. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +4 -2
  13. package/dist/src/modules/v4/opportunity/opportunity.model.js +4 -2
  14. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +148 -1
  15. package/dist/src/modules/v4/opportunity/opportunity.repository.js +45 -25
  16. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +54 -1
  17. package/dist/src/modules/v4/opportunity/opportunity.service.js +55 -4
  18. package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.js +1 -1
  19. package/dist/src/modules/v4/opportunity/subservices/getErc20Metadata.service.js +31 -50
  20. package/dist/src/modules/v4/router.d.ts +47 -3
  21. package/dist/src/utils/generateCardName.js +1 -1
  22. package/dist/tsconfig.package.tsbuildinfo +1 -1
  23. package/package.json +1 -1
@@ -97,6 +97,39 @@ declare const eden: {
97
97
  opportunities: ((params: {
98
98
  id: string | number;
99
99
  }) => {
100
+ post: (body: unknown, options: {
101
+ headers: {
102
+ authorization: string;
103
+ };
104
+ query?: Record<string, unknown> | undefined;
105
+ fetch?: RequestInit | undefined;
106
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
107
+ 200: {
108
+ id: string;
109
+ chainId: number;
110
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
111
+ identifier: string;
112
+ name: string;
113
+ status: "PAST" | "LIVE" | "SOON";
114
+ action: import("../../database/api/.generated").$Enums.OpportunityAction;
115
+ tokens: ({
116
+ symbol: string;
117
+ name: string | null;
118
+ id: string;
119
+ icon: string;
120
+ chainId: number;
121
+ address: string;
122
+ decimals: number;
123
+ verified: boolean;
124
+ isTest: boolean;
125
+ } & {
126
+ price?: number | null | undefined;
127
+ })[];
128
+ mainProtocol: "morpho" | "aura" | "poolside" | "gearbox" | "fluid" | "compound" | "ionic" | "layerbank" | "moonwell" | "fenix" | "syncswap" | "beefy" | "aerodrome" | "velodrome" | "curve" | "akron" | "dragonswap" | "koi" | "baseswap" | "zkswap" | "rfx" | "woofi" | "zkSwapThreePool" | "venus" | "reactor_fusion" | "balancer" | "aave" | "arthswap" | "camelot" | "crust" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "supswap-v3" | "thirdtrade" | "uniswap-v2" | "syncswap-v3" | "neptune" | "radiant" | "euler" | "sturdy" | "frax" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "ion" | "eigenlayer" | undefined;
129
+ depositUrl: any;
130
+ tags: string[];
131
+ };
132
+ }>>;
100
133
  get: (options?: {
101
134
  headers?: Record<string, unknown> | undefined;
102
135
  query?: Record<string, unknown> | undefined;
@@ -374,6 +407,10 @@ declare const eden: {
374
407
  index: {
375
408
  post: (body: {
376
409
  name?: string | undefined;
410
+ tags?: string[] | undefined;
411
+ depositUrl?: string | undefined;
412
+ protocols?: string[] | undefined;
413
+ mainProtocol?: string | undefined;
377
414
  type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
378
415
  tokens: {
379
416
  chainId: number;
@@ -383,8 +420,6 @@ declare const eden: {
383
420
  identifier: string;
384
421
  chainId: number;
385
422
  action: "INVALID" | "POOL" | "HOLD" | "DROP" | "LEND" | "BORROW";
386
- protocols: string[];
387
- mainProtocol: string;
388
423
  }, options: {
389
424
  headers: {
390
425
  authorization: string;
@@ -563,7 +598,7 @@ declare const eden: {
563
598
  tags?: string[] | undefined;
564
599
  identifier?: string | undefined;
565
600
  subType?: number | undefined;
566
- type: number;
601
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
567
602
  params: string;
568
603
  creator: string;
569
604
  chainId: number;
@@ -2894,6 +2929,10 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
2894
2929
  post: {
2895
2930
  body: {
2896
2931
  name?: string | undefined;
2932
+ tags?: string[] | undefined;
2933
+ depositUrl?: string | undefined;
2934
+ protocols?: string[] | undefined;
2935
+ mainProtocol?: string | undefined;
2897
2936
  type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
2898
2937
  tokens: {
2899
2938
  chainId: number;
@@ -2903,8 +2942,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
2903
2942
  identifier: string;
2904
2943
  chainId: number;
2905
2944
  action: "INVALID" | "POOL" | "HOLD" | "DROP" | "LEND" | "BORROW";
2906
- protocols: string[];
2907
- mainProtocol: string;
2908
2945
  };
2909
2946
  params: {};
2910
2947
  query: unknown;
@@ -2917,6 +2954,48 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
2917
2954
  };
2918
2955
  };
2919
2956
  };
2957
+ } & {
2958
+ opportunities: {
2959
+ ":id": {
2960
+ post: {
2961
+ body: unknown;
2962
+ params: {
2963
+ id: string;
2964
+ };
2965
+ query: unknown;
2966
+ headers: {
2967
+ authorization: string;
2968
+ };
2969
+ response: {
2970
+ 200: {
2971
+ id: string;
2972
+ chainId: number;
2973
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
2974
+ identifier: string;
2975
+ name: string;
2976
+ status: "PAST" | "LIVE" | "SOON";
2977
+ action: import("../../database/api/.generated").$Enums.OpportunityAction;
2978
+ tokens: ({
2979
+ symbol: string;
2980
+ name: string | null;
2981
+ id: string;
2982
+ icon: string;
2983
+ chainId: number;
2984
+ address: string;
2985
+ decimals: number;
2986
+ verified: boolean;
2987
+ isTest: boolean;
2988
+ } & {
2989
+ price?: number | null | undefined;
2990
+ })[];
2991
+ mainProtocol: "morpho" | "aura" | "poolside" | "gearbox" | "fluid" | "compound" | "ionic" | "layerbank" | "moonwell" | "fenix" | "syncswap" | "beefy" | "aerodrome" | "velodrome" | "curve" | "akron" | "dragonswap" | "koi" | "baseswap" | "zkswap" | "rfx" | "woofi" | "zkSwapThreePool" | "venus" | "reactor_fusion" | "balancer" | "aave" | "arthswap" | "camelot" | "crust" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "supswap-v3" | "thirdtrade" | "uniswap-v2" | "syncswap-v3" | "neptune" | "radiant" | "euler" | "sturdy" | "frax" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "ion" | "eigenlayer" | undefined;
2992
+ depositUrl: any;
2993
+ tags: string[];
2994
+ };
2995
+ };
2996
+ };
2997
+ };
2998
+ };
2920
2999
  } & {
2921
3000
  opportunities: {
2922
3001
  index: {
@@ -3407,7 +3486,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3407
3486
  tags?: string[] | undefined;
3408
3487
  identifier?: string | undefined;
3409
3488
  subType?: number | undefined;
3410
- type: number;
3489
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
3411
3490
  params: string;
3412
3491
  creator: string;
3413
3492
  chainId: number;
@@ -6297,6 +6376,39 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6297
6376
  opportunities: ((params: {
6298
6377
  id: string | number;
6299
6378
  }) => {
6379
+ post: (body: unknown, options: {
6380
+ headers: {
6381
+ authorization: string;
6382
+ };
6383
+ query?: Record<string, unknown> | undefined;
6384
+ fetch?: RequestInit | undefined;
6385
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
6386
+ 200: {
6387
+ id: string;
6388
+ chainId: number;
6389
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
6390
+ identifier: string;
6391
+ name: string;
6392
+ status: "PAST" | "LIVE" | "SOON";
6393
+ action: import("../../database/api/.generated").$Enums.OpportunityAction;
6394
+ tokens: ({
6395
+ symbol: string;
6396
+ name: string | null;
6397
+ id: string;
6398
+ icon: string;
6399
+ chainId: number;
6400
+ address: string;
6401
+ decimals: number;
6402
+ verified: boolean;
6403
+ isTest: boolean;
6404
+ } & {
6405
+ price?: number | null | undefined;
6406
+ })[];
6407
+ mainProtocol: "morpho" | "aura" | "poolside" | "gearbox" | "fluid" | "compound" | "ionic" | "layerbank" | "moonwell" | "fenix" | "syncswap" | "beefy" | "aerodrome" | "velodrome" | "curve" | "akron" | "dragonswap" | "koi" | "baseswap" | "zkswap" | "rfx" | "woofi" | "zkSwapThreePool" | "venus" | "reactor_fusion" | "balancer" | "aave" | "arthswap" | "camelot" | "crust" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "supswap-v3" | "thirdtrade" | "uniswap-v2" | "syncswap-v3" | "neptune" | "radiant" | "euler" | "sturdy" | "frax" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "ion" | "eigenlayer" | undefined;
6408
+ depositUrl: any;
6409
+ tags: string[];
6410
+ };
6411
+ }>>;
6300
6412
  get: (options?: {
6301
6413
  headers?: Record<string, unknown> | undefined;
6302
6414
  query?: Record<string, unknown> | undefined;
@@ -6574,6 +6686,10 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6574
6686
  index: {
6575
6687
  post: (body: {
6576
6688
  name?: string | undefined;
6689
+ tags?: string[] | undefined;
6690
+ depositUrl?: string | undefined;
6691
+ protocols?: string[] | undefined;
6692
+ mainProtocol?: string | undefined;
6577
6693
  type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
6578
6694
  tokens: {
6579
6695
  chainId: number;
@@ -6583,8 +6699,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6583
6699
  identifier: string;
6584
6700
  chainId: number;
6585
6701
  action: "INVALID" | "POOL" | "HOLD" | "DROP" | "LEND" | "BORROW";
6586
- protocols: string[];
6587
- mainProtocol: string;
6588
6702
  }, options: {
6589
6703
  headers: {
6590
6704
  authorization: string;
@@ -6763,7 +6877,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6763
6877
  tags?: string[] | undefined;
6764
6878
  identifier?: string | undefined;
6765
6879
  subType?: number | undefined;
6766
- type: number;
6880
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
6767
6881
  params: string;
6768
6882
  creator: string;
6769
6883
  chainId: number;
@@ -148,6 +148,10 @@ declare const app: Elysia<"", false, {
148
148
  post: {
149
149
  body: {
150
150
  name?: string | undefined;
151
+ tags?: string[] | undefined;
152
+ depositUrl?: string | undefined;
153
+ protocols?: string[] | undefined;
154
+ mainProtocol?: string | undefined;
151
155
  type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
152
156
  tokens: {
153
157
  chainId: number;
@@ -157,8 +161,6 @@ declare const app: Elysia<"", false, {
157
161
  identifier: string;
158
162
  chainId: number;
159
163
  action: "INVALID" | "POOL" | "HOLD" | "DROP" | "LEND" | "BORROW";
160
- protocols: string[];
161
- mainProtocol: string;
162
164
  };
163
165
  params: {};
164
166
  query: unknown;
@@ -171,6 +173,48 @@ declare const app: Elysia<"", false, {
171
173
  };
172
174
  };
173
175
  };
176
+ } & {
177
+ opportunities: {
178
+ ":id": {
179
+ post: {
180
+ body: unknown;
181
+ params: {
182
+ id: string;
183
+ };
184
+ query: unknown;
185
+ headers: {
186
+ authorization: string;
187
+ };
188
+ response: {
189
+ 200: {
190
+ id: string;
191
+ chainId: number;
192
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
193
+ identifier: string;
194
+ name: string;
195
+ status: "PAST" | "LIVE" | "SOON";
196
+ action: import("../database/api/.generated").$Enums.OpportunityAction;
197
+ tokens: ({
198
+ symbol: string;
199
+ name: string | null;
200
+ id: string;
201
+ icon: string;
202
+ chainId: number;
203
+ address: string;
204
+ decimals: number;
205
+ verified: boolean;
206
+ isTest: boolean;
207
+ } & {
208
+ price?: number | null | undefined;
209
+ })[];
210
+ mainProtocol: "morpho" | "aura" | "poolside" | "gearbox" | "fluid" | "compound" | "ionic" | "layerbank" | "moonwell" | "fenix" | "syncswap" | "beefy" | "aerodrome" | "velodrome" | "curve" | "akron" | "dragonswap" | "koi" | "baseswap" | "zkswap" | "rfx" | "woofi" | "zkSwapThreePool" | "venus" | "reactor_fusion" | "balancer" | "aave" | "arthswap" | "camelot" | "crust" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "supswap-v3" | "thirdtrade" | "uniswap-v2" | "syncswap-v3" | "neptune" | "radiant" | "euler" | "sturdy" | "frax" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "ion" | "eigenlayer" | undefined;
211
+ depositUrl: any;
212
+ tags: string[];
213
+ };
214
+ };
215
+ };
216
+ };
217
+ };
174
218
  } & {
175
219
  opportunities: {
176
220
  index: {
@@ -661,7 +705,7 @@ declare const app: Elysia<"", false, {
661
705
  tags?: string[] | undefined;
662
706
  identifier?: string | undefined;
663
707
  subType?: number | undefined;
664
- type: number;
708
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
665
709
  params: string;
666
710
  creator: string;
667
711
  chainId: number;
@@ -52,6 +52,7 @@ export class RfxProcessor extends GenericProcessor {
52
52
  }
53
53
  const priceTargetToken = tvl / BN2Number(typeInfo.totalSupply, Number(typeInfo.decimalsToken));
54
54
  return {
55
+ ...typeInfo,
55
56
  tokenAddress: typeInfo.tokenAddress,
56
57
  totalSupply,
57
58
  whitelistedSupplyTargetToken,
@@ -19,7 +19,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
19
19
  tags?: string[] | undefined;
20
20
  identifier?: string | undefined;
21
21
  subType?: number | undefined;
22
- type: number;
22
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
23
23
  params: string;
24
24
  creator: string;
25
25
  chainId: number;
@@ -92,7 +92,24 @@ 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").TNumber;
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
+ }>;
96
113
  subType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
97
114
  rewardTokenAddress: import("@sinclair/typebox").TString;
98
115
  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.Number(),
56
+ type: t.Enum(CampaignType),
57
57
  subType: t.Optional(t.Number()),
58
58
  rewardTokenAddress: t.String(),
59
59
  amount: t.String(),
@@ -1,10 +1,9 @@
1
1
  import type { CampaignUnique, CreateCampaignModel, GetCampaignQueryModel } from "./";
2
2
  import { Prisma } from "../../../../database/api/.generated";
3
3
  import { type ChainId } from "@sdk";
4
- import { type OpportunityMetadata } from "../opportunity";
5
4
  export declare abstract class CampaignRepository {
6
5
  #private;
7
- static upsert(campaign: CreateCampaignModel, metadata: OpportunityMetadata): Promise<{
6
+ static upsert(campaign: CreateCampaignModel): Promise<{
8
7
  type: import("../../../../database/api/.generated").$Enums.CampaignType;
9
8
  id: string;
10
9
  params: Prisma.JsonValue;
@@ -19,7 +18,7 @@ export declare abstract class CampaignRepository {
19
18
  opportunityId: string;
20
19
  creatorAddress: string;
21
20
  } | undefined>;
22
- static upsertMany(campaigns: CreateCampaignModel[], campaignToOpp: Record<string, OpportunityMetadata>): Promise<{
21
+ static upsertMany(campaigns: CreateCampaignModel[]): Promise<{
23
22
  success: number;
24
23
  fail: number;
25
24
  }>;
@@ -2,7 +2,7 @@ import { CampaignService } from "./";
2
2
  import { log } from "../../../utils/logger";
3
3
  import { apiDbClient, engineDbClient } from "../../../utils/prisma";
4
4
  import { ALL_CAMPAIGNS_FOR_CHAIN_AFTER } from "../../../utils/queries/allCampaigns";
5
- import { Prisma, RunStatus, Status } from "../../../../database/api/.generated";
5
+ import { Prisma, RunStatus } from "../../../../database/api/.generated";
6
6
  import { MAX_COMPUTE_JOB_TIME, WEEK } from "@sdk";
7
7
  import moment from "moment";
8
8
  import { OpportunityService } from "../opportunity";
@@ -43,27 +43,19 @@ export class CampaignRepository {
43
43
  };
44
44
  }
45
45
  // ─── Public Methods ──────────────────────────────────────────────────
46
- static async upsert(campaign, metadata) {
47
- const campaignType = CampaignService.getTypeFromV3(campaign.type);
46
+ static async upsert(campaign) {
48
47
  try {
49
- let tokens = await TokenService.getManyOrCreate(metadata.tokens);
50
48
  const [rewardToken] = await TokenService.getManyOrCreate([
51
49
  { chainId: campaign.chainId, address: campaign.rewardTokenAddress },
52
50
  ]);
53
51
  if (!rewardToken) {
54
52
  throw new Error(`unable to fetch data for token ${campaign.rewardTokenAddress}`);
55
53
  }
56
- tokens = tokens.filter(t => t !== undefined);
57
54
  const params = JSON.parse(campaign.params);
58
55
  const opportunityId = OpportunityService.hashId({
59
56
  chainId: campaign.computeChainId,
60
57
  identifier: campaign.opportunityIdentifier,
61
- type: campaignType,
62
- });
63
- const opportunityTokens = tokens.map(t => {
64
- return {
65
- chainId_address: { chainId: t.chainId, address: t.address }, //TODO: use id
66
- };
58
+ type: campaign.type,
67
59
  });
68
60
  const data = {
69
61
  id: campaign.id,
@@ -72,7 +64,7 @@ export class CampaignRepository {
72
64
  endTimestamp: BigInt(campaign.endTimestamp),
73
65
  params,
74
66
  startTimestamp: BigInt(campaign.startTimestamp),
75
- type: campaignType,
67
+ type: campaign.type,
76
68
  ComputeChain: {
77
69
  connect: {
78
70
  id: campaign.computeChainId,
@@ -87,28 +79,7 @@ export class CampaignRepository {
87
79
  },
88
80
  },
89
81
  Opportunity: {
90
- connectOrCreate: {
91
- where: { id: opportunityId },
92
- create: {
93
- id: opportunityId,
94
- Chain: { connect: { id: campaign.computeChainId } },
95
- type: campaignType,
96
- identifier: campaign.opportunityIdentifier, // mainParameter
97
- name: metadata.name,
98
- status: +campaign.startTimestamp >= new Date().getTime() * 1000
99
- ? Status.LIVE
100
- : +campaign.endTimestamp < new Date().getTime() * 1000
101
- ? Status.PAST
102
- : Status.SOON,
103
- action: metadata.action,
104
- Tokens: { connect: opportunityTokens },
105
- MainProtocol: {
106
- connect: metadata.mainProtocol && { id: metadata.mainProtocol },
107
- },
108
- depositUrl: !!params.url ? params.url : undefined,
109
- tags: metadata.tags,
110
- },
111
- },
82
+ connect: { id: opportunityId },
112
83
  },
113
84
  RewardToken: {
114
85
  connectOrCreate: { where: { id: rewardToken?.id }, create: rewardToken },
@@ -128,22 +99,16 @@ export class CampaignRepository {
128
99
  log.error(`Failed to upsert campaign ${campaign.campaignId}`, err);
129
100
  }
130
101
  }
131
- static async upsertMany(campaigns, campaignToOpp) {
102
+ static async upsertMany(campaigns) {
132
103
  const data = [];
133
104
  for (const campaign of campaigns) {
134
- const campaignType = CampaignService.getTypeFromV3(campaign.type);
135
- let tokens = await TokenService.getManyOrCreate(campaignToOpp[campaign.id].tokens);
136
105
  const [rewardToken] = await TokenService.getManyOrCreate([
137
106
  { chainId: campaign.chainId, address: campaign.rewardTokenAddress },
138
107
  ]);
139
- tokens = tokens.filter(t => t !== undefined);
140
108
  const opportunityId = OpportunityService.hashId({
141
109
  chainId: campaign.computeChainId,
142
110
  identifier: campaign.opportunityIdentifier,
143
- type: campaignType,
144
- });
145
- const opportunityTokens = tokens.map(t => {
146
- return { id: t?.id };
111
+ type: campaign.type,
147
112
  });
148
113
  data.push({
149
114
  id: campaign.id,
@@ -152,7 +117,7 @@ export class CampaignRepository {
152
117
  endTimestamp: BigInt(campaign.endTimestamp),
153
118
  params: JSON.parse(campaign.params),
154
119
  startTimestamp: BigInt(campaign.startTimestamp),
155
- type: campaignType,
120
+ type: campaign.type,
156
121
  ComputeChain: {
157
122
  connect: {
158
123
  id: campaign.computeChainId,
@@ -165,33 +130,7 @@ export class CampaignRepository {
165
130
  },
166
131
  },
167
132
  Opportunity: {
168
- connectOrCreate: {
169
- where: { id: opportunityId },
170
- create: {
171
- id: opportunityId,
172
- Chain: {
173
- connect: {
174
- id: campaign.computeChainId,
175
- },
176
- },
177
- type: campaignType,
178
- identifier: campaign.opportunityIdentifier, // mainParameter
179
- name: campaignToOpp[campaign.id].name,
180
- status: +campaign.startTimestamp >= new Date().getTime() * 1000
181
- ? Status.LIVE
182
- : +campaign.endTimestamp < new Date().getTime() * 1000
183
- ? Status.PAST
184
- : Status.SOON,
185
- action: campaignToOpp[campaign.id].action,
186
- Tokens: { connect: opportunityTokens },
187
- MainProtocol: {
188
- connect: campaignToOpp[campaign.id].mainProtocol && {
189
- id: campaignToOpp[campaign.id].mainProtocol,
190
- },
191
- },
192
- tags: campaignToOpp[campaign.id].tags,
193
- },
194
- },
133
+ connect: { id: opportunityId },
195
134
  },
196
135
  RewardToken: {
197
136
  connect: rewardToken ? { id: TokenService.hashId(rewardToken) } : undefined,
@@ -9,48 +9,31 @@ import { NETWORK_LABELS } from "@sdk";
9
9
  import moment from "moment";
10
10
  import { StatusService } from "../status";
11
11
  import { TokenService } from "../token";
12
- import { UserService } from "../user";
13
12
  export class CampaignService {
14
13
  static hashId(campaign) {
15
14
  return Bun.hash(`${campaign.distributionChain}${campaign.campaignId}`).toString();
16
15
  }
17
16
  static async create(campaign) {
18
17
  const id = CampaignService.hashId({ distributionChain: campaign.chainId, campaignId: campaign.campaignId });
19
- const opportunityMetadata = await OpportunityService.getMetadata({
20
- id,
21
- ...campaign,
22
- });
23
- opportunityMetadata.tags = [
24
- ...((await UserService.findUnique(campaign.creator))?.tags ?? []),
25
- ...(campaign?.tags ?? []),
26
- ];
27
- return await CampaignRepository.upsert({ id, ...campaign }, opportunityMetadata);
18
+ await OpportunityService.createFromCampaign(campaign);
19
+ return await CampaignRepository.upsert({ id, ...campaign });
28
20
  }
29
21
  static async createMany(campaigns) {
30
- const campaignToOppMetadata = {};
31
22
  const failedToFetchMetadata = [];
32
23
  const campaignsToInsert = [];
33
24
  await Promise.all(campaigns.map(async (campaign) => {
34
25
  const id = CampaignService.hashId({ distributionChain: campaign.chainId, campaignId: campaign.campaignId });
35
26
  campaign.computeChainId = campaign.computeChainId === 0 ? campaign.chainId : campaign.computeChainId;
36
27
  try {
37
- const oppMetadata = await OpportunityService.getMetadata({
38
- id,
39
- ...campaign,
40
- });
41
- oppMetadata.tags = [
42
- ...((await UserService.findUnique(campaign.creator))?.tags ?? []),
43
- ...(campaign?.tags ?? []),
44
- ];
45
- campaignToOppMetadata[id] = oppMetadata;
28
+ await OpportunityService.createFromCampaign(campaign);
46
29
  campaignsToInsert.push({ id, ...campaign });
47
30
  }
48
31
  catch (err) {
49
- log.error(`Cannot get Opportunity metadata for campaign ${campaign.campaignId} of type ${CampaignService.getTypeFromV3(campaign.type)}`, err);
32
+ log.error(`Cannot get Opportunity metadata for campaign ${campaign.campaignId} of type ${campaign.type}`, err);
50
33
  failedToFetchMetadata.push(campaign);
51
34
  }
52
35
  }));
53
- let { success, fail } = await CampaignRepository.upsertMany(campaignsToInsert, campaignToOppMetadata);
36
+ let { success, fail } = await CampaignRepository.upsertMany(campaignsToInsert);
54
37
  fail += failedToFetchMetadata.length;
55
38
  return { success, fail };
56
39
  }
@@ -123,7 +106,7 @@ export class CampaignService {
123
106
  params: JSON.stringify(campaign.campaignParameters),
124
107
  rewardTokenAddress: campaign.rewardToken,
125
108
  startTimestamp: campaign.startTimestamp.toString(),
126
- type: campaign.campaignType,
109
+ type: CampaignService.getTypeFromV3(campaign.campaignType),
127
110
  subType: campaign.campaignSubType,
128
111
  };
129
112
  }));
@@ -17,6 +17,10 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
17
17
  post: {
18
18
  body: {
19
19
  name?: string | undefined;
20
+ tags?: string[] | undefined;
21
+ depositUrl?: string | undefined;
22
+ protocols?: string[] | undefined;
23
+ mainProtocol?: string | undefined;
20
24
  type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
21
25
  tokens: {
22
26
  chainId: number;
@@ -26,8 +30,6 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
26
30
  identifier: string;
27
31
  chainId: number;
28
32
  action: "INVALID" | "POOL" | "HOLD" | "DROP" | "LEND" | "BORROW";
29
- protocols: string[];
30
- mainProtocol: string;
31
33
  };
32
34
  params: {};
33
35
  query: unknown;
@@ -40,6 +42,48 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
40
42
  };
41
43
  };
42
44
  };
45
+ } & {
46
+ opportunities: {
47
+ ":id": {
48
+ post: {
49
+ body: unknown;
50
+ params: {
51
+ id: string;
52
+ };
53
+ query: unknown;
54
+ headers: {
55
+ authorization: string;
56
+ };
57
+ response: {
58
+ 200: {
59
+ id: string;
60
+ chainId: number;
61
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
62
+ identifier: string;
63
+ name: string;
64
+ status: "PAST" | "LIVE" | "SOON";
65
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
66
+ tokens: ({
67
+ symbol: string;
68
+ name: string | null;
69
+ id: string;
70
+ icon: string;
71
+ chainId: number;
72
+ address: string;
73
+ decimals: number;
74
+ verified: boolean;
75
+ isTest: boolean;
76
+ } & {
77
+ price?: number | null | undefined;
78
+ })[];
79
+ mainProtocol: "morpho" | "aura" | "poolside" | "gearbox" | "fluid" | "compound" | "ionic" | "layerbank" | "moonwell" | "fenix" | "syncswap" | "beefy" | "aerodrome" | "velodrome" | "curve" | "akron" | "dragonswap" | "koi" | "baseswap" | "zkswap" | "rfx" | "woofi" | "zkSwapThreePool" | "venus" | "reactor_fusion" | "balancer" | "aave" | "arthswap" | "camelot" | "crust" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "supswap-v3" | "thirdtrade" | "uniswap-v2" | "syncswap-v3" | "neptune" | "radiant" | "euler" | "sturdy" | "frax" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "ion" | "eigenlayer" | undefined;
80
+ depositUrl: any;
81
+ tags: string[];
82
+ };
83
+ };
84
+ };
85
+ };
86
+ };
43
87
  } & {
44
88
  opportunities: {
45
89
  index: {