@merkl/api 0.21.4 → 0.21.6

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 (38) hide show
  1. package/dist/database/api/.generated/edge.js +2 -2
  2. package/dist/database/api/.generated/index.js +2 -2
  3. package/dist/database/api/.generated/package.json +1 -1
  4. package/dist/database/api/.generated/schema.prisma +1 -0
  5. package/dist/src/eden/index.d.ts +1110 -581
  6. package/dist/src/engine/deprecated/dynamicData/implementations/EventBased.js +2 -11
  7. package/dist/src/engine/deprecated/dynamicData/utils/getCompV2ForksVaults.js +10 -3
  8. package/dist/src/engine/implementations/MultiLog/tvl.js +33 -0
  9. package/dist/src/index.d.ts +448 -261
  10. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +11 -2
  11. package/dist/src/modules/v4/campaign/campaign.controller.js +3 -3
  12. package/dist/src/modules/v4/campaign/campaign.repository.d.ts +44 -3
  13. package/dist/src/modules/v4/campaign/campaign.repository.js +46 -2
  14. package/dist/src/modules/v4/campaign/campaign.service.d.ts +36 -2
  15. package/dist/src/modules/v4/campaign/campaign.service.js +20 -8
  16. package/dist/src/modules/v4/creator/creator.controller.d.ts +236 -34
  17. package/dist/src/modules/v4/creator/creator.controller.js +28 -21
  18. package/dist/src/modules/v4/creator/creator.model.d.ts +29 -5
  19. package/dist/src/modules/v4/creator/creator.model.js +21 -1
  20. package/dist/src/modules/v4/creator/creator.repository.d.ts +52 -6
  21. package/dist/src/modules/v4/creator/creator.repository.js +16 -13
  22. package/dist/src/modules/v4/creator/creator.service.d.ts +161 -14
  23. package/dist/src/modules/v4/creator/creator.service.js +49 -11
  24. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +1 -1
  25. package/dist/src/modules/v4/opportunity/opportunity.repository.js +4 -3
  26. package/dist/src/modules/v4/programPayload/programPayload.model.d.ts +14 -1
  27. package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +68 -7
  28. package/dist/src/modules/v4/programPayload/programPayload.repository.js +240 -12
  29. package/dist/src/modules/v4/router.d.ts +448 -261
  30. package/dist/src/modules/v4/user/user.controller.d.ts +177 -192
  31. package/dist/src/modules/v4/user/user.controller.js +38 -56
  32. package/dist/src/modules/v4/user/user.model.d.ts +1 -1
  33. package/dist/src/modules/v4/user/user.model.js +1 -1
  34. package/dist/src/modules/v4/user/user.repository.d.ts +1 -1
  35. package/dist/src/modules/v4/user/user.repository.js +1 -1
  36. package/dist/src/modules/v4/user/user.service.d.ts +1 -1
  37. package/dist/tsconfig.package.tsbuildinfo +1 -1
  38. package/package.json +3 -2
@@ -62,7 +62,7 @@ async function computeEventBasedPoolRewardsFromMostRecentStateSave(chainId, camp
62
62
  for (const [_, { value, params: _params }] of Object.entries(storedStates)) {
63
63
  distributedRewards += BN2Number(value.allTimeValue, 18);
64
64
  }
65
- distributedRewards = Math.max(distributedRewards, 1);
65
+ distributedRewards = distributedRewards === 0 ? 1 : distributedRewards;
66
66
  }
67
67
  catch {
68
68
  log.warn(`merklDynamic data - failed to decode state of event based on ${NETWORK_LABELS[chainId]}`);
@@ -84,16 +84,7 @@ export class EventBasedDynamicData {
84
84
  const { distributedRewards } = await computeEventBasedPoolRewardsFromMostRecentStateSave(chainId, campaign.campaignId, priceToken, decimalsCurrency0, campaign.campaignParameters.computeScoreParameters.computeMethod);
85
85
  const c = campaign;
86
86
  const amount = BN2Number(c.amount, c.campaignParameters.decimalsRewardToken);
87
- let multiplier = 1;
88
- try {
89
- const topicData = c.campaignParameters.topicToData[0];
90
- multiplier = BN2Number(topicData.multipliers[0], 12 + 9);
91
- }
92
- catch {
93
- // Current legacy fix for now, can be removed on the 01/05/25
94
- const topicData = c.campaignParameters.topicToData[0];
95
- multiplier = BN2Number(topicData.multiplier, 12 + 9);
96
- }
87
+ const multiplier = 1;
97
88
  const startTimestamp = BN2Number(c.startTimestamp, 0);
98
89
  const endTimestamp = BN2Number(c.endTimestamp, 0);
99
90
  const isLive = moment().unix() > startTimestamp && moment().unix() < endTimestamp;
@@ -24,9 +24,16 @@ async function getCompoundV2ForksVaults() {
24
24
  }
25
25
  const creationBlock = (await getContractCreationBlock(comptrollerAddress, providers[chainId])) ?? 0;
26
26
  let logs = [];
27
- const topic = compFork === CompFork.Venus && chainId === ChainId.ZKSYNC
28
- ? MARKET_SUPPORTED_EVENT_HASH
29
- : MARKET_LISTED_EVENT_HASH;
27
+ let topic;
28
+ if (compFork === CompFork.Venus && (chainId === ChainId.ZKSYNC || chainId === ChainId.SONIC)) {
29
+ topic = MARKET_SUPPORTED_EVENT_HASH;
30
+ }
31
+ else if (compFork === CompFork.Enclabs) {
32
+ topic = MARKET_SUPPORTED_EVENT_HASH;
33
+ }
34
+ else {
35
+ topic = MARKET_LISTED_EVENT_HASH;
36
+ }
30
37
  logs = await safeFetchLogs(chainId, [topic], [comptrollerAddress], creationBlock, toBlock);
31
38
  if (compFork === CompFork.Ionic && chainId === ChainId.MODE) {
32
39
  const isolatedIonicMarketUnitroller = "0x8Fb3D4a94D0aA5D6EDaAC3Ed82B59a27f56d923a";
@@ -1,5 +1,7 @@
1
1
  import { DynamicDataService } from "@/modules/v4/dynamicData/dynamicData.service";
2
+ import { TvlType } from "@db/api";
2
3
  import { ComposedType } from "@sdk";
4
+ import { all, create } from "mathjs";
3
5
  export class MultiLogTVLBuilder {
4
6
  async build(_computeChainId, campaigns) {
5
7
  const tvls = [];
@@ -10,6 +12,37 @@ export class MultiLogTVLBuilder {
10
12
  }
11
13
  if (mainComposedList.length > 1) {
12
14
  // TODO: handle multiple main composed campaigns
15
+ const tvlMapping = {};
16
+ const multipliers = {};
17
+ const tvlBreakdown = [];
18
+ for (const composedCampaign of mainComposedList) {
19
+ const composedCampaignTVL = (await DynamicDataService.update(composedCampaign.computeChainId, composedCampaign.campaignType, [composedCampaign], true))[0];
20
+ const tvlValue = typeof composedCampaignTVL.tvl === "string"
21
+ ? Number(composedCampaignTVL.tvl)
22
+ : composedCampaignTVL.tvl.total;
23
+ tvlMapping[composedCampaign.composedIndex] = tvlValue;
24
+ multipliers[composedCampaign.composedIndex] = Number(composedCampaign.composedMultiplier ?? 10 ** 9);
25
+ tvlBreakdown.push({
26
+ identifier: composedCampaign.campaignId,
27
+ type: TvlType.PROTOCOL,
28
+ value: Math.abs(tvlValue),
29
+ });
30
+ }
31
+ const config = {
32
+ number: "bigint",
33
+ };
34
+ const bigmath = create(all, config);
35
+ const scope = { tvlMapping, multipliers, BASE_9: Number(10 ** 9) };
36
+ const computeExpression = campaign.campaignParameters.composedCampaignsCompute.replace(/\d+/g, match => {
37
+ return tvlMapping[match] !== undefined ? `tvlMapping["${match}"] * multipliers["${match}"] / BASE_9` : "0";
38
+ });
39
+ const totalTvl = bigmath.evaluate(computeExpression, scope);
40
+ tvls.push({
41
+ campaign: campaign,
42
+ tvl: totalTvl,
43
+ tvlBreakdown,
44
+ });
45
+ continue;
13
46
  }
14
47
  const mainComposed = mainComposedList[0];
15
48
  if (mainComposed) {