@merkl/api 0.20.46 → 0.20.48

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 (43) hide show
  1. package/dist/database/api/.generated/drizzle/schema.d.ts +44 -1
  2. package/dist/database/api/.generated/drizzle/schema.js +3 -2
  3. package/dist/database/api/.generated/drizzle/schema.ts +3 -2
  4. package/dist/database/api/.generated/edge.js +7 -7
  5. package/dist/database/api/.generated/index-browser.js +9 -1
  6. package/dist/database/api/.generated/index.d.ts +97 -5
  7. package/dist/database/api/.generated/index.js +7 -7
  8. package/dist/database/api/.generated/package.json +1 -1
  9. package/dist/database/api/.generated/schema.prisma +13 -13
  10. package/dist/database/api/.generated/wasm.js +9 -1
  11. package/dist/src/eden/index.d.ts +351 -15
  12. package/dist/src/engine/dynamicData/implementations/Clamm.js +30 -31
  13. package/dist/src/index.d.ts +87 -3
  14. package/dist/src/jobs/update-dynamic-data.js +1 -1
  15. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +3 -0
  16. package/dist/src/modules/v4/campaign/campaign.repository.d.ts +5 -0
  17. package/dist/src/modules/v4/campaign/campaign.service.d.ts +9 -0
  18. package/dist/src/modules/v4/dynamicData/dynamicData.controller.d.ts +2 -0
  19. package/dist/src/modules/v4/dynamicData/dynamicData.controller.js +1 -1
  20. package/dist/src/modules/v4/dynamicData/dynamicData.model.d.ts +2 -0
  21. package/dist/src/modules/v4/dynamicData/dynamicData.model.js +2 -0
  22. package/dist/src/modules/v4/dynamicData/dynamicData.service.d.ts +1 -1
  23. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +4 -4
  24. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +80 -0
  25. package/dist/src/modules/v4/opportunity/opportunity.controller.js +16 -3
  26. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +26 -4
  27. package/dist/src/modules/v4/opportunity/opportunity.model.js +8 -1
  28. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +16 -40
  29. package/dist/src/modules/v4/opportunity/opportunity.repository.js +72 -181
  30. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +44 -25
  31. package/dist/src/modules/v4/opportunity/opportunity.service.js +15 -33
  32. package/dist/src/modules/v4/programPayload/programPayload.repository.js +9 -3
  33. package/dist/src/modules/v4/protocol/protocol.repository.d.ts +1 -0
  34. package/dist/src/modules/v4/reward/reward.repository.d.ts +1 -0
  35. package/dist/src/modules/v4/reward/reward.service.d.ts +7 -0
  36. package/dist/src/modules/v4/router.d.ts +87 -3
  37. package/dist/src/modules/v4/token/token.controller.d.ts +0 -3
  38. package/dist/src/modules/v4/token/token.model.d.ts +0 -3
  39. package/dist/src/modules/v4/token/token.model.js +0 -1
  40. package/dist/src/modules/v4/token/token.service.js +5 -5
  41. package/dist/src/modules/v4/user/user.controller.d.ts +2 -0
  42. package/dist/tsconfig.package.tsbuildinfo +1 -1
  43. package/package.json +1 -1
@@ -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, OpportunityIdDto, OpportunityResourceDto, OpportunityUniqueDto, OpportunityUniqueUpdateDto, OpportunityWithCampaignsResourceDto, UpdateOpportunityDto, } from "./opportunity.model";
6
+ import { CreateOpportunityDto, GetOpportunitiesQueryDto, GetOpportunityQueryDto, OpportunityAggregateFieldDto, OpportunityDeleteOverrideDto, OpportunityIdDto, OpportunityOverrideDto, OpportunityResourceDto, OpportunityUniqueDto, OpportunityUniqueUpdateDto, OpportunityWithCampaignsResourceDto, UpdateOpportunityDto, } 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";
@@ -20,6 +20,19 @@ export const OpportunityController = new Elysia({
20
20
  headers: AuthorizationHeadersDto,
21
21
  body: CreateOpportunityDto,
22
22
  detail: { hide: true },
23
+ })
24
+ // ─── Override An Opportunity Field ───────────────────────────────────
25
+ .patch("/:id/override", async ({ params, body }) => await OpportunityService.override(params.id, body), {
26
+ headers: AuthorizationHeadersDto,
27
+ params: OpportunityUniqueDto,
28
+ body: OpportunityOverrideDto,
29
+ beforeHandle: BackOfficeGuard,
30
+ })
31
+ .delete("/:id/override", async ({ params, body }) => await OpportunityService.deleteOverrides(params.id, body), {
32
+ headers: AuthorizationHeadersDto,
33
+ params: OpportunityUniqueDto,
34
+ body: OpportunityDeleteOverrideDto,
35
+ beforeHandle: BackOfficeGuard,
23
36
  })
24
37
  // ─── Tries to reparse An Opportunity ─────────────────────────────────
25
38
  .post("/:id", async ({ params }) => {
@@ -27,11 +40,11 @@ export const OpportunityController = new Elysia({
27
40
  if (!params.id.includes("-"))
28
41
  return await OpportunityService.recreate(params.id);
29
42
  const [chainId, type, identifier] = params.id.split("-");
30
- return await OpportunityService.recreate({
43
+ return await OpportunityService.recreate(OpportunityService.hashId({
31
44
  chainId: +chainId,
32
45
  type: type,
33
46
  identifier,
34
- });
47
+ }));
35
48
  }
36
49
  catch (err) {
37
50
  if (err.code && err.code === "P2025")
@@ -13,7 +13,7 @@ import type { OpportunityRepository } from "./opportunity.repository";
13
13
  * @description Target description of rewards campaigns
14
14
  * @see {@link Resource}
15
15
  */
16
- export type Opportunity = Resource<"Opportunity", "mainProtocolId", {
16
+ export type Opportunity = Resource<"Opportunity", "mainProtocolId" | "manualOverrides", {
17
17
  depositUrl?: string;
18
18
  explorerAddress?: string;
19
19
  chain: Chain["model"];
@@ -351,12 +351,34 @@ export declare const UpdateOpportunityDto: import("@sinclair/typebox").TObject<{
351
351
  SOON: "SOON";
352
352
  }>>;
353
353
  }>;
354
+ export declare const OpportunityOverrideDto: import("@sinclair/typebox").TObject<{
355
+ name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
356
+ depositUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
357
+ explorerAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
358
+ action: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
359
+ POOL: "POOL";
360
+ HOLD: "HOLD";
361
+ DROP: "DROP";
362
+ LEND: "LEND";
363
+ BORROW: "BORROW";
364
+ LONG: "LONG";
365
+ SHORT: "SHORT";
366
+ SWAP: "SWAP";
367
+ INVALID: "INVALID";
368
+ }>>;
369
+ }>;
370
+ export declare const OpportunityDeleteOverrideDto: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TEnum<{
371
+ name: "name";
372
+ depositUrl: "depositUrl";
373
+ explorerAddress: "explorerAddress";
374
+ action: "action";
375
+ }>>;
354
376
  export type GetOpportunitiesQueryModel = typeof GetOpportunitiesQueryDto.static;
355
377
  export type GetOpportunityQueryModel = typeof GetOpportunityQueryDto.static;
356
- export type CreateOpportunityModel = typeof CreateOpportunityDto.static & {
357
- id: string;
358
- };
378
+ export type CreateOpportunityModel = typeof CreateOpportunityDto.static;
359
379
  export type OpportunityAggregateField = typeof OpportunityAggregateFieldDto.static;
360
380
  export type UpdateOpportunityModel = typeof UpdateOpportunityDto.static;
361
381
  export type OpportunityResourceModel = typeof OpportunityResourceDto.static;
362
382
  export type OpportunityWithCampaignsResourceModel = typeof OpportunityWithCampaignsResourceDto.static;
383
+ export type OpportunityOverrideModel = typeof OpportunityOverrideDto.static;
384
+ export type OpportunityDeleteOverrideModel = typeof OpportunityDeleteOverrideDto.static;
@@ -4,7 +4,7 @@ import { ProtocolResourceDto } from "@/modules/v4/protocol/protocol.model";
4
4
  import { DailyRewardsRecordResourceDto } from "@/modules/v4/reward/reward.model";
5
5
  import { TokenDto, TokenResourceDto } from "@/modules/v4/token/token.model";
6
6
  import { TvlRecordResourceDto } from "@/modules/v4/tvl/tvl.model";
7
- import { OpportunityAction, Status } from "@db/api";
7
+ import { OpportunityAction, OpportunityManualOverride, Status } from "@db/api";
8
8
  import { t } from "elysia";
9
9
  import { ChainResourceDto } from "../chain/chain.model";
10
10
  // ─── DTOs ────────────────────────────────────────────────────────────────────
@@ -113,3 +113,10 @@ export const UpdateOpportunityDto = t.Object({
113
113
  tags: t.Optional(t.Array(t.String())),
114
114
  status: t.Optional(t.Enum(Status)),
115
115
  });
116
+ export const OpportunityOverrideDto = t.Object({
117
+ name: t.Optional(t.String()),
118
+ depositUrl: t.Optional(t.String({ format: "uri" })),
119
+ explorerAddress: t.Optional(t.String({ format: "uri" })),
120
+ action: t.Optional(t.Enum(OpportunityAction)),
121
+ });
122
+ export const OpportunityDeleteOverrideDto = t.Array(t.Enum(OpportunityManualOverride));
@@ -7,7 +7,9 @@ import { type TvlRecord } from "../tvl";
7
7
  import type { CreateOpportunityModel, GetOpportunitiesQueryModel, Opportunity, UpdateOpportunityModel } from "./opportunity.model";
8
8
  export declare abstract class OpportunityRepository {
9
9
  #private;
10
- static create(newOpp: CreateOpportunityModel, upsert?: boolean): Promise<{
10
+ static create(newOpp: CreateOpportunityModel & {
11
+ id: string;
12
+ }, upsert?: boolean): Promise<{
11
13
  id: string;
12
14
  name: string;
13
15
  type: string;
@@ -15,6 +17,7 @@ export declare abstract class OpportunityRepository {
15
17
  tags: string[];
16
18
  identifier: string;
17
19
  action: import("@db/api").$Enums.OpportunityAction;
20
+ manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
18
21
  chainId: number;
19
22
  depositUrl: string | null;
20
23
  explorerAddress: string | null;
@@ -171,6 +174,7 @@ export declare abstract class OpportunityRepository {
171
174
  tags: string[];
172
175
  identifier: string;
173
176
  action: import("@db/api").$Enums.OpportunityAction;
177
+ manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
174
178
  chainId: number;
175
179
  depositUrl: string | null;
176
180
  explorerAddress: string | null;
@@ -311,6 +315,7 @@ export declare abstract class OpportunityRepository {
311
315
  tags: string[];
312
316
  identifier: string;
313
317
  action: import("@db/api").$Enums.OpportunityAction;
318
+ manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
314
319
  chainId: number;
315
320
  depositUrl: string | null;
316
321
  explorerAddress: string | null;
@@ -509,6 +514,7 @@ export declare abstract class OpportunityRepository {
509
514
  tags: string[];
510
515
  identifier: string;
511
516
  action: import("@db/api").$Enums.OpportunityAction;
517
+ manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
512
518
  chainId: number;
513
519
  depositUrl: string | null;
514
520
  explorerAddress: string | null;
@@ -656,6 +662,7 @@ export declare abstract class OpportunityRepository {
656
662
  tags: string[];
657
663
  identifier: string;
658
664
  action: import("@db/api").$Enums.OpportunityAction;
665
+ manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
659
666
  chainId: number;
660
667
  depositUrl: string | null;
661
668
  explorerAddress: string | null;
@@ -855,6 +862,7 @@ export declare abstract class OpportunityRepository {
855
862
  tags: string[];
856
863
  identifier: string;
857
864
  action: import("@db/api").$Enums.OpportunityAction;
865
+ manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
858
866
  chainId: number;
859
867
  depositUrl: string | null;
860
868
  explorerAddress: string | null;
@@ -864,17 +872,14 @@ export declare abstract class OpportunityRepository {
864
872
  dailyRewards: number;
865
873
  })[]>;
866
874
  static countMany(query: GetOpportunitiesQueryModel): Promise<number>;
867
- static getAllIdsForDynamicOpp(): Promise<{
868
- id: string;
869
- }[]>;
870
875
  /**
871
- * Updates Apr, Tvl and DailyRewards record
876
+ * Updates Apr, Tvl and DailyRewards records
872
877
  * @param opportunityId
873
878
  * @param apr
874
879
  * @param tvl
875
880
  * @returns
876
881
  */
877
- static updateRecords(opportunityId: string, apr: AprRecord["model"], tvl: TvlRecord["model"], dailyRewards: DailyRewardsRecord["model"]): Promise<{
882
+ static updateDynamicData(opportunityId: string, apr: AprRecord["model"], tvl: TvlRecord["model"], dailyRewards: DailyRewardsRecord["model"]): Promise<{
878
883
  aprRecord: false | {
879
884
  id: string;
880
885
  opportunityId: string;
@@ -916,6 +921,7 @@ export declare abstract class OpportunityRepository {
916
921
  tags: string[];
917
922
  identifier: string;
918
923
  action: import("@db/api").$Enums.OpportunityAction;
924
+ manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
919
925
  chainId: number;
920
926
  depositUrl: string | null;
921
927
  explorerAddress: string | null;
@@ -933,6 +939,7 @@ export declare abstract class OpportunityRepository {
933
939
  tags: string[];
934
940
  identifier: string;
935
941
  action: import("@db/api").$Enums.OpportunityAction;
942
+ manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
936
943
  chainId: number;
937
944
  depositUrl: string | null;
938
945
  explorerAddress: string | null;
@@ -941,23 +948,7 @@ export declare abstract class OpportunityRepository {
941
948
  apr: number;
942
949
  dailyRewards: number;
943
950
  }>;
944
- static updateName(id: string, name: string): Promise<{
945
- id: string;
946
- name: string;
947
- type: string;
948
- status: import("@db/api").$Enums.Status;
949
- tags: string[];
950
- identifier: string;
951
- action: import("@db/api").$Enums.OpportunityAction;
952
- chainId: number;
953
- depositUrl: string | null;
954
- explorerAddress: string | null;
955
- mainProtocolId: string | null;
956
- tvl: number;
957
- apr: number;
958
- dailyRewards: number;
959
- }>;
960
- static updateChainId(id: string, chainId: MerklChainId): Promise<{
951
+ static update(id: string, data: Partial<Opportunity["raw"]>): Promise<{
961
952
  id: string;
962
953
  name: string;
963
954
  type: string;
@@ -965,6 +956,7 @@ export declare abstract class OpportunityRepository {
965
956
  tags: string[];
966
957
  identifier: string;
967
958
  action: import("@db/api").$Enums.OpportunityAction;
959
+ manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
968
960
  chainId: number;
969
961
  depositUrl: string | null;
970
962
  explorerAddress: string | null;
@@ -973,6 +965,7 @@ export declare abstract class OpportunityRepository {
973
965
  apr: number;
974
966
  dailyRewards: number;
975
967
  }>;
968
+ static updateMany(ids: string[], data: UpdateOpportunityModel): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
976
969
  static aggregateSum(field: keyof Prisma.OpportunitySumAggregateInputType, query: GetOpportunitiesQueryModel): Promise<{
977
970
  sum: string;
978
971
  }>;
@@ -982,21 +975,4 @@ export declare abstract class OpportunityRepository {
982
975
  static aggregateMax(field: keyof Prisma.OpportunityMaxAggregateInputType, query: GetOpportunitiesQueryModel): Promise<{
983
976
  max: string;
984
977
  }>;
985
- static update(id: string, data: Partial<Opportunity["raw"]>): Promise<{
986
- id: string;
987
- name: string;
988
- type: string;
989
- status: import("@db/api").$Enums.Status;
990
- tags: string[];
991
- identifier: string;
992
- action: import("@db/api").$Enums.OpportunityAction;
993
- chainId: number;
994
- depositUrl: string | null;
995
- explorerAddress: string | null;
996
- mainProtocolId: string | null;
997
- tvl: number;
998
- apr: number;
999
- dailyRewards: number;
1000
- }>;
1001
- static updateMany(ids: string[], data: UpdateOpportunityModel): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
1002
978
  }