@merkl/api 0.10.181 → 0.10.183

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 (28) hide show
  1. package/dist/src/eden/index.d.ts +46 -0
  2. package/dist/src/index.d.ts +20 -0
  3. package/dist/src/libs/campaigns/campaignsDynamicData.js +1 -4
  4. package/dist/src/libs/campaigns/campaignsDynamicDataRefacto.js +1 -4
  5. package/dist/src/modules/v4/claims/claims.controller.d.ts +40 -0
  6. package/dist/src/modules/v4/claims/claims.controller.js +13 -0
  7. package/dist/src/modules/v4/claims/claims.model.d.ts +9 -0
  8. package/dist/src/modules/v4/claims/claims.model.js +1 -0
  9. package/dist/src/modules/v4/claims/claims.repository.d.ts +5 -0
  10. package/dist/src/modules/v4/claims/claims.repository.js +39 -0
  11. package/dist/src/modules/v4/claims/claims.service.d.ts +8 -0
  12. package/dist/src/modules/v4/claims/claims.service.js +31 -0
  13. package/dist/src/modules/v4/claims/index.d.ts +3 -0
  14. package/dist/src/modules/v4/claims/index.js +3 -0
  15. package/dist/src/modules/v4/router.d.ts +20 -0
  16. package/dist/src/modules/v4/router.js +3 -1
  17. package/dist/src/modules/v4/user/user.model.d.ts +1 -0
  18. package/dist/src/routes/v3/blacklist.d.ts +20 -0
  19. package/dist/src/routes/v3/campaigns.d.ts +20 -0
  20. package/dist/src/routes/v3/campaignsInfo.d.ts +20 -0
  21. package/dist/src/routes/v3/multiChainPositions.d.ts +20 -0
  22. package/dist/src/routes/v3/opportunity.d.ts +20 -0
  23. package/dist/src/routes/v3/positions.d.ts +20 -0
  24. package/dist/src/routes/v3/rewards.d.ts +20 -0
  25. package/dist/src/routes/v3/updates.d.ts +20 -0
  26. package/dist/src/routes/v3/userRewards.d.ts +20 -0
  27. package/dist/tsconfig.package.tsbuildinfo +1 -1
  28. package/package.json +1 -1
@@ -1914,6 +1914,19 @@ declare const eden: {
1914
1914
  }>>;
1915
1915
  };
1916
1916
  };
1917
+ claims: ((params: {
1918
+ address: string | number;
1919
+ }) => {
1920
+ get: (options?: {
1921
+ headers?: Record<string, unknown> | undefined;
1922
+ query?: Record<string, unknown> | undefined;
1923
+ fetch?: RequestInit | undefined;
1924
+ } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1925
+ 200: (import("../modules/v4/claims").ClaimModel & {
1926
+ token: import("../modules/v4").Token["model"];
1927
+ })[];
1928
+ }>>;
1929
+ }) & {};
1917
1930
  };
1918
1931
  };
1919
1932
  type Api = typeof eden;
@@ -4309,6 +4322,26 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
4309
4322
  };
4310
4323
  };
4311
4324
  };
4325
+ } & {
4326
+ v4: {
4327
+ claims: {
4328
+ ":address": {
4329
+ get: {
4330
+ body: unknown;
4331
+ params: {
4332
+ address: string;
4333
+ };
4334
+ query: unknown;
4335
+ headers: unknown;
4336
+ response: {
4337
+ 200: (import("../modules/v4/claims").ClaimModel & {
4338
+ token: import("../modules/v4").Token["model"];
4339
+ })[];
4340
+ };
4341
+ };
4342
+ };
4343
+ };
4344
+ };
4312
4345
  }, {
4313
4346
  derive: {};
4314
4347
  resolve: {};
@@ -6231,6 +6264,19 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
6231
6264
  }>>;
6232
6265
  };
6233
6266
  };
6267
+ claims: ((params: {
6268
+ address: string | number;
6269
+ }) => {
6270
+ get: (options?: {
6271
+ headers?: Record<string, unknown> | undefined;
6272
+ query?: Record<string, unknown> | undefined;
6273
+ fetch?: RequestInit | undefined;
6274
+ } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
6275
+ 200: (import("../modules/v4/claims").ClaimModel & {
6276
+ token: import("../modules/v4").Token["model"];
6277
+ })[];
6278
+ }>>;
6279
+ }) & {};
6234
6280
  };
6235
6281
  };
6236
6282
  export type Opportunity = FromPromise<Api["v4"]["opportunities"]["index"]["get"]>;
@@ -2384,6 +2384,26 @@ declare const app: Elysia<"", false, {
2384
2384
  };
2385
2385
  };
2386
2386
  };
2387
+ } & {
2388
+ v4: {
2389
+ claims: {
2390
+ ":address": {
2391
+ get: {
2392
+ body: unknown;
2393
+ params: {
2394
+ address: string;
2395
+ };
2396
+ query: unknown;
2397
+ headers: unknown;
2398
+ response: {
2399
+ 200: (import("./modules/v4/claims").ClaimModel & {
2400
+ token: import("./modules/v4").Token["model"];
2401
+ })[];
2402
+ };
2403
+ };
2404
+ };
2405
+ };
2406
+ };
2387
2407
  }, {
2388
2408
  derive: {};
2389
2409
  resolve: {};
@@ -1,4 +1,3 @@
1
- import { log } from "../../utils/logger";
2
1
  import { engineDbClient } from "../../utils/prisma";
3
2
  import { Campaign } from "@sdk";
4
3
  import { getAddress } from "ethers/lib/utils";
@@ -25,9 +24,7 @@ export async function campaignsDynamicData(chainId, campaigns, type) {
25
24
  campaign.tags = tags[getAddress(campaign.creator)] || [];
26
25
  }
27
26
  }
28
- catch (_err) {
29
- log.warn("No tags assigned to creator address in database");
30
- }
27
+ catch (_err) { }
31
28
  switch (type) {
32
29
  case Campaign.ERC20: {
33
30
  const switchRefacto = process.env.SWITCH_REFACTO_SUBTYPES_ERC20 !== undefined ? process.env.SWITCH_REFACTO_SUBTYPES_ERC20 : false;
@@ -1,7 +1,6 @@
1
1
  import { engineDbClient } from "../../utils/prisma";
2
2
  import { Campaign } from "@sdk";
3
3
  import { getAddress } from "ethers/lib/utils";
4
- import { log } from "../../utils/logger";
5
4
  import { AjnaDynamicData } from "./campaignTypes/AjnaDynamicData";
6
5
  import { BadgerDynamicData } from "./campaignTypes/BadgerDynamicData";
7
6
  import { CLAMMDynamicData } from "./campaignTypes/CLAMMDynamicData";
@@ -24,9 +23,7 @@ export async function campaignsDynamicDataRefacto(chainId, campaigns, type, next
24
23
  campaign.tags = tags[getAddress(campaign.creator)] || [];
25
24
  }
26
25
  }
27
- catch (e) {
28
- log.warn("No tags assigned to creator address in database");
29
- }
26
+ catch (e) { }
30
27
  switch (type) {
31
28
  case Campaign.ERC20: {
32
29
  return ERC20DynamicDataRefacto(chainId, campaigns);
@@ -0,0 +1,40 @@
1
+ import Elysia from "elysia";
2
+ export declare const ClaimController: Elysia<"/claims", false, {
3
+ decorator: {};
4
+ store: {};
5
+ derive: {};
6
+ resolve: {};
7
+ }, {
8
+ type: {};
9
+ error: {};
10
+ }, {
11
+ schema: {};
12
+ macro: {};
13
+ macroFn: {};
14
+ }, {
15
+ claims: {
16
+ ":address": {
17
+ get: {
18
+ body: unknown;
19
+ params: {
20
+ address: string;
21
+ };
22
+ query: unknown;
23
+ headers: unknown;
24
+ response: {
25
+ 200: (import("./claims.model").ClaimModel & {
26
+ token: import("..").Token["model"];
27
+ })[];
28
+ };
29
+ };
30
+ };
31
+ };
32
+ }, {
33
+ derive: {};
34
+ resolve: {};
35
+ schema: {};
36
+ }, {
37
+ derive: {};
38
+ resolve: {};
39
+ schema: {};
40
+ }>;
@@ -0,0 +1,13 @@
1
+ import { throwOnInvalidRequiredAddress } from "../../../utils/throw";
2
+ import Elysia from "elysia";
3
+ import { UserUniqueDto } from "../user";
4
+ import { ClaimService } from "./claims.service";
5
+ // ─── Claim Controller ───────────────────────────────────────────────────────
6
+ export const ClaimController = new Elysia({ prefix: "/claims", detail: { tags: ["Claims"] } })
7
+ // ─── Get Historical Claims ────────────────────────────────────────────
8
+ .get("/:address", async ({ params }) => await ClaimService.getHistoricalClaims(params), {
9
+ params: UserUniqueDto,
10
+ beforeHandle: ({ params }) => {
11
+ params.address = throwOnInvalidRequiredAddress(params.address);
12
+ },
13
+ });
@@ -0,0 +1,9 @@
1
+ export type ClaimModel = {
2
+ timestamp: number;
3
+ token: string;
4
+ user: string;
5
+ amount: string;
6
+ rawAmount: string;
7
+ root: string;
8
+ txHash?: string;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { type MerklChainId } from "@sdk";
2
+ import type { ClaimModel } from "./claims.model";
3
+ export declare class ClaimRepository {
4
+ static fetch(chainId: MerklChainId, address: string): Promise<ClaimModel[]>;
5
+ }
@@ -0,0 +1,39 @@
1
+ import { merklSubgraphClaimsEndpoints } from "@sdk";
2
+ import request, { gql } from "graphql-request";
3
+ export class ClaimRepository {
4
+ static async fetch(chainId, address) {
5
+ try {
6
+ return (await request(merklSubgraphClaimsEndpoints[chainId],
7
+ // Request is limited to first 100 by default so needs to be sorted
8
+ gql `query MerklClaims($user: String) {
9
+ merklClaims(where: {user: $user }, orderBy: timestamp, orderDirection: desc) {
10
+ timestamp
11
+ token
12
+ user
13
+ amount
14
+ rawAmount
15
+ root
16
+ id
17
+ txHash
18
+ }
19
+ }
20
+ `, { user: address?.toLowerCase() })).merklClaims;
21
+ }
22
+ catch {
23
+ return (await request(merklSubgraphClaimsEndpoints[chainId],
24
+ // Request is limited to first 100 by default so needs to be sorted
25
+ gql `query MerklClaims($user: String) {
26
+ merklClaims(where: {user: $user }, orderBy: timestamp, orderDirection: desc) {
27
+ timestamp
28
+ token
29
+ user
30
+ amount
31
+ rawAmount
32
+ root
33
+ id
34
+ }
35
+ }
36
+ `, { user: address?.toLowerCase() })).merklClaims;
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,8 @@
1
+ import type { Token } from "../token";
2
+ import type { UserUniqueModel } from "../user";
3
+ import type { ClaimModel } from "./claims.model";
4
+ export declare abstract class ClaimService {
5
+ static getHistoricalClaims(params: UserUniqueModel): Promise<(ClaimModel & {
6
+ token: Token["model"];
7
+ })[]>;
8
+ }
@@ -0,0 +1,31 @@
1
+ import { MerklRootService } from "../merklRoot";
2
+ import { RewardService } from "../reward";
3
+ import { ClaimRepository } from "./claims.repository";
4
+ export class ClaimService {
5
+ // ─── Get Historical Claims ─────────────────────────────────────────────────
6
+ static async getHistoricalClaims(params) {
7
+ const roots = (await MerklRootService.fetchAll()).map(r => r.live);
8
+ const rewards = await RewardService.getByRecipient(params.address, roots, true);
9
+ const chainIds = [];
10
+ for (const reward of rewards) {
11
+ if (!chainIds.includes(reward.RewardToken.chainId)) {
12
+ chainIds.push(reward.RewardToken.chainId);
13
+ }
14
+ }
15
+ const tokens = rewards.reduce((acc, reward) => {
16
+ acc[reward.RewardToken.address.toLowerCase()] = reward.RewardToken;
17
+ return acc;
18
+ }, {});
19
+ const promises = await Promise.allSettled(chainIds.map(chainId => ClaimRepository.fetch(chainId, params.address)));
20
+ const claims = await promises
21
+ .filter(p => p.status === "fulfilled")
22
+ .flatMap(p => p.value)
23
+ .map(claim => {
24
+ return {
25
+ ...claim,
26
+ token: tokens[claim.token.toLowerCase()],
27
+ };
28
+ });
29
+ return claims.sort((a, b) => Number(b.timestamp) - Number(a.timestamp));
30
+ }
31
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./claims.model";
2
+ export * from "./claims.service";
3
+ export * from "./claims.controller";
@@ -0,0 +1,3 @@
1
+ export * from "./claims.model";
2
+ export * from "./claims.service";
3
+ export * from "./claims.controller";
@@ -2366,6 +2366,26 @@ export declare const v4: Elysia<"/v4", false, {
2366
2366
  };
2367
2367
  };
2368
2368
  };
2369
+ } & {
2370
+ v4: {
2371
+ claims: {
2372
+ ":address": {
2373
+ get: {
2374
+ body: unknown;
2375
+ params: {
2376
+ address: string;
2377
+ };
2378
+ query: unknown;
2379
+ headers: unknown;
2380
+ response: {
2381
+ 200: (import("./claims").ClaimModel & {
2382
+ token: import("./token").Token["model"];
2383
+ })[];
2384
+ };
2385
+ };
2386
+ };
2387
+ };
2388
+ };
2369
2389
  }, {
2370
2390
  derive: {};
2371
2391
  resolve: {};
@@ -15,6 +15,7 @@ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
15
15
  import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node";
16
16
  import { PrismaInstrumentation } from "@prisma/instrumentation";
17
17
  import Elysia from "elysia";
18
+ import { ClaimController } from "./claims";
18
19
  import { DynamicDataController } from "./dynamicData";
19
20
  import { InteractionController } from "./interaction/interaction.controller";
20
21
  import { LiquidityController } from "./liquidity/liquidity.controller";
@@ -59,4 +60,5 @@ export const v4 = new Elysia({ tags: ["v4"], prefix: "/v4" })
59
60
  .use(AccountingController)
60
61
  .use(DynamicDataController)
61
62
  .use(StatusController)
62
- .use(LiquidityController);
63
+ .use(LiquidityController)
64
+ .use(ClaimController);
@@ -21,5 +21,6 @@ export declare const GetManyUserQuery: import("@sinclair/typebox").TObject<{
21
21
  export declare const UpdateUserTagsDto: import("@sinclair/typebox").TObject<{
22
22
  tags: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
23
23
  }>;
24
+ export type UserUniqueModel = typeof UserUniqueDto.static;
24
25
  export type UserModel = typeof UserDto.static;
25
26
  export type GetManyUserModel = typeof GetManyUserQuery.static;
@@ -2390,6 +2390,26 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
2390
2390
  };
2391
2391
  };
2392
2392
  };
2393
+ } & {
2394
+ v4: {
2395
+ claims: {
2396
+ ":address": {
2397
+ get: {
2398
+ body: unknown;
2399
+ params: {
2400
+ address: string;
2401
+ };
2402
+ query: unknown;
2403
+ headers: unknown;
2404
+ response: {
2405
+ 200: (import("../../modules/v4/claims").ClaimModel & {
2406
+ token: import("../../modules/v4").Token["model"];
2407
+ })[];
2408
+ };
2409
+ };
2410
+ };
2411
+ };
2412
+ };
2393
2413
  } & {
2394
2414
  index: {
2395
2415
  get: {
@@ -2393,6 +2393,26 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
2393
2393
  };
2394
2394
  };
2395
2395
  };
2396
+ } & {
2397
+ v4: {
2398
+ claims: {
2399
+ ":address": {
2400
+ get: {
2401
+ body: unknown;
2402
+ params: {
2403
+ address: string;
2404
+ };
2405
+ query: unknown;
2406
+ headers: unknown;
2407
+ response: {
2408
+ 200: (import("../../modules/v4/claims").ClaimModel & {
2409
+ token: import("../../modules/v4").Token["model"];
2410
+ })[];
2411
+ };
2412
+ };
2413
+ };
2414
+ };
2415
+ };
2396
2416
  } & {
2397
2417
  index: {
2398
2418
  get: {
@@ -2384,6 +2384,26 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
2384
2384
  };
2385
2385
  };
2386
2386
  };
2387
+ } & {
2388
+ v4: {
2389
+ claims: {
2390
+ ":address": {
2391
+ get: {
2392
+ body: unknown;
2393
+ params: {
2394
+ address: string;
2395
+ };
2396
+ query: unknown;
2397
+ headers: unknown;
2398
+ response: {
2399
+ 200: (import("../../modules/v4/claims").ClaimModel & {
2400
+ token: import("../../modules/v4").Token["model"];
2401
+ })[];
2402
+ };
2403
+ };
2404
+ };
2405
+ };
2406
+ };
2387
2407
  } & {
2388
2408
  index: {
2389
2409
  post: {
@@ -2389,6 +2389,26 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
2389
2389
  };
2390
2390
  };
2391
2391
  };
2392
+ } & {
2393
+ v4: {
2394
+ claims: {
2395
+ ":address": {
2396
+ get: {
2397
+ body: unknown;
2398
+ params: {
2399
+ address: string;
2400
+ };
2401
+ query: unknown;
2402
+ headers: unknown;
2403
+ response: {
2404
+ 200: (import("../../modules/v4/claims").ClaimModel & {
2405
+ token: import("../../modules/v4").Token["model"];
2406
+ })[];
2407
+ };
2408
+ };
2409
+ };
2410
+ };
2411
+ };
2392
2412
  } & {
2393
2413
  index: {
2394
2414
  get: {
@@ -2407,6 +2407,26 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
2407
2407
  };
2408
2408
  };
2409
2409
  };
2410
+ } & {
2411
+ v4: {
2412
+ claims: {
2413
+ ":address": {
2414
+ get: {
2415
+ body: unknown;
2416
+ params: {
2417
+ address: string;
2418
+ };
2419
+ query: unknown;
2420
+ headers: unknown;
2421
+ response: {
2422
+ 200: (import("../../modules/v4/claims").ClaimModel & {
2423
+ token: import("../../modules/v4").Token["model"];
2424
+ })[];
2425
+ };
2426
+ };
2427
+ };
2428
+ };
2429
+ };
2410
2430
  } & {
2411
2431
  index: {
2412
2432
  get: {
@@ -2408,6 +2408,26 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
2408
2408
  };
2409
2409
  };
2410
2410
  };
2411
+ } & {
2412
+ v4: {
2413
+ claims: {
2414
+ ":address": {
2415
+ get: {
2416
+ body: unknown;
2417
+ params: {
2418
+ address: string;
2419
+ };
2420
+ query: unknown;
2421
+ headers: unknown;
2422
+ response: {
2423
+ 200: (import("../../modules/v4/claims").ClaimModel & {
2424
+ token: import("../../modules/v4").Token["model"];
2425
+ })[];
2426
+ };
2427
+ };
2428
+ };
2429
+ };
2430
+ };
2411
2431
  } & {
2412
2432
  index: {
2413
2433
  get: {
@@ -2390,6 +2390,26 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
2390
2390
  };
2391
2391
  };
2392
2392
  };
2393
+ } & {
2394
+ v4: {
2395
+ claims: {
2396
+ ":address": {
2397
+ get: {
2398
+ body: unknown;
2399
+ params: {
2400
+ address: string;
2401
+ };
2402
+ query: unknown;
2403
+ headers: unknown;
2404
+ response: {
2405
+ 200: (import("../../modules/v4/claims").ClaimModel & {
2406
+ token: import("../../modules/v4").Token["model"];
2407
+ })[];
2408
+ };
2409
+ };
2410
+ };
2411
+ };
2412
+ };
2393
2413
  } & {
2394
2414
  index: {
2395
2415
  get: {
@@ -2391,6 +2391,26 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
2391
2391
  };
2392
2392
  };
2393
2393
  };
2394
+ } & {
2395
+ v4: {
2396
+ claims: {
2397
+ ":address": {
2398
+ get: {
2399
+ body: unknown;
2400
+ params: {
2401
+ address: string;
2402
+ };
2403
+ query: unknown;
2404
+ headers: unknown;
2405
+ response: {
2406
+ 200: (import("../../modules/v4/claims").ClaimModel & {
2407
+ token: import("../../modules/v4").Token["model"];
2408
+ })[];
2409
+ };
2410
+ };
2411
+ };
2412
+ };
2413
+ };
2394
2414
  } & {
2395
2415
  index: {
2396
2416
  get: {
@@ -2393,6 +2393,26 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
2393
2393
  };
2394
2394
  };
2395
2395
  };
2396
+ } & {
2397
+ v4: {
2398
+ claims: {
2399
+ ":address": {
2400
+ get: {
2401
+ body: unknown;
2402
+ params: {
2403
+ address: string;
2404
+ };
2405
+ query: unknown;
2406
+ headers: unknown;
2407
+ response: {
2408
+ 200: (import("../../modules/v4/claims").ClaimModel & {
2409
+ token: import("../../modules/v4").Token["model"];
2410
+ })[];
2411
+ };
2412
+ };
2413
+ };
2414
+ };
2415
+ };
2396
2416
  } & {
2397
2417
  index: {
2398
2418
  get: {