@merkl/api 0.20.51 → 0.20.53
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 +5 -3
- package/dist/src/eden/index.d.ts +1169 -976
- package/dist/src/engine/dynamicData/factory.js +6 -0
- package/dist/src/engine/dynamicData/implementations/Erc20.d.ts +2 -2
- package/dist/src/engine/dynamicData/implementations/Erc20.js +16 -2
- package/dist/src/engine/dynamicData/implementations/UniswapV4.js +1 -1
- package/dist/src/engine/erc20SubTypeProcessors/helpers/tokenType.d.ts +2 -1
- package/dist/src/engine/erc20SubTypeProcessors/helpers/tokenType.js +5 -0
- package/dist/src/engine/erc20SubTypeProcessors/implementations/processorMapping.js +1 -0
- package/dist/src/engine/erc20SubTypeProcessors/subtypesRound1.js +2 -0
- package/dist/src/engine/opportunityMetadata/factory.js +6 -0
- package/dist/src/engine/opportunityMetadata/implementations/Erc20.js +1 -1
- package/dist/src/index.d.ts +246 -185
- package/dist/src/jobs/update-uniswap-v4-pools.js +3 -2
- package/dist/src/modules/v4/accounting/accounting.repository.js +72 -18
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +0 -169
- package/dist/src/modules/v4/campaign/campaign.controller.js +1 -65
- package/dist/src/modules/v4/campaign/campaign.test.controller.d.ts +193 -0
- package/dist/src/modules/v4/campaign/campaign.test.controller.js +71 -0
- package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +67 -2
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +67 -0
- package/dist/src/modules/v4/protocol/protocol.controller.d.ts +1 -1
- package/dist/src/modules/v4/protocol/protocol.controller.js +2 -2
- package/dist/src/modules/v4/protocol/protocol.repository.d.ts +1 -9
- package/dist/src/modules/v4/protocol/protocol.repository.js +1 -4
- package/dist/src/modules/v4/protocol/protocol.service.d.ts +1 -2
- package/dist/src/modules/v4/protocol/protocol.service.js +2 -6
- package/dist/src/modules/v4/router.d.ts +246 -185
- package/dist/src/modules/v4/router.js +2 -0
- package/dist/src/modules/v4/uniswap/uniswap.controller.d.ts +72 -15
- package/dist/src/modules/v4/uniswap/uniswap.controller.js +49 -6
- package/dist/src/modules/v4/uniswap/uniswap.model.d.ts +35 -16
- package/dist/src/modules/v4/uniswap/uniswap.model.js +22 -8
- package/dist/src/modules/v4/uniswap/uniswap.repository.d.ts +2 -2
- package/dist/src/modules/v4/uniswap/uniswap.repository.js +2 -2
- package/dist/src/modules/v4/uniswap/uniswap.service.d.ts +4 -19
- package/dist/src/modules/v4/uniswap/uniswap.service.js +20 -80
- package/dist/src/routes/v3/uniswapv4.js +5 -5
- package/dist/src/utils/decodeCalls.js +10 -1
- package/dist/src/utils/encodeCalls.js +3 -0
- package/dist/src/utils/generateCardName.js +5 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/dist/src/engine/dynamicData/utils/getUniswapV4Pools.d.ts +0 -10
- package/dist/src/engine/dynamicData/utils/getUniswapV4Pools.js +0 -188
@@ -14,9 +14,18 @@ export class AccountingRepository {
|
|
14
14
|
where: {
|
15
15
|
fromTokenId,
|
16
16
|
NOT: {
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
OR: [
|
18
|
+
{
|
19
|
+
recipient: {
|
20
|
+
equals: apiDbClient.dump.fields.multisig,
|
21
|
+
},
|
22
|
+
},
|
23
|
+
{
|
24
|
+
recipient: {
|
25
|
+
equals: "0xb08AB4332AD871F89da24df4751968A61e58013c",
|
26
|
+
},
|
27
|
+
},
|
28
|
+
],
|
20
29
|
},
|
21
30
|
},
|
22
31
|
});
|
@@ -38,9 +47,18 @@ export class AccountingRepository {
|
|
38
47
|
static async getForMultisigBetweenDates(startDate, endDate) {
|
39
48
|
return await apiDbClient.dump.findMany({
|
40
49
|
where: {
|
41
|
-
|
42
|
-
|
43
|
-
|
50
|
+
OR: [
|
51
|
+
{
|
52
|
+
recipient: {
|
53
|
+
equals: apiDbClient.dump.fields.multisig,
|
54
|
+
},
|
55
|
+
},
|
56
|
+
{
|
57
|
+
recipient: {
|
58
|
+
equals: "0xb08AB4332AD871F89da24df4751968A61e58013c",
|
59
|
+
},
|
60
|
+
},
|
61
|
+
],
|
44
62
|
datetime: {
|
45
63
|
gte: startDate,
|
46
64
|
lt: endDate,
|
@@ -51,9 +69,18 @@ export class AccountingRepository {
|
|
51
69
|
static async getForMultisig() {
|
52
70
|
return await apiDbClient.dump.findMany({
|
53
71
|
where: {
|
54
|
-
|
55
|
-
|
56
|
-
|
72
|
+
OR: [
|
73
|
+
{
|
74
|
+
recipient: {
|
75
|
+
equals: apiDbClient.dump.fields.multisig,
|
76
|
+
},
|
77
|
+
},
|
78
|
+
{
|
79
|
+
recipient: {
|
80
|
+
equals: "0xb08AB4332AD871F89da24df4751968A61e58013c",
|
81
|
+
},
|
82
|
+
},
|
83
|
+
],
|
57
84
|
},
|
58
85
|
});
|
59
86
|
}
|
@@ -61,9 +88,18 @@ export class AccountingRepository {
|
|
61
88
|
return await apiDbClient.dump.findMany({
|
62
89
|
where: {
|
63
90
|
chainId,
|
64
|
-
|
65
|
-
|
66
|
-
|
91
|
+
OR: [
|
92
|
+
{
|
93
|
+
recipient: {
|
94
|
+
equals: apiDbClient.dump.fields.multisig,
|
95
|
+
},
|
96
|
+
},
|
97
|
+
{
|
98
|
+
recipient: {
|
99
|
+
equals: "0xb08AB4332AD871F89da24df4751968A61e58013c",
|
100
|
+
},
|
101
|
+
},
|
102
|
+
],
|
67
103
|
},
|
68
104
|
});
|
69
105
|
}
|
@@ -75,9 +111,18 @@ export class AccountingRepository {
|
|
75
111
|
gte: startDate,
|
76
112
|
lte: endDate,
|
77
113
|
},
|
78
|
-
|
79
|
-
|
80
|
-
|
114
|
+
OR: [
|
115
|
+
{
|
116
|
+
recipient: {
|
117
|
+
equals: apiDbClient.dump.fields.multisig,
|
118
|
+
},
|
119
|
+
},
|
120
|
+
{
|
121
|
+
recipient: {
|
122
|
+
equals: "0xb08AB4332AD871F89da24df4751968A61e58013c",
|
123
|
+
},
|
124
|
+
},
|
125
|
+
],
|
81
126
|
},
|
82
127
|
});
|
83
128
|
}
|
@@ -90,9 +135,18 @@ export class AccountingRepository {
|
|
90
135
|
lte: endDate,
|
91
136
|
},
|
92
137
|
NOT: {
|
93
|
-
|
94
|
-
|
95
|
-
|
138
|
+
OR: [
|
139
|
+
{
|
140
|
+
recipient: {
|
141
|
+
equals: apiDbClient.dump.fields.multisig,
|
142
|
+
},
|
143
|
+
},
|
144
|
+
{
|
145
|
+
recipient: {
|
146
|
+
equals: "0xb08AB4332AD871F89da24df4751968A61e58013c",
|
147
|
+
},
|
148
|
+
},
|
149
|
+
],
|
96
150
|
},
|
97
151
|
},
|
98
152
|
});
|
@@ -165,175 +165,6 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
165
165
|
};
|
166
166
|
};
|
167
167
|
};
|
168
|
-
} & {
|
169
|
-
"dry-run": {
|
170
|
-
":campaignId": {
|
171
|
-
"dynamic-data": {
|
172
|
-
get: {
|
173
|
-
body: unknown;
|
174
|
-
params: {
|
175
|
-
campaignId: string;
|
176
|
-
};
|
177
|
-
query: unknown;
|
178
|
-
headers: {
|
179
|
-
authorization: string;
|
180
|
-
};
|
181
|
-
response: {
|
182
|
-
200: unknown[];
|
183
|
-
};
|
184
|
-
};
|
185
|
-
};
|
186
|
-
};
|
187
|
-
};
|
188
|
-
} & {
|
189
|
-
"dry-run": {
|
190
|
-
"dynamic-data": {
|
191
|
-
list: {
|
192
|
-
post: {
|
193
|
-
body: string[];
|
194
|
-
params: {};
|
195
|
-
query: unknown;
|
196
|
-
headers: {
|
197
|
-
authorization: string;
|
198
|
-
};
|
199
|
-
response: {
|
200
|
-
200: unknown[];
|
201
|
-
};
|
202
|
-
};
|
203
|
-
};
|
204
|
-
};
|
205
|
-
};
|
206
|
-
} & {
|
207
|
-
"dry-run": {
|
208
|
-
"dynamic-data": {
|
209
|
-
post: {
|
210
|
-
body: {
|
211
|
-
id?: string | undefined;
|
212
|
-
subType?: number | undefined;
|
213
|
-
campaignId?: string | undefined;
|
214
|
-
amount?: string | undefined;
|
215
|
-
creatorAddress?: string | undefined;
|
216
|
-
type: string;
|
217
|
-
params: any;
|
218
|
-
computeChainId: number;
|
219
|
-
distributionChainId: number;
|
220
|
-
startTimestamp: number;
|
221
|
-
endTimestamp: number;
|
222
|
-
rewardToken: string;
|
223
|
-
};
|
224
|
-
params: {};
|
225
|
-
query: unknown;
|
226
|
-
headers: {
|
227
|
-
authorization: string;
|
228
|
-
};
|
229
|
-
response: {
|
230
|
-
200: unknown[];
|
231
|
-
};
|
232
|
-
};
|
233
|
-
};
|
234
|
-
};
|
235
|
-
} & {
|
236
|
-
"dry-run": {
|
237
|
-
metadata: {
|
238
|
-
post: {
|
239
|
-
body: {
|
240
|
-
id?: string | undefined;
|
241
|
-
subType?: number | undefined;
|
242
|
-
campaignId?: string | undefined;
|
243
|
-
amount?: string | undefined;
|
244
|
-
creatorAddress?: string | undefined;
|
245
|
-
type: string;
|
246
|
-
params: any;
|
247
|
-
computeChainId: number;
|
248
|
-
distributionChainId: number;
|
249
|
-
startTimestamp: number;
|
250
|
-
endTimestamp: number;
|
251
|
-
rewardToken: string;
|
252
|
-
};
|
253
|
-
params: {};
|
254
|
-
query: unknown;
|
255
|
-
headers: {
|
256
|
-
authorization: string;
|
257
|
-
};
|
258
|
-
response: {
|
259
|
-
200: {
|
260
|
-
id: string;
|
261
|
-
chainId: number;
|
262
|
-
type: string;
|
263
|
-
identifier: string;
|
264
|
-
name: string;
|
265
|
-
status: "PAST" | "LIVE" | "SOON";
|
266
|
-
action: any;
|
267
|
-
tokens: ({
|
268
|
-
symbol: string;
|
269
|
-
id: string;
|
270
|
-
name: string | null;
|
271
|
-
icon: string;
|
272
|
-
address: string;
|
273
|
-
chainId: number;
|
274
|
-
decimals: number;
|
275
|
-
verified: boolean;
|
276
|
-
isTest: boolean;
|
277
|
-
isPoint: boolean;
|
278
|
-
isNative: boolean;
|
279
|
-
} & {
|
280
|
-
price?: number | null | undefined;
|
281
|
-
})[];
|
282
|
-
mainProtocol: "splice" | "morpho" | "quickswap" | "euler" | "ambient" | "uniswap" | "arthswap" | "base-swap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancake-swap" | "ramses" | "retro" | "stryke" | "sushi-swap" | "swapr" | "thruster" | "voltage" | "zero" | "koi" | "supswap" | "zk-swap" | "thirdtrade" | "swap-x" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap" | "neptune" | "zkSwapThreePool" | "rfx" | "ra" | "maverick" | "trader-joe" | "hanji" | "radiant" | "aave" | "fraxlend" | "ironclad" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | "lendle" | "tako-tako" | "equalizer" | "spectra" | "beraborrow" | "superlend" | "avalon" | "iguana" | "xlend" | "angles" | "enzyme" | "toros" | "vicuna" | "bunni" | "beratrax" | "concrete" | "cian" | "pendle" | "yei" | "filament" | "gammaswap" | "maha" | "tempest" | "uranium" | "holdstation" | "katana" | "satlayer" | undefined;
|
283
|
-
depositUrl: any;
|
284
|
-
explorerAddress: string | undefined;
|
285
|
-
tags: string[];
|
286
|
-
};
|
287
|
-
};
|
288
|
-
};
|
289
|
-
};
|
290
|
-
};
|
291
|
-
} & {
|
292
|
-
"dry-run": {
|
293
|
-
metadata: {
|
294
|
-
get: {
|
295
|
-
body: unknown;
|
296
|
-
params: {};
|
297
|
-
query: {
|
298
|
-
campaignId: string;
|
299
|
-
distributionChain: number;
|
300
|
-
};
|
301
|
-
headers: {
|
302
|
-
authorization: string;
|
303
|
-
};
|
304
|
-
response: {
|
305
|
-
200: {
|
306
|
-
id: string;
|
307
|
-
chainId: number;
|
308
|
-
type: string;
|
309
|
-
identifier: string;
|
310
|
-
name: string;
|
311
|
-
status: "PAST" | "LIVE" | "SOON";
|
312
|
-
action: any;
|
313
|
-
tokens: ({
|
314
|
-
symbol: string;
|
315
|
-
id: string;
|
316
|
-
name: string | null;
|
317
|
-
icon: string;
|
318
|
-
address: string;
|
319
|
-
chainId: number;
|
320
|
-
decimals: number;
|
321
|
-
verified: boolean;
|
322
|
-
isTest: boolean;
|
323
|
-
isPoint: boolean;
|
324
|
-
isNative: boolean;
|
325
|
-
} & {
|
326
|
-
price?: number | null | undefined;
|
327
|
-
})[];
|
328
|
-
mainProtocol: "splice" | "morpho" | "quickswap" | "euler" | "ambient" | "uniswap" | "arthswap" | "base-swap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancake-swap" | "ramses" | "retro" | "stryke" | "sushi-swap" | "swapr" | "thruster" | "voltage" | "zero" | "koi" | "supswap" | "zk-swap" | "thirdtrade" | "swap-x" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap" | "neptune" | "zkSwapThreePool" | "rfx" | "ra" | "maverick" | "trader-joe" | "hanji" | "radiant" | "aave" | "fraxlend" | "ironclad" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | "lendle" | "tako-tako" | "equalizer" | "spectra" | "beraborrow" | "superlend" | "avalon" | "iguana" | "xlend" | "angles" | "enzyme" | "toros" | "vicuna" | "bunni" | "beratrax" | "concrete" | "cian" | "pendle" | "yei" | "filament" | "gammaswap" | "maha" | "tempest" | "uranium" | "holdstation" | "katana" | "satlayer" | undefined;
|
329
|
-
depositUrl: any;
|
330
|
-
explorerAddress: string | undefined;
|
331
|
-
tags: string[];
|
332
|
-
};
|
333
|
-
};
|
334
|
-
};
|
335
|
-
};
|
336
|
-
};
|
337
168
|
} & {
|
338
169
|
index: {
|
339
170
|
get: {
|
@@ -6,9 +6,8 @@ import { Campaign } from "@sdk";
|
|
6
6
|
import Elysia, { t } from "elysia";
|
7
7
|
import { throwOnUnsupportedChainId } from "src/utils/throw";
|
8
8
|
import { DynamicDataService } from "../dynamicData/dynamicData.service";
|
9
|
-
import { OpportunityService } from "../opportunity";
|
10
9
|
import { OpportunityConvertorService } from "../opportunity/opportunity.converter";
|
11
|
-
import {
|
10
|
+
import { CampaignResourceDto, CreateCampaignDto, GetCampaignQueryDto, RemoveManualOverrideDto, UpdateCampaignCreatorDto, UpdateCampaignDto, UpdateMetaDataCampaignDto, } from "./campaign.model";
|
12
11
|
import { CampaignService } from "./campaign.service";
|
13
12
|
// ─── Campaigns Controller ────────────────────────────────────────────────────
|
14
13
|
export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { tags: ["Campaigns"] } })
|
@@ -54,69 +53,6 @@ export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { t
|
|
54
53
|
const campaignV3 = OpportunityConvertorService.convertV4CampaignToV3(Campaign[campaign.type], CampaignService.format(campaign), campaign.Opportunity.identifier);
|
55
54
|
return await DynamicDataService.updateForCampaigns([campaignV3]);
|
56
55
|
}, { beforeHandle: BackOfficeGuard, headers: AuthorizationHeadersDto, detail: { hide: true } })
|
57
|
-
// ─── Route for dev and test only ──────────────────────────────────────────────
|
58
|
-
.group("/dry-run", app => app
|
59
|
-
// ─── Test Dynamic data computation given a campaignId ───────────────────────
|
60
|
-
.get("/:campaignId/dynamic-data", async ({ params }) => {
|
61
|
-
const id = (await CampaignService.findMany({ campaignId: params.campaignId, test: true }))?.[0]?.id;
|
62
|
-
if (!id)
|
63
|
-
throw new NotFoundError();
|
64
|
-
const campaign = await CampaignService.findUniqueOrThrow(id, true);
|
65
|
-
const campaignV3 = OpportunityConvertorService.convertV4CampaignToV3(Campaign[campaign.type], CampaignService.format(campaign), campaign.Opportunity.identifier);
|
66
|
-
return await DynamicDataService.updateForCampaignType([campaignV3], campaignV3.campaignType, true);
|
67
|
-
}, { beforeHandle: BackOfficeGuard, headers: AuthorizationHeadersDto, detail: { hide: true } })
|
68
|
-
// ─── Test Dynamic data computation with a list of campaignId ───────────────────────
|
69
|
-
.post("/dynamic-data/list", async ({ body }) => {
|
70
|
-
const listCampaigns = [];
|
71
|
-
for (const campaignId of body) {
|
72
|
-
const id = (await CampaignService.findMany({ campaignId: campaignId, test: true }))?.[0]?.id;
|
73
|
-
if (!id)
|
74
|
-
throw new NotFoundError();
|
75
|
-
const campaign = await CampaignService.findUniqueOrThrow(id, true);
|
76
|
-
const campaignV3 = OpportunityConvertorService.convertV4CampaignToV3(Campaign[campaign.type], CampaignService.format(campaign), campaign.Opportunity.identifier);
|
77
|
-
listCampaigns.push(campaignV3);
|
78
|
-
}
|
79
|
-
return await DynamicDataService.updateForCampaigns(listCampaigns, true);
|
80
|
-
}, { beforeHandle: BackOfficeGuard, body: CampaignsDto, headers: AuthorizationHeadersDto, detail: { hide: true } })
|
81
|
-
// ─── Test Dynamic data computation with campaign config ───────────────────────
|
82
|
-
.post("/dynamic-data", async ({ body }) => {
|
83
|
-
const listCampaigns = [CampaignService.createFakeCampaign(body)];
|
84
|
-
return await DynamicDataService.updateForCampaigns(listCampaigns, true);
|
85
|
-
}, {
|
86
|
-
beforeHandle: BackOfficeGuard,
|
87
|
-
body: CampaignConfigMinimal,
|
88
|
-
headers: AuthorizationHeadersDto,
|
89
|
-
detail: { hide: true },
|
90
|
-
})
|
91
|
-
// ─── Test Opportunity creation through a campaign config ───────────────────────
|
92
|
-
// @dev Starts from the engine db to debug opportunity creation failing and preventing the api db to be filled
|
93
|
-
.post("/metadata", async ({ body }) => {
|
94
|
-
const engineCampaign = CampaignService.createFakeCampaignEngine(body);
|
95
|
-
return await OpportunityService.createFromCampaign(engineCampaign, false, false);
|
96
|
-
}, {
|
97
|
-
beforeHandle: BackOfficeGuard,
|
98
|
-
body: CampaignConfigMinimal,
|
99
|
-
headers: AuthorizationHeadersDto,
|
100
|
-
detail: { hide: true },
|
101
|
-
})
|
102
|
-
// ─── Test Opportunity creation through a campaign Id and a chain ───────────────────────
|
103
|
-
// @dev Starts from the engine db to debug opportunity creation failing and preventing the api db to be filled
|
104
|
-
.get("/metadata", async ({ query }) => {
|
105
|
-
const engineCampaigns = await CampaignService.findEngineCampaigns([
|
106
|
-
{
|
107
|
-
distributionChain: query.distributionChain,
|
108
|
-
campaignId: query.campaignId,
|
109
|
-
},
|
110
|
-
]);
|
111
|
-
if (!engineCampaigns.length)
|
112
|
-
throw new NotFoundError("Campaign not found in engine db");
|
113
|
-
return await OpportunityService.createFromCampaign(engineCampaigns[0], false, false);
|
114
|
-
}, {
|
115
|
-
beforeHandle: BackOfficeGuard,
|
116
|
-
headers: AuthorizationHeadersDto,
|
117
|
-
query: CampaignUniqueDto,
|
118
|
-
detail: { hide: true },
|
119
|
-
}))
|
120
56
|
// ─── Get Many Campaigns ──────────────────────────────────────────────
|
121
57
|
.get("/", async ({ query }) => {
|
122
58
|
if (query.items === 0)
|
@@ -0,0 +1,193 @@
|
|
1
|
+
import Elysia from "elysia";
|
2
|
+
export declare const CampaignTestController: Elysia<"/campaigns", false, {
|
3
|
+
decorator: {};
|
4
|
+
store: {};
|
5
|
+
derive: {};
|
6
|
+
resolve: {};
|
7
|
+
}, {
|
8
|
+
type: {};
|
9
|
+
error: {};
|
10
|
+
}, {
|
11
|
+
schema: {};
|
12
|
+
macro: {};
|
13
|
+
macroFn: {};
|
14
|
+
}, {
|
15
|
+
campaigns: {
|
16
|
+
"dry-run": {
|
17
|
+
":campaignId": {
|
18
|
+
"dynamic-data": {
|
19
|
+
get: {
|
20
|
+
body: unknown;
|
21
|
+
params: {
|
22
|
+
campaignId: string;
|
23
|
+
};
|
24
|
+
query: unknown;
|
25
|
+
headers: {
|
26
|
+
authorization: string;
|
27
|
+
};
|
28
|
+
response: {
|
29
|
+
200: unknown[];
|
30
|
+
};
|
31
|
+
};
|
32
|
+
};
|
33
|
+
};
|
34
|
+
};
|
35
|
+
} & {
|
36
|
+
"dry-run": {
|
37
|
+
"dynamic-data": {
|
38
|
+
list: {
|
39
|
+
post: {
|
40
|
+
body: string[];
|
41
|
+
params: {};
|
42
|
+
query: unknown;
|
43
|
+
headers: {
|
44
|
+
authorization: string;
|
45
|
+
};
|
46
|
+
response: {
|
47
|
+
200: unknown[];
|
48
|
+
};
|
49
|
+
};
|
50
|
+
};
|
51
|
+
};
|
52
|
+
};
|
53
|
+
} & {
|
54
|
+
"dry-run": {
|
55
|
+
"dynamic-data": {
|
56
|
+
post: {
|
57
|
+
body: {
|
58
|
+
id?: string | undefined;
|
59
|
+
subType?: number | undefined;
|
60
|
+
campaignId?: string | undefined;
|
61
|
+
amount?: string | undefined;
|
62
|
+
creatorAddress?: string | undefined;
|
63
|
+
type: string;
|
64
|
+
params: any;
|
65
|
+
computeChainId: number;
|
66
|
+
distributionChainId: number;
|
67
|
+
startTimestamp: number;
|
68
|
+
endTimestamp: number;
|
69
|
+
rewardToken: string;
|
70
|
+
};
|
71
|
+
params: {};
|
72
|
+
query: unknown;
|
73
|
+
headers: {
|
74
|
+
authorization: string;
|
75
|
+
};
|
76
|
+
response: {
|
77
|
+
200: unknown[];
|
78
|
+
};
|
79
|
+
};
|
80
|
+
};
|
81
|
+
};
|
82
|
+
} & {
|
83
|
+
"dry-run": {
|
84
|
+
metadata: {
|
85
|
+
post: {
|
86
|
+
body: {
|
87
|
+
id?: string | undefined;
|
88
|
+
subType?: number | undefined;
|
89
|
+
campaignId?: string | undefined;
|
90
|
+
amount?: string | undefined;
|
91
|
+
creatorAddress?: string | undefined;
|
92
|
+
type: string;
|
93
|
+
params: any;
|
94
|
+
computeChainId: number;
|
95
|
+
distributionChainId: number;
|
96
|
+
startTimestamp: number;
|
97
|
+
endTimestamp: number;
|
98
|
+
rewardToken: string;
|
99
|
+
};
|
100
|
+
params: {};
|
101
|
+
query: unknown;
|
102
|
+
headers: {
|
103
|
+
authorization: string;
|
104
|
+
};
|
105
|
+
response: {
|
106
|
+
200: {
|
107
|
+
id: string;
|
108
|
+
chainId: number;
|
109
|
+
type: string;
|
110
|
+
identifier: string;
|
111
|
+
name: string;
|
112
|
+
status: "PAST" | "LIVE" | "SOON";
|
113
|
+
action: any;
|
114
|
+
tokens: ({
|
115
|
+
symbol: string;
|
116
|
+
id: string;
|
117
|
+
name: string | null;
|
118
|
+
icon: string;
|
119
|
+
address: string;
|
120
|
+
chainId: number;
|
121
|
+
decimals: number;
|
122
|
+
verified: boolean;
|
123
|
+
isTest: boolean;
|
124
|
+
isPoint: boolean;
|
125
|
+
isNative: boolean;
|
126
|
+
} & {
|
127
|
+
price?: number | null | undefined;
|
128
|
+
})[];
|
129
|
+
mainProtocol: "splice" | "morpho" | "quickswap" | "euler" | "ambient" | "uniswap" | "arthswap" | "base-swap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancake-swap" | "ramses" | "retro" | "stryke" | "sushi-swap" | "swapr" | "thruster" | "voltage" | "zero" | "koi" | "supswap" | "zk-swap" | "thirdtrade" | "swap-x" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap" | "neptune" | "zkSwapThreePool" | "rfx" | "ra" | "maverick" | "trader-joe" | "hanji" | "radiant" | "aave" | "fraxlend" | "ironclad" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | "lendle" | "tako-tako" | "equalizer" | "spectra" | "beraborrow" | "superlend" | "avalon" | "iguana" | "xlend" | "angles" | "enzyme" | "toros" | "vicuna" | "bunni" | "beratrax" | "concrete" | "cian" | "pendle" | "yei" | "filament" | "gammaswap" | "maha" | "tempest" | "uranium" | "holdstation" | "katana" | "satlayer" | undefined;
|
130
|
+
depositUrl: any;
|
131
|
+
explorerAddress: string | undefined;
|
132
|
+
tags: string[];
|
133
|
+
};
|
134
|
+
};
|
135
|
+
};
|
136
|
+
};
|
137
|
+
};
|
138
|
+
} & {
|
139
|
+
"dry-run": {
|
140
|
+
metadata: {
|
141
|
+
get: {
|
142
|
+
body: unknown;
|
143
|
+
params: {};
|
144
|
+
query: {
|
145
|
+
campaignId: string;
|
146
|
+
distributionChain: number;
|
147
|
+
};
|
148
|
+
headers: {
|
149
|
+
authorization: string;
|
150
|
+
};
|
151
|
+
response: {
|
152
|
+
200: {
|
153
|
+
id: string;
|
154
|
+
chainId: number;
|
155
|
+
type: string;
|
156
|
+
identifier: string;
|
157
|
+
name: string;
|
158
|
+
status: "PAST" | "LIVE" | "SOON";
|
159
|
+
action: any;
|
160
|
+
tokens: ({
|
161
|
+
symbol: string;
|
162
|
+
id: string;
|
163
|
+
name: string | null;
|
164
|
+
icon: string;
|
165
|
+
address: string;
|
166
|
+
chainId: number;
|
167
|
+
decimals: number;
|
168
|
+
verified: boolean;
|
169
|
+
isTest: boolean;
|
170
|
+
isPoint: boolean;
|
171
|
+
isNative: boolean;
|
172
|
+
} & {
|
173
|
+
price?: number | null | undefined;
|
174
|
+
})[];
|
175
|
+
mainProtocol: "splice" | "morpho" | "quickswap" | "euler" | "ambient" | "uniswap" | "arthswap" | "base-swap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancake-swap" | "ramses" | "retro" | "stryke" | "sushi-swap" | "swapr" | "thruster" | "voltage" | "zero" | "koi" | "supswap" | "zk-swap" | "thirdtrade" | "swap-x" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap" | "neptune" | "zkSwapThreePool" | "rfx" | "ra" | "maverick" | "trader-joe" | "hanji" | "radiant" | "aave" | "fraxlend" | "ironclad" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | "lendle" | "tako-tako" | "equalizer" | "spectra" | "beraborrow" | "superlend" | "avalon" | "iguana" | "xlend" | "angles" | "enzyme" | "toros" | "vicuna" | "bunni" | "beratrax" | "concrete" | "cian" | "pendle" | "yei" | "filament" | "gammaswap" | "maha" | "tempest" | "uranium" | "holdstation" | "katana" | "satlayer" | undefined;
|
176
|
+
depositUrl: any;
|
177
|
+
explorerAddress: string | undefined;
|
178
|
+
tags: string[];
|
179
|
+
};
|
180
|
+
};
|
181
|
+
};
|
182
|
+
};
|
183
|
+
};
|
184
|
+
};
|
185
|
+
}, {
|
186
|
+
derive: {};
|
187
|
+
resolve: {};
|
188
|
+
schema: {};
|
189
|
+
}, {
|
190
|
+
derive: {};
|
191
|
+
resolve: {};
|
192
|
+
schema: {};
|
193
|
+
}>;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import { NotFoundError } from "@/errors";
|
2
|
+
import { BackOfficeGuard } from "@/guards/BackOffice.guard";
|
3
|
+
import { AuthorizationHeadersDto } from "@/guards/Engine.guard";
|
4
|
+
import { Campaign } from "@sdk";
|
5
|
+
import Elysia from "elysia";
|
6
|
+
import { DynamicDataService } from "../dynamicData/dynamicData.service";
|
7
|
+
import { OpportunityService } from "../opportunity";
|
8
|
+
import { OpportunityConvertorService } from "../opportunity/opportunity.converter";
|
9
|
+
import { CampaignConfigMinimal, CampaignUniqueDto, CampaignsDto } from "./campaign.model";
|
10
|
+
import { CampaignService } from "./campaign.service";
|
11
|
+
// ─── Routes for dev and test only ──────────────────────────────────────────────
|
12
|
+
export const CampaignTestController = new Elysia({
|
13
|
+
prefix: "/campaigns",
|
14
|
+
detail: { tags: ["Campaigns"], hide: true },
|
15
|
+
}).group("/dry-run", app => app
|
16
|
+
.guard({
|
17
|
+
headers: AuthorizationHeadersDto,
|
18
|
+
beforeHandle: BackOfficeGuard,
|
19
|
+
})
|
20
|
+
// ─── Test Dynamic data computation given a campaignId ───────────────────────
|
21
|
+
.get("/:campaignId/dynamic-data", async ({ params }) => {
|
22
|
+
const id = (await CampaignService.findMany({ campaignId: params.campaignId, test: true }))?.[0]?.id;
|
23
|
+
if (!id)
|
24
|
+
throw new NotFoundError();
|
25
|
+
const campaign = await CampaignService.findUniqueOrThrow(id, true);
|
26
|
+
const campaignV3 = OpportunityConvertorService.convertV4CampaignToV3(Campaign[campaign.type], CampaignService.format(campaign), campaign.Opportunity.identifier);
|
27
|
+
return await DynamicDataService.updateForCampaignType([campaignV3], campaignV3.campaignType, true);
|
28
|
+
})
|
29
|
+
// ─── Test Dynamic data computation with a list of campaignId ───────────────────────
|
30
|
+
.post("/dynamic-data/list", async ({ body }) => {
|
31
|
+
const listCampaigns = [];
|
32
|
+
for (const campaignId of body) {
|
33
|
+
const id = (await CampaignService.findMany({ campaignId: campaignId, test: true }))?.[0]?.id;
|
34
|
+
if (!id)
|
35
|
+
throw new NotFoundError();
|
36
|
+
const campaign = await CampaignService.findUniqueOrThrow(id, true);
|
37
|
+
const campaignV3 = OpportunityConvertorService.convertV4CampaignToV3(Campaign[campaign.type], CampaignService.format(campaign), campaign.Opportunity.identifier);
|
38
|
+
listCampaigns.push(campaignV3);
|
39
|
+
}
|
40
|
+
return await DynamicDataService.updateForCampaigns(listCampaigns, true);
|
41
|
+
}, { body: CampaignsDto })
|
42
|
+
// ─── Test Dynamic data computation with campaign config ───────────────────────
|
43
|
+
.post("/dynamic-data", async ({ body }) => {
|
44
|
+
const listCampaigns = [CampaignService.createFakeCampaign(body)];
|
45
|
+
return await DynamicDataService.updateForCampaigns(listCampaigns, true);
|
46
|
+
}, {
|
47
|
+
body: CampaignConfigMinimal,
|
48
|
+
})
|
49
|
+
// ─── Test Opportunity creation through a campaign config ───────────────────────
|
50
|
+
// @dev Starts from the engine db to debug opportunity creation failing and preventing the api db to be filled
|
51
|
+
.post("/metadata", async ({ body }) => {
|
52
|
+
const engineCampaign = CampaignService.createFakeCampaignEngine(body);
|
53
|
+
return await OpportunityService.createFromCampaign(engineCampaign, false, false);
|
54
|
+
}, {
|
55
|
+
body: CampaignConfigMinimal,
|
56
|
+
})
|
57
|
+
// ─── Test Opportunity creation through a campaign Id and a chain ───────────────────────
|
58
|
+
// @dev Starts from the engine db to debug opportunity creation failing and preventing the api db to be filled
|
59
|
+
.get("/metadata", async ({ query }) => {
|
60
|
+
const engineCampaigns = await CampaignService.findEngineCampaigns([
|
61
|
+
{
|
62
|
+
distributionChain: query.distributionChain,
|
63
|
+
campaignId: query.campaignId,
|
64
|
+
},
|
65
|
+
]);
|
66
|
+
if (!engineCampaigns.length)
|
67
|
+
throw new NotFoundError("Campaign not found in engine db");
|
68
|
+
return await OpportunityService.createFromCampaign(engineCampaigns[0], false, false);
|
69
|
+
}, {
|
70
|
+
query: CampaignUniqueDto,
|
71
|
+
}));
|