@merkl/api 0.13.15 → 0.14.1
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/backgroundJobs/index.js +2 -1
- package/dist/src/eden/index.d.ts +33 -3
- package/dist/src/entities/opportunity.js +4 -1
- package/dist/src/index.d.ts +13 -1
- package/dist/src/jobs/etl/pendings.js +3 -1
- package/dist/src/jobs/etl/reward-breakdowns.js +3 -1
- package/dist/src/jobs/etl/rewards.js +3 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.d.ts +2 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.js +1 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.d.ts +2 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +83 -112
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/EulerBorrowProcessor.d.ts +8 -12
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/EulerBorrowProcessor.js +28 -24
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/EulerLendProcessor.d.ts +7 -11
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/EulerLendProcessor.js +20 -21
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GenericProcessor.d.ts +6 -5
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GenericProcessor.js +4 -4
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/MaverickBPProcessor.d.ts +1 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/MaverickBPProcessor.js +1 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/NoLinkVaultProcessor.d.ts +1 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/NoLinkVaultProcessor.js +2 -2
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/RfxProcessor.d.ts +1 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/RfxProcessor.js +1 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound2.d.ts +3 -2
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound2.js +2 -2
- package/dist/src/libs/campaigns/campaignsDynamicData.js +1 -2
- package/dist/src/libs/campaigns/utils/getEulerV2Vaults.d.ts +2 -16
- package/dist/src/libs/campaigns/utils/getEulerV2Vaults.js +115 -57
- package/dist/src/modules/v4/bucket/bucket.model.d.ts +10 -0
- package/dist/src/modules/v4/bucket/bucket.model.js +85 -0
- package/dist/src/modules/v4/bucket/bucket.service.d.ts +8 -6
- package/dist/src/modules/v4/bucket/bucket.service.js +145 -83
- package/dist/src/modules/v4/campaign/campaign.repository.js +1 -2
- package/dist/src/modules/v4/opportunity/subservices/getErc20Metadata.service.js +1 -1
- package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +16 -2
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +113 -2
- package/dist/src/routes/v3/euler.d.ts +13 -1
- package/dist/src/routes/v3/euler.js +10 -2
- package/dist/src/routes/v3/router.d.ts +13 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/libs/campaigns/campaignTypes/EulerDynamicData.d.ts +0 -3
- package/dist/src/libs/campaigns/campaignTypes/EulerDynamicData.js +0 -165
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { Pricer } from "../../../../../utils/pricer";
|
2
2
|
import { type CallDto, type Campaign, type CampaignParameters } from "@sdk";
|
3
|
+
import type { ERC20SupportedCampaignType } from "../../ERC20DynamicData";
|
3
4
|
import { type tokenType, type tokenTypeStruct } from "../helpers/tokenType";
|
4
5
|
export declare enum roundType {
|
5
6
|
one = "round1",
|
@@ -51,8 +52,8 @@ export declare class GenericProcessor<Input extends callKeys, DataRaw extends da
|
|
51
52
|
round4: callType[];
|
52
53
|
};
|
53
54
|
debug: boolean;
|
54
|
-
processingRound1(typeInfo: DataRaw
|
55
|
-
processingRound2(typeInfo: DataRaw): void;
|
55
|
+
processingRound1(typeInfo: DataRaw): void;
|
56
|
+
processingRound2(typeInfo: DataRaw, campaign?: CampaignParameters<ERC20SupportedCampaignType>): void;
|
56
57
|
processingRound3(typeInfo: DataRaw): void;
|
57
58
|
processingRound4(typeInfo: DataRaw): void;
|
58
59
|
handleWhiteListBlacklistRound5(typeInfo: DataRaw, campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.ERC20LOGPROCESSOR> | CampaignParameters<Campaign.ERC20REBASELOGPROCESSOR> | CampaignParameters<Campaign.EULER>): {
|
@@ -62,10 +63,10 @@ export declare class GenericProcessor<Input extends callKeys, DataRaw extends da
|
|
62
63
|
};
|
63
64
|
processingRound5(index: number, type: tokenType, typeInfo: DataRaw, calls: string[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.ERC20LOGPROCESSOR> | CampaignParameters<Campaign.ERC20REBASELOGPROCESSOR> | CampaignParameters<Campaign.EULER>, pricer: Pricer): Promise<Output>;
|
64
65
|
computeRound1(type: tokenType, typeInfo: DataRaw): tokenTypeStruct;
|
65
|
-
computeRound2(index: number, type: tokenType, typeInfo: DataRaw, calls: string[]): tokenTypeStruct;
|
66
|
+
computeRound2(index: number, type: tokenType, typeInfo: DataRaw, calls: string[], campaign?: CampaignParameters<ERC20SupportedCampaignType>): tokenTypeStruct;
|
66
67
|
computeRound3(index: number, type: tokenType, typeInfo: DataRaw, calls: string[]): tokenTypeStruct;
|
67
|
-
computeRound4(index: number, type: tokenType, typeInfo: DataRaw, calls: string[], campaign: CampaignParameters<
|
68
|
-
computeRound5(index: number, type: tokenType, typeInfo: DataRaw, calls: string[], campaign: CampaignParameters<
|
68
|
+
computeRound4(index: number, type: tokenType, typeInfo: DataRaw, calls: string[], campaign: CampaignParameters<ERC20SupportedCampaignType>): tokenTypeStruct;
|
69
|
+
computeRound5(index: number, type: tokenType, typeInfo: DataRaw, calls: string[], campaign: CampaignParameters<ERC20SupportedCampaignType>, pricer: Pricer): Promise<tokenTypeStruct>;
|
69
70
|
generateWhitelistCall(type: tokenType, typeInfo: DataRaw, campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.ERC20LOGPROCESSOR> | CampaignParameters<Campaign.ERC20REBASELOGPROCESSOR> | CampaignParameters<Campaign.EULER>): CallDto[];
|
70
71
|
generateBlackListCall(type: tokenType, typeInfo: DataRaw, campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.ERC20LOGPROCESSOR> | CampaignParameters<Campaign.ERC20REBASELOGPROCESSOR> | CampaignParameters<Campaign.EULER>): CallDto[];
|
71
72
|
decodeListedSupply(index: number, decimals: number, list: string[], calls: string[]): string;
|
@@ -18,8 +18,8 @@ export class GenericProcessor {
|
|
18
18
|
round4: [{ key: "totalSupply", call: "totalSupply", target: "tokenAddress" }],
|
19
19
|
};
|
20
20
|
debug = false;
|
21
|
-
processingRound1(typeInfo
|
22
|
-
processingRound2(typeInfo) { }
|
21
|
+
processingRound1(typeInfo) { }
|
22
|
+
processingRound2(typeInfo, campaign) { }
|
23
23
|
processingRound3(typeInfo) { }
|
24
24
|
processingRound4(typeInfo) { }
|
25
25
|
handleWhiteListBlacklistRound5(typeInfo, campaign) {
|
@@ -65,9 +65,9 @@ export class GenericProcessor {
|
|
65
65
|
typeInfo,
|
66
66
|
};
|
67
67
|
}
|
68
|
-
computeRound2(index, type, typeInfo, calls) {
|
68
|
+
computeRound2(index, type, typeInfo, calls, campaign) {
|
69
69
|
this.decodePreviousRound(roundType.one, calls, typeInfo, type, index);
|
70
|
-
this.processingRound2(typeInfo);
|
70
|
+
this.processingRound2(typeInfo, campaign);
|
71
71
|
if (this.debug) {
|
72
72
|
console.log("Round 2", {
|
73
73
|
type: type,
|
package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/MaverickBPProcessor.d.ts
CHANGED
@@ -43,7 +43,7 @@ export declare class MaverickBPProcessor extends GenericProcessor<callKeysMaveri
|
|
43
43
|
round3: callType[];
|
44
44
|
round4: callType[];
|
45
45
|
};
|
46
|
-
processingRound1(typeInfo: dataRawMaverickBP
|
46
|
+
processingRound1(typeInfo: dataRawMaverickBP): void;
|
47
47
|
processingRound2(typeInfo: dataRawMaverickBP): void;
|
48
48
|
processingRound5(_index: number, type: tokenType, typeInfo: dataRawMaverickBP, _calls: string[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.EULER>, pricer: Pricer): Promise<dataTypeMaverickBP>;
|
49
49
|
}
|
package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/MaverickBPProcessor.js
CHANGED
@@ -37,7 +37,7 @@ export class MaverickBPProcessor extends GenericProcessor {
|
|
37
37
|
round3: [],
|
38
38
|
round4: [{ key: "totalSupply", call: "totalSupply", target: "tokenAddress" }],
|
39
39
|
};
|
40
|
-
processingRound1(typeInfo
|
40
|
+
processingRound1(typeInfo) {
|
41
41
|
typeInfo.lensAddress = MAVERICK_ZKSYNC_BP_LENS_ADDRESS;
|
42
42
|
}
|
43
43
|
processingRound2(typeInfo) {
|
package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/NoLinkVaultProcessor.d.ts
CHANGED
@@ -27,7 +27,7 @@ export declare class NoLinkVaultProcessor extends GenericProcessor<callKeysNoLin
|
|
27
27
|
round3: callType[];
|
28
28
|
round4: callType[];
|
29
29
|
};
|
30
|
-
processingRound1(typeInfo: dataRawNoLinkVault
|
30
|
+
processingRound1(typeInfo: dataRawNoLinkVault): void;
|
31
31
|
processingRound5(index: number, type: tokenType, typeInfo: dataRawNoLinkVault, calls: string[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.EULER>, pricer: Pricer): Promise<dataTypeNoLinkVault>;
|
32
32
|
computeRound1(type: tokenType, typeInfo: dataRawNoLinkVault): tokenTypeStruct;
|
33
33
|
computeRound2(index: number, type: tokenType, typeInfo: dataRawNoLinkVault, calls: string[]): tokenTypeStruct;
|
package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/NoLinkVaultProcessor.js
CHANGED
@@ -12,7 +12,7 @@ export class NoLinkVaultProcessor extends GenericProcessor {
|
|
12
12
|
round3: [{ key: "baseSymbol", call: "symbol", target: "base" }],
|
13
13
|
round4: [{ key: "totalSupply", call: "totalSupply", target: "tokenAddress" }],
|
14
14
|
};
|
15
|
-
processingRound1(typeInfo
|
15
|
+
processingRound1(typeInfo) {
|
16
16
|
if (typeInfo.tokenAddress === "0x196ead472583Bc1e9aF7A05F860D9857e1Bd3dCc") {
|
17
17
|
typeInfo.protocol = "Unifi";
|
18
18
|
typeInfo.rateAccountant = "0xA9fB7e2922216deBE3Fd5E1bBE7591eE446Dc21c";
|
@@ -25,7 +25,7 @@ export class NoLinkVaultProcessor extends GenericProcessor {
|
|
25
25
|
typeInfo.protocol = "Unifi";
|
26
26
|
typeInfo.rateAccountant = "0xe0bDb7b9225A2CeB42998dc2E51D4D3CDeb7e3Be";
|
27
27
|
}
|
28
|
-
if (type === tokenType.veda) {
|
28
|
+
if (typeInfo.type === tokenType.veda) {
|
29
29
|
// To retrieve the rateAccountant, look at a transaction, find the teller, then find the accountant.
|
30
30
|
if (typeInfo.tokenAddress === "0x08c6F91e2B681FaF5e17227F2a44C307b3C1364C")
|
31
31
|
typeInfo.rateAccountant = "0xc315D6e14DDCDC7407784e2Caf815d131Bc1D3E7";
|
@@ -34,7 +34,7 @@ export declare class RfxProcessor extends GenericProcessor<callKeysRfx, dataRawT
|
|
34
34
|
round3: callType[];
|
35
35
|
round4: callType[];
|
36
36
|
};
|
37
|
-
processingRound1(typeInfo: dataRawTemplate
|
37
|
+
processingRound1(typeInfo: dataRawTemplate): void;
|
38
38
|
processingRound5(index: number, type: tokenType, typeInfo: dataRawTemplate, calls: string[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.EULER>, pricer: Pricer): Promise<dataTypeRfx>;
|
39
39
|
}
|
40
40
|
export {};
|
@@ -32,7 +32,7 @@ export class RfxProcessor extends GenericProcessor {
|
|
32
32
|
round4: [{ key: "totalSupply", call: "totalSupply", target: "tokenAddress" }],
|
33
33
|
};
|
34
34
|
// override computeRound1(): void {}
|
35
|
-
processingRound1(typeInfo
|
35
|
+
processingRound1(typeInfo) {
|
36
36
|
const hexShortToken = ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode(["string"], ["SHORT_TOKEN"]));
|
37
37
|
const hexLongToken = ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode(["string"], ["LONG_TOKEN"]));
|
38
38
|
typeInfo.RFX_DATASTORE = RFX_DATASTORE;
|
@@ -1,3 +1,4 @@
|
|
1
|
-
import type { ResultDto } from "@sdk";
|
1
|
+
import type { CampaignParameters, ResultDto } from "@sdk";
|
2
|
+
import type { ERC20SupportedCampaignType } from "../ERC20DynamicData";
|
2
3
|
import type { tokenType, tokenTypeStruct } from "./helpers/tokenType";
|
3
|
-
export declare function getTokenTypeRound2(index: number, type: tokenType, typeInfo: any, calls: ResultDto[]): tokenTypeStruct;
|
4
|
+
export declare function getTokenTypeRound2(index: number, type: tokenType, typeInfo: any, calls: ResultDto[], campaign?: CampaignParameters<ERC20SupportedCampaignType>): tokenTypeStruct;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { processorMapping } from "./processor/processorMapping";
|
2
|
-
export function getTokenTypeRound2(index, type, typeInfo, calls) {
|
2
|
+
export function getTokenTypeRound2(index, type, typeInfo, calls, campaign) {
|
3
3
|
try {
|
4
4
|
const returnValueOfCalls = calls.map(call => call.returnData);
|
5
5
|
const ProcessorClass = processorMapping[type];
|
@@ -7,7 +7,7 @@ export function getTokenTypeRound2(index, type, typeInfo, calls) {
|
|
7
7
|
throw new Error(`Processor not found for key: ${type}`);
|
8
8
|
}
|
9
9
|
const processorObject = new ProcessorClass();
|
10
|
-
return processorObject.computeRound2(index, type, typeInfo, returnValueOfCalls);
|
10
|
+
return processorObject.computeRound2(index, type, typeInfo, returnValueOfCalls, campaign);
|
11
11
|
}
|
12
12
|
catch (error) {
|
13
13
|
console.error(error);
|
@@ -9,7 +9,6 @@ import { DolomiteDynamicData } from "./campaignTypes/DolomiteDynamicData";
|
|
9
9
|
import { ERC20DynamicData } from "./campaignTypes/ERC20DynamicData";
|
10
10
|
import { ERC20_SNAPSHOTDynamicData } from "./campaignTypes/ERC20_SNAPSHOTDynamicData";
|
11
11
|
import { EigenLayerDynamicData } from "./campaignTypes/EigenLayerDynamicData";
|
12
|
-
import { EulerDynamicData } from "./campaignTypes/EulerDynamicData";
|
13
12
|
import { HyperdriveDynamicData } from "./campaignTypes/HyperdriveDynamicData";
|
14
13
|
import { JSON_AIRDROPDynamicData } from "./campaignTypes/JSON_AIRDROPDynamicData";
|
15
14
|
import { MORPHODynamicData } from "./campaignTypes/MORPHODynamicData";
|
@@ -53,7 +52,7 @@ export async function campaignsDynamicData(chainId, campaigns, type) {
|
|
53
52
|
return MORPHODynamicData(chainId, campaigns);
|
54
53
|
}
|
55
54
|
case Campaign.EULER: {
|
56
|
-
return
|
55
|
+
return ERC20DynamicData(chainId, campaigns);
|
57
56
|
}
|
58
57
|
case Campaign.DOLOMITE: {
|
59
58
|
return DolomiteDynamicData(chainId, campaigns);
|
@@ -1,22 +1,8 @@
|
|
1
|
-
import { type
|
1
|
+
import { type EulerVaultType } from "@sdk";
|
2
2
|
export declare enum LoggedEntityType {
|
3
3
|
EULER = "EULER_VAULT",
|
4
4
|
UNISWAP_V4 = "UNISWAP_V4"
|
5
5
|
}
|
6
|
-
export type EulerVaultType = {
|
7
|
-
address: string;
|
8
|
-
asset: string;
|
9
|
-
chainId: MerklChainId;
|
10
|
-
debtTokenAddress: string;
|
11
|
-
name: string;
|
12
|
-
fetchedAtBlock: number;
|
13
|
-
collaterals: {
|
14
|
-
address: string;
|
15
|
-
borrowLTV: string;
|
16
|
-
nameCollateral: string;
|
17
|
-
symbolCollateral: string;
|
18
|
-
symbolUnderlying: string;
|
19
|
-
}[];
|
20
|
-
};
|
21
6
|
export declare function getEulerV2Vaults(): Promise<EulerVaultType[]>;
|
22
7
|
export declare const getEulerV2VaultsWithCache: () => Promise<EulerVaultType[]>;
|
8
|
+
export declare function updateEulerVaultsCollatInDatabase(): Promise<void>;
|
@@ -5,6 +5,7 @@ import { apiDbClient } from "../../../utils/prisma";
|
|
5
5
|
import { providers } from "../../../utils/providers";
|
6
6
|
import { ChainInteractionService, ERC20Interface, EULER_ADDRESSES, EulerEVKInterface, EulerVaultLensInterface, EulerVault__factory, NETWORK_LABELS, eulerChainIds, getContractCreationBlock, } from "@sdk";
|
7
7
|
import { getAddress } from "ethers/lib/utils";
|
8
|
+
import _ from "lodash";
|
8
9
|
import { fetchEulerVaultName } from "../campaignTypes/ERC20SubTypes/helpers/eulerVaultNames";
|
9
10
|
import { safeFetchLogs } from "./fetchLogs";
|
10
11
|
export var LoggedEntityType;
|
@@ -12,6 +13,79 @@ export var LoggedEntityType;
|
|
12
13
|
LoggedEntityType["EULER"] = "EULER_VAULT";
|
13
14
|
LoggedEntityType["UNISWAP_V4"] = "UNISWAP_V4";
|
14
15
|
})(LoggedEntityType || (LoggedEntityType = {}));
|
16
|
+
async function computeCollatListAndReturnVaults(chainId, vaults) {
|
17
|
+
let vaultsPerChain = [];
|
18
|
+
/** Extra calls batch to get the collateral addresses */
|
19
|
+
const resCollat = await batchMulticallCallWithRetry(chainId, {
|
20
|
+
calls: vaults
|
21
|
+
.map(vault => vault.address)
|
22
|
+
.map(vaultAddress => {
|
23
|
+
return {
|
24
|
+
allowFailure: true,
|
25
|
+
callData: EulerVaultLensInterface.encodeFunctionData("getRecognizedCollateralsLTVInfo", [vaultAddress]),
|
26
|
+
target: EULER_ADDRESSES[chainId].VAULT_LENS,
|
27
|
+
};
|
28
|
+
}),
|
29
|
+
});
|
30
|
+
const callsCollatUnderlying = [];
|
31
|
+
const callsCollatUnderlyingSymbol = [];
|
32
|
+
for (const [index, vault] of vaults.entries()) {
|
33
|
+
const collatArray = EulerVaultLensInterface.decodeFunctionResult("getRecognizedCollateralsLTVInfo", resCollat[index].returnData)[0];
|
34
|
+
for (const collat of collatArray) {
|
35
|
+
if (!!vault.collaterals &&
|
36
|
+
vault.collaterals.map(c => c.address.toLowerCase()).includes(collat.collateral.toLowerCase()))
|
37
|
+
continue;
|
38
|
+
log.info(`🦭 found new collateral ${collat.collateral} for vault ${vault.address} (${NETWORK_LABELS[chainId]})`);
|
39
|
+
callsCollatUnderlying.push({
|
40
|
+
allowFailure: true,
|
41
|
+
callData: EulerEVKInterface.encodeFunctionData("asset"),
|
42
|
+
target: collat.collateral,
|
43
|
+
}, {
|
44
|
+
allowFailure: true,
|
45
|
+
callData: EulerEVKInterface.encodeFunctionData("symbol"),
|
46
|
+
target: collat.collateral,
|
47
|
+
});
|
48
|
+
}
|
49
|
+
}
|
50
|
+
const resCollatUnderlying = await batchMulticallCallWithRetry(chainId, {
|
51
|
+
calls: callsCollatUnderlying,
|
52
|
+
});
|
53
|
+
for (let i = 0; i < resCollatUnderlying.length; i = i + 2) {
|
54
|
+
const underlyingToken = EulerEVKInterface.decodeFunctionResult("asset", resCollatUnderlying[i].returnData)[0];
|
55
|
+
callsCollatUnderlyingSymbol.push({
|
56
|
+
allowFailure: true,
|
57
|
+
callData: ERC20Interface.encodeFunctionData("symbol"),
|
58
|
+
target: underlyingToken,
|
59
|
+
});
|
60
|
+
}
|
61
|
+
const resCollatUnderlyingSymbol = await batchMulticallCallWithRetry(chainId, {
|
62
|
+
calls: callsCollatUnderlyingSymbol,
|
63
|
+
});
|
64
|
+
vaultsPerChain = vaultsPerChain.concat((await Promise.all(vaults.map(async (vault, index) => {
|
65
|
+
const collatArray = EulerVaultLensInterface.decodeFunctionResult("getRecognizedCollateralsLTVInfo", resCollat[index].returnData)[0];
|
66
|
+
if (!vault.collaterals)
|
67
|
+
vault.collaterals = [];
|
68
|
+
let offset = 0;
|
69
|
+
for (const [_index, collat] of collatArray.entries()) {
|
70
|
+
// _ Check whether the collat was already registered
|
71
|
+
if (!!vault.collaterals &&
|
72
|
+
vault.collaterals.map(c => c.address.toLowerCase()).includes(collat.collateral.toLowerCase())) {
|
73
|
+
offset += 1;
|
74
|
+
continue;
|
75
|
+
}
|
76
|
+
const symbolUnderlying = ERC20Interface.decodeFunctionResult("symbol", resCollatUnderlyingSymbol[_index - offset].returnData)[0];
|
77
|
+
vault.collaterals.push({
|
78
|
+
address: collat.collateral,
|
79
|
+
symbolCollateral: EulerEVKInterface.decodeFunctionResult("symbol", resCollatUnderlying[2 * (_index - offset) + 1].returnData)[0],
|
80
|
+
symbolUnderlying,
|
81
|
+
borrowLTV: collat.borrowLTV.toString(),
|
82
|
+
nameCollateral: (await fetchEulerVaultName(collat.collateral, chainId)) ?? symbolUnderlying,
|
83
|
+
});
|
84
|
+
}
|
85
|
+
return { ...vault };
|
86
|
+
}))));
|
87
|
+
return vaultsPerChain;
|
88
|
+
}
|
15
89
|
export async function getEulerV2Vaults() {
|
16
90
|
let vaults = [];
|
17
91
|
// 0_ Fetch all euler vaults from database
|
@@ -53,61 +127,7 @@ export async function getEulerV2Vaults() {
|
|
53
127
|
};
|
54
128
|
}));
|
55
129
|
log.local(`fetched ${decodedVaults.length} vaults(s) on ${NETWORK_LABELS[chainId]} between blocks ${fromBlock} and ${toBlock}`);
|
56
|
-
|
57
|
-
const resCollat = await batchMulticallCallWithRetry(chainId, {
|
58
|
-
calls: decodedVaults.map(vault => {
|
59
|
-
return {
|
60
|
-
allowFailure: true,
|
61
|
-
callData: EulerVaultLensInterface.encodeFunctionData("getRecognizedCollateralsLTVInfo", [vault.address]),
|
62
|
-
target: EULER_ADDRESSES[chainId].VAULT_LENS,
|
63
|
-
};
|
64
|
-
}),
|
65
|
-
});
|
66
|
-
const callsCollatUnderlying = [];
|
67
|
-
const callsCollatUnderlyingSymbol = [];
|
68
|
-
for (const [index, _] of decodedVaults.entries()) {
|
69
|
-
const collatArray = EulerVaultLensInterface.decodeFunctionResult("getRecognizedCollateralsLTVInfo", resCollat[index].returnData)[0];
|
70
|
-
for (const collat of collatArray) {
|
71
|
-
callsCollatUnderlying.push({
|
72
|
-
allowFailure: true,
|
73
|
-
callData: EulerEVKInterface.encodeFunctionData("asset"),
|
74
|
-
target: collat.collateral,
|
75
|
-
}, {
|
76
|
-
allowFailure: true,
|
77
|
-
callData: EulerEVKInterface.encodeFunctionData("symbol"),
|
78
|
-
target: collat.collateral,
|
79
|
-
});
|
80
|
-
}
|
81
|
-
}
|
82
|
-
const resCollatUnderlying = await batchMulticallCallWithRetry(chainId, {
|
83
|
-
calls: callsCollatUnderlying,
|
84
|
-
});
|
85
|
-
for (let i = 0; i < resCollatUnderlying.length; i = i + 2) {
|
86
|
-
const underlyingToken = EulerEVKInterface.decodeFunctionResult("asset", resCollatUnderlying[i].returnData)[0];
|
87
|
-
callsCollatUnderlyingSymbol.push({
|
88
|
-
allowFailure: true,
|
89
|
-
callData: ERC20Interface.encodeFunctionData("symbol"),
|
90
|
-
target: underlyingToken,
|
91
|
-
});
|
92
|
-
}
|
93
|
-
const resCollatUnderlyingSymbol = await batchMulticallCallWithRetry(chainId, {
|
94
|
-
calls: callsCollatUnderlyingSymbol,
|
95
|
-
});
|
96
|
-
vaultsPerChain = vaultsPerChain.concat((await Promise.all(decodedVaults.map(async (decodedVault, index) => {
|
97
|
-
const collatArray = EulerVaultLensInterface.decodeFunctionResult("getRecognizedCollateralsLTVInfo", resCollat[index].returnData)[0];
|
98
|
-
const collaterals = [];
|
99
|
-
for (const [_index, collat] of collatArray.entries()) {
|
100
|
-
const symbolUnderlying = ERC20Interface.decodeFunctionResult("symbol", resCollatUnderlyingSymbol[_index].returnData)[0];
|
101
|
-
collaterals.push({
|
102
|
-
address: collat.collateral,
|
103
|
-
symbolCollateral: EulerEVKInterface.decodeFunctionResult("symbol", resCollatUnderlying[2 * _index + 1].returnData)[0],
|
104
|
-
symbolUnderlying,
|
105
|
-
borrowLTV: collat.borrowLTV.toString(),
|
106
|
-
nameCollateral: (await fetchEulerVaultName(collat.collateral, chainId)) ?? symbolUnderlying,
|
107
|
-
});
|
108
|
-
}
|
109
|
-
return { ...decodedVault, collaterals };
|
110
|
-
}))));
|
130
|
+
vaultsPerChain = await computeCollatListAndReturnVaults(chainId, decodedVaults);
|
111
131
|
return vaultsPerChain;
|
112
132
|
}
|
113
133
|
catch (e) {
|
@@ -140,8 +160,7 @@ export async function getEulerV2Vaults() {
|
|
140
160
|
throw new Error("Error while saving vaults to API database (`Logged` table)");
|
141
161
|
}
|
142
162
|
}
|
143
|
-
log.info("✅ successfully fetched vaults on Euler V2");
|
144
|
-
// FIXME _ Merge previoulsy stored vaults with newly fetched ones
|
163
|
+
log.info("✅ successfully fetched new vaults on Euler V2");
|
145
164
|
if (storedVaults.length > 0) {
|
146
165
|
vaults = vaults.concat(storedVaults.map(v => v.entityData));
|
147
166
|
}
|
@@ -149,3 +168,42 @@ export async function getEulerV2Vaults() {
|
|
149
168
|
return vaults;
|
150
169
|
}
|
151
170
|
export const getEulerV2VaultsWithCache = async () => await Redis.getOrSet("EulerV2Vaults", getEulerV2Vaults);
|
171
|
+
export async function updateEulerVaultsCollatInDatabase() {
|
172
|
+
// 0_ Fetch all euler vaults from database
|
173
|
+
const vaults = await apiDbClient.logged.findMany({
|
174
|
+
where: { type: LoggedEntityType.EULER },
|
175
|
+
});
|
176
|
+
const clonedVaults = _.cloneDeep(vaults);
|
177
|
+
let toUpdateVaults = [];
|
178
|
+
// 1_ Return all vaults already stored with their collateral updated
|
179
|
+
const res = await Promise.all(eulerChainIds.map(async (chainId) => computeCollatListAndReturnVaults(chainId, clonedVaults.filter(entity => entity.chainId === chainId).map(entity => entity.entityData))));
|
180
|
+
for (const resPerChain of res) {
|
181
|
+
if (!!resPerChain && resPerChain.length > 0) {
|
182
|
+
toUpdateVaults = toUpdateVaults.concat(resPerChain.filter(updatedVault => {
|
183
|
+
return (updatedVault.collaterals.length >
|
184
|
+
vaults.find(vault => vault.address?.toLowerCase() === updatedVault.address.toLowerCase())
|
185
|
+
?.entityData?.collaterals.length);
|
186
|
+
}));
|
187
|
+
}
|
188
|
+
}
|
189
|
+
// 2_ Update the API database
|
190
|
+
if (toUpdateVaults.length > 0) {
|
191
|
+
try {
|
192
|
+
for (const vault of toUpdateVaults) {
|
193
|
+
await apiDbClient.logged.updateMany({
|
194
|
+
where: {
|
195
|
+
address: vault.address,
|
196
|
+
chainId: vault.chainId,
|
197
|
+
},
|
198
|
+
data: {
|
199
|
+
entityData: vault,
|
200
|
+
},
|
201
|
+
});
|
202
|
+
}
|
203
|
+
log.info(`✅ successfully updated ${toUpdateVaults.length} vault(s) collaterals in API database ('Logged' table)`);
|
204
|
+
}
|
205
|
+
catch {
|
206
|
+
throw new Error("Error while updating vaults to API database (`Logged` table)");
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare const mimeTypes: readonly ["audio/aac", "application/x-abiword", "image/apng", "application/x-freearc", "image/avif", "video/x-msvideo", "application/vnd.amazon.ebook", "application/octet-stream", "image/bmp", "application/x-bzip", "application/x-bzip2", "application/x-cdf", "application/x-csh", "text/css", "text/csv", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.ms-fontobject", "application/epub+zip", "application/gzip", "application/x-gzip", "image/gif", "text/html", "image/vnd.microsoft.icon", "text/calendar", "application/java-archive", "image/jpeg", "text/javascript", "application/json", "application/ld+json", "audio/midi", "audio/x-midi", "text/javascript", "audio/mpeg", "video/mp4", "video/mpeg", "application/vnd.apple.installer+xml", "application/vnd.oasis.opendocument.presentation", "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.text", "audio/ogg", "video/ogg", "application/ogg", "audio/ogg", "font/otf", "image/png", "application/pdf", "application/x-httpd-php", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.rar", "application/rtf", "application/x-sh", "image/svg+xml", "application/x-tar", "image/tiff", "video/mp2t", "font/ttf", "text/plain", "application/vnd.visio", "audio/wav", "audio/webm", "video/webm", "image/webp", "font/woff", "font/woff2", "application/xhtml+xml", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/xml", "text/xml", "application/atom+xml", "application/xml", "application/vnd.mozilla.xul+xml", "application/zip", "application/x-zip-compressed", "audio/video", "video/3gpp", "audio/3gpp", "audio/video", "video/3gpp2", "audio/3gpp2", "application/x-7z-compressed"];
|
2
|
+
export type MimeType = (typeof mimeTypes)[number];
|
3
|
+
export type UploadOptions<T> = {
|
4
|
+
type?: MimeType;
|
5
|
+
compression?: boolean;
|
6
|
+
overwrite?: boolean;
|
7
|
+
isPublic?: boolean;
|
8
|
+
transform?: (obj: T) => string;
|
9
|
+
separator?: string;
|
10
|
+
};
|
@@ -0,0 +1,85 @@
|
|
1
|
+
export const mimeTypes = [
|
2
|
+
"audio/aac",
|
3
|
+
"application/x-abiword",
|
4
|
+
"image/apng",
|
5
|
+
"application/x-freearc",
|
6
|
+
"image/avif",
|
7
|
+
"video/x-msvideo",
|
8
|
+
"application/vnd.amazon.ebook",
|
9
|
+
"application/octet-stream",
|
10
|
+
"image/bmp",
|
11
|
+
"application/x-bzip",
|
12
|
+
"application/x-bzip2",
|
13
|
+
"application/x-cdf",
|
14
|
+
"application/x-csh",
|
15
|
+
"text/css",
|
16
|
+
"text/csv",
|
17
|
+
"application/msword",
|
18
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
19
|
+
"application/vnd.ms-fontobject",
|
20
|
+
"application/epub+zip",
|
21
|
+
"application/gzip",
|
22
|
+
"application/x-gzip",
|
23
|
+
"image/gif",
|
24
|
+
"text/html",
|
25
|
+
"image/vnd.microsoft.icon",
|
26
|
+
"text/calendar",
|
27
|
+
"application/java-archive",
|
28
|
+
"image/jpeg",
|
29
|
+
"text/javascript",
|
30
|
+
"application/json",
|
31
|
+
"application/ld+json",
|
32
|
+
"audio/midi",
|
33
|
+
"audio/x-midi",
|
34
|
+
"text/javascript",
|
35
|
+
"audio/mpeg",
|
36
|
+
"video/mp4",
|
37
|
+
"video/mpeg",
|
38
|
+
"application/vnd.apple.installer+xml",
|
39
|
+
"application/vnd.oasis.opendocument.presentation",
|
40
|
+
"application/vnd.oasis.opendocument.spreadsheet",
|
41
|
+
"application/vnd.oasis.opendocument.text",
|
42
|
+
"audio/ogg",
|
43
|
+
"video/ogg",
|
44
|
+
"application/ogg",
|
45
|
+
"audio/ogg",
|
46
|
+
"font/otf",
|
47
|
+
"image/png",
|
48
|
+
"application/pdf",
|
49
|
+
"application/x-httpd-php",
|
50
|
+
"application/vnd.ms-powerpoint",
|
51
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
52
|
+
"application/vnd.rar",
|
53
|
+
"application/rtf",
|
54
|
+
"application/x-sh",
|
55
|
+
"image/svg+xml",
|
56
|
+
"application/x-tar",
|
57
|
+
"image/tiff",
|
58
|
+
"video/mp2t",
|
59
|
+
"font/ttf",
|
60
|
+
"text/plain",
|
61
|
+
"application/vnd.visio",
|
62
|
+
"audio/wav",
|
63
|
+
"audio/webm",
|
64
|
+
"video/webm",
|
65
|
+
"image/webp",
|
66
|
+
"font/woff",
|
67
|
+
"font/woff2",
|
68
|
+
"application/xhtml+xml",
|
69
|
+
"application/vnd.ms-excel",
|
70
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
71
|
+
"application/xml",
|
72
|
+
"text/xml",
|
73
|
+
"application/atom+xml",
|
74
|
+
"application/xml",
|
75
|
+
"application/vnd.mozilla.xul+xml",
|
76
|
+
"application/zip",
|
77
|
+
"application/x-zip-compressed",
|
78
|
+
"audio/video",
|
79
|
+
"video/3gpp",
|
80
|
+
"audio/3gpp",
|
81
|
+
"audio/video",
|
82
|
+
"video/3gpp2",
|
83
|
+
"audio/3gpp2",
|
84
|
+
"application/x-7z-compressed",
|
85
|
+
];
|
@@ -1,8 +1,10 @@
|
|
1
|
-
import type {
|
1
|
+
import type { UploadOptions } from "./bucket.model";
|
2
2
|
export declare class BucketService {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
#private;
|
4
|
+
defaultUploadOptions: UploadOptions<unknown>;
|
5
|
+
constructor(bucket: string);
|
6
|
+
pushArray<T>(filename: string, arr: T[], options?: UploadOptions<T>): Promise<number>;
|
7
|
+
push(filename: string, text: string, options?: Omit<UploadOptions<never>, "transform">): Promise<number>;
|
8
|
+
pullArray<T>(filename: string, callback: (elem: string) => T, separator?: string): Promise<T[]>;
|
9
|
+
pull(filename: string): Promise<string>;
|
8
10
|
}
|