@merkl/api 0.16.18 → 0.16.20

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 (45) hide show
  1. package/dist/src/backgroundJobs/jobs/campaignsCacheUpdater.js +1 -1
  2. package/dist/src/backgroundJobs/jobs/sync.js +1 -1
  3. package/dist/src/cache/index.d.ts +1 -1
  4. package/dist/src/cache/index.js +2 -2
  5. package/dist/src/eden/index.d.ts +410 -35
  6. package/dist/src/entities/campaign.js +1 -1
  7. package/dist/src/index.d.ts +82 -7
  8. package/dist/src/libs/deprecated-merklv3/index.js +2 -2
  9. package/dist/src/modules/v4/accounting/accounting.controller.js +1 -1
  10. package/dist/src/modules/v4/accounting/accounting.service.d.ts +1 -1
  11. package/dist/src/modules/v4/accounting/accounting.service.js +1 -1
  12. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +13 -1
  13. package/dist/src/modules/v4/campaign/campaign.repository.js +1 -1
  14. package/dist/src/modules/v4/campaign/campaign.service.d.ts +26 -2
  15. package/dist/src/modules/v4/chain/chain.controller.js +1 -1
  16. package/dist/src/modules/v4/chain/chain.repository.d.ts +1 -6
  17. package/dist/src/modules/v4/chain/chain.repository.js +2 -5
  18. package/dist/src/modules/v4/chain/chain.service.d.ts +1 -6
  19. package/dist/src/modules/v4/chain/chain.service.js +2 -5
  20. package/dist/src/modules/v4/enso/enso.service.js +4 -1
  21. package/dist/src/modules/v4/kyberzap/kyberzap.service.js +1 -1
  22. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +40 -4
  23. package/dist/src/modules/v4/opportunity/opportunity.controller.js +1 -1
  24. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +2 -2
  25. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +109 -13
  26. package/dist/src/modules/v4/opportunity/opportunity.service.js +1 -1
  27. package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.js +3 -3
  28. package/dist/src/modules/v4/protocol/protocol.controller.d.ts +1 -0
  29. package/dist/src/modules/v4/protocol/protocol.model.d.ts +1 -0
  30. package/dist/src/modules/v4/protocol/protocol.model.js +1 -0
  31. package/dist/src/modules/v4/protocol/protocol.repository.js +5 -1
  32. package/dist/src/modules/v4/protocol/protocol.service.d.ts +0 -2
  33. package/dist/src/modules/v4/protocol/protocol.service.js +1 -39
  34. package/dist/src/modules/v4/reward/reward.service.js +1 -1
  35. package/dist/src/modules/v4/router.d.ts +82 -7
  36. package/dist/src/modules/v4/token/token.controller.d.ts +28 -2
  37. package/dist/src/modules/v4/token/token.service.d.ts +71 -7
  38. package/dist/src/modules/v4/token/token.service.js +3 -3
  39. package/dist/src/modules/v4/user/user.service.js +1 -1
  40. package/dist/src/routes/v3/multiChainPositions.js +1 -1
  41. package/dist/src/routes/v3/opportunity.js +5 -0
  42. package/dist/src/utils/camelToKebabCase.d.ts +1 -0
  43. package/dist/src/utils/camelToKebabCase.js +3 -0
  44. package/dist/tsconfig.package.tsbuildinfo +1 -1
  45. package/package.json +1 -1
@@ -34,7 +34,7 @@ export declare abstract class OpportunityService {
34
34
  name: string;
35
35
  status: "SOON";
36
36
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
37
- mainProtocol: "morpho" | "euler" | "ambient" | "arthswap" | "baseswap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "koi" | "supswap-v3" | "zkswap" | "thirdtrade" | "uniswapv4" | "uniswap-v2" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap-v3" | "neptune" | "zkSwapThreePool" | "syncswap" | "rfx" | "radiant" | "aave" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | undefined;
37
+ mainProtocol: string | undefined;
38
38
  depositUrl: any;
39
39
  tags: string[];
40
40
  }>;
@@ -46,8 +46,20 @@ export declare abstract class OpportunityService {
46
46
  name: string;
47
47
  status: "PAST" | "LIVE" | "SOON";
48
48
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
49
- tokens: any[];
50
- mainProtocol: "morpho" | "euler" | "ambient" | "arthswap" | "baseswap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "koi" | "supswap-v3" | "zkswap" | "thirdtrade" | "uniswapv4" | "uniswap-v2" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap-v3" | "neptune" | "zkSwapThreePool" | "syncswap" | "rfx" | "radiant" | "aave" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | undefined;
49
+ tokens: ({
50
+ symbol: string;
51
+ name: string | null;
52
+ id: string;
53
+ icon: string;
54
+ chainId: number;
55
+ address: string;
56
+ decimals: number;
57
+ verified: boolean;
58
+ isTest: boolean;
59
+ } & {
60
+ price?: number | null | undefined;
61
+ })[];
62
+ mainProtocol: string | undefined;
51
63
  depositUrl: any;
52
64
  tags: string[];
53
65
  }>;
@@ -71,7 +83,7 @@ export declare abstract class OpportunityService {
71
83
  verified: boolean;
72
84
  isTest: boolean;
73
85
  }[];
74
- mainProtocol: "morpho" | "euler" | "ambient" | "arthswap" | "baseswap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "koi" | "supswap-v3" | "zkswap" | "thirdtrade" | "uniswapv4" | "uniswap-v2" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap-v3" | "neptune" | "zkSwapThreePool" | "syncswap" | "rfx" | "radiant" | "aave" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | undefined;
86
+ mainProtocol: string | undefined;
75
87
  depositUrl: string | undefined;
76
88
  tags: string[];
77
89
  }>;
@@ -86,8 +98,20 @@ export declare abstract class OpportunityService {
86
98
  name: string;
87
99
  status: "PAST" | "LIVE" | "SOON";
88
100
  action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
89
- tokens: any[];
90
- mainProtocol: "morpho" | "euler" | "ambient" | "arthswap" | "baseswap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "koi" | "supswap-v3" | "zkswap" | "thirdtrade" | "uniswapv4" | "uniswap-v2" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap-v3" | "neptune" | "zkSwapThreePool" | "syncswap" | "rfx" | "radiant" | "aave" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | undefined;
101
+ tokens: ({
102
+ symbol: string;
103
+ name: string | null;
104
+ id: string;
105
+ icon: string;
106
+ chainId: number;
107
+ address: string;
108
+ decimals: number;
109
+ verified: boolean;
110
+ isTest: boolean;
111
+ } & {
112
+ price?: number | null | undefined;
113
+ })[];
114
+ mainProtocol: string | undefined;
91
115
  depositUrl: any;
92
116
  tags: string[];
93
117
  }>;
@@ -190,7 +214,19 @@ export declare abstract class OpportunityService {
190
214
  id: number;
191
215
  icon: string;
192
216
  };
193
- rewardToken: Token;
217
+ rewardToken: {
218
+ symbol: string;
219
+ name: string | null;
220
+ id: string;
221
+ icon: string;
222
+ chainId: number;
223
+ address: string;
224
+ decimals: number;
225
+ verified: boolean;
226
+ isTest: boolean;
227
+ } & {
228
+ price?: number | null | undefined;
229
+ };
194
230
  distributionChain: {
195
231
  name: string;
196
232
  id: number;
@@ -230,7 +266,7 @@ export declare abstract class OpportunityService {
230
266
  * @param query
231
267
  * @returns A list of opportunities
232
268
  */
233
- static getMany(query: GetOpportunitiesQueryModel): Promise<{
269
+ static findMany(query: GetOpportunitiesQueryModel): Promise<{
234
270
  apr: number;
235
271
  aprRecord: {
236
272
  cumulated: number;
@@ -282,7 +318,19 @@ export declare abstract class OpportunityService {
282
318
  };
283
319
  id: string;
284
320
  depositUrl: string | undefined;
285
- tokens: Token[];
321
+ tokens: ({
322
+ symbol: string;
323
+ name: string | null;
324
+ id: string;
325
+ icon: string;
326
+ chainId: number;
327
+ address: string;
328
+ decimals: number;
329
+ verified: boolean;
330
+ isTest: boolean;
331
+ } & {
332
+ price?: number | null | undefined;
333
+ })[];
286
334
  chain: {
287
335
  name: string;
288
336
  id: number;
@@ -358,7 +406,19 @@ export declare abstract class OpportunityService {
358
406
  };
359
407
  id: string;
360
408
  depositUrl: string | undefined;
361
- tokens: Token[];
409
+ tokens: ({
410
+ symbol: string;
411
+ name: string | null;
412
+ id: string;
413
+ icon: string;
414
+ chainId: number;
415
+ address: string;
416
+ decimals: number;
417
+ verified: boolean;
418
+ isTest: boolean;
419
+ } & {
420
+ price?: number | null | undefined;
421
+ })[];
362
422
  chain: {
363
423
  name: string;
364
424
  id: number;
@@ -389,7 +449,19 @@ export declare abstract class OpportunityService {
389
449
  id: number;
390
450
  icon: string;
391
451
  };
392
- rewardToken: Token;
452
+ rewardToken: {
453
+ symbol: string;
454
+ name: string | null;
455
+ id: string;
456
+ icon: string;
457
+ chainId: number;
458
+ address: string;
459
+ decimals: number;
460
+ verified: boolean;
461
+ isTest: boolean;
462
+ } & {
463
+ price?: number | null | undefined;
464
+ };
393
465
  distributionChain: {
394
466
  name: string;
395
467
  id: number;
@@ -484,7 +556,19 @@ export declare abstract class OpportunityService {
484
556
  };
485
557
  id: string;
486
558
  depositUrl: string | undefined;
487
- tokens: Token[];
559
+ tokens: ({
560
+ symbol: string;
561
+ name: string | null;
562
+ id: string;
563
+ icon: string;
564
+ chainId: number;
565
+ address: string;
566
+ decimals: number;
567
+ verified: boolean;
568
+ isTest: boolean;
569
+ } & {
570
+ price?: number | null | undefined;
571
+ })[];
488
572
  chain: {
489
573
  name: string;
490
574
  id: number;
@@ -511,7 +595,19 @@ export declare abstract class OpportunityService {
511
595
  static formatResponseBase(opportunity: LightOpportunityFromDB): {
512
596
  id: string;
513
597
  depositUrl: string | undefined;
514
- tokens: Token[];
598
+ tokens: ({
599
+ symbol: string;
600
+ name: string | null;
601
+ id: string;
602
+ icon: string;
603
+ chainId: number;
604
+ address: string;
605
+ decimals: number;
606
+ verified: boolean;
607
+ isTest: boolean;
608
+ } & {
609
+ price?: number | null | undefined;
610
+ })[];
515
611
  chain: {
516
612
  name: string;
517
613
  id: number;
@@ -271,7 +271,7 @@ export class OpportunityService {
271
271
  * @param query
272
272
  * @returns A list of opportunities
273
273
  */
274
- static async getMany(query) {
274
+ static async findMany(query) {
275
275
  return await CacheService.wrap(TTLPresets.MIN_5, async (query) => {
276
276
  const opportunities = await OpportunityRepository.findMany(query);
277
277
  return opportunities.map(OpportunityService.formatResponse);
@@ -1,7 +1,7 @@
1
+ import { camelToKebabCase } from "../../../../utils/camelToKebabCase";
1
2
  import { OpportunityAction } from "../../../../../database/api/.generated";
2
- import { ChainId, almName, ammName } from "@sdk";
3
+ import { AMM, ChainId, almName, ammName } from "@sdk";
3
4
  import { getAddress } from "viem";
4
- import { ProtocolService } from "../../protocol";
5
5
  export const getClammMetadata = (chainId, params) => {
6
6
  let platform = ammName(params.amm);
7
7
  if (platform === "BaseSwap") {
@@ -43,6 +43,6 @@ export const getClammMetadata = (chainId, params) => {
43
43
  { chainId, address: params.token0 },
44
44
  { chainId, address: params.token1 },
45
45
  ],
46
- mainProtocol: ProtocolService.getIdFromAmmV3(params.amm),
46
+ mainProtocol: camelToKebabCase(AMM[params.amm]),
47
47
  };
48
48
  };
@@ -23,6 +23,7 @@ export declare const ProtocolController: Elysia<"/protocols", false, {
23
23
  items?: number | undefined;
24
24
  tags?: string[] | undefined;
25
25
  page?: number | undefined;
26
+ ids?: string[] | undefined;
26
27
  opportunityTag?: string | undefined;
27
28
  };
28
29
  headers: unknown;
@@ -21,6 +21,7 @@ export declare const ProtocolResourceDto: import("@sinclair/typebox").TObject<{
21
21
  }>;
22
22
  export declare const GetProtocolsQueryDto: import("@sinclair/typebox").TObject<{
23
23
  id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
24
+ ids: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
24
25
  name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
25
26
  tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
26
27
  opportunityTag: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -94,6 +94,7 @@ export const ProtocolResourceDto = t.Object({
94
94
  });
95
95
  export const GetProtocolsQueryDto = t.Object({
96
96
  id: t.Optional(t.String({ description: "Filter results by name. Useful for searching a protocol to verify its integration" })),
97
+ ids: t.Optional(t.Array(t.String())),
97
98
  name: t.Optional(t.String({ description: "Search protocols by name" })),
98
99
  tags: t.Optional(t.Array(t.String())),
99
100
  opportunityTag: t.Optional(t.String({ description: "Filter by underlying opportunities' tag" })),
@@ -22,7 +22,11 @@ export class ProtocolRepository {
22
22
  static #transformQueryToPrismaFilters(query) {
23
23
  return {
24
24
  where: {
25
- id: query.id ? { contains: query.id, mode: "insensitive" } : undefined,
25
+ id: query.id
26
+ ? { contains: query.id, mode: "insensitive" }
27
+ : query.ids
28
+ ? { in: query.ids, mode: "insensitive" }
29
+ : undefined,
26
30
  tags: query.tags ? { hasEvery: query.tags } : undefined,
27
31
  name: query.name ? { contains: query.name, mode: "insensitive" } : undefined,
28
32
  OR: query.opportunityTag // The opportunity tag specified can be either at the protocol level or the opportunity level
@@ -1,7 +1,5 @@
1
- import { AMM as AMMV3 } from "@sdk";
2
1
  import type { CreateProtocolModel, GetProtocolsQueryModel, Protocol, ProtocolId, UpdateProtocolModel } from "./protocol.model";
3
2
  export declare abstract class ProtocolService {
4
- static getIdFromAmmV3(amm: AMMV3): ProtocolId;
5
3
  static findMany(query: GetProtocolsQueryModel): Promise<Protocol["model"][]>;
6
4
  static countMany(query: GetProtocolsQueryModel): Promise<number>;
7
5
  static getFromId(id: ProtocolId | string): Promise<Protocol["model"] | null>;
@@ -1,47 +1,9 @@
1
1
  import { ChainService } from "../chain/chain.service";
2
2
  import { TokenService } from "../token/token.service";
3
3
  import { log } from "../../../utils/logger";
4
- import { AMM as AMMV3 } from "@sdk";
5
4
  import { ProtocolRepository } from "./protocol.repository";
6
5
  // ─── Protocols Services ──────────────────────────────────────────────────────
7
6
  export class ProtocolService {
8
- static getIdFromAmmV3(amm) {
9
- return {
10
- [AMMV3.ARTHSWAP]: "arthswap",
11
- [AMMV3.BaseSwap]: "baseswap",
12
- [AMMV3.Camelot]: "camelot",
13
- [AMMV3.Crust]: "crust",
14
- [AMMV3.Fenix]: "fenix",
15
- [AMMV3.Horiza]: "horiza",
16
- [AMMV3.Izumi]: "izumi",
17
- [AMMV3.Kim]: "kim",
18
- [AMMV3.PancakeSwapV3]: "pancakeswap-v3",
19
- [AMMV3.QuickswapAlgebra]: "quickswap-algebra",
20
- [AMMV3.QuickswapUni]: "quickswap-uni",
21
- [AMMV3.Ramses]: "ramses",
22
- [AMMV3.Retro]: "retro",
23
- [AMMV3.Stryke]: "stryke",
24
- [AMMV3.StrykePCS]: "stryke-pcs",
25
- [AMMV3.StrykeSushi]: "stryke-sushi",
26
- [AMMV3.SushiSwapV3]: "sushiswap-v3",
27
- [AMMV3.Swapr]: "swapr",
28
- [AMMV3.Thruster]: "thruster",
29
- [AMMV3.UniswapV3]: "uniswap-v3",
30
- [AMMV3.Voltage]: "voltage",
31
- [AMMV3.ZERO]: "zero",
32
- [AMMV3.KOI]: "koi",
33
- [AMMV3.SupswapV3]: "supswap-v3",
34
- [AMMV3.AERODROME]: "aerodrome",
35
- [AMMV3.zkSwap]: "zkswap",
36
- [AMMV3.ThirdTrade]: "thirdtrade",
37
- [AMMV3.SyncswapV3]: "syncswap",
38
- [AMMV3.Neptune]: "neptune",
39
- [AMMV3.KYO]: "kyo",
40
- [AMMV3.Sonex]: "sonex",
41
- [AMMV3.QuickswapAlgebraV1_2]: "quickswap-algebra",
42
- [AMMV3.Velodrome]: "velodrome",
43
- }[amm];
44
- }
45
7
  static async findMany(query) {
46
8
  const protocols = await ProtocolRepository.findMany(query);
47
9
  const enrichedProtocols = protocols.map(({ MainOpportunities, ...protocol }) => ({
@@ -82,7 +44,7 @@ export class ProtocolService {
82
44
  log.info(`Updated protocol ${protocol.id} icon`);
83
45
  }
84
46
  }
85
- const chains = await ChainService.findMany();
47
+ const chains = await ChainService.findMany({});
86
48
  for (const chain of chains) {
87
49
  if (chain.icon.includes(oldUrl)) {
88
50
  await ChainService.update(chain.id, { icon: chain.icon.replace(oldUrl, newUrl) });
@@ -174,7 +174,7 @@ export class RewardService {
174
174
  return rewards;
175
175
  }
176
176
  static async getUserRewardsByChain(user, withToken, chainFilter = [], connectedChainId = null, withTestTokens = false) {
177
- const chains = await ChainService.findMany();
177
+ const chains = await ChainService.findMany({});
178
178
  let chainIds = !chainFilter || !chainFilter.length
179
179
  ? chains.map(({ id }) => id)
180
180
  : chains.map(({ id }) => id).filter(id => chainFilter.includes(id));
@@ -93,8 +93,20 @@ export declare const v4: Elysia<"/v4", false, {
93
93
  name: string;
94
94
  status: "PAST" | "LIVE" | "SOON";
95
95
  action: import("../../../database/api/.generated").$Enums.OpportunityAction;
96
- tokens: any[];
97
- mainProtocol: "morpho" | "euler" | "ambient" | "arthswap" | "baseswap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "koi" | "supswap-v3" | "zkswap" | "thirdtrade" | "uniswapv4" | "uniswap-v2" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap-v3" | "neptune" | "zkSwapThreePool" | "syncswap" | "rfx" | "radiant" | "aave" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | undefined;
96
+ tokens: ({
97
+ symbol: string;
98
+ name: string | null;
99
+ id: string;
100
+ icon: string;
101
+ chainId: number;
102
+ address: string;
103
+ decimals: number;
104
+ verified: boolean;
105
+ isTest: boolean;
106
+ } & {
107
+ price?: number | null | undefined;
108
+ })[];
109
+ mainProtocol: string | undefined;
98
110
  depositUrl: any;
99
111
  tags: string[];
100
112
  };
@@ -179,7 +191,19 @@ export declare const v4: Elysia<"/v4", false, {
179
191
  };
180
192
  id: string;
181
193
  depositUrl: string | undefined;
182
- tokens: Token[];
194
+ tokens: ({
195
+ symbol: string;
196
+ name: string | null;
197
+ id: string;
198
+ icon: string;
199
+ chainId: number;
200
+ address: string;
201
+ decimals: number;
202
+ verified: boolean;
203
+ isTest: boolean;
204
+ } & {
205
+ price?: number | null | undefined;
206
+ })[];
183
207
  chain: {
184
208
  name: string;
185
209
  id: number;
@@ -466,7 +490,19 @@ export declare const v4: Elysia<"/v4", false, {
466
490
  id: number;
467
491
  icon: string;
468
492
  };
469
- rewardToken: Token;
493
+ rewardToken: {
494
+ symbol: string;
495
+ name: string | null;
496
+ id: string;
497
+ icon: string;
498
+ chainId: number;
499
+ address: string;
500
+ decimals: number;
501
+ verified: boolean;
502
+ isTest: boolean;
503
+ } & {
504
+ price?: number | null | undefined;
505
+ };
470
506
  distributionChain: {
471
507
  name: string;
472
508
  id: number;
@@ -946,7 +982,19 @@ export declare const v4: Elysia<"/v4", false, {
946
982
  id: number;
947
983
  icon: string;
948
984
  };
949
- rewardToken: Token;
985
+ rewardToken: {
986
+ symbol: string;
987
+ name: string | null;
988
+ id: string;
989
+ icon: string;
990
+ chainId: number;
991
+ address: string;
992
+ decimals: number;
993
+ verified: boolean;
994
+ isTest: boolean;
995
+ } & {
996
+ price?: number | null | undefined;
997
+ };
950
998
  distributionChain: {
951
999
  name: string;
952
1000
  id: number;
@@ -1103,6 +1151,7 @@ export declare const v4: Elysia<"/v4", false, {
1103
1151
  items?: number | undefined;
1104
1152
  tags?: string[] | undefined;
1105
1153
  page?: number | undefined;
1154
+ ids?: string[] | undefined;
1106
1155
  opportunityTag?: string | undefined;
1107
1156
  };
1108
1157
  headers: unknown;
@@ -1359,7 +1408,21 @@ export declare const v4: Elysia<"/v4", false, {
1359
1408
  };
1360
1409
  headers: unknown;
1361
1410
  response: {
1362
- 200: any[];
1411
+ 200: ({
1412
+ symbol: string;
1413
+ name: string | null;
1414
+ id: string;
1415
+ icon: string;
1416
+ chainId: number;
1417
+ address: string;
1418
+ decimals: number;
1419
+ verified: boolean;
1420
+ isTest: boolean;
1421
+ } & {
1422
+ price?: number | null | undefined;
1423
+ } & {
1424
+ balance: bigint;
1425
+ })[];
1363
1426
  };
1364
1427
  };
1365
1428
  };
@@ -1381,7 +1444,19 @@ export declare const v4: Elysia<"/v4", false, {
1381
1444
  };
1382
1445
  headers: unknown;
1383
1446
  response: {
1384
- 200: Token[];
1447
+ 200: ({
1448
+ symbol: string;
1449
+ name: string | null;
1450
+ id: string;
1451
+ icon: string;
1452
+ chainId: number;
1453
+ address: string;
1454
+ decimals: number;
1455
+ verified: boolean;
1456
+ isTest: boolean;
1457
+ } & {
1458
+ price?: number | null | undefined;
1459
+ })[];
1385
1460
  };
1386
1461
  };
1387
1462
  };
@@ -120,7 +120,21 @@ export declare const TokenController: Elysia<"/tokens", false, {
120
120
  };
121
121
  headers: unknown;
122
122
  response: {
123
- 200: any[];
123
+ 200: ({
124
+ symbol: string;
125
+ name: string | null;
126
+ id: string;
127
+ icon: string;
128
+ chainId: number;
129
+ address: string;
130
+ decimals: number;
131
+ verified: boolean;
132
+ isTest: boolean;
133
+ } & {
134
+ price?: number | null | undefined;
135
+ } & {
136
+ balance: bigint;
137
+ })[];
124
138
  };
125
139
  };
126
140
  };
@@ -142,7 +156,19 @@ export declare const TokenController: Elysia<"/tokens", false, {
142
156
  };
143
157
  headers: unknown;
144
158
  response: {
145
- 200: Token[];
159
+ 200: ({
160
+ symbol: string;
161
+ name: string | null;
162
+ id: string;
163
+ icon: string;
164
+ chainId: number;
165
+ address: string;
166
+ decimals: number;
167
+ verified: boolean;
168
+ isTest: boolean;
169
+ } & {
170
+ price?: number | null | undefined;
171
+ })[];
146
172
  };
147
173
  };
148
174
  };
@@ -1,6 +1,6 @@
1
- import type { CreateTokenModel, GetTokenQueryModel, Token, TokenModel, TokenUnique, UpdateTokenModel } from "./";
2
1
  import type { Pricer } from "../../../utils/pricer";
3
2
  import { type ChainId } from "@sdk";
3
+ import type { CreateTokenModel, GetTokenQueryModel, Token, TokenModel, TokenUnique, UpdateTokenModel } from "./token.model";
4
4
  import { TokenRepository } from "./token.repository";
5
5
  export declare abstract class TokenService {
6
6
  static hashId(token: TokenUnique): string;
@@ -14,16 +14,56 @@ export declare abstract class TokenService {
14
14
  /**
15
15
  * Fetches tokens and include balances
16
16
  */
17
- static fetchTokensAndBalances(chainId: number, userAddress: string, addresses: string[]): Promise<any[]>;
17
+ static fetchTokensAndBalances(chainId: number, userAddress: string, addresses: string[]): Promise<({
18
+ symbol: string;
19
+ name: string | null;
20
+ id: string;
21
+ icon: string;
22
+ chainId: number;
23
+ address: string;
24
+ decimals: number;
25
+ verified: boolean;
26
+ isTest: boolean;
27
+ } & {
28
+ price?: number | null | undefined;
29
+ } & {
30
+ balance: bigint;
31
+ })[]>;
18
32
  /**
19
33
  * Fetches balances of verified tokens
20
34
  * @info tokens that are popular and must be detected in the app are marked as 'verified'
21
35
  * @param additionalTokens balances along with the verified ones
22
36
  */
23
- static fetchVerifiedBalances(chainId: number, userAddress: string, additionalTokenAddresses?: string[]): Promise<any[]>;
37
+ static fetchVerifiedBalances(chainId: number, userAddress: string, additionalTokenAddresses?: string[]): Promise<({
38
+ symbol: string;
39
+ name: string | null;
40
+ id: string;
41
+ icon: string;
42
+ chainId: number;
43
+ address: string;
44
+ decimals: number;
45
+ verified: boolean;
46
+ isTest: boolean;
47
+ } & {
48
+ price?: number | null | undefined;
49
+ } & {
50
+ balance: bigint;
51
+ })[]>;
24
52
  static fetchOnChain(token: TokenModel): Promise<Omit<Token["model"], "id">>;
25
53
  static fetchManyOnChain(chainId: ChainId, addresses: string[]): Promise<{
26
- [address: string]: Omit<Token, "id">;
54
+ [address: string]: Omit<{
55
+ symbol: string;
56
+ name: string | null;
57
+ id: string;
58
+ icon: string;
59
+ chainId: number;
60
+ address: string;
61
+ decimals: number;
62
+ verified: boolean;
63
+ isTest: boolean;
64
+ } & {
65
+ price?: number | null | undefined;
66
+ }, "id">;
27
67
  }>;
28
68
  /**
29
69
  * Updates price of tokens that share the same symbol
@@ -110,15 +150,39 @@ export declare abstract class TokenService {
110
150
  * @param query
111
151
  * @returns A list of tokens
112
152
  */
113
- static findMany(query: GetTokenQueryModel): Promise<Token[]>;
114
- static findManyObjectPerAddress(query: GetTokenQueryModel): Promise<Token>;
153
+ static findMany(query: GetTokenQueryModel): Promise<({
154
+ symbol: string;
155
+ name: string | null;
156
+ id: string;
157
+ icon: string;
158
+ chainId: number;
159
+ address: string;
160
+ decimals: number;
161
+ verified: boolean;
162
+ isTest: boolean;
163
+ } & {
164
+ price?: number | null | undefined;
165
+ })[]>;
166
+ static findManyObjectPerAddress(query: GetTokenQueryModel): Promise<Record<string, {
167
+ symbol: string;
168
+ name: string | null;
169
+ id: string;
170
+ icon: string;
171
+ chainId: number;
172
+ address: string;
173
+ decimals: number;
174
+ verified: boolean;
175
+ isTest: boolean;
176
+ } & {
177
+ price?: number | null | undefined;
178
+ }>>;
115
179
  /**
116
180
  * Get value of tokens
117
181
  * @param tokenAmounts address/chain + amount of token
118
182
  * @returns the cumulated dollar value of all tokens
119
183
  */
120
184
  static getValue(tokenAmounts: {
121
- amount: bigint;
185
+ amount?: bigint;
122
186
  address: string;
123
187
  chainId: number;
124
188
  }[]): Promise<number>;
@@ -238,7 +238,7 @@ export class TokenService {
238
238
  .find(({ address: addr, chainId: chain }) => addr === address && chainId === chain);
239
239
  if (!token)
240
240
  return sum;
241
- const value = (bigIntToNumber(amount, token.decimals) ?? 0) * (token.price ?? 0);
241
+ const value = (bigIntToNumber(amount ?? 0n, token.decimals) ?? 0) * (token.price ?? 0);
242
242
  return sum + value;
243
243
  }, 0);
244
244
  }
@@ -267,10 +267,10 @@ export class TokenService {
267
267
  }
268
268
  catch (err) {
269
269
  if (err instanceof Prisma.PrismaClientKnownRequestError && err.code === "P2025") {
270
- const newToken = await TokenService.fetchOnChain(token);
270
+ const newToken = Object.assign(await TokenService.fetchOnChain(token), { id: id });
271
271
  if (!newToken)
272
272
  return;
273
- return await TokenRepository.upsert({ ...newToken, id });
273
+ return await TokenRepository.upsert(newToken);
274
274
  }
275
275
  }
276
276
  }));