@merkl/api 0.20.24 → 0.20.26

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.
@@ -8190,15 +8190,39 @@ declare const eden: {
8190
8190
  };
8191
8191
  }>>;
8192
8192
  };
8193
- uniswapv4: {
8194
- get: (options: {
8193
+ uniswapv4: ((params: {
8194
+ chainId: string | number;
8195
+ }) => {
8196
+ get: (options?: {
8195
8197
  headers?: Record<string, unknown> | undefined;
8196
- query: {};
8198
+ query?: Record<string, unknown> | undefined;
8197
8199
  fetch?: RequestInit | undefined;
8198
- }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
8200
+ } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
8199
8201
  [x: string]: any;
8200
8202
  200: any;
8201
8203
  }>>;
8204
+ }) & {
8205
+ index: {
8206
+ get: (options?: {
8207
+ headers?: Record<string, unknown> | undefined;
8208
+ query?: Record<string, unknown> | undefined;
8209
+ fetch?: RequestInit | undefined;
8210
+ } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
8211
+ [x: string]: any;
8212
+ 200: any;
8213
+ }>>;
8214
+ };
8215
+ pool: ((params: {
8216
+ poolId: string | number;
8217
+ }) => {
8218
+ get: (options?: {
8219
+ headers?: Record<string, unknown> | undefined;
8220
+ query?: Record<string, unknown> | undefined;
8221
+ fetch?: RequestInit | undefined;
8222
+ } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
8223
+ 200: UniswapV4PoolType[];
8224
+ }>>;
8225
+ }) & {};
8202
8226
  };
8203
8227
  };
8204
8228
  };
@@ -13788,14 +13812,47 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
13788
13812
  } & {
13789
13813
  v3: {
13790
13814
  uniswapv4: {
13791
- get: {
13792
- body: unknown;
13793
- params: {};
13794
- query: {};
13795
- headers: unknown;
13796
- response: {
13797
- [x: string]: any;
13798
- 200: any;
13815
+ index: {
13816
+ get: {
13817
+ body: unknown;
13818
+ params: {};
13819
+ query: unknown;
13820
+ headers: unknown;
13821
+ response: {
13822
+ [x: string]: any;
13823
+ 200: any;
13824
+ };
13825
+ };
13826
+ };
13827
+ } & {
13828
+ ":chainId": {
13829
+ get: {
13830
+ body: unknown;
13831
+ params: {
13832
+ chainId: number;
13833
+ };
13834
+ query: unknown;
13835
+ headers: unknown;
13836
+ response: {
13837
+ [x: string]: any;
13838
+ 200: any;
13839
+ };
13840
+ };
13841
+ };
13842
+ } & {
13843
+ pool: {
13844
+ ":poolId": {
13845
+ get: {
13846
+ body: unknown;
13847
+ params: {
13848
+ poolId: string;
13849
+ };
13850
+ query: unknown;
13851
+ headers: unknown;
13852
+ response: {
13853
+ 200: UniswapV4PoolType[];
13854
+ };
13855
+ };
13799
13856
  };
13800
13857
  };
13801
13858
  };
@@ -21998,15 +22055,39 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
21998
22055
  };
21999
22056
  }>>;
22000
22057
  };
22001
- uniswapv4: {
22002
- get: (options: {
22058
+ uniswapv4: ((params: {
22059
+ chainId: string | number;
22060
+ }) => {
22061
+ get: (options?: {
22003
22062
  headers?: Record<string, unknown> | undefined;
22004
- query: {};
22063
+ query?: Record<string, unknown> | undefined;
22005
22064
  fetch?: RequestInit | undefined;
22006
- }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
22065
+ } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
22007
22066
  [x: string]: any;
22008
22067
  200: any;
22009
22068
  }>>;
22069
+ }) & {
22070
+ index: {
22071
+ get: (options?: {
22072
+ headers?: Record<string, unknown> | undefined;
22073
+ query?: Record<string, unknown> | undefined;
22074
+ fetch?: RequestInit | undefined;
22075
+ } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
22076
+ [x: string]: any;
22077
+ 200: any;
22078
+ }>>;
22079
+ };
22080
+ pool: ((params: {
22081
+ poolId: string | number;
22082
+ }) => {
22083
+ get: (options?: {
22084
+ headers?: Record<string, unknown> | undefined;
22085
+ query?: Record<string, unknown> | undefined;
22086
+ fetch?: RequestInit | undefined;
22087
+ } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
22088
+ 200: UniswapV4PoolType[];
22089
+ }>>;
22090
+ }) & {};
22010
22091
  };
22011
22092
  };
22012
22093
  };
@@ -1,8 +1,10 @@
1
1
  import { type MerklChainId, type UniswapV4PoolType } from "@sdk";
2
+ export declare const UniV4ChainIdArray: MerklChainId[];
3
+ type UniV4ChainId = (typeof UniV4ChainIdArray)[number];
2
4
  export type UniswapV4PoolsReturnType = {
3
5
  [chainId in MerklChainId]?: {
4
6
  [poolId: string]: UniswapV4PoolType;
5
7
  };
6
8
  };
7
- export declare function getUniswapV4Pools(): Promise<UniswapV4PoolsReturnType>;
8
- export declare const getUniswapV4PoolsWithCache: () => Promise<UniswapV4PoolsReturnType>;
9
+ export declare function getUniswapV4Pools(chainId?: UniV4ChainId): Promise<UniswapV4PoolsReturnType>;
10
+ export {};
@@ -1,24 +1,30 @@
1
- import { Redis } from "@/cache";
2
1
  import { log } from "@/utils/logger";
3
2
  import { providers } from "@/utils/providers";
4
3
  import { apiDbClient } from "@db";
5
4
  import { ChainInteractionService, ERC20Interface, NETWORK_LABELS, NULL_ADDRESS, UniswapV4Addresses, UniswapV4PoolManagerInterface, getContractCreationBlock, } from "@sdk";
6
5
  import { safeFetchLogs } from "./fetchLogs";
7
6
  import { LoggedEntityType } from "./getEulerV2Vaults";
8
- const UNIV4_CHAINIDS = Object.keys(UniswapV4Addresses).map((x) => Number(x));
9
- export async function getUniswapV4Pools() {
7
+ export const UniV4ChainIdArray = Object.keys(UniswapV4Addresses).map((x) => Number(x));
8
+ export async function getUniswapV4Pools(chainId) {
9
+ let chainIdArray;
10
+ if (!!chainId) {
11
+ chainIdArray = [chainId];
12
+ }
13
+ else {
14
+ chainIdArray = UniV4ChainIdArray;
15
+ }
10
16
  const pools = {};
11
17
  // 0_ Fetch all euler vaults from database
12
18
  const storedPools = await apiDbClient.logged.findMany({
13
19
  where: { type: LoggedEntityType.UNISWAP_V4 },
14
20
  });
15
- const res = await Promise.all(UNIV4_CHAINIDS.map(async (chainId) => {
21
+ const res = await Promise.all(chainIdArray.map(async (chainId) => {
16
22
  chainId = chainId;
17
23
  const perChainIdRes = {};
18
24
  const poolManagerAddress = UniswapV4Addresses[chainId]?.PoolManager ?? NULL_ADDRESS;
19
25
  const jsonRPCprovider = providers[chainId];
20
26
  try {
21
- // 1_ Get latest euler vaults from chain
27
+ // 1_ Get latest uniswapV4 pools for `chainId`
22
28
  const storedPoolsPerChain = storedPools.filter(pool => pool.chainId === chainId);
23
29
  log.info(`found ${storedPoolsPerChain.length} already stored pools on ${NETWORK_LABELS[chainId]}`);
24
30
  let fromBlock;
@@ -137,13 +143,13 @@ export async function getUniswapV4Pools() {
137
143
  }
138
144
  return perChainIdRes;
139
145
  }));
140
- UNIV4_CHAINIDS.forEach((chainId, i) => {
146
+ chainIdArray.forEach((chainId, i) => {
141
147
  if (!!res[i])
142
148
  pools[chainId] = res[i];
143
149
  });
144
150
  // Update the API database
145
151
  const tableData = Object.values(pools).flatMap(pools => Object.values(pools));
146
- for (const chainId of UNIV4_CHAINIDS) {
152
+ for (const chainId of chainIdArray) {
147
153
  if (tableData.filter(p => p.chainId === chainId).length > 0) {
148
154
  try {
149
155
  await apiDbClient.logged.createMany({
@@ -180,4 +186,3 @@ export async function getUniswapV4Pools() {
180
186
  log.info("👋 exiting getUniswapV4Pools");
181
187
  return pools;
182
188
  }
183
- export const getUniswapV4PoolsWithCache = async () => await Redis.getOrSet("UniswapV4Pools", getUniswapV4Pools);
@@ -36,9 +36,9 @@ export declare class ClammMetadata implements MetadataBuilder<campaignType> {
36
36
  address: any;
37
37
  }[];
38
38
  mainProtocol: ProtocolId;
39
- depositUrl: string | undefined;
39
+ depositUrl: string;
40
40
  explorerAddress: `0x${string}`;
41
41
  }>;
42
- static generateUrl(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"]): string | undefined;
42
+ static generateUrl(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"]): string;
43
43
  }
44
44
  export {};
@@ -105,118 +105,58 @@ export class ClammMetadata {
105
105
  };
106
106
  }
107
107
  static generateUrl(computeChainId, params) {
108
- switch (params.amm) {
109
- case AMM.UniswapV3: {
108
+ const sanitizeChain = (computeChain) => NETWORK_LABELS[computeChain]?.toLowerCase().replaceAll(" ", "");
109
+ const sanitizeFee = (poolFee) => Number(poolFee) * 10000;
110
+ const ammLinkMap = {
111
+ UniswapV3: ({ poolAddress }) => {
110
112
  const availableOnOku = Object.keys(uniswapV3OkuChains).includes(computeChainId?.toString());
111
- if (availableOnOku) {
113
+ if (availableOnOku)
112
114
  return `https://oku.trade/app/${uniswapV3OkuChains[computeChainId]}/liquidity/${params.poolAddress} `;
113
- }
114
- return `https://app.uniswap.org/explore/pools/${computeChainId === ChainId.MAINNET
115
- ? "ethereum/"
116
- : `${NETWORK_LABELS[computeChainId]?.toLowerCase().replaceAll(" ", "")}/`}${params?.poolAddress?.toLowerCase()}`;
117
- }
118
- case AMM.PancakeSwapV3: {
119
- return `https://pancakeswap.finance/add/${params.token0?.toLowerCase()}/${params.token1?.toLowerCase()}/${Number(params.poolFee) * 10000}?chain=${pancakeswapChains[computeChainId] ?? NETWORK_LABELS[computeChainId]?.replaceAll(" ", "")}`;
120
- }
121
- case AMM.Sonex: {
122
- return `https://app.sonex.so/explore/pools/${params.poolAddress?.toLowerCase()}`;
123
- }
124
- case AMM.KYO: {
125
- return `https://app.kyo.finance/liquidity/${params.poolAddress?.toLowerCase()}`;
126
- }
127
- case AMM.SushiSwapV3: {
128
- return `https://www.sushi.com/${sushiswapv3Chains[computeChainId] ?? NETWORK_LABELS[computeChainId]?.toLowerCase()?.replaceAll(" ", "")}/pool/v3/${params.poolAddress?.toLowerCase()}`;
129
- }
130
- case AMM.Retro: {
131
- return "https://retro.finance/liquidity/managev3";
132
- }
133
- case AMM.Camelot: {
134
- return `https://app.camelot.exchange/liquidity?type=v3&token1=${params.token0?.toLowerCase()}&token2=${params.token1?.toLowerCase()}`;
135
- }
136
- case AMM.BaseSwap: {
137
- return `https://${computeChainId === ChainId.MODE ? "swapmode" : "baseswap"}.fi/addV3?currencyIdA=${params.token0}&currencyIdB=${params.token1}&feeAmount=${Number(params.poolFee) * 10000}`;
138
- }
139
- case AMM.Horiza: {
140
- return "https:/app.horiza.io/liquidity";
141
- }
142
- case AMM.QuickswapAlgebra: {
143
- return `https://quickswap.exchange/#/pools?currency0=${params.token0}&currency1=${params.token1}`;
144
- }
145
- case AMM.QuickswapUni: {
146
- return `https://quickswap.exchange/#/pools?currency0=${params.token0}&currency1=${params.token1}`;
147
- }
148
- case AMM.QuickswapAlgebraV1_2: {
149
- return `https://quickswap.exchange/#/pools?currency0=${params.token0}&currency1=${params.token1}`;
150
- }
151
- case AMM.Swapr: {
152
- return "https://v3.swapr.eth.limo/#/swap";
153
- }
154
- case AMM.ZERO: {
155
- return "https://v3.swapr.eth.limo/#/swap";
156
- }
157
- case AMM.Crust: {
158
- return "https://app.crust.finance/liquidity";
159
- }
160
- case AMM.Thruster: {
161
- return "https://app.thruster.finance/add";
162
- }
163
- case AMM.Kim: {
164
- return "https://app.kim.exchange/positions";
165
- }
166
- case AMM.Stryke: {
167
- return "https://www.stryke.xyz/en/dashboard";
168
- }
169
- case AMM.StrykePCS: {
170
- return `https://pancakeswap.stryke.xyz/${params.symbolToken0}-${params.symbolToken1}?mode=LP`;
171
- }
172
- case AMM.StrykeSushi: {
173
- return `https://sushiswap.stryke.xyz/${params.symbolToken0}-${params.symbolToken1}?mode=LP`;
174
- }
175
- case AMM.ARTHSWAP: {
176
- return "https://app.arthswap.org/#/pools";
177
- }
178
- case AMM.Fenix: {
179
- return "https://www.fenixfinance.io/";
180
- }
181
- case AMM.Ramses: {
182
- return "https://app.ramses.exchange/swap";
183
- }
184
- case AMM.Voltage: {
185
- return `https://app.voltage.finance/add/${params.token0?.toLowerCase()}/${params.token1?.toLowerCase()}?version=v3&feeAmount=${Number(params.poolFee) * 10000}`;
186
- }
187
- case AMM.Izumi: {
188
- return `https://${computeChainId === ChainId.ROOTSTOCK ? "woodswap.org" : "izumi.finance"}/trade/add-liquidity/?token0=${params.token0}&token1=${params.token1}&chainId=${computeChainId}&fee=${Number(params.poolFee) * 10000}`;
189
- }
190
- case AMM.KOI: {
191
- return `https://dapp.koi.finance/pool/v3/new/${params.token0?.toLowerCase()}/${params.token1?.toLowerCase()}`;
192
- }
193
- case AMM.SupswapV3: {
194
- return `https://supswap.xyz/add/${params.token0?.toLowerCase()}/${params.token1?.toLowerCase()}/${Number.parseInt(params.poolFee) * 10000}`;
195
- }
196
- case AMM.zkSwap: {
197
- return `https://www.zkswap.finance/add/${params.token0?.toLowerCase()}/${params.token1?.toLowerCase()}/2000?chain=${computeChainId}`;
198
- }
199
- case AMM.SyncswapV3: {
200
- return "https://www.syncswap.xyz/pools";
201
- }
202
- case AMM.Neptune: {
203
- return "https://app.nep.finance/add/";
204
- }
205
- case AMM.SwapX: {
206
- return "https://swapx.fi/earn";
207
- }
208
- case AMM.Velodrome: {
209
- return "https://app.velodrome.finance/";
210
- }
211
- case AMM.AERODROME: {
212
- return "https://app.aerodrome.finance/";
213
- }
214
- case AMM.ThirdTrade: {
215
- return "https://app.thirdtrade.xyz/";
216
- }
217
- case AMM.Katana: {
218
- return "https://app.roninchain.com/liquidity";
219
- }
220
- }
115
+ const chainLabel = computeChainId === ChainId.MAINNET ? "ethereum/" : `${sanitizeChain(computeChainId)}/`;
116
+ return `https://app.uniswap.org/explore/pools/${chainLabel}${poolAddress?.toLowerCase()}`;
117
+ },
118
+ //Pool address mappings
119
+ Sonex: ({ poolAddress }) => `https://app.sonex.so/explore/pools/${poolAddress}`,
120
+ KYO: ({ poolAddress }) => `https://app.kyo.finance/liquidity/${poolAddress}`,
121
+ SushiSwapV3: ({ poolAddress }) => `https://www.sushi.com/${sushiswapv3Chains[computeChainId] ?? sanitizeChain(computeChainId)}/pool/v3/${poolAddress}`,
122
+ Swapr: ({ poolAddress }) => `https://v3.swapr.eth.limo/#/info/pools/${poolAddress}`,
123
+ Crust: ({ poolAddress }) => `https://v1.crust.finance/liquidity/${poolAddress}`,
124
+ ThirdTrade: ({ poolAddress }) => `https://third.trade/pool/${poolAddress}`,
125
+ Katana: ({ poolAddress }) => `https://app.roninchain.com/liquidity/${poolAddress}`,
126
+ SyncswapV3: ({ poolAddress }) => `https://syncswap.xyz/pool/${poolAddress}`,
127
+ //Token address mappings
128
+ Camelot: ({ token0, token1 }) => `https://app.camelot.exchange/liquidity?type=v3&token1=${token0}&token2=${token1}`,
129
+ QuickswapAlgebra: ({ token0, token1 }) => `https://quickswap.exchange/#/pools?currency0=${token0}&currency1=${token1}`,
130
+ QuickswapUni: ({ token0, token1 }) => `https://quickswap.exchange/#/pools?currency0=${token0}&currency1=${token1}`,
131
+ QuickswapAlgebraV1_2: ({ token0, token1 }) => `https://quickswap.exchange/#/pools?currency0=${token0}&currency1=${token1}`,
132
+ AERODROME: ({ token0, token1 }) => `https://aerodrome.finance/pools?token0=${token0}&token1=${token1}&type=1&chain=${computeChainId}`,
133
+ KOI: ({ token0, token1 }) => `https://dapp.koi.finance/pool/v3/new/${token0}/${token1}`,
134
+ zkSwap: ({ token0, token1 }) => `https://www.zkswap.finance/add/${token0}/${token1}/2000?chain=${computeChainId}`,
135
+ Velodrome: ({ token0, token1 }) => `https://velodrome.finance/pools?token0=${token0}&token1=${token1}&type=1&chain=${computeChainId}`,
136
+ //Token address and pool fess
137
+ PancakeSwapV3: ({ token0, token1, poolFee }) => `https://pancakeswap.finance/add/${token0}/${token1}/${sanitizeFee(poolFee)}?chain=${pancakeswapChains[computeChainId] ?? sanitizeChain(computeChainId)}`,
138
+ BaseSwap: ({ token0, token1, poolFee }) => `https://${computeChainId === ChainId.MODE ? "swapmode" : "baseswap"}.fi/addV3?currencyIdA=${token0}&currencyIdB=${token1}&feeAmount=${sanitizeFee(poolFee)}`,
139
+ Voltage: ({ token0, token1, poolFee }) => `https://app.voltage.finance/add/${token0}/${token1}?version=v3&feeAmount=${sanitizeFee(poolFee)}`,
140
+ Izumi: ({ token0, token1, poolFee }) => `https://${computeChainId === ChainId.ROOTSTOCK ? "woodswap.org" : "izumi.finance"}/trade/add-liquidity/?token0=${token0}&token1=${token1}&chainId=${computeChainId}&fee=${Number(poolFee) * 10000}`,
141
+ SupswapV3: ({ token0, token1, poolFee }) => `https://supswap.xyz/add/${token0}/${token1}/${sanitizeFee(poolFee)}`,
142
+ Iguana: ({ token0, token1, poolFee }) => `https://www.iguanadex.com/add/${token0}/${token1}/${sanitizeFee(poolFee)}?chain=${sanitizeChain(computeChainId)}`,
143
+ //Token symbols
144
+ Stryke: ({ symbolToken0, symbolToken1 }) => `https://www.stryke.xyz/en/trade/arbitrum/${symbolToken0}-${symbolToken1}`,
145
+ StrykePCS: ({ symbolToken0, symbolToken1 }) => `https://pancakeswap.stryke.xyz/${symbolToken0}-${symbolToken1}?mode=LP`,
146
+ StrykeSushi: ({ symbolToken0, symbolToken1 }) => `https://sushiswap.stryke.xyz/${symbolToken0}-${symbolToken1}?mode=LP`,
147
+ //Token symbols and pool fees
148
+ Neptune: ({ symbolToken0, symbolToken1, poolFee }) => `https://app.nep.finance/add/${symbolToken0}/${symbolToken1}/${sanitizeFee(poolFee)}`,
149
+ //Protocols without unique links for pools
150
+ Retro: () => "https://retro.finance/liquidity/managev3",
151
+ Horiza: () => "https:/app.horiza.io/liquidity",
152
+ Thruster: () => "https://app.thruster.finance/add",
153
+ Kim: () => "https://app.kim.exchange/positions",
154
+ ARTHSWAP: () => "https://app.arthswap.org/#/pools",
155
+ Fenix: () => "https://www.fenixfinance.io/",
156
+ Ramses: () => "https://app.ramses.exchange/swap",
157
+ SwapX: () => "https://swapx.fi/earn",
158
+ ZERO: () => "https://www.zkzero.fi/",
159
+ };
160
+ return ammLinkMap[params.amm]?.(params)?.toLowerCase();
221
161
  }
222
162
  }
@@ -5577,14 +5577,47 @@ declare const app: Elysia<"", false, {
5577
5577
  } & {
5578
5578
  v3: {
5579
5579
  uniswapv4: {
5580
- get: {
5581
- body: unknown;
5582
- params: {};
5583
- query: {};
5584
- headers: unknown;
5585
- response: {
5586
- [x: string]: any;
5587
- 200: any;
5580
+ index: {
5581
+ get: {
5582
+ body: unknown;
5583
+ params: {};
5584
+ query: unknown;
5585
+ headers: unknown;
5586
+ response: {
5587
+ [x: string]: any;
5588
+ 200: any;
5589
+ };
5590
+ };
5591
+ };
5592
+ } & {
5593
+ ":chainId": {
5594
+ get: {
5595
+ body: unknown;
5596
+ params: {
5597
+ chainId: number;
5598
+ };
5599
+ query: unknown;
5600
+ headers: unknown;
5601
+ response: {
5602
+ [x: string]: any;
5603
+ 200: any;
5604
+ };
5605
+ };
5606
+ };
5607
+ } & {
5608
+ pool: {
5609
+ ":poolId": {
5610
+ get: {
5611
+ body: unknown;
5612
+ params: {
5613
+ poolId: string;
5614
+ };
5615
+ query: unknown;
5616
+ headers: unknown;
5617
+ response: {
5618
+ 200: UniswapV4PoolType[];
5619
+ };
5620
+ };
5588
5621
  };
5589
5622
  };
5590
5623
  };
@@ -1,6 +1,9 @@
1
1
  import type { apiDbClient } from "@db";
2
2
  import type { Prisma } from "@db/api";
3
3
  import type { MerklChainId, UniswapV4PoolType } from "@sdk";
4
+ export declare const Bytes32Dto: import("@sinclair/typebox").TObject<{
5
+ poolId: import("@sinclair/typebox").TRegExp;
6
+ }>;
4
7
  export declare const UniswapV4PoolsDto: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
5
8
  poolKey: import("@sinclair/typebox").TObject<{
6
9
  currency0: import("@sinclair/typebox").TString;
@@ -14,4 +14,9 @@ const UniswapV4PoolDto = t.Object({
14
14
  symbolCurrency0: t.String(),
15
15
  symbolCurrency1: t.String(),
16
16
  });
17
+ export const Bytes32Dto = t.Object({
18
+ poolId: t.RegExp(/^0x[a-fA-F0-9]{64}$/, {
19
+ description: "A 32-byte hexadecimal string (bytes32)",
20
+ }),
21
+ });
17
22
  export const UniswapV4PoolsDto = t.Record(t.String(), UniswapV4PoolDto);
@@ -769,14 +769,47 @@ export declare const v3: Elysia<"/v3", false, {
769
769
  } & {
770
770
  v3: {
771
771
  uniswapv4: {
772
- get: {
773
- body: unknown;
774
- params: {};
775
- query: {};
776
- headers: unknown;
777
- response: {
778
- [x: string]: any;
779
- 200: any;
772
+ index: {
773
+ get: {
774
+ body: unknown;
775
+ params: {};
776
+ query: unknown;
777
+ headers: unknown;
778
+ response: {
779
+ [x: string]: any;
780
+ 200: any;
781
+ };
782
+ };
783
+ };
784
+ } & {
785
+ ":chainId": {
786
+ get: {
787
+ body: unknown;
788
+ params: {
789
+ chainId: number;
790
+ };
791
+ query: unknown;
792
+ headers: unknown;
793
+ response: {
794
+ [x: string]: any;
795
+ 200: any;
796
+ };
797
+ };
798
+ };
799
+ } & {
800
+ pool: {
801
+ ":poolId": {
802
+ get: {
803
+ body: unknown;
804
+ params: {
805
+ poolId: string;
806
+ };
807
+ query: unknown;
808
+ headers: unknown;
809
+ response: {
810
+ 200: UniswapV4PoolType[];
811
+ };
812
+ };
780
813
  };
781
814
  };
782
815
  };
@@ -1,10 +1,4 @@
1
- import { type Elysia } from "elysia";
2
- export declare const response: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
3
- address: import("@sinclair/typebox").TString;
4
- asset: import("@sinclair/typebox").TString;
5
- chaind: import("@sinclair/typebox").TNumber;
6
- debtTokenAddress: import("@sinclair/typebox").TString;
7
- }>>;
1
+ import type { Elysia } from "elysia";
8
2
  declare const _default: (app: Elysia) => Elysia<"", false, {
9
3
  decorator: {};
10
4
  store: {};
@@ -19,14 +13,47 @@ declare const _default: (app: Elysia) => Elysia<"", false, {
19
13
  macroFn: {};
20
14
  }, {
21
15
  uniswapv4: {
22
- get: {
23
- body: unknown;
24
- params: {};
25
- query: {};
26
- headers: unknown;
27
- response: {
28
- [x: string]: any;
29
- 200: any;
16
+ index: {
17
+ get: {
18
+ body: unknown;
19
+ params: {};
20
+ query: unknown;
21
+ headers: unknown;
22
+ response: {
23
+ [x: string]: any;
24
+ 200: any;
25
+ };
26
+ };
27
+ };
28
+ } & {
29
+ ":chainId": {
30
+ get: {
31
+ body: unknown;
32
+ params: {
33
+ chainId: number;
34
+ };
35
+ query: unknown;
36
+ headers: unknown;
37
+ response: {
38
+ [x: string]: any;
39
+ 200: any;
40
+ };
41
+ };
42
+ };
43
+ } & {
44
+ pool: {
45
+ ":poolId": {
46
+ get: {
47
+ body: unknown;
48
+ params: {
49
+ poolId: string;
50
+ };
51
+ query: unknown;
52
+ headers: unknown;
53
+ response: {
54
+ 200: UniswapV4PoolType[];
55
+ };
56
+ };
30
57
  };
31
58
  };
32
59
  };
@@ -1,9 +1,29 @@
1
- import { getUniswapV4PoolsWithCache } from "@/engine/dynamicData/utils/getUniswapV4Pools";
2
- import { t } from "elysia";
3
- export const response = t.Array(t.Object({ address: t.String(), asset: t.String(), chaind: t.Number(), debtTokenAddress: t.String() }));
4
- export default (app) => app.get("/uniswapv4", async () => {
5
- return await getUniswapV4PoolsWithCache();
1
+ import { Redis } from "@/cache";
2
+ import { UniV4ChainIdArray, getUniswapV4Pools } from "@/engine/dynamicData/utils/getUniswapV4Pools";
3
+ import { ChainUniqueDto } from "@/modules/v4/chain/chain.model";
4
+ import { Bytes32Dto } from "@/modules/v4/uniswapV4";
5
+ import { UnsupportedNetwork } from "@/utils/error";
6
+ export default (app) => app.group("/uniswapv4", router => router
7
+ .get("/", async () => {
8
+ return await Redis.getOrSet("UniswapV4Pools", getUniswapV4Pools);
6
9
  }, {
7
- query: t.Object({}),
8
- tags: ["Protocols"],
9
- });
10
+ tags: ["uniswapv4"],
11
+ })
12
+ .get("/:chainId", async ({ params }) => {
13
+ return (await Redis.getOrSet("UniswapV4Pools", getUniswapV4Pools, params.chainId))[params.chainId];
14
+ }, {
15
+ params: ChainUniqueDto,
16
+ beforeHandle: ({ params }) => {
17
+ if (!UniV4ChainIdArray.includes(params.chainId))
18
+ throw new UnsupportedNetwork(params.chainId);
19
+ },
20
+ tags: ["uniswapv4"],
21
+ })
22
+ .get("/pool/:poolId", async ({ params }) => {
23
+ return Object.values((await Redis.getOrSet("UniswapV4Pools", getUniswapV4Pools)))
24
+ .flatMap(x => (x ? Object.values(x) : []))
25
+ .filter(p => p.poolId === params.poolId);
26
+ }, {
27
+ params: Bytes32Dto,
28
+ tags: ["uniswapv4"],
29
+ }));