@merkl/api 0.20.3 → 0.20.5
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/database/api/.generated/drizzle/schema.d.ts +0 -102
- package/dist/database/api/.generated/drizzle/schema.js +5 -11
- package/dist/database/api/.generated/drizzle/schema.ts +5 -11
- package/dist/database/api/.generated/edge.js +8 -15
- package/dist/database/api/.generated/index-browser.js +5 -12
- package/dist/database/api/.generated/index.d.ts +149 -464
- package/dist/database/api/.generated/index.js +8 -15
- package/dist/database/api/.generated/package.json +1 -1
- package/dist/database/api/.generated/schema.prisma +5 -11
- package/dist/database/api/.generated/wasm.js +5 -12
- package/dist/src/cache/declaration.d.ts +2 -2
- package/dist/src/cache/declaration.js +2 -2
- package/dist/src/eden/index.d.ts +65 -90
- 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 +13 -18
- 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/apr/apr.model.d.ts +3 -3
- package/dist/src/modules/v4/apr/apr.model.js +1 -1
- package/dist/src/modules/v4/computedValue/computedValue.controller.d.ts +1 -3
- package/dist/src/modules/v4/computedValue/computedValue.repository.d.ts +1 -3
- package/dist/src/modules/v4/computedValue/computedValue.repository.js +0 -2
- package/dist/src/modules/v4/computedValue/computedValue.service.d.ts +1 -3
- 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 +12 -15
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +6 -6
- package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +17 -34
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +15 -24
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +4 -0
- package/dist/src/modules/v4/reward/reward.model.d.ts +4 -4
- package/dist/src/modules/v4/reward/reward.model.js +1 -1
- package/dist/src/modules/v4/reward/reward.repository.d.ts +2 -4
- package/dist/src/modules/v4/reward/reward.service.d.ts +5 -10
- package/dist/src/modules/v4/reward/reward.service.js +1 -1
- package/dist/src/modules/v4/router.d.ts +13 -18
- package/dist/src/modules/v4/token/token.service.js +6 -9
- package/dist/src/modules/v4/tvl/tvl.model.d.ts +3 -3
- package/dist/src/modules/v4/tvl/tvl.model.js +1 -1
- 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
@@ -1,7 +1,6 @@
|
|
1
|
-
import { Redis } from "@/cache";
|
2
1
|
import { fetchEulerVaultName } from "@/engine/erc20SubTypeProcessors/helpers/eulerVaultNames";
|
3
2
|
import { batchMulticallCallWithRetry } from "@/utils/generic";
|
4
|
-
import { log } from "@/utils/logger";
|
3
|
+
import { log, logger } from "@/utils/logger";
|
5
4
|
import { providers } from "@/utils/providers";
|
6
5
|
import { apiDbClient } from "@db";
|
7
6
|
import { ChainInteractionService, ERC20Interface, EULER_ADDRESSES, EulerEVKInterface, EulerVaultLensInterface, EulerVault__factory, NETWORK_LABELS, eulerChainIds, getContractCreationBlock, } from "@sdk";
|
@@ -27,59 +26,93 @@ async function computeCollatListAndReturnVaults(chainId, vaults) {
|
|
27
26
|
};
|
28
27
|
}),
|
29
28
|
});
|
30
|
-
const
|
31
|
-
const
|
29
|
+
const callsToCollat = [];
|
30
|
+
const callsToCollatUnderlying = [];
|
31
|
+
// To keep track of all collat data
|
32
|
+
const collateralDataArray = [];
|
33
|
+
let k = 0;
|
32
34
|
for (const [index, vault] of vaults.entries()) {
|
33
35
|
const collatArray = EulerVaultLensInterface.decodeFunctionResult("getRecognizedCollateralsLTVInfo", resCollat[index].returnData)[0];
|
34
36
|
for (const collat of collatArray) {
|
37
|
+
// FIXME
|
35
38
|
if (!!vault.collaterals &&
|
36
|
-
vault.collaterals.map(c => c.address.toLowerCase()).includes(collat.collateral.toLowerCase()))
|
39
|
+
vault.collaterals.map(c => c.address.toLowerCase()).includes(collat.collateral.toLowerCase())) {
|
37
40
|
continue;
|
41
|
+
}
|
38
42
|
log.info(`🦭 found new collateral ${collat.collateral} for vault ${vault.address} (${NETWORK_LABELS[chainId]})`);
|
39
|
-
|
43
|
+
collateralDataArray.push({ vaultAddress: vault.address, address: collat.collateral, callsToCollatIndex: k });
|
44
|
+
k++;
|
45
|
+
callsToCollat.push({
|
40
46
|
allowFailure: true,
|
41
|
-
callData: EulerEVKInterface.encodeFunctionData("
|
47
|
+
callData: EulerEVKInterface.encodeFunctionData("symbol"),
|
42
48
|
target: collat.collateral,
|
43
49
|
}, {
|
44
50
|
allowFailure: true,
|
45
|
-
callData: EulerEVKInterface.encodeFunctionData("
|
51
|
+
callData: EulerEVKInterface.encodeFunctionData("asset"),
|
46
52
|
target: collat.collateral,
|
47
53
|
});
|
48
54
|
}
|
49
55
|
}
|
50
|
-
const
|
51
|
-
calls:
|
56
|
+
const resCallsToCollat = await batchMulticallCallWithRetry(chainId, {
|
57
|
+
calls: callsToCollat,
|
52
58
|
});
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
let j = 0;
|
60
|
+
for (let i = 0; i < resCallsToCollat.length; i = i + 2) {
|
61
|
+
const collatData = collateralDataArray.find(collat => collat.callsToCollatIndex === i / 2);
|
62
|
+
try {
|
63
|
+
// 1_ Collat symbol
|
64
|
+
const symbolCollateral = EulerEVKInterface.decodeFunctionResult("symbol", resCallsToCollat[i].returnData)[0];
|
65
|
+
collatData.symbolCollateral = symbolCollateral;
|
66
|
+
// 2_ Underlying asset => warning it can be undefined and throw an error
|
67
|
+
const underlyingToken = EulerEVKInterface.decodeFunctionResult("asset", resCallsToCollat[i + 1].returnData)[0];
|
68
|
+
callsToCollatUnderlying.push({
|
69
|
+
allowFailure: true,
|
70
|
+
callData: ERC20Interface.encodeFunctionData("symbol"),
|
71
|
+
target: underlyingToken,
|
72
|
+
});
|
73
|
+
collatData.callsToCollatUnderlyingIndex = j;
|
74
|
+
j++;
|
75
|
+
}
|
76
|
+
catch {
|
77
|
+
logger.warn(`🦭 error while decoding underlying token address for collat ${JSON.stringify(collatData)}`);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
let resCallsToCollatUnderlying;
|
81
|
+
if (callsToCollatUnderlying.length > 0) {
|
82
|
+
resCallsToCollatUnderlying = await batchMulticallCallWithRetry(chainId, {
|
83
|
+
calls: callsToCollatUnderlying,
|
59
84
|
});
|
60
85
|
}
|
61
|
-
const resCollatUnderlyingSymbol = await batchMulticallCallWithRetry(chainId, {
|
62
|
-
calls: callsCollatUnderlyingSymbol,
|
63
|
-
});
|
64
86
|
vaultsPerChain = vaultsPerChain.concat((await Promise.all(vaults.map(async (vault, index) => {
|
65
87
|
const collatArray = EulerVaultLensInterface.decodeFunctionResult("getRecognizedCollateralsLTVInfo", resCollat[index].returnData)[0];
|
66
88
|
if (!vault.collaterals)
|
67
89
|
vault.collaterals = [];
|
68
|
-
let offset = 0;
|
69
90
|
for (const [_index, collat] of collatArray.entries()) {
|
70
91
|
// _ Check whether the collat was already registered
|
71
92
|
if (!!vault.collaterals &&
|
72
93
|
vault.collaterals.map(c => c.address.toLowerCase()).includes(collat.collateral.toLowerCase())) {
|
73
|
-
offset += 1;
|
74
94
|
continue;
|
75
95
|
}
|
76
|
-
const
|
96
|
+
const collatData = collateralDataArray.find(c => c.vaultAddress?.toLowerCase() === vault.address?.toLowerCase() && c.address === collat.collateral);
|
97
|
+
if (!collatData || collatData.address !== collat.collateral) {
|
98
|
+
logger.warn(`🦭 issue when fetching data for collat ${collat.collateral} on vault ${vault.address}`);
|
99
|
+
console.log(collatData, collat.collateral);
|
100
|
+
process.exit(1);
|
101
|
+
}
|
102
|
+
// Collateral symbol
|
103
|
+
const symbolCollateral = collatData.symbolCollateral ?? "Unknown";
|
104
|
+
// Collat underlying symbol
|
105
|
+
let symbolUnderlying = "Unknown";
|
106
|
+
try {
|
107
|
+
symbolUnderlying = ERC20Interface.decodeFunctionResult("symbol", resCallsToCollatUnderlying[collatData.callsToCollatUnderlyingIndex ?? -1].returnData)[0];
|
108
|
+
}
|
109
|
+
catch { }
|
77
110
|
vault.collaterals.push({
|
78
111
|
address: collat.collateral,
|
79
|
-
symbolCollateral:
|
80
|
-
symbolUnderlying,
|
112
|
+
symbolCollateral: symbolCollateral,
|
113
|
+
symbolUnderlying: symbolUnderlying,
|
81
114
|
borrowLTV: collat.borrowLTV.toString(),
|
82
|
-
nameCollateral: (await fetchEulerVaultName(collat.collateral, chainId)) ??
|
115
|
+
nameCollateral: (await fetchEulerVaultName(collat.collateral, chainId)) ?? symbolCollateral,
|
83
116
|
});
|
84
117
|
}
|
85
118
|
return { ...vault };
|
@@ -113,20 +146,26 @@ export async function getEulerV2Vaults() {
|
|
113
146
|
}
|
114
147
|
const logs = await safeFetchLogs(chainId, [EulerEVKInterface.getEventTopic("EVaultCreated")], [], fromBlock, toBlock);
|
115
148
|
const decodedVaults = await Promise.all(logs.map(async (log) => {
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
149
|
+
try {
|
150
|
+
const aux = EulerEVKInterface.decodeEventLog("EVaultCreated", log.data, log.topics);
|
151
|
+
const name = (await EulerVault__factory.connect(log.address, providers[chainId]).name()).split(" ");
|
152
|
+
const vaultName = (await fetchEulerVaultName(getAddress(log.address), chainId)) ?? name[name.length - 1];
|
153
|
+
/** Respect the previous typing */
|
154
|
+
return {
|
155
|
+
address: log.address.toString(),
|
156
|
+
asset: aux[1].toString(),
|
157
|
+
fetchedAtBlock: Number(log.blockNumber),
|
158
|
+
chainId: chainId,
|
159
|
+
debtTokenAddress: aux[2].toString(),
|
160
|
+
name: vaultName,
|
161
|
+
};
|
162
|
+
}
|
163
|
+
catch {
|
164
|
+
logger.warn(`issue when fetching data on ${NETWORK_LABELS[chainId]} for vault ${log.address}`);
|
165
|
+
process.exit(1);
|
166
|
+
}
|
128
167
|
}));
|
129
|
-
log.
|
168
|
+
log.info(`fetched ${decodedVaults.length} vaults(s) on ${NETWORK_LABELS[chainId]} between blocks ${fromBlock} and ${toBlock}`);
|
130
169
|
vaultsPerChain = await computeCollatListAndReturnVaults(chainId, decodedVaults);
|
131
170
|
return vaultsPerChain;
|
132
171
|
}
|
@@ -160,14 +199,12 @@ export async function getEulerV2Vaults() {
|
|
160
199
|
throw new Error("Error while saving vaults to API database (`Logged` table)");
|
161
200
|
}
|
162
201
|
}
|
163
|
-
log.info("✅ successfully fetched new vaults on Euler V2");
|
164
202
|
if (storedVaults.length > 0) {
|
165
203
|
vaults = vaults.concat(storedVaults.map(v => v.entityData));
|
166
204
|
}
|
167
205
|
log.info("👋 exiting getEulerV2Vaults");
|
168
206
|
return vaults;
|
169
207
|
}
|
170
|
-
export const getEulerV2VaultsWithCache = async () => await Redis.getOrSet("EulerV2Vaults", getEulerV2Vaults);
|
171
208
|
export async function updateEulerVaultsCollatInDatabase() {
|
172
209
|
// 0_ Fetch all euler vaults from database
|
173
210
|
const vaults = await apiDbClient.logged.findMany({
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { generateCardName } from "@/utils/generateCardName";
|
2
|
+
import { log } from "@/utils/logger";
|
2
3
|
import { BN2Number } from "@sdk";
|
3
4
|
import { GenericProcessor } from "../GenericProcessor";
|
4
5
|
import { fetchEulerVaultName } from "../helpers/eulerVaultNames";
|
@@ -18,8 +19,12 @@ export class EulerLendProcessor extends GenericProcessor {
|
|
18
19
|
async processingRound5(index, type, typeInfo, calls, campaign, pricer) {
|
19
20
|
const { whitelistedSupplyTargetToken, totalSupply, blacklistedSupply } = this.handleWhiteListBlacklistRound5(typeInfo, campaign);
|
20
21
|
const symbolAsset = campaign.campaignParameters.symbolAsset;
|
21
|
-
|
22
|
+
let decimalsAsset = Number(campaign.campaignParameters.decimalsAsset) ?? 18;
|
22
23
|
const priceAsset = (await pricer.get({ symbol: symbolAsset })) ?? 1;
|
24
|
+
if (Number.isNaN(decimalsAsset)) {
|
25
|
+
log.warn(`decimalsAsset is NaN for ${symbolAsset} on campaign ${campaign.campaignId}`);
|
26
|
+
decimalsAsset = 18;
|
27
|
+
}
|
23
28
|
const totalAssets = BN2Number(typeInfo.totalAssets, decimalsAsset);
|
24
29
|
typeInfo.symbolUnderlyingToken = symbolAsset;
|
25
30
|
let cardName = generateCardName(type, typeInfo, campaign);
|
package/dist/src/index.d.ts
CHANGED
@@ -285,9 +285,8 @@ declare const app: Elysia<"", false, {
|
|
285
285
|
cumulated: number;
|
286
286
|
timestamp: bigint;
|
287
287
|
breakdowns: {
|
288
|
-
id:
|
288
|
+
id: string;
|
289
289
|
type: import("@db/api").$Enums.AprType;
|
290
|
-
uuid: string;
|
291
290
|
identifier: string;
|
292
291
|
value: number;
|
293
292
|
aprRecordId: string;
|
@@ -298,9 +297,8 @@ declare const app: Elysia<"", false, {
|
|
298
297
|
total: number;
|
299
298
|
timestamp: bigint;
|
300
299
|
breakdowns: {
|
301
|
-
id:
|
300
|
+
id: string;
|
302
301
|
type: import("@db/api").$Enums.TvlType;
|
303
|
-
uuid: string;
|
304
302
|
identifier: string;
|
305
303
|
value: number;
|
306
304
|
tvlRecordId: string;
|
@@ -311,8 +309,7 @@ declare const app: Elysia<"", false, {
|
|
311
309
|
total: number;
|
312
310
|
timestamp: bigint;
|
313
311
|
breakdowns: {
|
314
|
-
id:
|
315
|
-
uuid: string;
|
312
|
+
id: string;
|
316
313
|
value: number;
|
317
314
|
campaignId: string;
|
318
315
|
dailyRewardsRecordId: string;
|
@@ -513,7 +510,7 @@ declare const app: Elysia<"", false, {
|
|
513
510
|
timestamp: string | bigint;
|
514
511
|
cumulated: number;
|
515
512
|
breakdowns: {
|
516
|
-
id:
|
513
|
+
id: string;
|
517
514
|
type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
|
518
515
|
identifier: string;
|
519
516
|
value: number;
|
@@ -524,7 +521,7 @@ declare const app: Elysia<"", false, {
|
|
524
521
|
total: number;
|
525
522
|
timestamp: string | bigint;
|
526
523
|
breakdowns: {
|
527
|
-
id:
|
524
|
+
id: string;
|
528
525
|
type: "TOKEN" | "PROTOCOL";
|
529
526
|
identifier: string;
|
530
527
|
value: number;
|
@@ -536,7 +533,7 @@ declare const app: Elysia<"", false, {
|
|
536
533
|
total: number;
|
537
534
|
timestamp: string | bigint;
|
538
535
|
breakdowns: {
|
539
|
-
id:
|
536
|
+
id: string;
|
540
537
|
token: {
|
541
538
|
price?: number | null | undefined;
|
542
539
|
symbol: string;
|
@@ -644,7 +641,7 @@ declare const app: Elysia<"", false, {
|
|
644
641
|
timestamp: string | bigint;
|
645
642
|
cumulated: number;
|
646
643
|
breakdowns: {
|
647
|
-
id:
|
644
|
+
id: string;
|
648
645
|
type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
|
649
646
|
identifier: string;
|
650
647
|
value: number;
|
@@ -655,7 +652,7 @@ declare const app: Elysia<"", false, {
|
|
655
652
|
total: number;
|
656
653
|
timestamp: string | bigint;
|
657
654
|
breakdowns: {
|
658
|
-
id:
|
655
|
+
id: string;
|
659
656
|
type: "TOKEN" | "PROTOCOL";
|
660
657
|
identifier: string;
|
661
658
|
value: number;
|
@@ -667,7 +664,7 @@ declare const app: Elysia<"", false, {
|
|
667
664
|
total: number;
|
668
665
|
timestamp: string | bigint;
|
669
666
|
breakdowns: {
|
670
|
-
id:
|
667
|
+
id: string;
|
671
668
|
token: {
|
672
669
|
price?: number | null | undefined;
|
673
670
|
symbol: string;
|
@@ -809,7 +806,7 @@ declare const app: Elysia<"", false, {
|
|
809
806
|
timestamp: string | bigint;
|
810
807
|
cumulated: number;
|
811
808
|
breakdowns: {
|
812
|
-
id:
|
809
|
+
id: string;
|
813
810
|
type: "CAMPAIGN" | "TOKEN" | "PROTOCOL";
|
814
811
|
identifier: string;
|
815
812
|
value: number;
|
@@ -820,7 +817,7 @@ declare const app: Elysia<"", false, {
|
|
820
817
|
total: number;
|
821
818
|
timestamp: string | bigint;
|
822
819
|
breakdowns: {
|
823
|
-
id:
|
820
|
+
id: string;
|
824
821
|
type: "TOKEN" | "PROTOCOL";
|
825
822
|
identifier: string;
|
826
823
|
value: number;
|
@@ -832,7 +829,7 @@ declare const app: Elysia<"", false, {
|
|
832
829
|
total: number;
|
833
830
|
timestamp: string | bigint;
|
834
831
|
breakdowns: {
|
835
|
-
id:
|
832
|
+
id: string;
|
836
833
|
token: {
|
837
834
|
price?: number | null | undefined;
|
838
835
|
symbol: string;
|
@@ -4588,11 +4585,9 @@ declare const app: Elysia<"", false, {
|
|
4588
4585
|
headers: unknown;
|
4589
4586
|
response: {
|
4590
4587
|
200: {
|
4591
|
-
id:
|
4588
|
+
id: string;
|
4592
4589
|
reason: string;
|
4593
|
-
uuid: string;
|
4594
4590
|
campaignId: string;
|
4595
|
-
stringId: string;
|
4596
4591
|
boost: number | null;
|
4597
4592
|
}[];
|
4598
4593
|
};
|
@@ -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
|
+
})();
|
@@ -12,9 +12,9 @@ export type AprRecord = Resource<"AprRecord", "id" | "opportunityId", {
|
|
12
12
|
* @description Describes one apr fraction of record
|
13
13
|
* @see {@link Resource}
|
14
14
|
*/
|
15
|
-
export type AprBreakdown = Resource<"AprBreakdown", "id" | "aprRecordId"
|
15
|
+
export type AprBreakdown = Resource<"AprBreakdown", "id" | "aprRecordId">;
|
16
16
|
export declare const AprBreakdownResourceDto: import("@sinclair/typebox").TObject<{
|
17
|
-
id: import("@sinclair/typebox").
|
17
|
+
id: import("@sinclair/typebox").TString;
|
18
18
|
type: import("@sinclair/typebox").TEnum<{
|
19
19
|
CAMPAIGN: "CAMPAIGN";
|
20
20
|
TOKEN: "TOKEN";
|
@@ -28,7 +28,7 @@ export declare const AprRecordResourceDto: import("@sinclair/typebox").TObject<{
|
|
28
28
|
cumulated: import("@sinclair/typebox").TNumber;
|
29
29
|
timestamp: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBigInt, import("@sinclair/typebox").TString]>;
|
30
30
|
breakdowns: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
31
|
-
id: import("@sinclair/typebox").
|
31
|
+
id: import("@sinclair/typebox").TString;
|
32
32
|
type: import("@sinclair/typebox").TEnum<{
|
33
33
|
CAMPAIGN: "CAMPAIGN";
|
34
34
|
TOKEN: "TOKEN";
|
@@ -2,7 +2,7 @@ import { AprType } from "@db/api";
|
|
2
2
|
import { t } from "elysia";
|
3
3
|
// ─── Dtos ────────────────────────────────────────────────────────────────────
|
4
4
|
export const AprBreakdownResourceDto = t.Object({
|
5
|
-
id: t.
|
5
|
+
id: t.String(),
|
6
6
|
type: t.Enum(AprType),
|
7
7
|
identifier: t.String(),
|
8
8
|
value: t.Number(),
|
@@ -51,11 +51,9 @@ export declare const ComputedValueController: Elysia<"/value", false, {
|
|
51
51
|
headers: unknown;
|
52
52
|
response: {
|
53
53
|
200: {
|
54
|
-
id:
|
54
|
+
id: string;
|
55
55
|
reason: string;
|
56
|
-
uuid: string;
|
57
56
|
campaignId: string;
|
58
|
-
stringId: string;
|
59
57
|
boost: number | null;
|
60
58
|
}[];
|
61
59
|
};
|
@@ -7,11 +7,9 @@ export declare abstract class ComputedValueRepository {
|
|
7
7
|
} | null>;
|
8
8
|
static upsertCampaignComputedValue(data: UpsertCampaignComputedValueModel): Promise<void>;
|
9
9
|
static findUserValues(data: GetUserComputedValuesModel): Promise<{
|
10
|
-
id:
|
10
|
+
id: string;
|
11
11
|
reason: string;
|
12
|
-
uuid: string;
|
13
12
|
campaignId: string;
|
14
|
-
stringId: string;
|
15
13
|
boost: number | null;
|
16
14
|
}[]>;
|
17
15
|
static upsertUserComputedValues(data: UpsertUserComputedValuesModel): Promise<void>;
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { apiDbClient } from "@db";
|
2
2
|
import { UserRepository } from "../user/user.repository";
|
3
|
-
import { ComputedValueService } from "./computedValue.service";
|
4
3
|
export class ComputedValueRepository {
|
5
4
|
static async findCampaignValue(params) {
|
6
5
|
return await apiDbClient.campaignComputedValue.findUnique({
|
@@ -38,7 +37,6 @@ export class ComputedValueRepository {
|
|
38
37
|
},
|
39
38
|
update: { [item.field]: item.value },
|
40
39
|
create: {
|
41
|
-
stringId: ComputedValueService.hashUserComputedValueId(item.campaignId, item.address, item.reason),
|
42
40
|
campaignId: item.campaignId,
|
43
41
|
address: item.address,
|
44
42
|
reason: item.reason,
|
@@ -8,11 +8,9 @@ export declare abstract class ComputedValueService {
|
|
8
8
|
} | null>;
|
9
9
|
static upsertCampaignComputedValue(data: UpsertCampaignComputedValueModel): Promise<void>;
|
10
10
|
static findUserValues(params: GetUserComputedValuesModel): Promise<{
|
11
|
-
id:
|
11
|
+
id: string;
|
12
12
|
reason: string;
|
13
|
-
uuid: string;
|
14
13
|
campaignId: string;
|
15
|
-
stringId: string;
|
16
14
|
boost: number | null;
|
17
15
|
}[]>;
|
18
16
|
static upsertUserComputedValues(data: UpsertUserComputedValuesModel): Promise<void>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export class IconService {
|
2
|
+
static async pullPush(url, bucket, metadata) {
|
3
|
+
const filename = metadata?.name ?? url;
|
4
|
+
const iconFile = await fetch(url);
|
5
|
+
const mimeType = iconFile.headers.get("content-type");
|
6
|
+
const extension = metadata?.extension ? metadata.extension : mimeType.split("/")[1].split("+")[0];
|
7
|
+
const byteArray = await iconFile.bytes();
|
8
|
+
return await bucket.pushRaw(`${filename}.${extension}`, byteArray, {
|
9
|
+
type: mimeType,
|
10
|
+
isPublic: true,
|
11
|
+
compression: true,
|
12
|
+
overwrite: true,
|
13
|
+
});
|
14
|
+
}
|
15
|
+
}
|