@merkl/api 0.20.113 → 0.20.114
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 +2 -2
- package/dist/src/engine/deprecated/dynamicData/implementations/default.d.ts +3 -3
- package/dist/src/engine/implementations/Ajna/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Ambient/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Badger/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Clamm/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Compound/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/CompoundV3/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Default/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Dolomite/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/EigenLayer/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Encompassing/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Erc20/metadata.d.ts +1 -12
- package/dist/src/engine/implementations/Erc20/metadata.js +3 -3
- package/dist/src/engine/implementations/Erc20Snapshot/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Erc721/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/ErcMultiToken/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Euler/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Euler/metadata.js +2 -2
- package/dist/src/engine/implementations/EventBased/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Hyperdrive/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Invalid/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Ion/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/JsonAirdrop/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Morpho/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Radiant/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Silo/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/UniswapV4/metadata.d.ts +2 -2
- package/dist/src/engine/implementations/Vest/metadata.d.ts +2 -2
- package/dist/src/jobs/update-dynamic-data.js +2 -2
- package/dist/src/modules/v4/campaign/campaign.model.d.ts +2 -2
- package/dist/src/modules/v4/campaign/campaign.service.d.ts +4 -4
- package/dist/src/modules/v4/campaign/campaign.service.js +3 -3
- package/dist/src/modules/v4/campaign/campaign.test.controller.js +4 -4
- package/dist/src/modules/v4/dynamicData/dynamicData.service.d.ts +3 -3
- package/dist/src/modules/v4/dynamicData/dynamicData.service.js +10 -10
- package/dist/src/modules/v4/opportunity/opportunity.converter.d.ts +2 -2
- package/dist/src/modules/v4/opportunity/opportunity.converter.js +5 -5
- package/dist/src/modules/v4/opportunity/opportunity.service.js +2 -2
- package/dist/src/modules/v4/opportunity/validate-id.pipe.js +3 -3
- package/dist/src/modules/v4/reward/reward.service.d.ts +2 -2
- package/dist/src/modules/v4/reward/reward.service.js +2 -2
- package/dist/src/routes/v3/campaigns.js +3 -3
- package/dist/src/routes/v3/campaignsForMainParameter.js +2 -2
- package/dist/src/scripts/reparse-opportunities.js +2 -2
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -10,7 +10,7 @@ import { TvlService } from "@/modules/v4/tvl/tvl.service";
|
|
10
10
|
import bigintToString from "@/utils/bigintToString";
|
11
11
|
import { log } from "@/utils/logger";
|
12
12
|
import { AprType } from "@db/api";
|
13
|
-
import { Campaign as
|
13
|
+
import { Campaign as CampaignType, DAY, NETWORK_LABELS, bigIntToNumber, } from "@sdk";
|
14
14
|
import moment from "moment";
|
15
15
|
import { AprService } from "../apr";
|
16
16
|
import { CampaignService } from "../campaign";
|
@@ -38,7 +38,7 @@ export class DynamicDataService {
|
|
38
38
|
const opportunityIds = new Set(records.map(r => OpportunityService.hashId({
|
39
39
|
chainId,
|
40
40
|
identifier: r.campaign.mainParameter,
|
41
|
-
type:
|
41
|
+
type: CampaignType[+type],
|
42
42
|
})));
|
43
43
|
const now = moment().unix();
|
44
44
|
const updates = [];
|
@@ -46,7 +46,7 @@ export class DynamicDataService {
|
|
46
46
|
const recordsForOpportunity = records.filter(r => OpportunityService.hashId({
|
47
47
|
chainId,
|
48
48
|
identifier: r.campaign.mainParameter,
|
49
|
-
type:
|
49
|
+
type: CampaignType[+type],
|
50
50
|
}) === opportunityId);
|
51
51
|
const tvl = {
|
52
52
|
timestamp: BigInt(now),
|
@@ -96,7 +96,7 @@ export class DynamicDataService {
|
|
96
96
|
let campaignDailyValue = await TokenService.getValueByTokenId(TokenService.hashId({ address: rewardTokenAddress, chainId: record.campaign.chainId }), dailyAmount);
|
97
97
|
// Fixed APR campaigns
|
98
98
|
if (hasFixedAprConfig(campaignParameters)) {
|
99
|
-
log.local(`[${NETWORK_LABELS[chainId]}][${
|
99
|
+
log.local(`[${NETWORK_LABELS[chainId]}][${CampaignType[type]}] calculating fixed APR for ${record.campaign.campaignId}`);
|
100
100
|
const { targetTokenPricing, rewardTokenPricing, apr: fixedApr } = campaignParameters;
|
101
101
|
const targetApr = Number(fixedApr);
|
102
102
|
if (targetTokenPricing && rewardTokenPricing) {
|
@@ -182,7 +182,7 @@ export class DynamicDataService {
|
|
182
182
|
});
|
183
183
|
}
|
184
184
|
}
|
185
|
-
log.info(`[${NETWORK_LABELS[chainId]}][${
|
185
|
+
log.info(`[${NETWORK_LABELS[chainId]}][${CampaignType[type]}] updated ${updates.length}/${campaigns.length} campaigns using campaignTVLBuilder`);
|
186
186
|
}
|
187
187
|
return updates;
|
188
188
|
}
|
@@ -192,7 +192,7 @@ export class DynamicDataService {
|
|
192
192
|
for (const data of dynamicData) {
|
193
193
|
if (!!data) {
|
194
194
|
// Main Parameter OVERRIDING
|
195
|
-
if (data.campaignType ===
|
195
|
+
if (data.campaignType === CampaignType.SILO && data.campaignParameters.whitelist?.length === 1)
|
196
196
|
data.mainParameter = `${data.mainParameter}-${data.campaignParameters.whitelist[0]}`;
|
197
197
|
if (!oppMap[`${data.campaignType}_${data.mainParameter}`])
|
198
198
|
oppMap[`${data.campaignType}_${data.mainParameter}`] = {};
|
@@ -207,7 +207,7 @@ export class DynamicDataService {
|
|
207
207
|
const opportunityId = OpportunityService.hashId({
|
208
208
|
chainId,
|
209
209
|
identifier: mainParameter,
|
210
|
-
type:
|
210
|
+
type: CampaignType[+type],
|
211
211
|
});
|
212
212
|
try {
|
213
213
|
if (!dryRun)
|
@@ -218,7 +218,7 @@ export class DynamicDataService {
|
|
218
218
|
}
|
219
219
|
dynamicDataArray.push(bigintToString({ campaignId: Object.values(entry[1])[0].campaignId, apr, tvl, dailyRewards }));
|
220
220
|
}
|
221
|
-
log.info(`[${NETWORK_LABELS[chainId]}][${
|
221
|
+
log.info(`[${NETWORK_LABELS[chainId]}][${CampaignType[type]}] updated ${dynamicData.length}/${campaigns.length} campaigns`);
|
222
222
|
return dynamicDataArray;
|
223
223
|
}
|
224
224
|
/**
|
@@ -252,11 +252,11 @@ export class DynamicDataService {
|
|
252
252
|
symbolTargetToken: "EXT",
|
253
253
|
targetToken: tokenAddress,
|
254
254
|
},
|
255
|
-
campaignType:
|
255
|
+
campaignType: CampaignType.ERC20,
|
256
256
|
},
|
257
257
|
];
|
258
258
|
log.info(`querying mock campaign on chain: ${NETWORK_LABELS[chainId]}`);
|
259
|
-
const result = await dynamicDataBuilderFactory(
|
259
|
+
const result = await dynamicDataBuilderFactory(CampaignType.ERC20).build(Number(chainId), campaigns);
|
260
260
|
return {
|
261
261
|
priceTargetToken: result[0]?.typeInfo.priceTargetToken,
|
262
262
|
totalSupply: result[0]?.typeInfo.totalSupply,
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { Campaign as
|
1
|
+
import { type CampaignParameters, Campaign as CampaignType, type Opportunity as OpportunityV3 } from "@sdk";
|
2
2
|
import type { CampaignWithParams } from "../campaign";
|
3
3
|
import { OpportunityService } from "./opportunity.service";
|
4
4
|
export declare abstract class OpportunityConvertorService {
|
5
5
|
#private;
|
6
|
-
static convertV4CampaignToV3<C extends
|
6
|
+
static convertV4CampaignToV3<C extends CampaignType>(campaignType: C, campaign: Exclude<Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]["campaigns"], undefined>[number] | Omit<CampaignWithParams<C>, "manualOverrides">, opportunityIdentifier: string): CampaignParameters<C>;
|
7
7
|
static convertV4toV3(opportunity: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number], withCampaigns?: boolean): OpportunityV3;
|
8
8
|
static setV3Opportunities(showCampaigns: boolean, test: boolean | undefined, identifier: string | undefined, chainId: string | undefined): Promise<{}>;
|
9
9
|
static logKeyAndTTLV3Opportunities(showCampaigns: boolean, test: boolean | undefined, identifier: string | undefined, chainId: string | undefined): Promise<void>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { kebabToPascalCase } from "@/utils/caseChanges";
|
2
2
|
import { log } from "@/utils/logger";
|
3
|
-
import { Campaign as
|
3
|
+
import { Campaign as CampaignType, EAprBreakdownType, opportunityActions, } from "@sdk";
|
4
4
|
import moment from "moment";
|
5
5
|
import { CacheService } from "../cache";
|
6
6
|
import { TTLPresets } from "../cache/cache.model";
|
@@ -26,7 +26,7 @@ export class OpportunityConvertorService {
|
|
26
26
|
}
|
27
27
|
static convertV4toV3(opportunity, withCampaigns = false) {
|
28
28
|
const now = moment().unix();
|
29
|
-
const id = `${
|
29
|
+
const id = `${CampaignType[opportunity.type]}_${opportunity.identifier}`; // V3 id
|
30
30
|
// Convert v4 actions to old type
|
31
31
|
let action = opportunity.action.toLowerCase();
|
32
32
|
if (!opportunityActions.includes(action)) {
|
@@ -117,17 +117,17 @@ export class OpportunityConvertorService {
|
|
117
117
|
return acc;
|
118
118
|
}, []) ?? [],
|
119
119
|
campaigns: {
|
120
|
-
type:
|
120
|
+
type: CampaignType[opportunity.type],
|
121
121
|
ids: opportunity.campaigns?.map(campaign => campaign.campaignId) ?? [],
|
122
122
|
active: withCampaigns
|
123
123
|
? opportunity.campaigns
|
124
124
|
?.filter(campaign => campaign.startTimestamp < BigInt(now) && BigInt(now) < campaign.endTimestamp)
|
125
|
-
.map(campaign => OpportunityConvertorService.convertV4CampaignToV3(
|
125
|
+
.map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignType[campaign.type], campaign, opportunity.identifier))
|
126
126
|
: undefined,
|
127
127
|
inactive: withCampaigns
|
128
128
|
? opportunity.campaigns
|
129
129
|
?.filter(campaign => !(campaign.startTimestamp < BigInt(now) && BigInt(now) < campaign.endTimestamp))
|
130
|
-
.map(campaign => OpportunityConvertorService.convertV4CampaignToV3(
|
130
|
+
.map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignType[campaign.type], campaign, opportunity.identifier))
|
131
131
|
: undefined,
|
132
132
|
},
|
133
133
|
};
|
@@ -7,7 +7,7 @@ import { TokenService } from "@/modules/v4/token/token.service";
|
|
7
7
|
import { UserService } from "@/modules/v4/user/user.service";
|
8
8
|
import { log } from "@/utils/logger";
|
9
9
|
import { Status } from "@db/api";
|
10
|
-
import { Campaign as
|
10
|
+
import { Campaign as CampaignType } from "@sdk";
|
11
11
|
import moment from "moment";
|
12
12
|
import { metadataBuilderFactory } from "../../../engine/metadata/factory";
|
13
13
|
import { ProtocolService } from "../protocol/protocol.service";
|
@@ -43,7 +43,7 @@ export class OpportunityService {
|
|
43
43
|
* @param campaign
|
44
44
|
*/
|
45
45
|
static async #getMetadata(campaign, opportunityIdentifier) {
|
46
|
-
const campaignType =
|
46
|
+
const campaignType = CampaignType[campaign.type];
|
47
47
|
return await metadataBuilderFactory(campaignType).build(campaign, opportunityIdentifier);
|
48
48
|
}
|
49
49
|
/**
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { BadRequestError } from "@/errors";
|
2
|
-
import { Campaign as
|
2
|
+
import { Campaign as CampaignType } from "@sdk";
|
3
3
|
export const validateId = ({ params }) => {
|
4
4
|
if (!params.id.includes("-")) {
|
5
5
|
if (/[0-9]{1,20}/.test(params.id))
|
@@ -7,6 +7,6 @@ export const validateId = ({ params }) => {
|
|
7
7
|
throw new BadRequestError("Invalid Opportunity id");
|
8
8
|
}
|
9
9
|
const [_chainId, type, _campaignId] = params.id.split("-");
|
10
|
-
if (!Object.values(
|
11
|
-
throw new BadRequestError("Invalid Campaign type", Object.keys(
|
10
|
+
if (!Object.values(CampaignType).includes(type))
|
11
|
+
throw new BadRequestError("Invalid Campaign type", Object.keys(CampaignType));
|
12
12
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { CacheKeys } from "@/cache/keys";
|
2
2
|
import type { Chain } from "@db/api";
|
3
|
-
import { type CampaignDynamicData, Campaign as
|
3
|
+
import { type CampaignDynamicData, Campaign as CampaignType, type ChainId, type MerklChainId } from "@sdk";
|
4
4
|
import { type LightOpportunityFromDB, type Opportunity } from "../opportunity";
|
5
5
|
import type { CampaignIdModel, CampaignIdWithoutPageModel, CreateManyBreakdownModel, CreateManyRewardModel, DailyRewardsRecord, RegisterClaimsModel, RewardBreakdown, TokenIdModel } from "./reward.model";
|
6
6
|
import { RewardRepository } from "./reward.repository";
|
@@ -785,5 +785,5 @@ export declare abstract class RewardService {
|
|
785
785
|
/**
|
786
786
|
* @deprecated
|
787
787
|
*/
|
788
|
-
static extractDailyRewardsRecordFromDynamicData<C extends
|
788
|
+
static extractDailyRewardsRecordFromDynamicData<C extends CampaignType>(type: C, dynamicData: CampaignDynamicData<C>[], timestamp?: bigint): Promise<DailyRewardsRecord["model"]>;
|
789
789
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { log } from "@/utils/logger";
|
2
|
-
import { Campaign as
|
2
|
+
import { Campaign as CampaignType, DAY, DistributorService, NETWORK_LABELS, } from "@sdk";
|
3
3
|
import moment from "moment";
|
4
4
|
import { BlacklistService } from "../blacklist";
|
5
5
|
import { CacheService } from "../cache";
|
@@ -358,7 +358,7 @@ export class RewardService {
|
|
358
358
|
* @deprecated
|
359
359
|
*/
|
360
360
|
static async extractDailyRewardsRecordFromDynamicData(type, dynamicData, timestamp = BigInt(moment().unix())) {
|
361
|
-
const typesWithoutApr = [
|
361
|
+
const typesWithoutApr = [CampaignType.INVALID];
|
362
362
|
if (typesWithoutApr.includes(type))
|
363
363
|
return { timestamp, total: 0, breakdowns: [] };
|
364
364
|
const breakdowns = [];
|
@@ -2,7 +2,7 @@ import { Redis } from "@/cache";
|
|
2
2
|
import { CampaignService } from "@/modules/v4/campaign";
|
3
3
|
import { OpportunityConvertorService } from "@/modules/v4/opportunity/opportunity.converter";
|
4
4
|
import { UnsupportedNetwork } from "@/utils/error";
|
5
|
-
import { ANGLE_NETWORKS, Campaign as
|
5
|
+
import { ANGLE_NETWORKS, Campaign as CampaignType, ChainId, isSupportedChain, registry, } from "@sdk";
|
6
6
|
import { t } from "elysia";
|
7
7
|
export const query = t.Object({
|
8
8
|
chainIds: t.Optional(t.Union([t.String(), t.Array(t.String())])),
|
@@ -72,7 +72,7 @@ export default (app) => app.get("/campaigns", async ({ query }) => {
|
|
72
72
|
if (process.env.FF_OPPORTUNITY === "true") {
|
73
73
|
const campaigns = await CampaignService.findMany({
|
74
74
|
distributionChainIds: chainIds,
|
75
|
-
types: !types.length ? undefined : types.map(type =>
|
75
|
+
types: !types.length ? undefined : types.map(type => CampaignType[type]),
|
76
76
|
status: query.live ? "LIVE" : undefined,
|
77
77
|
creatorTag: query.creatorTag,
|
78
78
|
test: !hideTestTokens,
|
@@ -84,7 +84,7 @@ export default (app) => app.get("/campaigns", async ({ query }) => {
|
|
84
84
|
res[campaign.distributionChainId] = {};
|
85
85
|
}
|
86
86
|
const opportunityIdentifier = campaign.Opportunity.identifier;
|
87
|
-
const campaignType =
|
87
|
+
const campaignType = CampaignType[campaign.type];
|
88
88
|
if (!res[campaign.distributionChainId][`${campaignType}_${opportunityIdentifier}`]) {
|
89
89
|
res[campaign.distributionChainId][`${campaignType}_${opportunityIdentifier}`] = {
|
90
90
|
...OpportunityConvertorService.convertV4CampaignToV3(campaignType, campaign, opportunityIdentifier),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { NotFoundError } from "@/errors";
|
2
2
|
import { OpportunityService } from "@/modules/v4/opportunity";
|
3
|
-
import { BN2Number, Campaign as
|
3
|
+
import { BN2Number, Campaign as CampaignType } from "@sdk";
|
4
4
|
import { t } from "elysia";
|
5
5
|
import checkQueryChainIdValidity from "../../hooks/checkQueryChainIdValidity";
|
6
6
|
export const query = t.Object({
|
@@ -19,7 +19,7 @@ export default (app) => app.use(checkQueryChainIdValidity()).get("/campaignsForM
|
|
19
19
|
return (await OpportunityService.getUniqueWithCampaignsOrThrow(opportunityId))?.campaigns
|
20
20
|
?.map(c => ({
|
21
21
|
campaignId: c.campaignId,
|
22
|
-
campaignType:
|
22
|
+
campaignType: CampaignType[c.type],
|
23
23
|
rewardToken: c.rewardToken.address,
|
24
24
|
rewardTokenSymbol: c.rewardToken.symbol,
|
25
25
|
amountDecimal: BN2Number(c.amount, c.rewardToken.decimals),
|
@@ -3,7 +3,7 @@ import { metadataBuilderFactory } from "@/engine/metadata/factory";
|
|
3
3
|
import { CampaignService } from "@/modules/v4/campaign";
|
4
4
|
import { log } from "@/utils/logger";
|
5
5
|
import { apiDbClient } from "@db";
|
6
|
-
import { Campaign as
|
6
|
+
import { Campaign as CampaignType } from "@sdk";
|
7
7
|
const opportunities = await apiDbClient.opportunity.findMany({
|
8
8
|
select: {
|
9
9
|
id: true,
|
@@ -41,7 +41,7 @@ const opportunities = await apiDbClient.opportunity.findMany({
|
|
41
41
|
for (const opportunity of opportunities) {
|
42
42
|
try {
|
43
43
|
const campaign = CampaignService.format(await CampaignService.findUniqueOrThrow(opportunity.Campaigns[0].id));
|
44
|
-
const metadata = await metadataBuilderFactory(
|
44
|
+
const metadata = await metadataBuilderFactory(CampaignType[opportunity.type]).build(campaign, opportunity.identifier);
|
45
45
|
if (!!metadata?.explorerAddress && !opportunity.explorerAddress) {
|
46
46
|
await apiDbClient.opportunity.update({
|
47
47
|
where: {
|