four-flap-meme-sdk 1.3.90 → 1.3.91

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.
@@ -282,24 +282,30 @@ async function detectOrcaWhirlpool(mint, connection, debug) {
282
282
  }
283
283
  /**
284
284
  * 检测 Raydium 池子
285
+ * 直接使用 Raydium 公开 API,更可靠
285
286
  */
286
287
  async function detectRaydiumPools(mint, connection, debug) {
287
288
  const pools = [];
288
289
  try {
289
- const sdk = await loadRaydiumSdk();
290
- if (!sdk)
290
+ // 直接调用 Raydium 公开 API
291
+ const apiUrl = `https://api-v3.raydium.io/pools/info/mint?mint1=${mint}&poolType=all&poolSortField=default&sortType=desc&pageSize=20&page=1`;
292
+ const response = await fetch(apiUrl);
293
+ if (!response.ok) {
294
+ if (debug)
295
+ console.log('[LP Inspect] Raydium API request failed:', response.status);
291
296
  return pools;
292
- const { initRaydium } = sdk;
293
- const raydium = await initRaydium(connection);
294
- // 通过 API 查找所有包含该代币的池子
295
- const poolList = await raydium.api.fetchPoolByMints({
296
- mint1: mint,
297
- mint2: WSOL,
298
- });
299
- // poolList 可能是对象而不是数组,需要处理
300
- const poolArray = poolList?.data || [];
297
+ }
298
+ const result = await response.json();
299
+ if (!result.success || !result.data?.data) {
300
+ if (debug)
301
+ console.log('[LP Inspect] Raydium API returned no data');
302
+ return pools;
303
+ }
304
+ const poolArray = result.data.data;
301
305
  if (!Array.isArray(poolArray))
302
306
  return pools;
307
+ if (debug)
308
+ console.log('[LP Inspect] Raydium found', poolArray.length, 'pools');
303
309
  for (const pool of poolArray) {
304
310
  // 判断池子类型
305
311
  let platform = 'RAYDIUM_AMM';
@@ -309,6 +315,7 @@ async function detectRaydiumPools(mint, connection, debug) {
309
315
  else if (pool.type === 'Concentrated') {
310
316
  platform = 'RAYDIUM_CLMM';
311
317
  }
318
+ // 判断哪个是 base token
312
319
  const isBaseA = pool.mintA?.address === mint;
313
320
  const quoteToken = isBaseA ? pool.mintB?.address : pool.mintA?.address;
314
321
  const quoteSymbol = isBaseA ? pool.mintB?.symbol : pool.mintA?.symbol;
@@ -325,13 +332,14 @@ async function detectRaydiumPools(mint, connection, debug) {
325
332
  quoteDecimals: quoteDecimals || 9,
326
333
  baseToken: mint,
327
334
  reserveQuote: String(reserveQuoteNum || 0),
328
- reserveQuoteRaw: BigInt(Math.floor((reserveQuoteNum || 0) * 1e9)),
335
+ reserveQuoteRaw: BigInt(Math.floor((reserveQuoteNum || 0) * Math.pow(10, quoteDecimals || 9))),
329
336
  reserveBase: String(reserveBaseNum || 0),
330
- reserveBaseRaw: BigInt(Math.floor((reserveBaseNum || 0) * 1e9)),
337
+ reserveBaseRaw: BigInt(Math.floor((reserveBaseNum || 0) * Math.pow(10, pool.mintB?.decimals || 6))),
331
338
  price: pool.price,
332
339
  feeBps: Math.floor((pool.feeRate || 0) * 10000),
333
340
  extra: {
334
341
  type: pool.type,
342
+ tvl: pool.tvl,
335
343
  lpMint: pool.lpMint?.address,
336
344
  },
337
345
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.3.90",
3
+ "version": "1.3.91",
4
4
  "description": "SDK for Flap bonding curve, four.meme TokenManager, and Solana DEX",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",