@merkl/api 0.10.261 → 0.10.263

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.
@@ -233,11 +233,13 @@ declare const eden: {
233
233
  };
234
234
  }>>;
235
235
  campaigns: {
236
- get: (options?: {
236
+ get: (options: {
237
237
  headers?: Record<string, unknown> | undefined;
238
- query?: Record<string, unknown> | undefined;
238
+ query: {
239
+ test?: boolean | undefined;
240
+ };
239
241
  fetch?: RequestInit | undefined;
240
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
242
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
241
243
  200: {
242
244
  protocol?: {
243
245
  name: string;
@@ -549,21 +551,6 @@ declare const eden: {
549
551
  identifier: string;
550
552
  chainId: number;
551
553
  action: import("../../database/api/.generated").$Enums.OpportunityAction;
552
- Campaigns: {
553
- type: import("../../database/api/.generated").$Enums.CampaignType;
554
- id: string;
555
- params: import("database/api/.generated/runtime/library").JsonValue;
556
- subType: number | null;
557
- startTimestamp: bigint;
558
- endTimestamp: bigint;
559
- computeChainId: number;
560
- distributionChainId: number;
561
- campaignId: string;
562
- rewardTokenId: string;
563
- amount: string;
564
- opportunityId: string;
565
- creatorAddress: string;
566
- }[];
567
554
  tvl: number;
568
555
  apr: number;
569
556
  dailyRewards: number;
@@ -3152,21 +3139,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3152
3139
  identifier: string;
3153
3140
  chainId: number;
3154
3141
  action: import("../../database/api/.generated").$Enums.OpportunityAction;
3155
- Campaigns: {
3156
- type: import("../../database/api/.generated").$Enums.CampaignType;
3157
- id: string;
3158
- params: import("database/api/.generated/runtime/library").JsonValue;
3159
- subType: number | null;
3160
- startTimestamp: bigint;
3161
- endTimestamp: bigint;
3162
- computeChainId: number;
3163
- distributionChainId: number;
3164
- campaignId: string;
3165
- rewardTokenId: string;
3166
- amount: string;
3167
- opportunityId: string;
3168
- creatorAddress: string;
3169
- }[];
3170
3142
  tvl: number;
3171
3143
  apr: number;
3172
3144
  dailyRewards: number;
@@ -3324,7 +3296,9 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3324
3296
  params: {
3325
3297
  id: string;
3326
3298
  };
3327
- query: unknown;
3299
+ query: {
3300
+ test?: boolean | undefined;
3301
+ };
3328
3302
  headers: unknown;
3329
3303
  response: {
3330
3304
  200: {
@@ -6578,11 +6552,13 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6578
6552
  };
6579
6553
  }>>;
6580
6554
  campaigns: {
6581
- get: (options?: {
6555
+ get: (options: {
6582
6556
  headers?: Record<string, unknown> | undefined;
6583
- query?: Record<string, unknown> | undefined;
6557
+ query: {
6558
+ test?: boolean | undefined;
6559
+ };
6584
6560
  fetch?: RequestInit | undefined;
6585
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
6561
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
6586
6562
  200: {
6587
6563
  protocol?: {
6588
6564
  name: string;
@@ -6894,21 +6870,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6894
6870
  identifier: string;
6895
6871
  chainId: number;
6896
6872
  action: import("../../database/api/.generated").$Enums.OpportunityAction;
6897
- Campaigns: {
6898
- type: import("../../database/api/.generated").$Enums.CampaignType;
6899
- id: string;
6900
- params: import("database/api/.generated/runtime/library").JsonValue;
6901
- subType: number | null;
6902
- startTimestamp: bigint;
6903
- endTimestamp: bigint;
6904
- computeChainId: number;
6905
- distributionChainId: number;
6906
- campaignId: string;
6907
- rewardTokenId: string;
6908
- amount: string;
6909
- opportunityId: string;
6910
- creatorAddress: string;
6911
- }[];
6912
6873
  tvl: number;
6913
6874
  apr: number;
6914
6875
  dailyRewards: number;
@@ -337,21 +337,6 @@ declare const app: Elysia<"", false, {
337
337
  identifier: string;
338
338
  chainId: number;
339
339
  action: import("../database/api/.generated").$Enums.OpportunityAction;
340
- Campaigns: {
341
- type: import("../database/api/.generated").$Enums.CampaignType;
342
- id: string;
343
- params: import("database/api/.generated/runtime/library").JsonValue;
344
- subType: number | null;
345
- startTimestamp: bigint;
346
- endTimestamp: bigint;
347
- computeChainId: number;
348
- distributionChainId: number;
349
- campaignId: string;
350
- rewardTokenId: string;
351
- amount: string;
352
- opportunityId: string;
353
- creatorAddress: string;
354
- }[];
355
340
  tvl: number;
356
341
  apr: number;
357
342
  dailyRewards: number;
@@ -509,7 +494,9 @@ declare const app: Elysia<"", false, {
509
494
  params: {
510
495
  id: string;
511
496
  };
512
- query: unknown;
497
+ query: {
498
+ test?: boolean | undefined;
499
+ };
513
500
  headers: unknown;
514
501
  response: {
515
502
  200: {
@@ -1,6 +1,6 @@
1
1
  import type { Pricer } from "../../../../../utils/pricer";
2
2
  import { type Campaign, type CampaignParameters } from "@sdk";
3
- import type { tokenType } from "../helpers/tokenType";
3
+ import type { tokenType, tokenTypeStruct } from "../helpers/tokenType";
4
4
  import { GenericProcessor, type dataType, type mandatoryCallKeys } from "./GenericProcessor";
5
5
  type callType = {
6
6
  key: keyof dataRawUni;
@@ -37,6 +37,8 @@ export declare class UniswapProcessor extends GenericProcessor<callKeysUni, data
37
37
  round3: callType[];
38
38
  round4: callType[];
39
39
  };
40
+ processingRound2(typeInfo: dataRawUni): void;
41
+ computeRound3(index: number, type: tokenType, typeInfo: dataRawUni, calls: string[]): tokenTypeStruct;
40
42
  processingRound5(_index: number, type: tokenType, typeInfo: dataRawUni, _calls: string[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.EULER>, pricer: Pricer): Promise<dataTypeUni>;
41
43
  }
42
44
  export {};
@@ -1,4 +1,5 @@
1
1
  import { generateCardName } from "../../../../../utils/generateCardName";
2
+ import { log } from "../../../../../utils/logger";
2
3
  import { BN2Number } from "@sdk";
3
4
  import { GenericProcessor } from "./GenericProcessor";
4
5
  export class UniswapProcessor extends GenericProcessor {
@@ -18,6 +19,21 @@ export class UniswapProcessor extends GenericProcessor {
18
19
  round3: [],
19
20
  round4: [{ key: "totalSupply", call: "totalSupply", target: "tokenAddress" }],
20
21
  };
22
+ processingRound2(typeInfo) {
23
+ if (typeInfo.tokenAddress === "0x45856bD6Bb9f076F4C558A4D5932c6c8d832b0d0") {
24
+ log.local("Processing round 2 for UniswapProcessor on classic pools");
25
+ this.rounds.round2[4] = { key: "balanceToken0", call: "reserve0", target: "tokenAddress" };
26
+ this.rounds.round2[5] = { key: "balanceToken1", call: "reserve1", target: "tokenAddress" };
27
+ }
28
+ }
29
+ computeRound3(index, type, typeInfo, calls) {
30
+ if (typeInfo.tokenAddress === "0x45856bD6Bb9f076F4C558A4D5932c6c8d832b0d0") {
31
+ log.local("Computing round 3 for UniswapProcessor on classic pools");
32
+ this.rounds.round2[4] = { key: "balanceToken0", call: "reserve0", target: "tokenAddress" };
33
+ this.rounds.round2[5] = { key: "balanceToken1", call: "reserve1", target: "tokenAddress" };
34
+ }
35
+ return super.computeRound3(index, type, typeInfo, calls);
36
+ }
21
37
  async processingRound5(_index, type, typeInfo, _calls, campaign, pricer) {
22
38
  const { whitelistedSupplyTargetToken, totalSupply, blacklistedSupply } = this.handleWhiteListBlacklistRound5(typeInfo, campaign);
23
39
  const decimalsToken0 = Number(typeInfo.decimalsToken0);
@@ -206,21 +206,6 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
206
206
  identifier: string;
207
207
  chainId: number;
208
208
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
209
- Campaigns: {
210
- type: import("../../../../database/api/.generated").$Enums.CampaignType;
211
- id: string;
212
- params: import("database/api/.generated/runtime/library").JsonValue;
213
- subType: number | null;
214
- startTimestamp: bigint;
215
- endTimestamp: bigint;
216
- computeChainId: number;
217
- distributionChainId: number;
218
- campaignId: string;
219
- rewardTokenId: string;
220
- amount: string;
221
- opportunityId: string;
222
- creatorAddress: string;
223
- }[];
224
209
  tvl: number;
225
210
  apr: number;
226
211
  dailyRewards: number;
@@ -378,7 +363,9 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
378
363
  params: {
379
364
  id: string;
380
365
  };
381
- query: unknown;
366
+ query: {
367
+ test?: boolean | undefined;
368
+ };
382
369
  headers: unknown;
383
370
  response: {
384
371
  200: {
@@ -88,7 +88,7 @@ export const OpportunityController = new Elysia({
88
88
  detail: { description: "Get a unique opportunity." },
89
89
  })
90
90
  // ─── Get An Opportunity By Id With Related Campaigns ─────────────────
91
- .get("/:id/campaigns", async ({ params }) => {
91
+ .get("/:id/campaigns", async ({ query, params }) => {
92
92
  try {
93
93
  if (!params.id.includes("-"))
94
94
  return await OpportunityService.getUniqueWithCampaignsOrThrow(params.id);
@@ -97,7 +97,7 @@ export const OpportunityController = new Elysia({
97
97
  chainId: +chainId,
98
98
  type: type,
99
99
  identifier,
100
- });
100
+ }, query.test ?? false);
101
101
  // Todo: need to be refactor Parsing issue
102
102
  const campaignsFormatted = oppWithCampaigns.campaigns.map(campaign => {
103
103
  if (!campaign.distributionChain)
@@ -114,6 +114,7 @@ export const OpportunityController = new Elysia({
114
114
  throw err;
115
115
  }
116
116
  }, {
117
+ query: GetOpportunityQueryDto,
117
118
  params: OpportunityUniqueDto,
118
119
  transform: transformId,
119
120
  beforeHandle: validateId,
@@ -174,21 +174,6 @@ export declare abstract class OpportunityRepository {
174
174
  id: number;
175
175
  icon: string;
176
176
  };
177
- Campaigns: {
178
- type: import("../../../../database/api/.generated").$Enums.CampaignType;
179
- id: string;
180
- params: Prisma.JsonValue;
181
- subType: number | null;
182
- startTimestamp: bigint;
183
- endTimestamp: bigint;
184
- computeChainId: number;
185
- distributionChainId: number;
186
- campaignId: string;
187
- rewardTokenId: string;
188
- amount: string;
189
- opportunityId: string;
190
- creatorAddress: string;
191
- }[];
192
177
  Tokens: {
193
178
  symbol: string;
194
179
  name: string | null;
@@ -301,7 +286,7 @@ export declare abstract class OpportunityRepository {
301
286
  apr: number;
302
287
  dailyRewards: number;
303
288
  }>;
304
- static findUniqueOrThrowWithCampaigns(id: string): Promise<{
289
+ static findUniqueOrThrowWithCampaigns(id: string, withTest: boolean): Promise<{
305
290
  Chain: {
306
291
  Explorer: {
307
292
  type: import("../../../../database/api/.generated").$Enums.ExplorerType;
@@ -133,20 +133,11 @@ export class OpportunityRepository {
133
133
  MainProtocol: true,
134
134
  Protocols: true,
135
135
  Tokens: true,
136
- Campaigns: withTest
137
- ? undefined
138
- : {
139
- where: {
140
- RewardToken: {
141
- isTest: false,
142
- },
143
- },
144
- },
145
136
  },
146
137
  where: { id },
147
138
  });
148
139
  }
149
- static async findUniqueOrThrowWithCampaigns(id) {
140
+ static async findUniqueOrThrowWithCampaigns(id, withTest) {
150
141
  const b = await apiDbClient.opportunity.findUniqueOrThrow({
151
142
  include: {
152
143
  ...OpportunityRepository.#getRecordInclusion(),
@@ -156,6 +147,13 @@ export class OpportunityRepository {
156
147
  },
157
148
  },
158
149
  Campaigns: {
150
+ where: withTest
151
+ ? undefined
152
+ : {
153
+ RewardToken: {
154
+ isTest: false,
155
+ },
156
+ },
159
157
  include: {
160
158
  RewardToken: true,
161
159
  ComputeChain: true,
@@ -80,7 +80,7 @@ export declare abstract class OpportunityService {
80
80
  tags: string[];
81
81
  }>;
82
82
  static updateMetadata(chain: ChainId): Promise<void>;
83
- static getUniqueWithCampaignsOrThrow(opportunityId: string | OpportunityUnique): Promise<OpportunityWithCampaignsResourceModel>;
83
+ static getUniqueWithCampaignsOrThrow(opportunityId: string | OpportunityUnique, withTest?: boolean): Promise<OpportunityWithCampaignsResourceModel>;
84
84
  static getUniqueOrThrow(opportunityId: string | OpportunityUnique, withTest?: boolean): Promise<OpportunityResourceModel>;
85
85
  /**
86
86
  * Get the list of opportunities satisfying the query
@@ -171,21 +171,6 @@ export declare abstract class OpportunityService {
171
171
  identifier: string;
172
172
  chainId: number;
173
173
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
174
- Campaigns: {
175
- type: import("../../../../database/api/.generated").$Enums.CampaignType;
176
- id: string;
177
- params: Prisma.JsonValue;
178
- subType: number | null;
179
- startTimestamp: bigint;
180
- endTimestamp: bigint;
181
- computeChainId: number;
182
- distributionChainId: number;
183
- campaignId: string;
184
- rewardTokenId: string;
185
- amount: string;
186
- opportunityId: string;
187
- creatorAddress: string;
188
- }[];
189
174
  tvl: number;
190
175
  apr: number;
191
176
  dailyRewards: number;
@@ -274,21 +259,6 @@ export declare abstract class OpportunityService {
274
259
  identifier: string;
275
260
  chainId: number;
276
261
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
277
- Campaigns: {
278
- type: import("../../../../database/api/.generated").$Enums.CampaignType;
279
- id: string;
280
- params: Prisma.JsonValue;
281
- subType: number | null;
282
- startTimestamp: bigint;
283
- endTimestamp: bigint;
284
- computeChainId: number;
285
- distributionChainId: number;
286
- campaignId: string;
287
- rewardTokenId: string;
288
- amount: string;
289
- opportunityId: string;
290
- creatorAddress: string;
291
- }[];
292
262
  tvl: number;
293
263
  apr: number;
294
264
  dailyRewards: number;
@@ -434,21 +404,6 @@ export declare abstract class OpportunityService {
434
404
  identifier: string;
435
405
  chainId: number;
436
406
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
437
- Campaigns: {
438
- type: import("../../../../database/api/.generated").$Enums.CampaignType;
439
- id: string;
440
- params: Prisma.JsonValue;
441
- subType: number | null;
442
- startTimestamp: bigint;
443
- endTimestamp: bigint;
444
- computeChainId: number;
445
- distributionChainId: number;
446
- campaignId: string;
447
- rewardTokenId: string;
448
- amount: string;
449
- opportunityId: string;
450
- creatorAddress: string;
451
- }[];
452
407
  tvl: number;
453
408
  apr: number;
454
409
  dailyRewards: number;
@@ -489,21 +444,6 @@ export declare abstract class OpportunityService {
489
444
  identifier: string;
490
445
  chainId: number;
491
446
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
492
- Campaigns: {
493
- type: import("../../../../database/api/.generated").$Enums.CampaignType;
494
- id: string;
495
- params: Prisma.JsonValue;
496
- subType: number | null;
497
- startTimestamp: bigint;
498
- endTimestamp: bigint;
499
- computeChainId: number;
500
- distributionChainId: number;
501
- campaignId: string;
502
- rewardTokenId: string;
503
- amount: string;
504
- opportunityId: string;
505
- creatorAddress: string;
506
- }[];
507
447
  tvl: number;
508
448
  apr: number;
509
449
  dailyRewards: number;
@@ -157,9 +157,9 @@ export class OpportunityService {
157
157
  throw err;
158
158
  }
159
159
  }
160
- static async getUniqueWithCampaignsOrThrow(opportunityId) {
160
+ static async getUniqueWithCampaignsOrThrow(opportunityId, withTest = false) {
161
161
  const id = typeof opportunityId === "string" ? opportunityId : OpportunityService.hashId(opportunityId);
162
- const { Campaigns, ...opportunity } = await OpportunityRepository.findUniqueOrThrowWithCampaigns(id);
162
+ const { Campaigns, ...opportunity } = await OpportunityRepository.findUniqueOrThrowWithCampaigns(id, withTest);
163
163
  const formatted = OpportunityService.formatResponse(opportunity);
164
164
  return Object.assign(formatted, { campaigns: Campaigns.map(CampaignService.format) });
165
165
  }
@@ -215,21 +215,6 @@ export declare const v4: Elysia<"/v4", false, {
215
215
  identifier: string;
216
216
  chainId: number;
217
217
  action: import("../../../database/api/.generated").$Enums.OpportunityAction;
218
- Campaigns: {
219
- type: import("../../../database/api/.generated").$Enums.CampaignType;
220
- id: string;
221
- params: import("database/api/.generated/runtime/library").JsonValue;
222
- subType: number | null;
223
- startTimestamp: bigint;
224
- endTimestamp: bigint;
225
- computeChainId: number;
226
- distributionChainId: number;
227
- campaignId: string;
228
- rewardTokenId: string;
229
- amount: string;
230
- opportunityId: string;
231
- creatorAddress: string;
232
- }[];
233
218
  tvl: number;
234
219
  apr: number;
235
220
  dailyRewards: number;
@@ -387,7 +372,9 @@ export declare const v4: Elysia<"/v4", false, {
387
372
  params: {
388
373
  id: string;
389
374
  };
390
- query: unknown;
375
+ query: {
376
+ test?: boolean | undefined;
377
+ };
391
378
  headers: unknown;
392
379
  response: {
393
380
  200: {
@@ -1,4 +1,5 @@
1
1
  import { AaveInterface, AccountantWithRateProvidersInterface, AuraInterface, AuraOperatorInterface, BalancerGaugeInterface, BalancerPoolInterface, BalancerVaultInterface, BeefyInterface, CPMMGammaPoolMainInterface, CompoundInterface, CurveInterface, CurveStableSwapNGInterface, DefutureVaultInterface, ERC20Interface, EnzymeInterface, EulerInterface, FactoryInterface, FluidInterface, FraxlendInterface, GearboxVaultInterface, IonicInterface, LayerBankInterface, MaverickBPLensInterface, MetamorphoInterface, MoonwellInterface, OneInchStakingInterface, PendleInterface, PendleYTInterface, RadiantInterface, RfxInterface, RswEthStrategyInterface, SturdyInterface, SymetricAmbientStrategyInterface, TorosInterface, UniswapV2PoolInterface, VePufferInterface, ZFStableLPINterface, ZFStableSwapThreePoolInterface, } from "@sdk";
2
+ import { SyncSwapClassicPoolInterface } from "libs/sdk/src/merkl/interface";
2
3
  import { tokenType } from "../libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType";
3
4
  export function decodeCall(calls, index, key, type) {
4
5
  const returnData = calls[index];
@@ -229,6 +230,10 @@ export function decodeCall(calls, index, key, type) {
229
230
  ];
230
231
  case "tokenBalances":
231
232
  return CPMMGammaPoolMainInterface.decodeFunctionResult("getLatestCFMMBalances", returnData)[0];
233
+ case "reserve0":
234
+ return SyncSwapClassicPoolInterface.decodeFunctionResult("reserve0", returnData)[0];
235
+ case "reserve1":
236
+ return SyncSwapClassicPoolInterface.decodeFunctionResult("reserve1", returnData)[0];
232
237
  default:
233
238
  throw new Error(`Key not recognized for ${key}`);
234
239
  }
@@ -1,5 +1,6 @@
1
1
  import { tokenType } from "../libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType";
2
2
  import { AaveInterface, AccountantWithRateProvidersInterface, AuraInterface, AuraOperatorInterface, BalancerGaugeInterface, BalancerPoolInterface, BalancerVaultInterface, BeefyInterface, CPMMGammaPoolMainInterface, CompoundInterface, CurveInterface, CurveStableSwapNGInterface, DefutureVaultInterface, ERC20Interface, EnzymeInterface, EulerInterface, FactoryInterface, FluidInterface, FraxlendInterface, GearboxVaultInterface, IonicInterface, LayerBankInterface, MaverickBPLensInterface, MetamorphoInterface, MoonwellInterface, OneInchStakingInterface, PendleInterface, PendleYTInterface, RadiantInterface, RfxDatastoreInterface, RswEthStrategyInterface, SturdyInterface, SymetricAmbientStrategyInterface, TorosInterface, UniswapV2PoolInterface, VePufferInterface, ZFStableLPINterface, } from "@sdk";
3
+ import { SyncSwapClassicPoolInterface } from "libs/sdk/src/merkl/interface";
3
4
  export function createCall(target, key, type, metaData) {
4
5
  switch (key) {
5
6
  case "SY":
@@ -350,6 +351,18 @@ export function createCall(target, key, type, metaData) {
350
351
  callData: UniswapV2PoolInterface.encodeFunctionData("getReserves"),
351
352
  target: target,
352
353
  };
354
+ case "reserve0":
355
+ return {
356
+ allowFailure: true,
357
+ callData: SyncSwapClassicPoolInterface.encodeFunctionData("reserve0"),
358
+ target: target,
359
+ };
360
+ case "reserve1":
361
+ return {
362
+ allowFailure: true,
363
+ callData: SyncSwapClassicPoolInterface.encodeFunctionData("reserve1"),
364
+ target: target,
365
+ };
353
366
  default:
354
367
  throw new Error(`Unknown key ${key}`);
355
368
  }