@merkl/api 0.20.2 → 0.20.4
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.
- package/dist/src/cache/declaration.d.ts +2 -2
- package/dist/src/cache/declaration.js +2 -2
- package/dist/src/eden/index.d.ts +1179 -2529
- package/dist/src/engine/dynamicData/utils/getEulerV2Vaults.d.ts +0 -1
- package/dist/src/engine/dynamicData/utils/getEulerV2Vaults.js +77 -40
- package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerLendProcessor.js +6 -1
- package/dist/src/index.d.ts +97 -367
- package/dist/src/jobs/update-euler-vaults.d.ts +1 -1
- package/dist/src/jobs/update-euler-vaults.js +5 -121
- package/dist/src/modules/v4/icon/icon.model.d.ts +4 -0
- package/dist/src/modules/v4/icon/icon.model.js +1 -0
- package/dist/src/modules/v4/icon/icon.service.d.ts +5 -0
- package/dist/src/modules/v4/icon/icon.service.js +15 -0
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +97 -367
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +1 -0
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +4 -4
- package/dist/src/modules/v4/opportunity/opportunity.service.js +1 -0
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +4 -0
- package/dist/src/modules/v4/reward/reward.service.d.ts +1 -1
- package/dist/src/modules/v4/router.d.ts +97 -367
- package/dist/src/modules/v4/token/token.service.js +6 -9
- package/dist/src/routes/v3/euler.d.ts +0 -6
- package/dist/src/routes/v3/euler.js +3 -3
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
@@ -279,136 +279,44 @@ declare const app: Elysia<"", false, {
|
|
279
279
|
};
|
280
280
|
headers: unknown;
|
281
281
|
response: {
|
282
|
-
200:
|
283
|
-
|
284
|
-
|
285
|
-
name: string;
|
286
|
-
url: string;
|
287
|
-
description: string;
|
288
|
-
tags: string[];
|
289
|
-
icon: string;
|
290
|
-
} | null | undefined;
|
291
|
-
depositUrl?: string | undefined;
|
292
|
-
explorerAddress?: string | undefined;
|
293
|
-
aprRecord?: {
|
294
|
-
timestamp: string | bigint;
|
282
|
+
200: {
|
283
|
+
apr: number;
|
284
|
+
aprRecord: {
|
295
285
|
cumulated: number;
|
286
|
+
timestamp: bigint;
|
296
287
|
breakdowns: {
|
297
288
|
id: number;
|
298
|
-
type: "
|
289
|
+
type: import("@db/api").$Enums.AprType;
|
290
|
+
uuid: string;
|
299
291
|
identifier: string;
|
300
292
|
value: number;
|
301
293
|
aprRecordId: string;
|
302
294
|
}[];
|
303
|
-
}
|
304
|
-
tvlRecord
|
295
|
+
};
|
296
|
+
tvlRecord: {
|
297
|
+
id: string;
|
305
298
|
total: number;
|
306
|
-
timestamp:
|
299
|
+
timestamp: bigint;
|
307
300
|
breakdowns: {
|
308
301
|
id: number;
|
309
|
-
type: "
|
302
|
+
type: import("@db/api").$Enums.TvlType;
|
303
|
+
uuid: string;
|
310
304
|
identifier: string;
|
311
305
|
value: number;
|
312
306
|
tvlRecordId: string;
|
313
307
|
}[];
|
314
|
-
}
|
315
|
-
rewardsRecord
|
308
|
+
};
|
309
|
+
rewardsRecord: {
|
316
310
|
id: string;
|
317
311
|
total: number;
|
318
|
-
timestamp:
|
312
|
+
timestamp: bigint;
|
319
313
|
breakdowns: {
|
320
314
|
id: number;
|
321
|
-
|
322
|
-
price?: number | null | undefined;
|
323
|
-
symbol: string;
|
324
|
-
id: string;
|
325
|
-
name: string | null;
|
326
|
-
icon: string;
|
327
|
-
address: string;
|
328
|
-
chainId: number;
|
329
|
-
decimals: number;
|
330
|
-
verified: boolean;
|
331
|
-
isTest: boolean;
|
332
|
-
};
|
315
|
+
uuid: string;
|
333
316
|
value: number;
|
334
317
|
campaignId: string;
|
335
|
-
amount: string | bigint;
|
336
318
|
dailyRewardsRecordId: string;
|
337
|
-
}[];
|
338
|
-
} | undefined;
|
339
|
-
id: string;
|
340
|
-
name: string;
|
341
|
-
type: string;
|
342
|
-
status: string;
|
343
|
-
tokens: {
|
344
|
-
price?: number | null | undefined;
|
345
|
-
symbol: string;
|
346
|
-
id: string;
|
347
|
-
name: string | null;
|
348
|
-
icon: string;
|
349
|
-
address: string;
|
350
|
-
chainId: number;
|
351
|
-
decimals: number;
|
352
|
-
verified: boolean;
|
353
|
-
isTest: boolean;
|
354
|
-
}[];
|
355
|
-
tags: string[];
|
356
|
-
identifier: string;
|
357
|
-
chain: {
|
358
|
-
id: number;
|
359
|
-
name: string;
|
360
|
-
icon: string;
|
361
|
-
};
|
362
|
-
action: string;
|
363
|
-
chainId: number;
|
364
|
-
tvl: number;
|
365
|
-
apr: number;
|
366
|
-
dailyRewards: number;
|
367
|
-
} | null)[];
|
368
|
-
} | {
|
369
|
-
200: never;
|
370
|
-
} | {
|
371
|
-
200: (Response | ({
|
372
|
-
protocol?: {
|
373
|
-
id: string;
|
374
|
-
name: string;
|
375
|
-
url: string;
|
376
|
-
description: string;
|
377
|
-
tags: string[];
|
378
|
-
icon: string;
|
379
|
-
} | null | undefined;
|
380
|
-
depositUrl?: string | undefined;
|
381
|
-
explorerAddress?: string | undefined;
|
382
|
-
aprRecord?: {
|
383
|
-
timestamp: string | bigint;
|
384
|
-
cumulated: number;
|
385
|
-
breakdowns: {
|
386
|
-
id: number;
|
387
|
-
type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
|
388
|
-
identifier: string;
|
389
|
-
value: number;
|
390
|
-
aprRecordId: string;
|
391
|
-
}[];
|
392
|
-
} | undefined;
|
393
|
-
tvlRecord?: {
|
394
|
-
total: number;
|
395
|
-
timestamp: string | bigint;
|
396
|
-
breakdowns: {
|
397
|
-
id: number;
|
398
|
-
type: "TOKEN" | "PROTOCOL";
|
399
|
-
identifier: string;
|
400
|
-
value: number;
|
401
|
-
tvlRecordId: string;
|
402
|
-
}[];
|
403
|
-
} | undefined;
|
404
|
-
rewardsRecord?: {
|
405
|
-
id: string;
|
406
|
-
total: number;
|
407
|
-
timestamp: string | bigint;
|
408
|
-
breakdowns: {
|
409
|
-
id: number;
|
410
319
|
token: {
|
411
|
-
price?: number | null | undefined;
|
412
320
|
symbol: string;
|
413
321
|
id: string;
|
414
322
|
name: string | null;
|
@@ -416,107 +324,26 @@ declare const app: Elysia<"", false, {
|
|
416
324
|
address: string;
|
417
325
|
chainId: number;
|
418
326
|
decimals: number;
|
327
|
+
displaySymbol: string;
|
419
328
|
verified: boolean;
|
420
329
|
isTest: boolean;
|
330
|
+
isPoint: boolean;
|
331
|
+
isNative: boolean;
|
332
|
+
price: number | null;
|
421
333
|
};
|
422
|
-
|
423
|
-
campaignId: string;
|
424
|
-
amount: string | bigint;
|
425
|
-
dailyRewardsRecordId: string;
|
334
|
+
amount: bigint;
|
426
335
|
}[];
|
427
|
-
} | undefined;
|
428
|
-
id: string;
|
429
|
-
name: string;
|
430
|
-
type: string;
|
431
|
-
status: string;
|
432
|
-
tokens: {
|
433
|
-
price?: number | null | undefined;
|
434
|
-
symbol: string;
|
435
|
-
id: string;
|
436
|
-
name: string | null;
|
437
|
-
icon: string;
|
438
|
-
address: string;
|
439
|
-
chainId: number;
|
440
|
-
decimals: number;
|
441
|
-
verified: boolean;
|
442
|
-
isTest: boolean;
|
443
|
-
}[];
|
444
|
-
tags: string[];
|
445
|
-
identifier: string;
|
446
|
-
chain: {
|
447
|
-
id: number;
|
448
|
-
name: string;
|
449
|
-
icon: string;
|
450
336
|
};
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
dailyRewards: number;
|
456
|
-
} | null)[] | {
|
457
|
-
200: ({
|
458
|
-
protocol?: {
|
459
|
-
id: string;
|
337
|
+
campaigns: {
|
338
|
+
params: any;
|
339
|
+
chain: {
|
340
|
+
id: number;
|
460
341
|
name: string;
|
461
|
-
url: string;
|
462
|
-
description: string;
|
463
|
-
tags: string[];
|
464
342
|
icon: string;
|
465
|
-
}
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
timestamp: string | bigint;
|
470
|
-
cumulated: number;
|
471
|
-
breakdowns: {
|
472
|
-
id: number;
|
473
|
-
type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
|
474
|
-
identifier: string;
|
475
|
-
value: number;
|
476
|
-
aprRecordId: string;
|
477
|
-
}[];
|
478
|
-
} | undefined;
|
479
|
-
tvlRecord?: {
|
480
|
-
total: number;
|
481
|
-
timestamp: string | bigint;
|
482
|
-
breakdowns: {
|
483
|
-
id: number;
|
484
|
-
type: "TOKEN" | "PROTOCOL";
|
485
|
-
identifier: string;
|
486
|
-
value: number;
|
487
|
-
tvlRecordId: string;
|
488
|
-
}[];
|
489
|
-
} | undefined;
|
490
|
-
rewardsRecord?: {
|
491
|
-
id: string;
|
492
|
-
total: number;
|
493
|
-
timestamp: string | bigint;
|
494
|
-
breakdowns: {
|
495
|
-
id: number;
|
496
|
-
token: {
|
497
|
-
price?: number | null | undefined;
|
498
|
-
symbol: string;
|
499
|
-
id: string;
|
500
|
-
name: string | null;
|
501
|
-
icon: string;
|
502
|
-
address: string;
|
503
|
-
chainId: number;
|
504
|
-
decimals: number;
|
505
|
-
verified: boolean;
|
506
|
-
isTest: boolean;
|
507
|
-
};
|
508
|
-
value: number;
|
509
|
-
campaignId: string;
|
510
|
-
amount: string | bigint;
|
511
|
-
dailyRewardsRecordId: string;
|
512
|
-
}[];
|
513
|
-
} | undefined;
|
514
|
-
id: string;
|
515
|
-
name: string;
|
516
|
-
type: string;
|
517
|
-
status: string;
|
518
|
-
tokens: {
|
519
|
-
price?: number | null | undefined;
|
343
|
+
};
|
344
|
+
endTimestamp: number;
|
345
|
+
startTimestamp: number;
|
346
|
+
rewardToken: {
|
520
347
|
symbol: string;
|
521
348
|
id: string;
|
522
349
|
name: string | null;
|
@@ -526,83 +353,61 @@ declare const app: Elysia<"", false, {
|
|
526
353
|
decimals: number;
|
527
354
|
verified: boolean;
|
528
355
|
isTest: boolean;
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
356
|
+
isPoint: boolean;
|
357
|
+
isNative: boolean;
|
358
|
+
} & {
|
359
|
+
price?: number | null | undefined;
|
360
|
+
};
|
361
|
+
distributionChain: {
|
533
362
|
id: number;
|
534
363
|
name: string;
|
535
364
|
icon: string;
|
365
|
+
} | undefined;
|
366
|
+
campaignStatus: {
|
367
|
+
computedUntil: number;
|
368
|
+
processingStarted: number;
|
369
|
+
error: string;
|
370
|
+
status: import("@db/api").$Enums.RunStatus;
|
371
|
+
details: import("database/api/.generated/runtime/library").JsonValue;
|
372
|
+
campaignId: string;
|
373
|
+
} | undefined;
|
374
|
+
creatorAddress: string;
|
375
|
+
creator: {
|
376
|
+
tags: string[];
|
377
|
+
address: string;
|
378
|
+
creatorId: string | null;
|
536
379
|
};
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
protocol?: {
|
545
|
-
id: string;
|
546
|
-
name: string;
|
547
|
-
url: string;
|
548
|
-
description: string;
|
549
|
-
tags: string[];
|
550
|
-
icon: string;
|
551
|
-
} | null | undefined;
|
552
|
-
depositUrl?: string | undefined;
|
553
|
-
explorerAddress?: string | undefined;
|
554
|
-
aprRecord?: {
|
555
|
-
timestamp: string | bigint;
|
556
|
-
cumulated: number;
|
557
|
-
breakdowns: {
|
558
|
-
id: number;
|
559
|
-
type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
|
560
|
-
identifier: string;
|
561
|
-
value: number;
|
562
|
-
aprRecordId: string;
|
563
|
-
}[];
|
564
|
-
} | undefined;
|
565
|
-
tvlRecord?: {
|
566
|
-
total: number;
|
567
|
-
timestamp: string | bigint;
|
568
|
-
breakdowns: {
|
569
|
-
id: number;
|
570
|
-
type: "TOKEN" | "PROTOCOL";
|
380
|
+
createdAt: string;
|
381
|
+
Opportunity: {
|
382
|
+
id: string;
|
383
|
+
name: string;
|
384
|
+
type: string;
|
385
|
+
status: import("@db/api").$Enums.Status;
|
386
|
+
tags: string[];
|
571
387
|
identifier: string;
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
388
|
+
action: import("@db/api").$Enums.OpportunityAction;
|
389
|
+
chainId: number;
|
390
|
+
depositUrl: string | null;
|
391
|
+
explorerAddress: string | null;
|
392
|
+
mainProtocolId: string | null;
|
393
|
+
tvl: number;
|
394
|
+
apr: number;
|
395
|
+
dailyRewards: number;
|
396
|
+
};
|
577
397
|
id: string;
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
icon: string;
|
588
|
-
address: string;
|
589
|
-
chainId: number;
|
590
|
-
decimals: number;
|
591
|
-
verified: boolean;
|
592
|
-
isTest: boolean;
|
593
|
-
};
|
594
|
-
value: number;
|
595
|
-
campaignId: string;
|
596
|
-
amount: string | bigint;
|
597
|
-
dailyRewardsRecordId: string;
|
598
|
-
}[];
|
599
|
-
} | undefined;
|
398
|
+
type: string;
|
399
|
+
subType: number | null;
|
400
|
+
computeChainId: number;
|
401
|
+
distributionChainId: number;
|
402
|
+
campaignId: string;
|
403
|
+
rewardTokenId: string;
|
404
|
+
amount: string;
|
405
|
+
opportunityId: string;
|
406
|
+
}[] | undefined;
|
600
407
|
id: string;
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
tokens: {
|
605
|
-
price?: number | null | undefined;
|
408
|
+
depositUrl: string | undefined;
|
409
|
+
explorerAddress: string | undefined;
|
410
|
+
tokens: ({
|
606
411
|
symbol: string;
|
607
412
|
id: string;
|
608
413
|
name: string | null;
|
@@ -612,109 +417,34 @@ declare const app: Elysia<"", false, {
|
|
612
417
|
decimals: number;
|
613
418
|
verified: boolean;
|
614
419
|
isTest: boolean;
|
615
|
-
|
616
|
-
|
617
|
-
|
420
|
+
isPoint: boolean;
|
421
|
+
isNative: boolean;
|
422
|
+
} & {
|
423
|
+
price?: number | null | undefined;
|
424
|
+
})[];
|
618
425
|
chain: {
|
619
426
|
id: number;
|
620
427
|
name: string;
|
621
428
|
icon: string;
|
622
429
|
};
|
623
|
-
|
624
|
-
chainId: number;
|
625
|
-
tvl: number;
|
626
|
-
apr: number;
|
627
|
-
dailyRewards: number;
|
628
|
-
} | null)[];
|
629
|
-
} | {
|
630
|
-
200: {
|
631
|
-
200: ({
|
632
|
-
protocol?: {
|
633
|
-
id: string;
|
634
|
-
name: string;
|
635
|
-
url: string;
|
636
|
-
description: string;
|
637
|
-
tags: string[];
|
638
|
-
icon: string;
|
639
|
-
} | null | undefined;
|
640
|
-
depositUrl?: string | undefined;
|
641
|
-
explorerAddress?: string | undefined;
|
642
|
-
aprRecord?: {
|
643
|
-
timestamp: string | bigint;
|
644
|
-
cumulated: number;
|
645
|
-
breakdowns: {
|
646
|
-
id: number;
|
647
|
-
type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
|
648
|
-
identifier: string;
|
649
|
-
value: number;
|
650
|
-
aprRecordId: string;
|
651
|
-
}[];
|
652
|
-
} | undefined;
|
653
|
-
tvlRecord?: {
|
654
|
-
total: number;
|
655
|
-
timestamp: string | bigint;
|
656
|
-
breakdowns: {
|
657
|
-
id: number;
|
658
|
-
type: "TOKEN" | "PROTOCOL";
|
659
|
-
identifier: string;
|
660
|
-
value: number;
|
661
|
-
tvlRecordId: string;
|
662
|
-
}[];
|
663
|
-
} | undefined;
|
664
|
-
rewardsRecord?: {
|
665
|
-
id: string;
|
666
|
-
total: number;
|
667
|
-
timestamp: string | bigint;
|
668
|
-
breakdowns: {
|
669
|
-
id: number;
|
670
|
-
token: {
|
671
|
-
price?: number | null | undefined;
|
672
|
-
symbol: string;
|
673
|
-
id: string;
|
674
|
-
name: string | null;
|
675
|
-
icon: string;
|
676
|
-
address: string;
|
677
|
-
chainId: number;
|
678
|
-
decimals: number;
|
679
|
-
verified: boolean;
|
680
|
-
isTest: boolean;
|
681
|
-
};
|
682
|
-
value: number;
|
683
|
-
campaignId: string;
|
684
|
-
amount: string | bigint;
|
685
|
-
dailyRewardsRecordId: string;
|
686
|
-
}[];
|
687
|
-
} | undefined;
|
430
|
+
protocol: {
|
688
431
|
id: string;
|
689
432
|
name: string;
|
690
|
-
|
691
|
-
|
692
|
-
tokens: {
|
693
|
-
price?: number | null | undefined;
|
694
|
-
symbol: string;
|
695
|
-
id: string;
|
696
|
-
name: string | null;
|
697
|
-
icon: string;
|
698
|
-
address: string;
|
699
|
-
chainId: number;
|
700
|
-
decimals: number;
|
701
|
-
verified: boolean;
|
702
|
-
isTest: boolean;
|
703
|
-
}[];
|
433
|
+
url: string;
|
434
|
+
description: string;
|
704
435
|
tags: string[];
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
};
|
436
|
+
icon: string;
|
437
|
+
} | undefined;
|
438
|
+
name: string;
|
439
|
+
type: string;
|
440
|
+
status: import("@db/api").$Enums.Status;
|
441
|
+
tags: string[];
|
442
|
+
identifier: string;
|
443
|
+
action: import("@db/api").$Enums.OpportunityAction;
|
444
|
+
chainId: number;
|
445
|
+
tvl: number;
|
446
|
+
dailyRewards: number;
|
447
|
+
}[];
|
718
448
|
};
|
719
449
|
};
|
720
450
|
};
|
@@ -1 +1 @@
|
|
1
|
-
export
|
1
|
+
export {};
|
@@ -1,122 +1,6 @@
|
|
1
1
|
import { Redis } from "@/cache";
|
2
|
-
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
import { ERC20Interface, EULER_ADDRESSES, EulerEVKInterface, EulerVaultLensInterface, NETWORK_LABELS, eulerChainIds, } from "@sdk";
|
8
|
-
import _ from "lodash";
|
9
|
-
async function computeCollatListAndReturnVaults(chainId, vaults) {
|
10
|
-
let vaultsPerChain = [];
|
11
|
-
/** Extra calls batch to get the collateral addresses */
|
12
|
-
const resCollat = await batchMulticallCallWithRetry(chainId, {
|
13
|
-
calls: vaults
|
14
|
-
.map(vault => vault.address)
|
15
|
-
.map(vaultAddress => {
|
16
|
-
return {
|
17
|
-
allowFailure: true,
|
18
|
-
callData: EulerVaultLensInterface.encodeFunctionData("getRecognizedCollateralsLTVInfo", [vaultAddress]),
|
19
|
-
target: EULER_ADDRESSES[chainId].VAULT_LENS,
|
20
|
-
};
|
21
|
-
}),
|
22
|
-
});
|
23
|
-
const callsCollatUnderlying = [];
|
24
|
-
const callsCollatUnderlyingSymbol = [];
|
25
|
-
for (const [index, vault] of vaults.entries()) {
|
26
|
-
const collatArray = EulerVaultLensInterface.decodeFunctionResult("getRecognizedCollateralsLTVInfo", resCollat[index].returnData)[0];
|
27
|
-
for (const collat of collatArray) {
|
28
|
-
if (!!vault.collaterals &&
|
29
|
-
vault.collaterals.map(c => c.address.toLowerCase()).includes(collat.collateral.toLowerCase()))
|
30
|
-
continue;
|
31
|
-
log.info(`🦭 found new collateral ${collat.collateral} for vault ${vault.address} (${NETWORK_LABELS[chainId]})`);
|
32
|
-
callsCollatUnderlying.push({
|
33
|
-
allowFailure: true,
|
34
|
-
callData: EulerEVKInterface.encodeFunctionData("asset"),
|
35
|
-
target: collat.collateral,
|
36
|
-
}, {
|
37
|
-
allowFailure: true,
|
38
|
-
callData: EulerEVKInterface.encodeFunctionData("symbol"),
|
39
|
-
target: collat.collateral,
|
40
|
-
});
|
41
|
-
}
|
42
|
-
}
|
43
|
-
const resCollatUnderlying = await batchMulticallCallWithRetry(chainId, {
|
44
|
-
calls: callsCollatUnderlying,
|
45
|
-
});
|
46
|
-
for (let i = 0; i < resCollatUnderlying.length; i = i + 2) {
|
47
|
-
const underlyingToken = EulerEVKInterface.decodeFunctionResult("asset", resCollatUnderlying[i].returnData)[0];
|
48
|
-
callsCollatUnderlyingSymbol.push({
|
49
|
-
allowFailure: true,
|
50
|
-
callData: ERC20Interface.encodeFunctionData("symbol"),
|
51
|
-
target: underlyingToken,
|
52
|
-
});
|
53
|
-
}
|
54
|
-
const resCollatUnderlyingSymbol = await batchMulticallCallWithRetry(chainId, {
|
55
|
-
calls: callsCollatUnderlyingSymbol,
|
56
|
-
});
|
57
|
-
vaultsPerChain = vaultsPerChain.concat((await Promise.all(vaults.map(async (vault, index) => {
|
58
|
-
const collatArray = EulerVaultLensInterface.decodeFunctionResult("getRecognizedCollateralsLTVInfo", resCollat[index].returnData)[0];
|
59
|
-
if (!vault.collaterals)
|
60
|
-
vault.collaterals = [];
|
61
|
-
let offset = 0;
|
62
|
-
for (const [_index, collat] of collatArray.entries()) {
|
63
|
-
// _ Check whether the collat was already registered
|
64
|
-
if (!!vault.collaterals &&
|
65
|
-
vault.collaterals.map(c => c.address.toLowerCase()).includes(collat.collateral.toLowerCase())) {
|
66
|
-
offset += 1;
|
67
|
-
continue;
|
68
|
-
}
|
69
|
-
const symbolUnderlying = ERC20Interface.decodeFunctionResult("symbol", resCollatUnderlyingSymbol[_index - offset].returnData)[0];
|
70
|
-
vault.collaterals.push({
|
71
|
-
address: collat.collateral,
|
72
|
-
symbolCollateral: EulerEVKInterface.decodeFunctionResult("symbol", resCollatUnderlying[2 * (_index - offset) + 1].returnData)[0],
|
73
|
-
symbolUnderlying,
|
74
|
-
borrowLTV: collat.borrowLTV.toString(),
|
75
|
-
nameCollateral: (await fetchEulerVaultName(collat.collateral, chainId)) ?? symbolUnderlying,
|
76
|
-
});
|
77
|
-
}
|
78
|
-
return { ...vault };
|
79
|
-
}))));
|
80
|
-
return vaultsPerChain;
|
81
|
-
}
|
82
|
-
export async function updateEulerVaultsCollatInDatabase() {
|
83
|
-
// 0_ Fetch all euler vaults from database
|
84
|
-
const vaults = await apiDbClient.logged.findMany({
|
85
|
-
where: { type: LoggedEntityType.EULER },
|
86
|
-
});
|
87
|
-
const clonedVaults = _.cloneDeep(vaults);
|
88
|
-
let toUpdateVaults = [];
|
89
|
-
// 1_ Return all vaults already stored with their collateral updated
|
90
|
-
const res = await Promise.all(eulerChainIds.map(async (chainId) => computeCollatListAndReturnVaults(chainId, clonedVaults.filter(entity => entity.chainId === chainId).map(entity => entity.entityData))));
|
91
|
-
for (const resPerChain of res) {
|
92
|
-
if (!!resPerChain && resPerChain.length > 0) {
|
93
|
-
toUpdateVaults = toUpdateVaults.concat(resPerChain.filter(updatedVault => {
|
94
|
-
return (updatedVault.collaterals.length >
|
95
|
-
vaults.find(vault => vault.address?.toLowerCase() === updatedVault.address.toLowerCase())
|
96
|
-
?.entityData?.collaterals.length);
|
97
|
-
}));
|
98
|
-
}
|
99
|
-
}
|
100
|
-
// 2_ Update the API database
|
101
|
-
if (toUpdateVaults.length > 0) {
|
102
|
-
try {
|
103
|
-
for (const vault of toUpdateVaults) {
|
104
|
-
await apiDbClient.logged.updateMany({
|
105
|
-
where: {
|
106
|
-
address: vault.address,
|
107
|
-
chainId: vault.chainId,
|
108
|
-
},
|
109
|
-
data: {
|
110
|
-
entityData: vault,
|
111
|
-
},
|
112
|
-
});
|
113
|
-
}
|
114
|
-
log.info(`✅ successfully updated ${toUpdateVaults.length} vault(s) collaterals in API database ('Logged' table)`);
|
115
|
-
}
|
116
|
-
catch {
|
117
|
-
throw new Error("Error while updating vaults to API database (`Logged` table)");
|
118
|
-
}
|
119
|
-
}
|
120
|
-
}
|
121
|
-
await updateEulerVaultsCollatInDatabase();
|
122
|
-
await Redis.safeSet("EulerV2Vaults", await getEulerV2Vaults());
|
2
|
+
import { getEulerV2Vaults, updateEulerVaultsCollatInDatabase } from "@/engine/dynamicData/utils/getEulerV2Vaults";
|
3
|
+
(async () => {
|
4
|
+
await Redis.safeSet("EulerV2Vaults", await getEulerV2Vaults());
|
5
|
+
await updateEulerVaultsCollatInDatabase();
|
6
|
+
})();
|