@merkl/api 0.18.2 → 0.18.4

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.
@@ -1689,11 +1689,6 @@ declare const eden: {
1689
1689
  plain_text: string;
1690
1690
  }[];
1691
1691
  };
1692
- Name: {
1693
- rich_text: {
1694
- plain_text: string;
1695
- }[];
1696
- };
1697
1692
  Icon: {
1698
1693
  files: {
1699
1694
  file: {
@@ -1709,6 +1704,14 @@ declare const eden: {
1709
1704
  "Chain ID": {
1710
1705
  number: number;
1711
1706
  };
1707
+ Verified: {
1708
+ checkbox: boolean;
1709
+ };
1710
+ "CoinGecko API ID": {
1711
+ rich_text: {
1712
+ plain_text: string;
1713
+ }[];
1714
+ };
1712
1715
  };
1713
1716
  };
1714
1717
  }, options: {
@@ -1718,7 +1721,20 @@ declare const eden: {
1718
1721
  query?: Record<string, unknown> | undefined;
1719
1722
  fetch?: RequestInit | undefined;
1720
1723
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1721
- 200: void;
1724
+ 200: {
1725
+ symbol: string;
1726
+ id: string;
1727
+ name: string | null;
1728
+ icon: string;
1729
+ chainId: number;
1730
+ address: string;
1731
+ decimals: number;
1732
+ displaySymbol: string;
1733
+ verified: boolean;
1734
+ isTest: boolean;
1735
+ isNative: boolean;
1736
+ price: number | null;
1737
+ };
1722
1738
  }>>;
1723
1739
  };
1724
1740
  };
@@ -5128,11 +5144,6 @@ declare const eden: {
5128
5144
  plain_text: string;
5129
5145
  }[];
5130
5146
  };
5131
- Name: {
5132
- rich_text: {
5133
- plain_text: string;
5134
- }[];
5135
- };
5136
5147
  Icon: {
5137
5148
  files: {
5138
5149
  file: {
@@ -5148,6 +5159,14 @@ declare const eden: {
5148
5159
  "Chain ID": {
5149
5160
  number: number;
5150
5161
  };
5162
+ Verified: {
5163
+ checkbox: boolean;
5164
+ };
5165
+ "CoinGecko API ID": {
5166
+ rich_text: {
5167
+ plain_text: string;
5168
+ }[];
5169
+ };
5151
5170
  };
5152
5171
  };
5153
5172
  }, options: {
@@ -5157,7 +5176,20 @@ declare const eden: {
5157
5176
  query?: Record<string, unknown> | undefined;
5158
5177
  fetch?: RequestInit | undefined;
5159
5178
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
5160
- 200: void;
5179
+ 200: {
5180
+ symbol: string;
5181
+ id: string;
5182
+ name: string | null;
5183
+ icon: string;
5184
+ chainId: number;
5185
+ address: string;
5186
+ decimals: number;
5187
+ displaySymbol: string;
5188
+ verified: boolean;
5189
+ isTest: boolean;
5190
+ isNative: boolean;
5191
+ price: number | null;
5192
+ };
5161
5193
  }>>;
5162
5194
  };
5163
5195
  };
@@ -9511,11 +9543,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
9511
9543
  plain_text: string;
9512
9544
  }[];
9513
9545
  };
9514
- Name: {
9515
- rich_text: {
9516
- plain_text: string;
9517
- }[];
9518
- };
9519
9546
  Icon: {
9520
9547
  files: {
9521
9548
  file: {
@@ -9531,6 +9558,14 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
9531
9558
  "Chain ID": {
9532
9559
  number: number;
9533
9560
  };
9561
+ Verified: {
9562
+ checkbox: boolean;
9563
+ };
9564
+ "CoinGecko API ID": {
9565
+ rich_text: {
9566
+ plain_text: string;
9567
+ }[];
9568
+ };
9534
9569
  };
9535
9570
  };
9536
9571
  };
@@ -9540,7 +9575,20 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
9540
9575
  authorization: string;
9541
9576
  };
9542
9577
  response: {
9543
- 200: void;
9578
+ 200: {
9579
+ symbol: string;
9580
+ id: string;
9581
+ name: string | null;
9582
+ icon: string;
9583
+ chainId: number;
9584
+ address: string;
9585
+ decimals: number;
9586
+ displaySymbol: string;
9587
+ verified: boolean;
9588
+ isTest: boolean;
9589
+ isNative: boolean;
9590
+ price: number | null;
9591
+ };
9544
9592
  };
9545
9593
  };
9546
9594
  };
@@ -14304,11 +14352,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14304
14352
  plain_text: string;
14305
14353
  }[];
14306
14354
  };
14307
- Name: {
14308
- rich_text: {
14309
- plain_text: string;
14310
- }[];
14311
- };
14312
14355
  Icon: {
14313
14356
  files: {
14314
14357
  file: {
@@ -14324,6 +14367,14 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14324
14367
  "Chain ID": {
14325
14368
  number: number;
14326
14369
  };
14370
+ Verified: {
14371
+ checkbox: boolean;
14372
+ };
14373
+ "CoinGecko API ID": {
14374
+ rich_text: {
14375
+ plain_text: string;
14376
+ }[];
14377
+ };
14327
14378
  };
14328
14379
  };
14329
14380
  }, options: {
@@ -14333,7 +14384,20 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14333
14384
  query?: Record<string, unknown> | undefined;
14334
14385
  fetch?: RequestInit | undefined;
14335
14386
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
14336
- 200: void;
14387
+ 200: {
14388
+ symbol: string;
14389
+ id: string;
14390
+ name: string | null;
14391
+ icon: string;
14392
+ chainId: number;
14393
+ address: string;
14394
+ decimals: number;
14395
+ displaySymbol: string;
14396
+ verified: boolean;
14397
+ isTest: boolean;
14398
+ isNative: boolean;
14399
+ price: number | null;
14400
+ };
14337
14401
  }>>;
14338
14402
  };
14339
14403
  };
@@ -17743,11 +17807,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
17743
17807
  plain_text: string;
17744
17808
  }[];
17745
17809
  };
17746
- Name: {
17747
- rich_text: {
17748
- plain_text: string;
17749
- }[];
17750
- };
17751
17810
  Icon: {
17752
17811
  files: {
17753
17812
  file: {
@@ -17763,6 +17822,14 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
17763
17822
  "Chain ID": {
17764
17823
  number: number;
17765
17824
  };
17825
+ Verified: {
17826
+ checkbox: boolean;
17827
+ };
17828
+ "CoinGecko API ID": {
17829
+ rich_text: {
17830
+ plain_text: string;
17831
+ }[];
17832
+ };
17766
17833
  };
17767
17834
  };
17768
17835
  }, options: {
@@ -17772,7 +17839,20 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
17772
17839
  query?: Record<string, unknown> | undefined;
17773
17840
  fetch?: RequestInit | undefined;
17774
17841
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
17775
- 200: void;
17842
+ 200: {
17843
+ symbol: string;
17844
+ id: string;
17845
+ name: string | null;
17846
+ icon: string;
17847
+ chainId: number;
17848
+ address: string;
17849
+ decimals: number;
17850
+ displaySymbol: string;
17851
+ verified: boolean;
17852
+ isTest: boolean;
17853
+ isNative: boolean;
17854
+ price: number | null;
17855
+ };
17776
17856
  }>>;
17777
17857
  };
17778
17858
  };
@@ -1959,11 +1959,6 @@ declare const app: Elysia<"", false, {
1959
1959
  plain_text: string;
1960
1960
  }[];
1961
1961
  };
1962
- Name: {
1963
- rich_text: {
1964
- plain_text: string;
1965
- }[];
1966
- };
1967
1962
  Icon: {
1968
1963
  files: {
1969
1964
  file: {
@@ -1979,6 +1974,14 @@ declare const app: Elysia<"", false, {
1979
1974
  "Chain ID": {
1980
1975
  number: number;
1981
1976
  };
1977
+ Verified: {
1978
+ checkbox: boolean;
1979
+ };
1980
+ "CoinGecko API ID": {
1981
+ rich_text: {
1982
+ plain_text: string;
1983
+ }[];
1984
+ };
1982
1985
  };
1983
1986
  };
1984
1987
  };
@@ -1988,7 +1991,20 @@ declare const app: Elysia<"", false, {
1988
1991
  authorization: string;
1989
1992
  };
1990
1993
  response: {
1991
- 200: void;
1994
+ 200: {
1995
+ symbol: string;
1996
+ id: string;
1997
+ name: string | null;
1998
+ icon: string;
1999
+ chainId: number;
2000
+ address: string;
2001
+ decimals: number;
2002
+ displaySymbol: string;
2003
+ verified: boolean;
2004
+ isTest: boolean;
2005
+ isNative: boolean;
2006
+ price: number | null;
2007
+ };
1992
2008
  };
1993
2009
  };
1994
2010
  };
@@ -1829,11 +1829,6 @@ export declare const v4: Elysia<"/v4", false, {
1829
1829
  plain_text: string;
1830
1830
  }[];
1831
1831
  };
1832
- Name: {
1833
- rich_text: {
1834
- plain_text: string;
1835
- }[];
1836
- };
1837
1832
  Icon: {
1838
1833
  files: {
1839
1834
  file: {
@@ -1849,6 +1844,14 @@ export declare const v4: Elysia<"/v4", false, {
1849
1844
  "Chain ID": {
1850
1845
  number: number;
1851
1846
  };
1847
+ Verified: {
1848
+ checkbox: boolean;
1849
+ };
1850
+ "CoinGecko API ID": {
1851
+ rich_text: {
1852
+ plain_text: string;
1853
+ }[];
1854
+ };
1852
1855
  };
1853
1856
  };
1854
1857
  };
@@ -1858,7 +1861,20 @@ export declare const v4: Elysia<"/v4", false, {
1858
1861
  authorization: string;
1859
1862
  };
1860
1863
  response: {
1861
- 200: void;
1864
+ 200: {
1865
+ symbol: string;
1866
+ id: string;
1867
+ name: string | null;
1868
+ icon: string;
1869
+ chainId: number;
1870
+ address: string;
1871
+ decimals: number;
1872
+ displaySymbol: string;
1873
+ verified: boolean;
1874
+ isTest: boolean;
1875
+ isNative: boolean;
1876
+ price: number | null;
1877
+ };
1862
1878
  };
1863
1879
  };
1864
1880
  };
@@ -284,11 +284,6 @@ export declare const TokenController: Elysia<"/tokens", false, {
284
284
  plain_text: string;
285
285
  }[];
286
286
  };
287
- Name: {
288
- rich_text: {
289
- plain_text: string;
290
- }[];
291
- };
292
287
  Icon: {
293
288
  files: {
294
289
  file: {
@@ -304,6 +299,14 @@ export declare const TokenController: Elysia<"/tokens", false, {
304
299
  "Chain ID": {
305
300
  number: number;
306
301
  };
302
+ Verified: {
303
+ checkbox: boolean;
304
+ };
305
+ "CoinGecko API ID": {
306
+ rich_text: {
307
+ plain_text: string;
308
+ }[];
309
+ };
307
310
  };
308
311
  };
309
312
  };
@@ -313,7 +316,20 @@ export declare const TokenController: Elysia<"/tokens", false, {
313
316
  authorization: string;
314
317
  };
315
318
  response: {
316
- 200: void;
319
+ 200: {
320
+ symbol: string;
321
+ id: string;
322
+ name: string | null;
323
+ icon: string;
324
+ chainId: number;
325
+ address: string;
326
+ decimals: number;
327
+ displaySymbol: string;
328
+ verified: boolean;
329
+ isTest: boolean;
330
+ isNative: boolean;
331
+ price: number | null;
332
+ };
317
333
  };
318
334
  };
319
335
  };
@@ -93,7 +93,10 @@ export declare const NotionWebhookDto: import("@sinclair/typebox").TObject<{
93
93
  plain_text: import("@sinclair/typebox").TString;
94
94
  }>>;
95
95
  }>;
96
- Name: import("@sinclair/typebox").TObject<{
96
+ Verified: import("@sinclair/typebox").TObject<{
97
+ checkbox: import("@sinclair/typebox").TBoolean;
98
+ }>;
99
+ "CoinGecko API ID": import("@sinclair/typebox").TObject<{
97
100
  rich_text: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
98
101
  plain_text: import("@sinclair/typebox").TString;
99
102
  }>>;
@@ -65,7 +65,8 @@ export const NotionWebhookDto = t.Object({
65
65
  Address: t.Object({ rich_text: t.Array(t.Object({ plain_text: t.String() })) }),
66
66
  "Chain ID": t.Object({ number: t.Numeric() }),
67
67
  Symbol: t.Object({ rich_text: t.Array(t.Object({ plain_text: t.String() })) }),
68
- Name: t.Object({ rich_text: t.Array(t.Object({ plain_text: t.String() })) }),
68
+ Verified: t.Object({ checkbox: t.Boolean() }),
69
+ "CoinGecko API ID": t.Object({ rich_text: t.Array(t.Object({ plain_text: t.String() })) }),
69
70
  }),
70
71
  }),
71
72
  }, { additionalProperties: true });
@@ -240,5 +240,18 @@ export declare abstract class TokenService {
240
240
  isNative: boolean;
241
241
  price: number | null;
242
242
  }>;
243
- static notionWebhook(body: NotionWebhookModel): Promise<void>;
243
+ static notionWebhook(body: NotionWebhookModel): Promise<{
244
+ symbol: string;
245
+ id: string;
246
+ name: string | null;
247
+ icon: string;
248
+ chainId: number;
249
+ address: string;
250
+ decimals: number;
251
+ displaySymbol: string;
252
+ verified: boolean;
253
+ isTest: boolean;
254
+ isNative: boolean;
255
+ price: number | null;
256
+ }>;
244
257
  }
@@ -1,3 +1,4 @@
1
+ import { HttpError } from "@/errors";
1
2
  import { getTokensListWithCache } from "@/libs/getTokensList";
2
3
  import { getOnlyUserBalance } from "@/libs/tokens/balances";
3
4
  import { log } from "@/utils/logger";
@@ -8,6 +9,7 @@ import { getAddress, parseUnits } from "viem";
8
9
  import { BucketService } from "../bucket/bucket.service";
9
10
  import { CacheService } from "../cache";
10
11
  import { TTLPresets } from "../cache/cache.model";
12
+ import { PriceService } from "../price";
11
13
  import { TokenRepository } from "./token.repository";
12
14
  export class TokenService {
13
15
  static hashId(token) {
@@ -295,9 +297,10 @@ export class TokenService {
295
297
  }
296
298
  catch (err) {
297
299
  if (err instanceof Prisma.PrismaClientKnownRequestError && err.code === "P2025") {
298
- const newToken = Object.assign(await TokenService.fetchOnChain(token), { id: id });
299
- if (!newToken)
300
- return;
300
+ const newToken = Object.assign(await TokenService.fetchOnChain(token), { id });
301
+ if (!newToken) {
302
+ throw new HttpError(`Failed to fetch on-chain data for token ${token.address} on chain ${token.chainId}).`);
303
+ }
301
304
  return await TokenRepository.upsert(newToken);
302
305
  }
303
306
  }
@@ -334,7 +337,8 @@ export class TokenService {
334
337
  const address = properties["Address"].rich_text[0].plain_text;
335
338
  const chainId = properties["Chain ID"].number;
336
339
  const symbol = properties["Symbol"].rich_text[0]?.plain_text;
337
- const name = properties["Name"].rich_text[0]?.plain_text;
340
+ const isVerified = properties["Verified"].checkbox;
341
+ const coingeckoApiId = properties["CoinGecko API ID"].rich_text[0].plain_text;
338
342
  const byteArray = await iconFile.bytes();
339
343
  const [token] = await TokenService.getManyOrCreate([
340
344
  {
@@ -342,16 +346,33 @@ export class TokenService {
342
346
  address,
343
347
  },
344
348
  ]);
345
- if (token) {
346
- await TokenService.update(token.id, {
347
- icon: icon && icon !== "" ? icon : token.icon,
348
- displaySymbol: symbol && symbol !== "" ? symbol : token.symbol,
349
- name: name && name !== "" ? name : token.name ? token.name : "Unknown",
350
- });
349
+ if (!token || !token.name)
350
+ throw new HttpError(`Failed to fetch on-chain data for token ${symbol} (${address} on chainId ${chainId}).`);
351
+ try {
351
352
  await bucket.pushRaw(`${chainId}/${address}.${extension}`, byteArray, {
352
353
  type: mimeType,
353
354
  isPublic: true,
354
355
  });
356
+ token.icon = `${process.env.GCS_ENDPOINT}/merkl-${env}-tokens/${chainId}/${address}.${extension}`;
357
+ }
358
+ catch (err) {
359
+ console.error(err);
360
+ token.icon = icon;
361
+ }
362
+ if (coingeckoApiId) {
363
+ try {
364
+ await PriceService.createPriceSource({ method: "COINGECKO", symbol, args: { ticker: coingeckoApiId } });
365
+ }
366
+ catch (err) {
367
+ console.error("Failed to create price source.");
368
+ console.error(err);
369
+ }
355
370
  }
371
+ return await TokenService.update(token.id, {
372
+ icon: token.icon,
373
+ displaySymbol: symbol && symbol !== "" ? symbol : token.symbol,
374
+ name: token.name,
375
+ verified: isVerified,
376
+ });
356
377
  }
357
378
  }
@@ -20,7 +20,14 @@ export default (app) => app.get("/app", async () => {
20
20
  json.tokens[token.chainId] = {};
21
21
  }
22
22
  if (!json.tokens[token.chainId][token.address]) {
23
- json.tokens[token.chainId][token.address] = token;
23
+ json.tokens[token.chainId][token.address] = {
24
+ address: token.address,
25
+ chainId: token.chainId,
26
+ decimals: token.decimals,
27
+ name: token.name,
28
+ symbol: token.symbol,
29
+ logoURI: token.icon,
30
+ };
24
31
  }
25
32
  }
26
33
  return json;
@@ -1,35 +1,9 @@
1
1
  import type { BytesLike } from "ethers";
2
- export type CampaignFrontend = {
3
- chainId: number;
4
- index: number;
5
- creator: string;
6
- campaignId: string;
7
- campaignType: string;
8
- campaignSubType: string;
9
- rewardToken: string;
10
- amount: string;
11
- amountDecimal: number;
12
- startTimestamp: number;
13
- endTimestamp: number;
14
- lastProcessedTimestamp: number;
15
- mainParameter: string;
16
- merklApr: string;
17
- otherAprs: string[];
18
- };
19
- export declare enum Campaign {
20
- INVALID = 0,
21
- ERC20 = 1,
22
- CLAMM = 2
23
- }
24
2
  export type MultiCallDataType = {
25
3
  target: string;
26
4
  callData: BytesLike;
27
5
  allowFailure?: boolean;
28
6
  }[];
29
- export type leafCacheType = {
30
- type: "Buffer";
31
- data: number[];
32
- };
33
7
  export type MerklChainData = {
34
8
  merkleRoot: string;
35
9
  treeRoot: string;
@@ -1,6 +1 @@
1
- export var Campaign;
2
- (function (Campaign) {
3
- Campaign[Campaign["INVALID"] = 0] = "INVALID";
4
- Campaign[Campaign["ERC20"] = 1] = "ERC20";
5
- Campaign[Campaign["CLAMM"] = 2] = "CLAMM";
6
- })(Campaign || (Campaign = {}));
1
+ export {};