@merkl/api 0.20.123 → 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.
@@ -2360,11 +2360,13 @@ declare const eden: {
2360
2360
  }[];
2361
2361
  }>>;
2362
2362
  }) & {
2363
- get: (options?: {
2363
+ get: (options: {
2364
2364
  headers?: Record<string, unknown> | undefined;
2365
- query?: Record<string, unknown> | undefined;
2365
+ query: {
2366
+ chainId?: string | undefined;
2367
+ };
2366
2368
  fetch?: RequestInit | undefined;
2367
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
2369
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
2368
2370
  200: {
2369
2371
  [x: number]: {
2370
2372
  minimumAmountPerHour: any;
@@ -4138,6 +4140,7 @@ declare const eden: {
4138
4140
  contract?: string | undefined;
4139
4141
  forwarders?: (string | {})[] | undefined;
4140
4142
  targetToken?: string | undefined;
4143
+ evkAddress?: string | undefined;
4141
4144
  whitelist?: string[] | undefined;
4142
4145
  isOutOfRangeIncentivized?: boolean | undefined;
4143
4146
  weightFees?: number | undefined;
@@ -4151,7 +4154,6 @@ declare const eden: {
4151
4154
  repository?: string | undefined;
4152
4155
  capInUSD?: string | undefined;
4153
4156
  compFork?: number | undefined;
4154
- evkAddress?: string | undefined;
4155
4157
  collateralAddress?: string | undefined;
4156
4158
  creator: string;
4157
4159
  computeChainId: number;
@@ -7944,7 +7946,9 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7944
7946
  get: {
7945
7947
  body: unknown;
7946
7948
  params: {};
7947
- query: unknown;
7949
+ query: {
7950
+ chainId?: string | undefined;
7951
+ };
7948
7952
  headers: unknown;
7949
7953
  response: {
7950
7954
  200: {
@@ -10269,6 +10273,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
10269
10273
  contract?: string | undefined;
10270
10274
  forwarders?: (string | {})[] | undefined;
10271
10275
  targetToken?: string | undefined;
10276
+ evkAddress?: string | undefined;
10272
10277
  whitelist?: string[] | undefined;
10273
10278
  isOutOfRangeIncentivized?: boolean | undefined;
10274
10279
  weightFees?: number | undefined;
@@ -10282,7 +10287,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
10282
10287
  repository?: string | undefined;
10283
10288
  capInUSD?: string | undefined;
10284
10289
  compFork?: number | undefined;
10285
- evkAddress?: string | undefined;
10286
10290
  collateralAddress?: string | undefined;
10287
10291
  creator: string;
10288
10292
  computeChainId: number;
@@ -14043,11 +14047,13 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14043
14047
  }[];
14044
14048
  }>>;
14045
14049
  }) & {
14046
- get: (options?: {
14050
+ get: (options: {
14047
14051
  headers?: Record<string, unknown> | undefined;
14048
- query?: Record<string, unknown> | undefined;
14052
+ query: {
14053
+ chainId?: string | undefined;
14054
+ };
14049
14055
  fetch?: RequestInit | undefined;
14050
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
14056
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
14051
14057
  200: {
14052
14058
  [x: number]: {
14053
14059
  minimumAmountPerHour: any;
@@ -15821,6 +15827,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
15821
15827
  contract?: string | undefined;
15822
15828
  forwarders?: (string | {})[] | undefined;
15823
15829
  targetToken?: string | undefined;
15830
+ evkAddress?: string | undefined;
15824
15831
  whitelist?: string[] | undefined;
15825
15832
  isOutOfRangeIncentivized?: boolean | undefined;
15826
15833
  weightFees?: number | undefined;
@@ -15834,7 +15841,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
15834
15841
  repository?: string | undefined;
15835
15842
  capInUSD?: string | undefined;
15836
15843
  compFork?: number | undefined;
15837
- evkAddress?: string | undefined;
15838
15844
  collateralAddress?: string | undefined;
15839
15845
  creator: string;
15840
15846
  computeChainId: number;
@@ -29,7 +29,6 @@ export class EulerBorrowProcessor extends GenericProcessor {
29
29
  }
30
30
  if (campaign.campaignSubType === EulerSubCampaignType.BORROW_FROM_COLLATERAL) {
31
31
  cardName = `${cardName} using ${campaign.campaignParameters.symbolCollateral}`;
32
- // TODO
33
32
  }
34
33
  const tvl = priceAsset * totalBorrows;
35
34
  const priceTargetToken = tvl / totalSupply;
@@ -1,4 +1,5 @@
1
1
  import { Erc20SubType } from ".";
2
+ import { EulerMetadata } from "./implementations/euler/metadata";
2
3
  import { GearboxMetadata } from "./implementations/gearbox/metadata";
3
4
  import { GearboxTVLBuilder } from "./implementations/gearbox/tvl";
4
5
  import { SuperlendMetadata } from "./implementations/superlend/metadata";
@@ -30,6 +31,8 @@ const metadataMap = {
30
31
  [Erc20SubType.gearbox]: new GearboxMetadata(),
31
32
  [Erc20SubType.superlend_borrowing]: new SuperlendMetadata(),
32
33
  [Erc20SubType.superlend_lending]: new SuperlendMetadata(),
34
+ [Erc20SubType.euler_borrow]: new EulerMetadata(),
35
+ [Erc20SubType.euler_lend]: new EulerMetadata(),
33
36
  };
34
37
  export const erc20SubTypeMetadataBuilderFactory = (erc20Subtype) => {
35
38
  if (!metadataMap[erc20Subtype]) {
@@ -1,20 +1,19 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign/campaign.model";
3
3
  import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
4
- import { type CampaignParameters, Campaign as CampaignType, type ChainId } from "@sdk";
4
+ import { type Campaign as CampaignType } from "@sdk";
5
5
  type campaignType = CampaignType.EULER;
6
6
  export declare class EulerMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
+ action: "LEND" | "BORROW";
9
+ protocol: ProtocolId;
8
10
  name: string;
9
11
  tokens: {
10
12
  chainId: number;
11
13
  address: any;
12
14
  }[];
13
- action: "LEND" | "BORROW";
14
- mainProtocol: ProtocolId;
15
15
  depositUrl: string;
16
- explorerAddress: `0x${string}`;
16
+ explorerAddress: any;
17
17
  }>;
18
- static generateUrl(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"]): string;
19
18
  }
20
19
  export {};
@@ -0,0 +1,35 @@
1
+ import { fetchEulerVaultName } from "@/engine/deprecated/erc20SubTypeProcessors/helpers/eulerVaultNames";
2
+ import { TokenService } from "@/modules/v4/token/token.service";
3
+ import { sanitizeChainName } from "@/utils/sanitizeChain";
4
+ import { OpportunityAction } from "@db/api";
5
+ import { ChainInteractionService, EulerSubCampaignType, Euler__factory } from "@sdk";
6
+ export class EulerMetadata {
7
+ async build(campaign) {
8
+ const { params, computeChainId, subType } = campaign;
9
+ let { targetToken, addressAsset: underlyingToken, symbolCollateral, evkAddress } = params;
10
+ if (!underlyingToken)
11
+ underlyingToken = await Euler__factory.connect(targetToken, ChainInteractionService(computeChainId).provider()).asset();
12
+ const underlyingTokenInfo = await TokenService.findUniqueFillOrThrow({
13
+ chainId: computeChainId,
14
+ address: underlyingToken,
15
+ });
16
+ let vaultName = await fetchEulerVaultName(underlyingToken, computeChainId);
17
+ if (!vaultName)
18
+ vaultName = await fetchEulerVaultName(evkAddress, computeChainId);
19
+ const action = subType === EulerSubCampaignType.BORROW_FROM_COLLATERAL || subType === EulerSubCampaignType.BORROW
20
+ ? OpportunityAction.BORROW
21
+ : OpportunityAction.LEND;
22
+ const name = `${action === OpportunityAction.LEND ? `Supply ${underlyingTokenInfo.symbol} on` : "Borrow from"}${vaultName ? ` ${vaultName}` : ""} vault ${subType === EulerSubCampaignType.BORROW_FROM_COLLATERAL ? `using ${symbolCollateral}` : ""}`;
23
+ return {
24
+ action,
25
+ protocol: "euler",
26
+ name,
27
+ tokens: [
28
+ { chainId: computeChainId, address: targetToken },
29
+ { chainId: computeChainId, address: underlyingToken },
30
+ ],
31
+ depositUrl: `https://app.euler.finance/vault/${evkAddress}?network=${sanitizeChainName(computeChainId)}`,
32
+ explorerAddress: params.targetToken,
33
+ };
34
+ }
35
+ }
@@ -12,7 +12,6 @@ import { EncompassingMetadata } from "../implementations/Encompassing/metadata";
12
12
  import { Erc20Metadata } from "../implementations/Erc20/metadata";
13
13
  import { Erc721Metadata } from "../implementations/Erc721/metadata";
14
14
  import { ErcMultiTokenMetadata } from "../implementations/ErcMultiToken/metadata";
15
- import { EulerMetadata } from "../implementations/Euler/metadata";
16
15
  import { EventBasedMetadata } from "../implementations/EventBased/metadata";
17
16
  import { HyperdriveMetadata } from "../implementations/Hyperdrive/metadata";
18
17
  import { InvalidMetadata } from "../implementations/Invalid/metadata";
@@ -39,7 +38,7 @@ const map = {
39
38
  [Campaign.DOLOMITE]: new DolomiteMetadata(),
40
39
  [Campaign.BADGER]: new BadgerMetadata(),
41
40
  [Campaign.AJNA]: new AjnaMetadata(),
42
- [Campaign.EULER]: new EulerMetadata(),
41
+ [Campaign.EULER]: new Erc20Metadata(),
43
42
  [Campaign.COMPOUND]: new CompoundMetadata(),
44
43
  [Campaign.COMPOUND_V3]: new CompoundV3Metadata(),
45
44
  [Campaign.COMPOUND_V3_FIXAPR]: new CompoundV3Metadata(),
@@ -2718,7 +2718,9 @@ declare const app: Elysia<"", false, {
2718
2718
  get: {
2719
2719
  body: unknown;
2720
2720
  params: {};
2721
- query: unknown;
2721
+ query: {
2722
+ chainId?: string | undefined;
2723
+ };
2722
2724
  headers: unknown;
2723
2725
  response: {
2724
2726
  200: {
@@ -5043,6 +5045,7 @@ declare const app: Elysia<"", false, {
5043
5045
  contract?: string | undefined;
5044
5046
  forwarders?: (string | {})[] | undefined;
5045
5047
  targetToken?: string | undefined;
5048
+ evkAddress?: string | undefined;
5046
5049
  whitelist?: string[] | undefined;
5047
5050
  isOutOfRangeIncentivized?: boolean | undefined;
5048
5051
  weightFees?: number | undefined;
@@ -5056,7 +5059,6 @@ declare const app: Elysia<"", false, {
5056
5059
  repository?: string | undefined;
5057
5060
  capInUSD?: string | undefined;
5058
5061
  compFork?: number | undefined;
5059
- evkAddress?: string | undefined;
5060
5062
  collateralAddress?: string | undefined;
5061
5063
  creator: string;
5062
5064
  computeChainId: number;
@@ -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;
@@ -2588,7 +2588,9 @@ export declare const v4: Elysia<"/v4", false, {
2588
2588
  get: {
2589
2589
  body: unknown;
2590
2590
  params: {};
2591
- query: unknown;
2591
+ query: {
2592
+ chainId?: string | undefined;
2593
+ };
2592
2594
  headers: unknown;
2593
2595
  response: {
2594
2596
  200: {
@@ -4913,6 +4915,7 @@ export declare const v4: Elysia<"/v4", false, {
4913
4915
  contract?: string | undefined;
4914
4916
  forwarders?: (string | {})[] | undefined;
4915
4917
  targetToken?: string | undefined;
4918
+ evkAddress?: string | undefined;
4916
4919
  whitelist?: string[] | undefined;
4917
4920
  isOutOfRangeIncentivized?: boolean | undefined;
4918
4921
  weightFees?: number | undefined;
@@ -4926,7 +4929,6 @@ export declare const v4: Elysia<"/v4", false, {
4926
4929
  repository?: string | undefined;
4927
4930
  capInUSD?: string | undefined;
4928
4931
  compFork?: number | undefined;
4929
- evkAddress?: string | undefined;
4930
4932
  collateralAddress?: string | undefined;
4931
4933
  creator: string;
4932
4934
  computeChainId: number;
@@ -82,7 +82,9 @@ export declare const TokenController: Elysia<"/tokens", false, {
82
82
  get: {
83
83
  body: unknown;
84
84
  params: {};
85
- query: unknown;
85
+ query: {
86
+ chainId?: string | undefined;
87
+ };
86
88
  headers: unknown;
87
89
  response: {
88
90
  200: {
@@ -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(): Promise<Record<number, {
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 chains = await ChainService.findMany({
305
- test: true,
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(chains.map(chain => withTimeout(TokenService.getValidRewardTokens(chain.id), 5_000)));
310
+ const promises = await Promise.allSettled(chainIds.map(chainId => withTimeout(TokenService.getValidRewardTokens(chainId), 5_000)));
309
311
  /** Filter out unsuccessful chainIds */
310
- chains = chains.filter((_, index) => promises[index].status === "fulfilled");
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[chains[index].id] = promise.value;
316
+ acc[chainIds[index]] = promise.value;
315
317
  return acc;
316
318
  }, {});
317
319
  });