@merkl/api 0.10.249 → 0.10.250

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.
@@ -406,6 +406,7 @@ declare const eden: {
406
406
  page?: number | undefined;
407
407
  chainId?: string | undefined;
408
408
  action?: string | undefined;
409
+ creatorAddress?: string | undefined;
409
410
  mainProtocolId?: string | undefined;
410
411
  order?: string | undefined;
411
412
  test?: boolean | undefined;
@@ -516,6 +517,7 @@ declare const eden: {
516
517
  page?: number | undefined;
517
518
  chainId?: string | undefined;
518
519
  action?: string | undefined;
520
+ creatorAddress?: string | undefined;
519
521
  mainProtocolId?: string | undefined;
520
522
  order?: string | undefined;
521
523
  test?: boolean | undefined;
@@ -541,6 +543,7 @@ declare const eden: {
541
543
  page?: number | undefined;
542
544
  chainId?: string | undefined;
543
545
  action?: string | undefined;
546
+ creatorAddress?: string | undefined;
544
547
  mainProtocolId?: string | undefined;
545
548
  order?: string | undefined;
546
549
  test?: boolean | undefined;
@@ -2929,6 +2932,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
2929
2932
  page?: number | undefined;
2930
2933
  chainId?: string | undefined;
2931
2934
  action?: string | undefined;
2935
+ creatorAddress?: string | undefined;
2932
2936
  mainProtocolId?: string | undefined;
2933
2937
  order?: string | undefined;
2934
2938
  test?: boolean | undefined;
@@ -3044,6 +3048,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3044
3048
  page?: number | undefined;
3045
3049
  chainId?: string | undefined;
3046
3050
  action?: string | undefined;
3051
+ creatorAddress?: string | undefined;
3047
3052
  mainProtocolId?: string | undefined;
3048
3053
  order?: string | undefined;
3049
3054
  test?: boolean | undefined;
@@ -3340,6 +3345,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3340
3345
  page?: number | undefined;
3341
3346
  chainId?: string | undefined;
3342
3347
  action?: string | undefined;
3348
+ creatorAddress?: string | undefined;
3343
3349
  mainProtocolId?: string | undefined;
3344
3350
  order?: string | undefined;
3345
3351
  test?: boolean | undefined;
@@ -6598,6 +6604,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6598
6604
  page?: number | undefined;
6599
6605
  chainId?: string | undefined;
6600
6606
  action?: string | undefined;
6607
+ creatorAddress?: string | undefined;
6601
6608
  mainProtocolId?: string | undefined;
6602
6609
  order?: string | undefined;
6603
6610
  test?: boolean | undefined;
@@ -6708,6 +6715,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6708
6715
  page?: number | undefined;
6709
6716
  chainId?: string | undefined;
6710
6717
  action?: string | undefined;
6718
+ creatorAddress?: string | undefined;
6711
6719
  mainProtocolId?: string | undefined;
6712
6720
  order?: string | undefined;
6713
6721
  test?: boolean | undefined;
@@ -6733,6 +6741,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6733
6741
  page?: number | undefined;
6734
6742
  chainId?: string | undefined;
6735
6743
  action?: string | undefined;
6744
+ creatorAddress?: string | undefined;
6736
6745
  mainProtocolId?: string | undefined;
6737
6746
  order?: string | undefined;
6738
6747
  test?: boolean | undefined;
@@ -187,6 +187,7 @@ declare const app: Elysia<"", false, {
187
187
  page?: number | undefined;
188
188
  chainId?: string | undefined;
189
189
  action?: string | undefined;
190
+ creatorAddress?: string | undefined;
190
191
  mainProtocolId?: string | undefined;
191
192
  order?: string | undefined;
192
193
  test?: boolean | undefined;
@@ -302,6 +303,7 @@ declare const app: Elysia<"", false, {
302
303
  page?: number | undefined;
303
304
  chainId?: string | undefined;
304
305
  action?: string | undefined;
306
+ creatorAddress?: string | undefined;
305
307
  mainProtocolId?: string | undefined;
306
308
  order?: string | undefined;
307
309
  test?: boolean | undefined;
@@ -598,6 +600,7 @@ declare const app: Elysia<"", false, {
598
600
  page?: number | undefined;
599
601
  chainId?: string | undefined;
600
602
  action?: string | undefined;
603
+ creatorAddress?: string | undefined;
601
604
  mainProtocolId?: string | undefined;
602
605
  order?: string | undefined;
603
606
  test?: boolean | undefined;
@@ -5,7 +5,7 @@ export class ClaimService {
5
5
  // ─── Get Historical Claims ─────────────────────────────────────────────────
6
6
  static async getHistoricalClaims(params, chainFilter = []) {
7
7
  const roots = (await MerklRootService.fetchAll()).map(r => r.live);
8
- const rewards = await RewardService.getByRecipient(params.address, roots, true, chainFilter);
8
+ const rewards = await RewardService.getByRecipient(params.address, roots, true, true, chainFilter);
9
9
  const filteredRewards = chainFilter.length
10
10
  ? rewards.filter(reward => chainFilter.includes(reward.RewardToken.chainId))
11
11
  : rewards;
@@ -56,6 +56,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
56
56
  page?: number | undefined;
57
57
  chainId?: string | undefined;
58
58
  action?: string | undefined;
59
+ creatorAddress?: string | undefined;
59
60
  mainProtocolId?: string | undefined;
60
61
  order?: string | undefined;
61
62
  test?: boolean | undefined;
@@ -171,6 +172,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
171
172
  page?: number | undefined;
172
173
  chainId?: string | undefined;
173
174
  action?: string | undefined;
175
+ creatorAddress?: string | undefined;
174
176
  mainProtocolId?: string | undefined;
175
177
  order?: string | undefined;
176
178
  test?: boolean | undefined;
@@ -467,6 +469,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
467
469
  page?: number | undefined;
468
470
  chainId?: string | undefined;
469
471
  action?: string | undefined;
472
+ creatorAddress?: string | undefined;
470
473
  mainProtocolId?: string | undefined;
471
474
  order?: string | undefined;
472
475
  test?: boolean | undefined;
@@ -278,6 +278,7 @@ export declare const GetOpportunitiesQueryDto: import("@sinclair/typebox").TObje
278
278
  name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
279
279
  chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRegExp>;
280
280
  action: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRegExp>;
281
+ creatorAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
281
282
  tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
282
283
  test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
283
284
  minimumTvl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
@@ -51,6 +51,7 @@ export const GetOpportunitiesQueryDto = t.Object({
51
51
  action: t.Optional(t.RegExp(/^(POOL|HOLD|DROP|LEND|BORROW)(,(POOL|HOLD|DROP|LEND|BORROW)){0,4}$/, {
52
52
  description: "A comma seprated list actions. Legal values are: `POOL`, `HOLD`, `DROP`, `LEND`, `BORROW`",
53
53
  })),
54
+ creatorAddress: t.Optional(t.String({ description: "Filter by creator address" })),
54
55
  tags: t.Optional(t.String({ description: "Filter by tag" })),
55
56
  test: t.Optional(t.Boolean({ description: "Include opportunities with test campaigns" })),
56
57
  minimumTvl: t.Optional(t.Number({ description: "Minimum TVL threshhold in USD" })),
@@ -137,6 +137,7 @@ export class OpportunityRepository {
137
137
  const sort = (query.sort === "rewards" ? "dailyRewards" : query.sort) ?? "dailyRewards";
138
138
  const order = query.order ?? "desc";
139
139
  const test = query.test ?? false;
140
+ const creatorAddress = query.creatorAddress ?? null;
140
141
  const noFilters = Object.values(filters).every(v => v === undefined);
141
142
  const tokensFilters = tokens?.map(symbol => ({
142
143
  Tokens: { some: { symbol: { equals: symbol, mode: "insensitive" } } },
@@ -162,7 +163,16 @@ export class OpportunityRepository {
162
163
  status: !status ? undefined : { in: status },
163
164
  },
164
165
  { mainProtocolId: !protocols ? undefined : { in: protocols } },
165
- { Campaigns: test ? undefined : { some: { RewardToken: { isTest: false } } } },
166
+ {
167
+ Campaigns: test || !creatorAddress
168
+ ? undefined
169
+ : {
170
+ some: {
171
+ RewardToken: !test ? { isTest: false } : undefined,
172
+ creatorAddress: creatorAddress ? creatorAddress : undefined,
173
+ },
174
+ },
175
+ },
166
176
  ],
167
177
  },
168
178
  };
@@ -172,6 +182,7 @@ export class OpportunityRepository {
172
182
  const { page: _page, items: _items } = query;
173
183
  const page = _page ? _page : 0;
174
184
  const items = _items ? _items : 20;
185
+ const test = query.test ?? false;
175
186
  const args = OpportunityRepository.#transformQueryToPrismaFilters(query);
176
187
  return await apiDbClient.opportunity.findMany({
177
188
  take: items,
@@ -181,7 +192,9 @@ export class OpportunityRepository {
181
192
  MainProtocol: true,
182
193
  Chain: true,
183
194
  Protocols: true,
184
- Tokens: true,
195
+ Tokens: {
196
+ where: !test ? { isTest: false } : undefined,
197
+ },
185
198
  },
186
199
  ...args,
187
200
  });
@@ -65,6 +65,7 @@ export declare const v4: Elysia<"/v4", false, {
65
65
  page?: number | undefined;
66
66
  chainId?: string | undefined;
67
67
  action?: string | undefined;
68
+ creatorAddress?: string | undefined;
68
69
  mainProtocolId?: string | undefined;
69
70
  order?: string | undefined;
70
71
  test?: boolean | undefined;
@@ -180,6 +181,7 @@ export declare const v4: Elysia<"/v4", false, {
180
181
  page?: number | undefined;
181
182
  chainId?: string | undefined;
182
183
  action?: string | undefined;
184
+ creatorAddress?: string | undefined;
183
185
  mainProtocolId?: string | undefined;
184
186
  order?: string | undefined;
185
187
  test?: boolean | undefined;
@@ -476,6 +478,7 @@ export declare const v4: Elysia<"/v4", false, {
476
478
  page?: number | undefined;
477
479
  chainId?: string | undefined;
478
480
  action?: string | undefined;
481
+ creatorAddress?: string | undefined;
479
482
  mainProtocolId?: string | undefined;
480
483
  order?: string | undefined;
481
484
  test?: boolean | undefined;
@@ -64,7 +64,10 @@ export const UserController = new Elysia({ prefix: "/users", detail: { tags: ["U
64
64
  detail: { hide: true },
65
65
  })
66
66
  // ─── Sync Creator Tags with Engine DB ─────────────────────────────────
67
- .post("/sync", async () => await UserService.syncTags(), {
67
+ .post("/sync", async () => {
68
+ await UserService.syncTags();
69
+ await UserService.syncOpportunityTags();
70
+ }, {
68
71
  headers: AuthorizationHeadersDto,
69
72
  beforeHandle: BackOfficeGuard,
70
73
  detail: { hide: true },
@@ -22,4 +22,5 @@ export declare abstract class UserService {
22
22
  address: string;
23
23
  }>;
24
24
  static syncTags(): Promise<void>;
25
+ static syncOpportunityTags(): Promise<void>;
25
26
  }
@@ -1,5 +1,6 @@
1
1
  import { log } from "../../../utils/logger";
2
2
  import { engineDbClient } from "../../../utils/prisma";
3
+ import { OpportunityService } from "../opportunity";
3
4
  import { UserRepository } from "./user.repository";
4
5
  // ─── Users Services ──────────────────────────────────────────────────────────
5
6
  export class UserService {
@@ -19,6 +20,9 @@ export class UserService {
19
20
  return await UserRepository.createMany(users);
20
21
  }
21
22
  static async updateTags(user, tags) {
23
+ if (!(await UserRepository.findUnique(user))) {
24
+ await UserRepository.create({ address: user, tags: [] });
25
+ }
22
26
  return await UserRepository.updateTags(user, tags);
23
27
  }
24
28
  static async syncTags() {
@@ -47,4 +51,16 @@ export class UserService {
47
51
  }
48
52
  }
49
53
  }
54
+ static async syncOpportunityTags() {
55
+ const users = await UserRepository.findManyWithTags();
56
+ for (const user of users) {
57
+ const opportunities = await OpportunityService.getMany({ creatorAddress: user.address });
58
+ for (const opportunity of opportunities) {
59
+ if (!user.tags.every(tag => opportunity.tags.includes(tag))) {
60
+ log.local(`updating tags for opportunity ${opportunity.id}: adding ${user.tags.join(",")}`);
61
+ await OpportunityService.update(opportunity.id, { tags: [...opportunity.tags, ...user.tags] });
62
+ }
63
+ }
64
+ }
65
+ }
50
66
  }
@@ -27,7 +27,7 @@ export default (app) => app.use(checkQueryAddressValidity()).get("/rewards", asy
27
27
  }
28
28
  const user = query.user;
29
29
  // @Warning: this is not taking into account the creator tag filter
30
- const v4Res = await RewardService.getUserRewardsByChain(user, false, chainIds);
30
+ const v4Res = await RewardService.getUserRewardsByChain(user, false, chainIds, null, true);
31
31
  const v3Res = RewardConvertorService.convertV4toRewardV3(v4Res);
32
32
  return v3Res;
33
33
  }, { query, tags: ["Rewards"] });
@@ -45,7 +45,7 @@ export default (app) => app
45
45
  }
46
46
  }
47
47
  // @Warning: this is not taking into account the mainParameter filter
48
- const v4Res = await RewardService.getUserRewardsByChain(user, false, [chainId], query.reloadChainId ?? null);
48
+ const v4Res = await RewardService.getUserRewardsByChain(user, false, [chainId], query.reloadChainId ?? null, true);
49
49
  const v3Res = RewardConvertorService.convertV4toUserRewardV3(v4Res, proof);
50
50
  return v3Res;
51
51
  }, {