@merkl/api 0.20.110 → 0.20.111

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.
@@ -12,7 +12,7 @@ export class Erc20TVLBuilder {
12
12
  const builder = erc20SubTypeTVLBuilderFactory(subType);
13
13
  const campaignsOfSubType = campaigns.filter((_campaign, index) => subTypes[index] === subType);
14
14
  if (!!builder) {
15
- log.info(`building TVLs for subtype ${subType}`);
15
+ log.local(`building TVLs for subtype ${subType}`);
16
16
  const subTypeTVLs = await builder.build(computeChainId, campaignsOfSubType);
17
17
  // Impact blacklist or whitelist
18
18
  const calls = [];
@@ -51,6 +51,7 @@ export class Erc20TVLBuilder {
51
51
  const result = await ChainInteractionService(computeChainId).fetchState(calls);
52
52
  let index = 0;
53
53
  for (const [i, { campaign }] of subTypeTVLs.entries()) {
54
+ log.local(`building TVLs for subtype ${subType} using deprecated code`);
54
55
  const { campaignParameters } = campaign;
55
56
  const { whitelist, blacklist } = campaignParameters;
56
57
  if (whitelist?.length > 0) {
@@ -14,6 +14,10 @@ const map = {
14
14
  [Campaign.AMBIENTPROCESSOR]: new AmbiantTVLBuilder(),
15
15
  [Campaign.UNISWAP_V4]: new UniswapV4TVLBuilder(),
16
16
  [Campaign.ERC20]: new Erc20TVLBuilder(),
17
+ [Campaign.ERC20LOGPROCESSOR]: new Erc20TVLBuilder(),
18
+ [Campaign.ERC20REBASEFIXAPR]: new Erc20TVLBuilder(),
19
+ [Campaign.ERC20_FIX_APR]: new Erc20TVLBuilder(),
20
+ [Campaign.EULER]: new Erc20TVLBuilder(),
17
21
  };
18
22
  export const campaignTVLBuilderFactory = (campaignType) => {
19
23
  if (!map[campaignType]) {
@@ -10,7 +10,7 @@ import { TvlService } from "@/modules/v4/tvl/tvl.service";
10
10
  import bigintToString from "@/utils/bigintToString";
11
11
  import { log } from "@/utils/logger";
12
12
  import { AprType } from "@db/api";
13
- import { Campaign as CampaignEnum, DAY, NETWORK_LABELS, } from "@sdk";
13
+ import { Campaign as CampaignEnum, DAY, NETWORK_LABELS, bigIntToNumber, } from "@sdk";
14
14
  import moment from "moment";
15
15
  import { AprService } from "../apr";
16
16
  import { CampaignService } from "../campaign";
@@ -96,6 +96,7 @@ export class DynamicDataService {
96
96
  let campaignDailyValue = await TokenService.getValueByTokenId(TokenService.hashId({ address: rewardTokenAddress, chainId: record.campaign.chainId }), dailyAmount);
97
97
  // Fixed APR campaigns
98
98
  if (hasFixedAprConfig(campaignParameters)) {
99
+ log.local(`[${NETWORK_LABELS[chainId]}][${CampaignEnum[type]}] calculating fixed APR for ${record.campaign.campaignId}`);
99
100
  const { targetTokenPricing, rewardTokenPricing, apr: fixedApr } = campaignParameters;
100
101
  const targetApr = Number(fixedApr);
101
102
  if (targetTokenPricing && rewardTokenPricing) {
@@ -106,8 +107,11 @@ export class DynamicDataService {
106
107
  if (targetTokenPricing && !rewardTokenPricing) {
107
108
  // Case 2: Fixed # amount of reward per $ of liquidity
108
109
  // Return 0 if reward token price is invalid
109
- campaignDailyValue = !rewardToken.price ? 0 : targetApr * rewardToken.price * tvl.total;
110
- dailyAmount = BigInt((campaignDailyValue / (rewardToken.price ?? 1)) * 10 ** rewardToken.decimals);
110
+ // targetApr represents a yearly # amount of reward per $ of liquidity
111
+ dailyAmount =
112
+ (BigInt(Math.floor((targetApr * tvl.total * 10 ** 6) / 365)) * 10n ** BigInt(rewardToken.decimals)) /
113
+ 10n ** 6n;
114
+ campaignDailyValue = bigIntToNumber(dailyAmount, rewardToken.decimals) * (rewardToken.price ?? 1);
111
115
  }
112
116
  }
113
117
  dailyRewards.total += campaignDailyValue;