@merkl/api 0.16.33 → 0.16.35
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 +0 -4
- package/dist/src/backgroundJobs/jobs/opportunityUpdater.js +3 -0
- package/dist/src/eden/index.d.ts +659 -446
- package/dist/src/entities/opportunity.d.ts +3 -1
- package/dist/src/index.d.ts +137 -118
- package/dist/src/jobs/etl/prices.js +9 -2
- package/dist/src/libs/deprecated-merklv3/index.js +1 -1
- package/dist/src/modules/v4/boost/boost.controller.js +1 -1
- package/dist/src/modules/v4/cache/cache.repository.d.ts +1 -0
- package/dist/src/modules/v4/cache/cache.repository.js +19 -0
- package/dist/src/modules/v4/campaign/campaign.service.d.ts +0 -5
- package/dist/src/modules/v4/campaign/campaign.service.js +0 -5
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +120 -57
- package/dist/src/modules/v4/opportunity/opportunity.controller.js +1 -1
- package/dist/src/modules/v4/opportunity/opportunity.converter.d.ts +9 -0
- package/dist/src/modules/v4/opportunity/opportunity.converter.js +153 -0
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +3 -1
- package/dist/src/modules/v4/opportunity/opportunity.model.js +2 -0
- package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +18 -210
- package/dist/src/modules/v4/opportunity/opportunity.repository.js +76 -113
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +219 -64
- package/dist/src/modules/v4/opportunity/opportunity.service.js +19 -21
- package/dist/src/modules/v4/reward/{subservices/converter.d.ts → reward.converter.d.ts} +3 -3
- package/dist/src/modules/v4/reward/{subservices/converter.js → reward.converter.js} +1 -1
- package/dist/src/modules/v4/router.d.ts +121 -58
- package/dist/src/modules/v4/status/status.controller.d.ts +1 -1
- package/dist/src/modules/v4/status/status.service.d.ts +1 -1
- package/dist/src/modules/v4/status/status.service.js +6 -4
- package/dist/src/routes/v3/app.js +1 -0
- package/dist/src/routes/v3/blacklist.js +1 -0
- package/dist/src/routes/v3/campaign/delay.js +1 -0
- package/dist/src/routes/v3/campaignClaims.d.ts +3 -1
- package/dist/src/routes/v3/campaignClaims.js +4 -13
- package/dist/src/routes/v3/campaignUnclaimed.js +1 -0
- package/dist/src/routes/v3/campaignsForMainParameter.d.ts +9 -1
- package/dist/src/routes/v3/campaignsForMainParameter.js +17 -7
- package/dist/src/routes/v3/campaignsRewardsReport.js +1 -0
- package/dist/src/routes/v3/claims.d.ts +3 -1
- package/dist/src/routes/v3/claims.js +4 -33
- package/dist/src/routes/v3/opportunity.d.ts +7 -7
- package/dist/src/routes/v3/opportunity.js +12 -13
- package/dist/src/routes/v3/recipients.js +1 -0
- package/dist/src/routes/v3/rewards.js +2 -1
- package/dist/src/routes/v3/rewardsReport.js +1 -0
- package/dist/src/routes/v3/router.d.ts +16 -60
- package/dist/src/routes/v3/router.js +0 -6
- package/dist/src/routes/v3/userRewards.js +2 -1
- package/dist/src/types/returnTypes.d.ts +0 -8
- package/dist/src/utils/camelToKebabCase.d.ts +2 -0
- package/dist/src/utils/camelToKebabCase.js +9 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/backgroundJobs/jobs/priceUpdater.d.ts +0 -37
- package/dist/src/backgroundJobs/jobs/priceUpdater.js +0 -21
- package/dist/src/backgroundJobs/jobs/sync.d.ts +0 -40
- package/dist/src/backgroundJobs/jobs/sync.js +0 -33
- package/dist/src/routes/v3/campaignReport.d.ts +0 -43
- package/dist/src/routes/v3/campaignReport.js +0 -22
- package/dist/src/routes/v3/campaignsInfo.d.ts +0 -41
- package/dist/src/routes/v3/campaignsInfo.js +0 -54
- package/dist/src/routes/v3/exports/campaigns.d.ts +0 -43
- package/dist/src/routes/v3/exports/campaigns.js +0 -28
- package/dist/src/routes/v3/tokenUnclaimed.d.ts +0 -44
- package/dist/src/routes/v3/tokenUnclaimed.js +0 -24
- package/dist/src/utils/queries/campaignsForMainParameter.d.ts +0 -2
- package/dist/src/utils/queries/campaignsForMainParameter.js +0 -23
- package/dist/src/utils/queries/claimsOverTime.d.ts +0 -8
- package/dist/src/utils/queries/claimsOverTime.js +0 -111
- package/dist/src/utils/queries/endingCampaigns.d.ts +0 -10
- package/dist/src/utils/queries/endingCampaigns.js +0 -21
- package/dist/src/utils/queries/futureCampaigns.d.ts +0 -3
- package/dist/src/utils/queries/futureCampaigns.js +0 -19
- package/dist/src/utils/queries/mainParameterCampaigns.d.ts +0 -5
- package/dist/src/utils/queries/mainParameterCampaigns.js +0 -11
- package/dist/src/utils/queries/rewardsAmount.d.ts +0 -10
- package/dist/src/utils/queries/rewardsAmount.js +0 -106
- package/dist/src/utils/queries/unclaimed.d.ts +0 -11
- package/dist/src/utils/queries/unclaimed.js +0 -81
@@ -113,11 +113,13 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
113
113
|
status?: string | undefined;
|
114
114
|
items?: number | undefined;
|
115
115
|
tags?: string | undefined;
|
116
|
+
identifier?: string | undefined;
|
116
117
|
page?: number | undefined;
|
117
118
|
chainId?: string | undefined;
|
118
119
|
action?: string | undefined;
|
119
120
|
creatorAddress?: string | undefined;
|
120
121
|
mainProtocolId?: string | undefined;
|
122
|
+
campaigns?: boolean | undefined;
|
121
123
|
order?: string | undefined;
|
122
124
|
test?: boolean | undefined;
|
123
125
|
minimumTvl?: number | undefined;
|
@@ -174,6 +176,57 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
174
176
|
amount: bigint;
|
175
177
|
}[];
|
176
178
|
};
|
179
|
+
campaigns: {
|
180
|
+
params: any;
|
181
|
+
chain: {
|
182
|
+
name: string;
|
183
|
+
id: number;
|
184
|
+
icon: string;
|
185
|
+
};
|
186
|
+
rewardToken: {
|
187
|
+
symbol: string;
|
188
|
+
name: string | null;
|
189
|
+
id: string;
|
190
|
+
icon: string;
|
191
|
+
chainId: number;
|
192
|
+
address: string;
|
193
|
+
decimals: number;
|
194
|
+
verified: boolean;
|
195
|
+
isTest: boolean;
|
196
|
+
} & {
|
197
|
+
price?: number | null | undefined;
|
198
|
+
};
|
199
|
+
distributionChain: {
|
200
|
+
name: string;
|
201
|
+
id: number;
|
202
|
+
icon: string;
|
203
|
+
} | undefined;
|
204
|
+
campaignStatus: {
|
205
|
+
error: string;
|
206
|
+
details: import("database/api/.generated/runtime/library").JsonValue;
|
207
|
+
status: import("../../../../database/api/.generated").$Enums.RunStatus;
|
208
|
+
campaignId: string;
|
209
|
+
computedUntil: bigint;
|
210
|
+
processingStarted: bigint;
|
211
|
+
};
|
212
|
+
creatorAddress: string;
|
213
|
+
Creator: {
|
214
|
+
tags: string[];
|
215
|
+
address: string;
|
216
|
+
creatorId: string | null;
|
217
|
+
};
|
218
|
+
type: string;
|
219
|
+
id: string;
|
220
|
+
subType: number | null;
|
221
|
+
startTimestamp: bigint;
|
222
|
+
endTimestamp: bigint;
|
223
|
+
computeChainId: number;
|
224
|
+
distributionChainId: number;
|
225
|
+
campaignId: string;
|
226
|
+
rewardTokenId: string;
|
227
|
+
amount: string;
|
228
|
+
opportunityId: string;
|
229
|
+
}[];
|
177
230
|
id: string;
|
178
231
|
depositUrl: string | undefined;
|
179
232
|
tokens: ({
|
@@ -230,11 +283,13 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
230
283
|
status?: string | undefined;
|
231
284
|
items?: number | undefined;
|
232
285
|
tags?: string | undefined;
|
286
|
+
identifier?: string | undefined;
|
233
287
|
page?: number | undefined;
|
234
288
|
chainId?: string | undefined;
|
235
289
|
action?: string | undefined;
|
236
290
|
creatorAddress?: string | undefined;
|
237
291
|
mainProtocolId?: string | undefined;
|
292
|
+
campaigns?: boolean | undefined;
|
238
293
|
order?: string | undefined;
|
239
294
|
test?: boolean | undefined;
|
240
295
|
minimumTvl?: number | undefined;
|
@@ -383,45 +438,41 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
383
438
|
};
|
384
439
|
headers: unknown;
|
385
440
|
response: {
|
386
|
-
200:
|
387
|
-
|
388
|
-
|
389
|
-
url: string;
|
390
|
-
description: string;
|
391
|
-
id: string;
|
392
|
-
tags: string[];
|
393
|
-
icon: string;
|
394
|
-
} | null | undefined;
|
395
|
-
depositUrl?: string | undefined;
|
396
|
-
aprRecord?: {
|
397
|
-
timestamp: string | bigint;
|
441
|
+
200: {
|
442
|
+
apr: number;
|
443
|
+
aprRecord: {
|
398
444
|
cumulated: number;
|
445
|
+
timestamp: bigint;
|
399
446
|
breakdowns: {
|
400
|
-
type: "
|
447
|
+
type: import("../../../../database/api/.generated").$Enums.AprType;
|
401
448
|
id: number;
|
402
449
|
identifier: string;
|
403
450
|
value: number;
|
404
451
|
aprRecordId: string;
|
405
452
|
}[];
|
406
|
-
}
|
407
|
-
tvlRecord
|
453
|
+
};
|
454
|
+
tvlRecord: {
|
455
|
+
id: string;
|
408
456
|
total: number;
|
409
|
-
timestamp:
|
457
|
+
timestamp: bigint;
|
410
458
|
breakdowns: {
|
411
|
-
type: "
|
459
|
+
type: import("../../../../database/api/.generated").$Enums.TvlType;
|
412
460
|
id: number;
|
413
461
|
identifier: string;
|
414
462
|
value: number;
|
415
463
|
tvlRecordId: string;
|
416
464
|
}[];
|
417
|
-
}
|
418
|
-
rewardsRecord
|
419
|
-
total: number;
|
465
|
+
};
|
466
|
+
rewardsRecord: {
|
420
467
|
id: string;
|
421
|
-
|
468
|
+
total: number;
|
469
|
+
timestamp: bigint;
|
422
470
|
breakdowns: {
|
471
|
+
id: number;
|
472
|
+
value: number;
|
473
|
+
campaignId: string;
|
474
|
+
dailyRewardsRecordId: string;
|
423
475
|
token: {
|
424
|
-
price?: number | null | undefined;
|
425
476
|
symbol: string;
|
426
477
|
name: string | null;
|
427
478
|
id: string;
|
@@ -429,45 +480,14 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
429
480
|
chainId: number;
|
430
481
|
address: string;
|
431
482
|
decimals: number;
|
483
|
+
displaySymbol: string;
|
432
484
|
verified: boolean;
|
433
485
|
isTest: boolean;
|
486
|
+
price: number | null;
|
434
487
|
};
|
435
|
-
|
436
|
-
value: number;
|
437
|
-
campaignId: string;
|
438
|
-
amount: string | bigint;
|
439
|
-
dailyRewardsRecordId: string;
|
488
|
+
amount: bigint;
|
440
489
|
}[];
|
441
|
-
} | undefined;
|
442
|
-
name: string;
|
443
|
-
type: string;
|
444
|
-
tokens: {
|
445
|
-
price?: number | null | undefined;
|
446
|
-
symbol: string;
|
447
|
-
name: string | null;
|
448
|
-
id: string;
|
449
|
-
icon: string;
|
450
|
-
chainId: number;
|
451
|
-
address: string;
|
452
|
-
decimals: number;
|
453
|
-
verified: boolean;
|
454
|
-
isTest: boolean;
|
455
|
-
}[];
|
456
|
-
id: string;
|
457
|
-
status: string;
|
458
|
-
tags: string[];
|
459
|
-
identifier: string;
|
460
|
-
chain: {
|
461
|
-
name: string;
|
462
|
-
id: number;
|
463
|
-
icon: string;
|
464
490
|
};
|
465
|
-
chainId: number;
|
466
|
-
action: string;
|
467
|
-
tvl: number;
|
468
|
-
apr: number;
|
469
|
-
dailyRewards: number;
|
470
|
-
} & {
|
471
491
|
campaigns: {
|
472
492
|
params: any;
|
473
493
|
chain: {
|
@@ -519,7 +539,44 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
519
539
|
amount: string;
|
520
540
|
opportunityId: string;
|
521
541
|
}[];
|
522
|
-
|
542
|
+
id: string;
|
543
|
+
depositUrl: string | undefined;
|
544
|
+
tokens: ({
|
545
|
+
symbol: string;
|
546
|
+
name: string | null;
|
547
|
+
id: string;
|
548
|
+
icon: string;
|
549
|
+
chainId: number;
|
550
|
+
address: string;
|
551
|
+
decimals: number;
|
552
|
+
verified: boolean;
|
553
|
+
isTest: boolean;
|
554
|
+
} & {
|
555
|
+
price?: number | null | undefined;
|
556
|
+
})[];
|
557
|
+
chain: {
|
558
|
+
name: string;
|
559
|
+
id: number;
|
560
|
+
icon: string;
|
561
|
+
};
|
562
|
+
protocol: {
|
563
|
+
name: string;
|
564
|
+
url: string;
|
565
|
+
description: string;
|
566
|
+
id: string;
|
567
|
+
tags: string[];
|
568
|
+
icon: string;
|
569
|
+
} | undefined;
|
570
|
+
name: string;
|
571
|
+
type: string;
|
572
|
+
status: import("../../../../database/api/.generated").$Enums.Status;
|
573
|
+
tags: string[];
|
574
|
+
identifier: string;
|
575
|
+
chainId: number;
|
576
|
+
action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
|
577
|
+
tvl: number;
|
578
|
+
dailyRewards: number;
|
579
|
+
}[];
|
523
580
|
readonly 404: {
|
524
581
|
message: string;
|
525
582
|
name: string;
|
@@ -708,11 +765,13 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
708
765
|
status?: string | undefined;
|
709
766
|
items?: number | undefined;
|
710
767
|
tags?: string | undefined;
|
768
|
+
identifier?: string | undefined;
|
711
769
|
page?: number | undefined;
|
712
770
|
chainId?: string | undefined;
|
713
771
|
action?: string | undefined;
|
714
772
|
creatorAddress?: string | undefined;
|
715
773
|
mainProtocolId?: string | undefined;
|
774
|
+
campaigns?: boolean | undefined;
|
716
775
|
order?: string | undefined;
|
717
776
|
test?: boolean | undefined;
|
718
777
|
minimumTvl?: number | undefined;
|
@@ -745,11 +804,13 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
745
804
|
status?: string | undefined;
|
746
805
|
items?: number | undefined;
|
747
806
|
tags?: string | undefined;
|
807
|
+
identifier?: string | undefined;
|
748
808
|
page?: number | undefined;
|
749
809
|
chainId?: string | undefined;
|
750
810
|
action?: string | undefined;
|
751
811
|
creatorAddress?: string | undefined;
|
752
812
|
mainProtocolId?: string | undefined;
|
813
|
+
campaigns?: boolean | undefined;
|
753
814
|
order?: string | undefined;
|
754
815
|
test?: boolean | undefined;
|
755
816
|
minimumTvl?: number | undefined;
|
@@ -783,11 +844,13 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
783
844
|
status?: string | undefined;
|
784
845
|
items?: number | undefined;
|
785
846
|
tags?: string | undefined;
|
847
|
+
identifier?: string | undefined;
|
786
848
|
page?: number | undefined;
|
787
849
|
chainId?: string | undefined;
|
788
850
|
action?: string | undefined;
|
789
851
|
creatorAddress?: string | undefined;
|
790
852
|
mainProtocolId?: string | undefined;
|
853
|
+
campaigns?: boolean | undefined;
|
791
854
|
order?: string | undefined;
|
792
855
|
test?: boolean | undefined;
|
793
856
|
minimumTvl?: number | undefined;
|
@@ -89,7 +89,7 @@ export const OpportunityController = new Elysia({
|
|
89
89
|
detail: { description: "Get a unique opportunity." },
|
90
90
|
})
|
91
91
|
.get("/campaigns", async ({ query }) => {
|
92
|
-
return await OpportunityService.
|
92
|
+
return await OpportunityService.findManyByCampaigns(query);
|
93
93
|
}, {
|
94
94
|
query: GetCampaignQueryDto,
|
95
95
|
response: {
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { type CampaignParameters, type Opportunity as OpportunityV3, type ValidCampaign } from "@sdk";
|
2
|
+
import { OpportunityService } from "./opportunity.service";
|
3
|
+
export declare abstract class OpportunityConvertorService {
|
4
|
+
#private;
|
5
|
+
static convertV4CampaignToV3<C extends ValidCampaign>(campaignType: C, campaign: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]["campaigns"][number], opportunity: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]): CampaignParameters<C>;
|
6
|
+
static convertV4toV3(opportunity: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number], withCampaigns?: boolean): OpportunityV3;
|
7
|
+
static setV3Opportunities(showCampaigns: boolean, test: boolean | undefined, identifier: string | undefined, chainId: string | undefined): Promise<{}>;
|
8
|
+
static wrapV3Opportunities(showCampaigns: boolean, test: boolean | undefined, identifier: string | undefined, chainId: string | undefined): Promise<{}>;
|
9
|
+
}
|
@@ -0,0 +1,153 @@
|
|
1
|
+
import { kebabToPascalCase } from "../../../utils/camelToKebabCase";
|
2
|
+
import { Campaign as CampaignEnum, EAprBreakdownType, opportunityActions, } from "@sdk";
|
3
|
+
import moment from "moment";
|
4
|
+
import { CacheService } from "../cache";
|
5
|
+
import { TTLPresets } from "../cache/cache.model";
|
6
|
+
import { OpportunityService } from "./opportunity.service";
|
7
|
+
export class OpportunityConvertorService {
|
8
|
+
static convertV4CampaignToV3(campaignType, campaign, opportunity) {
|
9
|
+
return {
|
10
|
+
amount: campaign.amount.toString(),
|
11
|
+
campaignId: campaign.campaignId,
|
12
|
+
computeChainId: campaign.computeChainId,
|
13
|
+
campaignParameters: campaign.params,
|
14
|
+
campaignSubType: campaign.subType ?? 0,
|
15
|
+
campaignType,
|
16
|
+
chainId: campaign.distributionChain?.id ?? 0,
|
17
|
+
creator: campaign.Creator.address,
|
18
|
+
index: 0, // DEPRECATED
|
19
|
+
mainParameter: opportunity.identifier,
|
20
|
+
endTimestamp: Number(campaign.endTimestamp),
|
21
|
+
startTimestamp: Number(campaign.startTimestamp),
|
22
|
+
rewardToken: campaign.rewardToken.address,
|
23
|
+
};
|
24
|
+
}
|
25
|
+
static convertV4toV3(opportunity, withCampaigns = false) {
|
26
|
+
const now = moment().unix();
|
27
|
+
const id = `${CampaignEnum[opportunity.type]}_${opportunity.identifier}`; // V3 id
|
28
|
+
// Convert v4 actions to old type
|
29
|
+
let action = opportunity.action.toLowerCase();
|
30
|
+
if (!opportunityActions.includes(action)) {
|
31
|
+
action = "hold";
|
32
|
+
}
|
33
|
+
const tvlBreakdownTokens = [];
|
34
|
+
const tvlBreakdownDetails = {};
|
35
|
+
if (!!opportunity?.tvlRecord?.breakdowns) {
|
36
|
+
for (const breakdown of opportunity.tvlRecord.breakdowns) {
|
37
|
+
if (breakdown.type === "TOKEN") {
|
38
|
+
const token = opportunity.tokens.find(token => token.address === breakdown.identifier);
|
39
|
+
if (!!token)
|
40
|
+
tvlBreakdownTokens.push({
|
41
|
+
symbol: token?.symbol,
|
42
|
+
amount: breakdown.value,
|
43
|
+
});
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
tvlBreakdownDetails[breakdown.identifier] = {
|
47
|
+
value: breakdown.value,
|
48
|
+
address: breakdown.identifier.split(" ")[breakdown.identifier.split(" ").length - 1],
|
49
|
+
label: breakdown.identifier.split(" ")[0],
|
50
|
+
};
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
const aprBreakdown = {};
|
55
|
+
const aprBreakdown2 = [];
|
56
|
+
if (!!opportunity?.aprRecord?.breakdowns) {
|
57
|
+
for (const breakdown of opportunity.aprRecord.breakdowns) {
|
58
|
+
if (breakdown.type === "CAMPAIGN") {
|
59
|
+
aprBreakdown2.push({
|
60
|
+
value: breakdown.value,
|
61
|
+
label: `Campaign ${breakdown.identifier.slice(0, 8)}`,
|
62
|
+
type: EAprBreakdownType.CAMPAIGN,
|
63
|
+
address: breakdown.identifier,
|
64
|
+
});
|
65
|
+
}
|
66
|
+
else if (breakdown.type === "PROTOCOL") {
|
67
|
+
const address = breakdown.identifier.split(" ")[breakdown.identifier.split(" ").length - 1];
|
68
|
+
const detail = {
|
69
|
+
value: breakdown.value,
|
70
|
+
label: breakdown.identifier.replace(address, "").trim(),
|
71
|
+
type: EAprBreakdownType.FORWARDER,
|
72
|
+
address,
|
73
|
+
};
|
74
|
+
aprBreakdown[breakdown.identifier] = detail;
|
75
|
+
aprBreakdown2.push(detail);
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
console.log(breakdown);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return {
|
83
|
+
id,
|
84
|
+
chainId: opportunity.chainId,
|
85
|
+
name: opportunity.name,
|
86
|
+
status: opportunity.status.toLowerCase(),
|
87
|
+
action,
|
88
|
+
tokenIcons: opportunity.tokens.map(token => token.symbol),
|
89
|
+
tvl: opportunity?.tvlRecord?.total,
|
90
|
+
tvlBreakdown: tvlBreakdownTokens.length > 0 || Object.keys(tvlBreakdownDetails).length > 0
|
91
|
+
? {
|
92
|
+
tokens: tvlBreakdownTokens,
|
93
|
+
details: tvlBreakdownDetails,
|
94
|
+
}
|
95
|
+
: undefined,
|
96
|
+
platform: kebabToPascalCase(opportunity.protocol?.id ?? ""),
|
97
|
+
apr: opportunity.apr,
|
98
|
+
aprBreakdown: Object.keys(aprBreakdown).length > 0 ? aprBreakdown : undefined,
|
99
|
+
aprBreakdown2: aprBreakdown2.length > 0 ? aprBreakdown2 : undefined,
|
100
|
+
dailyrewards: opportunity.dailyRewards,
|
101
|
+
dailyRewardTokens: !!opportunity?.rewardsRecord?.breakdowns
|
102
|
+
? opportunity.rewardsRecord.breakdowns.map(reward => ({
|
103
|
+
symbol: reward.token.symbol,
|
104
|
+
amount: reward.amount.toString(),
|
105
|
+
address: reward.token.address,
|
106
|
+
}))
|
107
|
+
: undefined,
|
108
|
+
tags: opportunity.tags,
|
109
|
+
rewardTokenIcons: opportunity.campaigns
|
110
|
+
.map(campaign => campaign.rewardToken.symbol)
|
111
|
+
.reduce((acc, curr) => {
|
112
|
+
if (!acc.includes(curr))
|
113
|
+
acc.push(curr);
|
114
|
+
return acc;
|
115
|
+
}, []),
|
116
|
+
campaigns: {
|
117
|
+
type: CampaignEnum[opportunity.type],
|
118
|
+
ids: opportunity.campaigns.map(campaign => campaign.campaignId),
|
119
|
+
active: withCampaigns
|
120
|
+
? opportunity.campaigns
|
121
|
+
.filter(campaign => campaign.startTimestamp < BigInt(now) && BigInt(now) < campaign.endTimestamp)
|
122
|
+
.map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], campaign, opportunity))
|
123
|
+
: undefined,
|
124
|
+
inactive: withCampaigns
|
125
|
+
? opportunity.campaigns
|
126
|
+
.filter(campaign => !(campaign.startTimestamp < BigInt(now) && BigInt(now) < campaign.endTimestamp))
|
127
|
+
.map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], campaign, opportunity))
|
128
|
+
: undefined,
|
129
|
+
},
|
130
|
+
};
|
131
|
+
}
|
132
|
+
static async #extractV3Opportunities(showCampaigns, test, identifier, chainId) {
|
133
|
+
const opportunities = await OpportunityService.findMany({
|
134
|
+
items: 10_000, // HARDCODED LIMIT
|
135
|
+
test,
|
136
|
+
identifier,
|
137
|
+
chainId,
|
138
|
+
campaigns: true,
|
139
|
+
});
|
140
|
+
const res = {};
|
141
|
+
for (const opportunity of opportunities) {
|
142
|
+
const opportunityV3 = OpportunityConvertorService.convertV4toV3(opportunity, showCampaigns);
|
143
|
+
res[opportunityV3.id] = opportunityV3;
|
144
|
+
}
|
145
|
+
return res;
|
146
|
+
}
|
147
|
+
static async setV3Opportunities(showCampaigns, test, identifier, chainId) {
|
148
|
+
return await CacheService.set(TTLPresets.MIN_5, OpportunityConvertorService.#extractV3Opportunities, showCampaigns, test, identifier, chainId);
|
149
|
+
}
|
150
|
+
static async wrapV3Opportunities(showCampaigns, test, identifier, chainId) {
|
151
|
+
return await CacheService.wrap(TTLPresets.MIN_30, OpportunityConvertorService.#extractV3Opportunities, showCampaigns, test, identifier, chainId);
|
152
|
+
}
|
153
|
+
}
|
@@ -24,7 +24,7 @@ export type Opportunity = Resource<"Opportunity", "mainProtocolId", {
|
|
24
24
|
rewardsRecord?: DailyRewardsRecord["model"];
|
25
25
|
campaigns?: Campaign["model"][];
|
26
26
|
}>;
|
27
|
-
export type LightOpportunityFromDB = Omit<Awaited<ReturnType<typeof OpportunityRepository.findUniqueOrThrow>>, "AprRecords" | "TvlRecords" | "DailyRewardsRecords">;
|
27
|
+
export type LightOpportunityFromDB = Omit<Awaited<ReturnType<typeof OpportunityRepository.findUniqueOrThrow>>, "AprRecords" | "TvlRecords" | "DailyRewardsRecords" | "Campaigns">;
|
28
28
|
export type OpportunityMetadata = {
|
29
29
|
name: string;
|
30
30
|
action: OpportunityAction;
|
@@ -289,6 +289,8 @@ export declare const GetOpportunitiesQueryDto: import("@sinclair/typebox").TObje
|
|
289
289
|
test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
290
290
|
minimumTvl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
291
291
|
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRegExp>;
|
292
|
+
identifier: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
293
|
+
campaigns: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
292
294
|
tokens: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
293
295
|
sort: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRegExp>;
|
294
296
|
order: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRegExp>;
|
@@ -66,6 +66,8 @@ export const GetOpportunitiesQueryDto = t.Object({
|
|
66
66
|
status: t.Optional(t.RegExp(/^(LIVE|PAST|SOON)(,(LIVE|PAST|SOON)){0,2}$/, {
|
67
67
|
description: "A comma separeted list of status. Legal values are: `LIVE`, `PAST`, `SOON`",
|
68
68
|
})),
|
69
|
+
identifier: t.Optional(t.String({ description: "Filter by identifier" })),
|
70
|
+
campaigns: t.Optional(t.Boolean({ description: "Include campaign data. Will slow down the request. Default: false" })),
|
69
71
|
tokens: t.Optional(t.String({ description: "A comma separated list of token symbol. Use to filter by token" })),
|
70
72
|
sort: t.Optional(t.RegExp(/(apr|tvl|rewards)/, { description: "Sort by `apr`, `tvl` or `rewards`" })),
|
71
73
|
order: t.Optional(t.RegExp(/desc|asc/, {
|