@merkl/api 0.10.237 → 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,17 +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
- depositUrl: string | undefined;
117
- tokens: ({
209
+ } | undefined;
210
+ name: string;
211
+ type: string;
212
+ tokens: {
213
+ price?: number | null | undefined;
118
214
  symbol: string;
119
215
  name: string | null;
120
216
  id: string;
@@ -124,33 +220,280 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
124
220
  decimals: number;
125
221
  verified: boolean;
126
222
  isTest: boolean;
127
- } & {
128
- price?: number | null | undefined;
129
- })[];
223
+ }[];
224
+ id: string;
225
+ status: string;
226
+ tags: string[];
227
+ identifier: string;
130
228
  chain: {
131
229
  name: string;
132
230
  id: number;
133
231
  icon: string;
134
232
  };
135
- 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?: {
136
326
  name: string;
137
327
  url: string;
138
328
  description: string;
139
329
  id: string;
140
330
  tags: string[];
141
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
+ }[];
142
379
  } | undefined;
143
380
  name: string;
144
- type: import("../../../../database/api/.generated").$Enums.CampaignType;
145
- 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;
146
396
  tags: string[];
147
397
  identifier: string;
398
+ chain: {
399
+ name: string;
400
+ id: number;
401
+ icon: string;
402
+ };
148
403
  chainId: number;
149
- action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
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
  };
@@ -71,7 +71,7 @@ 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;
@@ -159,7 +159,7 @@ 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;
@@ -304,7 +304,7 @@ 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;
@@ -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 }),