@merkl/api 0.10.236 → 0.10.238

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.
@@ -63,40 +63,133 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
63
63
  };
64
64
  headers: unknown;
65
65
  response: {
66
- 200: {
67
- aprRecord: {
66
+ 200: ({
67
+ protocol?: {
68
+ name: string;
69
+ url: string;
70
+ description: string;
71
+ id: string;
72
+ tags: string[];
73
+ icon: string;
74
+ } | null | undefined;
75
+ depositUrl?: string | undefined;
76
+ aprRecord?: {
77
+ timestamp: string | bigint;
68
78
  cumulated: number;
69
- timestamp: bigint;
70
79
  breakdowns: {
71
- type: import("../../../../database/api/.generated").$Enums.AprType;
80
+ type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
72
81
  id: number;
73
82
  identifier: string;
74
83
  value: number;
75
84
  aprRecordId: string;
76
85
  }[];
77
- };
78
- tvlRecord: {
79
- id: string;
86
+ } | undefined;
87
+ tvlRecord?: {
80
88
  total: number;
81
- timestamp: bigint;
89
+ timestamp: string | bigint;
82
90
  breakdowns: {
83
- type: import("../../../../database/api/.generated").$Enums.TvlType;
91
+ type: "TOKEN" | "PROTOCOL";
84
92
  id: number;
85
93
  identifier: string;
86
94
  value: number;
87
95
  tvlRecordId: string;
88
96
  }[];
89
- };
90
- rewardsRecord: {
91
- id: string;
97
+ } | undefined;
98
+ rewardsRecord?: {
92
99
  total: number;
93
- timestamp: bigint;
100
+ id: string;
101
+ timestamp: string | bigint;
94
102
  breakdowns: {
103
+ token: {
104
+ price?: number | null | undefined;
105
+ symbol: string;
106
+ name: string | null;
107
+ id: string;
108
+ icon: string;
109
+ chainId: number;
110
+ address: string;
111
+ decimals: number;
112
+ verified: boolean;
113
+ isTest: boolean;
114
+ };
95
115
  id: number;
96
116
  value: number;
97
117
  campaignId: string;
118
+ amount: string | bigint;
98
119
  dailyRewardsRecordId: string;
120
+ }[];
121
+ } | undefined;
122
+ name: string;
123
+ type: string;
124
+ tokens: {
125
+ price?: number | null | undefined;
126
+ symbol: string;
127
+ name: string | null;
128
+ id: string;
129
+ icon: string;
130
+ chainId: number;
131
+ address: string;
132
+ decimals: number;
133
+ verified: boolean;
134
+ isTest: boolean;
135
+ }[];
136
+ id: string;
137
+ status: string;
138
+ tags: string[];
139
+ identifier: string;
140
+ chain: {
141
+ name: string;
142
+ id: number;
143
+ icon: string;
144
+ };
145
+ chainId: number;
146
+ action: string;
147
+ tvl: number;
148
+ apr: number;
149
+ dailyRewards: number;
150
+ } | null)[];
151
+ } | {
152
+ 200: never;
153
+ } | {
154
+ 200: (Response | ({
155
+ protocol?: {
156
+ name: string;
157
+ url: string;
158
+ description: string;
159
+ id: string;
160
+ tags: string[];
161
+ icon: string;
162
+ } | null | undefined;
163
+ depositUrl?: string | undefined;
164
+ aprRecord?: {
165
+ timestamp: string | bigint;
166
+ cumulated: number;
167
+ breakdowns: {
168
+ type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
169
+ id: number;
170
+ identifier: string;
171
+ value: number;
172
+ aprRecordId: string;
173
+ }[];
174
+ } | undefined;
175
+ tvlRecord?: {
176
+ total: number;
177
+ timestamp: string | bigint;
178
+ breakdowns: {
179
+ type: "TOKEN" | "PROTOCOL";
180
+ id: number;
181
+ identifier: string;
182
+ value: number;
183
+ tvlRecordId: string;
184
+ }[];
185
+ } | undefined;
186
+ rewardsRecord?: {
187
+ total: number;
188
+ id: string;
189
+ timestamp: string | bigint;
190
+ breakdowns: {
99
191
  token: {
192
+ price?: number | null | undefined;
100
193
  symbol: string;
101
194
  name: string | null;
102
195
  id: string;
@@ -104,16 +197,20 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
104
197
  chainId: number;
105
198
  address: string;
106
199
  decimals: number;
107
- displaySymbol: string;
108
200
  verified: boolean;
109
201
  isTest: boolean;
110
- price: number | null;
111
202
  };
112
- amount: bigint;
203
+ id: number;
204
+ value: number;
205
+ campaignId: string;
206
+ amount: string | bigint;
207
+ dailyRewardsRecordId: string;
113
208
  }[];
114
- };
115
- id: string;
116
- tokens: ({
209
+ } | undefined;
210
+ name: string;
211
+ type: string;
212
+ tokens: {
213
+ price?: number | null | undefined;
117
214
  symbol: string;
118
215
  name: string | null;
119
216
  id: string;
@@ -123,34 +220,280 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
123
220
  decimals: number;
124
221
  verified: boolean;
125
222
  isTest: boolean;
126
- } & {
127
- price?: number | null | undefined;
128
- })[];
223
+ }[];
224
+ id: string;
225
+ status: string;
226
+ tags: string[];
227
+ identifier: string;
129
228
  chain: {
130
229
  name: string;
131
230
  id: number;
132
231
  icon: string;
133
232
  };
134
- protocol: {
233
+ chainId: number;
234
+ action: string;
235
+ tvl: number;
236
+ apr: number;
237
+ dailyRewards: number;
238
+ } | null)[] | {
239
+ 200: ({
240
+ protocol?: {
241
+ name: string;
242
+ url: string;
243
+ description: string;
244
+ id: string;
245
+ tags: string[];
246
+ icon: string;
247
+ } | null | undefined;
248
+ depositUrl?: string | undefined;
249
+ aprRecord?: {
250
+ timestamp: string | bigint;
251
+ cumulated: number;
252
+ breakdowns: {
253
+ type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
254
+ id: number;
255
+ identifier: string;
256
+ value: number;
257
+ aprRecordId: string;
258
+ }[];
259
+ } | undefined;
260
+ tvlRecord?: {
261
+ total: number;
262
+ timestamp: string | bigint;
263
+ breakdowns: {
264
+ type: "TOKEN" | "PROTOCOL";
265
+ id: number;
266
+ identifier: string;
267
+ value: number;
268
+ tvlRecordId: string;
269
+ }[];
270
+ } | undefined;
271
+ rewardsRecord?: {
272
+ total: number;
273
+ id: string;
274
+ timestamp: string | bigint;
275
+ breakdowns: {
276
+ token: {
277
+ price?: number | null | undefined;
278
+ symbol: string;
279
+ name: string | null;
280
+ id: string;
281
+ icon: string;
282
+ chainId: number;
283
+ address: string;
284
+ decimals: number;
285
+ verified: boolean;
286
+ isTest: boolean;
287
+ };
288
+ id: number;
289
+ value: number;
290
+ campaignId: string;
291
+ amount: string | bigint;
292
+ dailyRewardsRecordId: string;
293
+ }[];
294
+ } | undefined;
295
+ name: string;
296
+ type: string;
297
+ tokens: {
298
+ price?: number | null | undefined;
299
+ symbol: string;
300
+ name: string | null;
301
+ id: string;
302
+ icon: string;
303
+ chainId: number;
304
+ address: string;
305
+ decimals: number;
306
+ verified: boolean;
307
+ isTest: boolean;
308
+ }[];
309
+ id: string;
310
+ status: string;
311
+ tags: string[];
312
+ identifier: string;
313
+ chain: {
314
+ name: string;
315
+ id: number;
316
+ icon: string;
317
+ };
318
+ chainId: number;
319
+ action: string;
320
+ tvl: number;
321
+ apr: number;
322
+ dailyRewards: number;
323
+ } | null)[];
324
+ }) & ({
325
+ protocol?: {
135
326
  name: string;
136
327
  url: string;
137
328
  description: string;
138
329
  id: string;
139
330
  tags: string[];
140
331
  icon: string;
332
+ } | null | undefined;
333
+ depositUrl?: string | undefined;
334
+ aprRecord?: {
335
+ timestamp: string | bigint;
336
+ cumulated: number;
337
+ breakdowns: {
338
+ type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
339
+ id: number;
340
+ identifier: string;
341
+ value: number;
342
+ aprRecordId: string;
343
+ }[];
344
+ } | undefined;
345
+ tvlRecord?: {
346
+ total: number;
347
+ timestamp: string | bigint;
348
+ breakdowns: {
349
+ type: "TOKEN" | "PROTOCOL";
350
+ id: number;
351
+ identifier: string;
352
+ value: number;
353
+ tvlRecordId: string;
354
+ }[];
355
+ } | undefined;
356
+ rewardsRecord?: {
357
+ total: number;
358
+ id: string;
359
+ timestamp: string | bigint;
360
+ breakdowns: {
361
+ token: {
362
+ price?: number | null | undefined;
363
+ symbol: string;
364
+ name: string | null;
365
+ id: string;
366
+ icon: string;
367
+ chainId: number;
368
+ address: string;
369
+ decimals: number;
370
+ verified: boolean;
371
+ isTest: boolean;
372
+ };
373
+ id: number;
374
+ value: number;
375
+ campaignId: string;
376
+ amount: string | bigint;
377
+ dailyRewardsRecordId: string;
378
+ }[];
141
379
  } | undefined;
142
380
  name: string;
143
- type: import("../../../../database/api/.generated").$Enums.CampaignType;
144
- status: import("../../../../database/api/.generated").$Enums.Status;
381
+ type: string;
382
+ tokens: {
383
+ price?: number | null | undefined;
384
+ symbol: string;
385
+ name: string | null;
386
+ id: string;
387
+ icon: string;
388
+ chainId: number;
389
+ address: string;
390
+ decimals: number;
391
+ verified: boolean;
392
+ isTest: boolean;
393
+ }[];
394
+ id: string;
395
+ status: string;
145
396
  tags: string[];
146
397
  identifier: string;
398
+ chain: {
399
+ name: string;
400
+ id: number;
401
+ icon: string;
402
+ };
147
403
  chainId: number;
148
- action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
149
- depositUrl: string | null;
404
+ action: string;
150
405
  tvl: number;
151
406
  apr: number;
152
407
  dailyRewards: number;
153
- }[];
408
+ } | null)[];
409
+ } | {
410
+ 200: {
411
+ 200: ({
412
+ protocol?: {
413
+ name: string;
414
+ url: string;
415
+ description: string;
416
+ id: string;
417
+ tags: string[];
418
+ icon: string;
419
+ } | null | undefined;
420
+ depositUrl?: string | undefined;
421
+ aprRecord?: {
422
+ timestamp: string | bigint;
423
+ cumulated: number;
424
+ breakdowns: {
425
+ type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
426
+ id: number;
427
+ identifier: string;
428
+ value: number;
429
+ aprRecordId: string;
430
+ }[];
431
+ } | undefined;
432
+ tvlRecord?: {
433
+ total: number;
434
+ timestamp: string | bigint;
435
+ breakdowns: {
436
+ type: "TOKEN" | "PROTOCOL";
437
+ id: number;
438
+ identifier: string;
439
+ value: number;
440
+ tvlRecordId: string;
441
+ }[];
442
+ } | undefined;
443
+ rewardsRecord?: {
444
+ total: number;
445
+ id: string;
446
+ timestamp: string | bigint;
447
+ breakdowns: {
448
+ token: {
449
+ price?: number | null | undefined;
450
+ symbol: string;
451
+ name: string | null;
452
+ id: string;
453
+ icon: string;
454
+ chainId: number;
455
+ address: string;
456
+ decimals: number;
457
+ verified: boolean;
458
+ isTest: boolean;
459
+ };
460
+ id: number;
461
+ value: number;
462
+ campaignId: string;
463
+ amount: string | bigint;
464
+ dailyRewardsRecordId: string;
465
+ }[];
466
+ } | undefined;
467
+ name: string;
468
+ type: string;
469
+ tokens: {
470
+ price?: number | null | undefined;
471
+ symbol: string;
472
+ name: string | null;
473
+ id: string;
474
+ icon: string;
475
+ chainId: number;
476
+ address: string;
477
+ decimals: number;
478
+ verified: boolean;
479
+ isTest: boolean;
480
+ }[];
481
+ id: string;
482
+ status: string;
483
+ tags: string[];
484
+ identifier: string;
485
+ chain: {
486
+ name: string;
487
+ id: number;
488
+ icon: string;
489
+ };
490
+ chainId: number;
491
+ action: string;
492
+ tvl: number;
493
+ apr: number;
494
+ dailyRewards: number;
495
+ } | null)[];
496
+ };
154
497
  };
155
498
  };
156
499
  };
@@ -203,6 +546,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
203
546
  tags: string[];
204
547
  icon: string;
205
548
  } | null | undefined;
549
+ depositUrl?: string | undefined;
206
550
  aprRecord?: {
207
551
  timestamp: string | bigint;
208
552
  cumulated: number;
@@ -312,6 +656,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
312
656
  tags: string[];
313
657
  icon: string;
314
658
  } | null | undefined;
659
+ depositUrl?: string | undefined;
315
660
  aprRecord?: {
316
661
  timestamp: string | bigint;
317
662
  cumulated: number;
@@ -15,6 +15,7 @@ import type { OpportunityRepository } from "./opportunity.repository";
15
15
  * @see {@link Resource}
16
16
  */
17
17
  export type Opportunity = Resource<"Opportunity", "mainProtocolId", {
18
+ depositUrl?: string;
18
19
  chain: Chain["model"];
19
20
  tokens: Token["model"][];
20
21
  protocol?: Protocol["model"];
@@ -48,6 +49,7 @@ export declare const OpportunityResourceDto: import("@sinclair/typebox").TObject
48
49
  tvl: import("@sinclair/typebox").TNumber;
49
50
  apr: import("@sinclair/typebox").TNumber;
50
51
  dailyRewards: import("@sinclair/typebox").TNumber;
52
+ depositUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
51
53
  tags: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
52
54
  id: import("@sinclair/typebox").TString;
53
55
  tokens: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
@@ -163,6 +165,7 @@ export declare const OpportunityWithCampaignsResourceDto: import("@sinclair/type
163
165
  }>;
164
166
  chainId: import("@sinclair/typebox").TNumber;
165
167
  action: import("@sinclair/typebox").TString;
168
+ depositUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
166
169
  tvl: import("@sinclair/typebox").TNumber;
167
170
  apr: import("@sinclair/typebox").TNumber;
168
171
  dailyRewards: import("@sinclair/typebox").TNumber;
@@ -18,6 +18,7 @@ export const OpportunityResourceDto = t.Object({
18
18
  tvl: t.Number(),
19
19
  apr: t.Number(),
20
20
  dailyRewards: t.Number(),
21
+ depositUrl: t.Optional(t.String()),
21
22
  tags: t.Array(t.String()),
22
23
  id: t.String(),
23
24
  tokens: t.Array(TokenResourceDto),
@@ -71,10 +71,11 @@ export declare abstract class OpportunityService {
71
71
  isTest: boolean;
72
72
  price: number | null;
73
73
  };
74
- amount: bigint;
74
+ amount: number | bigint;
75
75
  }[];
76
76
  };
77
77
  id: string;
78
+ depositUrl: string | undefined;
78
79
  tokens: ({
79
80
  symbol: string;
80
81
  name: string | null;
@@ -108,7 +109,6 @@ export declare abstract class OpportunityService {
108
109
  identifier: string;
109
110
  chainId: number;
110
111
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
111
- depositUrl: string | null;
112
112
  tvl: number;
113
113
  apr: number;
114
114
  dailyRewards: number;
@@ -159,10 +159,11 @@ export declare abstract class OpportunityService {
159
159
  isTest: boolean;
160
160
  price: number | null;
161
161
  };
162
- amount: bigint;
162
+ amount: number | bigint;
163
163
  }[];
164
164
  };
165
165
  id: string;
166
+ depositUrl: string | undefined;
166
167
  tokens: ({
167
168
  symbol: string;
168
169
  name: string | null;
@@ -196,7 +197,6 @@ export declare abstract class OpportunityService {
196
197
  identifier: string;
197
198
  chainId: number;
198
199
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
199
- depositUrl: string | null;
200
200
  tvl: number;
201
201
  apr: number;
202
202
  dailyRewards: number;
@@ -304,10 +304,11 @@ export declare abstract class OpportunityService {
304
304
  isTest: boolean;
305
305
  price: number | null;
306
306
  };
307
- amount: bigint;
307
+ amount: number | bigint;
308
308
  }[];
309
309
  };
310
310
  id: string;
311
+ depositUrl: string | undefined;
311
312
  tokens: ({
312
313
  symbol: string;
313
314
  name: string | null;
@@ -341,13 +342,13 @@ export declare abstract class OpportunityService {
341
342
  identifier: string;
342
343
  chainId: number;
343
344
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
344
- depositUrl: string | null;
345
345
  tvl: number;
346
346
  apr: number;
347
347
  dailyRewards: number;
348
348
  };
349
349
  static formatResponseBase(opportunity: LightOpportunityFromDB): {
350
350
  id: string;
351
+ depositUrl: string | undefined;
351
352
  tokens: ({
352
353
  symbol: string;
353
354
  name: string | null;
@@ -381,7 +382,6 @@ export declare abstract class OpportunityService {
381
382
  identifier: string;
382
383
  chainId: number;
383
384
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
384
- depositUrl: string | null;
385
385
  tvl: number;
386
386
  apr: number;
387
387
  dailyRewards: number;
@@ -180,6 +180,7 @@ export class OpportunityService {
180
180
  return {
181
181
  ...opp,
182
182
  id,
183
+ depositUrl: opp.depositUrl ?? undefined,
183
184
  tokens: Tokens.map(t => TokenService.format(t)),
184
185
  chain: Chain,
185
186
  protocol: MainProtocol ?? undefined,
@@ -312,8 +312,9 @@ export class RewardService {
312
312
  const breakdowns = [];
313
313
  for (const { amount, rewardToken: address, chainId, startTimestamp: start, endTimestamp: end, campaignId, } of dynamicData) {
314
314
  const timespan = Math.abs(end - start);
315
+ const isWithinTimespan = moment().unix() > start && moment().unix() < end;
315
316
  const dayspan = Math.max(1, Math.floor(timespan / (60 * 60 * 24)));
316
- const dailyAmount = moment().unix() <= end && moment().unix() >= start ? BigInt(amount) / BigInt(dayspan) : BigInt(0);
317
+ const dailyAmount = isWithinTimespan ? BigInt(amount) / BigInt(dayspan) : BigInt(0);
317
318
  const campaignDailyValue = await TokenService.getValue([{ amount: dailyAmount, address, chainId }]);
318
319
  breakdowns.push({
319
320
  campaignId: CampaignService.hashId({ campaignId, distributionChain: chainId }),