@merkl/api 0.16.45 → 0.17.0

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 (24) hide show
  1. package/dist/src/eden/index.d.ts +65 -10
  2. package/dist/src/index.d.ts +13 -2
  3. package/dist/src/jobs/etl/update-dynamic-data.js +97 -42
  4. package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.js +1 -2
  5. package/dist/src/modules/v4/enso/enso.service.d.ts +12 -1
  6. package/dist/src/modules/v4/interaction/interaction.controller.d.ts +12 -2
  7. package/dist/src/modules/v4/liquidity/liquidity.service.js +1 -1
  8. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +1 -0
  9. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +6 -0
  10. package/dist/src/modules/v4/opportunity/opportunity.model.js +1 -0
  11. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +2 -1
  12. package/dist/src/modules/v4/opportunity/opportunity.repository.js +5 -2
  13. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +18 -2
  14. package/dist/src/modules/v4/opportunity/opportunity.service.js +9 -3
  15. package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +13 -6
  16. package/dist/src/modules/v4/programPayload/programPayload.repository.js +120 -15
  17. package/dist/src/modules/v4/protocol/protocol.service.d.ts +7 -7
  18. package/dist/src/modules/v4/protocol/protocol.service.js +9 -9
  19. package/dist/src/modules/v4/router.d.ts +13 -2
  20. package/dist/src/modules/v4/token/token.controller.js +31 -5
  21. package/dist/tsconfig.package.tsbuildinfo +1 -1
  22. package/package.json +1 -1
  23. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/getTVL.d.ts +0 -2
  24. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/getTVL.js +0 -8
@@ -386,6 +386,7 @@ declare const eden: {
386
386
  };
387
387
  patch: (body: {
388
388
  name?: string | undefined;
389
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
389
390
  tags?: string[] | undefined;
390
391
  }, options: {
391
392
  headers: {
@@ -2450,8 +2451,18 @@ declare const eden: {
2450
2451
  };
2451
2452
  fetch?: RequestInit | undefined;
2452
2453
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
2453
- [x: string]: any;
2454
- 200: any;
2454
+ 200: ({
2455
+ name: string;
2456
+ url: string;
2457
+ description: string;
2458
+ id: string;
2459
+ tags: string[];
2460
+ icon: string;
2461
+ } & {
2462
+ dailyRewards?: number | undefined;
2463
+ numberOfLiveCampaigns?: number | undefined;
2464
+ opportunityLiveTags?: string[] | undefined;
2465
+ })[];
2455
2466
  }>>;
2456
2467
  };
2457
2468
  transaction: {
@@ -3658,6 +3669,7 @@ declare const eden: {
3658
3669
  };
3659
3670
  patch: (body: {
3660
3671
  name?: string | undefined;
3672
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
3661
3673
  tags?: string[] | undefined;
3662
3674
  }, options: {
3663
3675
  headers: {
@@ -5722,8 +5734,18 @@ declare const eden: {
5722
5734
  };
5723
5735
  fetch?: RequestInit | undefined;
5724
5736
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
5725
- [x: string]: any;
5726
- 200: any;
5737
+ 200: ({
5738
+ name: string;
5739
+ url: string;
5740
+ description: string;
5741
+ id: string;
5742
+ tags: string[];
5743
+ icon: string;
5744
+ } & {
5745
+ dailyRewards?: number | undefined;
5746
+ numberOfLiveCampaigns?: number | undefined;
5747
+ opportunityLiveTags?: string[] | undefined;
5748
+ })[];
5727
5749
  }>>;
5728
5750
  };
5729
5751
  transaction: {
@@ -8222,6 +8244,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
8222
8244
  patch: {
8223
8245
  body: {
8224
8246
  name?: string | undefined;
8247
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
8225
8248
  tags?: string[] | undefined;
8226
8249
  };
8227
8250
  params: {
@@ -10190,8 +10213,18 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
10190
10213
  };
10191
10214
  headers: unknown;
10192
10215
  response: {
10193
- [x: string]: any;
10194
- 200: any;
10216
+ 200: ({
10217
+ name: string;
10218
+ url: string;
10219
+ description: string;
10220
+ id: string;
10221
+ tags: string[];
10222
+ icon: string;
10223
+ } & {
10224
+ dailyRewards?: number | undefined;
10225
+ numberOfLiveCampaigns?: number | undefined;
10226
+ opportunityLiveTags?: string[] | undefined;
10227
+ })[];
10195
10228
  };
10196
10229
  };
10197
10230
  };
@@ -12484,6 +12517,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
12484
12517
  };
12485
12518
  patch: (body: {
12486
12519
  name?: string | undefined;
12520
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
12487
12521
  tags?: string[] | undefined;
12488
12522
  }, options: {
12489
12523
  headers: {
@@ -14548,8 +14582,18 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14548
14582
  };
14549
14583
  fetch?: RequestInit | undefined;
14550
14584
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
14551
- [x: string]: any;
14552
- 200: any;
14585
+ 200: ({
14586
+ name: string;
14587
+ url: string;
14588
+ description: string;
14589
+ id: string;
14590
+ tags: string[];
14591
+ icon: string;
14592
+ } & {
14593
+ dailyRewards?: number | undefined;
14594
+ numberOfLiveCampaigns?: number | undefined;
14595
+ opportunityLiveTags?: string[] | undefined;
14596
+ })[];
14553
14597
  }>>;
14554
14598
  };
14555
14599
  transaction: {
@@ -15756,6 +15800,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
15756
15800
  };
15757
15801
  patch: (body: {
15758
15802
  name?: string | undefined;
15803
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
15759
15804
  tags?: string[] | undefined;
15760
15805
  }, options: {
15761
15806
  headers: {
@@ -17820,8 +17865,18 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
17820
17865
  };
17821
17866
  fetch?: RequestInit | undefined;
17822
17867
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
17823
- [x: string]: any;
17824
- 200: any;
17868
+ 200: ({
17869
+ name: string;
17870
+ url: string;
17871
+ description: string;
17872
+ id: string;
17873
+ tags: string[];
17874
+ icon: string;
17875
+ } & {
17876
+ dailyRewards?: number | undefined;
17877
+ numberOfLiveCampaigns?: number | undefined;
17878
+ opportunityLiveTags?: string[] | undefined;
17879
+ })[];
17825
17880
  }>>;
17826
17881
  };
17827
17882
  transaction: {
@@ -1009,6 +1009,7 @@ declare const app: Elysia<"", false, {
1009
1009
  patch: {
1010
1010
  body: {
1011
1011
  name?: string | undefined;
1012
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
1012
1013
  tags?: string[] | undefined;
1013
1014
  };
1014
1015
  params: {
@@ -2977,8 +2978,18 @@ declare const app: Elysia<"", false, {
2977
2978
  };
2978
2979
  headers: unknown;
2979
2980
  response: {
2980
- [x: string]: any;
2981
- 200: any;
2981
+ 200: ({
2982
+ name: string;
2983
+ url: string;
2984
+ description: string;
2985
+ id: string;
2986
+ tags: string[];
2987
+ icon: string;
2988
+ } & {
2989
+ dailyRewards?: number | undefined;
2990
+ numberOfLiveCampaigns?: number | undefined;
2991
+ opportunityLiveTags?: string[] | undefined;
2992
+ })[];
2982
2993
  };
2983
2994
  };
2984
2995
  };
@@ -6,22 +6,60 @@ import { OpportunityRepository } from "../../modules/v4/opportunity/opportunity.
6
6
  import { RewardService } from "../../modules/v4/reward";
7
7
  import { TvlService } from "../../modules/v4/tvl";
8
8
  import { executeSimple } from "../../utils/execute";
9
- import { Campaign } from "@sdk";
9
+ import { Campaign as CampaignTypesEnum } from "@sdk";
10
+ import moment from "moment";
11
+ // ─── Required Env Variables ──────────────────────────────────────────────────
10
12
  const chainId = Number(process.env.CHAIN_ID);
11
13
  if (!chainId)
12
14
  throw new Error("Environment variable CHAIN_ID is required.");
13
- const campaignType = process.env.CAMPAIGN_TYPE;
14
- if (!campaignType)
15
- throw new Error("Environment variable CAMPAIGN_TYPE is required.");
16
- async function updateDynamicData() {
17
- const liveCampaigns = (await CampaignService.getLiveCampaigns({ computeChainId: chainId, type: campaignType })).map(c => {
15
+ // ─── Update Dynamic Data (APR / TVL / Daily Rewards) ─────────────────────────
16
+ async function updateDynamicData(liveCampaigns, campaignType) {
17
+ try {
18
+ const dynamicData = await executeSimple(chainId, campaignsDynamicData(chainId, liveCampaigns, campaignType));
19
+ const oppMap = {};
20
+ for (const data of dynamicData) {
21
+ if (!!data) {
22
+ // Main Parameter OVERRIDING
23
+ if (data.campaignType === CampaignTypesEnum.SILO && data.campaignParameters.whitelist?.length === 1)
24
+ data.mainParameter = `${data.mainParameter}-${data.campaignParameters.whitelist[0]}`;
25
+ if (!oppMap[`${data.campaignType}_${data.mainParameter}`])
26
+ oppMap[`${data.campaignType}_${data.mainParameter}`] = {};
27
+ oppMap[`${data.campaignType}_${data.mainParameter}`][data.campaignId] = data;
28
+ }
29
+ }
30
+ for (const entry of Object.entries(oppMap)) {
31
+ const [type, mainParameter] = entry[0].split("_");
32
+ try {
33
+ const apr = AprService.extractFromDynamicData(+type, Object.values(entry[1]));
34
+ const tvl = TvlService.extractFromDynamicData(+type, Object.values(entry[1]));
35
+ const dailyRewards = await RewardService.extractDailyRewardsRecordFromDynamicData(+type, Object.values(entry[1]));
36
+ const opportunityId = OpportunityService.hashId({
37
+ chainId,
38
+ identifier: mainParameter,
39
+ type: type,
40
+ });
41
+ await OpportunityRepository.updateRecords(opportunityId, apr, tvl, dailyRewards);
42
+ }
43
+ catch (err) {
44
+ console.log(mainParameter);
45
+ console.error(err);
46
+ }
47
+ }
48
+ }
49
+ catch (err) {
50
+ console.error(err);
51
+ }
52
+ }
53
+ // ─── Get And Transform Live Campaigns Into A Map ─────────────────────────────
54
+ const getLiveCampaignsByType = async (chainId) => {
55
+ const liveCampaigns = (await CampaignService.getLiveCampaigns({ computeChainId: chainId })).map(c => {
18
56
  return {
19
57
  amount: c.amount,
20
58
  campaignId: c.campaignId,
21
59
  mainParameter: c.Opportunity.identifier,
22
60
  campaignParameters: c.params,
23
61
  campaignSubType: c.subType,
24
- campaignType,
62
+ campaignType: c.type,
25
63
  chainId: c.distributionChainId,
26
64
  computeChainId: c.computeChainId,
27
65
  creator: c.creatorAddress,
@@ -30,42 +68,59 @@ async function updateDynamicData() {
30
68
  startTimestamp: c.startTimestamp,
31
69
  };
32
70
  });
33
- const dynamicData = await executeSimple(chainId, campaignsDynamicData(chainId, liveCampaigns, campaignType));
34
- const oppMap = {};
35
- for (const data of dynamicData) {
36
- if (!!data) {
37
- // Main Parameter OVERRIDING
38
- if (data.campaignType === Campaign.SILO && data.campaignParameters.whitelist?.length === 1)
39
- data.mainParameter = `${data.mainParameter}-${data.campaignParameters.whitelist[0]}`;
40
- if (!oppMap[`${data.campaignType}_${data.mainParameter}`])
41
- oppMap[`${data.campaignType}_${data.mainParameter}`] = {};
42
- oppMap[`${data.campaignType}_${data.mainParameter}`][data.campaignId] = data;
43
- }
71
+ const campaignTypeToCampaigns = new Map();
72
+ for (const campaign of liveCampaigns) {
73
+ const type = campaign.campaignType;
74
+ let campaigns = campaignTypeToCampaigns.get(campaign.campaignType);
75
+ if (!campaigns)
76
+ campaigns = [campaign];
77
+ else
78
+ campaigns.push(campaign);
79
+ campaignTypeToCampaigns.set(type, campaigns);
44
80
  }
45
- for (const entry of Object.entries(oppMap)) {
46
- const [type, mainParameter] = entry[0].split("_");
47
- try {
48
- const apr = AprService.extractFromDynamicData(+type, Object.values(entry[1]));
49
- const tvl = TvlService.extractFromDynamicData(+type, Object.values(entry[1]));
50
- const dailyRewards = await RewardService.extractDailyRewardsRecordFromDynamicData(+type, Object.values(entry[1]));
51
- const opportunityId = OpportunityService.hashId({
52
- chainId,
53
- identifier: mainParameter,
54
- type: type,
55
- });
56
- await OpportunityRepository.updateRecords(opportunityId, apr, tvl, dailyRewards);
81
+ return campaignTypeToCampaigns;
82
+ };
83
+ // ─── Main function / entry point ─────────────────────────────────────────────
84
+ const main = async () => {
85
+ try {
86
+ // 1. Get a map of campaigns by campaign type
87
+ const liveCampaigns = await getLiveCampaignsByType(chainId);
88
+ // 2. Call updateDynamicData with each entries of the map (process by campaign type)
89
+ for (const [type, campaigns] of liveCampaigns.entries())
90
+ await updateDynamicData(campaigns, type);
91
+ // 3. Update status of opportunities
92
+ // 3.1 Get current live opportunities
93
+ const liveOpportunities = await OpportunityService.findLiveWithCampaigns(chainId);
94
+ // 3.2 For each currently live opportunities, infer its updated status by looping through its campaigns
95
+ const now = moment().unix();
96
+ for (const opportunity of liveOpportunities) {
97
+ let status = "NONE";
98
+ const campaigns = opportunity.campaigns;
99
+ for (const campaign of campaigns) {
100
+ if (status !== "LIVE" && campaign.endTimestamp < now)
101
+ status = "PAST";
102
+ else if (campaign.startTimestamp < now && campaign.endTimestamp > now)
103
+ status = "LIVE";
104
+ else if (status !== "LIVE" && campaign.startTimestamp > now)
105
+ status = "SOON";
106
+ }
107
+ await OpportunityService.updateStatus(opportunity.id, status);
57
108
  }
58
- catch (err) {
59
- console.log(mainParameter);
60
- console.error(err);
109
+ // 4. Compute the opportunity ids of the liveCampaigns
110
+ const opportunities = new Set();
111
+ for (const [type, campaigns] of liveCampaigns.entries()) {
112
+ for (const campaign of campaigns) {
113
+ const opportunityId = OpportunityService.hashId({ chainId, identifier: campaign.mainParameter, type });
114
+ opportunities.add(opportunityId);
115
+ }
61
116
  }
117
+ // 5. Update the status of the liveCampaigns opportunities
118
+ await OpportunityService.updateMany(Array.from(opportunities), { status: "LIVE" });
119
+ process.exit(0);
62
120
  }
63
- }
64
- try {
65
- await updateDynamicData();
66
- process.exit(0);
67
- }
68
- catch (err) {
69
- console.error(err);
70
- process.exit(1);
71
- }
121
+ catch (err) {
122
+ console.error(err);
123
+ process.exit(1);
124
+ }
125
+ };
126
+ await main();
@@ -4,7 +4,6 @@ import { TokenRepository } from "../../../modules/v4/token/token.repository";
4
4
  import { log } from "../../../utils/logger";
5
5
  import { BN2Number, BalancerPoolInterface, BalancerV3StablePoolInterface, ChainInteractionService, ERC20Interface, EnzymeInterface, FactoryInterface, LayerBankERC20Interface, MetamorphoInterface, YEAR, getEnv, } from "@sdk";
6
6
  import { Pricer } from "../../../utils/pricer";
7
- import { getTVL } from "./ERC20SubTypes/helpers/getTVL";
8
7
  import { tokenType } from "./ERC20SubTypes/helpers/tokenType";
9
8
  import { getTokenPricesInfo } from "./ERC20SubTypes/subtypesPrices";
10
9
  import { getTokenTypeRound1 } from "./ERC20SubTypes/subtypesRound1";
@@ -151,7 +150,7 @@ export async function ERC20DynamicData(chainId, campaigns) {
151
150
  campaign.campaignParameters.duration /
152
151
  (whitelistedSupplyTargetToken * priceTargetToken),
153
152
  totalSupplyTargetToken,
154
- tvl: getTVL(tokenTypesByCampaign[campaign.campaignId].typeInfo.type, tokenTypesByCampaign[campaign.campaignId].typeInfo.totalSupply, whitelistedSupplyTargetToken, priceTargetToken),
153
+ tvl: whitelistedSupplyTargetToken * priceTargetToken,
155
154
  type: tokenTypesByCampaign[campaign.campaignId].type,
156
155
  typeInfo: tokenTypesByCampaign[campaign.campaignId].typeInfo,
157
156
  priceRewardToken: priceRewardToken,
@@ -5,7 +5,18 @@ export declare abstract class EnsoService {
5
5
  #private;
6
6
  static getSlug(protocolId: ProtocolId | string): EnsoSlug | undefined;
7
7
  static getProtocolId(slug: EnsoSlug | string): ProtocolId | undefined;
8
- static getCompatibleProtocols(query: GetInteractionProtocolsQuery): Promise<any>;
8
+ static getCompatibleProtocols(query: GetInteractionProtocolsQuery): Promise<({
9
+ name: string;
10
+ url: string;
11
+ description: string;
12
+ id: string;
13
+ tags: string[];
14
+ icon: string;
15
+ } & {
16
+ dailyRewards?: number | undefined;
17
+ numberOfLiveCampaigns?: number | undefined;
18
+ opportunityLiveTags?: string[] | undefined;
19
+ })[]>;
9
20
  static getTokens(chainId: number, slug: EnsoSlug, identifier?: string): Promise<{
10
21
  type: "base" | "defi";
11
22
  chainId: number;
@@ -40,8 +40,18 @@ export declare const InteractionController: Elysia<"/interaction", false, {
40
40
  };
41
41
  headers: unknown;
42
42
  response: {
43
- [x: string]: any;
44
- 200: any;
43
+ 200: ({
44
+ name: string;
45
+ url: string;
46
+ description: string;
47
+ id: string;
48
+ tags: string[];
49
+ icon: string;
50
+ } & {
51
+ dailyRewards?: number | undefined;
52
+ numberOfLiveCampaigns?: number | undefined;
53
+ opportunityLiveTags?: string[] | undefined;
54
+ })[];
45
55
  };
46
56
  };
47
57
  };
@@ -17,7 +17,7 @@ export class LiquidityService {
17
17
  [Campaign.DOLOMITE]: new DolomitePositionFetcher(),
18
18
  };
19
19
  static async fetchPositions(query) {
20
- const opportunities = await OpportunityService.findLiveWithFirstCampaign(query.chainId);
20
+ const opportunities = await OpportunityService.findLiveWithCampaigns(query.chainId, 1);
21
21
  const promises = [];
22
22
  for (const campaignType of Object.keys(Campaign)) {
23
23
  const fetcher = LiquidityService.#fetchers[Number.parseInt(campaignType)];
@@ -864,6 +864,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
864
864
  patch: {
865
865
  body: {
866
866
  name?: string | undefined;
867
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
867
868
  tags?: string[] | undefined;
868
869
  };
869
870
  params: {
@@ -340,6 +340,12 @@ export declare const OpportunityIdDto: import("@sinclair/typebox").TObject<{
340
340
  export declare const UpdateOpportunityDto: import("@sinclair/typebox").TObject<{
341
341
  name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
342
342
  tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
343
+ status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
344
+ NONE: "NONE";
345
+ PAST: "PAST";
346
+ LIVE: "LIVE";
347
+ SOON: "SOON";
348
+ }>>;
343
349
  }>;
344
350
  export type GetOpportunitiesQueryModel = typeof GetOpportunitiesQueryDto.static;
345
351
  export type GetOpportunityQueryModel = typeof GetOpportunityQueryDto.static;
@@ -103,4 +103,5 @@ export const OpportunityIdDto = t.Object({ id: t.String() });
103
103
  export const UpdateOpportunityDto = t.Object({
104
104
  name: t.Optional(t.String()),
105
105
  tags: t.Optional(t.Array(t.String())),
106
+ status: t.Optional(t.Enum(Status)),
106
107
  });
@@ -628,7 +628,7 @@ export declare abstract class OpportunityRepository {
628
628
  apr: number;
629
629
  dailyRewards: number;
630
630
  })[]>;
631
- static findLiveWithFirstCampaign(chainId: MerklChainId): Promise<({
631
+ static findLiveWithCampaigns(chainId: MerklChainId, take?: number): Promise<({
632
632
  Chain: {
633
633
  name: string;
634
634
  id: number;
@@ -936,4 +936,5 @@ export declare abstract class OpportunityRepository {
936
936
  apr: number;
937
937
  dailyRewards: number;
938
938
  }>;
939
+ static updateMany(ids: string[], data: UpdateOpportunityModel): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
939
940
  }
@@ -257,7 +257,7 @@ export class OpportunityRepository {
257
257
  ...args,
258
258
  });
259
259
  }
260
- static async findLiveWithFirstCampaign(chainId) {
260
+ static async findLiveWithCampaigns(chainId, take) {
261
261
  const now = moment().unix();
262
262
  return await apiDbClient.opportunity.findMany({
263
263
  include: {
@@ -274,7 +274,7 @@ export class OpportunityRepository {
274
274
  CampaignStatus: true,
275
275
  Creator: true,
276
276
  },
277
- take: 1,
277
+ take: take ? take : undefined,
278
278
  orderBy: { endTimestamp: "desc" },
279
279
  },
280
280
  MainProtocol: true,
@@ -406,4 +406,7 @@ export class OpportunityRepository {
406
406
  static async update(id, data) {
407
407
  return await apiDbClient.opportunity.update({ where: { id }, data });
408
408
  }
409
+ static async updateMany(ids, data) {
410
+ return await apiDbClient.opportunity.updateMany({ where: { id: { in: ids } }, data });
411
+ }
409
412
  }
@@ -1,5 +1,5 @@
1
1
  import { type CreateCampaignModel, type GetCampaignQueryModel } from "../campaign";
2
- import { Prisma } from "../../../../database/api/.generated";
2
+ import { Prisma, Status } from "../../../../database/api/.generated";
3
3
  import { type ChainId, type MerklChainId } from "@sdk";
4
4
  import type { CreateOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, OpportunityResourceModel, OpportunityUnique, UpdateOpportunityModel } from "./opportunity.model";
5
5
  import { OpportunityRepository } from "./opportunity.repository";
@@ -63,6 +63,21 @@ export declare abstract class OpportunityService {
63
63
  depositUrl: any;
64
64
  tags: string[];
65
65
  }>;
66
+ static updateStatus(opportunityId: string, status: Status): Promise<{
67
+ name: string;
68
+ type: string;
69
+ id: string;
70
+ status: import("../../../../database/api/.generated").$Enums.Status;
71
+ tags: string[];
72
+ identifier: string;
73
+ chainId: number;
74
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
75
+ depositUrl: string | null;
76
+ mainProtocolId: string | null;
77
+ tvl: number;
78
+ apr: number;
79
+ dailyRewards: number;
80
+ }>;
66
81
  static updateStatusFromCampaign(campaign: Omit<CreateCampaignModel, "id">, upsert?: boolean): Promise<{
67
82
  id: string;
68
83
  chainId: number;
@@ -535,7 +550,7 @@ export declare abstract class OpportunityService {
535
550
  * @returns the number of opportunities
536
551
  */
537
552
  static countMany(query: GetOpportunitiesQueryModel): Promise<number>;
538
- static findLiveWithFirstCampaign(chainId: MerklChainId): Promise<{
553
+ static findLiveWithCampaigns(chainId: MerklChainId, take?: number): Promise<{
539
554
  apr: number;
540
555
  aprRecord: {
541
556
  cumulated: number;
@@ -882,4 +897,5 @@ export declare abstract class OpportunityService {
882
897
  apr: number;
883
898
  dailyRewards: number;
884
899
  }>;
900
+ static updateMany(ids: string[], data: UpdateOpportunityModel): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
885
901
  }
@@ -28,7 +28,7 @@ import { getMorphoMetadata } from "./subservices/getMorphoMetadata.service";
28
28
  import { getRadiantMetadata } from "./subservices/getRadiantMetadata.service";
29
29
  import { getSiloMetadata } from "./subservices/getSiloMetadata.service";
30
30
  import { getUniswapV4Metadata } from "./subservices/getUniswapV4Metadata.service";
31
- import { getVestMetadata } from "./subservices/getVestMetadata.service";
31
+ import { getVestMetadata } from "./subservices/getVestMetaData.service";
32
32
  export class OpportunityService {
33
33
  static hashId(opportunity) {
34
34
  return Bun.hash(`${opportunity.chainId}${opportunity.type}${opportunity.identifier}`).toString();
@@ -165,6 +165,9 @@ export class OpportunityService {
165
165
  await OpportunityRepository.create(opportunity, upsert);
166
166
  return opportunity;
167
167
  }
168
+ static async updateStatus(opportunityId, status) {
169
+ return await OpportunityRepository.update(opportunityId, { status });
170
+ }
168
171
  static async updateStatusFromCampaign(campaign, upsert = true) {
169
172
  const campaignType = CampaignService.getTypeFromV3(campaign.type);
170
173
  const metadata = await OpportunityService.#getMetadata(campaign);
@@ -283,10 +286,10 @@ export class OpportunityService {
283
286
  static async countMany(query) {
284
287
  return await OpportunityRepository.countMany(query);
285
288
  }
286
- static async findLiveWithFirstCampaign(chainId) {
289
+ static async findLiveWithCampaigns(chainId, take) {
287
290
  return record("data-layer.access", async () => {
288
291
  return await CacheService.wrap(TTLPresets.MIN_10, async (chainId) => {
289
- const opportunities = await OpportunityRepository.findLiveWithFirstCampaign(chainId);
292
+ const opportunities = await OpportunityRepository.findLiveWithCampaigns(chainId, take);
290
293
  return opportunities.map(o => {
291
294
  return OpportunityService.formatResponse(o);
292
295
  });
@@ -365,4 +368,7 @@ export class OpportunityService {
365
368
  static async update(id, data) {
366
369
  return await OpportunityRepository.update(id, data);
367
370
  }
371
+ static async updateMany(ids, data) {
372
+ return await OpportunityRepository.updateMany(ids, data);
373
+ }
368
374
  }
@@ -29,11 +29,14 @@ export declare enum swapxCampaigns {
29
29
  Swapx_SWPx_Weth_Swapx = "Swapx SWPx/Weth Swapx 0x9c2a7bb01951bE15fe835886188fA13255eF9486",
30
30
  Swapx_SWPx_OS_Swapx = "Swapx SWPx/OS Swapx 0x9Cb484FAD38D953bc79e2a39bBc93655256F0B16",
31
31
  Swapx_USDCe_wS_Swapx = "Swapx USDC.e/wS Swapx 0x5C4B7d607aAF7B5CDE9F09b5F03Cf3b5c923AEEa",
32
- Swapx_USDCe_scUSD_Swapx = "Swapx USDC.e/scUSD Swapx 0xDd35c88B1754879EF86BBF3A24F81fCCA5Eb6B5D",
32
+ Swapx_USDCe_scUSD_USDCe_gauge_Swapx = "Swapx USDC.e/scUSD USDC.e gauge Swapx 0xDd35c88B1754879EF86BBF3A24F81fCCA5Eb6B5D",
33
+ Swapx_USDCe_scUSD_scUSD_gauge_Swapx = "Swapx USDC.e/scUSD scUSD gauge Swapx 0xDd35c88B1754879EF86BBF3A24F81fCCA5Eb6B5D",
33
34
  Swapx_scETH_wS_Swapx = "Swapx scETH/wS Swapx 0xFC64BD7c84F7Dc1387D6E752679a533F22f6F1DB",
34
- Swapx_stS_wS_Swapx = "Swapx stS/wS Swapx 0xD760791B29e7894FB827A94Ca433254bb5aFB653",
35
+ Swapx_stS_wS_stS_gauge_Swapx = "Swapx stS/wS stS gauge Swapx 0xD760791B29e7894FB827A94Ca433254bb5aFB653",
36
+ Swapx_stS_wS_wS_gauge_Swapx = "Swapx stS/wS wS gauge Swapx 0xD760791B29e7894FB827A94Ca433254bb5aFB653",
35
37
  Swapx_WETH_USDCe_Swapx = "Swapx WETH/USDC.e Swapx 0xeC4Ee7d6988Ab06F7a8DAaf8C5FDfFdE6321Be68",
36
- Swapx_stS_USDCe_Swapx = "Swapx stS/USDC.e Swapx 0x5DDbeF774488cc68266d5F15bFB08eaA7cd513F9",
38
+ Swapx_stS_USDCe_stS_gauge_Swapx = "Swapx stS/USDC.e stS gauge Swapx 0x5DDbeF774488cc68266d5F15bFB08eaA7cd513F9",
39
+ Swapx_stS_USDCe_USDCe_gauge_Swapx = "Swapx stS/USDC.e USDC.e gauge Swapx 0x5DDbeF774488cc68266d5F15bFB08eaA7cd513F9",
37
40
  Swapx_wETH_wS_Swapx = "Swapx wETH/wS Swapx 0xF58fC088C33aD46113940173cB0da3Dd08c4AA88",
38
41
  Swapx_ANON_USDC_Swapx = "Swapx ANON/USDC Swapx 0x6F7C5f531024216CD8156D0B4E271E0C92a8A4E6",
39
42
  Swapx_ANON_wS_Swapx = "Swapx ANON/wS Swapx 0xb73a4d63fa27EB0Ded5305C5D4D1cE488edfE2A1",
@@ -41,17 +44,21 @@ export declare enum swapxCampaigns {
41
44
  Swapx_OS_wS_Swapx = "Swapx OS/wS Swapx 0xa76Beaf111BaD5dD866fa4835D66b9aA2Eb1FdEc",
42
45
  Swapx_scETH_WETH_Swapx = "Swapx scETH/WETH Swapx 0xDa2fDdeb3D654E1F32E2664d8d95C9329e34E5c8",
43
46
  Swapx_OS_GEMSx_Swapx = "Swapx OS/GEMSx Swapx 0x9ac7F5961a452e9cD5Be5717bD2c3dF412D1c1a5",
44
- Swapx_USDT_USDC_Swapx = "Swapx USDT/USDC Swapx 0x0d13400CC7c46D77a43957fE614ba58C827dfde6",
47
+ Swapx_USDT_USDCe_USDT_gauge_Swapx = "Swapx USDT/USDC.e USDT gauge Swapx 0x0d13400CC7c46D77a43957fE614ba58C827dfde6",
48
+ Swapx_USDT_USDCe_USDCe_gauge_Swapx = "Swapx USDT/USDC.e USDC.e gauge Swapx 0x0d13400CC7c46D77a43957fE614ba58C827dfde6",
45
49
  Swapx_frxUSD_scUSD_Swapx = "Swapx frxUSD/scUSD Swapx 0x63a66Dd60b0F2812249802477adA8a890A030Eca",
46
50
  Swapx_frxETH_scETH_Swapx = "Swapx frxETH/scETH Swapx 0x77BF14037D3f72c65CbaEa92FA3f09f2f8978cBe",
47
51
  Swapx_FXS_frxETH_Swapx = "Swapx FXS/frxETH Swapx 0x3f74c162E4B2baeBA31Ac1698fEB7c5DB3aFFE4A",
48
52
  Swapx_sfrxUSD_frxUSD_Swapx = "Swapx sfrxUSD/frxUSD Swapx 0x7d709a567BA2fdBbB92E94E5fE74b9cbbc590835",
49
53
  Swapx_sfrxETH_frxETH_Swapx = "Swapx sfrxETH/frxETH Swapx 0x586C118d62664C5D253272357359A14349219EBA",
50
- Swapx_sfrxUSD_OS_Swapx = "Swapx sfrxUSD/OS Swapx 0x9255F31eF9B35d085cED6fE29F9E077EB1f513C6",
54
+ Swapx_sfrxUSD_OS_sfrxUSD_gauge_Swapx = "Swapx sfrxUSD/OS sfrxUSD gauge Swapx 0x9255F31eF9B35d085cED6fE29F9E077EB1f513C6",
55
+ Swapx_sfrxUSD_OS_OS_gauge_Swapx = "Swapx sfrxUSD/OS OS gauge Swapx 0x9255F31eF9B35d085cED6fE29F9E077EB1f513C6",
51
56
  Swapx_WBTC_SCBTC_Swapx = "Swapx WBTC/SCBTC Swapx 0xb96F401F789271bc14ADe2229E6189084805c50C",
52
57
  Swapx_ws_scbtc_Swapx = "Swapx ws/scbtc Swapx 0xcD531DAfD592be3CA9bef79cDb4C0dF8A5104b81",
53
58
  Swapx_scUSD_OS_Swapx = "Swapx scUSD/OS Swapx 0x370428430503B3b5970Ccaf530CbC71d02C3B61a",
54
- Swapx_V2_USDCe_scUSD_Swapx = "Swapx V2 USDCe/scUSD 0xBb8aE5b889243561ac9261F22F592B72250AFd1F"
59
+ Swapx_V2_USDCe_scUSD_Swapx = "Swapx V2 USDCe/scUSD 0xBb8aE5b889243561ac9261F22F592B72250AFd1F",
60
+ Swapx_wstkscUSD_scUSD_wstkscUSD_gauge_Swapx = "Swapx wstkscUSD/scUSD wstkscUSD gauge Swapx 0xEd08f5caD599E7F523d6B3FD598005B43aA003bb",
61
+ Swapx_wstkscUSD_scUSD_scUSD_gauge_Swapx = "Swapx wstkscUSD/scUSD scUSD gauge Swapx 0xEd08f5caD599E7F523d6B3FD598005B43aA003bb"
55
62
  }
56
63
  export declare enum celoCampaigns {
57
64
  UniswapV3_cUSD_USDT_Celo = "UniswapV3 cUSD/USDT Celo 0x5dC631aD6C26BEA1a59fBF2C2680CF3df43d249f",