@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.
@@ -91,8 +91,9 @@ export function getRewardTokens(campaigns) {
91
91
  const rewardTokens = {};
92
92
  campaigns.forEach(({ amount, rewardToken, campaignParameters: { symbolRewardToken: symbol }, ...c }) => {
93
93
  const timespan = Math.abs(c.endTimestamp - c.startTimestamp);
94
+ const isWithinTimespan = moment().unix() > c.startTimestamp && moment().unix() < c.endTimestamp;
94
95
  const dayspan = Math.max(Math.floor(timespan / (60 * 60 * 24)), 1);
95
- const dailyAmount = BigInt(amount) / BigInt(dayspan);
96
+ const dailyAmount = isWithinTimespan ? BigInt(amount) / BigInt(dayspan) : 0n;
96
97
  if (!rewardTokens[symbol])
97
98
  rewardTokens[symbol] = { amount: dailyAmount, address: rewardToken };
98
99
  else
@@ -194,40 +194,133 @@ declare const app: Elysia<"", false, {
194
194
  };
195
195
  headers: unknown;
196
196
  response: {
197
- 200: {
198
- aprRecord: {
197
+ 200: ({
198
+ protocol?: {
199
+ name: string;
200
+ url: string;
201
+ description: string;
202
+ id: string;
203
+ tags: string[];
204
+ icon: string;
205
+ } | null | undefined;
206
+ depositUrl?: string | undefined;
207
+ aprRecord?: {
208
+ timestamp: string | bigint;
199
209
  cumulated: number;
200
- timestamp: bigint;
201
210
  breakdowns: {
202
- type: import("../database/api/.generated").$Enums.AprType;
211
+ type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
203
212
  id: number;
204
213
  identifier: string;
205
214
  value: number;
206
215
  aprRecordId: string;
207
216
  }[];
208
- };
209
- tvlRecord: {
210
- id: string;
217
+ } | undefined;
218
+ tvlRecord?: {
211
219
  total: number;
212
- timestamp: bigint;
220
+ timestamp: string | bigint;
213
221
  breakdowns: {
214
- type: import("../database/api/.generated").$Enums.TvlType;
222
+ type: "TOKEN" | "PROTOCOL";
215
223
  id: number;
216
224
  identifier: string;
217
225
  value: number;
218
226
  tvlRecordId: string;
219
227
  }[];
220
- };
221
- rewardsRecord: {
222
- id: string;
228
+ } | undefined;
229
+ rewardsRecord?: {
223
230
  total: number;
224
- timestamp: bigint;
231
+ id: string;
232
+ timestamp: string | bigint;
225
233
  breakdowns: {
234
+ token: {
235
+ price?: number | null | undefined;
236
+ symbol: string;
237
+ name: string | null;
238
+ id: string;
239
+ icon: string;
240
+ chainId: number;
241
+ address: string;
242
+ decimals: number;
243
+ verified: boolean;
244
+ isTest: boolean;
245
+ };
226
246
  id: number;
227
247
  value: number;
228
248
  campaignId: string;
249
+ amount: string | bigint;
229
250
  dailyRewardsRecordId: string;
251
+ }[];
252
+ } | undefined;
253
+ name: string;
254
+ type: string;
255
+ tokens: {
256
+ price?: number | null | undefined;
257
+ symbol: string;
258
+ name: string | null;
259
+ id: string;
260
+ icon: string;
261
+ chainId: number;
262
+ address: string;
263
+ decimals: number;
264
+ verified: boolean;
265
+ isTest: boolean;
266
+ }[];
267
+ id: string;
268
+ status: string;
269
+ tags: string[];
270
+ identifier: string;
271
+ chain: {
272
+ name: string;
273
+ id: number;
274
+ icon: string;
275
+ };
276
+ chainId: number;
277
+ action: string;
278
+ tvl: number;
279
+ apr: number;
280
+ dailyRewards: number;
281
+ } | null)[];
282
+ } | {
283
+ 200: never;
284
+ } | {
285
+ 200: (Response | ({
286
+ protocol?: {
287
+ name: string;
288
+ url: string;
289
+ description: string;
290
+ id: string;
291
+ tags: string[];
292
+ icon: string;
293
+ } | null | undefined;
294
+ depositUrl?: string | undefined;
295
+ aprRecord?: {
296
+ timestamp: string | bigint;
297
+ cumulated: number;
298
+ breakdowns: {
299
+ type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
300
+ id: number;
301
+ identifier: string;
302
+ value: number;
303
+ aprRecordId: string;
304
+ }[];
305
+ } | undefined;
306
+ tvlRecord?: {
307
+ total: number;
308
+ timestamp: string | bigint;
309
+ breakdowns: {
310
+ type: "TOKEN" | "PROTOCOL";
311
+ id: number;
312
+ identifier: string;
313
+ value: number;
314
+ tvlRecordId: string;
315
+ }[];
316
+ } | undefined;
317
+ rewardsRecord?: {
318
+ total: number;
319
+ id: string;
320
+ timestamp: string | bigint;
321
+ breakdowns: {
230
322
  token: {
323
+ price?: number | null | undefined;
231
324
  symbol: string;
232
325
  name: string | null;
233
326
  id: string;
@@ -235,16 +328,20 @@ declare const app: Elysia<"", false, {
235
328
  chainId: number;
236
329
  address: string;
237
330
  decimals: number;
238
- displaySymbol: string;
239
331
  verified: boolean;
240
332
  isTest: boolean;
241
- price: number | null;
242
333
  };
243
- amount: bigint;
334
+ id: number;
335
+ value: number;
336
+ campaignId: string;
337
+ amount: string | bigint;
338
+ dailyRewardsRecordId: string;
244
339
  }[];
245
- };
246
- id: string;
247
- tokens: ({
340
+ } | undefined;
341
+ name: string;
342
+ type: string;
343
+ tokens: {
344
+ price?: number | null | undefined;
248
345
  symbol: string;
249
346
  name: string | null;
250
347
  id: string;
@@ -254,34 +351,280 @@ declare const app: Elysia<"", false, {
254
351
  decimals: number;
255
352
  verified: boolean;
256
353
  isTest: boolean;
257
- } & {
258
- price?: number | null | undefined;
259
- })[];
354
+ }[];
355
+ id: string;
356
+ status: string;
357
+ tags: string[];
358
+ identifier: string;
260
359
  chain: {
261
360
  name: string;
262
361
  id: number;
263
362
  icon: string;
264
363
  };
265
- protocol: {
364
+ chainId: number;
365
+ action: string;
366
+ tvl: number;
367
+ apr: number;
368
+ dailyRewards: number;
369
+ } | null)[] | {
370
+ 200: ({
371
+ protocol?: {
372
+ name: string;
373
+ url: string;
374
+ description: string;
375
+ id: string;
376
+ tags: string[];
377
+ icon: string;
378
+ } | null | undefined;
379
+ depositUrl?: string | undefined;
380
+ aprRecord?: {
381
+ timestamp: string | bigint;
382
+ cumulated: number;
383
+ breakdowns: {
384
+ type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
385
+ id: number;
386
+ identifier: string;
387
+ value: number;
388
+ aprRecordId: string;
389
+ }[];
390
+ } | undefined;
391
+ tvlRecord?: {
392
+ total: number;
393
+ timestamp: string | bigint;
394
+ breakdowns: {
395
+ type: "TOKEN" | "PROTOCOL";
396
+ id: number;
397
+ identifier: string;
398
+ value: number;
399
+ tvlRecordId: string;
400
+ }[];
401
+ } | undefined;
402
+ rewardsRecord?: {
403
+ total: number;
404
+ id: string;
405
+ timestamp: string | bigint;
406
+ breakdowns: {
407
+ token: {
408
+ price?: number | null | undefined;
409
+ symbol: string;
410
+ name: string | null;
411
+ id: string;
412
+ icon: string;
413
+ chainId: number;
414
+ address: string;
415
+ decimals: number;
416
+ verified: boolean;
417
+ isTest: boolean;
418
+ };
419
+ id: number;
420
+ value: number;
421
+ campaignId: string;
422
+ amount: string | bigint;
423
+ dailyRewardsRecordId: string;
424
+ }[];
425
+ } | undefined;
426
+ name: string;
427
+ type: string;
428
+ tokens: {
429
+ price?: number | null | undefined;
430
+ symbol: string;
431
+ name: string | null;
432
+ id: string;
433
+ icon: string;
434
+ chainId: number;
435
+ address: string;
436
+ decimals: number;
437
+ verified: boolean;
438
+ isTest: boolean;
439
+ }[];
440
+ id: string;
441
+ status: string;
442
+ tags: string[];
443
+ identifier: string;
444
+ chain: {
445
+ name: string;
446
+ id: number;
447
+ icon: string;
448
+ };
449
+ chainId: number;
450
+ action: string;
451
+ tvl: number;
452
+ apr: number;
453
+ dailyRewards: number;
454
+ } | null)[];
455
+ }) & ({
456
+ protocol?: {
266
457
  name: string;
267
458
  url: string;
268
459
  description: string;
269
460
  id: string;
270
461
  tags: string[];
271
462
  icon: string;
463
+ } | null | undefined;
464
+ depositUrl?: string | undefined;
465
+ aprRecord?: {
466
+ timestamp: string | bigint;
467
+ cumulated: number;
468
+ breakdowns: {
469
+ type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
470
+ id: number;
471
+ identifier: string;
472
+ value: number;
473
+ aprRecordId: string;
474
+ }[];
475
+ } | undefined;
476
+ tvlRecord?: {
477
+ total: number;
478
+ timestamp: string | bigint;
479
+ breakdowns: {
480
+ type: "TOKEN" | "PROTOCOL";
481
+ id: number;
482
+ identifier: string;
483
+ value: number;
484
+ tvlRecordId: string;
485
+ }[];
486
+ } | undefined;
487
+ rewardsRecord?: {
488
+ total: number;
489
+ id: string;
490
+ timestamp: string | bigint;
491
+ breakdowns: {
492
+ token: {
493
+ price?: number | null | undefined;
494
+ symbol: string;
495
+ name: string | null;
496
+ id: string;
497
+ icon: string;
498
+ chainId: number;
499
+ address: string;
500
+ decimals: number;
501
+ verified: boolean;
502
+ isTest: boolean;
503
+ };
504
+ id: number;
505
+ value: number;
506
+ campaignId: string;
507
+ amount: string | bigint;
508
+ dailyRewardsRecordId: string;
509
+ }[];
272
510
  } | undefined;
273
511
  name: string;
274
- type: import("../database/api/.generated").$Enums.CampaignType;
275
- status: import("../database/api/.generated").$Enums.Status;
512
+ type: string;
513
+ tokens: {
514
+ price?: number | null | undefined;
515
+ symbol: string;
516
+ name: string | null;
517
+ id: string;
518
+ icon: string;
519
+ chainId: number;
520
+ address: string;
521
+ decimals: number;
522
+ verified: boolean;
523
+ isTest: boolean;
524
+ }[];
525
+ id: string;
526
+ status: string;
276
527
  tags: string[];
277
528
  identifier: string;
529
+ chain: {
530
+ name: string;
531
+ id: number;
532
+ icon: string;
533
+ };
278
534
  chainId: number;
279
- action: import("../database/api/.generated").$Enums.OpportunityAction;
280
- depositUrl: string | null;
535
+ action: string;
281
536
  tvl: number;
282
537
  apr: number;
283
538
  dailyRewards: number;
284
- }[];
539
+ } | null)[];
540
+ } | {
541
+ 200: {
542
+ 200: ({
543
+ protocol?: {
544
+ name: string;
545
+ url: string;
546
+ description: string;
547
+ id: string;
548
+ tags: string[];
549
+ icon: string;
550
+ } | null | undefined;
551
+ depositUrl?: string | undefined;
552
+ aprRecord?: {
553
+ timestamp: string | bigint;
554
+ cumulated: number;
555
+ breakdowns: {
556
+ type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
557
+ id: number;
558
+ identifier: string;
559
+ value: number;
560
+ aprRecordId: string;
561
+ }[];
562
+ } | undefined;
563
+ tvlRecord?: {
564
+ total: number;
565
+ timestamp: string | bigint;
566
+ breakdowns: {
567
+ type: "TOKEN" | "PROTOCOL";
568
+ id: number;
569
+ identifier: string;
570
+ value: number;
571
+ tvlRecordId: string;
572
+ }[];
573
+ } | undefined;
574
+ rewardsRecord?: {
575
+ total: number;
576
+ id: string;
577
+ timestamp: string | bigint;
578
+ breakdowns: {
579
+ token: {
580
+ price?: number | null | undefined;
581
+ symbol: string;
582
+ name: string | null;
583
+ id: string;
584
+ icon: string;
585
+ chainId: number;
586
+ address: string;
587
+ decimals: number;
588
+ verified: boolean;
589
+ isTest: boolean;
590
+ };
591
+ id: number;
592
+ value: number;
593
+ campaignId: string;
594
+ amount: string | bigint;
595
+ dailyRewardsRecordId: string;
596
+ }[];
597
+ } | undefined;
598
+ name: string;
599
+ type: string;
600
+ tokens: {
601
+ price?: number | null | undefined;
602
+ symbol: string;
603
+ name: string | null;
604
+ id: string;
605
+ icon: string;
606
+ chainId: number;
607
+ address: string;
608
+ decimals: number;
609
+ verified: boolean;
610
+ isTest: boolean;
611
+ }[];
612
+ id: string;
613
+ status: string;
614
+ tags: string[];
615
+ identifier: string;
616
+ chain: {
617
+ name: string;
618
+ id: number;
619
+ icon: string;
620
+ };
621
+ chainId: number;
622
+ action: string;
623
+ tvl: number;
624
+ apr: number;
625
+ dailyRewards: number;
626
+ } | null)[];
627
+ };
285
628
  };
286
629
  };
287
630
  };
@@ -334,6 +677,7 @@ declare const app: Elysia<"", false, {
334
677
  tags: string[];
335
678
  icon: string;
336
679
  } | null | undefined;
680
+ depositUrl?: string | undefined;
337
681
  aprRecord?: {
338
682
  timestamp: string | bigint;
339
683
  cumulated: number;
@@ -443,6 +787,7 @@ declare const app: Elysia<"", false, {
443
787
  tags: string[];
444
788
  icon: string;
445
789
  } | null | undefined;
790
+ depositUrl?: string | undefined;
446
791
  aprRecord?: {
447
792
  timestamp: string | bigint;
448
793
  cumulated: number;
@@ -224,5 +224,5 @@ export declare abstract class CampaignService {
224
224
  * @param amount
225
225
  * @returns daily token amount
226
226
  */
227
- static getDailyAmount<T extends bigint | number>(start: T, end: T, amount: bigint): bigint;
227
+ static getDailyAmount<T extends bigint | number>(start: T, end: T, amount: bigint): bigint | 0;
228
228
  }
@@ -206,8 +206,9 @@ export class CampaignService {
206
206
  */
207
207
  static getDailyAmount(start, end, amount) {
208
208
  const timespan = Math.abs(Number(end - start));
209
+ const isWithinTimespan = moment().unix() > start && moment().unix() < end;
209
210
  const dayspan = Math.max(1, Math.floor(timespan / (60 * 60 * 24)));
210
- const dailyAmount = BigInt(amount) / BigInt(dayspan);
211
+ const dailyAmount = isWithinTimespan ? BigInt(amount) / BigInt(dayspan) : 0;
211
212
  return dailyAmount;
212
213
  }
213
214
  }
@@ -1,7 +1,7 @@
1
1
  export declare const slugToProtocolId: {
2
2
  readonly "uniswap-v2": "uniswap-v2";
3
- readonly "aave-v2": "aave";
4
3
  readonly "aave-v3": "aave";
4
+ readonly "aave-v2": "aave";
5
5
  readonly "aave-static-atokens": "aave";
6
6
  readonly "camelot-v2": "camelot";
7
7
  readonly "meta-morpho": "morpho";
@@ -1,8 +1,8 @@
1
1
  import { t } from "elysia";
2
2
  export const slugToProtocolId = {
3
3
  "uniswap-v2": "uniswap-v2",
4
- "aave-v2": "aave",
5
4
  "aave-v3": "aave",
5
+ "aave-v2": "aave",
6
6
  "aave-static-atokens": "aave",
7
7
  "camelot-v2": "camelot",
8
8
  "meta-morpho": "morpho",
@@ -28,7 +28,7 @@ export declare const apiTypes: {
28
28
  amountIn: import("@sinclair/typebox").TString;
29
29
  feeAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
30
30
  feePcm: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
31
- sipplage: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
31
+ slippage: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
32
32
  }>;
33
33
  readonly response: import("@sinclair/typebox").TObject<{
34
34
  message: import("@sinclair/typebox").TString;
@@ -40,7 +40,7 @@ export const apiTypes = {
40
40
  amountIn: t.String(),
41
41
  feeAddress: t.Optional(t.String()),
42
42
  feePcm: t.Optional(t.Number()),
43
- sipplage: t.Optional(t.Number()),
43
+ slippage: t.Optional(t.Number()),
44
44
  }),
45
45
  response: t.Object({
46
46
  message: t.String({ example: "OK" }),
@@ -56,7 +56,7 @@ export class KyberZapService {
56
56
  "position.tickUpper": upper?.toString(),
57
57
  dex: KyberZapService.getDexId(protocol),
58
58
  //TODO: add a lesser value here (2% by default)
59
- sipplage: slippage ?? 200,
59
+ slippage: slippage ?? 200,
60
60
  },
61
61
  chainId,
62
62
  });