@merkl/api 0.21.31 → 0.21.33

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 (41) hide show
  1. package/dist/src/eden/index.d.ts +89 -9
  2. package/dist/src/engine/deprecated/erc20SubTypeProcessors/helpers/factoryFinder.js +1 -1
  3. package/dist/src/engine/deprecated/erc20SubTypeProcessors/implementations/curveProcessor.js +6 -2
  4. package/dist/src/engine/deprecated/erc20SubTypeProcessors/implementations/processorMapping.js +1 -0
  5. package/dist/src/engine/deprecated/erc20SubTypeProcessors/tokenTypeToProtocolAndAction.js +4 -0
  6. package/dist/src/engine/implementations/Erc20/subTypes/implementations/euler/tvl.js +5 -1
  7. package/dist/src/engine/implementations/Erc20/subTypes/index.d.ts +2 -1
  8. package/dist/src/engine/implementations/Erc20/subTypes/index.js +1 -0
  9. package/dist/src/guards/BackOffice.guard.d.ts +1 -1
  10. package/dist/src/guards/BackOffice.guard.js +1 -1
  11. package/dist/src/guards/Engine.guard.d.ts +1 -1
  12. package/dist/src/guards/Engine.guard.js +2 -3
  13. package/dist/src/guards/VerifyJwt.guard.d.ts +10 -0
  14. package/dist/src/guards/VerifyJwt.guard.js +13 -0
  15. package/dist/src/index.d.ts +35 -3
  16. package/dist/src/index.js +2 -0
  17. package/dist/src/modules/v4/accounting/accounting.controller.js +7 -13
  18. package/dist/src/modules/v4/authentication/authentication.controller.d.ts +52 -0
  19. package/dist/src/modules/v4/authentication/authentication.controller.js +23 -0
  20. package/dist/src/modules/v4/authentication/authentication.model.d.ts +10 -0
  21. package/dist/src/modules/v4/authentication/authentication.model.js +6 -0
  22. package/dist/src/modules/v4/authentication/authentication.service.d.ts +10 -0
  23. package/dist/src/modules/v4/authentication/authentication.service.js +31 -0
  24. package/dist/src/modules/v4/blacklist/blacklist.controller.js +2 -2
  25. package/dist/src/modules/v4/cache/cache.repository.d.ts +3 -0
  26. package/dist/src/modules/v4/cache/cache.repository.js +9 -0
  27. package/dist/src/modules/v4/cache/cache.service.d.ts +3 -0
  28. package/dist/src/modules/v4/cache/cache.service.js +9 -0
  29. package/dist/src/modules/v4/opportunity/opportunity.controller.js +1 -3
  30. package/dist/src/modules/v4/reward/reward.controller.d.ts +3 -3
  31. package/dist/src/modules/v4/reward/reward.controller.js +14 -5
  32. package/dist/src/modules/v4/reward/reward.model.d.ts +1 -1
  33. package/dist/src/modules/v4/reward/reward.model.js +1 -1
  34. package/dist/src/modules/v4/router.d.ts +35 -3
  35. package/dist/src/modules/v4/router.js +3 -1
  36. package/dist/src/modules/v4/token/token.controller.js +1 -1
  37. package/dist/src/modules/v4/uniswap/uniswap.controller.js +1 -1
  38. package/dist/src/utils/decodeCalls.js +15 -5
  39. package/dist/src/utils/generateCardName.js +1 -0
  40. package/dist/tsconfig.package.tsbuildinfo +1 -1
  41. package/package.json +4 -3
@@ -10,4 +10,13 @@ export class CacheRepository {
10
10
  static async get(key) {
11
11
  return await withRetry(withTimeout, [redisClient.get(key), REDIS_READ_TIMEOUT], REDIS_RETRIES);
12
12
  }
13
+ static async sAdd(sName, sValue) {
14
+ await withRetry(withTimeout, [redisClient.sAdd(sName, sValue), REDIS_WRITE_TIMEOUT], REDIS_RETRIES);
15
+ }
16
+ static async sRem(sName, sValue) {
17
+ await withRetry(withTimeout, [redisClient.sRem(sName, sValue), REDIS_WRITE_TIMEOUT], REDIS_RETRIES);
18
+ }
19
+ static async sIsMember(sName, sValue) {
20
+ return await withRetry(withTimeout, [redisClient.sIsMember(sName, sValue), REDIS_READ_TIMEOUT], REDIS_RETRIES);
21
+ }
13
22
  }
@@ -6,4 +6,7 @@ export declare abstract class CacheService {
6
6
  static keyAndTTL<Fn extends (...args: Args) => Promise<unknown>, Args extends unknown[]>(fn: Fn, ...args: Args): Promise<[string, number]>;
7
7
  static set<Fn extends (...args: Args) => Promise<unknown>, Args extends unknown[], T extends Awaited<ReturnType<Fn>>>(ttl: number, fn: Fn, ...args: Args): Promise<T>;
8
8
  static get<Fn extends (...args: Args) => Promise<unknown>, Args extends unknown[], T extends Awaited<ReturnType<Fn>>>(fn: Fn, args: Args): Promise<T | null>;
9
+ static sAdd(sName: string, sValue: string): Promise<void>;
10
+ static sRem(sName: string, sValue: string): Promise<void>;
11
+ static sIsMember(sName: string, sValue: string): Promise<any>;
9
12
  }
@@ -47,4 +47,13 @@ export class CacheService {
47
47
  return null;
48
48
  return CacheService.#uncompress(cached);
49
49
  }
50
+ static async sAdd(sName, sValue) {
51
+ return CacheRepository.sAdd(sName, sValue);
52
+ }
53
+ static async sRem(sName, sValue) {
54
+ return CacheRepository.sRem(sName, sValue);
55
+ }
56
+ static async sIsMember(sName, sValue) {
57
+ return await CacheRepository.sIsMember(sName, sValue);
58
+ }
50
59
  }
@@ -13,9 +13,7 @@ import { validateId } from "./validate-id.pipe";
13
13
  // ─── Opportunities Controller ────────────────────────────────────────────────
14
14
  export const OpportunityController = new Elysia({
15
15
  prefix: "/opportunities",
16
- detail: {
17
- tags: ["Opportunities"],
18
- },
16
+ detail: { tags: ["Opportunities"] },
19
17
  })
20
18
  // ─── Get All Opportunities ───────────────────────────────────────────
21
19
  .get("/", async ({ query }) => OpportunityService.findMany(query), {
@@ -144,9 +144,9 @@ export declare const RewardController: Elysia<"/rewards", false, {
144
144
  query: {
145
145
  items?: number | undefined;
146
146
  page?: number | undefined;
147
+ campaignIds?: string[] | undefined;
147
148
  address: string;
148
149
  chainId: number;
149
- campaignIds: string[];
150
150
  };
151
151
  headers: unknown;
152
152
  response: {
@@ -169,9 +169,9 @@ export declare const RewardController: Elysia<"/rewards", false, {
169
169
  query: {
170
170
  items?: number | undefined;
171
171
  page?: number | undefined;
172
+ campaignIds?: string[] | undefined;
172
173
  address: string;
173
174
  chainId: number;
174
- campaignIds: string[];
175
175
  };
176
176
  headers: unknown;
177
177
  response: {
@@ -192,9 +192,9 @@ export declare const RewardController: Elysia<"/rewards", false, {
192
192
  query: {
193
193
  items?: number | undefined;
194
194
  page?: number | undefined;
195
+ campaignIds?: string[] | undefined;
195
196
  address: string;
196
197
  chainId: number;
197
- campaignIds: string[];
198
198
  };
199
199
  headers: unknown;
200
200
  response: {
@@ -65,14 +65,23 @@ export const RewardController = new Elysia({ prefix: "/rewards", detail: { tags:
65
65
  query: TokenIdDto,
66
66
  beforeHandle: ({ query }) => {
67
67
  query.address = throwOnInvalidRequiredAddress(query.address);
68
- query.campaignIds = query.campaignIds.flatMap(x => x.split(","));
68
+ query.campaignIds = query?.campaignIds?.flatMap(x => x.split(","));
69
69
  throwOnUnsupportedChainId(query.chainId);
70
70
  },
71
- detail: { hide: true },
72
71
  })
73
- .get("/", async ({ query }) => await RewardService.breakdownForToken(query))
74
- .get("/total", async ({ query }) => await RewardService.totalForToken(query))
75
- .get("/count", async ({ query }) => await RewardService.countForToken(query));
72
+ .get("/", async ({ query }) => await RewardService.breakdownForToken(query), {
73
+ detail: {
74
+ description: "Returns the all the address that received rewards of a given token, sorted by descending amounts",
75
+ },
76
+ })
77
+ .get("/total", async ({ query }) => await RewardService.totalForToken(query), {
78
+ detail: { description: "Returns the total amount distributed for a given token" },
79
+ })
80
+ .get("/count", async ({ query }) => await RewardService.countForToken(query), {
81
+ detail: {
82
+ description: "Returns the number of recipients that earned rewards in a given token",
83
+ },
84
+ });
76
85
  })
77
86
  .group("/engine", {
78
87
  headers: AuthorizationHeadersDto,
@@ -172,7 +172,7 @@ export declare const CampaignIdDto: import("@sinclair/typebox").TObject<{
172
172
  export declare const TokenIdDto: import("@sinclair/typebox").TObject<{
173
173
  chainId: import("@sinclair/typebox").TNumber;
174
174
  address: import("@sinclair/typebox").TString;
175
- campaignIds: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
175
+ campaignIds: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
176
176
  page: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
177
177
  items: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
178
178
  }>;
@@ -109,7 +109,7 @@ export const TokenIdDto = t.Object({
109
109
  address: t.String({
110
110
  description: "Token Address",
111
111
  }),
112
- campaignIds: t.Array(t.String()),
112
+ campaignIds: t.Optional(t.Array(t.String())),
113
113
  page: t.Optional(t.Numeric({ description: "Page number", default: 0 })), // 0-indexed
114
114
  items: t.Optional(t.Numeric({ description: "Number of returned rows", default: 20 })), // items per page
115
115
  });
@@ -3212,9 +3212,9 @@ export declare const v4: Elysia<"/v4", false, {
3212
3212
  query: {
3213
3213
  items?: number | undefined;
3214
3214
  page?: number | undefined;
3215
+ campaignIds?: string[] | undefined;
3215
3216
  address: string;
3216
3217
  chainId: number;
3217
- campaignIds: string[];
3218
3218
  };
3219
3219
  headers: unknown;
3220
3220
  response: {
@@ -3237,9 +3237,9 @@ export declare const v4: Elysia<"/v4", false, {
3237
3237
  query: {
3238
3238
  items?: number | undefined;
3239
3239
  page?: number | undefined;
3240
+ campaignIds?: string[] | undefined;
3240
3241
  address: string;
3241
3242
  chainId: number;
3242
- campaignIds: string[];
3243
3243
  };
3244
3244
  headers: unknown;
3245
3245
  response: {
@@ -3260,9 +3260,9 @@ export declare const v4: Elysia<"/v4", false, {
3260
3260
  query: {
3261
3261
  items?: number | undefined;
3262
3262
  page?: number | undefined;
3263
+ campaignIds?: string[] | undefined;
3263
3264
  address: string;
3264
3265
  chainId: number;
3265
- campaignIds: string[];
3266
3266
  };
3267
3267
  headers: unknown;
3268
3268
  response: {
@@ -5916,6 +5916,38 @@ export declare const v4: Elysia<"/v4", false, {
5916
5916
  };
5917
5917
  };
5918
5918
  };
5919
+ } & {
5920
+ v4: {
5921
+ authlogin: {
5922
+ post: {
5923
+ body: {
5924
+ message: string;
5925
+ address: string;
5926
+ signature: string;
5927
+ };
5928
+ params: {};
5929
+ query: unknown;
5930
+ headers: unknown;
5931
+ response: {
5932
+ 200: void;
5933
+ };
5934
+ };
5935
+ };
5936
+ } & {
5937
+ auth: {
5938
+ revoke: {
5939
+ delete: {
5940
+ body: unknown;
5941
+ params: {};
5942
+ query: unknown;
5943
+ headers: unknown;
5944
+ response: {
5945
+ 200: void;
5946
+ };
5947
+ };
5948
+ };
5949
+ };
5950
+ };
5919
5951
  }, {
5920
5952
  derive: {};
5921
5953
  resolve: {};
@@ -30,6 +30,7 @@ import { RedisInstrumentation } from "@opentelemetry/instrumentation-redis-4";
30
30
  import { AlwaysOffSampler, BatchSpanProcessor } from "@opentelemetry/sdk-trace-node";
31
31
  import { PrismaInstrumentation } from "@prisma/instrumentation";
32
32
  import Elysia from "elysia";
33
+ import { AuthController } from "./authentication/authentication.controller";
33
34
  import { ReferralController } from "./referral/referral.controller";
34
35
  import { TurtleController } from "./turtle/turtle.controller";
35
36
  // ─── V4 Router ───────────────────────────────────────────────────────────────
@@ -88,4 +89,5 @@ export const v4 = new Elysia({ tags: ["v4"], prefix: "/v4" })
88
89
  .use(CreatorController)
89
90
  .use(ReferralController)
90
91
  .use(UniswapController)
91
- .use(TurtleController);
92
+ .use(TurtleController)
93
+ .use(AuthController);
@@ -94,7 +94,7 @@ export const TokenController = new Elysia({ prefix: "/tokens", detail: { tags: [
94
94
  body: CreateTokenDto,
95
95
  headers: AuthorizationHeadersDto,
96
96
  beforeHandle: async ({ headers, body }) => {
97
- await BackOfficeGuard({ headers });
97
+ BackOfficeGuard({ headers });
98
98
  body.address = throwOnInvalidRequiredAddress(body.address);
99
99
  throwOnUnsupportedChainId(body.chainId);
100
100
  },
@@ -91,7 +91,7 @@ export const UniswapController = new Elysia({
91
91
  params: ChainUniqueDto,
92
92
  headers: AuthorizationHeadersDto,
93
93
  beforeHandle: async ({ params, headers }) => {
94
- await BackOfficeGuard({ headers });
94
+ BackOfficeGuard({ headers });
95
95
  if (!UniV4ChainIdArray.includes(params.chainId))
96
96
  throw new UnsupportedNetwork(params.chainId);
97
97
  },
@@ -193,11 +193,21 @@ export function decodeReturnValue(returnData, key, type) {
193
193
  case "coin2":
194
194
  return CurveInterface.decodeFunctionResult("coins", returnData)[0];
195
195
  case "N_COINS":
196
- try {
197
- return CurveStableSwapNGInterface.decodeFunctionResult("N_COINS", returnData)[0];
198
- }
199
- catch (e) {
200
- return 2;
196
+ switch (type) {
197
+ case Erc20SubType.curveTricrypto:
198
+ try {
199
+ return CurveStableSwapNGInterface.decodeFunctionResult("N_COINS", returnData)[0];
200
+ }
201
+ catch (e) {
202
+ return 3;
203
+ }
204
+ default:
205
+ try {
206
+ return CurveStableSwapNGInterface.decodeFunctionResult("N_COINS", returnData)[0];
207
+ }
208
+ catch (e) {
209
+ return 2;
210
+ }
201
211
  }
202
212
  case "balances":
203
213
  return CurveStableSwapNGInterface.decodeFunctionResult("balances", returnData)[0];
@@ -160,6 +160,7 @@ export function generateCardName(type, typeInfo, campaign, symbols = [""], displ
160
160
  }
161
161
  return `${typeInfo.name}`;
162
162
  case Erc20SubType.curveNPool:
163
+ case Erc20SubType.curveTricrypto:
163
164
  return `Curve ${typeInfo.name}`;
164
165
  case Erc20SubType.vicuna: {
165
166
  const parsedName = typeInfo.name.split(" ");