@merkl/api 1.0.47 → 1.0.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.
@@ -1,12 +1,12 @@
1
1
  import { type MerklChainId } from "@angleprotocol/sdk/ts";
2
2
  import { type OpportunityAction, type OpportunityManualOverride, type Prisma } from "@package/databases/api";
3
- import type { CampaignWithParams, GetCampaignQueryModel } from "../../../modules/v4/campaign/campaign.model";
3
+ import type { CampaignWithParams, FindCampaignModel } from "../../../modules/v4/campaign/campaign.model";
4
4
  import type { Protocol } from "../protocol/protocol.model";
5
5
  import type { Token } from "../token/token.model";
6
- import type { CreateOpportunityModel, FindOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, Opportunity, OpportunityOverrideModel, OpportunityResourceModel, OpportunityUnique } from "./opportunity.model";
6
+ import { OpportunityFormatter } from "./opportunity.formatter";
7
+ import type { FindOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, Opportunity, OpportunityOverrideModel, OpportunityResourceModel, OpportunityUnique } from "./opportunity.model";
7
8
  import { OpportunityRepository } from "./opportunity.repository";
8
- export declare abstract class OpportunityService {
9
- #private;
9
+ export declare abstract class OpportunityService extends OpportunityFormatter {
10
10
  static hashId(opportunity: OpportunityUnique): string;
11
11
  static getAprBins(query: GetOpportunitiesQueryModel): Promise<{
12
12
  min: number;
@@ -118,56 +118,6 @@ export declare abstract class OpportunityService {
118
118
  tags: string[];
119
119
  lastCampaignCreatedAt: Date;
120
120
  })>;
121
- /**
122
- * create an opportunity without campaigns
123
- * @param newOpp the new opportunity to create
124
- * @returns {Promise<Opportunity|undefined>}
125
- */
126
- static create(newOpp: CreateOpportunityModel): Promise<{
127
- Tokens: {
128
- symbol: string;
129
- name: string | null;
130
- decimals: number;
131
- price: number | null;
132
- address: string;
133
- id: string;
134
- chainId: number;
135
- icon: string;
136
- isNative: boolean;
137
- isPoint: boolean;
138
- isPreTGE: boolean;
139
- isTest: boolean;
140
- verified: boolean;
141
- displaySymbol: string;
142
- }[];
143
- Protocols: {
144
- name: string;
145
- description: string;
146
- id: string;
147
- url: string;
148
- icon: string;
149
- tags: string[];
150
- }[];
151
- } & {
152
- name: string;
153
- apr: number;
154
- tvl: number;
155
- description: string;
156
- id: string;
157
- status: import("@package/databases").Status;
158
- chainId: number;
159
- action: import("@package/databases").OpportunityAction;
160
- type: string;
161
- depositUrl: string | null;
162
- explorerAddress: string | null;
163
- howToSteps: string[];
164
- mainProtocolId: string | null;
165
- manualOverrides: import("@package/databases").OpportunityManualOverride[];
166
- identifier: string;
167
- dailyRewards: number;
168
- tags: string[];
169
- lastCampaignCreatedAt: Date;
170
- }>;
171
121
  /**
172
122
  * @param upsert whether to update the opportunity if it already exists in database
173
123
  * @param dryRun whether to skip the opportunity table interaction and just return the computed opportunity
@@ -251,7 +201,8 @@ export declare abstract class OpportunityService {
251
201
  lastCampaignCreatedAt: Date;
252
202
  })>;
253
203
  /**
254
- * deletes and recreates an opportunity with fresh data
204
+ * @notice Find the first campaign of an opportunity and then upserts the opportunity
205
+ * based on this
255
206
  */
256
207
  static recreate(opportunityId: string, campaignId?: string): Promise<{
257
208
  id: string;
@@ -336,7 +287,7 @@ export declare abstract class OpportunityService {
336
287
  * @param where
337
288
  * @returns opportunities
338
289
  */
339
- static findManyByCampaigns(query: GetCampaignQueryModel): Promise<{
290
+ static findManyByCampaigns(query: FindCampaignModel): Promise<{
340
291
  protocol?: {
341
292
  dailyRewards?: number | undefined;
342
293
  numberOfLiveCampaigns?: number | undefined;
@@ -510,7 +461,6 @@ export declare abstract class OpportunityService {
510
461
  * @returns A list of opportunities
511
462
  */
512
463
  static findMany(query: GetOpportunitiesQueryModel): Promise<{
513
- apr: number;
514
464
  aprRecord: {
515
465
  cumulated: number;
516
466
  timestamp: bigint;
@@ -681,6 +631,7 @@ export declare abstract class OpportunityService {
681
631
  tags: string[];
682
632
  } | undefined;
683
633
  name: string;
634
+ apr: number;
684
635
  tvl: number;
685
636
  description: string;
686
637
  status: import("@package/databases").Status;
@@ -700,7 +651,6 @@ export declare abstract class OpportunityService {
700
651
  */
701
652
  static countMany(query: GetOpportunitiesQueryModel): Promise<number>;
702
653
  static findLiveWithCampaigns(chainId: MerklChainId, take?: number): Promise<{
703
- apr: number;
704
654
  aprRecord: {
705
655
  cumulated: number;
706
656
  timestamp: bigint;
@@ -871,6 +821,7 @@ export declare abstract class OpportunityService {
871
821
  tags: string[];
872
822
  } | undefined;
873
823
  name: string;
824
+ apr: number;
874
825
  tvl: number;
875
826
  description: string;
876
827
  status: import("@package/databases").Status;
@@ -882,8 +833,7 @@ export declare abstract class OpportunityService {
882
833
  dailyRewards: number;
883
834
  tags: string[];
884
835
  }[]>;
885
- static formatResponse(opportunity: Awaited<ReturnType<typeof OpportunityRepository.findUniqueOrThrow>>): {
886
- apr: number;
836
+ static format(opportunity: Awaited<ReturnType<typeof OpportunityRepository.findUniqueOrThrow>>): {
887
837
  aprRecord: {
888
838
  cumulated: number;
889
839
  timestamp: bigint;
@@ -1054,6 +1004,7 @@ export declare abstract class OpportunityService {
1054
1004
  tags: string[];
1055
1005
  } | undefined;
1056
1006
  name: string;
1007
+ apr: number;
1057
1008
  tvl: number;
1058
1009
  description: string;
1059
1010
  status: import("@package/databases").Status;
@@ -1065,7 +1016,7 @@ export declare abstract class OpportunityService {
1065
1016
  dailyRewards: number;
1066
1017
  tags: string[];
1067
1018
  };
1068
- static formatResponseBase(opportunity: LightOpportunityFromDB): {
1019
+ static formatWithoutRecords(opportunity: LightOpportunityFromDB): {
1069
1020
  id: string;
1070
1021
  depositUrl: string | undefined;
1071
1022
  explorerAddress: string | undefined;
@@ -9,7 +9,6 @@ export declare abstract class RewardService {
9
9
  static hashDailyRewardsRecordId(opportunityId: string, timestamp: bigint): string;
10
10
  static createManyReward(rewards: CreateManyRewardModel): Promise<import("@package/databases").BatchPayload>;
11
11
  static getTotalDistributedByOpportunities(since: number): Promise<Map<{
12
- apr: number;
13
12
  aprRecord: {
14
13
  cumulated: number;
15
14
  timestamp: bigint;
@@ -180,6 +179,7 @@ export declare abstract class RewardService {
180
179
  tags: string[];
181
180
  } | undefined;
182
181
  name: string;
182
+ apr: number;
183
183
  tvl: number;
184
184
  description: string;
185
185
  status: import("@package/databases").Status;
@@ -1068,90 +1068,6 @@ export declare const v4: Elysia<"/v4", {
1068
1068
  };
1069
1069
  };
1070
1070
  };
1071
- } & {
1072
- opportunities: {
1073
- post: {
1074
- body: {
1075
- name?: string | undefined;
1076
- description?: string | undefined;
1077
- depositUrl?: string | undefined;
1078
- explorerAddress?: string | undefined;
1079
- howToSteps?: string[] | undefined;
1080
- tags?: string[] | undefined;
1081
- protocols?: string[] | undefined;
1082
- mainProtocol?: string | undefined;
1083
- tokens: {
1084
- address: string;
1085
- chainId: number;
1086
- }[];
1087
- status: "NONE" | "PAST" | "LIVE" | "SOON";
1088
- chainId: number;
1089
- action: "POOL" | "INVALID" | "HOLD" | "DROP" | "LEND" | "BORROW" | "LONG" | "SHORT" | "SWAP";
1090
- type: string;
1091
- identifier: string;
1092
- };
1093
- params: {};
1094
- query: unknown;
1095
- headers: {
1096
- authorization: string;
1097
- };
1098
- response: {
1099
- 200: {
1100
- Tokens: {
1101
- symbol: string;
1102
- name: string | null;
1103
- decimals: number;
1104
- price: number | null;
1105
- address: string;
1106
- id: string;
1107
- chainId: number;
1108
- icon: string;
1109
- isNative: boolean;
1110
- isPoint: boolean;
1111
- isPreTGE: boolean;
1112
- isTest: boolean;
1113
- verified: boolean;
1114
- displaySymbol: string;
1115
- }[];
1116
- Protocols: {
1117
- name: string;
1118
- description: string;
1119
- id: string;
1120
- url: string;
1121
- icon: string;
1122
- tags: string[];
1123
- }[];
1124
- name: string;
1125
- apr: number;
1126
- tvl: number;
1127
- description: string;
1128
- id: string;
1129
- status: import("@package/databases").Status;
1130
- chainId: number;
1131
- action: import("@package/databases").OpportunityAction;
1132
- type: string;
1133
- depositUrl: string | null;
1134
- explorerAddress: string | null;
1135
- howToSteps: string[];
1136
- mainProtocolId: string | null;
1137
- manualOverrides: import("@package/databases").OpportunityManualOverride[];
1138
- identifier: string;
1139
- dailyRewards: number;
1140
- tags: string[];
1141
- lastCampaignCreatedAt: Date;
1142
- };
1143
- 422: {
1144
- type: "validation";
1145
- on: string;
1146
- summary?: string;
1147
- message?: string;
1148
- found?: unknown;
1149
- property?: string;
1150
- expected?: string;
1151
- };
1152
- };
1153
- };
1154
- };
1155
1071
  } & {
1156
1072
  opportunities: {
1157
1073
  ":id": {
@@ -8,5 +8,5 @@ export default class CoingeckoService implements PriceFetcher {
8
8
  getPrice(tickers: PriceSource[]): Promise<ResponsePriceType[]>;
9
9
  private buildUrl;
10
10
  private fetchPrices;
11
- private formatResponse;
11
+ private format;
12
12
  }
@@ -8,5 +8,5 @@ export default class DefillamaService implements PriceFetcher {
8
8
  getPrice(sources: PriceSource[]): Promise<ResponsePriceType[]>;
9
9
  private buildUrl;
10
10
  private fetchPrices;
11
- private formatResponse;
11
+ private format;
12
12
  }