@merkl/api 0.20.122 → 0.20.124
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 +169 -10
- package/dist/src/engine/deprecated/erc20SubTypeProcessors/implementations/EulerBorrowProcessor.js +0 -1
- package/dist/src/engine/implementations/Erc20/subTypes/factories.js +3 -0
- package/dist/src/engine/implementations/{Euler → Erc20/subTypes/implementations/euler}/metadata.d.ts +4 -5
- package/dist/src/engine/implementations/Erc20/subTypes/implementations/euler/metadata.js +35 -0
- package/dist/src/engine/metadata/factory.js +1 -2
- package/dist/src/index.d.ts +55 -2
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +17 -0
- package/dist/src/modules/v4/campaign/campaign.service.d.ts +18 -1
- package/dist/src/modules/v4/campaign/campaign.service.js +2 -1
- package/dist/src/modules/v4/campaign/campaign.test.controller.d.ts +34 -0
- package/dist/src/modules/v4/opportunity/opportunity.service.js +35 -19
- package/dist/src/modules/v4/programPayload/programPayload.controller.d.ts +1 -1
- package/dist/src/modules/v4/router.d.ts +55 -2
- package/dist/src/modules/v4/token/token.controller.d.ts +3 -1
- package/dist/src/modules/v4/token/token.controller.js +4 -1
- package/dist/src/modules/v4/token/token.service.d.ts +3 -1
- package/dist/src/modules/v4/token/token.service.js +9 -7
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/engine/implementations/Euler/metadata.js +0 -42
@@ -165,6 +165,39 @@ export class OpportunityService {
|
|
165
165
|
}
|
166
166
|
static formatResponse(opportunity) {
|
167
167
|
const { DailyRewardsRecords, AprRecords, TvlRecords, Campaigns, ...opp } = opportunity;
|
168
|
+
const rewardsRecord = DailyRewardsRecords.length === 0
|
169
|
+
? {
|
170
|
+
id: "",
|
171
|
+
total: 0,
|
172
|
+
timestamp: 0n,
|
173
|
+
breakdowns: [],
|
174
|
+
}
|
175
|
+
: (DailyRewardsRecords?.map(({ id, total, timestamp, DailyRewardsBreakdown: breakdowns }) => ({
|
176
|
+
id,
|
177
|
+
total,
|
178
|
+
timestamp,
|
179
|
+
breakdowns: breakdowns.map(({ Campaign, ...breakdown }) => {
|
180
|
+
return {
|
181
|
+
token: Campaign.RewardToken,
|
182
|
+
amount: CampaignService.getDailyAmount(Campaign.startTimestamp, Campaign.endTimestamp, BigInt(Campaign.amount)),
|
183
|
+
distributionType: Campaign.distributionType,
|
184
|
+
...breakdown,
|
185
|
+
};
|
186
|
+
}),
|
187
|
+
}))?.[0] ?? undefined);
|
188
|
+
const tvlRecord = TvlRecords.length === 0
|
189
|
+
? {
|
190
|
+
id: "",
|
191
|
+
total: 0,
|
192
|
+
timestamp: 0n,
|
193
|
+
breakdowns: [],
|
194
|
+
}
|
195
|
+
: (TvlRecords?.map(({ id, total, timestamp, TvlBreakdown: breakdowns }) => ({
|
196
|
+
id,
|
197
|
+
total,
|
198
|
+
timestamp,
|
199
|
+
breakdowns,
|
200
|
+
}))?.[0] ?? undefined);
|
168
201
|
const aprRecord = opp.status === "LIVE"
|
169
202
|
? (AprRecords?.map(({ cumulated, timestamp, AprBreakdown: breakdowns }) => ({
|
170
203
|
cumulated,
|
@@ -180,25 +213,8 @@ export class OpportunityService {
|
|
180
213
|
...OpportunityService.formatResponseBase(opp),
|
181
214
|
apr: opp.apr,
|
182
215
|
aprRecord,
|
183
|
-
tvlRecord
|
184
|
-
|
185
|
-
total,
|
186
|
-
timestamp,
|
187
|
-
breakdowns,
|
188
|
-
}))?.[0] ?? undefined,
|
189
|
-
rewardsRecord: DailyRewardsRecords?.map(({ id, total, timestamp, DailyRewardsBreakdown: breakdowns }) => ({
|
190
|
-
id,
|
191
|
-
total,
|
192
|
-
timestamp,
|
193
|
-
breakdowns: breakdowns.map(({ Campaign, ...breakdown }) => {
|
194
|
-
return {
|
195
|
-
token: Campaign.RewardToken,
|
196
|
-
amount: CampaignService.getDailyAmount(Campaign.startTimestamp, Campaign.endTimestamp, BigInt(Campaign.amount)),
|
197
|
-
distributionType: Campaign.distributionType,
|
198
|
-
...breakdown,
|
199
|
-
};
|
200
|
-
}),
|
201
|
-
}))?.[0] ?? undefined,
|
216
|
+
tvlRecord,
|
217
|
+
rewardsRecord,
|
202
218
|
campaigns: !!Campaigns ? Campaigns?.map(c => CampaignService.format(c)) : undefined,
|
203
219
|
//TODO: change this to accomodate all return types
|
204
220
|
};
|
@@ -201,6 +201,7 @@ export declare const ProgramPayloadController: Elysia<"/program-payload", false,
|
|
201
201
|
contract?: string | undefined;
|
202
202
|
forwarders?: (string | {})[] | undefined;
|
203
203
|
targetToken?: string | undefined;
|
204
|
+
evkAddress?: string | undefined;
|
204
205
|
whitelist?: string[] | undefined;
|
205
206
|
isOutOfRangeIncentivized?: boolean | undefined;
|
206
207
|
weightFees?: number | undefined;
|
@@ -214,7 +215,6 @@ export declare const ProgramPayloadController: Elysia<"/program-payload", false,
|
|
214
215
|
repository?: string | undefined;
|
215
216
|
capInUSD?: string | undefined;
|
216
217
|
compFork?: number | undefined;
|
217
|
-
evkAddress?: string | undefined;
|
218
218
|
collateralAddress?: string | undefined;
|
219
219
|
creator: string;
|
220
220
|
computeChainId: number;
|
@@ -1202,6 +1202,23 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1202
1202
|
};
|
1203
1203
|
response: {
|
1204
1204
|
200: {
|
1205
|
+
id: string;
|
1206
|
+
type: string;
|
1207
|
+
params: import("database/api/.generated/runtime/library").JsonValue;
|
1208
|
+
subType: number | null;
|
1209
|
+
computeChainId: number;
|
1210
|
+
distributionChainId: number;
|
1211
|
+
campaignId: string;
|
1212
|
+
distributionType: import("@db/api").$Enums.DistributionType;
|
1213
|
+
rewardTokenId: string;
|
1214
|
+
amount: string;
|
1215
|
+
opportunityId: string;
|
1216
|
+
startTimestamp: bigint;
|
1217
|
+
endTimestamp: bigint;
|
1218
|
+
creatorAddress: string;
|
1219
|
+
manualOverrides: import("@db/api").$Enums.CampaignManualOverride[];
|
1220
|
+
createdAt: Date;
|
1221
|
+
} | {
|
1205
1222
|
Tokens: {
|
1206
1223
|
symbol: string;
|
1207
1224
|
id: string;
|
@@ -2069,6 +2086,23 @@ export declare const v4: Elysia<"/v4", false, {
|
|
2069
2086
|
};
|
2070
2087
|
response: {
|
2071
2088
|
200: {
|
2089
|
+
id: string;
|
2090
|
+
type: string;
|
2091
|
+
params: import("database/api/.generated/runtime/library").JsonValue;
|
2092
|
+
subType: number | null;
|
2093
|
+
computeChainId: number;
|
2094
|
+
distributionChainId: number;
|
2095
|
+
campaignId: string;
|
2096
|
+
distributionType: import("@db/api").$Enums.DistributionType;
|
2097
|
+
rewardTokenId: string;
|
2098
|
+
amount: string;
|
2099
|
+
opportunityId: string;
|
2100
|
+
startTimestamp: bigint;
|
2101
|
+
endTimestamp: bigint;
|
2102
|
+
creatorAddress: string;
|
2103
|
+
manualOverrides: import("@db/api").$Enums.CampaignManualOverride[];
|
2104
|
+
createdAt: Date;
|
2105
|
+
} | {
|
2072
2106
|
Tokens: {
|
2073
2107
|
symbol: string;
|
2074
2108
|
id: string;
|
@@ -2157,6 +2191,23 @@ export declare const v4: Elysia<"/v4", false, {
|
|
2157
2191
|
};
|
2158
2192
|
response: {
|
2159
2193
|
200: {
|
2194
|
+
id: string;
|
2195
|
+
type: string;
|
2196
|
+
params: import("database/api/.generated/runtime/library").JsonValue;
|
2197
|
+
subType: number | null;
|
2198
|
+
computeChainId: number;
|
2199
|
+
distributionChainId: number;
|
2200
|
+
campaignId: string;
|
2201
|
+
distributionType: import("@db/api").$Enums.DistributionType;
|
2202
|
+
rewardTokenId: string;
|
2203
|
+
amount: string;
|
2204
|
+
opportunityId: string;
|
2205
|
+
startTimestamp: bigint;
|
2206
|
+
endTimestamp: bigint;
|
2207
|
+
creatorAddress: string;
|
2208
|
+
manualOverrides: import("@db/api").$Enums.CampaignManualOverride[];
|
2209
|
+
createdAt: Date;
|
2210
|
+
} | {
|
2160
2211
|
Tokens: {
|
2161
2212
|
symbol: string;
|
2162
2213
|
id: string;
|
@@ -2537,7 +2588,9 @@ export declare const v4: Elysia<"/v4", false, {
|
|
2537
2588
|
get: {
|
2538
2589
|
body: unknown;
|
2539
2590
|
params: {};
|
2540
|
-
query:
|
2591
|
+
query: {
|
2592
|
+
chainId?: string | undefined;
|
2593
|
+
};
|
2541
2594
|
headers: unknown;
|
2542
2595
|
response: {
|
2543
2596
|
200: {
|
@@ -4862,6 +4915,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
4862
4915
|
contract?: string | undefined;
|
4863
4916
|
forwarders?: (string | {})[] | undefined;
|
4864
4917
|
targetToken?: string | undefined;
|
4918
|
+
evkAddress?: string | undefined;
|
4865
4919
|
whitelist?: string[] | undefined;
|
4866
4920
|
isOutOfRangeIncentivized?: boolean | undefined;
|
4867
4921
|
weightFees?: number | undefined;
|
@@ -4875,7 +4929,6 @@ export declare const v4: Elysia<"/v4", false, {
|
|
4875
4929
|
repository?: string | undefined;
|
4876
4930
|
capInUSD?: string | undefined;
|
4877
4931
|
compFork?: number | undefined;
|
4878
|
-
evkAddress?: string | undefined;
|
4879
4932
|
collateralAddress?: string | undefined;
|
4880
4933
|
creator: string;
|
4881
4934
|
computeChainId: number;
|
@@ -41,7 +41,10 @@ export const TokenController = new Elysia({ prefix: "/tokens", detail: { tags: [
|
|
41
41
|
},
|
42
42
|
})
|
43
43
|
// ─── Get All Valid Reward Tokens across all chains ───────────────────
|
44
|
-
.get("/reward", async () => TokenService.getAllValidRewardTokens(), {
|
44
|
+
.get("/reward", async ({ query }) => TokenService.getAllValidRewardTokens(query), {
|
45
|
+
query: t.Object({
|
46
|
+
chainId: t.Optional(t.RegExp(/^\d+(,\d+)*$/)),
|
47
|
+
}),
|
45
48
|
detail: {
|
46
49
|
description: "Get all tokens that are accept as reward tokens",
|
47
50
|
},
|
@@ -246,7 +246,9 @@ export declare abstract class TokenService {
|
|
246
246
|
} & {
|
247
247
|
price?: number | null | undefined;
|
248
248
|
})[]>;
|
249
|
-
static getAllValidRewardTokens(
|
249
|
+
static getAllValidRewardTokens(query: {
|
250
|
+
chainId?: string;
|
251
|
+
}): Promise<Record<number, {
|
250
252
|
minimumAmountPerHour: any;
|
251
253
|
symbol: string;
|
252
254
|
id: string;
|
@@ -299,19 +299,21 @@ export class TokenService {
|
|
299
299
|
}
|
300
300
|
}));
|
301
301
|
}
|
302
|
-
static async getAllValidRewardTokens() {
|
302
|
+
static async getAllValidRewardTokens(query) {
|
303
303
|
return await CacheService.wrap(TTLPresets.MIN_5, async () => {
|
304
|
-
let
|
305
|
-
|
306
|
-
|
304
|
+
let chainIds = !!query.chainId
|
305
|
+
? query.chainId?.split(",").map(n => Number.parseInt(n))
|
306
|
+
: (await ChainService.findMany({
|
307
|
+
test: true,
|
308
|
+
})).map(chain => chain.id);
|
307
309
|
/** Fetch current Merkle Roots */
|
308
|
-
const promises = await Promise.allSettled(
|
310
|
+
const promises = await Promise.allSettled(chainIds.map(chainId => withTimeout(TokenService.getValidRewardTokens(chainId), 5_000)));
|
309
311
|
/** Filter out unsuccessful chainIds */
|
310
|
-
|
312
|
+
chainIds = chainIds.filter((_, index) => promises[index].status === "fulfilled");
|
311
313
|
return promises
|
312
314
|
.filter(({ status }) => status === "fulfilled")
|
313
315
|
.reduce((acc, promise, index) => {
|
314
|
-
acc[
|
316
|
+
acc[chainIds[index]] = promise.value;
|
315
317
|
return acc;
|
316
318
|
}, {});
|
317
319
|
});
|