@merkl/api 0.20.101 → 0.20.103

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 (129) hide show
  1. package/dist/src/eden/index.d.ts +54 -36
  2. package/dist/src/engine/campaignTVL/factory.d.ts +1 -1
  3. package/dist/src/engine/campaignTVL/factory.js +9 -3
  4. package/dist/src/engine/{erc20SubTypeProcessors/helpers/tokenType.d.ts → campaignTVL/implementations/Erc20/Erc20SubType.d.ts} +7 -13
  5. package/dist/src/engine/campaignTVL/implementations/Erc20/Erc20SubType.js +106 -0
  6. package/dist/src/engine/campaignTVL/implementations/Erc20/computeSubTypes.d.ts +8 -0
  7. package/dist/src/engine/campaignTVL/implementations/Erc20/computeSubTypes.js +128 -0
  8. package/dist/src/engine/campaignTVL/implementations/Erc20/factory.d.ts +3 -0
  9. package/dist/src/engine/campaignTVL/implementations/Erc20/factory.js +13 -0
  10. package/dist/src/engine/campaignTVL/implementations/Erc20/index.d.ts +6 -0
  11. package/dist/src/engine/campaignTVL/implementations/Erc20/index.js +27 -0
  12. package/dist/src/engine/dynamicData/implementations/Erc20.d.ts +4 -4
  13. package/dist/src/engine/dynamicData/implementations/Erc20.js +5 -11
  14. package/dist/src/engine/dynamicData/implementations/Radiant.js +2 -2
  15. package/dist/src/engine/erc20SubTypeProcessors/GenericProcessor.d.ts +19 -19
  16. package/dist/src/engine/erc20SubTypeProcessors/GenericProcessor.js +1 -1
  17. package/dist/src/engine/erc20SubTypeProcessors/helpers/factoryFinder.d.ts +2 -2
  18. package/dist/src/engine/erc20SubTypeProcessors/helpers/factoryFinder.js +31 -31
  19. package/dist/src/engine/erc20SubTypeProcessors/helpers/hardcoded.d.ts +2 -2
  20. package/dist/src/engine/erc20SubTypeProcessors/helpers/hardcoded.js +17 -17
  21. package/dist/src/engine/erc20SubTypeProcessors/helpers/ownerFinder.d.ts +2 -2
  22. package/dist/src/engine/erc20SubTypeProcessors/helpers/ownerFinder.js +6 -6
  23. package/dist/src/engine/erc20SubTypeProcessors/implementations/AaveProcessor.d.ts +2 -2
  24. package/dist/src/engine/erc20SubTypeProcessors/implementations/AnglesLiquid.d.ts +7 -7
  25. package/dist/src/engine/erc20SubTypeProcessors/implementations/AssetProcessor.d.ts +2 -2
  26. package/dist/src/engine/erc20SubTypeProcessors/implementations/AssetProcessor.js +2 -2
  27. package/dist/src/engine/erc20SubTypeProcessors/implementations/AuraProcessor.d.ts +40 -3
  28. package/dist/src/engine/erc20SubTypeProcessors/implementations/BEXRewardGaugeProcessor.d.ts +32 -3
  29. package/dist/src/engine/erc20SubTypeProcessors/implementations/BEXRewardGaugeProcessor.js +2 -2
  30. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerGaugeProcessor.d.ts +29 -3
  31. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerPoolProcessor.d.ts +31 -3
  32. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerV3PoolProcessor.d.ts +3 -3
  33. package/dist/src/engine/erc20SubTypeProcessors/implementations/BeefyProcessor.d.ts +2 -2
  34. package/dist/src/engine/erc20SubTypeProcessors/implementations/BunniV2Processor.d.ts +2 -2
  35. package/dist/src/engine/erc20SubTypeProcessors/implementations/CompoundProcessor.d.ts +2 -2
  36. package/dist/src/engine/erc20SubTypeProcessors/implementations/ERC4626Processor.d.ts +2 -2
  37. package/dist/src/engine/erc20SubTypeProcessors/implementations/EnzymeProcessor.d.ts +3 -3
  38. package/dist/src/engine/erc20SubTypeProcessors/implementations/EqualizerGaugeProcessor.d.ts +2 -2
  39. package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerBorrowProcessor.d.ts +2 -2
  40. package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerLendProcessor.d.ts +2 -2
  41. package/dist/src/engine/erc20SubTypeProcessors/implementations/FluidProcessor.d.ts +2 -2
  42. package/dist/src/engine/erc20SubTypeProcessors/implementations/FraxProcessor.d.ts +2 -2
  43. package/dist/src/engine/erc20SubTypeProcessors/implementations/FraxProcessor.js +2 -2
  44. package/dist/src/engine/erc20SubTypeProcessors/implementations/GammaALMProcessor.d.ts +2 -2
  45. package/dist/src/engine/erc20SubTypeProcessors/implementations/GammaProcessor.d.ts +7 -7
  46. package/dist/src/engine/erc20SubTypeProcessors/implementations/GearboxProcessor.d.ts +2 -2
  47. package/dist/src/engine/erc20SubTypeProcessors/implementations/HanjiVaultProcessor.d.ts +4 -4
  48. package/dist/src/engine/erc20SubTypeProcessors/implementations/HoldStationProcessor.d.ts +2 -2
  49. package/dist/src/engine/erc20SubTypeProcessors/implementations/HourglassProcessor.d.ts +2 -2
  50. package/dist/src/engine/erc20SubTypeProcessors/implementations/MaverickBPProcessor.d.ts +2 -2
  51. package/dist/src/engine/erc20SubTypeProcessors/implementations/MetamorphoProcessor.d.ts +3 -3
  52. package/dist/src/engine/erc20SubTypeProcessors/implementations/NoLinkVaultProcessor.d.ts +7 -7
  53. package/dist/src/engine/erc20SubTypeProcessors/implementations/NoLinkVaultProcessor.js +2 -2
  54. package/dist/src/engine/erc20SubTypeProcessors/implementations/PendleProcessor.d.ts +2 -2
  55. package/dist/src/engine/erc20SubTypeProcessors/implementations/PendleYTProcessor.d.ts +2 -2
  56. package/dist/src/engine/erc20SubTypeProcessors/implementations/RadiantProcessor.d.ts +3 -3
  57. package/dist/src/engine/erc20SubTypeProcessors/implementations/RfxProcessor.d.ts +2 -2
  58. package/dist/src/engine/erc20SubTypeProcessors/implementations/Satlayer.d.ts +2 -2
  59. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpectraProcessor.d.ts +2 -2
  60. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpectraYTProcessor.d.ts +2 -2
  61. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpliceProcessor.d.ts +3 -3
  62. package/dist/src/engine/erc20SubTypeProcessors/implementations/SturdySiloProcessor.d.ts +2 -2
  63. package/dist/src/engine/erc20SubTypeProcessors/implementations/TempestVaultProcessor.d.ts +3 -3
  64. package/dist/src/engine/erc20SubTypeProcessors/implementations/TempestVaultProcessor.js +2 -2
  65. package/dist/src/engine/erc20SubTypeProcessors/implementations/TemplateProcessor.d.ts +7 -7
  66. package/dist/src/engine/erc20SubTypeProcessors/implementations/TorosProcessor.d.ts +2 -2
  67. package/dist/src/engine/erc20SubTypeProcessors/implementations/UniswapProcessor.d.ts +3 -3
  68. package/dist/src/engine/erc20SubTypeProcessors/implementations/VicunaProcessor.d.ts +2 -2
  69. package/dist/src/engine/erc20SubTypeProcessors/implementations/WoofiProcessor.d.ts +2 -2
  70. package/dist/src/engine/erc20SubTypeProcessors/implementations/ZkSwapThreePoolProcessor.d.ts +2 -2
  71. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveNPoolProcessor.d.ts +4 -4
  72. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveProcessor.d.ts +2 -2
  73. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveProcessor.js +2 -2
  74. package/dist/src/engine/erc20SubTypeProcessors/implementations/processorMapping.d.ts +2 -2
  75. package/dist/src/engine/erc20SubTypeProcessors/implementations/processorMapping.js +100 -100
  76. package/dist/src/engine/erc20SubTypeProcessors/implementations/stakedCurveProcessor.d.ts +2 -2
  77. package/dist/src/engine/erc20SubTypeProcessors/implementations/stakedCurveProcessor.js +2 -2
  78. package/dist/src/engine/erc20SubTypeProcessors/implementations/xU308Processor.d.ts +2 -2
  79. package/dist/src/engine/erc20SubTypeProcessors/subtypesPrices.d.ts +3 -2
  80. package/dist/src/engine/erc20SubTypeProcessors/subtypesPrices.js +2 -2
  81. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound1.d.ts +2 -1
  82. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound1.js +87 -87
  83. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound2.d.ts +2 -3
  84. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound3.d.ts +2 -2
  85. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound4.d.ts +2 -2
  86. package/dist/src/engine/erc20SubTypeProcessors/tokenTypeStruct.d.ts +7 -0
  87. package/dist/src/engine/erc20SubTypeProcessors/tokenTypeStruct.js +1 -0
  88. package/dist/src/engine/erc20SubTypeProcessors/tokenTypeToProtocolAndAction.d.ts +7 -0
  89. package/dist/src/engine/erc20SubTypeProcessors/tokenTypeToProtocolAndAction.js +130 -0
  90. package/dist/src/engine/opportunityMetadata/factory.js +4 -2
  91. package/dist/src/engine/opportunityMetadata/implementations/ERCMultiToken.d.ts +14 -2
  92. package/dist/src/engine/opportunityMetadata/implementations/ERCMultiToken.js +52 -2
  93. package/dist/src/engine/opportunityMetadata/implementations/{Erc20.d.ts → Erc20/index.d.ts} +1 -1
  94. package/dist/src/engine/opportunityMetadata/implementations/{Erc20.js → Erc20/index.js} +1 -1
  95. package/dist/src/engine/opportunityMetadata/implementations/JsonAirdrop.d.ts +2 -2
  96. package/dist/src/index.d.ts +18 -12
  97. package/dist/src/modules/v4/campaign/campaign.service.d.ts +6 -0
  98. package/dist/src/modules/v4/campaign/campaign.service.js +9 -0
  99. package/dist/src/modules/v4/campaign/campaign.test.controller.d.ts +2 -2
  100. package/dist/src/modules/v4/campaign/campaign.test.controller.js +1 -1
  101. package/dist/src/modules/v4/computedValue/computedValue.controller.js +2 -1
  102. package/dist/src/modules/v4/computedValue/computedValue.service.d.ts +1 -1
  103. package/dist/src/modules/v4/computedValue/computedValue.service.js +5 -10
  104. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +2 -2
  105. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +7 -7
  106. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +3 -3
  107. package/dist/src/modules/v4/programPayload/programPayload.controller.d.ts +1 -1
  108. package/dist/src/modules/v4/protocol/protocol.controller.d.ts +2 -2
  109. package/dist/src/modules/v4/protocol/protocol.model.d.ts +1 -1
  110. package/dist/src/modules/v4/protocol/protocol.model.js +1 -0
  111. package/dist/src/modules/v4/router.d.ts +18 -12
  112. package/dist/src/modules/v4/token/token.controller.d.ts +6 -0
  113. package/dist/src/modules/v4/token/token.controller.js +1 -1
  114. package/dist/src/modules/v4/token/token.model.d.ts +3 -0
  115. package/dist/src/modules/v4/token/token.model.js +3 -0
  116. package/dist/src/modules/v4/token/token.repository.js +47 -25
  117. package/dist/src/modules/v4/token/token.service.d.ts +27 -6
  118. package/dist/src/modules/v4/token/token.service.js +29 -79
  119. package/dist/src/utils/decodeCalls.d.ts +3 -3
  120. package/dist/src/utils/decodeCalls.js +80 -80
  121. package/dist/src/utils/encodeCalls.d.ts +2 -2
  122. package/dist/src/utils/encodeCalls.js +77 -77
  123. package/dist/src/utils/generateCardName.d.ts +2 -2
  124. package/dist/src/utils/generateCardName.js +97 -97
  125. package/dist/tsconfig.package.tsbuildinfo +1 -1
  126. package/package.json +1 -1
  127. package/dist/src/engine/erc20SubTypeProcessors/helpers/tokenType.js +0 -232
  128. package/dist/src/modules/v4/computedValue/index.d.ts +0 -2
  129. package/dist/src/modules/v4/computedValue/index.js +0 -2
@@ -4,33 +4,55 @@ import axios from "axios";
4
4
  export class TokenRepository {
5
5
  static #transformQueryToPrismaFilters(query) {
6
6
  const ids = query.id ? query.id.map(id => ({ id })) : [];
7
+ const { page: _page, items: _items } = query;
8
+ const page = _page ? _page : 0;
9
+ const items = _items !== undefined ? _items : 100;
7
10
  return {
11
+ take: items === 0 ? undefined : items,
12
+ skip: page * items,
8
13
  where: {
9
- OR: query.symbol
10
- ? [
11
- { symbol: { equals: query.symbol, mode: "insensitive" } },
12
- { displaySymbol: { equals: query.symbol, mode: "insensitive" } },
13
- ...ids,
14
- ]
15
- : query.displaySymbol
16
- ? [
17
- {
18
- displaySymbol: "",
19
- symbol: { equals: query.displaySymbol, mode: "insensitive" },
20
- },
21
- { displaySymbol: { equals: query.displaySymbol, mode: "insensitive" } },
22
- ...ids,
23
- ]
24
- : ids.length
25
- ? [...ids]
26
- : undefined,
27
- address: query.address ? { equals: query.address, mode: "insensitive" } : undefined,
28
- chainId: query.chainId ? { equals: query.chainId } : undefined,
29
- name: query.name ? { contains: query.name, mode: "insensitive" } : undefined,
30
- verified: query.verified ? { equals: query.verified } : undefined,
31
- isTest: query.test ? { equals: query.test } : undefined,
32
- icon: query.missingIcons ? { equals: "" } : undefined,
33
- price: query.missingPrice ? { equals: null } : undefined,
14
+ AND: [
15
+ {
16
+ OR: query.symbol
17
+ ? [
18
+ { symbol: { equals: query.symbol, mode: "insensitive" } },
19
+ { displaySymbol: { equals: query.symbol, mode: "insensitive" } },
20
+ ...ids,
21
+ ]
22
+ : query.displaySymbol
23
+ ? [
24
+ {
25
+ displaySymbol: "",
26
+ symbol: { equals: query.displaySymbol, mode: "insensitive" },
27
+ },
28
+ { displaySymbol: { equals: query.displaySymbol, mode: "insensitive" } },
29
+ ...ids,
30
+ ]
31
+ : ids.length
32
+ ? [...ids]
33
+ : undefined,
34
+ address: query.address ? { equals: query.address, mode: "insensitive" } : undefined,
35
+ chainId: query.chainId ? { equals: query.chainId } : undefined,
36
+ name: query.name ? { contains: query.name, mode: "insensitive" } : undefined,
37
+ verified: query.verified ? { equals: query.verified } : undefined,
38
+ isTest: query.test ? { equals: query.test } : undefined,
39
+ icon: query.missingIcons ? { equals: "" } : undefined,
40
+ price: query.missingPrice ? { equals: null } : undefined,
41
+ },
42
+ !query.search
43
+ ? {}
44
+ : {
45
+ AND: query.search?.split(" ")?.map((keyword) => ({
46
+ OR: [
47
+ { id: { contains: keyword, mode: "insensitive" } },
48
+ { name: { contains: keyword, mode: "insensitive" } },
49
+ { symbol: { contains: keyword, mode: "insensitive" } },
50
+ { address: { contains: keyword, mode: "insensitive" } },
51
+ { Chain: { name: { contains: keyword, mode: "insensitive" } } },
52
+ ],
53
+ })),
54
+ },
55
+ ],
34
56
  },
35
57
  };
36
58
  }
@@ -114,6 +114,13 @@ export declare abstract class TokenService {
114
114
  } & {
115
115
  price?: number | null | undefined;
116
116
  }>;
117
+ /**
118
+ * Checks if two tokens are the same based on chainId/address combo
119
+ * @param a token
120
+ * @param b token
121
+ * @returns true if both tokens are the same
122
+ */
123
+ static isSame(a: Pick<Token["model"], "chainId" | "address">, b: Pick<Token["model"], "chainId" | "address">): Promise<boolean>;
117
124
  /**
118
125
  * Get the list of tokens satisfying the query
119
126
  * @param query
@@ -134,6 +141,26 @@ export declare abstract class TokenService {
134
141
  } & {
135
142
  price?: number | null | undefined;
136
143
  })[]>;
144
+ /**
145
+ * Get the list of tokens satisfying the query or fetch if chainId and address are provided
146
+ * @param query
147
+ * @returns A list of tokens
148
+ */
149
+ static findManyOrFetch(query: GetTokenQueryModel): Promise<({
150
+ symbol: string;
151
+ id: string;
152
+ name: string | null;
153
+ icon: string;
154
+ address: string;
155
+ chainId: number;
156
+ decimals: number;
157
+ verified: boolean;
158
+ isTest: boolean;
159
+ isPoint: boolean;
160
+ isNative: boolean;
161
+ } & {
162
+ price?: number | null | undefined;
163
+ })[]>;
137
164
  static getPrice(query: GetTokenQueryModel): Promise<number>;
138
165
  static findManyObjectPerAddress(query: GetTokenQueryModel): Promise<Record<string, {
139
166
  symbol: string;
@@ -256,10 +283,4 @@ export declare abstract class TokenService {
256
283
  isNative: boolean;
257
284
  price: number | null;
258
285
  }>;
259
- /**
260
- * @deprecated Should be useless now that the token list is not used anymore
261
- * Get all tokens from https://github.com/AngleProtocol/angle-token-list and override icons from it
262
- * TODO: use the bucket
263
- */
264
- static fillTokenAndIconsFromTokenList(): Promise<void>;
265
286
  }
@@ -1,18 +1,16 @@
1
1
  import { HttpError } from "@/errors";
2
- import { getTokensListWithCache } from "@/libs/getTokensList";
3
2
  import { getOnlyUserBalance } from "@/libs/tokens/balances";
4
3
  import { BucketService } from "@/modules/v4/bucket/bucket.service";
4
+ import { CacheService } from "@/modules/v4/cache";
5
+ import { TTLPresets } from "@/modules/v4/cache/cache.model";
6
+ import { CoingeckoService } from "@/modules/v4/coingecko/coingecko.service";
5
7
  import { IconService } from "@/modules/v4/icon/icon.service";
6
8
  import { PriceService } from "@/modules/v4/price/price.service";
7
9
  import { log } from "@/utils/logger";
8
10
  import { throwOnInvalidRequiredAddress, throwOnUnsupportedChainId } from "@/utils/throw";
9
- import { apiDbClient } from "@db";
10
11
  import { Prisma } from "@db/api";
11
12
  import { ChainInteractionService, DistributionCreatorService, NETWORK_LABELS, NULL_ADDRESS, bigIntToNumber, } from "@sdk";
12
- import { getAddress, parseUnits } from "viem";
13
- import { CacheService } from "../cache";
14
- import { TTLPresets } from "../cache/cache.model";
15
- import { CoingeckoService } from "../coingecko/coingecko.service";
13
+ import { getAddress, isAddress, parseUnits } from "viem";
16
14
  import { TokenRepository } from "./token.repository";
17
15
  export class TokenService {
18
16
  static hashId(token) {
@@ -165,6 +163,15 @@ export class TokenService {
165
163
  const id = typeof token === "string" ? token : TokenService.hashId(token);
166
164
  return await TokenRepository.findUniqueOrThrow(id);
167
165
  }
166
+ /**
167
+ * Checks if two tokens are the same based on chainId/address combo
168
+ * @param a token
169
+ * @param b token
170
+ * @returns true if both tokens are the same
171
+ */
172
+ static async isSame(a, b) {
173
+ return a.chainId === b.chainId && a.address?.toLowerCase() === b.address?.toLowerCase();
174
+ }
168
175
  /**
169
176
  * Get the list of tokens satisfying the query
170
177
  * @param query
@@ -173,6 +180,22 @@ export class TokenService {
173
180
  static async findMany(query) {
174
181
  return (await TokenRepository.findMany(query)).map(TokenService.format);
175
182
  }
183
+ /**
184
+ * Get the list of tokens satisfying the query or fetch if chainId and address are provided
185
+ * @param query
186
+ * @returns A list of tokens
187
+ */
188
+ static async findManyOrFetch(query) {
189
+ const foundTokens = (await TokenRepository.findMany(query)).map(TokenService.format);
190
+ const isTokenAddress = query.chainId && query.search && isAddress(query.search);
191
+ if (isTokenAddress &&
192
+ !foundTokens.some(t => TokenService.isSame(t, { chainId: query.chainId, address: query.search }))) {
193
+ const token = await TokenService.fetchOnChain({ chainId: query.chainId, address: query.search });
194
+ //Assigning a temporary id since token is not in the database
195
+ token && foundTokens.push({ ...token, id: `tmp-${token.chainId}-${token.address}` });
196
+ }
197
+ return foundTokens;
198
+ }
176
199
  static async getPrice(query) {
177
200
  const tokensFound = (await TokenRepository.findMany(query)).map(TokenService.format);
178
201
  if (tokensFound.length === 0) {
@@ -343,77 +366,4 @@ export class TokenService {
343
366
  }
344
367
  return await TokenRepository.upsert({ ...filledData, ...token, id });
345
368
  }
346
- /**
347
- * @deprecated Should be useless now that the token list is not used anymore
348
- * Get all tokens from https://github.com/AngleProtocol/angle-token-list and override icons from it
349
- * TODO: use the bucket
350
- */
351
- static async fillTokenAndIconsFromTokenList() {
352
- const tokenList = await getTokensListWithCache();
353
- for (const chain of Object.keys(tokenList)) {
354
- for (const [symbol, token] of Object.entries(tokenList[chain])) {
355
- if (!(await TokenRepository.findUnique(TokenService.hashId({ chainId: Number.parseInt(chain), address: token.address })))) {
356
- try {
357
- const res = await TokenRepository.create({
358
- id: TokenService.hashId({ chainId: Number.parseInt(chain), address: token.address }),
359
- chainId: Number.parseInt(chain),
360
- address: token.address,
361
- name: token.name,
362
- symbol: token.symbol,
363
- verified: true,
364
- decimals: token.decimals,
365
- icon: token.logoURI,
366
- isTest: false,
367
- isPoint: false,
368
- isNative: false,
369
- });
370
- log.local(`Token created: ${res?.symbol} on ${NETWORK_LABELS[Number.parseInt(chain)]}`);
371
- }
372
- catch (e) {
373
- console.error(e);
374
- }
375
- }
376
- try {
377
- await apiDbClient.token.update({
378
- data: {
379
- chainId: Number.parseInt(chain),
380
- address: token.address,
381
- name: token.name,
382
- symbol: token.symbol,
383
- verified: true,
384
- decimals: token.decimals,
385
- icon: token.logoURI,
386
- },
387
- where: {
388
- chainId_address: {
389
- chainId: Number.parseInt(chain),
390
- address: token.address,
391
- },
392
- },
393
- });
394
- }
395
- catch (e) {
396
- console.error(e);
397
- }
398
- try {
399
- const tokensWithSameSymbol = await apiDbClient.token.findMany({
400
- select: { chainId: true, address: true },
401
- where: { symbol: { equals: symbol, mode: "insensitive" } },
402
- });
403
- for (const dbToken of tokensWithSameSymbol) {
404
- await apiDbClient.token.update({
405
- data: { icon: token.logoURI },
406
- where: {
407
- chainId_address: {
408
- chainId: dbToken.chainId,
409
- address: dbToken.address,
410
- },
411
- },
412
- });
413
- }
414
- }
415
- catch (_err) { }
416
- }
417
- }
418
- }
419
369
  }
@@ -1,3 +1,3 @@
1
- import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
2
- export declare function decodeCall(calls: string[], index: number, key: string, type?: tokenType): any;
3
- export declare function decodeReturnValue(returnData: string, key: string, type?: tokenType): any;
1
+ import { Erc20SubType } from "@/engine/campaignTVL/implementations/Erc20/Erc20SubType";
2
+ export declare function decodeCall(calls: string[], index: number, key: string, type?: Erc20SubType): any;
3
+ export declare function decodeReturnValue(returnData: string, key: string, type?: Erc20SubType): any;
@@ -1,4 +1,4 @@
1
- import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
1
+ import { Erc20SubType } from "@/engine/campaignTVL/implementations/Erc20/Erc20SubType";
2
2
  import { AaveInterface, AccountantWithRateProvidersInterface, AuraInterface, AuraOperatorInterface, BalancerGaugeInterface, BalancerPoolInterface, BalancerV3StablePoolInterface, BalancerVaultInterface, BeefyInterface, BunniV2HubInterface, BunniV2TokenInterface, CPMMGammaPoolMainInterface, CompoundInterface, CurveInterface, CurveLPTokenInterface, CurveStableSwapNGInterface, DefutureVaultInterface, ERC20Interface, ERC4626Interface, EnzymeInterface, EulerInterface, FactoryInterface, FluidInterface, FraxlendInterface, GearboxVaultInterface, HourglassERC20TBTInterface, HourglassVedaLockDepositorV2Interface, IonicInterface, LPManagerHelperInterface, LPManagerInterface, LayerBankERC20Interface, LayerBankInterface, LendleInterface, MaverickBPLensInterface, MetamorphoInterface, MoonwellInterface, OneInchStakingInterface, PendleInterface, PendleYTInterface, RadiantInterface, RfxInterface, RswEthStrategyInterface, SpectraYTInterface, SturdyInterface, SymetricAmbientStrategyInterface, SyncSwapClassicPoolInterface, TorosInterface, UniswapV2PoolInterface, UniswapV3PoolInterface, VePufferInterface, ZFStableLPINterface, ZFStableSwapThreePoolInterface, } from "@sdk";
3
3
  import { BigNumber } from "ethers";
4
4
  export function decodeCall(calls, index, key, type) {
@@ -25,8 +25,8 @@ export function decodeReturnValue(returnData, key, type) {
25
25
  return ERC20Interface.decodeFunctionResult("decimals", returnData)[0];
26
26
  case "totalSupply":
27
27
  switch (type) {
28
- case tokenType.lendle_lending:
29
- case tokenType.lendle_borrowing:
28
+ case Erc20SubType.lendle_lending:
29
+ case Erc20SubType.lendle_borrowing:
30
30
  return LendleInterface.decodeFunctionResult("scaledTotalSupply", returnData)[0];
31
31
  default:
32
32
  return ERC20Interface.decodeFunctionResult("totalSupply", returnData)[0];
@@ -51,8 +51,8 @@ export function decodeReturnValue(returnData, key, type) {
51
51
  return UniswapV2PoolInterface.decodeFunctionResult("token1", returnData)[0];
52
52
  case "lp_token":
53
53
  switch (type) {
54
- case tokenType.beraborrow_gauge:
55
- case tokenType.beratrax_vault:
54
+ case Erc20SubType.beraborrow_gauge:
55
+ case Erc20SubType.beratrax_vault:
56
56
  return ERC4626Interface.decodeFunctionResult("asset", returnData)[0];
57
57
  default:
58
58
  return BalancerGaugeInterface.decodeFunctionResult("lp_token", returnData)[0];
@@ -73,94 +73,94 @@ export function decodeReturnValue(returnData, key, type) {
73
73
  return RfxInterface.decodeFunctionResult("longToken", returnData)[0];
74
74
  case "underlying":
75
75
  switch (type) {
76
- case tokenType.pendle:
77
- case tokenType.pendleYT:
76
+ case Erc20SubType.pendle:
77
+ case Erc20SubType.pendleYT:
78
78
  return PendleInterface.decodeFunctionResult("yieldToken", returnData)[0];
79
- case tokenType.gearbox:
79
+ case Erc20SubType.gearbox:
80
80
  return GearboxVaultInterface.decodeFunctionResult("underlyingToken", returnData)[0];
81
- case tokenType.enzyme:
81
+ case Erc20SubType.enzyme:
82
82
  return EnzymeInterface.decodeFunctionResult("calcNetShareValue", returnData)[0];
83
- case tokenType.aura:
83
+ case Erc20SubType.aura:
84
84
  return AuraInterface.decodeFunctionResult("asset", returnData)[0];
85
- case tokenType.fluid:
85
+ case Erc20SubType.fluid:
86
86
  return FluidInterface.decodeFunctionResult("asset", returnData)[0];
87
- case tokenType.metamorpho:
87
+ case Erc20SubType.metamorpho:
88
88
  return MetamorphoInterface.decodeFunctionResult("asset", returnData)[0];
89
- case tokenType.fraxlend:
90
- case tokenType.sturdy_aggregator:
91
- case tokenType.sturdy_silo:
89
+ case Erc20SubType.fraxlend:
90
+ case Erc20SubType.sturdy_aggregator:
91
+ case Erc20SubType.sturdy_silo:
92
92
  return FraxlendInterface.decodeFunctionResult("asset", returnData)[0];
93
- case tokenType.aave_lending:
94
- case tokenType.aave_borrowing:
95
- case tokenType.sake_lending:
96
- case tokenType.sake_borrowing:
97
- case tokenType.ironclad_lending:
98
- case tokenType.ironclad_borrowing:
99
- case tokenType.zerolend_lending:
100
- case tokenType.zerolend_borrowing:
101
- case tokenType.avalon_lending:
102
- case tokenType.avalon_borrowing:
103
- case tokenType.superlend_lending:
104
- case tokenType.superlend_borrowing:
105
- case tokenType.takotako_lending:
106
- case tokenType.takotako_borrowing:
107
- case tokenType.vicuna_borrowing:
108
- case tokenType.vicuna_lending:
109
- case tokenType.lendle_lending:
110
- case tokenType.lendle_borrowing:
111
- case tokenType.yei_borrowing:
112
- case tokenType.yei_lending:
113
- case tokenType.xlend_lending:
114
- case tokenType.xlend_borrowing:
93
+ case Erc20SubType.aave_lending:
94
+ case Erc20SubType.aave_borrowing:
95
+ case Erc20SubType.sake_lending:
96
+ case Erc20SubType.sake_borrowing:
97
+ case Erc20SubType.ironclad_lending:
98
+ case Erc20SubType.ironclad_borrowing:
99
+ case Erc20SubType.zerolend_lending:
100
+ case Erc20SubType.zerolend_borrowing:
101
+ case Erc20SubType.avalon_lending:
102
+ case Erc20SubType.avalon_borrowing:
103
+ case Erc20SubType.superlend_lending:
104
+ case Erc20SubType.superlend_borrowing:
105
+ case Erc20SubType.takotako_lending:
106
+ case Erc20SubType.takotako_borrowing:
107
+ case Erc20SubType.vicuna_borrowing:
108
+ case Erc20SubType.vicuna_lending:
109
+ case Erc20SubType.lendle_lending:
110
+ case Erc20SubType.lendle_borrowing:
111
+ case Erc20SubType.yei_borrowing:
112
+ case Erc20SubType.yei_lending:
113
+ case Erc20SubType.xlend_lending:
114
+ case Erc20SubType.xlend_borrowing:
115
115
  return AaveInterface.decodeFunctionResult("UNDERLYING_ASSET_ADDRESS", returnData)[0];
116
- case tokenType.radiant_borrow:
117
- case tokenType.radiant_lend:
116
+ case Erc20SubType.radiant_borrow:
117
+ case Erc20SubType.radiant_lend:
118
118
  return RadiantInterface.decodeFunctionResult("UNDERLYING_ASSET_ADDRESS", returnData)[0];
119
- case tokenType.moonwell:
119
+ case Erc20SubType.moonwell:
120
120
  return MoonwellInterface.decodeFunctionResult("underlying", returnData)[0];
121
- case tokenType.ionic:
122
- case tokenType.venus:
121
+ case Erc20SubType.ionic:
122
+ case Erc20SubType.venus:
123
123
  return IonicInterface.decodeFunctionResult("underlying", returnData)[0];
124
- case tokenType.reactor_fusion:
124
+ case Erc20SubType.reactor_fusion:
125
125
  try {
126
126
  return IonicInterface.decodeFunctionResult("underlying", returnData)[0];
127
127
  }
128
128
  catch (e) {
129
129
  return "0x000000000000000000000000000000000000800A";
130
130
  }
131
- case tokenType.layerbank:
131
+ case Erc20SubType.layerbank:
132
132
  return LayerBankInterface.decodeFunctionResult("underlying", returnData)[0];
133
- case tokenType.holdstation:
133
+ case Erc20SubType.holdstation:
134
134
  return DefutureVaultInterface.decodeFunctionResult("asset", returnData)[0];
135
- case tokenType.euler_borrow:
136
- case tokenType.euler_lend:
137
- case tokenType.maha:
135
+ case Erc20SubType.euler_borrow:
136
+ case Erc20SubType.euler_lend:
137
+ case Erc20SubType.maha:
138
138
  return EulerInterface.decodeFunctionResult("asset", returnData)[0];
139
- case tokenType.hourglass:
139
+ case Erc20SubType.hourglass:
140
140
  return HourglassVedaLockDepositorV2Interface.decodeFunctionResult("getUnderlying", returnData)[0];
141
- case tokenType.curve_gauge:
141
+ case Erc20SubType.curve_gauge:
142
142
  return BalancerGaugeInterface.decodeFunctionResult("lp_token", returnData)[0];
143
143
  default:
144
- throw new Error(`Need tokenType for this key ${key}, or type ${type} not matched`);
144
+ throw new Error(`Need Erc20SubType for this key ${key}, or type ${type} not matched`);
145
145
  }
146
146
  // case "exchangeRateCurrent":
147
147
  // return IonicInterface.decodeFunctionResult("exchangeRateCurrent", returnData)[0];
148
148
  case "exchangeRate":
149
149
  switch (type) {
150
- case tokenType.pendle:
150
+ case Erc20SubType.pendle:
151
151
  return PendleInterface.decodeFunctionResult("exchangeRate", returnData)[0];
152
- case tokenType.layerbank:
152
+ case Erc20SubType.layerbank:
153
153
  return LayerBankInterface.decodeFunctionResult("exchangeRate", returnData)[0];
154
- case tokenType.enzyme:
154
+ case Erc20SubType.enzyme:
155
155
  return EnzymeInterface.decodeFunctionResult("calcNetShareValue", returnData)[1];
156
- case tokenType.ionic:
156
+ case Erc20SubType.ionic:
157
157
  return IonicInterface.decodeFunctionResult("exchangeRateCurrent", returnData)[0];
158
- case tokenType.moonwell:
159
- case tokenType.venus:
160
- case tokenType.reactor_fusion:
158
+ case Erc20SubType.moonwell:
159
+ case Erc20SubType.venus:
160
+ case Erc20SubType.reactor_fusion:
161
161
  return MoonwellInterface.decodeFunctionResult("exchangeRateStored", returnData)[0];
162
162
  default:
163
- throw new Error(`Need tokenType for this key ${key}`);
163
+ throw new Error(`Need Erc20SubType for this key ${key}`);
164
164
  }
165
165
  // case "exchangeRateStored":
166
166
  // return MoonwellInterface.decodeFunctionResult("exchangeRateStored", returnData)[0];
@@ -170,14 +170,14 @@ export function decodeReturnValue(returnData, key, type) {
170
170
  return SturdyInterface.decodeFunctionResult("collateralContract", returnData)[0];
171
171
  case "lp_price":
172
172
  switch (type) {
173
- case tokenType.curve:
174
- case tokenType.curve_gauge:
173
+ case Erc20SubType.curve:
174
+ case Erc20SubType.curve_gauge:
175
175
  return CurveInterface.decodeFunctionResult("lp_price", returnData)[0];
176
- case tokenType.curve_2:
177
- case tokenType.maha:
176
+ case Erc20SubType.curve_2:
177
+ case Erc20SubType.maha:
178
178
  return CurveInterface.decodeFunctionResult("get_virtual_price", returnData)[0];
179
179
  default:
180
- throw new Error(`Need tokenType for this key ${key}`);
180
+ throw new Error(`Need Erc20SubType for this key ${key}`);
181
181
  }
182
182
  case "coin0":
183
183
  return CurveInterface.decodeFunctionResult("coins", returnData)[0];
@@ -213,25 +213,25 @@ export function decodeReturnValue(returnData, key, type) {
213
213
  return AuraOperatorInterface.decodeFunctionResult("staker", returnData)[0];
214
214
  case "totalAssets":
215
215
  switch (type) {
216
- case tokenType.anglesLiquid:
217
- case tokenType.cian:
218
- case tokenType.rfx_slv:
219
- case tokenType.beratrax_vault:
220
- case tokenType.beraborrow_gauge:
221
- case tokenType.metamorpho:
216
+ case Erc20SubType.anglesLiquid:
217
+ case Erc20SubType.cian:
218
+ case Erc20SubType.rfx_slv:
219
+ case Erc20SubType.beratrax_vault:
220
+ case Erc20SubType.beraborrow_gauge:
221
+ case Erc20SubType.metamorpho:
222
222
  return ERC4626Interface.decodeFunctionResult("totalAssets", returnData)[0];
223
- case tokenType.concrete:
223
+ case Erc20SubType.concrete:
224
224
  return ERC4626Interface.decodeFunctionResult("totalAssets", returnData)[0];
225
- case tokenType.gearbox:
225
+ case Erc20SubType.gearbox:
226
226
  return GearboxVaultInterface.decodeFunctionResult("totalAssets", returnData)[0];
227
- case tokenType.euler_lend:
227
+ case Erc20SubType.euler_lend:
228
228
  return EulerInterface.decodeFunctionResult("totalAssets", returnData)[0];
229
- case tokenType.euler_borrow:
229
+ case Erc20SubType.euler_borrow:
230
230
  return EulerInterface.decodeFunctionResult("totalBorrows", returnData)[0];
231
- case tokenType.compound:
231
+ case Erc20SubType.compound:
232
232
  return CompoundInterface.decodeFunctionResult("totalBorrow", returnData)[0];
233
233
  default:
234
- throw new Error(`Need tokenType for this key ${key}, or type ${type} not matched`);
234
+ throw new Error(`Need Erc20SubType for this key ${key}, or type ${type} not matched`);
235
235
  }
236
236
  case "getPoolTokens":
237
237
  return [
@@ -240,7 +240,7 @@ export function decodeReturnValue(returnData, key, type) {
240
240
  ];
241
241
  case "convertToAssets":
242
242
  switch (type) {
243
- case tokenType.curve_gauge:
243
+ case Erc20SubType.curve_gauge:
244
244
  return BigNumber.from("1000000000000000000");
245
245
  default:
246
246
  return FluidInterface.decodeFunctionResult("convertToAssets", returnData)[0];
@@ -257,7 +257,7 @@ export function decodeReturnValue(returnData, key, type) {
257
257
  return ZFStableSwapThreePoolInterface.decodeFunctionResult("coins", returnData)[0];
258
258
  case "minter":
259
259
  switch (type) {
260
- case tokenType.spectra_lpt:
260
+ case Erc20SubType.spectra_lpt:
261
261
  return CurveLPTokenInterface.decodeFunctionResult("minter", returnData)[0];
262
262
  default:
263
263
  return ZFStableLPINterface.decodeFunctionResult("minter", returnData)[0];
@@ -266,7 +266,7 @@ export function decodeReturnValue(returnData, key, type) {
266
266
  return SpectraYTInterface.decodeFunctionResult("getPT", returnData)[0];
267
267
  case "getTokenAddresses":
268
268
  switch (type) {
269
- case tokenType.tempestStaking: {
269
+ case Erc20SubType.tempestStaking: {
270
270
  return RswEthStrategyInterface.decodeFunctionResult("getTokenAddresses", returnData)[0];
271
271
  }
272
272
  default:
@@ -274,7 +274,7 @@ export function decodeReturnValue(returnData, key, type) {
274
274
  }
275
275
  case "getPositions":
276
276
  switch (type) {
277
- case tokenType.tempestStaking: {
277
+ case Erc20SubType.tempestStaking: {
278
278
  return RswEthStrategyInterface.decodeFunctionResult("getPositions", returnData);
279
279
  }
280
280
  default:
@@ -1,3 +1,3 @@
1
- import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
1
+ import { Erc20SubType } from "@/engine/campaignTVL/implementations/Erc20/Erc20SubType";
2
2
  import { type CallDto } from "@sdk";
3
- export declare function createCall(target: string, key: string, type?: tokenType, metaData?: any): CallDto;
3
+ export declare function createCall(target: string, key: string, type?: Erc20SubType, metaData?: any): CallDto;