@merkl/api 0.17.34 → 0.17.36
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 +1 -1
- package/dist/src/backgroundJobs/jobs/opportunityUpdater.d.ts +0 -2
- package/dist/src/backgroundJobs/jobs/opportunityUpdater.js +2 -54
- package/dist/src/eden/index.d.ts +5 -5
- package/dist/src/factories/metadataFactory/factory.d.ts +3 -0
- package/dist/src/factories/metadataFactory/factory.js +56 -0
- package/dist/src/factories/metadataFactory/implementations/Ajna.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Ajna.js +52 -0
- package/dist/src/factories/metadataFactory/implementations/Ambiant.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Ambiant.js +31 -0
- package/dist/src/factories/metadataFactory/implementations/Badger.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Badger.js +25 -0
- package/dist/src/factories/metadataFactory/implementations/Clamm.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Clamm.js +50 -0
- package/dist/src/factories/metadataFactory/implementations/Compound.d.ts +16 -0
- package/dist/src/factories/metadataFactory/implementations/Compound.js +20 -0
- package/dist/src/factories/metadataFactory/implementations/Default.d.ts +13 -0
- package/dist/src/factories/metadataFactory/implementations/Default.js +11 -0
- package/dist/src/factories/metadataFactory/implementations/Dolomite.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Dolomite.js +17 -0
- package/dist/src/factories/metadataFactory/implementations/EigenLayer.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/EigenLayer.js +11 -0
- package/dist/src/factories/metadataFactory/implementations/Encompassing.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Encompassing.js +37 -0
- package/dist/src/factories/metadataFactory/implementations/Erc20.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Erc20.js +71 -0
- package/dist/src/factories/metadataFactory/implementations/Erc20Snapshot.d.ts +14 -0
- package/dist/src/factories/metadataFactory/implementations/Erc20Snapshot.js +10 -0
- package/dist/src/factories/metadataFactory/implementations/Euler.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Euler.js +34 -0
- package/dist/src/factories/metadataFactory/implementations/EventBased.d.ts +20 -0
- package/dist/src/factories/metadataFactory/implementations/EventBased.js +45 -0
- package/dist/src/factories/metadataFactory/implementations/Hyperdrive.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Hyperdrive.js +21 -0
- package/dist/src/factories/metadataFactory/implementations/Invalid.d.ts +11 -0
- package/dist/src/factories/metadataFactory/implementations/Invalid.js +10 -0
- package/dist/src/factories/metadataFactory/implementations/Ion.d.ts +16 -0
- package/dist/src/factories/metadataFactory/implementations/Ion.js +15 -0
- package/dist/src/factories/metadataFactory/implementations/JsonAirdrop.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/JsonAirdrop.js +38 -0
- package/dist/src/factories/metadataFactory/implementations/Morpho.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Morpho.js +21 -0
- package/dist/src/factories/metadataFactory/implementations/Radiant.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Radiant.js +11 -0
- package/dist/src/factories/metadataFactory/implementations/Silo.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Silo.js +15 -0
- package/dist/src/factories/metadataFactory/implementations/UniswapV4Metadata.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/UniswapV4Metadata.js +28 -0
- package/dist/src/factories/metadataFactory/implementations/Vest.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Vest.js +12 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +12 -12
- package/dist/src/modules/v4/dungeonKeeper/dungeonKeeper.controller.d.ts +2 -1
- package/dist/src/modules/v4/explorer/explorer.controller.js +1 -1
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +1 -1
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +0 -11
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +4 -4
- package/dist/src/modules/v4/opportunity/opportunity.service.js +10 -86
- package/dist/src/modules/v4/router.d.ts +1 -1
- package/dist/src/routes/v3/opportunity.js +2 -30
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/entities/opportunity.d.ts +0 -22
- package/dist/src/entities/opportunity.js +0 -1073
- package/dist/src/modules/v4/dungeonKeeper/index.d.ts +0 -2
- package/dist/src/modules/v4/dungeonKeeper/index.js +0 -2
- package/dist/src/modules/v4/explorer/index.d.ts +0 -1
- package/dist/src/modules/v4/explorer/index.js +0 -1
- package/dist/src/modules/v4/opportunity/subservices/getAjnaMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getAjnaMetadata.service.js +0 -50
- package/dist/src/modules/v4/opportunity/subservices/getAmbientMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getAmbientMetadata.service.js +0 -29
- package/dist/src/modules/v4/opportunity/subservices/getBadgerMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getBadgerMetadata.service.js +0 -23
- package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.js +0 -48
- package/dist/src/modules/v4/opportunity/subservices/getCompoundMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getCompoundMetadata.service.js +0 -18
- package/dist/src/modules/v4/opportunity/subservices/getDolomiteMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getDolomiteMetadata.service.js +0 -15
- package/dist/src/modules/v4/opportunity/subservices/getEigenLayerMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getEigenLayerMetadata.service.js +0 -9
- package/dist/src/modules/v4/opportunity/subservices/getEncompassingMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getEncompassingMetadata.service.js +0 -35
- package/dist/src/modules/v4/opportunity/subservices/getErc20Metadata.service.d.ts +0 -5
- package/dist/src/modules/v4/opportunity/subservices/getErc20Metadata.service.js +0 -69
- package/dist/src/modules/v4/opportunity/subservices/getErc20SnapshotMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getErc20SnapshotMetadata.service.js +0 -8
- package/dist/src/modules/v4/opportunity/subservices/getEulerMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getEulerMetadata.service.js +0 -34
- package/dist/src/modules/v4/opportunity/subservices/getEventBasedMetadata.service.ts.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getEventBasedMetadata.service.ts.js +0 -43
- package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.js +0 -19
- package/dist/src/modules/v4/opportunity/subservices/getIonMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getIonMetadata.service.js +0 -13
- package/dist/src/modules/v4/opportunity/subservices/getJsonAirDropMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getJsonAirDropMetadata.service.js +0 -36
- package/dist/src/modules/v4/opportunity/subservices/getMorphoMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getMorphoMetadata.service.js +0 -19
- package/dist/src/modules/v4/opportunity/subservices/getRadiantMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getRadiantMetadata.service.js +0 -9
- package/dist/src/modules/v4/opportunity/subservices/getSiloMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getSiloMetadata.service.js +0 -13
- package/dist/src/modules/v4/opportunity/subservices/getUniswapV4Metadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getUniswapV4Metadata.service.js +0 -26
- package/dist/src/modules/v4/opportunity/subservices/getVestMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getVestMetadata.service.js +0 -10
@@ -77,7 +77,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
77
77
|
identifier: string;
|
78
78
|
name: string;
|
79
79
|
status: "PAST" | "LIVE" | "SOON";
|
80
|
-
action:
|
80
|
+
action: any;
|
81
81
|
tokens: ({
|
82
82
|
symbol: string;
|
83
83
|
name: string | null;
|
@@ -5,7 +5,6 @@ import { type Protocol } from "../protocol/protocol.model";
|
|
5
5
|
import { type DailyRewardsRecord } from "../reward/reward.model";
|
6
6
|
import { type Token } from "../token/token.model";
|
7
7
|
import { type TvlRecord } from "../tvl/tvl.model";
|
8
|
-
import { OpportunityAction } from "../../../../database/api/.generated";
|
9
8
|
import type { ChainId } from "@sdk";
|
10
9
|
import { type Chain } from "../chain/chain.model";
|
11
10
|
import type { OpportunityRepository } from "./opportunity.repository";
|
@@ -25,16 +24,6 @@ export type Opportunity = Resource<"Opportunity", "mainProtocolId", {
|
|
25
24
|
campaigns?: Campaign["model"][];
|
26
25
|
}>;
|
27
26
|
export type LightOpportunityFromDB = Omit<Awaited<ReturnType<typeof OpportunityRepository.findUniqueOrThrow>>, "AprRecords" | "TvlRecords" | "DailyRewardsRecords" | "Campaigns">;
|
28
|
-
export type OpportunityMetadata = {
|
29
|
-
name: string;
|
30
|
-
action: OpportunityAction;
|
31
|
-
tokens: {
|
32
|
-
chainId: number;
|
33
|
-
address: string;
|
34
|
-
}[];
|
35
|
-
mainProtocol?: string;
|
36
|
-
tags?: string[];
|
37
|
-
};
|
38
27
|
export type OpportunityUnique = {
|
39
28
|
chainId: ChainId;
|
40
29
|
type: string;
|
@@ -33,7 +33,7 @@ export declare abstract class OpportunityService {
|
|
33
33
|
identifier: string;
|
34
34
|
name: string;
|
35
35
|
status: "SOON";
|
36
|
-
action:
|
36
|
+
action: OpportunityAction;
|
37
37
|
mainProtocol: string | undefined;
|
38
38
|
depositUrl: any;
|
39
39
|
tags: string[];
|
@@ -45,7 +45,7 @@ export declare abstract class OpportunityService {
|
|
45
45
|
identifier: string;
|
46
46
|
name: string;
|
47
47
|
status: "PAST" | "LIVE" | "SOON";
|
48
|
-
action:
|
48
|
+
action: OpportunityAction;
|
49
49
|
tokens: ({
|
50
50
|
symbol: string;
|
51
51
|
name: string | null;
|
@@ -86,7 +86,7 @@ export declare abstract class OpportunityService {
|
|
86
86
|
identifier: string;
|
87
87
|
name: string;
|
88
88
|
status: "PAST" | "LIVE" | "SOON";
|
89
|
-
action:
|
89
|
+
action: OpportunityAction;
|
90
90
|
tokens: {
|
91
91
|
price?: number | null | undefined;
|
92
92
|
symbol: string;
|
@@ -113,7 +113,7 @@ export declare abstract class OpportunityService {
|
|
113
113
|
identifier: string;
|
114
114
|
name: string;
|
115
115
|
status: "PAST" | "LIVE" | "SOON";
|
116
|
-
action:
|
116
|
+
action: OpportunityAction;
|
117
117
|
tokens: ({
|
118
118
|
symbol: string;
|
119
119
|
name: string | null;
|
@@ -6,30 +6,12 @@ import { CampaignRepository } from "../campaign/campaign.repository";
|
|
6
6
|
import { TokenService } from "../token/token.service";
|
7
7
|
import { UserService } from "../user/user.service";
|
8
8
|
import { log } from "../../../utils/logger";
|
9
|
-
import {
|
9
|
+
import { Prisma, Status } from "../../../../database/api/.generated";
|
10
10
|
import { record } from "@elysiajs/opentelemetry";
|
11
11
|
import { Campaign as CampaignEnum } from "@sdk";
|
12
12
|
import moment from "moment";
|
13
|
+
import { metadataBuilderFactory } from "../../../factories/metadataFactory/factory";
|
13
14
|
import { OpportunityRepository } from "./opportunity.repository";
|
14
|
-
import { getAjnaMetadata } from "./subservices/getAjnaMetadata.service";
|
15
|
-
import { getAmbientMetadata } from "./subservices/getAmbientMetadata.service";
|
16
|
-
import { getBadgerMetadata } from "./subservices/getBadgerMetadata.service";
|
17
|
-
import { getClammMetadata } from "./subservices/getClammMetadata.service";
|
18
|
-
import { getCompoundMetadata } from "./subservices/getCompoundMetadata.service";
|
19
|
-
import { getDolomiteMetadata } from "./subservices/getDolomiteMetadata.service";
|
20
|
-
import { getEigenLayerMetadata } from "./subservices/getEigenLayerMetadata.service";
|
21
|
-
import { getEncompassingMetadata } from "./subservices/getEncompassingMetadata.service";
|
22
|
-
import { getErc20Metadata } from "./subservices/getErc20Metadata.service";
|
23
|
-
import { getErc20SnapshotMetadata } from "./subservices/getErc20SnapshotMetadata.service";
|
24
|
-
import { getEulerMetadata } from "./subservices/getEulerMetadata.service";
|
25
|
-
import { getEventBasedMetadata } from "./subservices/getEventBasedMetadata.service.ts";
|
26
|
-
import { getHyperdriveMetadata } from "./subservices/getHyperdriveMetadata.service";
|
27
|
-
import { getJsonAirdropMetadata } from "./subservices/getJsonAirDropMetadata.service";
|
28
|
-
import { getMorphoMetadata } from "./subservices/getMorphoMetadata.service";
|
29
|
-
import { getRadiantMetadata } from "./subservices/getRadiantMetadata.service";
|
30
|
-
import { getSiloMetadata } from "./subservices/getSiloMetadata.service";
|
31
|
-
import { getUniswapV4Metadata } from "./subservices/getUniswapV4Metadata.service";
|
32
|
-
import { getVestMetadata } from "./subservices/getVestMetadata.service";
|
33
15
|
export class OpportunityService {
|
34
16
|
static hashId(opportunity) {
|
35
17
|
return Bun.hash(`${opportunity.chainId}${opportunity.type}${opportunity.identifier}`).toString();
|
@@ -46,76 +28,18 @@ export class OpportunityService {
|
|
46
28
|
/**
|
47
29
|
* build/fetch metadata of a campaign's opportunity
|
48
30
|
* @param campaign
|
49
|
-
* @returns {OpportunityMetadata}
|
50
31
|
*/
|
51
32
|
static async #getMetadata(campaign) {
|
52
|
-
const campaignType =
|
33
|
+
const campaignType = campaign.type;
|
53
34
|
const campaignParams = JSON.parse(campaign.params);
|
54
|
-
const
|
55
|
-
|
56
|
-
|
57
|
-
return getClammMetadata(chainId, campaignParams);
|
58
|
-
case "ERC20":
|
59
|
-
return getErc20Metadata(chainId, campaign.chainId, // distributionChainId
|
60
|
-
campaign.campaignId, campaign.rewardTokenAddress, campaign.amount, campaignParams);
|
61
|
-
case "ERC20LOGPROCESSOR":
|
62
|
-
return getErc20Metadata(chainId, campaign.chainId, // distributionChainId
|
63
|
-
campaign.campaignId, campaign.rewardTokenAddress, campaign.amount, campaignParams);
|
64
|
-
case "ERC20REBASELOGPROCESSOR":
|
65
|
-
return getErc20Metadata(chainId, campaign.chainId, // distributionChainId
|
66
|
-
campaign.campaignId, campaign.rewardTokenAddress, campaign.amount, campaignParams);
|
67
|
-
case "ERC20_SNAPSHOT":
|
68
|
-
return getErc20SnapshotMetadata(chainId, campaignParams);
|
69
|
-
case "ERC20_FIX_APR":
|
70
|
-
return getErc20Metadata(chainId, campaign.chainId, // distributionChainId
|
71
|
-
campaign.campaignId, campaign.rewardTokenAddress, campaign.amount, campaignParams);
|
72
|
-
case "JSON_AIRDROP":
|
73
|
-
return getJsonAirdropMetadata(chainId, campaign.creator, campaignParams);
|
74
|
-
case "SILO":
|
75
|
-
return getSiloMetadata(chainId, campaign.subType, campaignParams);
|
76
|
-
case "RADIANT":
|
77
|
-
return getRadiantMetadata(chainId, campaign.subType, campaignParams);
|
78
|
-
case "MORPHO":
|
79
|
-
return getMorphoMetadata(chainId, campaign.subType, campaignParams);
|
80
|
-
case "DOLOMITE":
|
81
|
-
return getDolomiteMetadata(chainId, campaign.subType, campaignParams);
|
82
|
-
case "BADGER":
|
83
|
-
return getBadgerMetadata(chainId, campaignParams);
|
84
|
-
case "COMPOUND":
|
85
|
-
return getCompoundMetadata(chainId, campaign.subType, campaignParams);
|
86
|
-
case "AJNA":
|
87
|
-
return getAjnaMetadata(chainId, campaign.subType, campaignParams);
|
88
|
-
case "EIGENLAYER":
|
89
|
-
return getEigenLayerMetadata(chainId, campaignParams);
|
90
|
-
case "VEST":
|
91
|
-
return getVestMetadata(chainId, campaignParams);
|
92
|
-
case "EULER":
|
93
|
-
return getEulerMetadata(chainId, campaign.campaignId, campaign.subType, campaign.rewardTokenAddress, campaign.amount, campaignParams);
|
94
|
-
case "HYPERDRIVELOGPROCESSOR":
|
95
|
-
case "HYPERDRIVELOGFIXPROCESSOR":
|
96
|
-
return getHyperdriveMetadata(chainId, campaign.subType, campaignParams);
|
97
|
-
case "AMBIENTPROCESSOR":
|
98
|
-
return getAmbientMetadata(chainId, campaignParams);
|
99
|
-
case "UNISWAP_V4":
|
100
|
-
return getUniswapV4Metadata(chainId, campaignParams);
|
101
|
-
case "ENCOMPASSING":
|
102
|
-
return getEncompassingMetadata(chainId, campaign.rewardTokenAddress, campaignParams);
|
103
|
-
case "EVENT_BASED":
|
104
|
-
return getEventBasedMetadata(chainId, campaign.computeChainId, campaign.campaignId, campaign.rewardTokenAddress, campaign.amount, campaignParams);
|
105
|
-
case "INVALID":
|
106
|
-
return {
|
107
|
-
name: "Invalid Campaigns",
|
108
|
-
action: OpportunityAction.INVALID,
|
109
|
-
tokens: [],
|
110
|
-
};
|
111
|
-
default:
|
112
|
-
throw "UNKNOWN CAMPAIGN TYPE";
|
113
|
-
}
|
35
|
+
const computeChainId = campaign.computeChainId === 0 ? campaign.chainId : campaign.computeChainId;
|
36
|
+
const distributionChainId = campaign.chainId;
|
37
|
+
return await metadataBuilderFactory(campaignType).getMetadata(computeChainId, campaignParams, campaign.subType, campaign.rewardTokenAddress, distributionChainId, campaign.campaignId, campaign.creator);
|
114
38
|
}
|
115
39
|
static async fakeCreateFromCampaign(campaign) {
|
116
40
|
const campaignType = CampaignService.getTypeFromV3(campaign.type);
|
117
41
|
const metadata = await OpportunityService.#getMetadata(campaign);
|
118
|
-
|
42
|
+
const tags = [...((await UserService.findUnique(campaign.creator))?.tags ?? []), ...(campaign?.tags ?? [])];
|
119
43
|
const opportunityId = OpportunityService.hashId({
|
120
44
|
chainId: campaign.computeChainId,
|
121
45
|
identifier: campaign.opportunityIdentifier,
|
@@ -132,14 +56,14 @@ export class OpportunityService {
|
|
132
56
|
action: metadata.action,
|
133
57
|
mainProtocol: metadata.mainProtocol,
|
134
58
|
depositUrl: !!params.url ? params.url : undefined,
|
135
|
-
tags
|
59
|
+
tags,
|
136
60
|
};
|
137
61
|
return opportunity;
|
138
62
|
}
|
139
63
|
static async createFromCampaign(campaign, upsert = false) {
|
140
64
|
const campaignType = CampaignService.getTypeFromV3(campaign.type);
|
141
65
|
const metadata = await OpportunityService.#getMetadata(campaign);
|
142
|
-
|
66
|
+
const tags = [...((await UserService.findUnique(campaign.creator))?.tags ?? []), ...(campaign?.tags ?? [])];
|
143
67
|
const opportunityId = OpportunityService.hashId({
|
144
68
|
chainId: campaign.computeChainId,
|
145
69
|
identifier: campaign.opportunityIdentifier,
|
@@ -163,7 +87,7 @@ export class OpportunityService {
|
|
163
87
|
tokens,
|
164
88
|
mainProtocol: metadata.mainProtocol,
|
165
89
|
depositUrl: !!params.url ? params.url : undefined,
|
166
|
-
tags
|
90
|
+
tags,
|
167
91
|
};
|
168
92
|
await OpportunityRepository.create(opportunity, upsert);
|
169
93
|
return opportunity;
|
@@ -92,7 +92,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
92
92
|
identifier: string;
|
93
93
|
name: string;
|
94
94
|
status: "PAST" | "LIVE" | "SOON";
|
95
|
-
action:
|
95
|
+
action: any;
|
96
96
|
tokens: ({
|
97
97
|
symbol: string;
|
98
98
|
name: string | null;
|
@@ -1,7 +1,5 @@
|
|
1
|
-
import { Redis } from "../../cache";
|
2
1
|
import { OpportunityConvertorService } from "../../modules/v4/opportunity/opportunity.converter";
|
3
2
|
import { t } from "elysia";
|
4
|
-
import { fillCampaigns } from "../../entities/opportunity";
|
5
3
|
import param from "../../types/parameters";
|
6
4
|
export const query = t.Object({
|
7
5
|
campaigns: t.Optional(t.Boolean()),
|
@@ -14,34 +12,8 @@ export const query = t.Object({
|
|
14
12
|
});
|
15
13
|
export default (app) => {
|
16
14
|
return app.get("/opportunity", async ({ query: { campaigns: showCampaigns, ...filters } }) => {
|
17
|
-
|
18
|
-
|
19
|
-
return await OpportunityConvertorService.wrapV3Opportunities(showCampaigns ?? false, !!filters.testTokens ? filters.testTokens : undefined, !!filters.mainParameter ? filters.mainParameter : undefined, !!filters.chainId ? filters.chainId.toString() : undefined);
|
20
|
-
}
|
21
|
-
const opportunities = await Redis.get(filters?.testTokens ? "OpportunitiesWithTest" : "Opportunities");
|
22
|
-
const returnedOpportunities = {};
|
23
|
-
const corresponds = (opp) => {
|
24
|
-
if (filters.type !== undefined && filters.type !== opp.campaigns.type)
|
25
|
-
return false;
|
26
|
-
if (filters.action !== undefined && filters.action !== opp.action)
|
27
|
-
return false;
|
28
|
-
if (filters.chainId !== undefined && filters.chainId !== opp.chainId)
|
29
|
-
return false;
|
30
|
-
if (filters.mainParameter !== undefined &&
|
31
|
-
filters.mainParameter?.toLowerCase() !== opp.id.split("_")?.[1]?.toLowerCase())
|
32
|
-
return false;
|
33
|
-
if (filters.tag !== undefined && !opp.tags?.includes(filters.tag))
|
34
|
-
return false;
|
35
|
-
return true;
|
36
|
-
};
|
37
|
-
for (const [id, opportunity] of Object.entries(opportunities)) {
|
38
|
-
if (!corresponds(opportunity))
|
39
|
-
continue;
|
40
|
-
returnedOpportunities[id] = opportunity;
|
41
|
-
}
|
42
|
-
if (!showCampaigns)
|
43
|
-
return returnedOpportunities;
|
44
|
-
return await fillCampaigns(returnedOpportunities, !showCampaigns, filters.testTokens);
|
15
|
+
await OpportunityConvertorService.logKeyAndTTLV3Opportunities(showCampaigns ?? false, !!filters.testTokens ? filters.testTokens : false, !!filters.mainParameter ? filters.mainParameter : undefined, !!filters.chainId ? filters.chainId.toString() : undefined);
|
16
|
+
return await OpportunityConvertorService.wrapV3Opportunities(showCampaigns ?? false, !!filters.testTokens ? filters.testTokens : false, !!filters.mainParameter ? filters.mainParameter : undefined, !!filters.chainId ? filters.chainId.toString() : undefined);
|
45
17
|
}, {
|
46
18
|
transform({ query }) {
|
47
19
|
query.chainId = !query.chainId ? undefined : Number.parseInt(query.chainId.toString());
|