@merkl/api 0.20.5 → 0.20.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.
@@ -46,6 +46,8 @@ const main = async () => {
46
46
  else if (status !== "LIVE" && campaign.startTimestamp > now)
47
47
  status = "SOON";
48
48
  }
49
+ if (status === "PAST" && opportunity.apr !== 0)
50
+ await OpportunityService.update(opportunity.id, { status, apr: 0 });
49
51
  if (opportunity.status !== status)
50
52
  await OpportunityService.updateStatus(opportunity.id, status);
51
53
  }
@@ -102,11 +102,8 @@ export class DynamicDataService {
102
102
  const campaignTypeToCampaigns = new Map();
103
103
  for (const campaign of campaigns) {
104
104
  const type = campaign.campaignType;
105
- let campaigns = campaignTypeToCampaigns.get(campaign.campaignType);
106
- if (!campaigns)
107
- campaigns = [campaign];
108
- else
109
- campaigns.push(campaign);
105
+ const campaigns = campaignTypeToCampaigns.get(campaign.campaignType) ?? [];
106
+ campaigns.push(campaign);
110
107
  campaignTypeToCampaigns.set(type, campaigns);
111
108
  }
112
109
  const dynamicDataArray = [];
@@ -4,7 +4,7 @@ import { type AprRecord } from "../apr";
4
4
  import type { Campaign } from "../campaign";
5
5
  import { type DailyRewardsRecord } from "../reward";
6
6
  import { type TvlRecord } from "../tvl";
7
- import type { CreateOpportunityModel, GetOpportunitiesQueryModel, UpdateOpportunityModel } from "./opportunity.model";
7
+ import type { CreateOpportunityModel, GetOpportunitiesQueryModel, Opportunity, UpdateOpportunityModel } from "./opportunity.model";
8
8
  export declare abstract class OpportunityRepository {
9
9
  #private;
10
10
  static create(newOpp: CreateOpportunityModel, upsert?: boolean): Promise<{
@@ -981,7 +981,7 @@ export declare abstract class OpportunityRepository {
981
981
  static aggregateMax(field: keyof Prisma.OpportunityMaxAggregateInputType, query: GetOpportunitiesQueryModel): Promise<{
982
982
  max: string;
983
983
  }>;
984
- static update(id: string, data: UpdateOpportunityModel): Promise<{
984
+ static update(id: string, data: Partial<Opportunity["raw"]>): Promise<{
985
985
  id: string;
986
986
  name: string;
987
987
  type: string;
@@ -1,7 +1,7 @@
1
1
  import { type CreateCampaignModel, type GetCampaignQueryModel } from "@/modules/v4/campaign";
2
2
  import { Prisma, Status } from "@db/api";
3
3
  import { type ChainId, type MerklChainId } from "@sdk";
4
- import type { CreateOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, OpportunityResourceModel, OpportunityUnique, UpdateOpportunityModel } from "./opportunity.model";
4
+ import type { CreateOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, Opportunity, OpportunityResourceModel, OpportunityUnique, UpdateOpportunityModel } from "./opportunity.model";
5
5
  import { OpportunityRepository } from "./opportunity.repository";
6
6
  export declare abstract class OpportunityService {
7
7
  #private;
@@ -945,7 +945,7 @@ export declare abstract class OpportunityService {
945
945
  static aggregateMax(query: GetOpportunitiesQueryModel, field: keyof Prisma.OpportunityMaxAggregateInputType): Promise<{
946
946
  max: string;
947
947
  }>;
948
- static update(id: string, data: UpdateOpportunityModel): Promise<{
948
+ static update(id: string, data: Partial<Opportunity["raw"]>): Promise<{
949
949
  id: string;
950
950
  name: string;
951
951
  type: string;
@@ -206,7 +206,7 @@ export class OpportunityService {
206
206
  };
207
207
  const formated = {
208
208
  ...OpportunityService.formatResponseBase(opp),
209
- apr: opp.status === "LIVE" ? opp.apr : 0,
209
+ apr: opp.apr,
210
210
  aprRecord,
211
211
  tvlRecord: TvlRecords?.map(({ id, total, timestamp, TvlBreakdown: breakdowns }) => ({
212
212
  id,