@merkl/api 0.10.394 → 0.10.397

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.
Files changed (43) hide show
  1. package/dist/database/api/.generated/drizzle/schema.d.ts +2806 -0
  2. package/dist/database/api/.generated/drizzle/schema.js +849 -0
  3. package/dist/database/api/.generated/drizzle/schema.ts +906 -0
  4. package/dist/database/api/.generated/edge.js +2 -2
  5. package/dist/database/api/.generated/index.js +2 -2
  6. package/dist/database/api/.generated/package.json +1 -1
  7. package/dist/database/api/.generated/schema.prisma +5 -0
  8. package/dist/src/backgroundJobs/jobs/campaignsCacheUpdater.js +1 -1
  9. package/dist/src/eden/index.d.ts +314 -36
  10. package/dist/src/index.d.ts +120 -12
  11. package/dist/src/modules/v4/cache/cache.service.js +2 -0
  12. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +1 -1
  13. package/dist/src/modules/v4/campaign/campaign.repository.d.ts +10 -10
  14. package/dist/src/modules/v4/campaign/campaign.repository.js +2 -2
  15. package/dist/src/modules/v4/campaign/campaign.service.d.ts +3 -2
  16. package/dist/src/modules/v4/campaign/campaign.service.js +9 -1
  17. package/dist/src/modules/v4/dynamicData/dynamicData.controller.d.ts +1 -1
  18. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +3 -3
  19. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +5 -5
  20. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +72 -72
  21. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +1 -1
  22. package/dist/src/modules/v4/reward/reward.controller.d.ts +109 -1
  23. package/dist/src/modules/v4/reward/reward.controller.js +29 -21
  24. package/dist/src/modules/v4/reward/reward.model.d.ts +5 -0
  25. package/dist/src/modules/v4/reward/reward.model.js +8 -0
  26. package/dist/src/modules/v4/reward/reward.repository.d.ts +12 -8
  27. package/dist/src/modules/v4/reward/reward.repository.js +13 -16
  28. package/dist/src/modules/v4/reward/reward.service.d.ts +10 -5
  29. package/dist/src/modules/v4/router.d.ts +120 -12
  30. package/dist/src/modules/v4/status/status.controller.d.ts +6 -6
  31. package/dist/src/modules/v4/status/status.repository.d.ts +6 -6
  32. package/dist/src/modules/v4/status/status.service.d.ts +6 -6
  33. package/dist/src/modules/v4/token/token.repository.d.ts +2 -2
  34. package/dist/src/modules/v4/token/token.service.d.ts +3 -4
  35. package/dist/src/modules/v4/token/token.service.js +2 -1
  36. package/dist/src/modules/v4/user/user.model.d.ts +5 -0
  37. package/dist/src/modules/v4/user/user.model.js +4 -0
  38. package/dist/src/modules/v4/user/user.repository.d.ts +1 -1
  39. package/dist/src/modules/v4/user/user.service.d.ts +1 -1
  40. package/dist/src/utils/prisma.d.ts +16 -3
  41. package/dist/src/utils/prisma.js +2 -1
  42. package/dist/tsconfig.package.tsbuildinfo +1 -1
  43. package/package.json +4 -2
@@ -119,6 +119,14 @@ export declare abstract class OpportunityRepository {
119
119
  Campaign: {
120
120
  startTimestamp: bigint;
121
121
  endTimestamp: bigint;
122
+ CampaignStatus: {
123
+ error: string;
124
+ details: Prisma.JsonValue;
125
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
126
+ campaignId: string;
127
+ computedUntil: bigint;
128
+ processingStarted: bigint;
129
+ }[];
122
130
  amount: string;
123
131
  RewardToken: {
124
132
  symbol: string;
@@ -133,14 +141,6 @@ export declare abstract class OpportunityRepository {
133
141
  isTest: boolean;
134
142
  price: number | null;
135
143
  };
136
- CampaignStatus: {
137
- error: string;
138
- details: Prisma.JsonValue;
139
- status: import("../../../../database/api/.generated").$Enums.RunStatus;
140
- campaignId: string;
141
- computedUntil: bigint;
142
- processingStarted: bigint;
143
- }[];
144
144
  };
145
145
  } & {
146
146
  id: number;
@@ -237,6 +237,14 @@ export declare abstract class OpportunityRepository {
237
237
  Campaign: {
238
238
  startTimestamp: bigint;
239
239
  endTimestamp: bigint;
240
+ CampaignStatus: {
241
+ error: string;
242
+ details: Prisma.JsonValue;
243
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
244
+ campaignId: string;
245
+ computedUntil: bigint;
246
+ processingStarted: bigint;
247
+ }[];
240
248
  amount: string;
241
249
  RewardToken: {
242
250
  symbol: string;
@@ -251,14 +259,6 @@ export declare abstract class OpportunityRepository {
251
259
  isTest: boolean;
252
260
  price: number | null;
253
261
  };
254
- CampaignStatus: {
255
- error: string;
256
- details: Prisma.JsonValue;
257
- status: import("../../../../database/api/.generated").$Enums.RunStatus;
258
- campaignId: string;
259
- computedUntil: bigint;
260
- processingStarted: bigint;
261
- }[];
262
262
  };
263
263
  } & {
264
264
  id: number;
@@ -301,6 +301,14 @@ export declare abstract class OpportunityRepository {
301
301
  icon: string;
302
302
  };
303
303
  Campaigns: ({
304
+ CampaignStatus: {
305
+ error: string;
306
+ details: Prisma.JsonValue;
307
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
308
+ campaignId: string;
309
+ computedUntil: bigint;
310
+ processingStarted: bigint;
311
+ }[];
304
312
  ComputeChain: {
305
313
  name: string;
306
314
  id: number;
@@ -331,14 +339,6 @@ export declare abstract class OpportunityRepository {
331
339
  isTest: boolean;
332
340
  price: number | null;
333
341
  };
334
- CampaignStatus: {
335
- error: string;
336
- details: Prisma.JsonValue;
337
- status: import("../../../../database/api/.generated").$Enums.RunStatus;
338
- campaignId: string;
339
- computedUntil: bigint;
340
- processingStarted: bigint;
341
- }[];
342
342
  } & {
343
343
  params: Prisma.JsonValue;
344
344
  type: import("../../../../database/api/.generated").$Enums.CampaignType;
@@ -416,6 +416,14 @@ export declare abstract class OpportunityRepository {
416
416
  Campaign: {
417
417
  startTimestamp: bigint;
418
418
  endTimestamp: bigint;
419
+ CampaignStatus: {
420
+ error: string;
421
+ details: Prisma.JsonValue;
422
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
423
+ campaignId: string;
424
+ computedUntil: bigint;
425
+ processingStarted: bigint;
426
+ }[];
419
427
  amount: string;
420
428
  RewardToken: {
421
429
  symbol: string;
@@ -430,14 +438,6 @@ export declare abstract class OpportunityRepository {
430
438
  isTest: boolean;
431
439
  price: number | null;
432
440
  };
433
- CampaignStatus: {
434
- error: string;
435
- details: Prisma.JsonValue;
436
- status: import("../../../../database/api/.generated").$Enums.RunStatus;
437
- campaignId: string;
438
- computedUntil: bigint;
439
- processingStarted: bigint;
440
- }[];
441
441
  };
442
442
  } & {
443
443
  id: number;
@@ -485,6 +485,14 @@ export declare abstract class OpportunityRepository {
485
485
  icon: string;
486
486
  };
487
487
  Campaigns: ({
488
+ CampaignStatus: {
489
+ error: string;
490
+ details: Prisma.JsonValue;
491
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
492
+ campaignId: string;
493
+ computedUntil: bigint;
494
+ processingStarted: bigint;
495
+ }[];
488
496
  ComputeChain: {
489
497
  name: string;
490
498
  id: number;
@@ -515,14 +523,6 @@ export declare abstract class OpportunityRepository {
515
523
  isTest: boolean;
516
524
  price: number | null;
517
525
  };
518
- CampaignStatus: {
519
- error: string;
520
- details: Prisma.JsonValue;
521
- status: import("../../../../database/api/.generated").$Enums.RunStatus;
522
- campaignId: string;
523
- computedUntil: bigint;
524
- processingStarted: bigint;
525
- }[];
526
526
  } & {
527
527
  params: Prisma.JsonValue;
528
528
  type: import("../../../../database/api/.generated").$Enums.CampaignType;
@@ -600,6 +600,14 @@ export declare abstract class OpportunityRepository {
600
600
  Campaign: {
601
601
  startTimestamp: bigint;
602
602
  endTimestamp: bigint;
603
+ CampaignStatus: {
604
+ error: string;
605
+ details: Prisma.JsonValue;
606
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
607
+ campaignId: string;
608
+ computedUntil: bigint;
609
+ processingStarted: bigint;
610
+ }[];
603
611
  amount: string;
604
612
  RewardToken: {
605
613
  symbol: string;
@@ -614,14 +622,6 @@ export declare abstract class OpportunityRepository {
614
622
  isTest: boolean;
615
623
  price: number | null;
616
624
  };
617
- CampaignStatus: {
618
- error: string;
619
- details: Prisma.JsonValue;
620
- status: import("../../../../database/api/.generated").$Enums.RunStatus;
621
- campaignId: string;
622
- computedUntil: bigint;
623
- processingStarted: bigint;
624
- }[];
625
625
  };
626
626
  } & {
627
627
  id: number;
@@ -763,6 +763,14 @@ export declare abstract class OpportunityRepository {
763
763
  Campaign: {
764
764
  startTimestamp: bigint;
765
765
  endTimestamp: bigint;
766
+ CampaignStatus: {
767
+ error: string;
768
+ details: Prisma.JsonValue;
769
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
770
+ campaignId: string;
771
+ computedUntil: bigint;
772
+ processingStarted: bigint;
773
+ }[];
766
774
  amount: string;
767
775
  RewardToken: {
768
776
  symbol: string;
@@ -777,14 +785,6 @@ export declare abstract class OpportunityRepository {
777
785
  isTest: boolean;
778
786
  price: number | null;
779
787
  };
780
- CampaignStatus: {
781
- error: string;
782
- details: Prisma.JsonValue;
783
- status: import("../../../../database/api/.generated").$Enums.RunStatus;
784
- campaignId: string;
785
- computedUntil: bigint;
786
- processingStarted: bigint;
787
- }[];
788
788
  };
789
789
  } & {
790
790
  id: number;
@@ -820,6 +820,14 @@ export declare abstract class OpportunityRepository {
820
820
  icon: string;
821
821
  };
822
822
  Campaigns: ({
823
+ CampaignStatus: {
824
+ error: string;
825
+ details: Prisma.JsonValue;
826
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
827
+ campaignId: string;
828
+ computedUntil: bigint;
829
+ processingStarted: bigint;
830
+ }[];
823
831
  ComputeChain: {
824
832
  name: string;
825
833
  id: number;
@@ -843,14 +851,6 @@ export declare abstract class OpportunityRepository {
843
851
  isTest: boolean;
844
852
  price: number | null;
845
853
  };
846
- CampaignStatus: {
847
- error: string;
848
- details: Prisma.JsonValue;
849
- status: import("../../../../database/api/.generated").$Enums.RunStatus;
850
- campaignId: string;
851
- computedUntil: bigint;
852
- processingStarted: bigint;
853
- }[];
854
854
  } & {
855
855
  params: Prisma.JsonValue;
856
856
  type: import("../../../../database/api/.generated").$Enums.CampaignType;
@@ -928,6 +928,14 @@ export declare abstract class OpportunityRepository {
928
928
  Campaign: {
929
929
  startTimestamp: bigint;
930
930
  endTimestamp: bigint;
931
+ CampaignStatus: {
932
+ error: string;
933
+ details: Prisma.JsonValue;
934
+ status: import("../../../../database/api/.generated").$Enums.RunStatus;
935
+ campaignId: string;
936
+ computedUntil: bigint;
937
+ processingStarted: bigint;
938
+ }[];
931
939
  amount: string;
932
940
  RewardToken: {
933
941
  symbol: string;
@@ -942,14 +950,6 @@ export declare abstract class OpportunityRepository {
942
950
  isTest: boolean;
943
951
  price: number | null;
944
952
  };
945
- CampaignStatus: {
946
- error: string;
947
- details: Prisma.JsonValue;
948
- status: import("../../../../database/api/.generated").$Enums.RunStatus;
949
- campaignId: string;
950
- computedUntil: bigint;
951
- processingStarted: bigint;
952
- }[];
953
953
  };
954
954
  } & {
955
955
  id: number;
@@ -131,7 +131,6 @@ export declare abstract class OpportunityService {
131
131
  tags: string[];
132
132
  icon: string;
133
133
  } | null | undefined;
134
- depositUrl?: string | undefined;
135
134
  aprRecord?: {
136
135
  timestamp: string | bigint;
137
136
  cumulated: number;
@@ -143,6 +142,7 @@ export declare abstract class OpportunityService {
143
142
  aprRecordId: string;
144
143
  }[];
145
144
  } | undefined;
145
+ depositUrl?: string | undefined;
146
146
  tvlRecord?: {
147
147
  total: number;
148
148
  timestamp: string | bigint;
@@ -96,6 +96,106 @@ export declare const RewardController: Elysia<"/rewards", {
96
96
  };
97
97
  };
98
98
  };
99
+ } & {
100
+ campaign: {
101
+ ":campaignId": {
102
+ index: {
103
+ get: {
104
+ body: unknown;
105
+ params: {
106
+ campaignId: string;
107
+ };
108
+ query: {
109
+ items?: number | undefined;
110
+ page?: number | undefined;
111
+ };
112
+ headers: unknown;
113
+ response: {
114
+ 200: {
115
+ amount: string;
116
+ claimed: string;
117
+ pending: string;
118
+ recipient: string;
119
+ }[];
120
+ 422: {
121
+ type: "validation";
122
+ on: string;
123
+ summary?: string;
124
+ message?: string;
125
+ found?: unknown;
126
+ property?: string;
127
+ expected?: string;
128
+ };
129
+ };
130
+ };
131
+ };
132
+ };
133
+ };
134
+ } & {
135
+ campaign: {
136
+ ":campaignId": {
137
+ total: {
138
+ get: {
139
+ body: unknown;
140
+ params: {
141
+ campaignId: string;
142
+ };
143
+ query: {
144
+ items?: number | undefined;
145
+ page?: number | undefined;
146
+ };
147
+ headers: unknown;
148
+ response: {
149
+ 200: {
150
+ tokenId: string;
151
+ amount: bigint;
152
+ };
153
+ 422: {
154
+ type: "validation";
155
+ on: string;
156
+ summary?: string;
157
+ message?: string;
158
+ found?: unknown;
159
+ property?: string;
160
+ expected?: string;
161
+ };
162
+ };
163
+ };
164
+ };
165
+ };
166
+ };
167
+ } & {
168
+ campaign: {
169
+ ":campaignId": {
170
+ count: {
171
+ get: {
172
+ body: unknown;
173
+ params: {
174
+ campaignId: string;
175
+ };
176
+ query: {
177
+ items?: number | undefined;
178
+ page?: number | undefined;
179
+ };
180
+ headers: unknown;
181
+ response: {
182
+ 200: {
183
+ count: number;
184
+ };
185
+ 422: {
186
+ type: "validation";
187
+ on: string;
188
+ summary?: string;
189
+ message?: string;
190
+ found?: unknown;
191
+ property?: string;
192
+ expected?: string;
193
+ };
194
+ };
195
+ };
196
+ };
197
+ };
198
+ };
99
199
  } & {
100
200
  token: {
101
201
  index: {
@@ -105,12 +205,18 @@ export declare const RewardController: Elysia<"/rewards", {
105
205
  query: {
106
206
  items?: number | undefined;
107
207
  page?: number | undefined;
208
+ campaignIds?: string[] | undefined;
108
209
  chainId: number;
109
210
  address: string;
110
211
  };
111
212
  headers: unknown;
112
213
  response: {
113
- 200: import("./reward.model").BreakdownForTokenRaw[];
214
+ 200: {
215
+ amount: string;
216
+ claimed: string;
217
+ pending: string;
218
+ recipient: string;
219
+ }[];
114
220
  422: {
115
221
  type: "validation";
116
222
  on: string;
@@ -133,6 +239,7 @@ export declare const RewardController: Elysia<"/rewards", {
133
239
  query: {
134
240
  items?: number | undefined;
135
241
  page?: number | undefined;
242
+ campaignIds?: string[] | undefined;
136
243
  chainId: number;
137
244
  address: string;
138
245
  };
@@ -164,6 +271,7 @@ export declare const RewardController: Elysia<"/rewards", {
164
271
  query: {
165
272
  items?: number | undefined;
166
273
  page?: number | undefined;
274
+ campaignIds?: string[] | undefined;
167
275
  chainId: number;
168
276
  address: string;
169
277
  };
@@ -3,7 +3,9 @@ import { AuthorizationHeadersDto, EngineGuard } from "../../../guards/Engine.gua
3
3
  import { throwOnInvalidRequiredAddress, throwOnUnsupportedChainId } from "../../../utils/throw";
4
4
  import Elysia from "elysia";
5
5
  import { ChainDto } from "../accounting";
6
- import { CampaignIdDto, CampaignIdWithoutPageDto, CreateManyBreakdownDto, CreateManyRewardDto, RegisterClaimsDto, TokenIdDto, UpdatePendingDto, } from "./reward.model";
6
+ import { CampaignService } from "../campaign";
7
+ import { TokenService } from "../token";
8
+ import { CampaignIdDto, CampaignIdWithoutPageDto, CampaignRewardsDto, CreateManyBreakdownDto, CreateManyRewardDto, RegisterClaimsDto, TokenIdDto, UpdatePendingDto, } from "./reward.model";
7
9
  import { RewardService } from "./reward.service";
8
10
  // ─── Rewards Controller ──────────────────────────────────────────────────────
9
11
  export const RewardController = new Elysia({ prefix: "/rewards", detail: { tags: ["Rewards"] } })
@@ -33,35 +35,41 @@ export const RewardController = new Elysia({ prefix: "/rewards", detail: { tags:
33
35
  },
34
36
  detail: { hide: true },
35
37
  })
36
- .group("/token", app => {
37
- return (app
38
- // ─── Get Reward Breakdowns For Token ───────────────────────────────
39
- .get("/", async ({ query }) => await RewardService.breakdownForToken(query), {
40
- query: TokenIdDto,
41
- beforeHandle: ({ query }) => {
42
- query.address = throwOnInvalidRequiredAddress(query.address);
43
- throwOnUnsupportedChainId(query.chainId);
44
- },
45
- detail: { hide: true },
38
+ // ─── Get Reward by campaign ─────────────
39
+ .group("/campaign/:campaignId", app => {
40
+ return app
41
+ .resolve(async ({ params: { campaignId } }) => {
42
+ const campaign = await CampaignService.findUniqueOrThrow(CampaignService.splitIdOrThrow(campaignId));
43
+ const token = await TokenService.findUniqueOrThrow(campaign.rewardTokenId);
44
+ const rewardQuery = {
45
+ chainId: token.chainId,
46
+ address: token.address,
47
+ campaignIds: [campaign.campaignId],
48
+ };
49
+ return { campaign, token, rewardQuery };
46
50
  })
47
- // ─── Get Total Amount Rewarded For Token ───────────────────────────
48
- .get("/total", async ({ query }) => await RewardService.totalForToken(query), {
49
- query: TokenIdDto,
50
- beforeHandle: ({ query }) => {
51
- query.address = throwOnInvalidRequiredAddress(query.address);
52
- throwOnUnsupportedChainId(query.chainId);
53
- },
51
+ .guard({
52
+ query: CampaignRewardsDto,
54
53
  detail: { hide: true },
55
54
  })
56
- // ─── Get Reward Count By Chain And Root For Token ───────────────────
57
- .get("/count", async ({ query }) => await RewardService.countForToken(query), {
55
+ .get("/", async ({ query, rewardQuery }) => await RewardService.breakdownForToken({ ...query, ...rewardQuery }))
56
+ .get("/total", async ({ query, rewardQuery }) => await RewardService.totalForToken({ ...query, ...rewardQuery }))
57
+ .get("/count", async ({ query, rewardQuery }) => await RewardService.countForToken({ ...query, ...rewardQuery }));
58
+ })
59
+ // ─── Get Reward Breakdowns For Token ───────────────────────────────
60
+ .group("/token", app => {
61
+ return app
62
+ .guard({
58
63
  query: TokenIdDto,
59
64
  beforeHandle: ({ query }) => {
60
65
  query.address = throwOnInvalidRequiredAddress(query.address);
61
66
  throwOnUnsupportedChainId(query.chainId);
62
67
  },
63
68
  detail: { hide: true },
64
- }));
69
+ })
70
+ .get("/", async ({ query }) => await RewardService.breakdownForToken(query))
71
+ .get("/total", async ({ query }) => await RewardService.totalForToken(query))
72
+ .get("/count", async ({ query }) => await RewardService.countForToken(query));
65
73
  })
66
74
  .group("/engine", app => {
67
75
  return (app
@@ -170,6 +170,11 @@ export declare const CampaignIdDto: import("@sinclair/typebox").TObject<{
170
170
  export declare const TokenIdDto: import("@sinclair/typebox").TObject<{
171
171
  chainId: import("@sinclair/typebox").TNumber;
172
172
  address: import("@sinclair/typebox").TString;
173
+ campaignIds: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>]>, string[]>>;
174
+ page: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
175
+ items: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
176
+ }>;
177
+ export declare const CampaignRewardsDto: import("@sinclair/typebox").TObject<{
173
178
  page: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
174
179
  items: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
175
180
  }>;
@@ -118,6 +118,14 @@ export const TokenIdDto = t.Object({
118
118
  address: t.String({
119
119
  description: "Token Address",
120
120
  }),
121
+ campaignIds: t.Optional(t
122
+ .Transform(t.Union([t.String(), t.Array(t.String())]))
123
+ .Decode(value => (typeof value === "string" ? value.split(",") : value))
124
+ .Encode(value => [...value])),
125
+ page: t.Optional(t.Numeric({ description: "Page number", default: 0 })), // 0-indexed
126
+ items: t.Optional(t.Numeric({ description: "Number of returned rows", default: 20 })), // items per page
127
+ });
128
+ export const CampaignRewardsDto = t.Object({
121
129
  page: t.Optional(t.Numeric({ description: "Page number", default: 0 })), // 0-indexed
122
130
  items: t.Optional(t.Numeric({ description: "Number of returned rows", default: 20 })), // items per page
123
131
  });
@@ -1,9 +1,8 @@
1
- import type { Prisma } from "../../../../database/api/.generated";
2
1
  import type { ChainId } from "@sdk";
3
- import type { BreakdownForCampaignsRaw, BreakdownForTokenRaw, CampaignIdModel, CampaignIdWithoutPageModel, CreateManyBreakdownModel, CreateManyRewardModel, PendingEntity, TokenIdModel } from "./reward.model";
2
+ import type { BreakdownForCampaignsRaw, CampaignIdModel, CampaignIdWithoutPageModel, CreateManyBreakdownModel, CreateManyRewardModel, PendingEntity, TokenIdModel } from "./reward.model";
4
3
  export declare abstract class RewardRepository {
5
- static createManyReward(rewards: CreateManyRewardModel): Promise<Prisma.BatchPayload>;
6
- static createManyBreakdown(data: CreateManyBreakdownModel): Promise<Prisma.BatchPayload>;
4
+ static createManyReward(rewards: CreateManyRewardModel): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
5
+ static createManyBreakdown(data: CreateManyBreakdownModel): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
7
6
  static getByRecipient(recipient: string, roots: string[], withToken: boolean, withTestTokens: boolean, chainFilter?: ChainId[]): Promise<({
8
7
  RewardToken: {
9
8
  symbol: string;
@@ -20,7 +19,6 @@ export declare abstract class RewardRepository {
20
19
  };
21
20
  Breakdown: ({
22
21
  Campaign: {
23
- campaignId: string;
24
22
  Opportunity: {
25
23
  Chain: {
26
24
  name: string;
@@ -71,6 +69,7 @@ export declare abstract class RewardRepository {
71
69
  apr: number;
72
70
  dailyRewards: number;
73
71
  };
72
+ campaignId: string;
74
73
  };
75
74
  } & {
76
75
  reason: string;
@@ -121,8 +120,8 @@ export declare abstract class RewardRepository {
121
120
  rewardCount: number;
122
121
  breakdownCount: number;
123
122
  }>;
124
- static updateRewardClaimed(recipient: string, rewardTokenId: string, amount: string): Promise<Prisma.BatchPayload>;
125
- static updateBreakdownClaimed(recipient: string, rewardTokenId: string, campaignId: string, reason: string, amount: string): Promise<Prisma.BatchPayload>;
123
+ static updateRewardClaimed(recipient: string, rewardTokenId: string, amount: string): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
124
+ static updateBreakdownClaimed(recipient: string, rewardTokenId: string, campaignId: string, reason: string, amount: string): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
126
125
  static findManyBreakdownUniques(uniques: {
127
126
  rewardId: string;
128
127
  campaignId: string;
@@ -188,7 +187,12 @@ export declare abstract class RewardRepository {
188
187
  static countForCampaign(campaignId: string, root: string): Promise<{
189
188
  count: number;
190
189
  }>;
191
- static breakdownForToken(root: string, id: string, query: TokenIdModel): Promise<BreakdownForTokenRaw[]>;
190
+ static breakdownForToken(root: string, id: string, query: TokenIdModel): Promise<{
191
+ amount: string;
192
+ claimed: string;
193
+ pending: string;
194
+ recipient: string;
195
+ }[]>;
192
196
  static totalForToken(tokenId: string, root: string): Promise<{
193
197
  tokenId: string;
194
198
  amount: bigint;
@@ -1,4 +1,6 @@
1
+ import { Campaign, Reward, RewardBreakdown } from "../../../../database/api/.generated/drizzle/schema.ts";
1
2
  import { apiDbClient } from "../../../utils/prisma";
3
+ import { and, eq, inArray, sql } from "drizzle-orm";
2
4
  import { CampaignService } from "../campaign";
3
5
  import { TokenService } from "../token";
4
6
  import { UserService } from "../user";
@@ -325,24 +327,19 @@ export class RewardRepository {
325
327
  return { count };
326
328
  }
327
329
  static async breakdownForToken(root, id, query) {
328
- const { page: _page, items: _items } = query;
330
+ const { page: _page, items: _items, campaignIds } = query;
329
331
  const page = _page || 0;
330
332
  const items = _items || 50;
331
- const result = await apiDbClient.$queryRawUnsafe(`
332
- SELECT
333
- r."amount",
334
- r."claimed",
335
- r."pending",
336
- r."recipient"
337
- FROM
338
- "Reward" r
339
- WHERE
340
- r."root" = $1 AND r."rewardTokenId" = $2
341
- ORDER BY
342
- (r."amount"::numeric + r."pending"::numeric) DESC
343
- LIMIT $3
344
- OFFSET $4
345
- `, root, id, items, items * page);
333
+ const ids = typeof campaignIds === "string" ? [campaignIds] : (campaignIds ?? []);
334
+ const result = await apiDbClient.$drizzle
335
+ .select({ amount: Reward.amount, claimed: Reward.claimed, pending: Reward.pending, recipient: Reward.recipient })
336
+ .from(Reward)
337
+ .innerJoin(RewardBreakdown, eq(RewardBreakdown.rewardId, Reward.id))
338
+ .innerJoin(Campaign, eq(RewardBreakdown.campaignId, Campaign.id))
339
+ .where(and(eq(Reward.root, root), eq(Reward.rewardTokenId, id), ids.length > 0 ? inArray(Campaign.campaignId, ids) : sql `TRUE`))
340
+ .orderBy(sql `(${Reward.amount}::numeric + ${Reward.pending}::numeric) desc`)
341
+ .limit(items)
342
+ .offset(items * page);
346
343
  return result;
347
344
  }
348
345
  static async totalForToken(tokenId, root) {