@merkl/api 0.19.35 → 0.19.36
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/dist/src/eden/index.d.ts +438 -25
- package/dist/src/index.d.ts +122 -5
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +14 -6
- package/dist/src/modules/v4/campaign/campaign.controller.js +13 -6
- package/dist/src/modules/v4/opportunity/opportunity.repository.js +2 -2
- package/dist/src/modules/v4/opportunity/opportunity.service.js +2 -2
- package/dist/src/modules/v4/reward/reward.controller.d.ts +123 -1
- package/dist/src/modules/v4/reward/reward.controller.js +14 -2
- package/dist/src/modules/v4/reward/reward.model.d.ts +7 -0
- package/dist/src/modules/v4/reward/reward.model.js +6 -0
- package/dist/src/modules/v4/reward/reward.repository.d.ts +9 -1
- package/dist/src/modules/v4/reward/reward.repository.js +27 -0
- package/dist/src/modules/v4/reward/reward.service.d.ts +165 -0
- package/dist/src/modules/v4/reward/reward.service.js +50 -0
- package/dist/src/modules/v4/router.d.ts +122 -5
- package/dist/src/modules/v4/token/token.service.js +9 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -8,6 +8,171 @@ export declare abstract class RewardService {
|
|
8
8
|
static hashId(root: string, recipient: string, rewardTokenId: string): string;
|
9
9
|
static hashDailyRewardsRecordId(opportunityId: string, timestamp: bigint): string;
|
10
10
|
static createManyReward(rewards: CreateManyRewardModel): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
|
11
|
+
static getTotalDistributedByOpportunities(since: number): Promise<Map<{
|
12
|
+
apr: number;
|
13
|
+
aprRecord: {
|
14
|
+
cumulated: number;
|
15
|
+
timestamp: bigint;
|
16
|
+
breakdowns: {
|
17
|
+
id: number;
|
18
|
+
type: import("@db/api").$Enums.AprType;
|
19
|
+
identifier: string;
|
20
|
+
value: number;
|
21
|
+
aprRecordId: string;
|
22
|
+
}[];
|
23
|
+
};
|
24
|
+
tvlRecord: {
|
25
|
+
id: string;
|
26
|
+
total: number;
|
27
|
+
timestamp: bigint;
|
28
|
+
breakdowns: {
|
29
|
+
id: number;
|
30
|
+
type: import("@db/api").$Enums.TvlType;
|
31
|
+
identifier: string;
|
32
|
+
value: number;
|
33
|
+
tvlRecordId: string;
|
34
|
+
}[];
|
35
|
+
};
|
36
|
+
rewardsRecord: {
|
37
|
+
id: string;
|
38
|
+
total: number;
|
39
|
+
timestamp: bigint;
|
40
|
+
breakdowns: {
|
41
|
+
id: number;
|
42
|
+
value: number;
|
43
|
+
campaignId: string;
|
44
|
+
dailyRewardsRecordId: string;
|
45
|
+
token: {
|
46
|
+
symbol: string;
|
47
|
+
id: string;
|
48
|
+
name: string | null;
|
49
|
+
icon: string;
|
50
|
+
address: string;
|
51
|
+
chainId: number;
|
52
|
+
decimals: number;
|
53
|
+
displaySymbol: string;
|
54
|
+
verified: boolean;
|
55
|
+
isTest: boolean;
|
56
|
+
isPoint: boolean;
|
57
|
+
isNative: boolean;
|
58
|
+
price: number | null;
|
59
|
+
};
|
60
|
+
amount: bigint;
|
61
|
+
}[];
|
62
|
+
};
|
63
|
+
campaigns: {
|
64
|
+
params: any;
|
65
|
+
chain: {
|
66
|
+
id: number;
|
67
|
+
name: string;
|
68
|
+
icon: string;
|
69
|
+
};
|
70
|
+
endTimestamp: number;
|
71
|
+
startTimestamp: number;
|
72
|
+
rewardToken: {
|
73
|
+
symbol: string;
|
74
|
+
id: string;
|
75
|
+
name: string | null;
|
76
|
+
icon: string;
|
77
|
+
address: string;
|
78
|
+
chainId: number;
|
79
|
+
decimals: number;
|
80
|
+
verified: boolean;
|
81
|
+
isTest: boolean;
|
82
|
+
isPoint: boolean;
|
83
|
+
isNative: boolean;
|
84
|
+
} & {
|
85
|
+
price?: number | null | undefined;
|
86
|
+
};
|
87
|
+
distributionChain: {
|
88
|
+
id: number;
|
89
|
+
name: string;
|
90
|
+
icon: string;
|
91
|
+
} | undefined;
|
92
|
+
campaignStatus: {
|
93
|
+
computedUntil: number;
|
94
|
+
processingStarted: number;
|
95
|
+
error: string;
|
96
|
+
status: import("@db/api").$Enums.RunStatus;
|
97
|
+
details: import("database/api/.generated/runtime/library").JsonValue;
|
98
|
+
campaignId: string;
|
99
|
+
} | undefined;
|
100
|
+
creatorAddress: string;
|
101
|
+
creator: {
|
102
|
+
tags: string[];
|
103
|
+
address: string;
|
104
|
+
creatorId: string | null;
|
105
|
+
};
|
106
|
+
createdAt: string;
|
107
|
+
Opportunity: {
|
108
|
+
id: string;
|
109
|
+
name: string;
|
110
|
+
type: string;
|
111
|
+
status: import("@db/api").$Enums.Status;
|
112
|
+
tags: string[];
|
113
|
+
identifier: string;
|
114
|
+
action: import("@db/api").$Enums.OpportunityAction;
|
115
|
+
chainId: number;
|
116
|
+
depositUrl: string | null;
|
117
|
+
mainProtocolId: string | null;
|
118
|
+
tvl: number;
|
119
|
+
apr: number;
|
120
|
+
dailyRewards: number;
|
121
|
+
};
|
122
|
+
id: string;
|
123
|
+
type: string;
|
124
|
+
subType: number | null;
|
125
|
+
computeChainId: number;
|
126
|
+
distributionChainId: number;
|
127
|
+
campaignId: string;
|
128
|
+
rewardTokenId: string;
|
129
|
+
amount: string;
|
130
|
+
opportunityId: string;
|
131
|
+
}[] | undefined;
|
132
|
+
id: string;
|
133
|
+
depositUrl: string | undefined;
|
134
|
+
tokens: ({
|
135
|
+
symbol: string;
|
136
|
+
id: string;
|
137
|
+
name: string | null;
|
138
|
+
icon: string;
|
139
|
+
address: string;
|
140
|
+
chainId: number;
|
141
|
+
decimals: number;
|
142
|
+
verified: boolean;
|
143
|
+
isTest: boolean;
|
144
|
+
isPoint: boolean;
|
145
|
+
isNative: boolean;
|
146
|
+
} & {
|
147
|
+
price?: number | null | undefined;
|
148
|
+
})[];
|
149
|
+
chain: {
|
150
|
+
id: number;
|
151
|
+
name: string;
|
152
|
+
icon: string;
|
153
|
+
};
|
154
|
+
protocol: {
|
155
|
+
id: string;
|
156
|
+
name: string;
|
157
|
+
url: string;
|
158
|
+
description: string;
|
159
|
+
tags: string[];
|
160
|
+
icon: string;
|
161
|
+
} | undefined;
|
162
|
+
name: string;
|
163
|
+
type: string;
|
164
|
+
status: import("@db/api").$Enums.Status;
|
165
|
+
tags: string[];
|
166
|
+
identifier: string;
|
167
|
+
action: import("@db/api").$Enums.OpportunityAction;
|
168
|
+
chainId: number;
|
169
|
+
tvl: number;
|
170
|
+
dailyRewards: number;
|
171
|
+
}, number>>;
|
172
|
+
static getTotalDistributed(since: number): Promise<number>;
|
173
|
+
static getTotalDistributedByChains(since: number): Promise<any>;
|
174
|
+
static getTotalDistributedByProtocol(since: number): Promise<any>;
|
175
|
+
static getTotalDistributedByType(since: number): Promise<any>;
|
11
176
|
/**
|
12
177
|
* Format the reward breakdown to conform to its resource model declaration
|
13
178
|
* @param breakdown straight from db
|
@@ -20,6 +20,56 @@ export class RewardService {
|
|
20
20
|
static async createManyReward(rewards) {
|
21
21
|
return await RewardRepository.createManyReward(rewards);
|
22
22
|
}
|
23
|
+
static async getTotalDistributedByOpportunities(since) {
|
24
|
+
const opportunities = await OpportunityService.findMany({ items: 0 });
|
25
|
+
const promiseArray = [];
|
26
|
+
let i = 0;
|
27
|
+
const oppToDailyRewards = new Map();
|
28
|
+
for (i = 0; i < opportunities.length; i++) {
|
29
|
+
promiseArray.push(RewardRepository.sumDailyRewardsAvgByOpportunity(since, opportunities[i].id));
|
30
|
+
}
|
31
|
+
const result = await Promise.all(promiseArray);
|
32
|
+
i = 0;
|
33
|
+
for (i = 0; i < result.length; i++) {
|
34
|
+
// need an upper threshold bc certain opportunities have crazy daily rewards (cf. vicuna)
|
35
|
+
if (result[i] !== null && result[i] > 0 && result[i] <= 1_000_000_000)
|
36
|
+
oppToDailyRewards.set(opportunities[i], result[i]);
|
37
|
+
}
|
38
|
+
return oppToDailyRewards;
|
39
|
+
}
|
40
|
+
static async getTotalDistributed(since) {
|
41
|
+
const oppToDailyRewards = await RewardService.getTotalDistributedByOpportunities(since);
|
42
|
+
return oppToDailyRewards.values().reduce((prev, curr) => prev + curr, 0);
|
43
|
+
}
|
44
|
+
static async getTotalDistributedByChains(since) {
|
45
|
+
const oppToDailyRewards = await RewardService.getTotalDistributedByOpportunities(since);
|
46
|
+
const chainsToDailyRewards = new Map();
|
47
|
+
for (const [opp, dr] of oppToDailyRewards.entries()) {
|
48
|
+
const dailyRewards = chainsToDailyRewards.get(opp.chainId) === undefined ? dr : chainsToDailyRewards.get(opp.chainId) + dr;
|
49
|
+
chainsToDailyRewards.set(opp.chainId, dailyRewards);
|
50
|
+
}
|
51
|
+
return Object.fromEntries(chainsToDailyRewards);
|
52
|
+
}
|
53
|
+
static async getTotalDistributedByProtocol(since) {
|
54
|
+
const oppToDailyRewards = await RewardService.getTotalDistributedByOpportunities(since);
|
55
|
+
const protocolToDailyRewards = new Map();
|
56
|
+
for (const [opp, dr] of oppToDailyRewards.entries()) {
|
57
|
+
const dailyRewards = protocolToDailyRewards.get(opp.protocol?.id) === undefined
|
58
|
+
? dr
|
59
|
+
: protocolToDailyRewards.get(opp.protocol?.id) + dr;
|
60
|
+
protocolToDailyRewards.set(opp.protocol?.id, dailyRewards);
|
61
|
+
}
|
62
|
+
return Object.fromEntries(protocolToDailyRewards);
|
63
|
+
}
|
64
|
+
static async getTotalDistributedByType(since) {
|
65
|
+
const oppToDailyRewards = await RewardService.getTotalDistributedByOpportunities(since);
|
66
|
+
const typeToDailyRewards = new Map();
|
67
|
+
for (const [opp, dr] of oppToDailyRewards.entries()) {
|
68
|
+
const dailyRewards = typeToDailyRewards.get(opp.type) === undefined ? dr : typeToDailyRewards.get(opp.type) + dr;
|
69
|
+
typeToDailyRewards.set(opp.type, dailyRewards);
|
70
|
+
}
|
71
|
+
return Object.fromEntries(typeToDailyRewards);
|
72
|
+
}
|
23
73
|
/**
|
24
74
|
* Format the reward breakdown to conform to its resource model declaration
|
25
75
|
* @param breakdown straight from db
|
@@ -1622,7 +1622,9 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1622
1622
|
withOpportunity?: boolean | undefined;
|
1623
1623
|
createdAfter?: Date | null | undefined;
|
1624
1624
|
};
|
1625
|
-
headers:
|
1625
|
+
headers: {
|
1626
|
+
authorization: string;
|
1627
|
+
};
|
1626
1628
|
response: {
|
1627
1629
|
200: {
|
1628
1630
|
[x: string]: number;
|
@@ -1634,7 +1636,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1634
1636
|
} & {
|
1635
1637
|
campaigns: {
|
1636
1638
|
count: {
|
1637
|
-
"by-
|
1639
|
+
"by-types": {
|
1638
1640
|
get: {
|
1639
1641
|
body: unknown;
|
1640
1642
|
params: {};
|
@@ -1662,7 +1664,9 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1662
1664
|
withOpportunity?: boolean | undefined;
|
1663
1665
|
createdAfter?: Date | null | undefined;
|
1664
1666
|
};
|
1665
|
-
headers:
|
1667
|
+
headers: {
|
1668
|
+
authorization: string;
|
1669
|
+
};
|
1666
1670
|
response: {
|
1667
1671
|
200: {
|
1668
1672
|
[x: string]: number;
|
@@ -1675,7 +1679,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1675
1679
|
} & {
|
1676
1680
|
campaigns: {
|
1677
1681
|
count: {
|
1678
|
-
"by-
|
1682
|
+
"by-protocols": {
|
1679
1683
|
get: {
|
1680
1684
|
body: unknown;
|
1681
1685
|
params: {};
|
@@ -1703,7 +1707,9 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1703
1707
|
withOpportunity?: boolean | undefined;
|
1704
1708
|
createdAfter?: Date | null | undefined;
|
1705
1709
|
};
|
1706
|
-
headers:
|
1710
|
+
headers: {
|
1711
|
+
authorization: string;
|
1712
|
+
};
|
1707
1713
|
response: {
|
1708
1714
|
200: {
|
1709
1715
|
[x: string]: number;
|
@@ -2531,6 +2537,117 @@ export declare const v4: Elysia<"/v4", false, {
|
|
2531
2537
|
};
|
2532
2538
|
};
|
2533
2539
|
};
|
2540
|
+
} & {
|
2541
|
+
rewards: {
|
2542
|
+
total: {
|
2543
|
+
distributed: {
|
2544
|
+
get: {
|
2545
|
+
body: unknown;
|
2546
|
+
params: {};
|
2547
|
+
query: {
|
2548
|
+
since: Date;
|
2549
|
+
};
|
2550
|
+
headers: {
|
2551
|
+
authorization: string;
|
2552
|
+
};
|
2553
|
+
response: {
|
2554
|
+
200: number;
|
2555
|
+
};
|
2556
|
+
};
|
2557
|
+
};
|
2558
|
+
};
|
2559
|
+
};
|
2560
|
+
} & {
|
2561
|
+
rewards: {
|
2562
|
+
total: {
|
2563
|
+
distributed: {
|
2564
|
+
"by-opportunities": {
|
2565
|
+
get: {
|
2566
|
+
body: unknown;
|
2567
|
+
params: {};
|
2568
|
+
query: {
|
2569
|
+
since: Date;
|
2570
|
+
};
|
2571
|
+
headers: {
|
2572
|
+
authorization: string;
|
2573
|
+
};
|
2574
|
+
response: {
|
2575
|
+
200: string;
|
2576
|
+
};
|
2577
|
+
};
|
2578
|
+
};
|
2579
|
+
};
|
2580
|
+
};
|
2581
|
+
};
|
2582
|
+
} & {
|
2583
|
+
rewards: {
|
2584
|
+
total: {
|
2585
|
+
distributed: {
|
2586
|
+
"by-chains": {
|
2587
|
+
get: {
|
2588
|
+
body: unknown;
|
2589
|
+
params: {};
|
2590
|
+
query: {
|
2591
|
+
since: Date;
|
2592
|
+
};
|
2593
|
+
headers: {
|
2594
|
+
authorization: string;
|
2595
|
+
};
|
2596
|
+
response: {
|
2597
|
+
[x: string]: any;
|
2598
|
+
200: any;
|
2599
|
+
};
|
2600
|
+
};
|
2601
|
+
};
|
2602
|
+
};
|
2603
|
+
};
|
2604
|
+
};
|
2605
|
+
} & {
|
2606
|
+
rewards: {
|
2607
|
+
total: {
|
2608
|
+
distributed: {
|
2609
|
+
"by-types": {
|
2610
|
+
get: {
|
2611
|
+
body: unknown;
|
2612
|
+
params: {};
|
2613
|
+
query: {
|
2614
|
+
since: Date;
|
2615
|
+
};
|
2616
|
+
headers: {
|
2617
|
+
authorization: string;
|
2618
|
+
};
|
2619
|
+
response: {
|
2620
|
+
[x: string]: any;
|
2621
|
+
200: any;
|
2622
|
+
};
|
2623
|
+
};
|
2624
|
+
};
|
2625
|
+
};
|
2626
|
+
};
|
2627
|
+
};
|
2628
|
+
} & {
|
2629
|
+
rewards: {
|
2630
|
+
total: {
|
2631
|
+
distributed: {
|
2632
|
+
"by-protocols": {
|
2633
|
+
get: {
|
2634
|
+
body: unknown;
|
2635
|
+
params: {};
|
2636
|
+
query: {
|
2637
|
+
since: Date;
|
2638
|
+
};
|
2639
|
+
headers: {
|
2640
|
+
authorization: string;
|
2641
|
+
};
|
2642
|
+
response: {
|
2643
|
+
[x: string]: any;
|
2644
|
+
200: any;
|
2645
|
+
};
|
2646
|
+
};
|
2647
|
+
};
|
2648
|
+
};
|
2649
|
+
};
|
2650
|
+
};
|
2534
2651
|
};
|
2535
2652
|
} & {
|
2536
2653
|
v4: {
|
@@ -70,6 +70,15 @@ export class TokenService {
|
|
70
70
|
}
|
71
71
|
static async fetchOnChain(token) {
|
72
72
|
const onchainData = await TokenRepository.getTokenInfo(token);
|
73
|
+
try {
|
74
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
|
75
|
+
onchainData.name = Buffer.from(onchainData.name.replace(/\u0000/g, ""), "utf-8").toString("utf-8");
|
76
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
|
77
|
+
onchainData.symbol = Buffer.from(onchainData.symbol.replace(/\u0000/g, ""), "utf-8").toString("utf-8");
|
78
|
+
}
|
79
|
+
catch (e) {
|
80
|
+
console.error(e);
|
81
|
+
}
|
73
82
|
return {
|
74
83
|
chainId: token.chainId,
|
75
84
|
address: token.address,
|