@merkl/api 0.17.7 → 0.17.9
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/eden/index.d.ts +172 -122
- package/dist/src/index.d.ts +33 -23
- package/dist/src/jobs/etl/update-dynamic-data.js +40 -38
- package/dist/src/libs/campaigns/campaignTypes/MORPHODynamicData.js +18 -31
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +10 -10
- package/dist/src/modules/v4/campaign/campaign.controller.js +1 -0
- package/dist/src/modules/v4/campaign/campaign.model.d.ts +19 -7
- package/dist/src/modules/v4/campaign/campaign.model.js +7 -2
- package/dist/src/modules/v4/campaign/campaign.repository.d.ts +67 -2
- package/dist/src/modules/v4/campaign/campaign.repository.js +46 -6
- package/dist/src/modules/v4/campaign/campaign.service.d.ts +66 -13
- package/dist/src/modules/v4/campaign/campaign.service.js +11 -5
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +23 -13
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +9 -4
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +33 -23
- package/dist/src/modules/v4/router.d.ts +33 -23
- package/dist/src/modules/v4/status/status.model.d.ts +6 -3
- package/dist/src/modules/v4/status/status.model.js +2 -2
- package/dist/src/modules/v4/status/status.service.d.ts +9 -1
- package/dist/src/modules/v4/status/status.service.js +7 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
@@ -328,6 +328,8 @@ declare const app: Elysia<"", false, {
|
|
328
328
|
id: number;
|
329
329
|
icon: string;
|
330
330
|
};
|
331
|
+
endTimestamp: number;
|
332
|
+
startTimestamp: number;
|
331
333
|
rewardToken: {
|
332
334
|
symbol: string;
|
333
335
|
name: string | null;
|
@@ -347,15 +349,15 @@ declare const app: Elysia<"", false, {
|
|
347
349
|
icon: string;
|
348
350
|
} | undefined;
|
349
351
|
campaignStatus: {
|
352
|
+
computedUntil: number;
|
353
|
+
processingStarted: number;
|
350
354
|
error: string;
|
351
355
|
details: import("database/api/.generated/runtime/library").JsonValue;
|
352
356
|
status: import("../database/api/.generated").$Enums.RunStatus;
|
353
357
|
campaignId: string;
|
354
|
-
computedUntil: bigint;
|
355
|
-
processingStarted: bigint;
|
356
358
|
};
|
357
359
|
creatorAddress: string;
|
358
|
-
|
360
|
+
creator: {
|
359
361
|
tags: string[];
|
360
362
|
address: string;
|
361
363
|
creatorId: string | null;
|
@@ -363,8 +365,6 @@ declare const app: Elysia<"", false, {
|
|
363
365
|
type: string;
|
364
366
|
id: string;
|
365
367
|
subType: number | null;
|
366
|
-
startTimestamp: bigint;
|
367
|
-
endTimestamp: bigint;
|
368
368
|
computeChainId: number;
|
369
369
|
distributionChainId: number;
|
370
370
|
campaignId: string;
|
@@ -668,13 +668,18 @@ declare const app: Elysia<"", false, {
|
|
668
668
|
apr: number;
|
669
669
|
dailyRewards: number;
|
670
670
|
campaigns: {
|
671
|
+
creator?: {
|
672
|
+
tags?: string[] | undefined;
|
673
|
+
creatorId?: string | null | undefined;
|
674
|
+
address: string;
|
675
|
+
} | undefined;
|
671
676
|
campaignStatus?: {
|
672
677
|
error?: string | undefined;
|
673
678
|
details?: any;
|
674
679
|
status: string;
|
675
680
|
campaignId: string;
|
676
|
-
computedUntil: string |
|
677
|
-
processingStarted: string |
|
681
|
+
computedUntil: string | number;
|
682
|
+
processingStarted: string | number;
|
678
683
|
} | undefined;
|
679
684
|
distributionChain?: {
|
680
685
|
name: string;
|
@@ -690,8 +695,8 @@ declare const app: Elysia<"", false, {
|
|
690
695
|
id: number;
|
691
696
|
icon: string;
|
692
697
|
};
|
693
|
-
startTimestamp: string |
|
694
|
-
endTimestamp: string |
|
698
|
+
startTimestamp: string | number;
|
699
|
+
endTimestamp: string | number;
|
695
700
|
computeChainId: number;
|
696
701
|
distributionChainId: number;
|
697
702
|
campaignId: string;
|
@@ -825,13 +830,18 @@ declare const app: Elysia<"", false, {
|
|
825
830
|
apr: number;
|
826
831
|
dailyRewards: number;
|
827
832
|
campaigns: {
|
833
|
+
creator?: {
|
834
|
+
tags?: string[] | undefined;
|
835
|
+
creatorId?: string | null | undefined;
|
836
|
+
address: string;
|
837
|
+
} | undefined;
|
828
838
|
campaignStatus?: {
|
829
839
|
error?: string | undefined;
|
830
840
|
details?: any;
|
831
841
|
status: string;
|
832
842
|
campaignId: string;
|
833
|
-
computedUntil: string |
|
834
|
-
processingStarted: string |
|
843
|
+
computedUntil: string | number;
|
844
|
+
processingStarted: string | number;
|
835
845
|
} | undefined;
|
836
846
|
distributionChain?: {
|
837
847
|
name: string;
|
@@ -847,8 +857,8 @@ declare const app: Elysia<"", false, {
|
|
847
857
|
id: number;
|
848
858
|
icon: string;
|
849
859
|
};
|
850
|
-
startTimestamp: string |
|
851
|
-
endTimestamp: string |
|
860
|
+
startTimestamp: string | number;
|
861
|
+
endTimestamp: string | number;
|
852
862
|
computeChainId: number;
|
853
863
|
distributionChainId: number;
|
854
864
|
campaignId: string;
|
@@ -1167,6 +1177,8 @@ declare const app: Elysia<"", false, {
|
|
1167
1177
|
id: number;
|
1168
1178
|
icon: string;
|
1169
1179
|
};
|
1180
|
+
endTimestamp: number;
|
1181
|
+
startTimestamp: number;
|
1170
1182
|
rewardToken: {
|
1171
1183
|
symbol: string;
|
1172
1184
|
name: string | null;
|
@@ -1186,15 +1198,15 @@ declare const app: Elysia<"", false, {
|
|
1186
1198
|
icon: string;
|
1187
1199
|
} | undefined;
|
1188
1200
|
campaignStatus: {
|
1201
|
+
computedUntil: number;
|
1202
|
+
processingStarted: number;
|
1189
1203
|
error: string;
|
1190
1204
|
details: import("database/api/.generated/runtime/library").JsonValue;
|
1191
1205
|
status: import("../database/api/.generated").$Enums.RunStatus;
|
1192
1206
|
campaignId: string;
|
1193
|
-
computedUntil: bigint;
|
1194
|
-
processingStarted: bigint;
|
1195
1207
|
};
|
1196
1208
|
creatorAddress: string;
|
1197
|
-
|
1209
|
+
creator: {
|
1198
1210
|
tags: string[];
|
1199
1211
|
address: string;
|
1200
1212
|
creatorId: string | null;
|
@@ -1202,8 +1214,6 @@ declare const app: Elysia<"", false, {
|
|
1202
1214
|
type: string;
|
1203
1215
|
id: string;
|
1204
1216
|
subType: number | null;
|
1205
|
-
startTimestamp: bigint;
|
1206
|
-
endTimestamp: bigint;
|
1207
1217
|
computeChainId: number;
|
1208
1218
|
distributionChainId: number;
|
1209
1219
|
campaignId: string;
|
@@ -1231,6 +1241,8 @@ declare const app: Elysia<"", false, {
|
|
1231
1241
|
id: number;
|
1232
1242
|
icon: string;
|
1233
1243
|
};
|
1244
|
+
endTimestamp: number;
|
1245
|
+
startTimestamp: number;
|
1234
1246
|
rewardToken: {
|
1235
1247
|
symbol: string;
|
1236
1248
|
name: string | null;
|
@@ -1250,15 +1262,15 @@ declare const app: Elysia<"", false, {
|
|
1250
1262
|
icon: string;
|
1251
1263
|
} | undefined;
|
1252
1264
|
campaignStatus: {
|
1265
|
+
computedUntil: number;
|
1266
|
+
processingStarted: number;
|
1253
1267
|
error: string;
|
1254
1268
|
details: import("database/api/.generated/runtime/library").JsonValue;
|
1255
1269
|
status: import("../database/api/.generated").$Enums.RunStatus;
|
1256
1270
|
campaignId: string;
|
1257
|
-
computedUntil: bigint;
|
1258
|
-
processingStarted: bigint;
|
1259
1271
|
};
|
1260
1272
|
creatorAddress: string;
|
1261
|
-
|
1273
|
+
creator: {
|
1262
1274
|
tags: string[];
|
1263
1275
|
address: string;
|
1264
1276
|
creatorId: string | null;
|
@@ -1266,8 +1278,6 @@ declare const app: Elysia<"", false, {
|
|
1266
1278
|
type: string;
|
1267
1279
|
id: string;
|
1268
1280
|
subType: number | null;
|
1269
|
-
startTimestamp: bigint;
|
1270
|
-
endTimestamp: bigint;
|
1271
1281
|
computeChainId: number;
|
1272
1282
|
distributionChainId: number;
|
1273
1283
|
campaignId: string;
|
@@ -6,7 +6,8 @@ import { OpportunityRepository } from "../../modules/v4/opportunity/opportunity.
|
|
6
6
|
import { RewardService } from "../../modules/v4/reward";
|
7
7
|
import { TvlService } from "../../modules/v4/tvl";
|
8
8
|
import { executeSimple } from "../../utils/execute";
|
9
|
-
import {
|
9
|
+
import { log } from "../../utils/logger";
|
10
|
+
import { Campaign as CampaignEnum } from "@sdk";
|
10
11
|
import moment from "moment";
|
11
12
|
// ─── Required Env Variables ──────────────────────────────────────────────────
|
12
13
|
const chainId = Number(process.env.CHAIN_ID);
|
@@ -31,7 +32,7 @@ async function updateDynamicData(liveCampaigns, campaignType) {
|
|
31
32
|
for (const data of dynamicData) {
|
32
33
|
if (!!data) {
|
33
34
|
// Main Parameter OVERRIDING
|
34
|
-
if (data.campaignType ===
|
35
|
+
if (data.campaignType === CampaignEnum.SILO && data.campaignParameters.whitelist?.length === 1)
|
35
36
|
data.mainParameter = `${data.mainParameter}-${data.campaignParameters.whitelist[0]}`;
|
36
37
|
if (!oppMap[`${data.campaignType}_${data.mainParameter}`])
|
37
38
|
oppMap[`${data.campaignType}_${data.mainParameter}`] = {};
|
@@ -57,25 +58,9 @@ async function updateDynamicData(liveCampaigns, campaignType) {
|
|
57
58
|
}
|
58
59
|
}
|
59
60
|
// ─── Get And Transform Live Campaigns Into A Map ─────────────────────────────
|
60
|
-
const
|
61
|
-
const liveCampaigns = (await CampaignService.getLiveCampaigns({ computeChainId: chainId })).map(c => {
|
62
|
-
return {
|
63
|
-
amount: c.amount,
|
64
|
-
campaignId: c.campaignId,
|
65
|
-
mainParameter: c.Opportunity.identifier,
|
66
|
-
campaignParameters: c.params,
|
67
|
-
campaignSubType: c.subType,
|
68
|
-
campaignType: c.type,
|
69
|
-
chainId: c.distributionChainId,
|
70
|
-
computeChainId: c.computeChainId,
|
71
|
-
creator: c.creatorAddress,
|
72
|
-
endTimestamp: c.endTimestamp,
|
73
|
-
rewardToken: c.rewardTokenId,
|
74
|
-
startTimestamp: c.startTimestamp,
|
75
|
-
};
|
76
|
-
});
|
61
|
+
const buildMapByType = async (campaignsToUpdate) => {
|
77
62
|
const campaignTypeToCampaigns = new Map();
|
78
|
-
for (const campaign of
|
63
|
+
for (const campaign of campaignsToUpdate) {
|
79
64
|
const type = campaign.campaignType;
|
80
65
|
let campaigns = campaignTypeToCampaigns.get(campaign.campaignType);
|
81
66
|
if (!campaigns)
|
@@ -87,22 +72,43 @@ const getLiveCampaignsByType = async (chainId) => {
|
|
87
72
|
return campaignTypeToCampaigns;
|
88
73
|
};
|
89
74
|
// ─── Main function / entry point ─────────────────────────────────────────────
|
90
|
-
const
|
75
|
+
const updateCampaigns = async (campaignsToUpdate) => {
|
91
76
|
// 1. Get a map of campaigns by campaign type
|
92
|
-
const
|
77
|
+
const campaignTypeToCampaigns = await buildMapByType(campaignsToUpdate);
|
93
78
|
// 2. Call updateDynamicData with each entries of the map (process by campaign type)
|
94
|
-
for (const [
|
79
|
+
for (const [campaignType, campaigns] of campaignTypeToCampaigns.entries()) {
|
80
|
+
log.info(`updating dynamic data for ${campaigns.length} campaigns of type ${CampaignEnum[campaignType]}`);
|
95
81
|
try {
|
96
|
-
await updateDynamicData(campaigns,
|
82
|
+
await updateDynamicData(campaigns, campaignType);
|
97
83
|
}
|
98
84
|
catch (err) {
|
99
|
-
console.error(`Failed to update dynamic data for campaign type ${
|
85
|
+
console.error(`Failed to update dynamic data for campaign type ${CampaignEnum[campaignType]}`, err);
|
100
86
|
}
|
101
87
|
}
|
102
|
-
|
103
|
-
|
88
|
+
};
|
89
|
+
const main = async () => {
|
90
|
+
const liveCampaigns = (await CampaignService.getLiveCampaigns({ computeChainId: chainId })).map(c => {
|
91
|
+
return {
|
92
|
+
amount: c.amount,
|
93
|
+
campaignId: c.campaignId,
|
94
|
+
mainParameter: c.Opportunity.identifier,
|
95
|
+
campaignParameters: c.params,
|
96
|
+
campaignSubType: c.subType,
|
97
|
+
campaignType: CampaignEnum[c.type],
|
98
|
+
chainId: c.distributionChainId,
|
99
|
+
computeChainId: c.computeChainId,
|
100
|
+
creator: c.creatorAddress,
|
101
|
+
endTimestamp: Number(c.endTimestamp),
|
102
|
+
rewardToken: c.rewardTokenId,
|
103
|
+
startTimestamp: Number(c.startTimestamp),
|
104
|
+
index: 0,
|
105
|
+
};
|
106
|
+
});
|
107
|
+
await updateCampaigns(liveCampaigns);
|
108
|
+
// Update status of opportunities
|
109
|
+
// 1. Get current live opportunities
|
104
110
|
const liveOpportunities = await OpportunityService.findLiveWithCampaigns(chainId);
|
105
|
-
//
|
111
|
+
// 2. For each currently live opportunities, infer its updated status by looping through its campaigns
|
106
112
|
const now = moment().unix();
|
107
113
|
for (const opportunity of liveOpportunities) {
|
108
114
|
let status = "NONE";
|
@@ -117,16 +123,12 @@ const main = async () => {
|
|
117
123
|
}
|
118
124
|
await OpportunityService.updateStatus(opportunity.id, status);
|
119
125
|
}
|
120
|
-
//
|
121
|
-
const
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
}
|
127
|
-
}
|
128
|
-
// 5. Update the status of the liveCampaigns opportunities
|
129
|
-
await OpportunityService.updateMany(Array.from(opportunities), { status: "LIVE" });
|
126
|
+
// 3. Update the status of the opportunities associated to future campaigns
|
127
|
+
const futureOpportunityIds = (await CampaignService.getFutureCampaigns({ computeChainId: chainId })).map(c => c.Opportunity.id);
|
128
|
+
await OpportunityService.updateMany(futureOpportunityIds, { status: "SOON" });
|
129
|
+
// 4. Update the status of the opportunities associated to live campaigns
|
130
|
+
const liveOpportunityIds = (await CampaignService.getLiveCampaigns({ computeChainId: chainId })).map(c => c.Opportunity.id);
|
131
|
+
await OpportunityService.updateMany(liveOpportunityIds, { status: "LIVE" });
|
130
132
|
};
|
131
133
|
try {
|
132
134
|
await main();
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BN2Number, MorphoSubCampaignType, YEAR, } from "@sdk";
|
1
|
+
import { BN2Number, MetamorphoInterface, MorphoSubCampaignType, YEAR, } from "@sdk";
|
2
2
|
import { Pricer } from "../../../utils/pricer";
|
3
3
|
const axios = require("axios");
|
4
4
|
export async function MORPHODynamicData(chainId, campaigns) {
|
@@ -8,6 +8,15 @@ export async function MORPHODynamicData(chainId, campaigns) {
|
|
8
8
|
const headers = {
|
9
9
|
"content-type": "application/json",
|
10
10
|
};
|
11
|
+
for (const campaign of campaigns) {
|
12
|
+
if (campaign.subType === MorphoSubCampaignType.META) {
|
13
|
+
calls.push({
|
14
|
+
allowFailure: true,
|
15
|
+
callData: MetamorphoInterface.encodeFunctionData("totalAssets"),
|
16
|
+
target: campaign.campaignParameters.targetToken,
|
17
|
+
});
|
18
|
+
}
|
19
|
+
}
|
11
20
|
return {
|
12
21
|
cached: false,
|
13
22
|
call: {
|
@@ -23,36 +32,14 @@ export async function MORPHODynamicData(chainId, campaigns) {
|
|
23
32
|
})) ?? 0;
|
24
33
|
let tvl = 0;
|
25
34
|
let totalSupplyTargetToken = 0;
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
`,
|
38
|
-
variables: {
|
39
|
-
address: campaign.campaignParameters.targetToken,
|
40
|
-
chainId: campaign.computeChainId,
|
41
|
-
},
|
42
|
-
};
|
43
|
-
try {
|
44
|
-
const response = await axios({
|
45
|
-
url: endpoint,
|
46
|
-
method: "post",
|
47
|
-
headers: headers,
|
48
|
-
data: graphqlQueryVaults,
|
49
|
-
});
|
50
|
-
tvl = response.data.data.vaultByAddress.state.totalAssetsUsd;
|
51
|
-
totalSupplyTargetToken = response.data.data.vaultByAddress.state.totalAssets;
|
52
|
-
}
|
53
|
-
catch (e) {
|
54
|
-
console.log(e);
|
55
|
-
}
|
35
|
+
let index = 0;
|
36
|
+
if (campaign.subType === MorphoSubCampaignType.META) {
|
37
|
+
const totalAssets = BN2Number(MetamorphoInterface.decodeFunctionResult("totalAssets", result[index++])[0], campaign.campaignParameters.decimalsUnderlyingToken);
|
38
|
+
const priceAsset = (await pricer.get({
|
39
|
+
symbol: campaign.campaignParameters.symbolUnderlyingToken,
|
40
|
+
})) ?? 0;
|
41
|
+
tvl = priceAsset * totalAssets;
|
42
|
+
totalSupplyTargetToken = totalAssets;
|
56
43
|
}
|
57
44
|
if (campaign.campaignSubType === MorphoSubCampaignType.SUPPLY_BLUE ||
|
58
45
|
campaign.campaignSubType === MorphoSubCampaignType.BORROWING_BLUE ||
|
@@ -138,6 +138,8 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
138
138
|
id: number;
|
139
139
|
icon: string;
|
140
140
|
};
|
141
|
+
endTimestamp: number;
|
142
|
+
startTimestamp: number;
|
141
143
|
rewardToken: {
|
142
144
|
symbol: string;
|
143
145
|
name: string | null;
|
@@ -157,15 +159,15 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
157
159
|
icon: string;
|
158
160
|
} | undefined;
|
159
161
|
campaignStatus: {
|
162
|
+
computedUntil: number;
|
163
|
+
processingStarted: number;
|
160
164
|
error: string;
|
161
165
|
details: import("database/api/.generated/runtime/library").JsonValue;
|
162
166
|
status: import("../../../../database/api/.generated").$Enums.RunStatus;
|
163
167
|
campaignId: string;
|
164
|
-
computedUntil: bigint;
|
165
|
-
processingStarted: bigint;
|
166
168
|
};
|
167
169
|
creatorAddress: string;
|
168
|
-
|
170
|
+
creator: {
|
169
171
|
tags: string[];
|
170
172
|
address: string;
|
171
173
|
creatorId: string | null;
|
@@ -173,8 +175,6 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
173
175
|
type: string;
|
174
176
|
id: string;
|
175
177
|
subType: number | null;
|
176
|
-
startTimestamp: bigint;
|
177
|
-
endTimestamp: bigint;
|
178
178
|
computeChainId: number;
|
179
179
|
distributionChainId: number;
|
180
180
|
campaignId: string;
|
@@ -202,6 +202,8 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
202
202
|
id: number;
|
203
203
|
icon: string;
|
204
204
|
};
|
205
|
+
endTimestamp: number;
|
206
|
+
startTimestamp: number;
|
205
207
|
rewardToken: {
|
206
208
|
symbol: string;
|
207
209
|
name: string | null;
|
@@ -221,15 +223,15 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
221
223
|
icon: string;
|
222
224
|
} | undefined;
|
223
225
|
campaignStatus: {
|
226
|
+
computedUntil: number;
|
227
|
+
processingStarted: number;
|
224
228
|
error: string;
|
225
229
|
details: import("database/api/.generated/runtime/library").JsonValue;
|
226
230
|
status: import("../../../../database/api/.generated").$Enums.RunStatus;
|
227
231
|
campaignId: string;
|
228
|
-
computedUntil: bigint;
|
229
|
-
processingStarted: bigint;
|
230
232
|
};
|
231
233
|
creatorAddress: string;
|
232
|
-
|
234
|
+
creator: {
|
233
235
|
tags: string[];
|
234
236
|
address: string;
|
235
237
|
creatorId: string | null;
|
@@ -237,8 +239,6 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
237
239
|
type: string;
|
238
240
|
id: string;
|
239
241
|
subType: number | null;
|
240
|
-
startTimestamp: bigint;
|
241
|
-
endTimestamp: bigint;
|
242
242
|
computeChainId: number;
|
243
243
|
distributionChainId: number;
|
244
244
|
campaignId: string;
|
@@ -45,6 +45,7 @@ export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { t
|
|
45
45
|
return CampaignService.format(await CampaignService.findUniqueOrThrow({ distributionChain: +distributionChain, campaignId }));
|
46
46
|
}
|
47
47
|
catch (_err) {
|
48
|
+
console.log(_err);
|
48
49
|
throw new NotFoundError("Campaign not found.");
|
49
50
|
}
|
50
51
|
}, {
|
@@ -8,15 +8,22 @@ import { type Status } from "../status/status.model";
|
|
8
8
|
* @description Target description of rewards campaigns
|
9
9
|
* @see {@link Resource}
|
10
10
|
*/
|
11
|
-
export type Campaign = Resource<"Campaign", "opportunityId" | "rewardTokenId"
|
11
|
+
export type Campaign = Resource<"Campaign", "opportunityId" | "rewardTokenId", {
|
12
12
|
chain: Chain["model"];
|
13
13
|
rewardToken: Token["model"];
|
14
14
|
distributionChain?: Chain["model"];
|
15
15
|
campaignStatus?: Status["model"];
|
16
|
+
creator?: {
|
17
|
+
address: string;
|
18
|
+
tags?: string[];
|
19
|
+
creatorId: string | null;
|
20
|
+
};
|
21
|
+
endTimestamp: number;
|
22
|
+
startTimestamp: number;
|
16
23
|
}>;
|
17
|
-
export type CampaignWithParams<C extends CampaignEnum = CampaignEnum> = Campaign
|
24
|
+
export type CampaignWithParams<C extends CampaignEnum = CampaignEnum> = Campaign["model"] & {
|
18
25
|
params: CampaignParameters<C>["campaignParameters"];
|
19
|
-
}
|
26
|
+
};
|
20
27
|
export declare const CampaignUniqueDto: import("@sinclair/typebox").TObject<{
|
21
28
|
distributionChain: import("@sinclair/typebox").TNumber;
|
22
29
|
campaignId: import("@sinclair/typebox").TString;
|
@@ -31,9 +38,14 @@ export declare const CampaignResourceDto: import("@sinclair/typebox").TObject<{
|
|
31
38
|
rewardTokenId: import("@sinclair/typebox").TString;
|
32
39
|
amount: import("@sinclair/typebox").TString;
|
33
40
|
opportunityId: import("@sinclair/typebox").TString;
|
34
|
-
startTimestamp: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").
|
35
|
-
endTimestamp: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").
|
41
|
+
startTimestamp: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
|
42
|
+
endTimestamp: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
|
36
43
|
creatorAddress: import("@sinclair/typebox").TString;
|
44
|
+
creator: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
45
|
+
address: import("@sinclair/typebox").TString;
|
46
|
+
tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
47
|
+
creatorId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>>;
|
48
|
+
}>>;
|
37
49
|
params: import("@sinclair/typebox").TAny;
|
38
50
|
chain: import("@sinclair/typebox").TObject<{
|
39
51
|
id: import("@sinclair/typebox").TNumber;
|
@@ -59,8 +71,8 @@ export declare const CampaignResourceDto: import("@sinclair/typebox").TObject<{
|
|
59
71
|
}>>;
|
60
72
|
campaignStatus: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
61
73
|
campaignId: import("@sinclair/typebox").TString;
|
62
|
-
computedUntil: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").
|
63
|
-
processingStarted: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").
|
74
|
+
computedUntil: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
|
75
|
+
processingStarted: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
|
64
76
|
status: import("@sinclair/typebox").TString;
|
65
77
|
error: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
66
78
|
details: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TAny>;
|
@@ -17,9 +17,14 @@ export const CampaignResourceDto = t.Object({
|
|
17
17
|
rewardTokenId: t.String(),
|
18
18
|
amount: t.String(),
|
19
19
|
opportunityId: t.String(),
|
20
|
-
startTimestamp: t.Union([t.
|
21
|
-
endTimestamp: t.Union([t.
|
20
|
+
startTimestamp: t.Union([t.String(), t.Numeric()]),
|
21
|
+
endTimestamp: t.Union([t.String(), t.Numeric()]),
|
22
22
|
creatorAddress: t.String(),
|
23
|
+
creator: t.Optional(t.Object({
|
24
|
+
address: t.String(),
|
25
|
+
tags: t.Optional(t.Array(t.String())),
|
26
|
+
creatorId: t.Optional(t.Nullable(t.String())),
|
27
|
+
})),
|
23
28
|
params: t.Any(),
|
24
29
|
chain: ChainResourceDto,
|
25
30
|
rewardToken: TokenResourceDto,
|
@@ -71,8 +71,29 @@ export declare abstract class CampaignRepository {
|
|
71
71
|
* A campaign is considered past if the current timestamp is greater than the campaign's end timestamp.
|
72
72
|
*
|
73
73
|
* @returns A promise that resolves to an array of past campaigns.
|
74
|
+
*
|
75
|
+
* @dev Excludes test campaigns
|
74
76
|
*/
|
75
|
-
static getPastCampaigns(
|
77
|
+
static getPastCampaigns(query?: {
|
78
|
+
computeChainId?: number;
|
79
|
+
type?: string;
|
80
|
+
}): Promise<({
|
81
|
+
Opportunity: {
|
82
|
+
name: string;
|
83
|
+
type: string;
|
84
|
+
id: string;
|
85
|
+
status: import("../../../../database/api/.generated").$Enums.Status;
|
86
|
+
tags: string[];
|
87
|
+
identifier: string;
|
88
|
+
chainId: number;
|
89
|
+
action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
|
90
|
+
depositUrl: string | null;
|
91
|
+
mainProtocolId: string | null;
|
92
|
+
tvl: number;
|
93
|
+
apr: number;
|
94
|
+
dailyRewards: number;
|
95
|
+
};
|
96
|
+
} & {
|
76
97
|
type: string;
|
77
98
|
id: string;
|
78
99
|
params: Prisma.JsonValue;
|
@@ -86,12 +107,56 @@ export declare abstract class CampaignRepository {
|
|
86
107
|
amount: string;
|
87
108
|
opportunityId: string;
|
88
109
|
creatorAddress: string;
|
89
|
-
}[]>;
|
110
|
+
})[]>;
|
111
|
+
/**
|
112
|
+
* Retrieves all past campaigns from the database.
|
113
|
+
* A campaign is considered past if the current timestamp is greater than the campaign's end timestamp.
|
114
|
+
*
|
115
|
+
* @returns A promise that resolves to an array of past campaigns.
|
116
|
+
*
|
117
|
+
* @dev Excludes test campaigns
|
118
|
+
*/
|
119
|
+
static getFutureCampaigns(query?: {
|
120
|
+
computeChainId?: number;
|
121
|
+
type?: string;
|
122
|
+
}): Promise<({
|
123
|
+
Opportunity: {
|
124
|
+
name: string;
|
125
|
+
type: string;
|
126
|
+
id: string;
|
127
|
+
status: import("../../../../database/api/.generated").$Enums.Status;
|
128
|
+
tags: string[];
|
129
|
+
identifier: string;
|
130
|
+
chainId: number;
|
131
|
+
action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
|
132
|
+
depositUrl: string | null;
|
133
|
+
mainProtocolId: string | null;
|
134
|
+
tvl: number;
|
135
|
+
apr: number;
|
136
|
+
dailyRewards: number;
|
137
|
+
};
|
138
|
+
} & {
|
139
|
+
type: string;
|
140
|
+
id: string;
|
141
|
+
params: Prisma.JsonValue;
|
142
|
+
subType: number | null;
|
143
|
+
startTimestamp: bigint;
|
144
|
+
endTimestamp: bigint;
|
145
|
+
computeChainId: number;
|
146
|
+
distributionChainId: number;
|
147
|
+
campaignId: string;
|
148
|
+
rewardTokenId: string;
|
149
|
+
amount: string;
|
150
|
+
opportunityId: string;
|
151
|
+
creatorAddress: string;
|
152
|
+
})[]>;
|
90
153
|
/**
|
91
154
|
* Retrieves all live campaigns from the database.
|
92
155
|
* A campaign is considered live if the current timestamp is between the campaign's start and end timestamps.
|
93
156
|
*
|
94
157
|
* @returns A promise that resolves to an array of live campaigns.
|
158
|
+
*
|
159
|
+
* @dev Excludes test campaigns
|
95
160
|
*/
|
96
161
|
static getLiveCampaigns(query?: {
|
97
162
|
computeChainId?: number;
|