@merkl/api 0.15.41 → 0.15.43

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,19 +46,29 @@ export class ChainRepository {
46
46
  * @returns
47
47
  */
48
48
  static async create(data) {
49
- const explorerId = await ExplorerRepository.create(data.id, data.explorerType, data.explorerUrl);
50
- return apiDbClient.chain.create({
49
+ await apiDbClient.chain.create({
51
50
  data: {
52
51
  id: data.id,
53
52
  icon: data.icon,
54
53
  name: data.name,
55
- Explorer: { connect: { id: explorerId.id } },
56
54
  },
57
55
  });
56
+ await ExplorerRepository.create(data.id, data.explorerType, data.explorerUrl);
57
+ return await ChainRepository.findUniqueOrThrow(data.id);
58
58
  }
59
59
  static async findMany() {
60
60
  return apiDbClient.chain.findMany();
61
61
  }
62
+ static async findUniqueOrThrow(id) {
63
+ return apiDbClient.chain.findUniqueOrThrow({
64
+ where: {
65
+ id,
66
+ },
67
+ select: {
68
+ Explorer: true,
69
+ },
70
+ });
71
+ }
62
72
  /**
63
73
  * Fetches the campaign dynamic data for a v3 campaign onchain
64
74
  * @param chainId
@@ -40,9 +40,12 @@ export declare abstract class ChainService {
40
40
  */
41
41
  static getSupportedIds(): Promise<number[]>;
42
42
  static create(chain: CreateChainModel): Promise<{
43
- name: string;
44
- id: number;
45
- icon: string;
43
+ Explorer: {
44
+ type: import("../../../../database/api/.generated").$Enums.ExplorerType;
45
+ url: string;
46
+ id: string;
47
+ chainId: number;
48
+ }[];
46
49
  }>;
47
50
  static update(id: number, data: UpdateChainModel): Promise<{
48
51
  name: string;
@@ -25,14 +25,46 @@ export declare abstract class ProtocolRepository {
25
25
  tags: string[];
26
26
  icon: string;
27
27
  }[]>;
28
- static findMany(query: GetProtocolsQueryModel): Promise<{
28
+ static findMany(query: GetProtocolsQueryModel): Promise<({
29
+ MainOpportunities: ({
30
+ Campaigns: {
31
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
32
+ id: string;
33
+ params: import("database/api/.generated/runtime/library").JsonValue;
34
+ subType: number | null;
35
+ startTimestamp: bigint;
36
+ endTimestamp: bigint;
37
+ computeChainId: number;
38
+ distributionChainId: number;
39
+ campaignId: string;
40
+ rewardTokenId: string;
41
+ amount: string;
42
+ opportunityId: string;
43
+ creatorAddress: string;
44
+ }[];
45
+ } & {
46
+ name: string;
47
+ type: import("../../../../database/api/.generated").$Enums.CampaignType;
48
+ id: string;
49
+ status: import("../../../../database/api/.generated").$Enums.Status;
50
+ tags: string[];
51
+ identifier: string;
52
+ chainId: number;
53
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
54
+ depositUrl: string | null;
55
+ mainProtocolId: string | null;
56
+ tvl: number;
57
+ apr: number;
58
+ dailyRewards: number;
59
+ })[];
60
+ } & {
29
61
  name: string;
30
62
  url: string;
31
63
  description: string;
32
64
  id: string;
33
65
  tags: string[];
34
66
  icon: string;
35
- }[]>;
67
+ })[]>;
36
68
  static countMany(query: GetProtocolsQueryModel): Promise<number>;
37
69
  static update(id: string, data: UpdateProtocolModel): Promise<{
38
70
  name: string;
@@ -52,6 +52,19 @@ export class ProtocolRepository {
52
52
  take: items,
53
53
  skip: page * items,
54
54
  ...args,
55
+ include: {
56
+ MainOpportunities: {
57
+ include: {
58
+ Campaigns: {
59
+ where: {
60
+ endTimestamp: {
61
+ gt: BigInt(Math.floor(Date.now() / 1000)),
62
+ },
63
+ },
64
+ },
65
+ },
66
+ },
67
+ },
55
68
  });
56
69
  }
57
70
  static async countMany(query) {
@@ -39,7 +39,13 @@ export class ProtocolService {
39
39
  }[amm];
40
40
  }
41
41
  static async findMany(query) {
42
- return ProtocolRepository.findMany(query);
42
+ const protocols = await ProtocolRepository.findMany(query);
43
+ const enrichedProtocols = protocols.map(({ MainOpportunities, ...protocol }) => ({
44
+ ...protocol,
45
+ dailyReward: MainOpportunities.reduce((sum, opportunity) => sum + opportunity.dailyRewards, 0),
46
+ numberOfCampaigns: MainOpportunities.reduce((sum, opportunity) => sum + opportunity.Campaigns.length, 0),
47
+ }));
48
+ return enrichedProtocols;
43
49
  }
44
50
  static async countMany(query) {
45
51
  return ProtocolRepository.countMany(query);
@@ -1996,9 +1996,12 @@ export declare const v4: Elysia<"/v4", false, {
1996
1996
  };
1997
1997
  response: {
1998
1998
  200: {
1999
- name: string;
2000
- id: number;
2001
- icon: string;
1999
+ Explorer: {
2000
+ type: import("../../../database/api/.generated").$Enums.ExplorerType;
2001
+ url: string;
2002
+ id: string;
2003
+ chainId: number;
2004
+ }[];
2002
2005
  };
2003
2006
  };
2004
2007
  };
@@ -57,7 +57,7 @@ export class StatusService {
57
57
  }
58
58
  static async findUpdatesAndDelays() {
59
59
  const merklRoots = await MerklRootService.fetchAll();
60
- const delayedCampaignPromises = Promise.allSettled(Object.keys(merklRoots).map(chainId => StatusService.findManyDelay({ chainId: Number.parseInt(chainId), delayLowerBound: 8 * HOUR })));
60
+ const delayedCampaignPromises = Promise.allSettled(Object.keys(merklRoots).map(chainId => StatusService.findManyDelay({ chainId: Number.parseInt(chainId), delayLowerBound: 9 * HOUR })));
61
61
  const liveCampaignPromises = await Promise.allSettled(Object.keys(merklRoots).map(chainId => CampaignService.countLives(Number.parseInt(chainId))));
62
62
  const delayedCampaignArray = await delayedCampaignPromises;
63
63
  const liveCampaignArray = await liveCampaignPromises;