@merkl/api 0.10.153 → 0.10.155

Sign up to get free protection for your applications and to get access to all the features.
@@ -541,17 +541,6 @@ declare const eden: {
541
541
  }[];
542
542
  }[];
543
543
  }>>;
544
- post: (body: unknown, options: {
545
- headers: {
546
- authorization: string;
547
- };
548
- query: {
549
- chainId: number;
550
- };
551
- fetch?: RequestInit | undefined;
552
- }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
553
- 200: string;
554
- }>>;
555
544
  };
556
545
  count: {
557
546
  get: (options: {
@@ -564,6 +553,21 @@ declare const eden: {
564
553
  200: number;
565
554
  }>>;
566
555
  };
556
+ engine: {
557
+ "": {
558
+ post: (body: unknown, options: {
559
+ headers: {
560
+ authorization: string;
561
+ };
562
+ query: {
563
+ chainId: number;
564
+ };
565
+ fetch?: RequestInit | undefined;
566
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
567
+ 200: string;
568
+ }>>;
569
+ };
570
+ };
567
571
  };
568
572
  };
569
573
  protocols: ((params: {
@@ -1222,7 +1226,7 @@ declare const eden: {
1222
1226
  get: (options: {
1223
1227
  headers?: Record<string, unknown> | undefined;
1224
1228
  query: {
1225
- chainId: number | number[];
1229
+ chainId: number[];
1226
1230
  };
1227
1231
  fetch?: RequestInit | undefined;
1228
1232
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
@@ -2398,18 +2402,20 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
2398
2402
  };
2399
2403
  } & {
2400
2404
  "campaigns-to-process": {
2401
- index: {
2402
- post: {
2403
- body: unknown;
2404
- params: {};
2405
- query: {
2406
- chainId: number;
2407
- };
2408
- headers: {
2409
- authorization: string;
2410
- };
2411
- response: {
2412
- 200: string;
2405
+ engine: {
2406
+ "": {
2407
+ post: {
2408
+ body: unknown;
2409
+ params: {};
2410
+ query: {
2411
+ chainId: number;
2412
+ };
2413
+ headers: {
2414
+ authorization: string;
2415
+ };
2416
+ response: {
2417
+ 200: string;
2418
+ };
2413
2419
  };
2414
2420
  };
2415
2421
  };
@@ -3313,7 +3319,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3313
3319
  address: string;
3314
3320
  };
3315
3321
  query: {
3316
- chainId: number | number[];
3322
+ chainId: number[];
3317
3323
  };
3318
3324
  headers: unknown;
3319
3325
  response: {
@@ -4494,17 +4500,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
4494
4500
  }[];
4495
4501
  }[];
4496
4502
  }>>;
4497
- post: (body: unknown, options: {
4498
- headers: {
4499
- authorization: string;
4500
- };
4501
- query: {
4502
- chainId: number;
4503
- };
4504
- fetch?: RequestInit | undefined;
4505
- }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
4506
- 200: string;
4507
- }>>;
4508
4503
  };
4509
4504
  count: {
4510
4505
  get: (options: {
@@ -4517,6 +4512,21 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
4517
4512
  200: number;
4518
4513
  }>>;
4519
4514
  };
4515
+ engine: {
4516
+ "": {
4517
+ post: (body: unknown, options: {
4518
+ headers: {
4519
+ authorization: string;
4520
+ };
4521
+ query: {
4522
+ chainId: number;
4523
+ };
4524
+ fetch?: RequestInit | undefined;
4525
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
4526
+ 200: string;
4527
+ }>>;
4528
+ };
4529
+ };
4520
4530
  };
4521
4531
  };
4522
4532
  protocols: ((params: {
@@ -5175,7 +5185,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
5175
5185
  get: (options: {
5176
5186
  headers?: Record<string, unknown> | undefined;
5177
5187
  query: {
5178
- chainId: number | number[];
5188
+ chainId: number[];
5179
5189
  };
5180
5190
  fetch?: RequestInit | undefined;
5181
5191
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
@@ -640,18 +640,20 @@ declare const app: Elysia<"", false, {
640
640
  };
641
641
  } & {
642
642
  "campaigns-to-process": {
643
- index: {
644
- post: {
645
- body: unknown;
646
- params: {};
647
- query: {
648
- chainId: number;
649
- };
650
- headers: {
651
- authorization: string;
652
- };
653
- response: {
654
- 200: string;
643
+ engine: {
644
+ "": {
645
+ post: {
646
+ body: unknown;
647
+ params: {};
648
+ query: {
649
+ chainId: number;
650
+ };
651
+ headers: {
652
+ authorization: string;
653
+ };
654
+ response: {
655
+ 200: string;
656
+ };
655
657
  };
656
658
  };
657
659
  };
@@ -1555,7 +1557,7 @@ declare const app: Elysia<"", false, {
1555
1557
  address: string;
1556
1558
  };
1557
1559
  query: {
1558
- chainId: number | number[];
1560
+ chainId: number[];
1559
1561
  };
1560
1562
  headers: unknown;
1561
1563
  response: {
package/dist/src/index.js CHANGED
@@ -32,34 +32,10 @@ const app = new Elysia({
32
32
  version: "1.0.1",
33
33
  },
34
34
  },
35
- exclude: [/engine\/*/, /v1\/.*/, /v2\/.*/],
35
+ exclude: [/engine\/*/, /v1\/.*/, /v2\/.*/, /full\/*/],
36
36
  }))
37
37
  .use(cors())
38
38
  .get("/", () => "Merkl API")
39
- .use(swagger({
40
- path: "/docs",
41
- documentation: {
42
- info: {
43
- contact: {
44
- email: "contact@angle.money",
45
- name: "Angle Labs",
46
- },
47
- description: "API to access data related to merkl campaigns, built and maintained by Angle Labs. This API is provided as is, without any warranty of any kind.",
48
- license: {
49
- name: "UNLICENSED",
50
- },
51
- title: "Merkl API v4 (in development)",
52
- version: "1.0.1",
53
- },
54
- tags: [
55
- {
56
- name: "Participate",
57
- description: "Interact with opportunities on-chain",
58
- },
59
- ],
60
- },
61
- exclude: [/v1\/.*/, /v2\/.*/, /v3\/.*/, /docs.*/, "/"],
62
- }))
63
39
  .use(v4)
64
40
  .use(autoroutes({
65
41
  routesDir: `${import.meta.dir}/routes`,
@@ -40,7 +40,10 @@ function satisfiesNameConditions(name, type) {
40
40
  case tokenType.moonwell:
41
41
  return lowerCaseName.includes("moonwell");
42
42
  case tokenType.curve_2:
43
- return lowerCaseName === "crvusd/frax" || lowerCaseName === "ezeth/wfrxeth" || lowerCaseName === "pufeth/wsteth";
43
+ return (lowerCaseName === "crvusd/frax" ||
44
+ lowerCaseName === "ezeth/wfrxeth" ||
45
+ lowerCaseName === "pufeth/wsteth" ||
46
+ lowerCaseName === "hai/lusd");
44
47
  case tokenType.silostaking:
45
48
  return lowerCaseName === "isei";
46
49
  case tokenType.beefy:
@@ -1,4 +1,3 @@
1
- import { engineDbClient } from "../../../utils/prisma";
2
1
  import { apiDbClient } from "src/utils/prisma";
3
2
  export const getLastEligibilityRatio = async (campaign, chainId, currentRoot, backupCampaignIds) => {
4
3
  if (campaign.campaignId === "0x6acb7a8cd2646f18e6e438658273bbee1ed6d664c19779d144cc339decf240ca") {
@@ -30,16 +29,26 @@ export const getLastEligibilityRatio = async (campaign, chainId, currentRoot, ba
30
29
  if (auxLastEligibilityRatio === undefined || auxLastEligibilityRatio === null) {
31
30
  // Otherwise we search in the backup campaigns
32
31
  for (const campaignId of backupCampaignIds) {
33
- auxLastEligibilityRatio = (await engineDbClient.leaves.findFirst({
32
+ const auxLastEligibilityRatioString = (await apiDbClient.rewardBreakdown.findFirst({
34
33
  select: {
35
34
  auxiliaryData1: true,
36
35
  },
37
36
  where: {
38
- chainId: chainId,
39
- campaignId,
40
- root: currentRoot,
37
+ Reward: {
38
+ RewardToken: {
39
+ chainId,
40
+ },
41
+ root: currentRoot,
42
+ },
43
+ campaignId: campaignId,
41
44
  },
42
- }))?.auxiliaryData1?.toNumber();
45
+ orderBy: {
46
+ amount: "desc",
47
+ },
48
+ }))?.auxiliaryData1;
49
+ auxLastEligibilityRatio = !!auxLastEligibilityRatioString
50
+ ? Number.parseFloat(auxLastEligibilityRatioString)
51
+ : null;
43
52
  if (!!auxLastEligibilityRatio)
44
53
  break;
45
54
  }
@@ -179,18 +179,20 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
179
179
  };
180
180
  } & {
181
181
  "campaigns-to-process": {
182
- index: {
183
- post: {
184
- body: unknown;
185
- params: {};
186
- query: {
187
- chainId: number;
188
- };
189
- headers: {
190
- authorization: string;
191
- };
192
- response: {
193
- 200: string;
182
+ engine: {
183
+ "": {
184
+ post: {
185
+ body: unknown;
186
+ params: {};
187
+ query: {
188
+ chainId: number;
189
+ };
190
+ headers: {
191
+ authorization: string;
192
+ };
193
+ response: {
194
+ 200: string;
195
+ };
194
196
  };
195
197
  };
196
198
  };
@@ -34,7 +34,7 @@ export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { t
34
34
  },
35
35
  })
36
36
  // ─── Returns a CampaignId to Process and flags it as PROCESSING ──────-
37
- .post("/", async ({ query }) => await CampaignService.pickCampaignToProcess(query.chainId), {
37
+ .post("/engine/", async ({ query }) => await CampaignService.pickCampaignToProcess(query.chainId), {
38
38
  query: ChainUniqueDto,
39
39
  beforeHandle: async ({ query, headers }) => {
40
40
  await EngineGuard({ headers });
@@ -12,7 +12,7 @@ export declare const ChainUniqueDto: import("@sinclair/typebox").TObject<{
12
12
  chainId: import("@sinclair/typebox").TNumber;
13
13
  }>;
14
14
  export declare const ChainArrayDto: import("@sinclair/typebox").TObject<{
15
- chainId: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>]>;
15
+ chainId: import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>]>, number[]>;
16
16
  }>;
17
17
  export declare const CreateChainExplorerDto: import("@sinclair/typebox").TObject<{
18
18
  type: import("@sinclair/typebox").TEnum<{
@@ -8,7 +8,10 @@ export const ChainUniqueDto = t.Object({
8
8
  chainId: t.Numeric(),
9
9
  });
10
10
  export const ChainArrayDto = t.Object({
11
- chainId: t.Union([t.Numeric(), t.Array(t.Numeric())]),
11
+ chainId: t
12
+ .Transform(t.Union([t.String(), t.Array(t.Numeric())]))
13
+ .Decode(value => (typeof value === "string" ? value.split(",").map(v => Number.parseInt(v)) : value))
14
+ .Encode(value => [...value]),
12
15
  });
13
16
  export const CreateChainExplorerDto = t.Object({
14
17
  type: t.Enum(ExplorerType),
@@ -622,18 +622,20 @@ export declare const v4: Elysia<"/v4", false, {
622
622
  };
623
623
  } & {
624
624
  "campaigns-to-process": {
625
- index: {
626
- post: {
627
- body: unknown;
628
- params: {};
629
- query: {
630
- chainId: number;
631
- };
632
- headers: {
633
- authorization: string;
634
- };
635
- response: {
636
- 200: string;
625
+ engine: {
626
+ "": {
627
+ post: {
628
+ body: unknown;
629
+ params: {};
630
+ query: {
631
+ chainId: number;
632
+ };
633
+ headers: {
634
+ authorization: string;
635
+ };
636
+ response: {
637
+ 200: string;
638
+ };
637
639
  };
638
640
  };
639
641
  };
@@ -1537,7 +1539,7 @@ export declare const v4: Elysia<"/v4", false, {
1537
1539
  address: string;
1538
1540
  };
1539
1541
  query: {
1540
- chainId: number | number[];
1542
+ chainId: number[];
1541
1543
  };
1542
1544
  headers: unknown;
1543
1545
  response: {
@@ -191,7 +191,7 @@ export declare const UserController: Elysia<"/users", false, {
191
191
  address: string;
192
192
  };
193
193
  query: {
194
- chainId: number | number[];
194
+ chainId: number[];
195
195
  };
196
196
  headers: unknown;
197
197
  response: {
@@ -648,18 +648,20 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
648
648
  };
649
649
  } & {
650
650
  "campaigns-to-process": {
651
- index: {
652
- post: {
653
- body: unknown;
654
- params: {};
655
- query: {
656
- chainId: number;
657
- };
658
- headers: {
659
- authorization: string;
660
- };
661
- response: {
662
- 200: string;
651
+ engine: {
652
+ "": {
653
+ post: {
654
+ body: unknown;
655
+ params: {};
656
+ query: {
657
+ chainId: number;
658
+ };
659
+ headers: {
660
+ authorization: string;
661
+ };
662
+ response: {
663
+ 200: string;
664
+ };
663
665
  };
664
666
  };
665
667
  };
@@ -1563,7 +1565,7 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1563
1565
  address: string;
1564
1566
  };
1565
1567
  query: {
1566
- chainId: number | number[];
1568
+ chainId: number[];
1567
1569
  };
1568
1570
  headers: unknown;
1569
1571
  response: {
@@ -646,18 +646,20 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
646
646
  };
647
647
  } & {
648
648
  "campaigns-to-process": {
649
- index: {
650
- post: {
651
- body: unknown;
652
- params: {};
653
- query: {
654
- chainId: number;
655
- };
656
- headers: {
657
- authorization: string;
658
- };
659
- response: {
660
- 200: string;
649
+ engine: {
650
+ "": {
651
+ post: {
652
+ body: unknown;
653
+ params: {};
654
+ query: {
655
+ chainId: number;
656
+ };
657
+ headers: {
658
+ authorization: string;
659
+ };
660
+ response: {
661
+ 200: string;
662
+ };
661
663
  };
662
664
  };
663
665
  };
@@ -1561,7 +1563,7 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1561
1563
  address: string;
1562
1564
  };
1563
1565
  query: {
1564
- chainId: number | number[];
1566
+ chainId: number[];
1565
1567
  };
1566
1568
  headers: unknown;
1567
1569
  response: {
@@ -649,18 +649,20 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
649
649
  };
650
650
  } & {
651
651
  "campaigns-to-process": {
652
- index: {
653
- post: {
654
- body: unknown;
655
- params: {};
656
- query: {
657
- chainId: number;
658
- };
659
- headers: {
660
- authorization: string;
661
- };
662
- response: {
663
- 200: string;
652
+ engine: {
653
+ "": {
654
+ post: {
655
+ body: unknown;
656
+ params: {};
657
+ query: {
658
+ chainId: number;
659
+ };
660
+ headers: {
661
+ authorization: string;
662
+ };
663
+ response: {
664
+ 200: string;
665
+ };
664
666
  };
665
667
  };
666
668
  };
@@ -1564,7 +1566,7 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1564
1566
  address: string;
1565
1567
  };
1566
1568
  query: {
1567
- chainId: number | number[];
1569
+ chainId: number[];
1568
1570
  };
1569
1571
  headers: unknown;
1570
1572
  response: {
@@ -2202,7 +2204,7 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
2202
2204
  body: unknown;
2203
2205
  params: {};
2204
2206
  query: {
2205
- types?: string | number | string[] | number[] | undefined;
2207
+ types?: string | number | number[] | string[] | undefined;
2206
2208
  live?: boolean | undefined;
2207
2209
  chainIds?: string | string[] | undefined;
2208
2210
  creatorTag?: string | undefined;
@@ -640,18 +640,20 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
640
640
  };
641
641
  } & {
642
642
  "campaigns-to-process": {
643
- index: {
644
- post: {
645
- body: unknown;
646
- params: {};
647
- query: {
648
- chainId: number;
649
- };
650
- headers: {
651
- authorization: string;
652
- };
653
- response: {
654
- 200: string;
643
+ engine: {
644
+ "": {
645
+ post: {
646
+ body: unknown;
647
+ params: {};
648
+ query: {
649
+ chainId: number;
650
+ };
651
+ headers: {
652
+ authorization: string;
653
+ };
654
+ response: {
655
+ 200: string;
656
+ };
655
657
  };
656
658
  };
657
659
  };
@@ -1555,7 +1557,7 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1555
1557
  address: string;
1556
1558
  };
1557
1559
  query: {
1558
- chainId: number | number[];
1560
+ chainId: number[];
1559
1561
  };
1560
1562
  headers: unknown;
1561
1563
  response: {
@@ -645,18 +645,20 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
645
645
  };
646
646
  } & {
647
647
  "campaigns-to-process": {
648
- index: {
649
- post: {
650
- body: unknown;
651
- params: {};
652
- query: {
653
- chainId: number;
654
- };
655
- headers: {
656
- authorization: string;
657
- };
658
- response: {
659
- 200: string;
648
+ engine: {
649
+ "": {
650
+ post: {
651
+ body: unknown;
652
+ params: {};
653
+ query: {
654
+ chainId: number;
655
+ };
656
+ headers: {
657
+ authorization: string;
658
+ };
659
+ response: {
660
+ 200: string;
661
+ };
660
662
  };
661
663
  };
662
664
  };
@@ -1560,7 +1562,7 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1560
1562
  address: string;
1561
1563
  };
1562
1564
  query: {
1563
- chainId: number | number[];
1565
+ chainId: number[];
1564
1566
  };
1565
1567
  headers: unknown;
1566
1568
  response: {
@@ -663,18 +663,20 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
663
663
  };
664
664
  } & {
665
665
  "campaigns-to-process": {
666
- index: {
667
- post: {
668
- body: unknown;
669
- params: {};
670
- query: {
671
- chainId: number;
672
- };
673
- headers: {
674
- authorization: string;
675
- };
676
- response: {
677
- 200: string;
666
+ engine: {
667
+ "": {
668
+ post: {
669
+ body: unknown;
670
+ params: {};
671
+ query: {
672
+ chainId: number;
673
+ };
674
+ headers: {
675
+ authorization: string;
676
+ };
677
+ response: {
678
+ 200: string;
679
+ };
678
680
  };
679
681
  };
680
682
  };
@@ -1578,7 +1580,7 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1578
1580
  address: string;
1579
1581
  };
1580
1582
  query: {
1581
- chainId: number | number[];
1583
+ chainId: number[];
1582
1584
  };
1583
1585
  headers: unknown;
1584
1586
  response: {