@merkl/api 0.20.58 → 0.20.60

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.
@@ -8730,8 +8730,9 @@ declare const eden: {
8730
8730
  query?: Record<string, unknown> | undefined;
8731
8731
  fetch?: RequestInit | undefined;
8732
8732
  } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
8733
- [x: string]: any;
8734
- 200: any;
8733
+ 200: {
8734
+ [x: string]: any;
8735
+ } | undefined;
8735
8736
  }>>;
8736
8737
  }) & {
8737
8738
  index: {
@@ -8740,8 +8741,11 @@ declare const eden: {
8740
8741
  query?: Record<string, unknown> | undefined;
8741
8742
  fetch?: RequestInit | undefined;
8742
8743
  } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
8743
- [x: string]: any;
8744
- 200: any;
8744
+ 200: {
8745
+ [x: string]: {
8746
+ [poolId: string]: UniswapV4PoolType;
8747
+ } | undefined;
8748
+ } | null;
8745
8749
  }>>;
8746
8750
  };
8747
8751
  pool: ((params: {
@@ -14691,8 +14695,11 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14691
14695
  query: unknown;
14692
14696
  headers: unknown;
14693
14697
  response: {
14694
- [x: string]: any;
14695
- 200: any;
14698
+ 200: {
14699
+ [x: string]: {
14700
+ [poolId: string]: UniswapV4PoolType;
14701
+ } | undefined;
14702
+ } | null;
14696
14703
  };
14697
14704
  };
14698
14705
  };
@@ -14706,8 +14713,9 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
14706
14713
  query: unknown;
14707
14714
  headers: unknown;
14708
14715
  response: {
14709
- [x: string]: any;
14710
- 200: any;
14716
+ 200: {
14717
+ [x: string]: any;
14718
+ } | undefined;
14711
14719
  };
14712
14720
  };
14713
14721
  };
@@ -23467,8 +23475,9 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
23467
23475
  query?: Record<string, unknown> | undefined;
23468
23476
  fetch?: RequestInit | undefined;
23469
23477
  } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
23470
- [x: string]: any;
23471
- 200: any;
23478
+ 200: {
23479
+ [x: string]: any;
23480
+ } | undefined;
23472
23481
  }>>;
23473
23482
  }) & {
23474
23483
  index: {
@@ -23477,8 +23486,11 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
23477
23486
  query?: Record<string, unknown> | undefined;
23478
23487
  fetch?: RequestInit | undefined;
23479
23488
  } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
23480
- [x: string]: any;
23481
- 200: any;
23489
+ 200: {
23490
+ [x: string]: {
23491
+ [poolId: string]: UniswapV4PoolType;
23492
+ } | undefined;
23493
+ } | null;
23482
23494
  }>>;
23483
23495
  };
23484
23496
  pool: ((params: {
@@ -1,4 +1,4 @@
1
- import { Campaign, type CampaignParameters, type MerklChainId } from "@sdk";
1
+ import { type Campaign, type CampaignParameters, type MerklChainId } from "@sdk";
2
2
  import type { DynamicDataBuilder } from "../interface";
3
3
  export type ERC20SupportedCampaignType = Campaign.ERC20 | Campaign.ERC20LOGPROCESSOR | Campaign.ERC20REBASELOGPROCESSOR | Campaign.EULER | Campaign.ERC20_FIX_APR;
4
4
  export declare class Erc20DynamicData implements DynamicDataBuilder<ERC20SupportedCampaignType> {
@@ -9,7 +9,8 @@ import { TokenRepository } from "@/modules/v4/token/token.repository";
9
9
  import { TokenService } from "@/modules/v4/token/token.service";
10
10
  import { log } from "@/utils/logger";
11
11
  import { Pricer } from "@/utils/pricer";
12
- import { BN2Number, BalancerPoolInterface, BalancerV3StablePoolInterface, Campaign, ChainId, ChainInteractionService, ERC20Interface, EnzymeInterface, FactoryInterface, LayerBankERC20Interface, MetamorphoInterface, YEAR, getEnv, } from "@sdk";
12
+ import { BN2Number, BalancerPoolInterface, BalancerV3StablePoolInterface, ChainId, ChainInteractionService, ERC20Interface, EnzymeInterface, FactoryInterface, LayerBankERC20Interface, MetamorphoInterface, YEAR, getEnv, } from "@sdk";
13
+ import { getFixedApr, hasFixedAprConfig } from "../utils/getFixedApr";
13
14
  export class Erc20DynamicData {
14
15
  async build(chainId, campaigns) {
15
16
  const pricer = await Pricer.load();
@@ -160,17 +161,8 @@ export class Erc20DynamicData {
160
161
  if (rewardToken.isPoint) {
161
162
  apr = apr / 365 / 100;
162
163
  }
163
- else if (campaign.campaignType === Campaign.ERC20_FIX_APR &&
164
- ["tacBTC", "tacETH", "tacUSD"].includes(campaign.campaignParameters.symbolTargetToken)) {
165
- if (campaign.campaignParameters.symbolTargetToken === "tacBTC") {
166
- apr = 27.92;
167
- }
168
- else if (campaign.campaignParameters.symbolTargetToken === "tacETH") {
169
- apr = 32.58;
170
- }
171
- else if (campaign.campaignParameters.symbolTargetToken === "tacUSD") {
172
- apr = 46.54;
173
- }
164
+ else if (hasFixedAprConfig(campaign.campaignParameters)) {
165
+ apr = getFixedApr(campaign, priceRewardToken, priceTargetToken);
174
166
  }
175
167
  if (campaign.chainId === ChainId.ETHERLINK) {
176
168
  whitelistedSupplyTargetToken = tokenTypesByCampaign[campaign.campaignId].typeInfo.totalSupply;
@@ -0,0 +1,9 @@
1
+ import type { Campaign, CampaignParameters } from "@sdk";
2
+ export type BaseFixAPRConfig = {
3
+ apr: string;
4
+ targetTokenPricing: boolean;
5
+ rewardTokenPricing: boolean;
6
+ };
7
+ export type FixedAprCampaignType = Campaign.ERC20_FIX_APR | Campaign.HYPERDRIVELOGFIXPROCESSOR;
8
+ export declare function hasFixedAprConfig<T>(params: T): params is T & BaseFixAPRConfig;
9
+ export declare function getFixedApr(campaignParameters: CampaignParameters<FixedAprCampaignType>, priceRewardToken: number, priceTargetToken: number): number;
@@ -0,0 +1,35 @@
1
+ // Type guard to check if campaign parameters have fixed APR config
2
+ export function hasFixedAprConfig(params) {
3
+ return (typeof params === "object" &&
4
+ params !== null &&
5
+ "targetTokenPricing" in params &&
6
+ "rewardTokenPricing" in params &&
7
+ "apr" in params);
8
+ }
9
+ // TODO: Enhance APR display for non-dollar denominations when front-end is ready.
10
+ // This should handle cases where one or both token price are unavailable, showing the APR as a direct ratio
11
+ // (e.g., X reward tokens per Y target tokens) instead of dollar values.
12
+ export function getFixedApr(campaignParameters, priceRewardToken, priceTargetToken) {
13
+ const { targetTokenPricing, rewardTokenPricing, apr: fixedApr } = campaignParameters.campaignParameters;
14
+ const targetApr = Number(fixedApr);
15
+ // Handle all pricing configurations
16
+ if (targetTokenPricing && rewardTokenPricing) {
17
+ // Case 1: Fixed $ amount of reward per $ of liquidity
18
+ return targetApr * 100;
19
+ }
20
+ if (targetTokenPricing && !rewardTokenPricing) {
21
+ // Case 2: Fixed # amount of reward per $ of liquidity
22
+ // Return 0 if reward token price is invalid
23
+ return !priceRewardToken ? 0 : targetApr * priceRewardToken * 100;
24
+ }
25
+ if (!targetTokenPricing && rewardTokenPricing) {
26
+ // Case 3: Fixed $ amount of reward per # of liquidity
27
+ // Return 0 if target token price is invalid
28
+ return !priceTargetToken || priceTargetToken === 0 ? 0 : targetApr * (1 / priceTargetToken) * 100;
29
+ }
30
+ // Case 4: Fixed # amount of reward per # of liquidity
31
+ // Return 0 if either price is invalid
32
+ return !priceRewardToken || !priceTargetToken || priceTargetToken === 0
33
+ ? 0
34
+ : targetApr * (priceRewardToken / priceTargetToken) * 100;
35
+ }
@@ -5924,8 +5924,11 @@ declare const app: Elysia<"", false, {
5924
5924
  query: unknown;
5925
5925
  headers: unknown;
5926
5926
  response: {
5927
- [x: string]: any;
5928
- 200: any;
5927
+ 200: {
5928
+ [x: string]: {
5929
+ [poolId: string]: UniswapV4PoolType;
5930
+ } | undefined;
5931
+ } | null;
5929
5932
  };
5930
5933
  };
5931
5934
  };
@@ -5939,8 +5942,9 @@ declare const app: Elysia<"", false, {
5939
5942
  query: unknown;
5940
5943
  headers: unknown;
5941
5944
  response: {
5942
- [x: string]: any;
5943
- 200: any;
5945
+ 200: {
5946
+ [x: string]: any;
5947
+ } | undefined;
5944
5948
  };
5945
5949
  };
5946
5950
  };
@@ -11,6 +11,7 @@ export class OpportunityRepository {
11
11
  static #transformQueryToPrismaFilters(query) {
12
12
  const { page: _page, items: _items, ...filters } = query;
13
13
  //TODO: abstract away query to not be strictly equal to controller
14
+ const now = moment().unix();
14
15
  const chainIds = query.chainId?.split(",").map(n => Number.parseInt(n));
15
16
  const actions = query.action?.split(",");
16
17
  const status = query.status?.split(",");
@@ -65,17 +66,40 @@ export class OpportunityRepository {
65
66
  : {
66
67
  AND: search?.map(keyword => ({
67
68
  OR: [
69
+ //IDs
68
70
  { id: { contains: keyword, mode: "insensitive" } },
69
71
  { name: { contains: keyword, mode: "insensitive" } },
70
72
  { identifier: { contains: keyword, mode: "insensitive" } },
71
73
  { explorerAddress: { contains: keyword, mode: "insensitive" } },
74
+ { Campaigns: { some: { campaignId: { contains: keyword, mode: "insensitive" } } } },
75
+ { Campaigns: { some: { id: { contains: keyword, mode: "insensitive" } } } },
76
+ //ERC20,CLAMM,...
72
77
  { type: { contains: keyword, mode: "insensitive" } },
78
+ //Protocol
73
79
  { MainProtocol: { name: { contains: keyword, mode: "insensitive" } } },
74
80
  { mainProtocolId: { contains: keyword, mode: "insensitive" } },
81
+ //Token
75
82
  { Tokens: { some: { name: { contains: keyword, mode: "insensitive" } } } },
76
83
  { Tokens: { some: { symbol: { contains: keyword, mode: "insensitive" } } } },
77
- { Campaigns: { some: { campaignId: { contains: keyword, mode: "insensitive" } } } },
78
- { Campaigns: { some: { id: { contains: keyword, mode: "insensitive" } } } },
84
+ { Tokens: { some: { address: { contains: keyword, mode: "insensitive" } } } },
85
+ //Match reward tokens only if campaign is live
86
+ {
87
+ Campaigns: {
88
+ some: {
89
+ endTimestamp: { gte: now },
90
+ RewardToken: {
91
+ OR: [
92
+ {
93
+ symbol: { contains: keyword, mode: "insensitive" },
94
+ },
95
+ {
96
+ address: { contains: keyword, mode: "insensitive" },
97
+ },
98
+ ],
99
+ },
100
+ },
101
+ },
102
+ },
79
103
  { Chain: { name: { contains: keyword, mode: "insensitive" } } },
80
104
  ],
81
105
  })),
@@ -776,8 +776,11 @@ export declare const v3: Elysia<"/v3", false, {
776
776
  query: unknown;
777
777
  headers: unknown;
778
778
  response: {
779
- [x: string]: any;
780
- 200: any;
779
+ 200: {
780
+ [x: string]: {
781
+ [poolId: string]: UniswapV4PoolType;
782
+ } | undefined;
783
+ } | null;
781
784
  };
782
785
  };
783
786
  };
@@ -791,8 +794,9 @@ export declare const v3: Elysia<"/v3", false, {
791
794
  query: unknown;
792
795
  headers: unknown;
793
796
  response: {
794
- [x: string]: any;
795
- 200: any;
797
+ 200: {
798
+ [x: string]: any;
799
+ } | undefined;
796
800
  };
797
801
  };
798
802
  };
@@ -20,8 +20,11 @@ declare const _default: (app: Elysia) => Elysia<"", false, {
20
20
  query: unknown;
21
21
  headers: unknown;
22
22
  response: {
23
- [x: string]: any;
24
- 200: any;
23
+ 200: {
24
+ [x: string]: {
25
+ [poolId: string]: UniswapV4PoolType;
26
+ } | undefined;
27
+ } | null;
25
28
  };
26
29
  };
27
30
  };
@@ -35,8 +38,9 @@ declare const _default: (app: Elysia) => Elysia<"", false, {
35
38
  query: unknown;
36
39
  headers: unknown;
37
40
  response: {
38
- [x: string]: any;
39
- 200: any;
41
+ 200: {
42
+ [x: string]: any;
43
+ } | undefined;
40
44
  };
41
45
  };
42
46
  };
@@ -1,16 +1,16 @@
1
- import { Redis } from "@/cache";
1
+ import { CacheService } from "@/modules/v4/cache";
2
2
  import { ChainUniqueDto } from "@/modules/v4/chain/chain.model";
3
- import { Bytes32Dto, UniV4ChainIdArray } from "@/modules/v4/uniswap/uniswap.model";
3
+ import { Bytes32Dto, UniV4ChainIdArray, } from "@/modules/v4/uniswap/uniswap.model";
4
4
  import { UniswapService } from "@/modules/v4/uniswap/uniswap.service";
5
5
  import { UnsupportedNetwork } from "@/utils/error";
6
6
  export default (app) => app.group("/uniswapv4", router => router
7
7
  .get("/", async () => {
8
- return await Redis.getOrSet("UniswapV4Pools", UniswapService.getUniswapV4Pools);
8
+ return await CacheService.get(UniswapService.getUniswapV4Pools, []);
9
9
  }, {
10
10
  tags: ["uniswapv4"],
11
11
  })
12
12
  .get("/:chainId", async ({ params }) => {
13
- return (await Redis.getOrSet("UniswapV4Pools", UniswapService.getUniswapV4Pools, params.chainId))[params.chainId];
13
+ return (await CacheService.get(UniswapService.getUniswapV4Pools, []))?.[params.chainId];
14
14
  }, {
15
15
  params: ChainUniqueDto,
16
16
  beforeHandle: ({ params }) => {
@@ -20,7 +20,7 @@ export default (app) => app.group("/uniswapv4", router => router
20
20
  tags: ["uniswapv4"],
21
21
  })
22
22
  .get("/pool/:poolId", async ({ params }) => {
23
- return Object.values((await Redis.getOrSet("UniswapV4Pools", UniswapService.getUniswapV4Pools)))
23
+ return Object.values((await CacheService.get(UniswapService.getUniswapV4Pools, [])))
24
24
  .flatMap(x => (x ? Object.values(x) : []))
25
25
  .filter(p => p.poolId === params.poolId);
26
26
  }, {