@merkl/api 0.10.206 → 0.10.207

Sign up to get free protection for your applications and to get access to all the features.
package/dist/src/index.js CHANGED
@@ -41,7 +41,7 @@ const app = new Elysia({
41
41
  exclude: [/v4\/.*/, "/"],
42
42
  }))
43
43
  .use(swagger({
44
- path: "/",
44
+ path: "/docs",
45
45
  scalarConfig: {
46
46
  theme: "kepler",
47
47
  darkMode: true,
@@ -82,14 +82,14 @@ const app = new Elysia({
82
82
  version: "1.0.1",
83
83
  },
84
84
  },
85
- exclude: [/engine\/*/, /v1\/.*/, /v2\/.*/, /v3\/.*/, "/", /swagger\/*/],
85
+ exclude: [/engine\/*/, /v1\/.*/, /v2\/.*/, /v3\/.*/, /swagger\/*/],
86
86
  }))
87
87
  .use(cors())
88
- .get("/", () => "Merkl API")
88
+ // .get("/", () => "Merkl API")
89
89
  .use(v1)
90
90
  .use(v2)
91
- .use(v3)
92
91
  .use(v4)
92
+ .use(v3)
93
93
  .use(errorHandler())
94
94
  .listen(PORT, ({ hostname, port }) => {
95
95
  log.info(`🌐 Api started (${hostname}:${port})`);
@@ -103,6 +103,35 @@ export declare const ProtocolController: Elysia<"/protocols", false, {
103
103
  };
104
104
  };
105
105
  };
106
+ } & {
107
+ protocols: {
108
+ index: {
109
+ post: {
110
+ body: {
111
+ name: string;
112
+ url: string;
113
+ description: string;
114
+ id: string;
115
+ icon: string;
116
+ };
117
+ params: {};
118
+ query: unknown;
119
+ headers: {
120
+ authorization: string;
121
+ };
122
+ response: {
123
+ 200: {
124
+ name: string;
125
+ url: string;
126
+ description: string;
127
+ id: string;
128
+ tags: import("../../../../database/api/.generated").$Enums.ProtocolTag[];
129
+ icon: string;
130
+ };
131
+ };
132
+ };
133
+ };
134
+ };
106
135
  }, {
107
136
  derive: {};
108
137
  resolve: {};
@@ -1,6 +1,6 @@
1
1
  import { AuthorizationHeadersDto, BackOfficeGuard } from "../../../guards/BackOffice.guard";
2
2
  import Elysia, { t } from "elysia";
3
- import { GetProtocolsQueryDto, ProtocolIdDto, ProtocolResourceDto, UpdateProtocolDto } from "./protocol.model";
3
+ import { CreateProtocolDto, GetProtocolsQueryDto, ProtocolIdDto, ProtocolResourceDto, UpdateProtocolDto, } from "./protocol.model";
4
4
  import { ProtocolService } from "./protocol.service";
5
5
  // ─── Protocols Controller ────────────────────────────────────────────────────
6
6
  export const ProtocolController = new Elysia({ prefix: "/protocols", detail: { tags: ["Protocols"] } })
@@ -28,4 +28,11 @@ export const ProtocolController = new Elysia({ prefix: "/protocols", detail: { t
28
28
  headers: AuthorizationHeadersDto,
29
29
  beforeHandle: BackOfficeGuard,
30
30
  detail: { hide: true },
31
+ })
32
+ // ─── Create A Protocol ───────────────────────────────────────────────
33
+ .post("/", async ({ body }) => await ProtocolService.create(body), {
34
+ body: CreateProtocolDto,
35
+ headers: AuthorizationHeadersDto,
36
+ beforeHandle: BackOfficeGuard,
37
+ detail: { hide: true },
31
38
  });
@@ -39,10 +39,18 @@ export declare const UpdateProtocolDto: import("@sinclair/typebox").TObject<{
39
39
  url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
40
40
  description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
41
41
  }>;
42
+ export declare const CreateProtocolDto: import("@sinclair/typebox").TObject<{
43
+ icon: import("@sinclair/typebox").TString;
44
+ url: import("@sinclair/typebox").TString;
45
+ description: import("@sinclair/typebox").TString;
46
+ id: import("@sinclair/typebox").TString;
47
+ name: import("@sinclair/typebox").TString;
48
+ }>;
42
49
  export declare const ProtocolIdDto: import("@sinclair/typebox").TObject<{
43
50
  id: import("@sinclair/typebox").TString;
44
51
  }>;
45
52
  export type GetProtocolsQueryModel = typeof GetProtocolsQueryDto.static;
46
53
  export type GetProtocolModel = typeof GetProtocolParamsDto.static;
47
54
  export type UpdateProtocolModel = typeof UpdateProtocolDto.static;
55
+ export type CreateProtocolModel = typeof CreateProtocolDto.static;
48
56
  export {};
@@ -81,4 +81,11 @@ export const UpdateProtocolDto = t.Object({
81
81
  description: t.Optional(t.String()),
82
82
  // iconFile: t.Optional(t.File()),
83
83
  });
84
+ export const CreateProtocolDto = t.Object({
85
+ icon: t.String({ format: "uri" }),
86
+ url: t.String({ format: "uri" }),
87
+ description: t.String(),
88
+ id: t.String(),
89
+ name: t.String(),
90
+ });
84
91
  export const ProtocolIdDto = t.Object({ id: t.String() });
@@ -15,7 +15,7 @@ export class ProtocolRepository {
15
15
  where: {
16
16
  name: query.name ? { contains: query.name, mode: "insensitive" } : undefined,
17
17
  tags: query.tags ? { hasEvery: query.tags } : undefined,
18
- id: typeof query.id === "string" ? query.id : !!query.id ? { in: query.id } : undefined,
18
+ // id: typeof query.id === "string" ? query.id : !!query.id ? { in: query.id } : undefined,
19
19
  },
20
20
  };
21
21
  }
@@ -1,11 +1,19 @@
1
1
  import { AMM as AMMV3 } from "@sdk";
2
- import type { GetProtocolsQueryModel, Protocol, ProtocolId, UpdateProtocolModel } from "./protocol.model";
2
+ import type { CreateProtocolModel, GetProtocolsQueryModel, Protocol, ProtocolId, UpdateProtocolModel } from "./protocol.model";
3
3
  export declare abstract class ProtocolService {
4
4
  static getIdFromAmmV3(amm: AMMV3): ProtocolId;
5
5
  static findMany(query: GetProtocolsQueryModel): Promise<Protocol["model"][]>;
6
6
  static countMany(query: GetProtocolsQueryModel): Promise<number>;
7
7
  static getFromId(id: ProtocolId | string): Promise<Protocol["model"] | null>;
8
8
  static getFromName(name: string): Promise<Protocol["model"] | null>;
9
+ static create(data: CreateProtocolModel): Promise<{
10
+ name: string;
11
+ url: string;
12
+ description: string;
13
+ id: string;
14
+ tags: import("../../../../database/api/.generated").$Enums.ProtocolTag[];
15
+ icon: string;
16
+ }>;
9
17
  static update(id: string, data: UpdateProtocolModel): Promise<{
10
18
  name: string;
11
19
  url: string;
@@ -49,6 +49,15 @@ export class ProtocolService {
49
49
  static async getFromName(name) {
50
50
  return (await ProtocolRepository.findManyByName(name))[0];
51
51
  }
52
+ static async create(data) {
53
+ // let iconUri = data.icon;
54
+ // if (data.iconFile) {
55
+ // iconUri = await BucketService.upload("merkl-assets", `/protocols/${id}`, data.iconFile.stream(), true);
56
+ // }
57
+ return await ProtocolRepository.create({
58
+ data,
59
+ });
60
+ }
52
61
  static async update(id, data) {
53
62
  // let iconUri = data.icon;
54
63
  // if (data.iconFile) {
@@ -817,6 +817,35 @@ export declare const v4: Elysia<"/v4", false, {
817
817
  };
818
818
  };
819
819
  };
820
+ } & {
821
+ protocols: {
822
+ index: {
823
+ post: {
824
+ body: {
825
+ name: string;
826
+ url: string;
827
+ description: string;
828
+ id: string;
829
+ icon: string;
830
+ };
831
+ params: {};
832
+ query: unknown;
833
+ headers: {
834
+ authorization: string;
835
+ };
836
+ response: {
837
+ 200: {
838
+ name: string;
839
+ url: string;
840
+ description: string;
841
+ id: string;
842
+ tags: import("../../../database/api/.generated").$Enums.ProtocolTag[];
843
+ icon: string;
844
+ };
845
+ };
846
+ };
847
+ };
848
+ };
820
849
  };
821
850
  } & {
822
851
  v4: {
@@ -29,12 +29,12 @@ declare const _default: (app: Elysia) => Elysia<"", false, {
29
29
  query: {
30
30
  user?: string | undefined;
31
31
  AMMs?: string | string[] | undefined;
32
- "AMMs[0]"?: string | undefined;
33
- "AMMs[]"?: string | string[] | undefined;
34
32
  chainIds?: number | number[] | undefined;
35
- "chainIds[0]"?: number | undefined;
36
- "chainIds[]"?: number | number[] | undefined;
37
33
  onlyLive?: string | undefined;
34
+ "AMMs[]"?: string | string[] | undefined;
35
+ "AMMs[0]"?: string | undefined;
36
+ "chainIds[]"?: number | number[] | undefined;
37
+ "chainIds[0]"?: number | undefined;
38
38
  };
39
39
  headers: unknown;
40
40
  response: {
@@ -20,12 +20,12 @@ export declare const v2: Elysia<"/v2", false, {
20
20
  query: {
21
21
  user?: string | undefined;
22
22
  AMMs?: string | string[] | undefined;
23
- "AMMs[0]"?: string | undefined;
24
- "AMMs[]"?: string | string[] | undefined;
25
23
  chainIds?: number | number[] | undefined;
26
- "chainIds[0]"?: number | undefined;
27
- "chainIds[]"?: number | number[] | undefined;
28
24
  onlyLive?: string | undefined;
25
+ "AMMs[]"?: string | string[] | undefined;
26
+ "AMMs[0]"?: string | undefined;
27
+ "chainIds[]"?: number | number[] | undefined;
28
+ "chainIds[0]"?: number | undefined;
29
29
  };
30
30
  headers: unknown;
31
31
  response: {
@@ -1,9 +1,45 @@
1
- import type { App } from "../../index";
1
+ import type Elysia from "elysia";
2
2
  export declare const query: import("@sinclair/typebox").TObject<{
3
3
  user: import("@sinclair/typebox").TString;
4
4
  }>;
5
5
  export declare const response: import("@sinclair/typebox").TObject<{
6
6
  isBlacklisted: import("@sinclair/typebox").TBoolean;
7
7
  }>;
8
- declare const _default: (app: App) => any;
8
+ declare const _default: (app: Elysia) => Elysia<"", false, {
9
+ decorator: {};
10
+ store: {};
11
+ derive: {};
12
+ resolve: {};
13
+ }, {
14
+ type: {};
15
+ error: {};
16
+ }, {
17
+ schema: {};
18
+ macro: {};
19
+ macroFn: {};
20
+ }, {
21
+ blacklist: {
22
+ get: {
23
+ body: unknown;
24
+ params: {};
25
+ query: {
26
+ user: string;
27
+ };
28
+ headers: unknown;
29
+ response: {
30
+ 200: {
31
+ isBlacklisted: boolean;
32
+ };
33
+ };
34
+ };
35
+ };
36
+ }, {
37
+ derive: {};
38
+ resolve: {};
39
+ schema: {};
40
+ }, {
41
+ derive: {};
42
+ resolve: {};
43
+ schema: {};
44
+ }>;
9
45
  export default _default;
@@ -1,4 +1,4 @@
1
- import type { App } from "../../index";
1
+ import type Elysia from "elysia";
2
2
  export declare const query: import("@sinclair/typebox").TObject<{
3
3
  chainIds: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>]>>;
4
4
  types: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>, import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>]>>;
@@ -7,5 +7,44 @@ export declare const query: import("@sinclair/typebox").TObject<{
7
7
  hideTestTokens: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
8
8
  }>;
9
9
  export declare const response: import("@sinclair/typebox").TObject<{}>;
10
- declare const _default: (app: App) => any;
10
+ declare const _default: (app: Elysia) => Elysia<"", false, {
11
+ decorator: {};
12
+ store: {};
13
+ derive: {};
14
+ resolve: {};
15
+ }, {
16
+ type: {};
17
+ error: {};
18
+ }, {
19
+ schema: {};
20
+ macro: {};
21
+ macroFn: {};
22
+ }, {
23
+ campaigns: {
24
+ get: {
25
+ body: unknown;
26
+ params: {};
27
+ query: {
28
+ types?: string | number | string[] | number[] | undefined;
29
+ creatorTag?: string | undefined;
30
+ live?: boolean | undefined;
31
+ chainIds?: string | string[] | undefined;
32
+ hideTestTokens?: string | undefined;
33
+ };
34
+ headers: unknown;
35
+ response: {
36
+ [x: string]: any;
37
+ 200: any;
38
+ };
39
+ };
40
+ };
41
+ }, {
42
+ derive: {};
43
+ resolve: {};
44
+ schema: {};
45
+ }, {
46
+ derive: {};
47
+ resolve: {};
48
+ schema: {};
49
+ }>;
11
50
  export default _default;
@@ -1,3 +1,41 @@
1
- import type { App } from "../../index";
2
- declare const _default: (app: App) => any;
1
+ import type Elysia from "elysia";
2
+ declare const _default: (app: Elysia) => Elysia<"", false, {
3
+ decorator: {};
4
+ store: {};
5
+ derive: {};
6
+ resolve: {};
7
+ }, {
8
+ type: {};
9
+ error: {};
10
+ }, {
11
+ schema: {};
12
+ macro: {};
13
+ macroFn: {};
14
+ }, {
15
+ campaignInfo: {
16
+ post: {
17
+ body: {
18
+ [x: string]: string[];
19
+ };
20
+ params: {};
21
+ query: unknown;
22
+ headers: unknown;
23
+ response: {
24
+ 200: {
25
+ [x: string]: Record<string, any>;
26
+ } | {
27
+ error: string;
28
+ };
29
+ };
30
+ };
31
+ };
32
+ }, {
33
+ derive: {};
34
+ resolve: {};
35
+ schema: {};
36
+ }, {
37
+ derive: {};
38
+ resolve: {};
39
+ schema: {};
40
+ }>;
3
41
  export default _default;
@@ -23,8 +23,8 @@ declare const _default: (app: Elysia) => Elysia<"", false, {
23
23
  body: unknown;
24
24
  params: {};
25
25
  query: {
26
- chainIds?: string | string[] | undefined;
27
26
  creatorTag?: string | undefined;
27
+ chainIds?: string | string[] | undefined;
28
28
  byReason?: boolean | undefined;
29
29
  user: string;
30
30
  };
@@ -1,8 +1,45 @@
1
- import type { App } from "../../index";
1
+ import type Elysia from "elysia";
2
2
  export declare const query: import("@sinclair/typebox").TObject<{
3
3
  chainIds: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>]>>;
4
4
  user: import("@sinclair/typebox").TString;
5
5
  creatorTag: import("@sinclair/typebox").TString;
6
6
  }>;
7
- declare const _default: (app: App) => any;
7
+ declare const _default: (app: Elysia) => Elysia<"", false, {
8
+ decorator: {};
9
+ store: {};
10
+ derive: {};
11
+ resolve: {};
12
+ }, {
13
+ type: {};
14
+ error: {};
15
+ }, {
16
+ schema: {};
17
+ macro: {};
18
+ macroFn: {};
19
+ }, {
20
+ multiChainPositions: {
21
+ get: {
22
+ body: unknown;
23
+ params: {};
24
+ query: {
25
+ chainIds?: string | string[] | undefined;
26
+ user: string;
27
+ creatorTag: string;
28
+ };
29
+ headers: unknown;
30
+ response: {
31
+ [x: string]: any;
32
+ 200: any;
33
+ };
34
+ };
35
+ };
36
+ }, {
37
+ derive: {};
38
+ resolve: {};
39
+ schema: {};
40
+ }, {
41
+ derive: {};
42
+ resolve: {};
43
+ schema: {};
44
+ }>;
8
45
  export default _default;
@@ -1,4 +1,4 @@
1
- import type { App } from "../../index";
1
+ import type Elysia from "elysia";
2
2
  export declare const query: import("@sinclair/typebox").TObject<{
3
3
  campaigns: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
4
4
  testTokens: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
@@ -22,5 +22,45 @@ export declare const response: import("@sinclair/typebox").TRecord<import("@sinc
22
22
  type: import("@sinclair/typebox").TNumber;
23
23
  }>;
24
24
  }>>;
25
- declare const _default: (app: App) => any;
25
+ declare const _default: (app: Elysia) => Elysia<"", false, {
26
+ decorator: {};
27
+ store: {};
28
+ derive: {};
29
+ resolve: {};
30
+ }, {
31
+ type: {};
32
+ error: {};
33
+ }, {
34
+ schema: {};
35
+ macro: {};
36
+ macroFn: {};
37
+ }, {
38
+ opportunity: {
39
+ get: {
40
+ body: unknown;
41
+ params: {};
42
+ query: {
43
+ type?: undefined;
44
+ tag?: string | undefined;
45
+ chainId?: undefined;
46
+ mainParameter?: string | undefined;
47
+ action?: undefined;
48
+ campaigns?: boolean | undefined;
49
+ testTokens?: boolean | undefined;
50
+ };
51
+ headers: unknown;
52
+ response: {
53
+ 200: {};
54
+ };
55
+ };
56
+ };
57
+ }, {
58
+ derive: {};
59
+ resolve: {};
60
+ schema: {};
61
+ }, {
62
+ derive: {};
63
+ resolve: {};
64
+ schema: {};
65
+ }>;
26
66
  export default _default;
@@ -1,4 +1,4 @@
1
- import type { App } from "../../index";
1
+ import type Elysia from "elysia";
2
2
  import { type TSchema } from "elysia";
3
3
  export declare const query: import("@sinclair/typebox").TObject<{
4
4
  chainId: import("@sinclair/typebox").TUnion<TSchema[]>;
@@ -23,5 +23,41 @@ export declare const response: import("@sinclair/typebox").TRecord<import("@sinc
23
23
  balance: import("@sinclair/typebox").TNumber;
24
24
  }>)[]>>;
25
25
  }>>;
26
- declare const _default: (app: App) => any;
26
+ declare const _default: (app: Elysia) => Elysia<"", false, {
27
+ decorator: {};
28
+ store: {};
29
+ derive: {};
30
+ resolve: {};
31
+ }, {
32
+ type: {};
33
+ error: {};
34
+ }, {
35
+ schema: {};
36
+ macro: {};
37
+ macroFn: {};
38
+ }, {
39
+ positions: {
40
+ get: {
41
+ body: unknown;
42
+ params: {};
43
+ query: {
44
+ chainId: never;
45
+ user: string;
46
+ };
47
+ headers: unknown;
48
+ response: {
49
+ [x: string]: any;
50
+ 200: any;
51
+ };
52
+ };
53
+ };
54
+ }, {
55
+ derive: {};
56
+ resolve: {};
57
+ schema: {};
58
+ }, {
59
+ derive: {};
60
+ resolve: {};
61
+ schema: {};
62
+ }>;
27
63
  export default _default;
@@ -1,8 +1,72 @@
1
- import type { App } from "../../index";
1
+ import type Elysia from "elysia";
2
2
  export declare const query: import("@sinclair/typebox").TObject<{
3
3
  chainIds: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>]>>;
4
4
  user: import("@sinclair/typebox").TString;
5
5
  creatorTag: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
6
6
  }>;
7
- declare const _default: (app: App) => any;
7
+ declare const _default: (app: Elysia) => Elysia<"", false, {
8
+ decorator: {};
9
+ store: {};
10
+ derive: {};
11
+ resolve: {};
12
+ }, {
13
+ type: {};
14
+ error: {};
15
+ }, {
16
+ schema: {};
17
+ macro: {};
18
+ macroFn: {};
19
+ }, {
20
+ rewards: {
21
+ get: {
22
+ body: unknown;
23
+ params: {};
24
+ query: {
25
+ creatorTag?: string | undefined;
26
+ chainIds?: string | string[] | undefined;
27
+ user: string;
28
+ };
29
+ headers: unknown;
30
+ response: {
31
+ 200: {
32
+ [x: string]: {
33
+ campaignData: {
34
+ [x: string]: {
35
+ [x: string]: {
36
+ pending?: string | undefined;
37
+ symbol: string;
38
+ token: string;
39
+ mainParameter: string;
40
+ decimals: number;
41
+ auxiliaryData1: string;
42
+ auxiliaryData2: string;
43
+ unclaimed: string;
44
+ accumulated: string;
45
+ };
46
+ };
47
+ };
48
+ tokenData: {
49
+ [x: string]: {
50
+ pending?: string | undefined;
51
+ symbol: string;
52
+ decimals: number;
53
+ proof: string[];
54
+ unclaimed: string;
55
+ accumulated: string;
56
+ };
57
+ };
58
+ };
59
+ };
60
+ };
61
+ };
62
+ };
63
+ }, {
64
+ derive: {};
65
+ resolve: {};
66
+ schema: {};
67
+ }, {
68
+ derive: {};
69
+ resolve: {};
70
+ schema: {};
71
+ }>;
8
72
  export default _default;