@merkl/api 0.20.174 → 0.20.176
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/reward-breakdowns.js +23 -13
- package/dist/src/modules/v4/campaign/campaign.repository.js +5 -0
- package/dist/src/modules/v4/merklRoot/merklRoot.repository.js +7 -5
- package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +29 -2
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +34 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -78,18 +78,28 @@ const transform = (rewardBreakdowns) => {
|
|
78
78
|
return transformedBreakdowns;
|
79
79
|
};
|
80
80
|
// ─── Load ────────────────────────────────────────────────────────────────────
|
81
|
-
const load = async (rewardBreakdowns) => {
|
81
|
+
const load = async (rewardBreakdowns, skipSubCampaignReasons = false) => {
|
82
82
|
const count = (await apiDbClient.rewardBreakdown.createMany({
|
83
|
-
data: rewardBreakdowns.map(breakdown =>
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
83
|
+
data: rewardBreakdowns.map(breakdown => {
|
84
|
+
// Trying to parse subcampaign reasons only when skipSubCampaignReasons is false because priority is having the breakdowns in the DB
|
85
|
+
if (!skipSubCampaignReasons && breakdown.reason.includes("~")) {
|
86
|
+
// subcampaign reason will have the form <protocol>_<campaignId>_<reason> outputted by the processor>
|
87
|
+
const subcampaignReason = breakdown.reason.split("~")[breakdown.reason.split("~").length - 1];
|
88
|
+
breakdown.reason = subcampaignReason.split("_").slice(2).join("_");
|
89
|
+
breakdown.subCampaignId = subcampaignReason.split("_")[1];
|
90
|
+
}
|
91
|
+
return {
|
92
|
+
id: breakdown.id,
|
93
|
+
protocolId: breakdown.protocolId,
|
94
|
+
reason: breakdown.reason,
|
95
|
+
amount: breakdown.amount,
|
96
|
+
claimed: breakdown.claimed,
|
97
|
+
pending: breakdown.pending,
|
98
|
+
rewardId: breakdown.rewardId,
|
99
|
+
campaignId: breakdown.campaignId,
|
100
|
+
subCampaignId: breakdown.subCampaignId ?? undefined,
|
101
|
+
};
|
102
|
+
}),
|
93
103
|
skipDuplicates: true,
|
94
104
|
})).count;
|
95
105
|
log.info(`Successfully inserted ${rewardBreakdowns.length} reward breakdown(s).`);
|
@@ -106,7 +116,7 @@ const retry = async (batches) => {
|
|
106
116
|
const secondHalf = currentBatch;
|
107
117
|
// Process first half
|
108
118
|
try {
|
109
|
-
inserted += await load(firstHalf);
|
119
|
+
inserted += await load(firstHalf, true);
|
110
120
|
}
|
111
121
|
catch (err) {
|
112
122
|
log.error(JSON.stringify(firstHalf), err);
|
@@ -117,7 +127,7 @@ const retry = async (batches) => {
|
|
117
127
|
}
|
118
128
|
// Process second half
|
119
129
|
try {
|
120
|
-
inserted += await load(secondHalf);
|
130
|
+
inserted += await load(secondHalf, true);
|
121
131
|
}
|
122
132
|
catch (err) {
|
123
133
|
log.error(JSON.stringify(secondHalf), err);
|
@@ -203,6 +203,9 @@ export class CampaignRepository {
|
|
203
203
|
throw new CannotUpdateOpportunityLastCreatedAt(campaign.campaignId, campaign.distributionChainId, campaign.type);
|
204
204
|
}
|
205
205
|
}
|
206
|
+
if (!!campaign.parentCampaignId || !!campaign.rootCampaignId) {
|
207
|
+
log.info(`inserting subcampaign ${campaign.campaignId}. Parent: ${campaign.parentCampaignId}, Root: ${campaign.rootCampaignId}`);
|
208
|
+
}
|
206
209
|
const data = {
|
207
210
|
id: campaign.id,
|
208
211
|
amount: campaign.amount,
|
@@ -238,6 +241,8 @@ export class CampaignRepository {
|
|
238
241
|
},
|
239
242
|
subType: campaign.subType,
|
240
243
|
DistributionChain: { connect: { id: campaign.distributionChainId } },
|
244
|
+
parentCampaign: campaign.parentCampaignId ? { connect: { id: campaign.parentCampaignId } } : undefined,
|
245
|
+
rootCampaign: campaign.rootCampaignId ? { connect: { id: campaign.rootCampaignId } } : undefined,
|
241
246
|
};
|
242
247
|
return await apiDbClient.campaign.upsert({
|
243
248
|
where: {
|
@@ -32,16 +32,18 @@ export class MerklRootRepository {
|
|
32
32
|
return { live, tree, lastTree, endOfDisputePeriod, disputer };
|
33
33
|
}
|
34
34
|
catch (e) {
|
35
|
+
let errorMessage = null;
|
35
36
|
// If the error is a timeout, log a warning and return a void object
|
36
37
|
if (e.message === `Timed out after ${RPC_CALL_TIMEOUT}ms`) {
|
37
|
-
|
38
|
-
log.warn(errorMessage);
|
39
|
-
return {};
|
38
|
+
errorMessage = `fetching Merkle Root for chain ${NETWORK_LABELS[chainId]} timed out`;
|
40
39
|
}
|
40
|
+
// If the error is a rpc failure, log a warning and return a void object
|
41
41
|
if (e.message === "EVMDistributorService: fetchUpdateData multicall failed") {
|
42
|
-
|
42
|
+
errorMessage = `fetching Merkle Root for chain ${NETWORK_LABELS[chainId]} multicall failed`;
|
43
|
+
}
|
44
|
+
if (errorMessage) {
|
43
45
|
log.warn(errorMessage);
|
44
|
-
return {};
|
46
|
+
return {}; // Return an empty object to indicate failure and prevent further trials of fetching this
|
45
47
|
}
|
46
48
|
throw e;
|
47
49
|
}
|
@@ -12,7 +12,8 @@ export declare enum program {
|
|
12
12
|
Etherlink = "Etherlink",
|
13
13
|
Angles = "Angles",
|
14
14
|
Ronin = "Ronin",
|
15
|
-
TAC = "TAC"
|
15
|
+
TAC = "TAC",
|
16
|
+
HypuurFi = "HypuurFi"
|
16
17
|
}
|
17
18
|
export declare enum roninCampaigns {
|
18
19
|
Katana_WETH_RON_Ronin = "Katana WETH-RON Ronin 0x90f31f1907a4d1443a6aacdc91ac2312f91bafa7",
|
@@ -1130,6 +1131,32 @@ declare const EtherlinkInterfaceCampaigns: {
|
|
1130
1131
|
url: string;
|
1131
1132
|
};
|
1132
1133
|
};
|
1134
|
+
declare const HypuurFiCampaignsInterface: {
|
1135
|
+
"mock program with referral": {
|
1136
|
+
campaignType: any;
|
1137
|
+
computeChainId: any;
|
1138
|
+
hooks: {
|
1139
|
+
hookType: any;
|
1140
|
+
key: string;
|
1141
|
+
chainId: any;
|
1142
|
+
contractAddress: string;
|
1143
|
+
contractState: any;
|
1144
|
+
boostForReferrer: any;
|
1145
|
+
valueForBoostForReferrer: number;
|
1146
|
+
boostForInvited: any;
|
1147
|
+
valueForBoostForInvited: number;
|
1148
|
+
defaultBoost: any;
|
1149
|
+
maximumBoostReferrer: number;
|
1150
|
+
maximumBoostInvited: number;
|
1151
|
+
cumulativeBoost: boolean;
|
1152
|
+
}[];
|
1153
|
+
targetToken: string;
|
1154
|
+
whitelist: never[];
|
1155
|
+
blacklist: never[];
|
1156
|
+
url: string;
|
1157
|
+
forwarders: never[];
|
1158
|
+
};
|
1159
|
+
};
|
1133
1160
|
declare const SwapxInterfaceCampaigns: {
|
1134
1161
|
[key in swapxCampaigns]: partialConfig;
|
1135
1162
|
};
|
@@ -1520,6 +1547,6 @@ declare const TACInterfaceCampaigns: {
|
|
1520
1547
|
};
|
1521
1548
|
};
|
1522
1549
|
export declare const MerklInterfaceCampaigns: {
|
1523
|
-
[key in program]: typeof PufferInterfaceCampaigns | typeof ZkSyncInterfaceCampaigns | typeof ModeInterfaceCampaigns | typeof VicunaInterfaceCampaigns | typeof SonicmarketInterfaceCampaigns | typeof ReserveInterfaceCampaigns | typeof BeetsInterfaceCampaigns | typeof CeloInterfaceCampaigns | typeof EtherlinkInterfaceCampaigns | typeof SwapxInterfaceCampaigns | typeof AnglesInterfaceCampaigns | typeof RoninInterfaceCampaigns | typeof TACInterfaceCampaigns;
|
1550
|
+
[key in program]: typeof PufferInterfaceCampaigns | typeof ZkSyncInterfaceCampaigns | typeof ModeInterfaceCampaigns | typeof VicunaInterfaceCampaigns | typeof SonicmarketInterfaceCampaigns | typeof ReserveInterfaceCampaigns | typeof BeetsInterfaceCampaigns | typeof CeloInterfaceCampaigns | typeof EtherlinkInterfaceCampaigns | typeof SwapxInterfaceCampaigns | typeof AnglesInterfaceCampaigns | typeof RoninInterfaceCampaigns | typeof TACInterfaceCampaigns | typeof HypuurFiCampaignsInterface;
|
1524
1551
|
};
|
1525
1552
|
export {};
|
@@ -16,6 +16,7 @@ export var program;
|
|
16
16
|
program["Angles"] = "Angles";
|
17
17
|
program["Ronin"] = "Ronin";
|
18
18
|
program["TAC"] = "TAC";
|
19
|
+
program["HypuurFi"] = "HypuurFi";
|
19
20
|
})(program || (program = {}));
|
20
21
|
export var roninCampaigns;
|
21
22
|
(function (roninCampaigns) {
|
@@ -995,6 +996,38 @@ const EtherlinkInterfaceCampaigns = {
|
|
995
996
|
url: "https://app.hanji.io/trade/0xbb6b01d94e3f6ebae8647cb56d544f57928ab758",
|
996
997
|
},
|
997
998
|
};
|
999
|
+
var HypuurFiCampaigns;
|
1000
|
+
(function (HypuurFiCampaigns) {
|
1001
|
+
HypuurFiCampaigns["test"] = "mock program with referral";
|
1002
|
+
})(HypuurFiCampaigns || (HypuurFiCampaigns = {}));
|
1003
|
+
const HypuurFiCampaignsInterface = {
|
1004
|
+
[HypuurFiCampaigns.test]: {
|
1005
|
+
campaignType: Campaign.ERC20,
|
1006
|
+
computeChainId: ChainId.HYPEREVM,
|
1007
|
+
hooks: [
|
1008
|
+
{
|
1009
|
+
hookType: HOOK.REFERRALPROGRAM,
|
1010
|
+
key: "test-0",
|
1011
|
+
chainId: ChainId.HYPEREVM,
|
1012
|
+
contractAddress: "0xD696E6b94cE79Fe9AAC288C0Fc761643219510B6",
|
1013
|
+
contractState: contractStateBoost.SYNCHRONIZED,
|
1014
|
+
boostForReferrer: boostingReferralFunction.PROPORTIONAL,
|
1015
|
+
valueForBoostForReferrer: 50000000,
|
1016
|
+
boostForInvited: boostingReferralFunction.PROPORTIONAL,
|
1017
|
+
valueForBoostForInvited: 50000000,
|
1018
|
+
defaultBoost: defaultReferralBoost.SCORE,
|
1019
|
+
maximumBoostReferrer: 0,
|
1020
|
+
maximumBoostInvited: 50000000,
|
1021
|
+
cumulativeBoost: false,
|
1022
|
+
},
|
1023
|
+
],
|
1024
|
+
targetToken: "0xfCA0802cb10b3b134a91e07f03965f63eF4B23eA",
|
1025
|
+
whitelist: [],
|
1026
|
+
blacklist: [],
|
1027
|
+
url: "",
|
1028
|
+
forwarders: [],
|
1029
|
+
},
|
1030
|
+
};
|
998
1031
|
const SwapxInterfaceCampaigns = {
|
999
1032
|
[swapxCampaigns.Swapx_beS_OS_beS_gauge_Swapx]: {
|
1000
1033
|
campaignType: Campaign.CLAMM,
|
@@ -6502,4 +6535,5 @@ export const MerklInterfaceCampaigns = {
|
|
6502
6535
|
[program.Angles]: AnglesInterfaceCampaigns,
|
6503
6536
|
[program.Ronin]: RoninInterfaceCampaigns,
|
6504
6537
|
[program.TAC]: TACInterfaceCampaigns,
|
6538
|
+
[program.HypuurFi]: HypuurFiCampaignsInterface,
|
6505
6539
|
};
|