@merkl/api 0.20.65 → 0.20.67

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 (130) hide show
  1. package/dist/src/engine/dynamicData/factory.js +2 -0
  2. package/dist/src/engine/dynamicData/implementations/Erc20.js +42 -80
  3. package/dist/src/engine/erc20SubTypeProcessors/GenericProcessor.d.ts +18 -18
  4. package/dist/src/engine/erc20SubTypeProcessors/GenericProcessor.js +30 -33
  5. package/dist/src/engine/erc20SubTypeProcessors/helpers/factoryFinder.d.ts +1 -1
  6. package/dist/src/engine/erc20SubTypeProcessors/helpers/factoryFinder.js +1 -1
  7. package/dist/src/engine/erc20SubTypeProcessors/helpers/hardcoded.d.ts +1 -1
  8. package/dist/src/engine/erc20SubTypeProcessors/helpers/hardcoded.js +1 -1
  9. package/dist/src/engine/erc20SubTypeProcessors/helpers/ownerFinder.d.ts +1 -1
  10. package/dist/src/engine/erc20SubTypeProcessors/helpers/ownerFinder.js +1 -1
  11. package/dist/src/engine/erc20SubTypeProcessors/{constants.d.ts → helpers/tokenType.d.ts} +6 -0
  12. package/dist/src/engine/erc20SubTypeProcessors/implementations/AaveProcessor.d.ts +2 -1
  13. package/dist/src/engine/erc20SubTypeProcessors/implementations/AaveProcessor.js +2 -1
  14. package/dist/src/engine/erc20SubTypeProcessors/implementations/AnglesLiquid.d.ts +3 -2
  15. package/dist/src/engine/erc20SubTypeProcessors/implementations/AnglesLiquid.js +5 -1
  16. package/dist/src/engine/erc20SubTypeProcessors/implementations/AssetProcessor.d.ts +2 -1
  17. package/dist/src/engine/erc20SubTypeProcessors/implementations/AssetProcessor.js +2 -2
  18. package/dist/src/engine/erc20SubTypeProcessors/implementations/AuraProcessor.d.ts +2 -3
  19. package/dist/src/engine/erc20SubTypeProcessors/implementations/AuraProcessor.js +7 -6
  20. package/dist/src/engine/erc20SubTypeProcessors/implementations/BEXRewardGaugeProcessor.d.ts +2 -3
  21. package/dist/src/engine/erc20SubTypeProcessors/implementations/BEXRewardGaugeProcessor.js +5 -4
  22. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerGaugeProcessor.d.ts +2 -3
  23. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerGaugeProcessor.js +4 -3
  24. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerPoolProcessor.d.ts +2 -3
  25. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerPoolProcessor.js +4 -3
  26. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerV3PoolProcessor.d.ts +2 -2
  27. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerV3PoolProcessor.js +2 -1
  28. package/dist/src/engine/erc20SubTypeProcessors/implementations/BeefyProcessor.d.ts +2 -2
  29. package/dist/src/engine/erc20SubTypeProcessors/implementations/BeefyProcessor.js +3 -3
  30. package/dist/src/engine/erc20SubTypeProcessors/implementations/BunniV2Processor.d.ts +2 -2
  31. package/dist/src/engine/erc20SubTypeProcessors/implementations/BunniV2Processor.js +2 -2
  32. package/dist/src/engine/erc20SubTypeProcessors/implementations/CompoundProcessor.d.ts +2 -2
  33. package/dist/src/engine/erc20SubTypeProcessors/implementations/CompoundProcessor.js +3 -2
  34. package/dist/src/engine/erc20SubTypeProcessors/implementations/ERC4626Processor.d.ts +2 -1
  35. package/dist/src/engine/erc20SubTypeProcessors/implementations/ERC4626Processor.js +1 -1
  36. package/dist/src/engine/erc20SubTypeProcessors/implementations/EnzymeProcessor.d.ts +2 -3
  37. package/dist/src/engine/erc20SubTypeProcessors/implementations/EnzymeProcessor.js +2 -2
  38. package/dist/src/engine/erc20SubTypeProcessors/implementations/EqualizerGaugeProcessor.d.ts +2 -1
  39. package/dist/src/engine/erc20SubTypeProcessors/implementations/EqualizerGaugeProcessor.js +1 -1
  40. package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerBorrowProcessor.d.ts +2 -1
  41. package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerBorrowProcessor.js +1 -1
  42. package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerLendProcessor.d.ts +2 -1
  43. package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerLendProcessor.js +1 -1
  44. package/dist/src/engine/erc20SubTypeProcessors/implementations/FluidProcessor.d.ts +2 -2
  45. package/dist/src/engine/erc20SubTypeProcessors/implementations/FluidProcessor.js +3 -2
  46. package/dist/src/engine/erc20SubTypeProcessors/implementations/FraxProcessor.d.ts +2 -1
  47. package/dist/src/engine/erc20SubTypeProcessors/implementations/FraxProcessor.js +2 -2
  48. package/dist/src/engine/erc20SubTypeProcessors/implementations/GammaProcessor.d.ts +3 -2
  49. package/dist/src/engine/erc20SubTypeProcessors/implementations/GammaProcessor.js +4 -1
  50. package/dist/src/engine/erc20SubTypeProcessors/implementations/GearboxProcessor.d.ts +2 -2
  51. package/dist/src/engine/erc20SubTypeProcessors/implementations/GearboxProcessor.js +3 -2
  52. package/dist/src/engine/erc20SubTypeProcessors/implementations/HanjiVaultProcessor.d.ts +2 -3
  53. package/dist/src/engine/erc20SubTypeProcessors/implementations/HanjiVaultProcessor.js +5 -4
  54. package/dist/src/engine/erc20SubTypeProcessors/implementations/HoldStationProcessor.d.ts +2 -1
  55. package/dist/src/engine/erc20SubTypeProcessors/implementations/HoldStationProcessor.js +1 -1
  56. package/dist/src/engine/erc20SubTypeProcessors/implementations/HourglassProcessor.d.ts +2 -2
  57. package/dist/src/engine/erc20SubTypeProcessors/implementations/HourglassProcessor.js +3 -2
  58. package/dist/src/engine/erc20SubTypeProcessors/implementations/MaverickBPProcessor.d.ts +2 -2
  59. package/dist/src/engine/erc20SubTypeProcessors/implementations/MaverickBPProcessor.js +2 -2
  60. package/dist/src/engine/erc20SubTypeProcessors/implementations/MetamorphoProcessor.d.ts +2 -2
  61. package/dist/src/engine/erc20SubTypeProcessors/implementations/MetamorphoProcessor.js +2 -1
  62. package/dist/src/engine/erc20SubTypeProcessors/implementations/NoLinkVaultProcessor.d.ts +3 -2
  63. package/dist/src/engine/erc20SubTypeProcessors/implementations/NoLinkVaultProcessor.js +6 -3
  64. package/dist/src/engine/erc20SubTypeProcessors/implementations/PendleProcessor.d.ts +2 -1
  65. package/dist/src/engine/erc20SubTypeProcessors/implementations/PendleProcessor.js +1 -1
  66. package/dist/src/engine/erc20SubTypeProcessors/implementations/PendleYTProcessor.d.ts +2 -1
  67. package/dist/src/engine/erc20SubTypeProcessors/implementations/PendleYTProcessor.js +1 -1
  68. package/dist/src/engine/erc20SubTypeProcessors/implementations/RadiantProcessor.d.ts +2 -2
  69. package/dist/src/engine/erc20SubTypeProcessors/implementations/RadiantProcessor.js +2 -1
  70. package/dist/src/engine/erc20SubTypeProcessors/implementations/RfxProcessor.d.ts +2 -2
  71. package/dist/src/engine/erc20SubTypeProcessors/implementations/RfxProcessor.js +6 -5
  72. package/dist/src/engine/erc20SubTypeProcessors/implementations/Satlayer.d.ts +2 -1
  73. package/dist/src/engine/erc20SubTypeProcessors/implementations/Satlayer.js +2 -1
  74. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpectraProcessor.d.ts +2 -1
  75. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpectraProcessor.js +1 -1
  76. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpectraYTProcessor.d.ts +2 -1
  77. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpectraYTProcessor.js +1 -1
  78. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpliceProcessor.d.ts +1 -2
  79. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpliceProcessor.js +1 -0
  80. package/dist/src/engine/erc20SubTypeProcessors/implementations/SturdySiloProcessor.d.ts +2 -1
  81. package/dist/src/engine/erc20SubTypeProcessors/implementations/SturdySiloProcessor.js +2 -1
  82. package/dist/src/engine/erc20SubTypeProcessors/implementations/TempestVaultProcessor.d.ts +2 -2
  83. package/dist/src/engine/erc20SubTypeProcessors/implementations/TempestVaultProcessor.js +2 -2
  84. package/dist/src/engine/erc20SubTypeProcessors/implementations/TemplateProcessor.d.ts +3 -2
  85. package/dist/src/engine/erc20SubTypeProcessors/implementations/TemplateProcessor.js +4 -0
  86. package/dist/src/engine/erc20SubTypeProcessors/implementations/TorosProcessor.d.ts +2 -1
  87. package/dist/src/engine/erc20SubTypeProcessors/implementations/TorosProcessor.js +2 -1
  88. package/dist/src/engine/erc20SubTypeProcessors/implementations/UniswapProcessor.d.ts +2 -3
  89. package/dist/src/engine/erc20SubTypeProcessors/implementations/UniswapProcessor.js +3 -3
  90. package/dist/src/engine/erc20SubTypeProcessors/implementations/VicunaProcessor.d.ts +2 -1
  91. package/dist/src/engine/erc20SubTypeProcessors/implementations/VicunaProcessor.js +1 -1
  92. package/dist/src/engine/erc20SubTypeProcessors/implementations/WoofiProcessor.d.ts +2 -1
  93. package/dist/src/engine/erc20SubTypeProcessors/implementations/WoofiProcessor.js +2 -1
  94. package/dist/src/engine/erc20SubTypeProcessors/implementations/ZkSwapThreePoolProcessor.d.ts +2 -2
  95. package/dist/src/engine/erc20SubTypeProcessors/implementations/ZkSwapThreePoolProcessor.js +7 -7
  96. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveNPoolProcessor.d.ts +2 -3
  97. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveNPoolProcessor.js +6 -5
  98. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveProcessor.d.ts +2 -1
  99. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveProcessor.js +3 -2
  100. package/dist/src/engine/erc20SubTypeProcessors/implementations/processorMapping.d.ts +6 -0
  101. package/dist/src/engine/erc20SubTypeProcessors/{factory.js → implementations/processorMapping.js} +48 -49
  102. package/dist/src/engine/erc20SubTypeProcessors/implementations/stakedCurveProcessor.d.ts +2 -2
  103. package/dist/src/engine/erc20SubTypeProcessors/implementations/stakedCurveProcessor.js +4 -3
  104. package/dist/src/engine/erc20SubTypeProcessors/implementations/xU308Processor.d.ts +2 -2
  105. package/dist/src/engine/erc20SubTypeProcessors/implementations/xU308Processor.js +4 -3
  106. package/dist/src/engine/erc20SubTypeProcessors/subtypesPrices.d.ts +4 -0
  107. package/dist/src/engine/erc20SubTypeProcessors/subtypesPrices.js +24 -0
  108. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound1.d.ts +3 -17
  109. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound1.js +62 -52
  110. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound2.d.ts +4 -0
  111. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound2.js +22 -0
  112. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound3.d.ts +3 -0
  113. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound3.js +22 -0
  114. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound4.d.ts +3 -0
  115. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound4.js +22 -0
  116. package/dist/src/engine/opportunityMetadata/factory.js +2 -0
  117. package/dist/src/engine/opportunityMetadata/implementations/CompoundV3.js +4 -1
  118. package/dist/src/engine/opportunityMetadata/implementations/JsonAirdrop.js +1 -1
  119. package/dist/src/utils/decodeCalls.d.ts +1 -1
  120. package/dist/src/utils/decodeCalls.js +1 -1
  121. package/dist/src/utils/encodeCalls.d.ts +2 -2
  122. package/dist/src/utils/encodeCalls.js +15 -15
  123. package/dist/src/utils/generateCardName.d.ts +3 -4
  124. package/dist/src/utils/generateCardName.js +3 -3
  125. package/dist/src/utils/generateIcons.d.ts +3 -0
  126. package/dist/src/utils/generateIcons.js +65 -0
  127. package/dist/tsconfig.package.tsbuildinfo +1 -1
  128. package/package.json +1 -1
  129. package/dist/src/engine/erc20SubTypeProcessors/factory.d.ts +0 -6
  130. /package/dist/src/engine/erc20SubTypeProcessors/{constants.js → helpers/tokenType.js} +0 -0
@@ -1,9 +1,9 @@
1
1
  import { decodeCall, decodeReturnValue } from "@/utils/decodeCalls";
2
- import { tokenType } from "./constants";
3
- import { erc20ProcessorFactory } from "./factory";
4
2
  import { enzymeFundValueCalculatorRouterMapping, getTypeFromFactoryAddress } from "./helpers/factoryFinder";
5
3
  import { getTypeFromAddressChain } from "./helpers/hardcoded";
6
4
  import { getTypeFromOwnerAddress } from "./helpers/ownerFinder";
5
+ import { tokenType } from "./helpers/tokenType";
6
+ import { processorMapping } from "./implementations/processorMapping";
7
7
  function satisfiesNameConditions(name, type) {
8
8
  const lowerCaseName = name.toLowerCase();
9
9
  switch (type) {
@@ -165,168 +165,178 @@ function satisfiesNameConditions(name, type) {
165
165
  return false;
166
166
  }
167
167
  }
168
- function generateResult(type, name, campaign, data) {
169
- const typeInfo = {
168
+ function generateResult(type, name, targetToken, typeInfo, campaign) {
169
+ const ProcessorClass = processorMapping[type];
170
+ if (!ProcessorClass) {
171
+ throw new Error(`Processor not found for key: ${type}`);
172
+ }
173
+ const processorObject = new ProcessorClass();
174
+ if (campaign)
175
+ typeInfo = { ...typeInfo, ...parseForStaking(campaign) };
176
+ typeInfo = {
177
+ ...typeInfo,
170
178
  name: name,
171
- tokenAddress: campaign.campaignParameters.targetToken,
179
+ tokenAddress: targetToken,
172
180
  totalSupply: 0,
173
181
  blacklistedSupply: 0,
174
- whitelistedSupply: 0,
175
- ...parseForStaking(campaign),
176
- ...(data ?? {}),
177
182
  };
178
- return erc20ProcessorFactory(type, campaign).computeRound1(typeInfo); // TODO Fix
183
+ return processorObject.computeRound1(type, typeInfo);
179
184
  }
180
- function processNamingConditions(type, name, campaign) {
185
+ function processNamingConditions(type, name, targetToken, campaign) {
181
186
  if (satisfiesNameConditions(name, type)) {
182
- return generateResult(type, name, campaign);
187
+ return generateResult(type, name, targetToken, {}, campaign);
183
188
  }
184
189
  }
185
- function processNamingConditionsInOrder(types, name, campaign) {
190
+ function processNamingConditionsInOrder(types, name, targetToken, campaign) {
186
191
  for (const type of types) {
187
- const result = processNamingConditions(type, name, campaign);
192
+ const result = processNamingConditions(type, name, targetToken, campaign);
188
193
  if (result)
189
194
  return result;
190
195
  }
191
196
  }
192
- function parseForFactory(calls, campaign) {
197
+ function parseForFactory(calls, targetToken, campaign) {
193
198
  try {
194
199
  const factory = decodeReturnValue(calls.factory, "factory");
195
200
  const name = decodeReturnValue(calls.name, "name");
196
201
  const type = getTypeFromFactoryAddress(factory);
197
202
  if (type !== tokenType.unknown)
198
- return generateResult(type, name, campaign, { factory });
203
+ return generateResult(type, name, targetToken, { factory }, campaign);
199
204
  }
200
205
  catch (e) {
201
206
  // No factory on this token
202
207
  // console.log(e);
203
208
  }
204
209
  }
205
- function parseForOwner(calls, campaign) {
210
+ function parseForOwner(calls, targetToken) {
206
211
  try {
207
212
  const owner = decodeReturnValue(calls.owner, "owner");
208
213
  const name = decodeReturnValue(calls.name, "name");
209
214
  const type = getTypeFromOwnerAddress(owner);
210
215
  if (type !== tokenType.unknown)
211
- return generateResult(type, name, campaign, { owner });
216
+ return generateResult(type, name, targetToken, { owner: owner });
212
217
  }
213
218
  catch (e) {
214
219
  // No factory on this token
215
220
  // console.log(e);
216
221
  }
217
222
  }
218
- function parseForEnzyme(calls, campaign) {
223
+ function parseForEnzyme(calls, targetToken) {
219
224
  // Enzyme check
220
225
  try {
221
226
  const dispatcher = decodeReturnValue(calls.creator, "getCreator");
222
227
  const name = decodeReturnValue(calls.name, "name");
223
228
  const type = getTypeFromFactoryAddress(dispatcher);
224
229
  const fundValueCalculator = enzymeFundValueCalculatorRouterMapping[dispatcher];
230
+ const typeInfo = {
231
+ fundValueCalculator,
232
+ dispatcher,
233
+ };
225
234
  if (type === tokenType.enzyme) {
226
- return generateResult(type, name, campaign, {
227
- fundValueCalculator,
228
- dispatcher,
229
- });
235
+ return generateResult(type, name, targetToken, typeInfo);
230
236
  }
231
237
  }
232
238
  catch (e) {
233
239
  // No factory on this token
234
240
  }
235
241
  }
236
- function parseForMetamorpho(calls, campaign) {
242
+ function parseForMetamorpho(calls, targetToken) {
237
243
  // MetaMorpho check
238
244
  try {
239
245
  decodeReturnValue(calls.metamorpho, "MORPHO");
240
246
  const name = decodeReturnValue(calls.name, "name");
241
- return generateResult(tokenType.metamorpho, name, campaign);
247
+ return generateResult(tokenType.metamorpho, name, targetToken, {});
242
248
  }
243
249
  catch (e) {
244
250
  // Not a metamorpho token
245
251
  }
246
252
  }
247
- function parseForBalancer(calls, name, campaign) {
253
+ function parseForBalancer(calls, targetToken, name) {
248
254
  // Check for balancer pools
249
255
  try {
250
256
  decodeReturnValue(calls.poolId, "getPoolId");
251
- return generateResult(tokenType.balancerPool, name, campaign);
257
+ return generateResult(tokenType.balancerPool, name, targetToken, {});
252
258
  }
253
259
  catch (e) {
254
260
  // Not a balancer pool
255
261
  }
256
262
  try {
257
263
  decodeReturnValue(calls.vault, "getVault");
258
- return generateResult(tokenType.balancerV3, name, campaign);
264
+ return generateResult(tokenType.balancerV3, name, targetToken, {});
259
265
  }
260
266
  catch (e) {
261
267
  // Not a balancer v3 pool
262
268
  }
263
269
  }
264
- function checkAgainstHardcoded(calls, campaign) {
270
+ function checkAgainstHardcoded(calls, chainId, targetToken) {
265
271
  // Check for balancer pools
266
272
  try {
267
273
  const name = decodeReturnValue(calls.name, "name");
268
- const type = getTypeFromAddressChain(campaign.computeChainId, campaign.campaignParameters.targetToken);
274
+ const type = getTypeFromAddressChain(chainId, targetToken);
269
275
  if (type !== tokenType.unknown)
270
- return generateResult(type, name, campaign);
276
+ return generateResult(type, name, targetToken, {});
271
277
  }
272
278
  catch (e) {
273
279
  // Not a hardcoded address
274
280
  }
275
281
  }
276
- export function parseForStaking(campaign) {
282
+ function parseForStaking(campaign) {
277
283
  try {
278
284
  const whitelist = campaign.campaignParameters.whitelist;
279
285
  if (whitelist.length === 1) {
280
286
  const forwarders = campaign.campaignParameters.forwarders;
281
287
  if (forwarders.length === 1) {
282
288
  if (forwarders[0].sender === whitelist[0]) {
283
- return { isStaking: true, stakingContract: whitelist[0] };
289
+ return { isStaking: "true", stakingContract: whitelist[0] };
284
290
  }
285
291
  }
286
292
  }
287
293
  }
288
- catch { }
289
- return { isStaking: false };
294
+ catch (e) {
295
+ // No factory on this token
296
+ // console.log(e);
297
+ }
298
+ return { isStaking: "false" };
290
299
  }
291
- export function getTokenTypeRound1(callResults, index, campaign) {
300
+ export function getTokenTypeRound1(calls, targetToken, index, campaign) {
301
+ const returnValueOfCalls = calls.map(call => call.returnData);
292
302
  const returnValue = {
293
- factory: callResults[index],
294
- metamorpho: callResults[index + 1],
295
- name: callResults[index + 2],
296
- poolId: callResults[index + 3],
297
- creator: callResults[index + 4],
298
- owner: callResults[index + 5],
299
- vault: callResults[index + 6],
303
+ factory: returnValueOfCalls[index],
304
+ metamorpho: returnValueOfCalls[index + 1],
305
+ name: returnValueOfCalls[index + 2],
306
+ poolId: returnValueOfCalls[index + 3],
307
+ creator: returnValueOfCalls[index + 4],
308
+ owner: returnValueOfCalls[index + 5],
309
+ vault: returnValueOfCalls[index + 6],
300
310
  };
301
- let result = parseForFactory(returnValue, campaign);
311
+ let result = parseForFactory(returnValue, targetToken, campaign);
302
312
  if (result)
303
313
  return result;
304
- result = parseForOwner(returnValue, campaign);
314
+ result = parseForOwner(returnValue, targetToken);
305
315
  if (result)
306
316
  return result;
307
- result = checkAgainstHardcoded(returnValue, campaign);
317
+ result = checkAgainstHardcoded(returnValue, campaign.computeChainId, targetToken);
308
318
  if (result)
309
319
  return result;
310
- result = parseForEnzyme(returnValue, campaign);
320
+ result = parseForEnzyme(returnValue, targetToken);
311
321
  if (result)
312
322
  return result;
313
- result = parseForMetamorpho(returnValue, campaign);
323
+ result = parseForMetamorpho(returnValue, targetToken);
314
324
  if (result)
315
325
  return result;
316
326
  let name;
317
327
  try {
318
- name = decodeCall(callResults, index + 2, "name");
328
+ name = decodeCall(returnValueOfCalls, index + 2, "name");
319
329
  }
320
330
  catch {
321
- return generateResult(tokenType.unknown, "Unknown", campaign);
331
+ return generateResult(tokenType.unknown, "Unknown", targetToken, {}, campaign);
322
332
  }
323
- result = parseForBalancer(returnValue, name, campaign);
333
+ result = parseForBalancer(returnValue, targetToken, name);
324
334
  if (result)
325
335
  return result;
326
336
  // Order matters
327
337
  const ordered_token_Type = Object.values(tokenType).filter(value => typeof value === "string");
328
- result = processNamingConditionsInOrder(ordered_token_Type, name, campaign);
338
+ result = processNamingConditionsInOrder(ordered_token_Type, name, targetToken, campaign);
329
339
  if (result)
330
340
  return result;
331
- return generateResult(tokenType.unknown, name, campaign);
341
+ return generateResult(tokenType.unknown, name, targetToken, {}, campaign);
332
342
  }
@@ -0,0 +1,4 @@
1
+ import type { CampaignParameters, ResultDto } from "@sdk";
2
+ import type { ERC20SupportedCampaignType } from "../dynamicData/implementations/Erc20";
3
+ import type { tokenType, tokenTypeStruct } from "./helpers/tokenType";
4
+ export declare function getTokenTypeRound2(index: number, type: tokenType, typeInfo: any, calls: ResultDto[], campaign?: CampaignParameters<ERC20SupportedCampaignType>): tokenTypeStruct;
@@ -0,0 +1,22 @@
1
+ import { processorMapping } from "./implementations/processorMapping";
2
+ export function getTokenTypeRound2(index, type, typeInfo, calls, campaign) {
3
+ try {
4
+ const returnValueOfCalls = calls.map(call => call.returnData);
5
+ const ProcessorClass = processorMapping[type];
6
+ if (!ProcessorClass) {
7
+ throw new Error(`Processor not found for key: ${type}`);
8
+ }
9
+ const processorObject = new ProcessorClass();
10
+ return processorObject.computeRound2(index, type, typeInfo, returnValueOfCalls, campaign);
11
+ }
12
+ catch (error) {
13
+ console.error(error);
14
+ return {
15
+ type: type,
16
+ calls: [],
17
+ typeInfo: {
18
+ ...typeInfo,
19
+ },
20
+ };
21
+ }
22
+ }
@@ -0,0 +1,3 @@
1
+ import type { ResultDto } from "@sdk";
2
+ import type { tokenType, tokenTypeStruct } from "./helpers/tokenType";
3
+ export declare function getTokenTypeRound3(index: number, type: tokenType, typeInfo: any, calls: ResultDto[]): tokenTypeStruct;
@@ -0,0 +1,22 @@
1
+ import { processorMapping } from "./implementations/processorMapping";
2
+ export function getTokenTypeRound3(index, type, typeInfo, calls) {
3
+ try {
4
+ const ProcessorClass = processorMapping[type];
5
+ const returnValueOfCalls = calls.map(call => call.returnData);
6
+ if (!ProcessorClass) {
7
+ throw new Error(`Processor not found for key: ${type}`);
8
+ }
9
+ const processorObject = new ProcessorClass();
10
+ return processorObject.computeRound3(index, type, typeInfo, returnValueOfCalls);
11
+ }
12
+ catch (error) {
13
+ console.error(error);
14
+ return {
15
+ type: type,
16
+ calls: [],
17
+ typeInfo: {
18
+ ...typeInfo,
19
+ },
20
+ };
21
+ }
22
+ }
@@ -0,0 +1,3 @@
1
+ import type { Campaign, CampaignParameters, ResultDto } from "@sdk";
2
+ import type { tokenType, tokenTypeStruct } from "./helpers/tokenType";
3
+ export declare function getTokenTypeRound4(index: number, type: tokenType, typeInfo: any, calls: ResultDto[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.ERC20LOGPROCESSOR> | CampaignParameters<Campaign.ERC20REBASELOGPROCESSOR> | CampaignParameters<Campaign.EULER>): tokenTypeStruct;
@@ -0,0 +1,22 @@
1
+ import { processorMapping } from "./implementations/processorMapping";
2
+ export function getTokenTypeRound4(index, type, typeInfo, calls, campaign) {
3
+ try {
4
+ const ProcessorClass = processorMapping[type];
5
+ const returnValueOfCalls = calls.map(call => call.returnData);
6
+ if (!ProcessorClass) {
7
+ throw new Error(`Processor not found for key: ${type}`);
8
+ }
9
+ const processorObject = new ProcessorClass();
10
+ return processorObject.computeRound4(index, type, typeInfo, returnValueOfCalls, campaign);
11
+ }
12
+ catch (error) {
13
+ console.error(error);
14
+ return {
15
+ type: type,
16
+ calls: [],
17
+ typeInfo: {
18
+ ...typeInfo,
19
+ },
20
+ };
21
+ }
22
+ }
@@ -61,5 +61,7 @@ const map = {
61
61
  [Campaign.ERC6909FIXAPR]: new DefaultMetadata(), // TODO
62
62
  [Campaign.ERC1155]: new DefaultMetadata(), // TODO
63
63
  [Campaign.ERC1155FIXAPR]: new DefaultMetadata(), // TODO
64
+ [Campaign.ERC721]: new DefaultMetadata(), // TODO
65
+ [Campaign.ERC721FIXAPR]: new DefaultMetadata(), // TODO
64
66
  };
65
67
  export const metadataBuilderFactory = (campaignType) => map[campaignType];
@@ -11,7 +11,10 @@ export class CompoundV3Metadata {
11
11
  : `Borrow ${symbolUnderlyingToken} on`,
12
12
  "Compound V3",
13
13
  ].join(" "),
14
- tokens: [{ chainId: computeChainId, address: params.targetToken }],
14
+ tokens: [
15
+ { chainId: computeChainId, address: params.underlyingToken },
16
+ { chainId: computeChainId, address: params.targetToken },
17
+ ],
15
18
  mainProtocol: "compound",
16
19
  depositUrl: undefined, // TODO, shall depend on compFork
17
20
  };
@@ -19,7 +19,7 @@ export class JsonAirdropMetadata {
19
19
  tokens: [
20
20
  {
21
21
  chainId: computeChainId,
22
- address: tokenAddress,
22
+ address: tokenAddress, // TODO: Make sure targetToken is set
23
23
  },
24
24
  ],
25
25
  mainProtocol: aavePrefix || aciPrefix ? "aave" : undefined,
@@ -1,3 +1,3 @@
1
- import { tokenType } from "@/engine/erc20SubTypeProcessors/constants";
1
+ import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
2
2
  export declare function decodeCall(calls: string[], index: number, key: string, type?: tokenType): any;
3
3
  export declare function decodeReturnValue(returnData: string, key: string, type?: tokenType): any;
@@ -1,4 +1,4 @@
1
- import { tokenType } from "@/engine/erc20SubTypeProcessors/constants";
1
+ import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
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) {
@@ -1,3 +1,3 @@
1
- import { tokenType } from "@/engine/erc20SubTypeProcessors/constants";
1
+ import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
2
2
  import { type CallDto } from "@sdk";
3
- export declare function createCall(target: string, key: string, type?: tokenType, callArgs?: any): CallDto;
3
+ export declare function createCall(target: string, key: string, type?: tokenType, metaData?: any): CallDto;
@@ -1,17 +1,17 @@
1
- import { tokenType } from "@/engine/erc20SubTypeProcessors/constants";
1
+ import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
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, LayerBankInterface, LendleInterface, MaverickBPLensInterface, MetamorphoInterface, MoonwellInterface, OneInchStakingInterface, PendleInterface, PendleYTInterface, RadiantInterface, RfxDatastoreInterface, RswEthStrategyInterface, SpectraYTInterface, SturdyInterface, SymetricAmbientStrategyInterface, SyncSwapClassicPoolInterface, TorosInterface, UniswapV2PoolInterface, UniswapV3PoolInterface, VePufferInterface, ZFStableLPINterface, } from "@sdk";
3
- export function createCall(target, key, type, callArgs) {
3
+ export function createCall(target, key, type, metaData) {
4
4
  switch (key) {
5
5
  case "sqrtPriceX96":
6
6
  return { allowFailure: true, callData: UniswapV3PoolInterface.encodeFunctionData("slot0"), target };
7
7
  case "tokens":
8
- return { allowFailure: true, callData: LPManagerInterface.encodeFunctionData("tokens", [callArgs]), target };
8
+ return { allowFailure: true, callData: LPManagerInterface.encodeFunctionData("tokens", [metaData]), target };
9
9
  case "getTokensCount":
10
10
  return { allowFailure: true, callData: LPManagerInterface.encodeFunctionData("getTokensCount"), target };
11
11
  case "getTotalValue":
12
12
  return {
13
13
  allowFailure: true,
14
- callData: LPManagerHelperInterface.encodeFunctionData("getTotalValue", [callArgs]),
14
+ callData: LPManagerHelperInterface.encodeFunctionData("getTotalValue", [metaData]),
15
15
  target,
16
16
  };
17
17
  case "SY":
@@ -38,13 +38,13 @@ export function createCall(target, key, type, callArgs) {
38
38
  case "coin2":
39
39
  return { allowFailure: true, callData: CurveInterface.encodeFunctionData("coins", [2]), target };
40
40
  case "coins":
41
- return { allowFailure: true, callData: CurveInterface.encodeFunctionData("coins", [callArgs]), target };
41
+ return { allowFailure: true, callData: CurveInterface.encodeFunctionData("coins", [metaData]), target };
42
42
  case "N_COINS":
43
43
  return { allowFailure: true, callData: CurveStableSwapNGInterface.encodeFunctionData("N_COINS"), target };
44
44
  case "balances":
45
45
  return {
46
46
  allowFailure: true,
47
- callData: CurveStableSwapNGInterface.encodeFunctionData("balances", [callArgs]),
47
+ callData: CurveStableSwapNGInterface.encodeFunctionData("balances", [metaData]),
48
48
  target,
49
49
  };
50
50
  case "operator":
@@ -81,14 +81,14 @@ export function createCall(target, key, type, callArgs) {
81
81
  case "shortToken": {
82
82
  return {
83
83
  allowFailure: true,
84
- callData: RfxDatastoreInterface.encodeFunctionData("getAddress", [callArgs]),
84
+ callData: RfxDatastoreInterface.encodeFunctionData("getAddress", [metaData]),
85
85
  target,
86
86
  };
87
87
  }
88
88
  case "longToken": {
89
89
  return {
90
90
  allowFailure: true,
91
- callData: RfxDatastoreInterface.encodeFunctionData("getAddress", [callArgs]),
91
+ callData: RfxDatastoreInterface.encodeFunctionData("getAddress", [metaData]),
92
92
  target,
93
93
  };
94
94
  }
@@ -183,7 +183,7 @@ export function createCall(target, key, type, callArgs) {
183
183
  case "calcNetShareValue":
184
184
  return {
185
185
  allowFailure: true,
186
- callData: EnzymeInterface.encodeFunctionData("calcNetShareValue", [callArgs]),
186
+ callData: EnzymeInterface.encodeFunctionData("calcNetShareValue", [metaData]),
187
187
  target,
188
188
  };
189
189
  case "getPricePerFullShare":
@@ -237,7 +237,7 @@ export function createCall(target, key, type, callArgs) {
237
237
  case "balanceOf":
238
238
  return {
239
239
  allowFailure: true,
240
- callData: ERC20Interface.encodeFunctionData("balanceOf", [callArgs]),
240
+ callData: ERC20Interface.encodeFunctionData("balanceOf", [metaData]),
241
241
  target,
242
242
  };
243
243
  case "getPoolId":
@@ -255,7 +255,7 @@ export function createCall(target, key, type, callArgs) {
255
255
  case "poolInfo":
256
256
  return {
257
257
  allowFailure: true,
258
- callData: AuraOperatorInterface.encodeFunctionData("poolInfo", [callArgs]),
258
+ callData: AuraOperatorInterface.encodeFunctionData("poolInfo", [metaData]),
259
259
  target,
260
260
  };
261
261
  case "staker":
@@ -263,13 +263,13 @@ export function createCall(target, key, type, callArgs) {
263
263
  case "getPoolTokens":
264
264
  return {
265
265
  allowFailure: true,
266
- callData: BalancerVaultInterface.encodeFunctionData("getPoolTokens", [callArgs]),
266
+ callData: BalancerVaultInterface.encodeFunctionData("getPoolTokens", [metaData]),
267
267
  target,
268
268
  };
269
269
  case "convertToAssets":
270
270
  return {
271
271
  allowFailure: true,
272
- callData: FluidInterface.encodeFunctionData("convertToAssets", [callArgs]),
272
+ callData: FluidInterface.encodeFunctionData("convertToAssets", [metaData]),
273
273
  target,
274
274
  };
275
275
  case "tokenPrice":
@@ -339,7 +339,7 @@ export function createCall(target, key, type, callArgs) {
339
339
  case "boostedPositionInformation":
340
340
  return {
341
341
  allowFailure: true,
342
- callData: MaverickBPLensInterface.encodeFunctionData("boostedPositionInformation", [callArgs]),
342
+ callData: MaverickBPLensInterface.encodeFunctionData("boostedPositionInformation", [metaData]),
343
343
  target: target,
344
344
  };
345
345
  case "minter":
@@ -488,7 +488,7 @@ export function createCall(target, key, type, callArgs) {
488
488
  case "poolState":
489
489
  return {
490
490
  allowFailure: true,
491
- callData: BunniV2HubInterface.encodeFunctionData("poolState", [callArgs]),
491
+ callData: BunniV2HubInterface.encodeFunctionData("poolState", [metaData]),
492
492
  target: target,
493
493
  };
494
494
  default:
@@ -1,7 +1,6 @@
1
- import type { ERC20SupportedCampaignType } from "@/engine/dynamicData/implementations/Erc20";
2
- import { tokenType } from "@/engine/erc20SubTypeProcessors/constants";
3
- import type { CampaignParameters } from "@sdk";
1
+ import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
2
+ import type { Campaign, CampaignParameters } from "@sdk";
4
3
  export declare const stakingContractToStakingSymbol: {
5
4
  [key: string]: string;
6
5
  };
7
- export declare function generateCardName(type: tokenType, isStaking: boolean, typeInfo: any, campaign: CampaignParameters<ERC20SupportedCampaignType>, symbols?: string[], displayName?: string): string;
6
+ export declare function generateCardName(type: tokenType, typeInfo: any, campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.ERC20LOGPROCESSOR> | CampaignParameters<Campaign.ERC20REBASELOGPROCESSOR> | CampaignParameters<Campaign.EULER>, symbols?: string[], displayName?: string): string;
@@ -1,12 +1,12 @@
1
- import { tokenType } from "@/engine/erc20SubTypeProcessors/constants";
1
+ import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
2
2
  import { capitalize } from "lodash";
3
3
  export const stakingContractToStakingSymbol = {
4
4
  "0x18eeD20f71BEf84B605253C89A7576E3634134C0": "CyberStaking",
5
5
  "0x68754d29f2e97B837Cb622ccfF325adAC27E9977": "Karak",
6
6
  "0xcd28cF8f7755f03967D27E128B38022B63919836": "Llamalend",
7
7
  };
8
- export function generateCardName(type, isStaking, typeInfo, campaign, symbols = [""], displayName) {
9
- if (isStaking) {
8
+ export function generateCardName(type, typeInfo, campaign, symbols = [""], displayName) {
9
+ if (typeInfo.isStaking === "true") {
10
10
  if (typeInfo.stakingName !== undefined) {
11
11
  typeInfo.stakingSymbol = typeInfo.stakingName.includes("Deposit")
12
12
  ? typeInfo.stakingName.replace("Deposit", "").trim()
@@ -0,0 +1,3 @@
1
+ import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
2
+ import type { Campaign, CampaignParameters } from "@sdk";
3
+ export declare function generateIcons(type: tokenType, typeInfo: any, campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.ERC20LOGPROCESSOR> | CampaignParameters<Campaign.ERC20REBASELOGPROCESSOR> | CampaignParameters<Campaign.EULER>, symbols?: string[]): string[];
@@ -0,0 +1,65 @@
1
+ import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
2
+ import { OpportunityAction } from "@db/api";
3
+ export function generateIcons(type, typeInfo, campaign, symbols = [""]) {
4
+ const action = typeInfo.action ? typeInfo.action : "HOLD";
5
+ switch (action) {
6
+ case OpportunityAction.POOL:
7
+ switch (type) {
8
+ case tokenType.vicuna: {
9
+ const parsedName = typeInfo.name.split(" ").pop();
10
+ return parsedName.split("-");
11
+ }
12
+ case tokenType.balancerGauge:
13
+ case tokenType.balancerPool:
14
+ case tokenType.aura:
15
+ return Object.values(typeInfo.poolTokens ?? {})
16
+ .map(tkn => tkn?.symbol)
17
+ .filter(tkn => tkn && !tkn.includes("/"));
18
+ case tokenType.curve:
19
+ case tokenType.curve_2:
20
+ case tokenType.hanji_liquidity_vault_token:
21
+ case tokenType.crosscurve: {
22
+ const icons = [];
23
+ for (let i = 0; i < typeInfo.numberTokens; i++) {
24
+ if (typeInfo[`symbolToken${i}`])
25
+ icons.push(typeInfo[`symbolToken${i}`]);
26
+ }
27
+ return icons;
28
+ }
29
+ case tokenType.rfx_slv:
30
+ return [typeInfo.symbolAsset];
31
+ case tokenType.rfx:
32
+ return [typeInfo.symbolShortToken, typeInfo.symbolLongToken];
33
+ case tokenType.maverickBoostedPosition:
34
+ return [typeInfo.symbolTokenA, typeInfo.symbolTokenB];
35
+ default:
36
+ return [typeInfo.symbolToken0, typeInfo.symbolToken1];
37
+ }
38
+ case OpportunityAction.LEND:
39
+ switch (type) {
40
+ case tokenType.compound:
41
+ return [typeInfo.symbolBaseToken];
42
+ default:
43
+ return [typeInfo.symbolUnderlyingToken];
44
+ }
45
+ case OpportunityAction.BORROW:
46
+ return [typeInfo.symbolUnderlyingToken];
47
+ case OpportunityAction.HOLD:
48
+ switch (type) {
49
+ case tokenType.toros:
50
+ case tokenType.enzyme:
51
+ return [typeInfo.symbolUnderlyingToken];
52
+ case tokenType.pendleYT: {
53
+ let symbol = campaign.campaignParameters.symbolTargetToken;
54
+ symbol = symbol.split("-").slice(0, 2).join("-");
55
+ return [symbol];
56
+ }
57
+ case tokenType.pendle:
58
+ return [typeInfo.symbolUnderlyingToken];
59
+ default:
60
+ return [campaign.campaignParameters.symbolTargetToken];
61
+ }
62
+ default:
63
+ return [];
64
+ }
65
+ }