@merkl/api 0.20.63 → 0.20.64

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.
@@ -2,7 +2,7 @@ import { PrismaClient as ApiPrismaClient } from "@db/api";
2
2
  import { PrismaClient as EnginePrismaClient } from "@db/engine";
3
3
  import { drizzle } from "drizzle-orm/prisma/pg";
4
4
  export const apiDbClient = new ApiPrismaClient({
5
- datasources: { db: { url: `${process.env.DATABASE_API_URL}&connection_limit=150&pool_timeout=60` } },
5
+ datasources: { db: { url: `${process.env.DATABASE_API_URL}&connection_limit=100&pool_timeout=60` } },
6
6
  }).$extends(drizzle());
7
7
  export const engineDbClient = new EnginePrismaClient({
8
8
  datasources: {
@@ -456,35 +456,6 @@ declare const eden: {
456
456
  };
457
457
  }>>;
458
458
  };
459
- patch: (body: {
460
- name?: string | undefined;
461
- status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
462
- tags?: string[] | undefined;
463
- }, options: {
464
- headers: {
465
- authorization: string;
466
- };
467
- query?: Record<string, unknown> | undefined;
468
- fetch?: RequestInit | undefined;
469
- }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
470
- 200: {
471
- id: string;
472
- name: string;
473
- type: string;
474
- status: import("@db/api").$Enums.Status;
475
- tags: string[];
476
- identifier: string;
477
- action: import("@db/api").$Enums.OpportunityAction;
478
- manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
479
- chainId: number;
480
- depositUrl: string | null;
481
- explorerAddress: string | null;
482
- mainProtocolId: string | null;
483
- tvl: number;
484
- apr: number;
485
- dailyRewards: number;
486
- };
487
- }>>;
488
459
  }) & {
489
460
  index: {
490
461
  post: (body: {
@@ -4489,35 +4460,6 @@ declare const eden: {
4489
4460
  };
4490
4461
  }>>;
4491
4462
  };
4492
- patch: (body: {
4493
- name?: string | undefined;
4494
- status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
4495
- tags?: string[] | undefined;
4496
- }, options: {
4497
- headers: {
4498
- authorization: string;
4499
- };
4500
- query?: Record<string, unknown> | undefined;
4501
- fetch?: RequestInit | undefined;
4502
- }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
4503
- 200: {
4504
- id: string;
4505
- name: string;
4506
- type: string;
4507
- status: import("@db/api").$Enums.Status;
4508
- tags: string[];
4509
- identifier: string;
4510
- action: import("@db/api").$Enums.OpportunityAction;
4511
- manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
4512
- chainId: number;
4513
- depositUrl: string | null;
4514
- explorerAddress: string | null;
4515
- mainProtocolId: string | null;
4516
- tvl: number;
4517
- apr: number;
4518
- dailyRewards: number;
4519
- };
4520
- }>>;
4521
4463
  }) & {
4522
4464
  index: {
4523
4465
  post: (body: {
@@ -9939,44 +9881,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
9939
9881
  };
9940
9882
  };
9941
9883
  };
9942
- } & {
9943
- opportunities: {
9944
- ":id": {
9945
- patch: {
9946
- body: {
9947
- name?: string | undefined;
9948
- status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
9949
- tags?: string[] | undefined;
9950
- };
9951
- params: {
9952
- id: string;
9953
- };
9954
- query: unknown;
9955
- headers: {
9956
- authorization: string;
9957
- };
9958
- response: {
9959
- 200: {
9960
- id: string;
9961
- name: string;
9962
- type: string;
9963
- status: import("@db/api").$Enums.Status;
9964
- tags: string[];
9965
- identifier: string;
9966
- action: import("@db/api").$Enums.OpportunityAction;
9967
- manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
9968
- chainId: number;
9969
- depositUrl: string | null;
9970
- explorerAddress: string | null;
9971
- mainProtocolId: string | null;
9972
- tvl: number;
9973
- apr: number;
9974
- dailyRewards: number;
9975
- };
9976
- };
9977
- };
9978
- };
9979
- };
9980
9884
  };
9981
9885
  } & {
9982
9886
  v4: {
@@ -15216,35 +15120,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
15216
15120
  };
15217
15121
  }>>;
15218
15122
  };
15219
- patch: (body: {
15220
- name?: string | undefined;
15221
- status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
15222
- tags?: string[] | undefined;
15223
- }, options: {
15224
- headers: {
15225
- authorization: string;
15226
- };
15227
- query?: Record<string, unknown> | undefined;
15228
- fetch?: RequestInit | undefined;
15229
- }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
15230
- 200: {
15231
- id: string;
15232
- name: string;
15233
- type: string;
15234
- status: import("@db/api").$Enums.Status;
15235
- tags: string[];
15236
- identifier: string;
15237
- action: import("@db/api").$Enums.OpportunityAction;
15238
- manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
15239
- chainId: number;
15240
- depositUrl: string | null;
15241
- explorerAddress: string | null;
15242
- mainProtocolId: string | null;
15243
- tvl: number;
15244
- apr: number;
15245
- dailyRewards: number;
15246
- };
15247
- }>>;
15248
15123
  }) & {
15249
15124
  index: {
15250
15125
  post: (body: {
@@ -19249,35 +19124,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
19249
19124
  };
19250
19125
  }>>;
19251
19126
  };
19252
- patch: (body: {
19253
- name?: string | undefined;
19254
- status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
19255
- tags?: string[] | undefined;
19256
- }, options: {
19257
- headers: {
19258
- authorization: string;
19259
- };
19260
- query?: Record<string, unknown> | undefined;
19261
- fetch?: RequestInit | undefined;
19262
- }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
19263
- 200: {
19264
- id: string;
19265
- name: string;
19266
- type: string;
19267
- status: import("@db/api").$Enums.Status;
19268
- tags: string[];
19269
- identifier: string;
19270
- action: import("@db/api").$Enums.OpportunityAction;
19271
- manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
19272
- chainId: number;
19273
- depositUrl: string | null;
19274
- explorerAddress: string | null;
19275
- mainProtocolId: string | null;
19276
- tvl: number;
19277
- apr: number;
19278
- dailyRewards: number;
19279
- };
19280
- }>>;
19281
19127
  }) & {
19282
19128
  index: {
19283
19129
  post: (body: {
@@ -1158,44 +1158,6 @@ declare const app: Elysia<"", false, {
1158
1158
  };
1159
1159
  };
1160
1160
  };
1161
- } & {
1162
- opportunities: {
1163
- ":id": {
1164
- patch: {
1165
- body: {
1166
- name?: string | undefined;
1167
- status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
1168
- tags?: string[] | undefined;
1169
- };
1170
- params: {
1171
- id: string;
1172
- };
1173
- query: unknown;
1174
- headers: {
1175
- authorization: string;
1176
- };
1177
- response: {
1178
- 200: {
1179
- id: string;
1180
- name: string;
1181
- type: string;
1182
- status: import("@db/api").$Enums.Status;
1183
- tags: string[];
1184
- identifier: string;
1185
- action: import("@db/api").$Enums.OpportunityAction;
1186
- manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
1187
- chainId: number;
1188
- depositUrl: string | null;
1189
- explorerAddress: string | null;
1190
- mainProtocolId: string | null;
1191
- tvl: number;
1192
- apr: number;
1193
- dailyRewards: number;
1194
- };
1195
- };
1196
- };
1197
- };
1198
- };
1199
1161
  };
1200
1162
  } & {
1201
1163
  v4: {
@@ -1,14 +1,14 @@
1
1
  import { CampaignService } from "@/modules/v4/campaign";
2
- import { ChainService } from "@/modules/v4/chain/chain.service";
3
2
  import { DynamicDataService } from "@/modules/v4/dynamicData/dynamicData.service";
4
3
  import { OpportunityService } from "@/modules/v4/opportunity";
5
4
  import { Campaign as CampaignEnum } from "@sdk";
6
5
  import moment from "moment";
7
6
  // ─── Required Env Variables ──────────────────────────────────────────────────
8
- // const chainId = Number(process.env.CHAIN_ID);
9
- // if (!chainId) throw new Error("Environment variable CHAIN_ID is required.");
7
+ const chainId = Number(process.env.CHAIN_ID);
8
+ if (!chainId)
9
+ throw new Error("Environment variable CHAIN_ID is required.");
10
10
  // ─── Update Dynamic Data (APR / TVL / Daily Rewards) ─────────────────────────
11
- const main = async (chainId) => {
11
+ const main = async () => {
12
12
  const liveCampaigns = (await CampaignService.getLiveCampaigns({ computeChainId: chainId })).map(c => {
13
13
  return {
14
14
  amount: c.amount,
@@ -58,13 +58,11 @@ const main = async (chainId) => {
58
58
  // 4. Update the status of the opportunities associated to live campaigns
59
59
  await OpportunityService.updateMany(liveOpportunityIds, { status: "LIVE" });
60
60
  };
61
- const chains = await ChainService.getSupportedIds();
62
- const promises = [];
63
- for (const chain of chains)
64
- promises.push(main(chain));
65
- await Promise.allSettled(promises)
66
- .then(success => (success ? process.exit(0) : process.exit(1)))
67
- .catch((err) => {
61
+ try {
62
+ await main();
63
+ process.exit(0);
64
+ }
65
+ catch (err) {
68
66
  console.error(err);
69
67
  process.exit(1);
70
- });
68
+ }
@@ -1013,44 +1013,6 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
1013
1013
  };
1014
1014
  };
1015
1015
  };
1016
- } & {
1017
- opportunities: {
1018
- ":id": {
1019
- patch: {
1020
- body: {
1021
- name?: string | undefined;
1022
- status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
1023
- tags?: string[] | undefined;
1024
- };
1025
- params: {
1026
- id: string;
1027
- };
1028
- query: unknown;
1029
- headers: {
1030
- authorization: string;
1031
- };
1032
- response: {
1033
- 200: {
1034
- id: string;
1035
- name: string;
1036
- type: string;
1037
- status: import("@db/api").$Enums.Status;
1038
- tags: string[];
1039
- identifier: string;
1040
- action: import("@db/api").$Enums.OpportunityAction;
1041
- manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
1042
- chainId: number;
1043
- depositUrl: string | null;
1044
- explorerAddress: string | null;
1045
- mainProtocolId: string | null;
1046
- tvl: number;
1047
- apr: number;
1048
- dailyRewards: number;
1049
- };
1050
- };
1051
- };
1052
- };
1053
- };
1054
1016
  }, {
1055
1017
  derive: {};
1056
1018
  resolve: {};
@@ -3,7 +3,7 @@ import { BackOfficeGuard } from "@/guards/BackOffice.guard";
3
3
  import { AuthorizationHeadersDto, TokenAuthGuard } from "@/guards/TokenAuth.guard";
4
4
  import Elysia, { t } from "elysia";
5
5
  import { GetCampaignQueryDto } from "../campaign";
6
- import { CreateOpportunityDto, GetOpportunitiesQueryDto, GetOpportunityQueryDto, OpportunityAggregateFieldDto, OpportunityDeleteOverrideDto, OpportunityIdDto, OpportunityOverrideDto, OpportunityResourceDto, OpportunityUniqueDto, OpportunityUniqueUpdateDto, OpportunityWithCampaignsResourceDto, UpdateOpportunityDto, } from "./opportunity.model";
6
+ import { CreateOpportunityDto, GetOpportunitiesQueryDto, GetOpportunityQueryDto, OpportunityAggregateFieldDto, OpportunityDeleteOverrideDto, OpportunityOverrideDto, OpportunityResourceDto, OpportunityUniqueDto, OpportunityUniqueUpdateDto, OpportunityWithCampaignsResourceDto, } from "./opportunity.model";
7
7
  import { OpportunityService } from "./opportunity.service";
8
8
  import { transformId } from "./transform-id.pipe";
9
9
  import { validateId } from "./validate-id.pipe";
@@ -158,12 +158,4 @@ export const OpportunityController = new Elysia({
158
158
  .get("/aggregate/min/:field", async ({ query, params }) => await OpportunityService.aggregateMin(query, params.field), {
159
159
  params: OpportunityAggregateFieldDto,
160
160
  query: GetOpportunitiesQueryDto,
161
- })
162
- // ─── Update An Opportunity ───────────────────────────────────────────
163
- .patch("/:id", async ({ params, body }) => await OpportunityService.update(params.id, body), {
164
- params: OpportunityIdDto,
165
- body: UpdateOpportunityDto,
166
- headers: AuthorizationHeadersDto,
167
- beforeHandle: BackOfficeGuard,
168
- detail: { hide: true },
169
161
  });
@@ -356,16 +356,6 @@ export declare const OpportunityAggregateFieldDto: import("@sinclair/typebox").T
356
356
  export declare const OpportunityIdDto: import("@sinclair/typebox").TObject<{
357
357
  id: import("@sinclair/typebox").TString;
358
358
  }>;
359
- export declare const UpdateOpportunityDto: import("@sinclair/typebox").TObject<{
360
- name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
361
- tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
362
- status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
363
- NONE: "NONE";
364
- PAST: "PAST";
365
- LIVE: "LIVE";
366
- SOON: "SOON";
367
- }>>;
368
- }>;
369
359
  export declare const OpportunityOverrideDto: import("@sinclair/typebox").TObject<{
370
360
  name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
371
361
  depositUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -392,7 +382,6 @@ export type GetOpportunitiesQueryModel = typeof GetOpportunitiesQueryDto.static;
392
382
  export type GetOpportunityQueryModel = typeof GetOpportunityQueryDto.static;
393
383
  export type CreateOpportunityModel = typeof CreateOpportunityDto.static;
394
384
  export type OpportunityAggregateField = typeof OpportunityAggregateFieldDto.static;
395
- export type UpdateOpportunityModel = typeof UpdateOpportunityDto.static;
396
385
  export type OpportunityResourceModel = typeof OpportunityResourceDto.static;
397
386
  export type OpportunityWithCampaignsResourceModel = typeof OpportunityWithCampaignsResourceDto.static;
398
387
  export type OpportunityOverrideModel = typeof OpportunityOverrideDto.static;
@@ -110,11 +110,6 @@ export const OpportunityAggregateFieldDto = t.Object({
110
110
  field: t.Union(["dailyRewards", "tvl", "apr"].map(v => t.Literal(v))),
111
111
  });
112
112
  export const OpportunityIdDto = t.Object({ id: t.String() });
113
- export const UpdateOpportunityDto = t.Object({
114
- name: t.Optional(t.String()),
115
- tags: t.Optional(t.Array(t.String())),
116
- status: t.Optional(t.Enum(Status)),
117
- });
118
113
  export const OpportunityOverrideDto = t.Object({
119
114
  name: t.Optional(t.String()),
120
115
  depositUrl: t.Optional(t.String({ format: "uri" })),
@@ -4,7 +4,7 @@ import { type AprRecord } from "../apr";
4
4
  import type { Campaign } from "../campaign";
5
5
  import { type DailyRewardsRecord } from "../reward";
6
6
  import { type TvlRecord } from "../tvl";
7
- import type { CreateOpportunityModel, GetOpportunitiesQueryModel, Opportunity, UpdateOpportunityModel } from "./opportunity.model";
7
+ import type { CreateOpportunityModel, GetOpportunitiesQueryModel, Opportunity } from "./opportunity.model";
8
8
  export declare abstract class OpportunityRepository {
9
9
  #private;
10
10
  static create(newOpp: CreateOpportunityModel & {
@@ -975,7 +975,7 @@ export declare abstract class OpportunityRepository {
975
975
  apr: number;
976
976
  dailyRewards: number;
977
977
  }>;
978
- static updateMany(ids: string[], data: UpdateOpportunityModel): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
978
+ static updateMany(ids: string[], data: Partial<Opportunity["raw"]>): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
979
979
  static aggregateSum(field: keyof Prisma.OpportunitySumAggregateInputType, query: GetOpportunitiesQueryModel): Promise<{
980
980
  sum: string;
981
981
  }>;
@@ -1,7 +1,7 @@
1
1
  import { type CreateCampaignModel, type GetCampaignQueryModel } from "@/modules/v4/campaign";
2
2
  import { type OpportunityManualOverride, type Prisma } from "@db/api";
3
3
  import { type MerklChainId } from "@sdk";
4
- import type { CreateOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, Opportunity, OpportunityOverrideModel, OpportunityResourceModel, OpportunityUnique, UpdateOpportunityModel } from "./opportunity.model";
4
+ import type { CreateOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, Opportunity, OpportunityOverrideModel, OpportunityResourceModel, OpportunityUnique } from "./opportunity.model";
5
5
  import { OpportunityRepository } from "./opportunity.repository";
6
6
  export declare abstract class OpportunityService {
7
7
  #private;
@@ -988,5 +988,5 @@ export declare abstract class OpportunityService {
988
988
  apr: number;
989
989
  dailyRewards: number;
990
990
  }>;
991
- static updateMany(ids: string[], data: UpdateOpportunityModel): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
991
+ static updateMany(ids: string[], data: Partial<Opportunity["raw"]>): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
992
992
  }
@@ -1028,44 +1028,6 @@ export declare const v4: Elysia<"/v4", false, {
1028
1028
  };
1029
1029
  };
1030
1030
  };
1031
- } & {
1032
- opportunities: {
1033
- ":id": {
1034
- patch: {
1035
- body: {
1036
- name?: string | undefined;
1037
- status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
1038
- tags?: string[] | undefined;
1039
- };
1040
- params: {
1041
- id: string;
1042
- };
1043
- query: unknown;
1044
- headers: {
1045
- authorization: string;
1046
- };
1047
- response: {
1048
- 200: {
1049
- id: string;
1050
- name: string;
1051
- type: string;
1052
- status: import("@db/api").$Enums.Status;
1053
- tags: string[];
1054
- identifier: string;
1055
- action: import("@db/api").$Enums.OpportunityAction;
1056
- manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
1057
- chainId: number;
1058
- depositUrl: string | null;
1059
- explorerAddress: string | null;
1060
- mainProtocolId: string | null;
1061
- tvl: number;
1062
- apr: number;
1063
- dailyRewards: number;
1064
- };
1065
- };
1066
- };
1067
- };
1068
- };
1069
1031
  };
1070
1032
  } & {
1071
1033
  v4: {