@merkl/api 0.10.295 → 0.10.297

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.
@@ -2229,8 +2229,10 @@ declare const eden: {
2229
2229
  query?: Record<string, unknown> | undefined;
2230
2230
  fetch?: RequestInit | undefined;
2231
2231
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
2232
- [x: string]: any;
2233
- 200: any;
2232
+ 200: {
2233
+ address: string;
2234
+ boost: string;
2235
+ }[];
2234
2236
  }>>;
2235
2237
  };
2236
2238
  };
@@ -5597,8 +5599,10 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
5597
5599
  authorization: string;
5598
5600
  };
5599
5601
  response: {
5600
- [x: string]: any;
5601
- 200: any;
5602
+ 200: {
5603
+ address: string;
5604
+ boost: string;
5605
+ }[];
5602
5606
  };
5603
5607
  };
5604
5608
  };
@@ -8593,8 +8597,10 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
8593
8597
  query?: Record<string, unknown> | undefined;
8594
8598
  fetch?: RequestInit | undefined;
8595
8599
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
8596
- [x: string]: any;
8597
- 200: any;
8600
+ 200: {
8601
+ address: string;
8602
+ boost: string;
8603
+ }[];
8598
8604
  }>>;
8599
8605
  };
8600
8606
  };
@@ -2778,8 +2778,10 @@ declare const app: Elysia<"", false, {
2778
2778
  authorization: string;
2779
2779
  };
2780
2780
  response: {
2781
- [x: string]: any;
2782
- 200: any;
2781
+ 200: {
2782
+ address: string;
2783
+ boost: string;
2784
+ }[];
2783
2785
  };
2784
2786
  };
2785
2787
  };
@@ -27,8 +27,10 @@ export declare const BoostController: Elysia<"/boosts", false, {
27
27
  authorization: string;
28
28
  };
29
29
  response: {
30
- [x: string]: any;
31
- 200: any;
30
+ 200: {
31
+ address: string;
32
+ boost: string;
33
+ }[];
32
34
  };
33
35
  };
34
36
  };
@@ -1,3 +1,6 @@
1
1
  export declare class BoostService {
2
- static getEulerBoost(): Promise<any>;
2
+ static getEulerBoost(): Promise<{
3
+ address: string;
4
+ boost: string;
5
+ }[]>;
3
6
  }
@@ -1,6 +1,6 @@
1
1
  import axios from "axios";
2
2
  export class BoostService {
3
3
  static async getEulerBoost() {
4
- return (await axios.get("https://points.euler.finance/integrations/merkl/usd0multipliers")).data;
4
+ return (await axios.get("https://points.euler.finance/integrations/merkl/usd0multipliers")).data.map(({ address, score }) => ({ address, boost: score }));
5
5
  }
6
6
  }
@@ -132,6 +132,18 @@ export declare abstract class RewardRepository {
132
132
  recipient: string;
133
133
  };
134
134
  }[]>;
135
+ static upsertPendings(rewardTokenId: string, root: string, campaignId: string, toUpdate: PendingEntity[]): Promise<{
136
+ reason: string;
137
+ pending: string;
138
+ id: number;
139
+ campaignId: string;
140
+ amount: string;
141
+ protocolId: string | null;
142
+ claimed: string;
143
+ auxiliaryData1: string | null;
144
+ auxiliaryData2: string | null;
145
+ rewardId: string;
146
+ }[]>;
135
147
  static updatePendings(rewardTokenId: string, root: string, campaignId: string, toUpdate: PendingEntity[]): Promise<{
136
148
  reason: string;
137
149
  pending: string;
@@ -158,6 +158,46 @@ export class RewardRepository {
158
158
  },
159
159
  });
160
160
  }
161
+ static async upsertPendings(rewardTokenId, root, campaignId, toUpdate) {
162
+ const users = toUpdate.map(x => x.recipient);
163
+ await UserService.createMany(users.map(x => ({ address: x, tags: [] })));
164
+ return await apiDbClient.$transaction(toUpdate.map(x => {
165
+ const rewardId = RewardService.hashId(root, x.recipient, rewardTokenId);
166
+ return apiDbClient.rewardBreakdown.upsert({
167
+ where: {
168
+ rewardId_campaignId_reason: {
169
+ rewardId: RewardService.hashId(root, x.recipient, rewardTokenId),
170
+ campaignId: campaignId,
171
+ reason: x.reason,
172
+ },
173
+ },
174
+ update: {
175
+ pending: x.pending,
176
+ auxiliaryData1: x.auxiliaryData1,
177
+ auxiliaryData2: x.auxiliaryData2,
178
+ },
179
+ create: {
180
+ reason: x.reason,
181
+ amount: "0",
182
+ pending: x.pending,
183
+ claimed: "0",
184
+ Reward: {
185
+ connectOrCreate: {
186
+ where: { id: rewardId },
187
+ create: {
188
+ id: rewardId,
189
+ MerklRoot: { connect: { root } },
190
+ User: { connect: { address: x.recipient } },
191
+ RewardToken: { connect: { id: rewardTokenId } },
192
+ proofs: [],
193
+ },
194
+ },
195
+ },
196
+ Campaign: { connect: { id: campaignId } },
197
+ },
198
+ });
199
+ }));
200
+ }
161
201
  static async updatePendings(rewardTokenId, root, campaignId, toUpdate) {
162
202
  return await apiDbClient.$transaction(toUpdate.map(x => {
163
203
  return apiDbClient.rewardBreakdown.update({
@@ -170,7 +210,6 @@ export class RewardRepository {
170
210
  },
171
211
  data: {
172
212
  pending: x.pending,
173
- reason: x.reason,
174
213
  auxiliaryData1: x.auxiliaryData1,
175
214
  auxiliaryData2: x.auxiliaryData2,
176
215
  },
@@ -238,20 +238,23 @@ export class RewardService {
238
238
  distributionChain: data.distributionChainId,
239
239
  campaignId: data.campaignId,
240
240
  });
241
- const ids = (await RewardRepository.findManyBreakdownUniques(rewardTokenId, data.root, campaignId)).map(({ Reward, reason }) => Bun.hash(`${Reward.recipient}${reason}`).toString());
242
- const toUpdate = [];
243
- const toCreate = [];
244
- for (const point of data.data) {
245
- if (ids.includes(Bun.hash(`${point.recipient}${point.reason}`).toString())) {
246
- toUpdate.push(point);
247
- }
248
- else {
249
- toCreate.push(point);
250
- }
251
- }
252
- await RewardRepository.updatePendings(rewardTokenId, data.root, campaignId, toUpdate);
253
- await RewardRepository.createPendings(rewardTokenId, data.root, campaignId, toCreate);
254
- return { created: toCreate.length, updated: toUpdate.length };
241
+ // const ids = (await RewardRepository.findManyBreakdownUniques(rewardTokenId, data.root, campaignId)).map(
242
+ // ({ Reward, reason }) => Bun.hash(`${Reward.recipient}${reason}`).toString()
243
+ // );
244
+ // const toUpdate = [];
245
+ // const toCreate = [];
246
+ // for (const point of data.data) {
247
+ // if (ids.includes(Bun.hash(`${point.recipient}${point.reason}`).toString())) {
248
+ // toUpdate.push(point);
249
+ // } else {
250
+ // toCreate.push(point);
251
+ // }
252
+ // }
253
+ // await RewardRepository.updatePendings(rewardTokenId, data.root, campaignId, toUpdate);
254
+ // await RewardRepository.createPendings(rewardTokenId, data.root, campaignId, toCreate);
255
+ // return { created: toCreate.length, updated: toUpdate.length };
256
+ await RewardRepository.upsertPendings(rewardTokenId, data.root, campaignId, data.data);
257
+ return { created: data.data.length, updated: 0 };
255
258
  }
256
259
  static async countAllchains() {
257
260
  const rewardPerRewardTokenId = await RewardRepository.countRewardPerRewardTokenIdAndRoot();
@@ -2656,8 +2656,10 @@ export declare const v4: Elysia<"/v4", false, {
2656
2656
  authorization: string;
2657
2657
  };
2658
2658
  response: {
2659
- [x: string]: any;
2660
- 200: any;
2659
+ 200: {
2660
+ address: string;
2661
+ boost: string;
2662
+ }[];
2661
2663
  };
2662
2664
  };
2663
2665
  };