@merkl/api 0.16.32 → 0.16.33

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.
package/package.json CHANGED
@@ -102,5 +102,5 @@
102
102
  "access": "public",
103
103
  "registry": "https://registry.npmjs.org/"
104
104
  },
105
- "version": "v0.16.32"
105
+ "version": "v0.16.33"
106
106
  }
@@ -1,2 +0,0 @@
1
- import type { Campaign, CampaignParameters, MerklChainId } from "@sdk";
2
- export declare const getLastEligibilityRatio: (campaign: CampaignParameters<Campaign>, chainId: MerklChainId, currentRoot: string, backupCampaignIds: string[]) => Promise<number>;
@@ -1,65 +0,0 @@
1
- import { apiDbClient } from "src/utils/prisma";
2
- export const getLastEligibilityRatio = async (campaign, chainId, currentRoot, backupCampaignIds) => {
3
- if (campaign.campaignId === "0x6acb7a8cd2646f18e6e438658273bbee1ed6d664c19779d144cc339decf240ca") {
4
- return 2;
5
- }
6
- let lastEligibilityRatio = 1; // By default it's 1
7
- try {
8
- const auxLastEligibilityRatioString = (await apiDbClient.rewardBreakdown.findFirst({
9
- select: {
10
- auxiliaryData1: true,
11
- },
12
- where: {
13
- Reward: {
14
- RewardToken: {
15
- chainId,
16
- },
17
- root: currentRoot,
18
- },
19
- campaignId: campaign.campaignId,
20
- },
21
- orderBy: {
22
- amount: "desc",
23
- },
24
- }))?.auxiliaryData1;
25
- let auxLastEligibilityRatio = !!auxLastEligibilityRatioString
26
- ? Number.parseFloat(auxLastEligibilityRatioString)
27
- : null;
28
- // If the last eligibility ratio is 0 it means the campaign do not use eligibility
29
- if (auxLastEligibilityRatio === undefined || auxLastEligibilityRatio === null) {
30
- // Otherwise we search in the backup campaigns
31
- for (const campaignId of backupCampaignIds) {
32
- const auxLastEligibilityRatioString = (await apiDbClient.rewardBreakdown.findFirst({
33
- select: {
34
- auxiliaryData1: true,
35
- },
36
- where: {
37
- Reward: {
38
- RewardToken: {
39
- chainId,
40
- },
41
- root: currentRoot,
42
- },
43
- campaignId: campaignId,
44
- },
45
- orderBy: {
46
- amount: "desc",
47
- },
48
- }))?.auxiliaryData1;
49
- auxLastEligibilityRatio = !!auxLastEligibilityRatioString
50
- ? Number.parseFloat(auxLastEligibilityRatioString)
51
- : null;
52
- if (!!auxLastEligibilityRatio)
53
- break;
54
- }
55
- }
56
- if (!!auxLastEligibilityRatio) {
57
- lastEligibilityRatio = auxLastEligibilityRatio * 100;
58
- }
59
- else if (auxLastEligibilityRatio === 0) {
60
- lastEligibilityRatio = 1;
61
- }
62
- }
63
- catch { }
64
- return lastEligibilityRatio;
65
- };