@merkl/api 0.10.273 → 0.10.275

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.
@@ -137,7 +137,7 @@ export class CampaignService {
137
137
  */
138
138
  static splitOnStatus(campaigns, timestamp = moment().unix()) {
139
139
  const past = campaigns.filter(({ endTimestamp: end }) => end <= timestamp);
140
- const live = campaigns.filter(({ startTimestamp: start, endTimestamp: end }) => start <= timestamp && end > timestamp);
140
+ const live = campaigns.filter(({ startTimestamp: start, endTimestamp: end }) => start >= timestamp && timestamp < end);
141
141
  const soon = campaigns.filter(({ startTimestamp: start }) => start > timestamp);
142
142
  return { past, live, soon };
143
143
  }
@@ -3,6 +3,7 @@ import { CampaignService, campaignTypeToEnumMap } from "../campaign";
3
3
  import { log } from "../../../utils/logger";
4
4
  import { OpportunityAction, Prisma, Status } from "../../../../database/api/.generated";
5
5
  import { record } from "@elysiajs/opentelemetry";
6
+ import moment from "moment";
6
7
  import { CacheService } from "../cache";
7
8
  import { TTLPresets } from "../cache/cache.model";
8
9
  import { TokenService } from "../token";
@@ -101,15 +102,16 @@ export class OpportunityService {
101
102
  });
102
103
  const tokens = (await TokenService.getManyOrCreate(metadata.tokens)).filter(t => t !== undefined);
103
104
  const params = JSON.parse(campaign.params);
105
+ const now = moment().unix();
104
106
  const opportunity = {
105
107
  id: opportunityId,
106
108
  chainId: campaign.computeChainId,
107
109
  type: campaignType,
108
110
  identifier: campaign.opportunityIdentifier, // mainParameter
109
111
  name: metadata.name,
110
- status: +campaign.startTimestamp >= new Date().getTime() * 1000
112
+ status: +campaign.startTimestamp >= now && now < +campaign.endTimestamp
111
113
  ? Status.LIVE
112
- : +campaign.endTimestamp < new Date().getTime() * 1000
114
+ : now > +campaign.endTimestamp
113
115
  ? Status.PAST
114
116
  : Status.SOON,
115
117
  action: metadata.action,
@@ -224,8 +226,10 @@ export class OpportunityService {
224
226
  }))?.[0] ?? undefined)
225
227
  : {
226
228
  cumulated: 0,
227
- timestamp: AprRecords[0].timestamp,
228
- breakdowns: [{ ...AprRecords[0].AprBreakdown[0], value: 0 }],
229
+ timestamp: AprRecords?.[0]?.timestamp ?? 0n,
230
+ breakdowns: !AprRecords?.[0]?.AprBreakdown?.[0]
231
+ ? []
232
+ : [{ ...AprRecords?.[0]?.AprBreakdown?.[0], value: 0 }],
229
233
  },
230
234
  tvlRecord: TvlRecords?.map(({ id, total, timestamp, TvlBreakdown: breakdowns }) => ({
231
235
  id,
@@ -80,7 +80,7 @@ export declare enum zkSyncCampaigns {
80
80
  SyncSwap_ZK_ETH = "SyncSwap WBTC-M-BTC Stable Pool v2.1 0x45856bd6bb9f076f4c558a4d5932c6c8d832b0d0",
81
81
  SyncSwap_USDCe_ETH = "SyncSwap WBTC-M-BTC Stable Pool v2.1 0x80115c708e12edd42e504c1cd52aea96c547c05c",
82
82
  Woofi_ETH = "Woofi ETH 0x1d686250bbffa9fe120b591f5992dd7fc0fd99a4",
83
- Woofi_USDC = "Woofi USDC 0xa8bbab0ac88382a0f507b9e93cdbe65ffa1f50d1",
83
+ Woofi_USDC = "Woofi USDC 0xDCA324bdD4eBB6b8a1802959324Ce125b5D57921",
84
84
  ZKSwap_wrsETH_ETH = "ZKSwap Finance wrsETH/ETH v2 0.1pct 0xeb9fd198b20dc73e63668b89a735b7dc84e13ea0",
85
85
  ZKSwap_ETH_USDCe = "ZKSwap Finance ETH/USDC.e v2 0.1pct 0x7642e38867860d4512fcce1116e2fb539c5cdd21",
86
86
  ZKSwap_USDC_USDCe_USDT = "ZKSwap Finance USDC/USDC.e/USDT Stable 0.01pct 0x15309aaf4fedf346e5204331027b4ef7b75b1dd7",
@@ -83,7 +83,7 @@ export var zkSyncCampaigns;
83
83
  zkSyncCampaigns["SyncSwap_ZK_ETH"] = "SyncSwap WBTC-M-BTC Stable Pool v2.1 0x45856bd6bb9f076f4c558a4d5932c6c8d832b0d0";
84
84
  zkSyncCampaigns["SyncSwap_USDCe_ETH"] = "SyncSwap WBTC-M-BTC Stable Pool v2.1 0x80115c708e12edd42e504c1cd52aea96c547c05c";
85
85
  zkSyncCampaigns["Woofi_ETH"] = "Woofi ETH 0x1d686250bbffa9fe120b591f5992dd7fc0fd99a4";
86
- zkSyncCampaigns["Woofi_USDC"] = "Woofi USDC 0xa8bbab0ac88382a0f507b9e93cdbe65ffa1f50d1";
86
+ zkSyncCampaigns["Woofi_USDC"] = "Woofi USDC 0xDCA324bdD4eBB6b8a1802959324Ce125b5D57921";
87
87
  zkSyncCampaigns["ZKSwap_wrsETH_ETH"] = "ZKSwap Finance wrsETH/ETH v2 0.1pct 0xeb9fd198b20dc73e63668b89a735b7dc84e13ea0";
88
88
  zkSyncCampaigns["ZKSwap_ETH_USDCe"] = "ZKSwap Finance ETH/USDC.e v2 0.1pct 0x7642e38867860d4512fcce1116e2fb539c5cdd21";
89
89
  zkSyncCampaigns["ZKSwap_USDC_USDCe_USDT"] = "ZKSwap Finance USDC/USDC.e/USDT Stable 0.01pct 0x15309aaf4fedf346e5204331027b4ef7b75b1dd7";
@@ -733,7 +733,7 @@ const ZkSyncInterfaceCampaigns = {
733
733
  {
734
734
  forwarderType: Forwarder.MASTERCHEF,
735
735
  priority: 0,
736
- sender: "0x940350023026b52ae8b1997f15166b2060e04940",
736
+ sender: "0x9F9D043fB77A194b4216784Eb5985c471b979D67",
737
737
  poolID: 28,
738
738
  },
739
739
  ],
@@ -750,7 +750,7 @@ const ZkSyncInterfaceCampaigns = {
750
750
  {
751
751
  forwarderType: Forwarder.MASTERCHEF,
752
752
  priority: 0,
753
- sender: "0x940350023026b52ae8b1997f15166b2060e04940",
753
+ sender: "0x9F9D043fB77A194b4216784Eb5985c471b979D67",
754
754
  poolID: 2,
755
755
  },
756
756
  ],
@@ -767,7 +767,7 @@ const ZkSyncInterfaceCampaigns = {
767
767
  {
768
768
  forwarderType: Forwarder.MASTERCHEF,
769
769
  priority: 0,
770
- sender: "0x940350023026b52ae8b1997f15166b2060e04940",
770
+ sender: "0x9F9D043fB77A194b4216784Eb5985c471b979D67",
771
771
  poolID: 31,
772
772
  },
773
773
  ],
@@ -784,7 +784,7 @@ const ZkSyncInterfaceCampaigns = {
784
784
  {
785
785
  forwarderType: Forwarder.MASTERCHEF,
786
786
  priority: 0,
787
- sender: "0x940350023026b52ae8b1997f15166b2060e04940",
787
+ sender: "0x9F9D043fB77A194b4216784Eb5985c471b979D67",
788
788
  poolID: 19,
789
789
  },
790
790
  ],
@@ -801,7 +801,7 @@ const ZkSyncInterfaceCampaigns = {
801
801
  {
802
802
  forwarderType: Forwarder.MASTERCHEF,
803
803
  priority: 0,
804
- sender: "0x940350023026b52ae8b1997f15166b2060e04940",
804
+ sender: "0x9F9D043fB77A194b4216784Eb5985c471b979D67",
805
805
  poolID: 30,
806
806
  },
807
807
  ],
@@ -819,7 +819,7 @@ const ZkSyncInterfaceCampaigns = {
819
819
  [zkSyncCampaigns.Woofi_USDC]: {
820
820
  campaignType: Campaign.ERC20,
821
821
  computeChainId: ChainId.ZKSYNC,
822
- targetToken: "0xa8bbab0ac88382a0f507b9e93cdbe65ffa1f50d1",
822
+ targetToken: "0xDCA324bdD4eBB6b8a1802959324Ce125b5D57921",
823
823
  hooks: [],
824
824
  whitelist: [],
825
825
  blacklist: [],
@@ -1,5 +1,5 @@
1
1
  import { log } from "../../../utils/logger";
2
- import { Campaign, DistributorService, NETWORK_LABELS, } from "@sdk";
2
+ import { Campaign, DAY, DistributorService, NETWORK_LABELS, } from "@sdk";
3
3
  import moment from "moment";
4
4
  import { BlacklistService } from "../blacklist";
5
5
  import { CacheService } from "../cache";
@@ -313,11 +313,12 @@ export class RewardService {
313
313
  for (const { amount, rewardToken: address, chainId, startTimestamp: start, endTimestamp: end, campaignId, } of dynamicData) {
314
314
  const timespan = Math.abs(end - start);
315
315
  const isWithinTimespan = moment().unix() > start && moment().unix() < end;
316
- const dayspan = Math.max(1, Math.floor(timespan / (60 * 60 * 24)));
316
+ const dayspan = Math.max(1, Math.floor(timespan / DAY));
317
317
  const dailyAmount = isWithinTimespan ? BigInt(amount) / BigInt(dayspan) : BigInt(0);
318
+ const campaignIdInDb = CampaignService.hashId({ campaignId, distributionChain: chainId });
318
319
  const campaignDailyValue = await TokenService.getValue([{ amount: dailyAmount, address, chainId }]);
319
320
  breakdowns.push({
320
- campaignId: CampaignService.hashId({ campaignId, distributionChain: chainId }),
321
+ campaignId: campaignIdInDb,
321
322
  value: campaignDailyValue,
322
323
  amount: dailyAmount,
323
324
  token: await TokenService.findUniqueOrThrow({