@merkl/api 0.10.273 → 0.10.274
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.
@@ -224,8 +224,10 @@ export class OpportunityService {
|
|
224
224
|
}))?.[0] ?? undefined)
|
225
225
|
: {
|
226
226
|
cumulated: 0,
|
227
|
-
timestamp: AprRecords[0]
|
228
|
-
breakdowns:
|
227
|
+
timestamp: AprRecords?.[0]?.timestamp ?? 0n,
|
228
|
+
breakdowns: !AprRecords?.[0]?.AprBreakdown?.[0]
|
229
|
+
? []
|
230
|
+
: [{ ...AprRecords?.[0]?.AprBreakdown?.[0], value: 0 }],
|
229
231
|
},
|
230
232
|
tvlRecord: TvlRecords?.map(({ id, total, timestamp, TvlBreakdown: breakdowns }) => ({
|
231
233
|
id,
|
@@ -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 /
|
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:
|
321
|
+
campaignId: campaignIdInDb,
|
321
322
|
value: campaignDailyValue,
|
322
323
|
amount: dailyAmount,
|
323
324
|
token: await TokenService.findUniqueOrThrow({
|