@merkl/api 0.19.6 → 0.19.7
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 +70 -0
- package/dist/src/factories/opportunityMetadata/implementations/EventBased.d.ts +1 -1
- package/dist/src/factories/opportunityMetadata/implementations/EventBased.js +2 -2
- package/dist/src/index.d.ts +14 -0
- package/dist/src/libs/campaigns/campaignTypes/AjnaDynamicData.js +7 -7
- package/dist/src/libs/campaigns/campaignTypes/AmbientDynamicData.js +7 -5
- package/dist/src/libs/campaigns/campaignTypes/BadgerDynamicData.js +8 -5
- package/dist/src/libs/campaigns/campaignTypes/CLAMMDynamicData.js +7 -5
- package/dist/src/libs/campaigns/campaignTypes/CompoundDynamicData.js +8 -5
- package/dist/src/libs/campaigns/campaignTypes/DolomiteDynamicData.js +9 -6
- package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.js +9 -6
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.d.ts +2 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +2 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/implementations/BunniV2Processor.d.ts +45 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/implementations/BunniV2Processor.js +87 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/implementations/processorMapping.js +2 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1.js +2 -0
- package/dist/src/libs/campaigns/campaignTypes/EigenLayerDynamicData.js +9 -6
- package/dist/src/libs/campaigns/campaignTypes/EventBasedDynamicData.js +2 -1
- package/dist/src/libs/campaigns/campaignTypes/HyperdriveDynamicData.js +9 -6
- package/dist/src/libs/campaigns/campaignTypes/MORPHODynamicData.js +8 -5
- package/dist/src/libs/campaigns/campaignTypes/RadiantDynamicData.js +8 -5
- package/dist/src/libs/campaigns/campaignTypes/SILODynamicData.js +8 -5
- package/dist/src/libs/campaigns/campaignTypes/UniswapV4DynamicData.js +7 -5
- package/dist/src/libs/campaigns/campaignTypes/VestDynamicData.js +8 -5
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +5 -0
- package/dist/src/modules/v4/campaign/campaign.model.d.ts +1 -0
- package/dist/src/modules/v4/campaign/campaign.model.js +1 -0
- package/dist/src/modules/v4/campaign/campaign.repository.d.ts +4 -0
- package/dist/src/modules/v4/campaign/campaign.repository.js +2 -1
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +8 -0
- package/dist/src/modules/v4/opportunity/opportunity.converter.js +2 -2
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +2 -0
- package/dist/src/modules/v4/opportunity/opportunity.model.js +2 -0
- package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +1 -1
- package/dist/src/modules/v4/opportunity/opportunity.repository.js +14 -10
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +2 -2
- package/dist/src/modules/v4/opportunity/opportunity.service.js +4 -4
- package/dist/src/modules/v4/router.d.ts +14 -0
- package/dist/src/modules/v4/token/token.controller.d.ts +1 -0
- package/dist/src/modules/v4/token/token.model.d.ts +1 -0
- package/dist/src/modules/v4/token/token.model.js +1 -0
- package/dist/src/modules/v4/token/token.service.d.ts +3 -1
- package/dist/src/modules/v4/token/token.service.js +18 -0
- package/dist/src/utils/decodeCalls.js +7 -1
- package/dist/src/utils/encodeCalls.js +19 -1
- package/dist/src/utils/generateCardName.js +2 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +2 -2
@@ -1,4 +1,5 @@
|
|
1
1
|
import { BucketService } from "@/modules/v4/bucket/bucket.service";
|
2
|
+
import { TokenService } from "@/modules/v4/token/token.service";
|
2
3
|
import { engineDbClient } from "@db";
|
3
4
|
import { BN2Number, ChainInteractionService, EAprBreakdownType, NETWORK_LABELS, UniswapV4Addresses, UniswapV4StateViewInterface, getSqrtRatioAtTick, shortenAddress, } from "@sdk";
|
4
5
|
import moment from "moment";
|
@@ -150,11 +151,12 @@ export async function UniswapV4DynamicData(chainId, campaigns) {
|
|
150
151
|
const aprBreakdowns = [];
|
151
152
|
let priceRewardToken = 0;
|
152
153
|
if (isLive && c.campaignParameters.symbolRewardToken !== "aglaMerkl") {
|
153
|
-
priceRewardToken = (await pricer.get({
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
}));
|
154
|
+
// priceRewardToken = (await pricer.get({
|
155
|
+
// address: c.rewardToken,
|
156
|
+
// chainId: chainId,
|
157
|
+
// symbol: c.campaignParameters.symbolRewardToken,
|
158
|
+
// })) as number;
|
159
|
+
priceRewardToken = await TokenService.getRewardTokenPrice(campaign);
|
158
160
|
/**
|
159
161
|
* Handle whitelisted/blacklisted addresses to compute APR
|
160
162
|
*/
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { TokenService } from "@/modules/v4/token/token.service";
|
1
2
|
import { BN2Number, ERC20Interface, YEAR, } from "@sdk";
|
2
3
|
import { log } from "../../../utils/logger";
|
3
4
|
import { Pricer } from "../../../utils/pricer";
|
@@ -30,11 +31,13 @@ export async function VestDynamicData(_chainId, campaigns) {
|
|
30
31
|
log.warn(`Error getting totalSupply for campaign ${campaign.campaignId}`);
|
31
32
|
totalSupply = 0.0000001;
|
32
33
|
}
|
33
|
-
const priceRewardToken =
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
// const priceRewardToken =
|
35
|
+
// (await pricer.get({
|
36
|
+
// address: campaign.rewardToken,
|
37
|
+
// chainId: campaign.chainId,
|
38
|
+
// symbol: campaign.campaignParameters.symbolRewardToken,
|
39
|
+
// })) ?? 0;
|
40
|
+
const priceRewardToken = await TokenService.getRewardTokenPrice(campaign);
|
38
41
|
const priceTargetToken = (await pricer.get({
|
39
42
|
address: VEST_TOKEN,
|
40
43
|
chainId: campaign.computeChainId,
|
@@ -183,6 +183,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
183
183
|
chainId?: number | undefined;
|
184
184
|
creatorId?: string | undefined;
|
185
185
|
mainParameter?: string | undefined;
|
186
|
+
point?: boolean | undefined;
|
186
187
|
tokenAddress?: string | undefined;
|
187
188
|
test?: boolean | undefined;
|
188
189
|
createdAfter?: number | undefined;
|
@@ -369,6 +370,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
369
370
|
chainId?: number | undefined;
|
370
371
|
creatorId?: string | undefined;
|
371
372
|
mainParameter?: string | undefined;
|
373
|
+
point?: boolean | undefined;
|
372
374
|
tokenAddress?: string | undefined;
|
373
375
|
test?: boolean | undefined;
|
374
376
|
createdAfter?: number | undefined;
|
@@ -404,6 +406,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
404
406
|
chainId?: number | undefined;
|
405
407
|
creatorId?: string | undefined;
|
406
408
|
mainParameter?: string | undefined;
|
409
|
+
point?: boolean | undefined;
|
407
410
|
tokenAddress?: string | undefined;
|
408
411
|
test?: boolean | undefined;
|
409
412
|
createdAfter?: number | undefined;
|
@@ -442,6 +445,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
442
445
|
chainId?: number | undefined;
|
443
446
|
creatorId?: string | undefined;
|
444
447
|
mainParameter?: string | undefined;
|
448
|
+
point?: boolean | undefined;
|
445
449
|
tokenAddress?: string | undefined;
|
446
450
|
test?: boolean | undefined;
|
447
451
|
createdAfter?: number | undefined;
|
@@ -558,6 +562,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
558
562
|
chainId?: number | undefined;
|
559
563
|
creatorId?: string | undefined;
|
560
564
|
mainParameter?: string | undefined;
|
565
|
+
point?: boolean | undefined;
|
561
566
|
tokenAddress?: string | undefined;
|
562
567
|
test?: boolean | undefined;
|
563
568
|
createdAfter?: number | undefined;
|
@@ -132,6 +132,7 @@ export declare const GetCampaignQueryDto: import("@sinclair/typebox").TObject<{
|
|
132
132
|
tokenSymbol: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
133
133
|
tokenAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
134
134
|
test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
135
|
+
point: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
135
136
|
opportunityId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
136
137
|
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
|
137
138
|
NONE: "NONE";
|
@@ -95,6 +95,7 @@ export const GetCampaignQueryDto = t.Object({
|
|
95
95
|
description: "Filter results by the reward token address. Use in combination with chainId for accuracy",
|
96
96
|
})),
|
97
97
|
test: t.Optional(t.Boolean({ description: "Return campaigns rewarding in test tokens", default: false })),
|
98
|
+
point: t.Optional(t.Boolean({ description: "Return campaigns rewarding in points", default: false })),
|
98
99
|
opportunityId: t.Optional(t.String({
|
99
100
|
description: "Filter by opportunity. You can find opportunity ids by calling [GET /v4/opportunities](#tag/opportunities/GET/v4/opportunities)",
|
100
101
|
})),
|
@@ -47,6 +47,7 @@ export declare abstract class CampaignRepository {
|
|
47
47
|
symbol?: undefined;
|
48
48
|
})[] | undefined;
|
49
49
|
isTest: false | undefined;
|
50
|
+
isPoint: boolean | undefined;
|
50
51
|
};
|
51
52
|
Creator: {
|
52
53
|
OR: ({
|
@@ -115,6 +116,7 @@ export declare abstract class CampaignRepository {
|
|
115
116
|
symbol?: undefined;
|
116
117
|
})[] | undefined;
|
117
118
|
isTest: false | undefined;
|
119
|
+
isPoint: boolean | undefined;
|
118
120
|
};
|
119
121
|
Creator: {
|
120
122
|
OR: ({
|
@@ -184,6 +186,7 @@ export declare abstract class CampaignRepository {
|
|
184
186
|
symbol?: undefined;
|
185
187
|
})[] | undefined;
|
186
188
|
isTest: false | undefined;
|
189
|
+
isPoint: boolean | undefined;
|
187
190
|
};
|
188
191
|
Creator: {
|
189
192
|
OR: ({
|
@@ -256,6 +259,7 @@ export declare abstract class CampaignRepository {
|
|
256
259
|
symbol?: undefined;
|
257
260
|
})[] | undefined;
|
258
261
|
isTest: false | undefined;
|
262
|
+
isPoint: boolean | undefined;
|
259
263
|
};
|
260
264
|
Creator: {
|
261
265
|
OR: ({
|
@@ -8,7 +8,7 @@ import moment from "moment";
|
|
8
8
|
import { OpportunityService } from "../opportunity";
|
9
9
|
export class CampaignRepository {
|
10
10
|
static transformQueryToPrismaFilters(query) {
|
11
|
-
const { creatorTag, creatorId, creatorAddress, chainId, distributionChainIds, endTimestamp, opportunityId, mainParameter, campaignId, startTimestamp, status, subType, type, types, tokenAddress, tokenSymbol, test, createdAfter, } = query;
|
11
|
+
const { creatorTag, creatorId, creatorAddress, chainId, distributionChainIds, endTimestamp, opportunityId, mainParameter, campaignId, startTimestamp, status, subType, type, types, tokenAddress, tokenSymbol, test, createdAfter, point, } = query;
|
12
12
|
const getTagFilter = () => {
|
13
13
|
if (creatorTag && creatorId)
|
14
14
|
return {
|
@@ -63,6 +63,7 @@ export class CampaignRepository {
|
|
63
63
|
]
|
64
64
|
: undefined,
|
65
65
|
isTest: !test ? false : undefined,
|
66
|
+
isPoint: point ? true : !test ? false : undefined,
|
66
67
|
},
|
67
68
|
Creator: getTagFilter(),
|
68
69
|
...timeFilter,
|
@@ -122,6 +122,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
122
122
|
chainId?: string | undefined;
|
123
123
|
mainProtocolId?: string | undefined;
|
124
124
|
campaigns?: boolean | undefined;
|
125
|
+
point?: boolean | undefined;
|
125
126
|
test?: boolean | undefined;
|
126
127
|
rewardTokenSymbol?: string | undefined;
|
127
128
|
order?: string | undefined;
|
@@ -316,6 +317,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
316
317
|
chainId?: string | undefined;
|
317
318
|
mainProtocolId?: string | undefined;
|
318
319
|
campaigns?: boolean | undefined;
|
320
|
+
point?: boolean | undefined;
|
319
321
|
test?: boolean | undefined;
|
320
322
|
rewardTokenSymbol?: string | undefined;
|
321
323
|
order?: string | undefined;
|
@@ -337,6 +339,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
337
339
|
id: string;
|
338
340
|
};
|
339
341
|
query: {
|
342
|
+
point?: boolean | undefined;
|
340
343
|
test?: boolean | undefined;
|
341
344
|
};
|
342
345
|
headers: unknown;
|
@@ -460,6 +463,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
460
463
|
chainId?: number | undefined;
|
461
464
|
creatorId?: string | undefined;
|
462
465
|
mainParameter?: string | undefined;
|
466
|
+
point?: boolean | undefined;
|
463
467
|
tokenAddress?: string | undefined;
|
464
468
|
test?: boolean | undefined;
|
465
469
|
createdAfter?: number | undefined;
|
@@ -628,6 +632,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
628
632
|
id: string;
|
629
633
|
};
|
630
634
|
query: {
|
635
|
+
point?: boolean | undefined;
|
631
636
|
test?: boolean | undefined;
|
632
637
|
};
|
633
638
|
headers: unknown;
|
@@ -805,6 +810,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
805
810
|
chainId?: string | undefined;
|
806
811
|
mainProtocolId?: string | undefined;
|
807
812
|
campaigns?: boolean | undefined;
|
813
|
+
point?: boolean | undefined;
|
808
814
|
test?: boolean | undefined;
|
809
815
|
rewardTokenSymbol?: string | undefined;
|
810
816
|
order?: string | undefined;
|
@@ -845,6 +851,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
845
851
|
chainId?: string | undefined;
|
846
852
|
mainProtocolId?: string | undefined;
|
847
853
|
campaigns?: boolean | undefined;
|
854
|
+
point?: boolean | undefined;
|
848
855
|
test?: boolean | undefined;
|
849
856
|
rewardTokenSymbol?: string | undefined;
|
850
857
|
order?: string | undefined;
|
@@ -886,6 +893,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
886
893
|
chainId?: string | undefined;
|
887
894
|
mainProtocolId?: string | undefined;
|
888
895
|
campaigns?: boolean | undefined;
|
896
|
+
point?: boolean | undefined;
|
889
897
|
test?: boolean | undefined;
|
890
898
|
rewardTokenSymbol?: string | undefined;
|
891
899
|
order?: string | undefined;
|
@@ -162,13 +162,13 @@ export class OpportunityConvertorService {
|
|
162
162
|
return res;
|
163
163
|
}
|
164
164
|
static async setV3Opportunities(showCampaigns, test, identifier, chainId) {
|
165
|
-
return await CacheService.set(TTLPresets.
|
165
|
+
return await CacheService.set(TTLPresets.HOUR_4, OpportunityConvertorService.#extractV3Opportunities, showCampaigns, test, identifier, chainId);
|
166
166
|
}
|
167
167
|
static async logKeyAndTTLV3Opportunities(showCampaigns, test, identifier, chainId) {
|
168
168
|
const [key, ttl] = await CacheService.keyAndTTL(OpportunityConvertorService.#extractV3Opportunities, showCampaigns, test, identifier, chainId);
|
169
169
|
log.info(`Args: ${showCampaigns}, ${test}, ${identifier}, ${chainId}, Key: ${key}, TTL: ${ttl}`);
|
170
170
|
}
|
171
171
|
static async wrapV3Opportunities(showCampaigns, test, identifier, chainId) {
|
172
|
-
return await CacheService.wrap(TTLPresets.
|
172
|
+
return await CacheService.wrap(TTLPresets.MIN_10, OpportunityConvertorService.#extractV3Opportunities, showCampaigns, test, identifier, chainId);
|
173
173
|
}
|
174
174
|
}
|
@@ -281,6 +281,7 @@ export declare const GetOpportunitiesQueryDto: import("@sinclair/typebox").TObje
|
|
281
281
|
creatorAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
282
282
|
tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
283
283
|
test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
284
|
+
point: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
284
285
|
minimumTvl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
285
286
|
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRegExp>;
|
286
287
|
identifier: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
@@ -295,6 +296,7 @@ export declare const GetOpportunitiesQueryDto: import("@sinclair/typebox").TObje
|
|
295
296
|
}>;
|
296
297
|
export declare const GetOpportunityQueryDto: import("@sinclair/typebox").TObject<{
|
297
298
|
test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
299
|
+
point: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
298
300
|
}>;
|
299
301
|
export declare const CreateOpportunityDto: import("@sinclair/typebox").TObject<{
|
300
302
|
chainId: import("@sinclair/typebox").TNumber;
|
@@ -62,6 +62,7 @@ export const GetOpportunitiesQueryDto = t.Object({
|
|
62
62
|
creatorAddress: t.Optional(t.String({ description: "Filter by creator address" })),
|
63
63
|
tags: t.Optional(t.String({ description: "Filter by tag" })),
|
64
64
|
test: t.Optional(t.Boolean({ description: "Include opportunities with test campaigns" })),
|
65
|
+
point: t.Optional(t.Boolean({ description: "Include opportunities with point campaigns", default: false })),
|
65
66
|
minimumTvl: t.Optional(t.Number({ description: "Minimum TVL threshhold in USD" })),
|
66
67
|
status: t.Optional(t.RegExp(/^(LIVE|PAST|SOON)(,(LIVE|PAST|SOON)){0,2}$/, {
|
67
68
|
description: "A comma separeted list of status. Legal values are: `LIVE`, `PAST`, `SOON`",
|
@@ -85,6 +86,7 @@ export const GetOpportunitiesQueryDto = t.Object({
|
|
85
86
|
});
|
86
87
|
export const GetOpportunityQueryDto = t.Object({
|
87
88
|
test: t.Optional(t.Boolean({ description: "Include test campaigns" })),
|
89
|
+
point: t.Optional(t.Boolean({ description: "Include point campaigns", default: false })),
|
88
90
|
});
|
89
91
|
export const CreateOpportunityDto = t.Object({
|
90
92
|
chainId: t.Number(),
|
@@ -177,7 +177,7 @@ export declare abstract class OpportunityRepository {
|
|
177
177
|
apr: number;
|
178
178
|
dailyRewards: number;
|
179
179
|
}) | null>;
|
180
|
-
static findUniqueOrThrow(id: string, withTest?: boolean, withCampaigns?: boolean): Promise<{
|
180
|
+
static findUniqueOrThrow(id: string, withTest?: boolean, withPoints?: boolean, withCampaigns?: boolean): Promise<{
|
181
181
|
Chain: {
|
182
182
|
id: number;
|
183
183
|
name: string;
|
@@ -20,6 +20,7 @@ export class OpportunityRepository {
|
|
20
20
|
const sort = (query.sort === "rewards" ? "dailyRewards" : query.sort) ?? "dailyRewards";
|
21
21
|
const order = query.order ?? "desc";
|
22
22
|
const test = query.test ?? false;
|
23
|
+
const point = query.point ?? false;
|
23
24
|
const creatorAddress = query.creatorAddress ?? null;
|
24
25
|
const identifier = query.identifier ?? null;
|
25
26
|
const orderBy = {
|
@@ -45,6 +46,7 @@ export class OpportunityRepository {
|
|
45
46
|
? undefined
|
46
47
|
: {
|
47
48
|
isTest: !test ? false : undefined,
|
49
|
+
isPoint: point,
|
48
50
|
symbol: rewardTokenSymbol ? { equals: rewardTokenSymbol, mode: "insensitive" } : undefined,
|
49
51
|
},
|
50
52
|
creatorAddress: creatorAddress ? creatorAddress : undefined,
|
@@ -54,7 +56,7 @@ export class OpportunityRepository {
|
|
54
56
|
},
|
55
57
|
};
|
56
58
|
}
|
57
|
-
static #getRecordInclusion(withTest = true) {
|
59
|
+
static #getRecordInclusion(withTest = true, withPoints = true) {
|
58
60
|
return {
|
59
61
|
AprRecords: {
|
60
62
|
take: 1,
|
@@ -73,7 +75,7 @@ export class OpportunityRepository {
|
|
73
75
|
DailyRewardsBreakdown: {
|
74
76
|
where: {
|
75
77
|
Campaign: {
|
76
|
-
RewardToken: withTest ? undefined : { isTest: false },
|
78
|
+
RewardToken: withTest ? undefined : { isTest: false, isPoint: withPoints },
|
77
79
|
},
|
78
80
|
},
|
79
81
|
include: {
|
@@ -92,7 +94,7 @@ export class OpportunityRepository {
|
|
92
94
|
},
|
93
95
|
};
|
94
96
|
}
|
95
|
-
static #getCampaignInclusion(withTest = true) {
|
97
|
+
static #getCampaignInclusion(withTest = true, withPoints = true) {
|
96
98
|
return {
|
97
99
|
orderBy: {
|
98
100
|
endTimestamp: "desc",
|
@@ -102,6 +104,7 @@ export class OpportunityRepository {
|
|
102
104
|
: {
|
103
105
|
RewardToken: {
|
104
106
|
isTest: false,
|
107
|
+
isPoint: withPoints,
|
105
108
|
},
|
106
109
|
},
|
107
110
|
include: {
|
@@ -198,16 +201,16 @@ export class OpportunityRepository {
|
|
198
201
|
where: { id },
|
199
202
|
});
|
200
203
|
}
|
201
|
-
static async findUniqueOrThrow(id, withTest = true, withCampaigns = false) {
|
204
|
+
static async findUniqueOrThrow(id, withTest = true, withPoints = true, withCampaigns = false) {
|
202
205
|
return await apiDbClient.opportunity.findUniqueOrThrow({
|
203
206
|
include: {
|
204
|
-
...OpportunityRepository.#getRecordInclusion(withTest),
|
205
|
-
Campaigns: withCampaigns ? OpportunityRepository.#getCampaignInclusion(withTest) : undefined,
|
207
|
+
...OpportunityRepository.#getRecordInclusion(withTest, withPoints),
|
208
|
+
Campaigns: withCampaigns ? OpportunityRepository.#getCampaignInclusion(withTest, withPoints) : undefined,
|
206
209
|
Chain: { include: { Explorer: true } },
|
207
210
|
MainProtocol: true,
|
208
211
|
Protocols: true,
|
209
212
|
Tokens: {
|
210
|
-
where: !withTest ? { isTest: false } : undefined,
|
213
|
+
where: !withTest ? { isTest: false, isPoint: withPoints } : undefined,
|
211
214
|
},
|
212
215
|
},
|
213
216
|
where: { id },
|
@@ -245,14 +248,15 @@ export class OpportunityRepository {
|
|
245
248
|
const page = _page ? _page : 0;
|
246
249
|
const items = _items ? _items : 20;
|
247
250
|
const withTest = query.test ?? false;
|
251
|
+
const withPoints = query.point ?? false;
|
248
252
|
const withCampaigns = query.campaigns ?? false;
|
249
253
|
const args = OpportunityRepository.#transformQueryToPrismaFilters(query);
|
250
254
|
return await apiDbClient.opportunity.findMany({
|
251
255
|
take: items,
|
252
256
|
skip: page * items,
|
253
257
|
include: {
|
254
|
-
...OpportunityRepository.#getRecordInclusion(withTest),
|
255
|
-
Campaigns: withCampaigns ? OpportunityRepository.#getCampaignInclusion(withTest) : undefined,
|
258
|
+
...OpportunityRepository.#getRecordInclusion(withTest, withPoints),
|
259
|
+
Campaigns: withCampaigns ? OpportunityRepository.#getCampaignInclusion(withTest, withPoints) : undefined,
|
256
260
|
MainProtocol: true,
|
257
261
|
Chain: {
|
258
262
|
include: {
|
@@ -261,7 +265,7 @@ export class OpportunityRepository {
|
|
261
265
|
},
|
262
266
|
Protocols: true,
|
263
267
|
Tokens: {
|
264
|
-
where: !withTest ? { isTest: false } : undefined,
|
268
|
+
where: !withTest ? { isTest: false, isPoint: withPoints } : undefined,
|
265
269
|
},
|
266
270
|
},
|
267
271
|
...args,
|
@@ -276,7 +276,7 @@ export declare abstract class OpportunityService {
|
|
276
276
|
};
|
277
277
|
}[];
|
278
278
|
}[]>;
|
279
|
-
static getUniqueWithCampaignsOrThrow(opportunityId: string | OpportunityUnique, withTest?: boolean): Promise<{
|
279
|
+
static getUniqueWithCampaignsOrThrow(opportunityId: string | OpportunityUnique, withTest?: boolean, withPoints?: boolean): Promise<{
|
280
280
|
protocol?: {
|
281
281
|
id: string;
|
282
282
|
name: string;
|
@@ -411,7 +411,7 @@ export declare abstract class OpportunityService {
|
|
411
411
|
};
|
412
412
|
}[];
|
413
413
|
}>;
|
414
|
-
static getUniqueOrThrow(opportunityId: string | OpportunityUnique, withTest?: boolean): Promise<OpportunityResourceModel>;
|
414
|
+
static getUniqueOrThrow(opportunityId: string | OpportunityUnique, withTest?: boolean, withPoints?: boolean): Promise<OpportunityResourceModel>;
|
415
415
|
/**
|
416
416
|
* Get the list of opportunities satisfying the query
|
417
417
|
* @param query
|
@@ -187,14 +187,14 @@ export class OpportunityService {
|
|
187
187
|
return OpportunityService.formatResponse(o);
|
188
188
|
});
|
189
189
|
}
|
190
|
-
static async getUniqueWithCampaignsOrThrow(opportunityId, withTest = false) {
|
190
|
+
static async getUniqueWithCampaignsOrThrow(opportunityId, withTest = false, withPoints = false) {
|
191
191
|
const id = typeof opportunityId === "string" ? opportunityId : OpportunityService.hashId(opportunityId);
|
192
|
-
const opportunity = await OpportunityRepository.findUniqueOrThrow(id, withTest, true);
|
192
|
+
const opportunity = await OpportunityRepository.findUniqueOrThrow(id, withTest, withTest ?? withPoints, true);
|
193
193
|
return OpportunityService.formatResponse(opportunity);
|
194
194
|
}
|
195
|
-
static async getUniqueOrThrow(opportunityId, withTest = false) {
|
195
|
+
static async getUniqueOrThrow(opportunityId, withTest = false, withPoints = false) {
|
196
196
|
const id = typeof opportunityId === "string" ? opportunityId : OpportunityService.hashId(opportunityId);
|
197
|
-
const opportunity = await OpportunityRepository.findUniqueOrThrow(id, withTest);
|
197
|
+
const opportunity = await OpportunityRepository.findUniqueOrThrow(id, withTest, withTest ?? withPoints);
|
198
198
|
return OpportunityService.formatResponse(opportunity);
|
199
199
|
}
|
200
200
|
/**
|
@@ -137,6 +137,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
137
137
|
chainId?: string | undefined;
|
138
138
|
mainProtocolId?: string | undefined;
|
139
139
|
campaigns?: boolean | undefined;
|
140
|
+
point?: boolean | undefined;
|
140
141
|
test?: boolean | undefined;
|
141
142
|
rewardTokenSymbol?: string | undefined;
|
142
143
|
order?: string | undefined;
|
@@ -331,6 +332,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
331
332
|
chainId?: string | undefined;
|
332
333
|
mainProtocolId?: string | undefined;
|
333
334
|
campaigns?: boolean | undefined;
|
335
|
+
point?: boolean | undefined;
|
334
336
|
test?: boolean | undefined;
|
335
337
|
rewardTokenSymbol?: string | undefined;
|
336
338
|
order?: string | undefined;
|
@@ -352,6 +354,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
352
354
|
id: string;
|
353
355
|
};
|
354
356
|
query: {
|
357
|
+
point?: boolean | undefined;
|
355
358
|
test?: boolean | undefined;
|
356
359
|
};
|
357
360
|
headers: unknown;
|
@@ -475,6 +478,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
475
478
|
chainId?: number | undefined;
|
476
479
|
creatorId?: string | undefined;
|
477
480
|
mainParameter?: string | undefined;
|
481
|
+
point?: boolean | undefined;
|
478
482
|
tokenAddress?: string | undefined;
|
479
483
|
test?: boolean | undefined;
|
480
484
|
createdAfter?: number | undefined;
|
@@ -643,6 +647,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
643
647
|
id: string;
|
644
648
|
};
|
645
649
|
query: {
|
650
|
+
point?: boolean | undefined;
|
646
651
|
test?: boolean | undefined;
|
647
652
|
};
|
648
653
|
headers: unknown;
|
@@ -820,6 +825,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
820
825
|
chainId?: string | undefined;
|
821
826
|
mainProtocolId?: string | undefined;
|
822
827
|
campaigns?: boolean | undefined;
|
828
|
+
point?: boolean | undefined;
|
823
829
|
test?: boolean | undefined;
|
824
830
|
rewardTokenSymbol?: string | undefined;
|
825
831
|
order?: string | undefined;
|
@@ -860,6 +866,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
860
866
|
chainId?: string | undefined;
|
861
867
|
mainProtocolId?: string | undefined;
|
862
868
|
campaigns?: boolean | undefined;
|
869
|
+
point?: boolean | undefined;
|
863
870
|
test?: boolean | undefined;
|
864
871
|
rewardTokenSymbol?: string | undefined;
|
865
872
|
order?: string | undefined;
|
@@ -901,6 +908,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
901
908
|
chainId?: string | undefined;
|
902
909
|
mainProtocolId?: string | undefined;
|
903
910
|
campaigns?: boolean | undefined;
|
911
|
+
point?: boolean | undefined;
|
904
912
|
test?: boolean | undefined;
|
905
913
|
rewardTokenSymbol?: string | undefined;
|
906
914
|
order?: string | undefined;
|
@@ -1127,6 +1135,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1127
1135
|
chainId?: number | undefined;
|
1128
1136
|
creatorId?: string | undefined;
|
1129
1137
|
mainParameter?: string | undefined;
|
1138
|
+
point?: boolean | undefined;
|
1130
1139
|
tokenAddress?: string | undefined;
|
1131
1140
|
test?: boolean | undefined;
|
1132
1141
|
createdAfter?: number | undefined;
|
@@ -1313,6 +1322,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1313
1322
|
chainId?: number | undefined;
|
1314
1323
|
creatorId?: string | undefined;
|
1315
1324
|
mainParameter?: string | undefined;
|
1325
|
+
point?: boolean | undefined;
|
1316
1326
|
tokenAddress?: string | undefined;
|
1317
1327
|
test?: boolean | undefined;
|
1318
1328
|
createdAfter?: number | undefined;
|
@@ -1348,6 +1358,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1348
1358
|
chainId?: number | undefined;
|
1349
1359
|
creatorId?: string | undefined;
|
1350
1360
|
mainParameter?: string | undefined;
|
1361
|
+
point?: boolean | undefined;
|
1351
1362
|
tokenAddress?: string | undefined;
|
1352
1363
|
test?: boolean | undefined;
|
1353
1364
|
createdAfter?: number | undefined;
|
@@ -1386,6 +1397,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1386
1397
|
chainId?: number | undefined;
|
1387
1398
|
creatorId?: string | undefined;
|
1388
1399
|
mainParameter?: string | undefined;
|
1400
|
+
point?: boolean | undefined;
|
1389
1401
|
tokenAddress?: string | undefined;
|
1390
1402
|
test?: boolean | undefined;
|
1391
1403
|
createdAfter?: number | undefined;
|
@@ -1502,6 +1514,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1502
1514
|
chainId?: number | undefined;
|
1503
1515
|
creatorId?: string | undefined;
|
1504
1516
|
mainParameter?: string | undefined;
|
1517
|
+
point?: boolean | undefined;
|
1505
1518
|
tokenAddress?: string | undefined;
|
1506
1519
|
test?: boolean | undefined;
|
1507
1520
|
createdAfter?: number | undefined;
|
@@ -1913,6 +1926,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1913
1926
|
displaySymbol?: string | undefined;
|
1914
1927
|
verified?: boolean | undefined;
|
1915
1928
|
isTest?: boolean | undefined;
|
1929
|
+
isPoint?: boolean | undefined;
|
1916
1930
|
};
|
1917
1931
|
params: {
|
1918
1932
|
id: string;
|
@@ -59,6 +59,7 @@ export declare const TokenIdDto: import("@sinclair/typebox").TObject<{
|
|
59
59
|
}>;
|
60
60
|
export declare const UpdateTokenDto: import("@sinclair/typebox").TObject<{
|
61
61
|
isTest: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
62
|
+
isPoint: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
62
63
|
verified: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
63
64
|
icon: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
64
65
|
displaySymbol: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
@@ -46,6 +46,7 @@ export const GetTokenBalanceDto = t.Object({
|
|
46
46
|
export const TokenIdDto = t.Object({ id: t.String() });
|
47
47
|
export const UpdateTokenDto = t.Object({
|
48
48
|
isTest: t.Optional(t.Boolean()),
|
49
|
+
isPoint: t.Optional(t.Boolean()),
|
49
50
|
verified: t.Optional(t.Boolean()),
|
50
51
|
icon: t.Optional(t.String({ format: "uri" })),
|
51
52
|
// iconFile: t.Optional(t.File()),
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Pricer } from "@/utils/pricer";
|
2
|
-
import { type ChainId } from "@sdk";
|
2
|
+
import { type Campaign, type CampaignParameters, type ChainId } from "@sdk";
|
3
3
|
import type { CreateTokenModel, NotionWebhookModel } from "./token.model";
|
4
4
|
import type { GetTokenQueryModel, Token, TokenModel, TokenUnique, UpdateTokenModel } from "./token.model";
|
5
5
|
import { TokenRepository } from "./token.repository";
|
@@ -135,6 +135,7 @@ export declare abstract class TokenService {
|
|
135
135
|
} & {
|
136
136
|
price?: number | null | undefined;
|
137
137
|
})[]>;
|
138
|
+
static getPrice(query: GetTokenQueryModel): Promise<number>;
|
138
139
|
static findManyObjectPerAddress(query: GetTokenQueryModel): Promise<Record<string, {
|
139
140
|
symbol: string;
|
140
141
|
id: string;
|
@@ -150,6 +151,7 @@ export declare abstract class TokenService {
|
|
150
151
|
} & {
|
151
152
|
price?: number | null | undefined;
|
152
153
|
}>>;
|
154
|
+
static getRewardTokenPrice(campaign: CampaignParameters<Campaign>): Promise<number>;
|
153
155
|
/**
|
154
156
|
* Get value of tokens
|
155
157
|
* @param tokenAmounts address/chain + amount of token
|
@@ -177,12 +177,30 @@ export class TokenService {
|
|
177
177
|
static async findMany(query) {
|
178
178
|
return (await TokenRepository.findMany(query)).map(TokenService.format);
|
179
179
|
}
|
180
|
+
static async getPrice(query) {
|
181
|
+
const tokensFound = (await TokenRepository.findMany(query)).map(TokenService.format);
|
182
|
+
if (tokensFound.length === 0) {
|
183
|
+
throw new Error("Token not found");
|
184
|
+
}
|
185
|
+
// In the case of points, we want to be able to compute X points distributed per $ of TVL, hence returning 1.
|
186
|
+
const priceToken = tokensFound[0].isPoint ? 1 : (tokensFound[0].price ?? 0);
|
187
|
+
return priceToken;
|
188
|
+
}
|
180
189
|
static async findManyObjectPerAddress(query) {
|
181
190
|
return (await TokenService.findMany(query)).reduce((acc, token) => {
|
182
191
|
acc[token.address] = token;
|
183
192
|
return acc;
|
184
193
|
}, {});
|
185
194
|
}
|
195
|
+
static async getRewardTokenPrice(campaign) {
|
196
|
+
const query = {
|
197
|
+
chainId: campaign.chainId,
|
198
|
+
address: campaign.rewardToken,
|
199
|
+
symbol: campaign.campaignParameters.symbolRewardToken,
|
200
|
+
};
|
201
|
+
const priceRewardToken = await TokenService.getPrice(query);
|
202
|
+
return priceRewardToken;
|
203
|
+
}
|
186
204
|
/**
|
187
205
|
* Get value of tokens
|
188
206
|
* @param tokenAmounts address/chain + amount of token
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { AaveInterface, AccountantWithRateProvidersInterface, AuraInterface, AuraOperatorInterface, BalancerGaugeInterface, BalancerPoolInterface, BalancerV3StablePoolInterface, BalancerVaultInterface, BeefyInterface, CPMMGammaPoolMainInterface, CompoundInterface, CurveInterface, CurveLPTokenInterface, CurveStableSwapNGInterface, DefutureVaultInterface, ERC20Interface, ERC4626Interface, EnzymeInterface, EulerInterface, FactoryInterface, FluidInterface, FraxlendInterface, GearboxVaultInterface, HourglassERC20TBTInterface, HourglassVedaLockDepositorV2Interface, IonicInterface, LPManagerHelperInterface, LPManagerInterface, LayerBankERC20Interface, LayerBankInterface, LendleInterface, MaverickBPLensInterface, MetamorphoInterface, MoonwellInterface, OneInchStakingInterface, PendleInterface, PendleYTInterface, RadiantInterface, RfxInterface, RswEthStrategyInterface, SpectraYTInterface, SturdyInterface, SymetricAmbientStrategyInterface, SyncSwapClassicPoolInterface, TorosInterface, UniswapV2PoolInterface, VePufferInterface, ZFStableLPINterface, ZFStableSwapThreePoolInterface, } from "@sdk";
|
1
|
+
import { AaveInterface, AccountantWithRateProvidersInterface, AuraInterface, AuraOperatorInterface, BalancerGaugeInterface, BalancerPoolInterface, BalancerV3StablePoolInterface, BalancerVaultInterface, BeefyInterface, BunniV2HubInterface, BunniV2TokenInterface, CPMMGammaPoolMainInterface, CompoundInterface, CurveInterface, CurveLPTokenInterface, CurveStableSwapNGInterface, DefutureVaultInterface, ERC20Interface, ERC4626Interface, EnzymeInterface, EulerInterface, FactoryInterface, FluidInterface, FraxlendInterface, GearboxVaultInterface, HourglassERC20TBTInterface, HourglassVedaLockDepositorV2Interface, IonicInterface, LPManagerHelperInterface, LPManagerInterface, LayerBankERC20Interface, LayerBankInterface, LendleInterface, MaverickBPLensInterface, MetamorphoInterface, MoonwellInterface, OneInchStakingInterface, PendleInterface, PendleYTInterface, RadiantInterface, RfxInterface, RswEthStrategyInterface, SpectraYTInterface, SturdyInterface, SymetricAmbientStrategyInterface, SyncSwapClassicPoolInterface, TorosInterface, UniswapV2PoolInterface, VePufferInterface, ZFStableLPINterface, ZFStableSwapThreePoolInterface, } from "@sdk";
|
2
2
|
import { tokenType } from "../libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType";
|
3
3
|
export function decodeCall(calls, index, key, type) {
|
4
4
|
const returnData = calls[index];
|
@@ -286,6 +286,12 @@ export function decodeReturnValue(returnData, key, type) {
|
|
286
286
|
return BalancerV3StablePoolInterface.decodeFunctionResult("getTokens", returnData)[0].length;
|
287
287
|
case "getTokenInfo":
|
288
288
|
return BalancerV3StablePoolInterface.decodeFunctionResult("getTokenInfo", returnData);
|
289
|
+
case "hub":
|
290
|
+
return BunniV2TokenInterface.decodeFunctionResult("hub", returnData)[0];
|
291
|
+
case "poolKey":
|
292
|
+
return BunniV2TokenInterface.decodeFunctionResult("poolKey", returnData)[0];
|
293
|
+
case "poolState":
|
294
|
+
return BunniV2HubInterface.decodeFunctionResult("poolState", returnData)[0];
|
289
295
|
default:
|
290
296
|
throw new Error(`Key not recognized for ${key}`);
|
291
297
|
}
|