@merkl/api 0.15.5 → 0.15.17
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/jobs/etl/reward-breakdowns.js +35 -34
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AnglesLiquid.d.ts +1 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AnglesLiquid.js +2 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -1,7 +1,6 @@
|
|
1
1
|
// ─── Reward Breakdowns ETL ───────────────────────────────────────────────────
|
2
2
|
if (!process.env.ENV || !process.env.CHAIN_ID || !process.env.ROOT)
|
3
3
|
throw new Error("[ENV]: missing variable");
|
4
|
-
import { CampaignService } from "../../modules/v4";
|
5
4
|
import { log } from "../../utils/logger";
|
6
5
|
import { apiDbClient } from "../../utils/prisma";
|
7
6
|
import { withRetry } from "@sdk";
|
@@ -79,42 +78,44 @@ const transform = async (rewardBreakdowns) => {
|
|
79
78
|
// ─── Load ────────────────────────────────────────────────────────────────────
|
80
79
|
const load = async (rewardBreakdowns) => {
|
81
80
|
log.info(`pushing ${rewardBreakdowns.length} rewardBreakdowns`);
|
82
|
-
const missingCampaigns = [];
|
83
|
-
const foundCampaigns = [];
|
84
|
-
const campaigns = rewardBreakdowns.reduce(
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
}
|
108
|
-
|
109
|
-
|
110
|
-
}
|
81
|
+
// const missingCampaigns: string[] = [];
|
82
|
+
// const foundCampaigns: string[] = [];
|
83
|
+
// const campaigns = rewardBreakdowns.reduce(
|
84
|
+
// (acc, x) => {
|
85
|
+
// const campaignUnique = {
|
86
|
+
// campaignId: x.campaignId,
|
87
|
+
// distributionChain: Number.parseInt(process.env.CHAIN_ID!),
|
88
|
+
// };
|
89
|
+
// if (!Object.keys(acc).includes(CampaignService.hashId(campaignUnique)))
|
90
|
+
// acc[CampaignService.hashId(campaignUnique)] = {
|
91
|
+
// campaignId: x.campaignId,
|
92
|
+
// distributionChain: Number.parseInt(process.env.CHAIN_ID!),
|
93
|
+
// };
|
94
|
+
// return acc;
|
95
|
+
// },
|
96
|
+
// {} as Record<string, CampaignUnique>
|
97
|
+
// );
|
98
|
+
// for (const campaign of Object.values(campaigns)) {
|
99
|
+
// const campaignExists = await CampaignService.checkIfExist(campaign);
|
100
|
+
// if (!campaignExists) {
|
101
|
+
// const { success, fail } = await CampaignService.fill([campaign]);
|
102
|
+
// if (fail === 1 || success !== 1) {
|
103
|
+
// missingCampaigns.push(CampaignService.hashId(campaign));
|
104
|
+
// log.warn(`createManyBreakdown - Missing campaign: ${campaign.campaignId}`);
|
105
|
+
// continue;
|
106
|
+
// }
|
107
|
+
// }
|
108
|
+
// foundCampaigns.push(CampaignService.hashId(campaign));
|
109
|
+
// }
|
110
|
+
// if (missingCampaigns.length !== 0) {
|
111
|
+
// log.warn(`createManyBreakdown - Missing ${missingCampaigns.length} campaigns: ${missingCampaigns.join(", ")}`);
|
112
|
+
// }
|
111
113
|
return (await apiDbClient.rewardBreakdown.createMany({
|
112
|
-
data: rewardBreakdowns
|
113
|
-
.map(x => {
|
114
|
+
data: rewardBreakdowns.map(x => {
|
114
115
|
const campaignId = Bun.hash(`${process.env.CHAIN_ID}${x.campaignId}`).toString();
|
115
116
|
return { ...x, campaignId };
|
116
|
-
})
|
117
|
-
|
117
|
+
}),
|
118
|
+
// .filter(x => !missingCampaigns.includes(x.campaignId)),
|
118
119
|
skipDuplicates: true,
|
119
120
|
})).count;
|
120
121
|
};
|
@@ -16,6 +16,7 @@ type dataRawAnglesLiquid = callKeysAnglesLiquid & {};
|
|
16
16
|
type dataTypeAnglesLiquid = dataType & {
|
17
17
|
poolToken: string;
|
18
18
|
totalAssets: string;
|
19
|
+
symbolUnderlyingToken: string;
|
19
20
|
};
|
20
21
|
export declare class AnglesLiquidProcessor extends GenericProcessor<callKeysAnglesLiquid, dataRawAnglesLiquid, dataTypeAnglesLiquid> {
|
21
22
|
rounds: {
|
@@ -18,6 +18,7 @@ export class AnglesLiquidProcessor extends GenericProcessor {
|
|
18
18
|
const priceUnderlying = (await pricer.get({ symbol: "S" })) ?? 0;
|
19
19
|
const tvl = priceUnderlying * BN2Number(typeInfo.totalAssets, 18);
|
20
20
|
const priceTargetToken = totalSupply ? tvl / totalSupply : 0;
|
21
|
+
const symbolUnderlyingToken = "S";
|
21
22
|
return {
|
22
23
|
...typeInfo,
|
23
24
|
tvl,
|
@@ -25,6 +26,7 @@ export class AnglesLiquidProcessor extends GenericProcessor {
|
|
25
26
|
blacklistedSupply,
|
26
27
|
priceTargetToken,
|
27
28
|
totalSupply,
|
29
|
+
symbolUnderlyingToken,
|
28
30
|
totalAssets: typeInfo.totalAssets,
|
29
31
|
poolToken: typeInfo.poolToken,
|
30
32
|
cardName: generateCardName(type, typeInfo, campaign),
|