@merkl/api 0.10.361 → 0.10.377
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/README.md +78 -14
- package/dist/database/api/.generated/edge.js +21 -6
- package/dist/database/api/.generated/index-browser.js +18 -3
- package/dist/database/api/.generated/index.d.ts +1746 -256
- package/dist/database/api/.generated/index.js +21 -6
- package/dist/database/api/.generated/package.json +1 -1
- package/dist/database/api/.generated/schema.prisma +12 -2
- package/dist/database/api/.generated/wasm.js +18 -3
- package/dist/src/eden/index.d.ts +1260 -127
- package/dist/src/entities/campaign.js +2 -1
- package/dist/src/entities/opportunity.js +169 -3
- package/dist/src/index.d.ts +432 -5
- package/dist/src/jobs/etl/pendings.js +2 -1
- package/dist/src/jobs/etl/reward-breakdowns.js +2 -1
- package/dist/src/jobs/etl/rewards.js +2 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.js +45 -54
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.d.ts +3 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +4 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/ERC4626Processor.d.ts +34 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/ERC4626Processor.js +36 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/processorMapping.js +3 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1.js +4 -1
- package/dist/src/libs/campaigns/campaignTypes/HyperdriveDynamicData.d.ts +5 -0
- package/dist/src/libs/campaigns/campaignTypes/HyperdriveDynamicData.js +76 -0
- package/dist/src/libs/campaigns/campaignsDynamicData.js +8 -0
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +2 -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 +63 -1
- package/dist/src/modules/v4/campaign/campaign.repository.js +15 -10
- package/dist/src/modules/v4/computedValue/computedValue.controller.d.ts +8 -5
- package/dist/src/modules/v4/computedValue/computedValue.controller.js +8 -6
- package/dist/src/modules/v4/computedValue/computedValue.model.js +12 -4
- package/dist/src/modules/v4/computedValue/computedValue.repository.d.ts +8 -5
- package/dist/src/modules/v4/computedValue/computedValue.repository.js +7 -3
- package/dist/src/modules/v4/computedValue/computedValue.service.d.ts +7 -4
- package/dist/src/modules/v4/computedValue/computedValue.service.js +10 -0
- package/dist/src/modules/v4/creator/creator.controller.d.ts +118 -0
- package/dist/src/modules/v4/creator/creator.controller.js +30 -0
- package/dist/src/modules/v4/creator/creator.model.d.ts +29 -0
- package/dist/src/modules/v4/creator/creator.model.js +18 -0
- package/dist/src/modules/v4/creator/creator.repository.d.ts +40 -0
- package/dist/src/modules/v4/creator/creator.repository.js +63 -0
- package/dist/src/modules/v4/creator/creator.service.d.ts +61 -0
- package/dist/src/modules/v4/creator/creator.service.js +44 -0
- package/dist/src/modules/v4/creator/index.d.ts +3 -0
- package/dist/src/modules/v4/creator/index.js +3 -0
- package/dist/src/modules/v4/dynamicData/dynamicData.controller.d.ts +3 -4
- package/dist/src/modules/v4/dynamicData/dynamicData.controller.js +1 -1
- package/dist/src/modules/v4/dynamicData/dynamicData.model.d.ts +1 -0
- package/dist/src/modules/v4/dynamicData/dynamicData.model.js +1 -0
- package/dist/src/modules/v4/dynamicData/dynamicData.service.d.ts +6 -3
- package/dist/src/modules/v4/dynamicData/dynamicData.service.js +50 -9
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +171 -1
- package/dist/src/modules/v4/opportunity/opportunity.controller.js +14 -0
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +0 -1
- package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +185 -0
- package/dist/src/modules/v4/opportunity/opportunity.repository.js +41 -0
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +151 -1
- package/dist/src/modules/v4/opportunity/opportunity.service.js +45 -2
- package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.d.ts +1 -1
- package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.js +2 -2
- package/dist/src/modules/v4/programPayload/programPayload.controller.d.ts +30 -0
- package/dist/src/modules/v4/programPayload/programPayload.controller.js +12 -1
- package/dist/src/modules/v4/programPayload/programPayload.model.d.ts +21 -1
- package/dist/src/modules/v4/programPayload/programPayload.model.js +12 -0
- package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +3 -2
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +28 -2
- package/dist/src/modules/v4/programPayload/programPayload.service.d.ts +2 -1
- package/dist/src/modules/v4/programPayload/programPayload.service.js +42 -2
- package/dist/src/modules/v4/protocol/protocol.controller.d.ts +1 -0
- package/dist/src/modules/v4/protocol/protocol.model.d.ts +1 -0
- package/dist/src/modules/v4/protocol/protocol.model.js +1 -0
- package/dist/src/modules/v4/reward/reward.repository.d.ts +2 -1
- package/dist/src/modules/v4/reward/reward.repository.js +12 -1
- package/dist/src/modules/v4/reward/reward.service.js +5 -2
- package/dist/src/modules/v4/router.d.ts +432 -5
- package/dist/src/modules/v4/router.js +5 -1
- package/dist/src/modules/v4/user/user.controller.d.ts +28 -0
- package/dist/src/modules/v4/user/user.controller.js +5 -0
- package/dist/src/modules/v4/user/user.repository.d.ts +5 -0
- package/dist/src/modules/v4/user/user.service.d.ts +5 -0
- package/dist/src/utils/decodeCalls.js +7 -1
- package/dist/src/utils/encodeCalls.js +19 -1
- package/dist/src/utils/generateCardName.js +3 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +6 -2
- package/dist/src/jobs/breakdowns.d.ts +0 -1
- package/dist/src/jobs/breakdowns.js +0 -55
- package/dist/src/jobs/rewards.d.ts +0 -1
- package/dist/src/jobs/rewards.js +0 -74
@@ -1,11 +1,12 @@
|
|
1
1
|
import { NotFoundError } from "../../../errors";
|
2
|
-
import { CampaignService, campaignTypeToEnumMap } from "../campaign";
|
2
|
+
import { CampaignService, campaignTypeToEnumMap, } from "../campaign";
|
3
3
|
import { log } from "../../../utils/logger";
|
4
4
|
import { OpportunityAction, Prisma, Status } from "../../../../database/api/.generated";
|
5
5
|
import { record } from "@elysiajs/opentelemetry";
|
6
6
|
import moment from "moment";
|
7
7
|
import { CacheService } from "../cache";
|
8
8
|
import { TTLPresets } from "../cache/cache.model";
|
9
|
+
import { CampaignRepository } from "../campaign/campaign.repository";
|
9
10
|
import { TokenService } from "../token";
|
10
11
|
import { UserService } from "../user";
|
11
12
|
import { OpportunityRepository } from "./opportunity.repository";
|
@@ -95,6 +96,30 @@ export class OpportunityService {
|
|
95
96
|
throw "UNKNOWN CAMPAIGN TYPE";
|
96
97
|
}
|
97
98
|
}
|
99
|
+
static async fakeCreateFromCampaign(campaign) {
|
100
|
+
const campaignType = CampaignService.getTypeFromV3(campaign.type);
|
101
|
+
const metadata = await OpportunityService.#getMetadata(campaign);
|
102
|
+
metadata.tags = [...((await UserService.findUnique(campaign.creator))?.tags ?? []), ...(campaign?.tags ?? [])];
|
103
|
+
const opportunityId = OpportunityService.hashId({
|
104
|
+
chainId: campaign.computeChainId,
|
105
|
+
identifier: campaign.opportunityIdentifier,
|
106
|
+
type: campaignType,
|
107
|
+
});
|
108
|
+
const params = JSON.parse(campaign.params);
|
109
|
+
const opportunity = {
|
110
|
+
id: opportunityId,
|
111
|
+
chainId: campaign.computeChainId,
|
112
|
+
type: campaignType,
|
113
|
+
identifier: campaign.opportunityIdentifier, // mainParameter
|
114
|
+
name: metadata.name,
|
115
|
+
status: Status.SOON,
|
116
|
+
action: metadata.action,
|
117
|
+
mainProtocol: metadata.mainProtocol,
|
118
|
+
depositUrl: !!params.url ? params.url : undefined,
|
119
|
+
tags: metadata.tags,
|
120
|
+
};
|
121
|
+
return opportunity;
|
122
|
+
}
|
98
123
|
static async createFromCampaign(campaign, upsert = false) {
|
99
124
|
const campaignType = CampaignService.getTypeFromV3(campaign.type);
|
100
125
|
const metadata = await OpportunityService.#getMetadata(campaign);
|
@@ -172,6 +197,21 @@ export class OpportunityService {
|
|
172
197
|
throw err;
|
173
198
|
}
|
174
199
|
}
|
200
|
+
/**
|
201
|
+
* Finds opportunities based on filters of its campaigns
|
202
|
+
* @notice campaigns are filtered as well
|
203
|
+
* @param where
|
204
|
+
* @returns opportunities
|
205
|
+
*/
|
206
|
+
static async getManyByCampaigns(where) {
|
207
|
+
const opportunities = await OpportunityRepository.findManyByCampaigns(CampaignRepository.transformQueryToPrismaFilters(where).where);
|
208
|
+
const formatted = opportunities.map(({ Campaigns, ...o }) => {
|
209
|
+
const opportunity = OpportunityService.formatResponse(o);
|
210
|
+
const campaigns = Campaigns.map(CampaignService.format);
|
211
|
+
return Object.assign(opportunity, { campaigns });
|
212
|
+
});
|
213
|
+
return formatted;
|
214
|
+
}
|
175
215
|
static async getUniqueWithCampaignsOrThrow(opportunityId, withTest = false) {
|
176
216
|
const id = typeof opportunityId === "string" ? opportunityId : OpportunityService.hashId(opportunityId);
|
177
217
|
const { Campaigns, ...opportunity } = await OpportunityRepository.findUniqueOrThrowWithCampaigns(id, withTest);
|
@@ -257,7 +297,10 @@ export class OpportunityService {
|
|
257
297
|
};
|
258
298
|
}
|
259
299
|
static formatResponseBase(opportunity) {
|
260
|
-
|
300
|
+
let { mainProtocolId, id, Tokens, Chain, Protocols, MainProtocol, ...opp } = opportunity;
|
301
|
+
if (mainProtocolId === "unknown") {
|
302
|
+
MainProtocol = null;
|
303
|
+
}
|
261
304
|
return {
|
262
305
|
...opp,
|
263
306
|
id,
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import type { ChainId, HyperDriveLogCampaign } from "@sdk";
|
2
2
|
import type { OpportunityMetadata } from "../opportunity.model";
|
3
|
-
export declare const getHyperdriveMetadata: (chainId: ChainId, campaignSubType: HyperDriveLogCampaign["campaignSubType"], params: HyperDriveLogCampaign["campaignParameters"]) =>
|
3
|
+
export declare const getHyperdriveMetadata: (chainId: ChainId, campaignSubType: HyperDriveLogCampaign["campaignSubType"], params: HyperDriveLogCampaign["campaignParameters"]) => OpportunityMetadata;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
export const getHyperdriveMetadata =
|
2
|
+
export const getHyperdriveMetadata = (chainId, campaignSubType, params) => {
|
3
3
|
const subtypes = [
|
4
|
-
{ name: "Add Liquidity on", action: OpportunityAction.
|
4
|
+
{ name: "Add Liquidity on", action: OpportunityAction.POOL },
|
5
5
|
{ name: "Open Long on", action: OpportunityAction.LONG },
|
6
6
|
{ name: "Open Short on", action: OpportunityAction.SHORT },
|
7
7
|
];
|
@@ -242,6 +242,36 @@ export declare const ProgramPayloadController: Elysia<"/program-payload", false,
|
|
242
242
|
};
|
243
243
|
};
|
244
244
|
};
|
245
|
+
} & {
|
246
|
+
"program-payload": {
|
247
|
+
parse: {
|
248
|
+
"from-campaign-data": {
|
249
|
+
post: {
|
250
|
+
body: {
|
251
|
+
chainId: number;
|
252
|
+
startTimestamp: number;
|
253
|
+
endTimestamp: number;
|
254
|
+
computeChainId: number;
|
255
|
+
amount: string;
|
256
|
+
rewardToken: string;
|
257
|
+
campaignType: number;
|
258
|
+
campaignData: string;
|
259
|
+
symbolRewardToken: string;
|
260
|
+
decimalsRewardToken: number;
|
261
|
+
};
|
262
|
+
params: {};
|
263
|
+
query: unknown;
|
264
|
+
headers: {
|
265
|
+
authorization: string;
|
266
|
+
};
|
267
|
+
response: {
|
268
|
+
[x: string]: any;
|
269
|
+
200: any;
|
270
|
+
};
|
271
|
+
};
|
272
|
+
};
|
273
|
+
};
|
274
|
+
};
|
245
275
|
}, {
|
246
276
|
derive: {};
|
247
277
|
resolve: {};
|
@@ -1,7 +1,8 @@
|
|
1
|
+
import { AuthorizationHeadersDto, BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
1
2
|
// import { AuthorizationHeadersDto, BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
2
3
|
import Elysia, { t } from "elysia";
|
3
4
|
import { throwOnUnsupportedChainId } from "src/utils/throw";
|
4
|
-
import { CampaignAmountsInputDto, CampaignPayloadInputDto, ProgramPayloadInputDto, SinglePayloadInputDto, } from "./programPayload.model";
|
5
|
+
import { CampaignAmountsInputDto, CampaignDataDto, CampaignPayloadInputDto, ProgramPayloadInputDto, SinglePayloadInputDto, } from "./programPayload.model";
|
5
6
|
import { ProgramPayloadService } from "./programPayload.service";
|
6
7
|
// ─── ProgramPaylod Controller ───────────────────────────────────────────────────────
|
7
8
|
export const ProgramPayloadController = new Elysia({ prefix: "/program-payload", detail: { tags: ["ProgramPayload"] } })
|
@@ -71,4 +72,14 @@ export const ProgramPayloadController = new Elysia({ prefix: "/program-payload",
|
|
71
72
|
query: t.Object({ debug: t.Optional(t.Boolean({ description: "Debug mode" })) }),
|
72
73
|
body: SinglePayloadInputDto,
|
73
74
|
detail: { description: "BETA FEATURE : Generate the payload from a config file." },
|
75
|
+
})
|
76
|
+
.post("/parse/from-campaign-data", async ({ body }) => {
|
77
|
+
return ProgramPayloadService.buildConfigFromCampaignData(body);
|
78
|
+
}, {
|
79
|
+
headers: AuthorizationHeadersDto,
|
80
|
+
body: CampaignDataDto,
|
81
|
+
beforeHandle: ({ headers }) => {
|
82
|
+
BackOfficeGuard({ headers });
|
83
|
+
},
|
84
|
+
detail: { hide: true },
|
74
85
|
});
|
@@ -9,6 +9,18 @@ export declare const CampaignPayloadInputDto: import("@sinclair/typebox").TObjec
|
|
9
9
|
endTimestamp: import("@sinclair/typebox").TNumber;
|
10
10
|
amount: import("@sinclair/typebox").TString;
|
11
11
|
}>;
|
12
|
+
export declare const CampaignDataDto: import("@sinclair/typebox").TObject<{
|
13
|
+
campaignType: import("@sinclair/typebox").TNumber;
|
14
|
+
campaignData: import("@sinclair/typebox").TString;
|
15
|
+
amount: import("@sinclair/typebox").TString;
|
16
|
+
chainId: import("@sinclair/typebox").TNumber;
|
17
|
+
computeChainId: import("@sinclair/typebox").TNumber;
|
18
|
+
endTimestamp: import("@sinclair/typebox").TNumber;
|
19
|
+
rewardToken: import("@sinclair/typebox").TString;
|
20
|
+
startTimestamp: import("@sinclair/typebox").TNumber;
|
21
|
+
symbolRewardToken: import("@sinclair/typebox").TString;
|
22
|
+
decimalsRewardToken: import("@sinclair/typebox").TNumber;
|
23
|
+
}>;
|
12
24
|
export declare const SinglePayloadInputDto: import("@sinclair/typebox").TObject<{
|
13
25
|
distributionChainId: import("@sinclair/typebox").TNumber;
|
14
26
|
rewardToken: import("@sinclair/typebox").TString;
|
@@ -58,6 +70,7 @@ export type CampaignPayloadInputModel = typeof CampaignPayloadInputDto.static;
|
|
58
70
|
export type ProgramPayloadInputModel = typeof ProgramPayloadInputDto.static;
|
59
71
|
export type CampaignAmountsInputModel = typeof CampaignAmountsInputDto.static;
|
60
72
|
export type SinglePayloadInputDtoModel = typeof SinglePayloadInputDto.static;
|
73
|
+
export type CampaignDataDtoModel = typeof CampaignDataDto.static;
|
61
74
|
export type approvalTransaction = {
|
62
75
|
to: string;
|
63
76
|
value: string;
|
@@ -179,7 +192,14 @@ export type partialConfigIonic = {
|
|
179
192
|
blacklist: string[];
|
180
193
|
forwarders: string[];
|
181
194
|
};
|
182
|
-
export type
|
195
|
+
export type partialConfigAirdrop = {
|
196
|
+
jsonUrl: string;
|
197
|
+
url?: string;
|
198
|
+
computeChainId?: MerklChainId;
|
199
|
+
hooks?: (HookParameters<HOOK> | string)[];
|
200
|
+
campaignType: Campaign;
|
201
|
+
};
|
202
|
+
export type partialConfig = partialConfigERC20 | partialConfigMorpho | partialConfigCLAMM | partialConfigIonic | partialConfigAirdrop;
|
183
203
|
export declare const safeTemplate: {
|
184
204
|
version: string;
|
185
205
|
chainId: string;
|
@@ -10,6 +10,18 @@ export const CampaignPayloadInputDto = t.Object({
|
|
10
10
|
endTimestamp: t.Numeric({ description: "End timestamp for the campaign" }),
|
11
11
|
amount: t.String({ description: "Amount of the reward token to be distributed" }),
|
12
12
|
});
|
13
|
+
export const CampaignDataDto = t.Object({
|
14
|
+
campaignType: t.Numeric({ description: "Type of the campaign 1 : ERC20, 2: CLAMM , ..." }),
|
15
|
+
campaignData: t.String({ description: "Campaign data" }),
|
16
|
+
amount: t.String({ description: "Amount of the reward token to be distributed" }),
|
17
|
+
chainId: t.Numeric({ description: "Chain ID where the reward tokens will be distributed" }),
|
18
|
+
computeChainId: t.Numeric({ description: "Chain ID used for computation" }),
|
19
|
+
endTimestamp: t.Numeric({ description: "End timestamp for the campaign" }),
|
20
|
+
rewardToken: t.String({ description: "Address of the reward token to be distributed" }),
|
21
|
+
startTimestamp: t.Numeric({ description: "Start timestamp for the campaign" }),
|
22
|
+
symbolRewardToken: t.String({ description: "Symbol of the reward token" }),
|
23
|
+
decimalsRewardToken: t.Numeric({ description: "Decimals of the reward token" }),
|
24
|
+
});
|
13
25
|
export const SinglePayloadInputDto = t.Object({
|
14
26
|
distributionChainId: t.Numeric({ description: "Chain ID where the reward tokens will be distributed" }),
|
15
27
|
rewardToken: t.String({ description: "Address of the reward token to be distributed" }),
|
@@ -35,7 +35,7 @@ export declare enum pufferCampaigns {
|
|
35
35
|
venus_pufeth = "0xE0ee5dDeBFe0abe0a4Af50299D68b74Cec31668e",
|
36
36
|
unifiBTC = "0x170D847A8320F3B6A77eE15B0CAE430e3eC933a0",
|
37
37
|
unifiUSD = "0x82c40e07277eBb92935f79cE92268F80dDc7caB4",
|
38
|
-
CARROT_USDC = "
|
38
|
+
CARROT_USDC = "0xf00032d0F95e8f43E750C51d0188DCa33cC5a8eA"
|
39
39
|
}
|
40
40
|
export declare enum zkSyncCampaigns {
|
41
41
|
Izumi_Finance_Zk_Weth = "Izumi Finance ZK/WETH 0xd62bc9f19bd94fde9c41df4b6eb6419ea6b8e25c",
|
@@ -112,7 +112,8 @@ export declare enum zkSyncCampaigns {
|
|
112
112
|
ZKSwap_ETH_USDCe_20 = "ZKSwap Finance ETH/USDC v3 0.2pct 0x6480665e22d82b3b9079b44e421a62c185b9bd77",
|
113
113
|
ZKSwap_wstETH_ETH_20 = "ZKSwap Finance wstETH/ETH v3 0.01pct 0xd587b615ac1acb6c1f95242a1bcac512d2cd8122",
|
114
114
|
ZKSwap_wrsETH_ETH_20 = "ZKSwap Finance wrsETH/ETH v3 0.01pct 0xcd6d8b89f24b017dbbdc0c13a99d29edc13e2189",
|
115
|
-
ZKSwap_ZF_ETH = "ZKSwap Finance ZF/ETH v2 0.1pct ZKSwap Finance ZF/ETH v2 0xd33a17c883d5aa79470cd2522abb213dc4017e01"
|
115
|
+
ZKSwap_ZF_ETH = "ZKSwap Finance ZF/ETH v2 0.1pct ZKSwap Finance ZF/ETH v2 0xd33a17c883d5aa79470cd2522abb213dc4017e01",
|
116
|
+
raffle_jumper = "raffle jumper"
|
116
117
|
}
|
117
118
|
export declare enum modeCampaigns {
|
118
119
|
Steer_EES_V2_Weth_USDC_Kim_Mode = "SteerEESV2 Kim WETH/USDC 0x468cc91df6f669cae6cdce766995bd7874052fbc",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BalanceCallType, Campaign, ChainId, CompFork, CompoundSubCampaignType, Forwarder, MorphoSubCampaignType, StandardType, } from "@sdk";
|
1
|
+
import { BalanceCallType, Campaign, ChainId, CompFork, CompoundSubCampaignType, Forwarder, HOOK, MorphoSubCampaignType, StandardType, selectionRaffleMethod, } from "@sdk";
|
2
2
|
export var program;
|
3
3
|
(function (program) {
|
4
4
|
program["Puffer"] = "Puffer";
|
@@ -37,7 +37,7 @@ export var pufferCampaigns;
|
|
37
37
|
pufferCampaigns["venus_pufeth"] = "0xE0ee5dDeBFe0abe0a4Af50299D68b74Cec31668e";
|
38
38
|
pufferCampaigns["unifiBTC"] = "0x170D847A8320F3B6A77eE15B0CAE430e3eC933a0";
|
39
39
|
pufferCampaigns["unifiUSD"] = "0x82c40e07277eBb92935f79cE92268F80dDc7caB4";
|
40
|
-
pufferCampaigns["CARROT_USDC"] = "
|
40
|
+
pufferCampaigns["CARROT_USDC"] = "0xf00032d0F95e8f43E750C51d0188DCa33cC5a8eA";
|
41
41
|
})(pufferCampaigns || (pufferCampaigns = {}));
|
42
42
|
export var zkSyncCampaigns;
|
43
43
|
(function (zkSyncCampaigns) {
|
@@ -116,6 +116,7 @@ export var zkSyncCampaigns;
|
|
116
116
|
zkSyncCampaigns["ZKSwap_wstETH_ETH_20"] = "ZKSwap Finance wstETH/ETH v3 0.01pct 0xd587b615ac1acb6c1f95242a1bcac512d2cd8122";
|
117
117
|
zkSyncCampaigns["ZKSwap_wrsETH_ETH_20"] = "ZKSwap Finance wrsETH/ETH v3 0.01pct 0xcd6d8b89f24b017dbbdc0c13a99d29edc13e2189";
|
118
118
|
zkSyncCampaigns["ZKSwap_ZF_ETH"] = "ZKSwap Finance ZF/ETH v2 0.1pct ZKSwap Finance ZF/ETH v2 0xd33a17c883d5aa79470cd2522abb213dc4017e01";
|
119
|
+
zkSyncCampaigns["raffle_jumper"] = "raffle jumper";
|
119
120
|
})(zkSyncCampaigns || (zkSyncCampaigns = {}));
|
120
121
|
export var modeCampaigns;
|
121
122
|
(function (modeCampaigns) {
|
@@ -1133,6 +1134,24 @@ const ModeInterfaceCampaigns = {
|
|
1133
1134
|
},
|
1134
1135
|
};
|
1135
1136
|
const ZkSyncInterfaceCampaigns = {
|
1137
|
+
[zkSyncCampaigns.raffle_jumper]: {
|
1138
|
+
campaignType: Campaign.JSON_AIRDROP,
|
1139
|
+
computeChainId: ChainId.ZKSYNC,
|
1140
|
+
hooks: [
|
1141
|
+
{
|
1142
|
+
hookType: HOOK.RAFFLE,
|
1143
|
+
resolutionIndex: 0,
|
1144
|
+
selectionMethod: selectionRaffleMethod.RANDOM,
|
1145
|
+
numberOfWinners: 5,
|
1146
|
+
multipleWinningPossible: false,
|
1147
|
+
weightIncreasesRewards: false,
|
1148
|
+
weightedSelection: true,
|
1149
|
+
blacklistWinnersFromRounds: [],
|
1150
|
+
weightOfTotalRewards: 10000000,
|
1151
|
+
},
|
1152
|
+
],
|
1153
|
+
jsonUrl: "https://angle-blog.infura-ipfs.io/ipfs/QmRgF8gpSsJCTHXxmjY53f4tfMxWTaZFmPyw55xCRen6YN",
|
1154
|
+
},
|
1136
1155
|
[zkSyncCampaigns.Vest_USDC]: {
|
1137
1156
|
campaignType: Campaign.VEST,
|
1138
1157
|
computeChainId: ChainId.ZKSYNC,
|
@@ -2345,12 +2364,19 @@ const PufferInterfaceCampaigns = {
|
|
2345
2364
|
targetToken: "0xD9A442856C234a39a81a089C06451EBAa4306a72",
|
2346
2365
|
whitelist: [],
|
2347
2366
|
blacklist: [
|
2367
|
+
"0x1f2aa9680910aC5a4527FA72001dC249943f60b4",
|
2348
2368
|
"0xF047ab4c75cebf0eB9ed34Ae2c186f3611aEAfa6",
|
2349
2369
|
"0x68754d29f2e97B837Cb622ccfF325adAC27E9977",
|
2350
2370
|
"0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
2351
2371
|
"0x18eeD20f71BEf84B605253C89A7576E3634134C0",
|
2352
2372
|
"0x196ead472583Bc1e9aF7A05F860D9857e1Bd3dCc",
|
2353
2373
|
"0x253008ba4aE2f3E6488DC998a5321D4EB1a0c905",
|
2374
|
+
"0xEEda34A377dD0ca676b9511EE1324974fA8d980D",
|
2375
|
+
"0x39F5b252dE249790fAEd0C2F05aBead56D2088e1",
|
2376
|
+
"0xdD7Afc0f014A1E1716307Ff040704fA12E8D33A3",
|
2377
|
+
"0x1a33B9be3Fe58C1Bde4325A68c09C1F7fA8aA1e5",
|
2378
|
+
"0xBDB04e915B94FbFD6e8552ff7860E59Db7d4499a",
|
2379
|
+
"0xE0ee5dDeBFe0abe0a4Af50299D68b74Cec31668e",
|
2354
2380
|
],
|
2355
2381
|
url: "https://etherscan.io/token/0xd9a442856c234a39a81a089c06451ebaa4306a72",
|
2356
2382
|
forwarders: [],
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type Campaign, ChainId, type campaignConfig } from "@sdk";
|
2
2
|
import type { CampaignParametersStruct } from "libs/sdk/src/generated/CampaignCreator";
|
3
|
-
import { type CampaignAmountsInputModel, type CampaignPayloadInputModel, type ProgramPayloadInputModel, type SinglePayloadInputDtoModel, type approvalTransaction, type createCampaignTransaction, type safePayload } from "./programPayload.model";
|
3
|
+
import { type CampaignAmountsInputModel, type CampaignDataDtoModel, type CampaignPayloadInputModel, type ProgramPayloadInputModel, type SinglePayloadInputDtoModel, type approvalTransaction, type createCampaignTransaction, type safePayload } from "./programPayload.model";
|
4
4
|
export declare class ProgramPayloadService {
|
5
5
|
static buildConfigTemplate(params: {
|
6
6
|
campaignType: number;
|
@@ -21,4 +21,5 @@ export declare class ProgramPayloadService {
|
|
21
21
|
static buildPayload(query: CampaignPayloadInputModel, initialCampaignPayload?: safePayload | null, totalAmount?: string): safePayload;
|
22
22
|
static buildProgramPayload(query: ProgramPayloadInputModel): safePayload | null;
|
23
23
|
static buildProgramPayloadWithAmounts(query: ProgramPayloadInputModel, body: CampaignAmountsInputModel): safePayload | null;
|
24
|
+
static buildConfigFromCampaignData(body: CampaignDataDtoModel): Promise<any>;
|
24
25
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CampaignTypeConfigResourceMapping, ChainId, NULL_ADDRESS, NULL_ROOT, buildCampaignPayload, encodeForwarderData, registry, } from "@sdk";
|
1
|
+
import { CampaignTypeConfigResourceMapping, ChainId, NULL_ADDRESS, NULL_ROOT, ParserService, buildCampaignPayload, encodeForwarderData, registry, } from "@sdk";
|
2
2
|
import _ from "lodash";
|
3
3
|
import { safeTemplate, } from "./programPayload.model";
|
4
4
|
import { MerklInterfaceCampaigns } from "./programPayload.repository";
|
@@ -102,7 +102,7 @@ export class ProgramPayloadService {
|
|
102
102
|
}
|
103
103
|
return [safePayload.transactions[2]];
|
104
104
|
}
|
105
|
-
static initiateSafePayload(distributionChainId, distributionCreator, rewardToken, approvalAmount = "
|
105
|
+
static initiateSafePayload(distributionChainId, distributionCreator, rewardToken, approvalAmount = "0") {
|
106
106
|
const safePayload = _.cloneDeep(safeTemplate);
|
107
107
|
safePayload.chainId = distributionChainId.toString();
|
108
108
|
safePayload.createdAt = Math.floor(Date.now() / 1000);
|
@@ -117,6 +117,17 @@ export class ProgramPayloadService {
|
|
117
117
|
}
|
118
118
|
else
|
119
119
|
safePayload.transactions = [safePayload.transactions[1]];
|
120
|
+
const wrapperContract = "0x8A5A5DE9db5770123Ff2145F59e9F20047f0A8EC";
|
121
|
+
if (rewardToken === wrapperContract && approvalAmount !== "0") {
|
122
|
+
const secondarySafePayload = _.cloneDeep(safeTemplate);
|
123
|
+
const underlying = "0x282A69142bac47855C3fbE1693FcC4bA3B4d5Ed6";
|
124
|
+
secondarySafePayload.transactions[0].to = underlying;
|
125
|
+
secondarySafePayload.transactions[0].contractInputsValues = {
|
126
|
+
amount: approvalAmount,
|
127
|
+
spender: wrapperContract,
|
128
|
+
};
|
129
|
+
safePayload.transactions.push(secondarySafePayload.transactions[0]);
|
130
|
+
}
|
120
131
|
return safePayload;
|
121
132
|
}
|
122
133
|
static buildPayload(query, initialCampaignPayload = null, totalAmount = "0") {
|
@@ -164,4 +175,33 @@ export class ProgramPayloadService {
|
|
164
175
|
}
|
165
176
|
return campaignPayloads;
|
166
177
|
}
|
178
|
+
static async buildConfigFromCampaignData(body) {
|
179
|
+
const parser = ParserService(body.campaignType);
|
180
|
+
const base = {
|
181
|
+
amount: body.amount,
|
182
|
+
campaignId: "0xdefaultId",
|
183
|
+
campaignSubType: 0,
|
184
|
+
campaignType: body.campaignType,
|
185
|
+
chainId: body.chainId,
|
186
|
+
computeChainId: body.computeChainId,
|
187
|
+
creator: "Oxcreator",
|
188
|
+
endTimestamp: body.endTimestamp,
|
189
|
+
index: 0,
|
190
|
+
mainParameter: " ".repeat(42),
|
191
|
+
rewardToken: body.rewardToken,
|
192
|
+
startTimestamp: body.startTimestamp,
|
193
|
+
};
|
194
|
+
try {
|
195
|
+
console.log("Parsing campaign data");
|
196
|
+
const res = await parser.parse(body.chainId, body.symbolRewardToken, body.decimalsRewardToken, base, body.campaignData);
|
197
|
+
if (res.success) {
|
198
|
+
return res;
|
199
|
+
}
|
200
|
+
throw res.message;
|
201
|
+
}
|
202
|
+
catch (e) {
|
203
|
+
console.error(e);
|
204
|
+
throw e;
|
205
|
+
}
|
206
|
+
}
|
167
207
|
}
|
@@ -30,6 +30,7 @@ export declare const UpdateProtocolDto: import("@sinclair/typebox").TObject<{
|
|
30
30
|
icon: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
31
31
|
url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
32
32
|
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
33
|
+
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
33
34
|
}>;
|
34
35
|
export declare const CreateProtocolDto: import("@sinclair/typebox").TObject<{
|
35
36
|
icon: import("@sinclair/typebox").TString;
|
@@ -95,6 +95,7 @@ export const UpdateProtocolDto = t.Object({
|
|
95
95
|
icon: t.Optional(t.String({ format: "uri" })),
|
96
96
|
url: t.Optional(t.String({ format: "uri" })),
|
97
97
|
description: t.Optional(t.String()),
|
98
|
+
name: t.Optional(t.String()),
|
98
99
|
// iconFile: t.Optional(t.File()),
|
99
100
|
});
|
100
101
|
export const CreateProtocolDto = t.Object({
|
@@ -125,7 +125,8 @@ export declare abstract class RewardRepository {
|
|
125
125
|
rewardCount: number;
|
126
126
|
breakdownCount: number;
|
127
127
|
}>;
|
128
|
-
static
|
128
|
+
static updateRewardClaimed(recipient: string, rewardTokenId: string, amount: string): Promise<Prisma.BatchPayload>;
|
129
|
+
static updateBreakdownClaimed(recipient: string, rewardTokenId: string, campaignId: string, reason: string, amount: string): Promise<Prisma.BatchPayload>;
|
129
130
|
static findManyBreakdownUniques(uniques: {
|
130
131
|
rewardId: string;
|
131
132
|
campaignId: string;
|
@@ -136,7 +136,18 @@ export class RewardRepository {
|
|
136
136
|
});
|
137
137
|
return { rewardCount, breakdownCount };
|
138
138
|
}
|
139
|
-
static async
|
139
|
+
static async updateRewardClaimed(recipient, rewardTokenId, amount) {
|
140
|
+
return await apiDbClient.reward.updateMany({
|
141
|
+
where: {
|
142
|
+
recipient,
|
143
|
+
rewardTokenId,
|
144
|
+
},
|
145
|
+
data: {
|
146
|
+
claimed: amount,
|
147
|
+
},
|
148
|
+
});
|
149
|
+
}
|
150
|
+
static async updateBreakdownClaimed(recipient, rewardTokenId, campaignId, reason, amount) {
|
140
151
|
return await apiDbClient.rewardBreakdown.updateMany({
|
141
152
|
where: {
|
142
153
|
campaignId,
|
@@ -41,8 +41,8 @@ export class RewardService {
|
|
41
41
|
static format(rewards) {
|
42
42
|
return rewards.map(reward => {
|
43
43
|
const { Breakdown, RewardToken, id, rewardTokenId, ...rest } = reward;
|
44
|
-
const claimed = Breakdown.reduce((sum, { claimed }) => sum + BigInt(claimed), 0n);
|
45
44
|
const pending = Breakdown.reduce((sum, { pending }) => sum + BigInt(pending), 0n);
|
45
|
+
const claimed = Breakdown.reduce((sum, { claimed }) => sum + BigInt(claimed), 0n);
|
46
46
|
return {
|
47
47
|
...rest,
|
48
48
|
token: RewardToken,
|
@@ -148,6 +148,7 @@ export class RewardService {
|
|
148
148
|
const merklRootClaimedOn = claims[index].merkleRoot;
|
149
149
|
// -> claim is on the current root (chainData.merklRoot) -> claimed === accumulated
|
150
150
|
if (merklRootClaimedOn === roots.live) {
|
151
|
+
reward.claimed = reward.amount;
|
151
152
|
for (const breakdown of reward.Breakdown) {
|
152
153
|
if (BigInt(breakdown.claimed) === BigInt(breakdown.amount))
|
153
154
|
continue;
|
@@ -160,6 +161,7 @@ export class RewardService {
|
|
160
161
|
const lastTreeRewards = await RewardRepository.getByChainRecipientToken(user, merklRootClaimedOn, TokenService.hashId(reward.RewardToken));
|
161
162
|
if (!lastTreeRewards)
|
162
163
|
continue;
|
164
|
+
reward.claimed = lastTreeRewards.amount;
|
163
165
|
for (const breakdown of reward.Breakdown) {
|
164
166
|
const lastTreeRewardsBreakdown = lastTreeRewards.Breakdown.find(lastTreeBreakdown => lastTreeBreakdown.reason === breakdown.reason &&
|
165
167
|
lastTreeBreakdown.Campaign.campaignId === breakdown.Campaign.campaignId);
|
@@ -227,8 +229,9 @@ export class RewardService {
|
|
227
229
|
const rewards = await RewardRepository.getByChainRecipientToken(claim.recipient, claim.root, tokenId);
|
228
230
|
if (!rewards)
|
229
231
|
continue;
|
232
|
+
await RewardRepository.updateRewardClaimed(claim.recipient, tokenId, rewards.amount);
|
230
233
|
for (const breakdown of rewards.Breakdown) {
|
231
|
-
await RewardRepository.
|
234
|
+
await RewardRepository.updateBreakdownClaimed(claim.recipient, tokenId, breakdown.campaignId, breakdown.reason, breakdown.amount);
|
232
235
|
}
|
233
236
|
}
|
234
237
|
}
|