four-flap-meme-sdk 1.3.91 → 1.3.93

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.
Files changed (127) hide show
  1. package/dist/clients/blockrazor.js +0 -1
  2. package/dist/contracts/tm-bundle-merkle/config.d.ts +5 -0
  3. package/dist/contracts/tm-bundle-merkle/config.js +10 -0
  4. package/dist/contracts/tm-bundle-merkle/core.js +92 -24
  5. package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +103 -54
  6. package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +0 -1
  7. package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +36 -6
  8. package/dist/contracts/tm-bundle-merkle/swap.d.ts +0 -3
  9. package/dist/contracts/tm-bundle-merkle/swap.js +59 -6
  10. package/dist/flap/portal-bundle-merkle/config.d.ts +8 -0
  11. package/dist/flap/portal-bundle-merkle/config.js +17 -0
  12. package/dist/flap/portal-bundle-merkle/core.js +120 -68
  13. package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
  14. package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
  15. package/dist/flap/portal-bundle-merkle/pancake-proxy.js +136 -78
  16. package/dist/flap/portal-bundle-merkle/swap-buy-first.d.ts +0 -2
  17. package/dist/flap/portal-bundle-merkle/swap-buy-first.js +49 -30
  18. package/dist/flap/portal-bundle-merkle/swap.d.ts +0 -2
  19. package/dist/flap/portal-bundle-merkle/swap.js +75 -47
  20. package/dist/flap/portal-bundle-merkle/types.d.ts +1 -0
  21. package/dist/index.d.ts +1 -2
  22. package/dist/index.js +0 -1
  23. package/dist/pancake/bundle-buy-first.d.ts +1 -1
  24. package/dist/pancake/bundle-buy-first.js +49 -17
  25. package/dist/pancake/bundle-swap.d.ts +1 -4
  26. package/dist/pancake/bundle-swap.js +98 -33
  27. package/dist/utils/erc20.d.ts +108 -2
  28. package/dist/utils/erc20.js +65 -17
  29. package/package.json +4 -39
  30. package/dist/sol/constants.d.ts +0 -126
  31. package/dist/sol/constants.js +0 -145
  32. package/dist/sol/dex/index.d.ts +0 -8
  33. package/dist/sol/dex/index.js +0 -12
  34. package/dist/sol/dex/meteora/client.d.ts +0 -76
  35. package/dist/sol/dex/meteora/client.js +0 -219
  36. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
  37. package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
  38. package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
  39. package/dist/sol/dex/meteora/damm-v1.js +0 -315
  40. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
  41. package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
  42. package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
  43. package/dist/sol/dex/meteora/damm-v2.js +0 -632
  44. package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
  45. package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
  46. package/dist/sol/dex/meteora/dbc.d.ts +0 -192
  47. package/dist/sol/dex/meteora/dbc.js +0 -619
  48. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
  49. package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
  50. package/dist/sol/dex/meteora/dlmm.d.ts +0 -146
  51. package/dist/sol/dex/meteora/dlmm.js +0 -593
  52. package/dist/sol/dex/meteora/index.d.ts +0 -25
  53. package/dist/sol/dex/meteora/index.js +0 -65
  54. package/dist/sol/dex/meteora/types.d.ts +0 -787
  55. package/dist/sol/dex/meteora/types.js +0 -110
  56. package/dist/sol/dex/orca/index.d.ts +0 -10
  57. package/dist/sol/dex/orca/index.js +0 -16
  58. package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
  59. package/dist/sol/dex/orca/orca-bundle.js +0 -173
  60. package/dist/sol/dex/orca/orca.d.ts +0 -65
  61. package/dist/sol/dex/orca/orca.js +0 -474
  62. package/dist/sol/dex/orca/types.d.ts +0 -263
  63. package/dist/sol/dex/orca/types.js +0 -38
  64. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
  65. package/dist/sol/dex/orca/wavebreak-bundle.js +0 -198
  66. package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
  67. package/dist/sol/dex/orca/wavebreak-types.js +0 -23
  68. package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
  69. package/dist/sol/dex/orca/wavebreak.js +0 -497
  70. package/dist/sol/dex/pump/index.d.ts +0 -9
  71. package/dist/sol/dex/pump/index.js +0 -14
  72. package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
  73. package/dist/sol/dex/pump/pump-bundle.js +0 -383
  74. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
  75. package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
  76. package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
  77. package/dist/sol/dex/pump/pump-swap.js +0 -199
  78. package/dist/sol/dex/pump/pump.d.ts +0 -35
  79. package/dist/sol/dex/pump/pump.js +0 -352
  80. package/dist/sol/dex/pump/types.d.ts +0 -215
  81. package/dist/sol/dex/pump/types.js +0 -5
  82. package/dist/sol/dex/raydium/index.d.ts +0 -8
  83. package/dist/sol/dex/raydium/index.js +0 -12
  84. package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
  85. package/dist/sol/dex/raydium/launchlab.js +0 -210
  86. package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
  87. package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
  88. package/dist/sol/dex/raydium/raydium.d.ts +0 -40
  89. package/dist/sol/dex/raydium/raydium.js +0 -366
  90. package/dist/sol/dex/raydium/types.d.ts +0 -240
  91. package/dist/sol/dex/raydium/types.js +0 -5
  92. package/dist/sol/index.d.ts +0 -10
  93. package/dist/sol/index.js +0 -16
  94. package/dist/sol/jito/bundle.d.ts +0 -90
  95. package/dist/sol/jito/bundle.js +0 -263
  96. package/dist/sol/jito/index.d.ts +0 -7
  97. package/dist/sol/jito/index.js +0 -7
  98. package/dist/sol/jito/tip.d.ts +0 -51
  99. package/dist/sol/jito/tip.js +0 -83
  100. package/dist/sol/jito/types.d.ts +0 -100
  101. package/dist/sol/jito/types.js +0 -5
  102. package/dist/sol/token/create-complete.d.ts +0 -115
  103. package/dist/sol/token/create-complete.js +0 -235
  104. package/dist/sol/token/create-token.d.ts +0 -57
  105. package/dist/sol/token/create-token.js +0 -230
  106. package/dist/sol/token/index.d.ts +0 -9
  107. package/dist/sol/token/index.js +0 -14
  108. package/dist/sol/token/metadata-upload.d.ts +0 -86
  109. package/dist/sol/token/metadata-upload.js +0 -173
  110. package/dist/sol/token/metadata.d.ts +0 -92
  111. package/dist/sol/token/metadata.js +0 -274
  112. package/dist/sol/token/types.d.ts +0 -153
  113. package/dist/sol/token/types.js +0 -5
  114. package/dist/sol/types.d.ts +0 -176
  115. package/dist/sol/types.js +0 -7
  116. package/dist/sol/utils/balance.d.ts +0 -160
  117. package/dist/sol/utils/balance.js +0 -638
  118. package/dist/sol/utils/connection.d.ts +0 -78
  119. package/dist/sol/utils/connection.js +0 -168
  120. package/dist/sol/utils/index.d.ts +0 -9
  121. package/dist/sol/utils/index.js +0 -9
  122. package/dist/sol/utils/lp-inspect.d.ts +0 -129
  123. package/dist/sol/utils/lp-inspect.js +0 -529
  124. package/dist/sol/utils/transfer.d.ts +0 -125
  125. package/dist/sol/utils/transfer.js +0 -220
  126. package/dist/sol/utils/wallet.d.ts +0 -107
  127. package/dist/sol/utils/wallet.js +0 -210
@@ -1,529 +0,0 @@
1
- /**
2
- * Solana LP 检测工具
3
- * 自动判断代币在哪个平台(内盘/外盘)
4
- * @module sol/utils/lp-inspect
5
- */
6
- import { PublicKey } from '@solana/web3.js';
7
- import { createConnection } from './connection.js';
8
- // ============================================================================
9
- // 常量
10
- // ============================================================================
11
- /** Wrapped SOL */
12
- const WSOL = 'So11111111111111111111111111111111111111112';
13
- /** 常用 Quote Token */
14
- const QUOTE_TOKENS = {
15
- [WSOL]: { symbol: 'SOL', decimals: 9 },
16
- 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v': { symbol: 'USDC', decimals: 6 },
17
- 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB': { symbol: 'USDT', decimals: 6 },
18
- };
19
- // ============================================================================
20
- // 动态导入(避免循环依赖和类型冲突)
21
- // ============================================================================
22
- /** 懒加载 Pump.fun SDK */
23
- async function loadPumpSdk() {
24
- const { getBondingCurveInfo } = await import('../dex/pump/pump.js');
25
- const { getPumpSwapPoolInfo } = await import('../dex/pump/pump-swap.js');
26
- return { getBondingCurveInfo, getPumpSwapPoolInfo };
27
- }
28
- /** 懒加载 Meteora SDK */
29
- async function loadMeteoraSdk() {
30
- const { findDbcPoolByBaseMint, getDbcPoolInfo } = await import('../dex/meteora/dbc.js');
31
- const { findDlmmPool, getDlmmPoolInfo } = await import('../dex/meteora/dlmm.js');
32
- return { findDbcPoolByBaseMint, getDbcPoolInfo, findDlmmPool, getDlmmPoolInfo };
33
- }
34
- /** 懒加载 Orca SDK */
35
- async function loadOrcaSdk() {
36
- try {
37
- const { getWavebreakBondingCurveInfo } = await import('../dex/orca/wavebreak.js');
38
- const { findOrcaPool, getOrcaPoolInfo } = await import('../dex/orca/orca.js');
39
- return { getWavebreakBondingCurveInfo, findOrcaPool, getOrcaPoolInfo };
40
- }
41
- catch {
42
- return null;
43
- }
44
- }
45
- /** 懒加载 Raydium SDK */
46
- async function loadRaydiumSdk() {
47
- try {
48
- const { initRaydium, getRaydiumPoolInfo } = await import('../dex/raydium/raydium.js');
49
- return { initRaydium, getRaydiumPoolInfo };
50
- }
51
- catch {
52
- return null;
53
- }
54
- }
55
- // ============================================================================
56
- // 内盘检测
57
- // ============================================================================
58
- /**
59
- * 检测 Pump.fun Bonding Curve
60
- */
61
- async function detectPumpBondingCurve(mint, connection, debug) {
62
- try {
63
- const { getBondingCurveInfo } = await loadPumpSdk();
64
- const info = await getBondingCurveInfo(connection, mint);
65
- if (!info)
66
- return null;
67
- // 计算价格 (virtualSolReserves / virtualTokenReserves)
68
- const price = Number(info.virtualSolReserves) / Number(info.virtualTokenReserves);
69
- // 计算进度 (realSolReserves / 85 SOL threshold)
70
- const GRADUATION_THRESHOLD = 85000000000n; // 85 SOL in lamports
71
- const progress = Math.min(100, Number(info.realSolReserves * 100n / GRADUATION_THRESHOLD));
72
- return {
73
- type: 'pump',
74
- address: info.bondingCurve,
75
- complete: info.complete,
76
- reserveQuote: (Number(info.virtualSolReserves) / 1e9).toFixed(4),
77
- reserveQuoteRaw: info.virtualSolReserves,
78
- reserveToken: (Number(info.virtualTokenReserves) / 1e6).toFixed(0),
79
- reserveTokenRaw: info.virtualTokenReserves,
80
- price,
81
- progress,
82
- creator: info.creator,
83
- };
84
- }
85
- catch (err) {
86
- if (debug)
87
- console.log('[LP Inspect] Pump bonding curve check failed:', err);
88
- return null;
89
- }
90
- }
91
- /**
92
- * 检测 Meteora DBC
93
- */
94
- async function detectMeteoraDbc(mint, connection, debug) {
95
- try {
96
- const { findDbcPoolByBaseMint, getDbcPoolInfo } = await loadMeteoraSdk();
97
- const poolAddress = await findDbcPoolByBaseMint(mint, connection);
98
- if (!poolAddress)
99
- return null;
100
- const poolInfo = await getDbcPoolInfo(poolAddress, connection);
101
- return {
102
- type: 'meteora_dbc',
103
- address: poolAddress,
104
- complete: poolInfo.isMigrated,
105
- reserveQuote: poolInfo.quoteReserve,
106
- reserveQuoteRaw: BigInt(poolInfo.quoteReserve),
107
- reserveToken: poolInfo.baseReserve,
108
- reserveTokenRaw: BigInt(poolInfo.baseReserve),
109
- price: poolInfo.currentPrice,
110
- progress: poolInfo.progressPercent,
111
- creator: poolInfo.creator,
112
- };
113
- }
114
- catch (err) {
115
- if (debug)
116
- console.log('[LP Inspect] Meteora DBC check failed:', err);
117
- return null;
118
- }
119
- }
120
- /**
121
- * 检测 Orca Wavebreak
122
- */
123
- async function detectOrcaWavebreak(mint, connection, debug) {
124
- try {
125
- const sdk = await loadOrcaSdk();
126
- if (!sdk)
127
- return null;
128
- const { getWavebreakBondingCurveInfo } = sdk;
129
- const info = await getWavebreakBondingCurveInfo(mint, connection);
130
- if (!info)
131
- return null;
132
- return {
133
- type: 'orca_wavebreak',
134
- address: info.bondingCurveAddress,
135
- complete: info.isGraduated,
136
- reserveQuote: (Number(info.quoteAmount) / 1e9).toFixed(4),
137
- reserveQuoteRaw: info.quoteAmount,
138
- reserveToken: info.baseAmount.toString(),
139
- reserveTokenRaw: info.baseAmount,
140
- price: info.currentPrice,
141
- progress: info.progressPercent,
142
- creator: info.creator,
143
- };
144
- }
145
- catch (err) {
146
- if (debug)
147
- console.log('[LP Inspect] Orca Wavebreak check failed:', err);
148
- return null;
149
- }
150
- }
151
- /**
152
- * 检测 Raydium LaunchLab
153
- * 注意:LaunchLab API 可能需要特定的端点,这里做基础检测
154
- */
155
- async function detectRaydiumLaunchLab(_mint, _connection, _debug) {
156
- // Raydium LaunchLab 检测暂未实现
157
- // 需要 Raydium 提供专门的 LaunchLab API
158
- return null;
159
- }
160
- // ============================================================================
161
- // 外盘检测
162
- // ============================================================================
163
- /**
164
- * 检测 Pump.fun Swap Pool
165
- */
166
- async function detectPumpSwapPool(mint, connection, debug) {
167
- try {
168
- const { getPumpSwapPoolInfo } = await loadPumpSdk();
169
- const info = await getPumpSwapPoolInfo(connection, mint);
170
- if (!info)
171
- return null;
172
- // 获取池子余额
173
- const poolPubkey = new PublicKey(info.poolAddress);
174
- const balance = await connection.getBalance(poolPubkey);
175
- return {
176
- platform: 'PUMP_SWAP',
177
- poolAddress: info.poolAddress,
178
- quoteToken: info.quoteMint,
179
- quoteSymbol: 'SOL',
180
- quoteDecimals: 9,
181
- baseToken: info.baseMint,
182
- reserveQuote: (balance / 1e9).toFixed(4),
183
- reserveQuoteRaw: BigInt(balance),
184
- reserveBase: info.lpSupply.toString(),
185
- reserveBaseRaw: info.lpSupply,
186
- extra: {
187
- lpMint: info.lpMint,
188
- creator: info.creator,
189
- },
190
- };
191
- }
192
- catch (err) {
193
- if (debug)
194
- console.log('[LP Inspect] Pump Swap pool check failed:', err);
195
- return null;
196
- }
197
- }
198
- /**
199
- * 检测 Meteora DLMM Pool
200
- */
201
- async function detectMeteoraDlmm(mint, connection, debug) {
202
- try {
203
- const { findDlmmPool, getDlmmPoolInfo } = await loadMeteoraSdk();
204
- // 尝试与 SOL 配对
205
- const poolAddress = await findDlmmPool(mint, WSOL, connection);
206
- if (!poolAddress)
207
- return null;
208
- const poolInfo = await getDlmmPoolInfo(poolAddress, connection);
209
- // 判断哪个是 base token
210
- const isTokenX = poolInfo.tokenXMint === mint;
211
- const reserveQuote = isTokenX ? poolInfo.tokenYReserve : poolInfo.tokenXReserve;
212
- const reserveBase = isTokenX ? poolInfo.tokenXReserve : poolInfo.tokenYReserve;
213
- return {
214
- platform: 'METEORA_DLMM',
215
- poolAddress,
216
- quoteToken: isTokenX ? poolInfo.tokenYMint : poolInfo.tokenXMint,
217
- quoteSymbol: 'SOL',
218
- quoteDecimals: 9,
219
- baseToken: mint,
220
- reserveQuote: reserveQuote || '0',
221
- reserveQuoteRaw: BigInt(reserveQuote || 0),
222
- reserveBase: reserveBase || '0',
223
- reserveBaseRaw: BigInt(reserveBase || 0),
224
- price: poolInfo.currentPrice,
225
- feeBps: poolInfo.feeBps,
226
- extra: {
227
- binStep: poolInfo.binStep,
228
- activeId: poolInfo.activeId,
229
- },
230
- };
231
- }
232
- catch (err) {
233
- if (debug)
234
- console.log('[LP Inspect] Meteora DLMM check failed:', err);
235
- return null;
236
- }
237
- }
238
- /**
239
- * 检测 Orca Whirlpool
240
- */
241
- async function detectOrcaWhirlpool(mint, connection, debug) {
242
- try {
243
- const sdk = await loadOrcaSdk();
244
- if (!sdk)
245
- return null;
246
- const { findOrcaPool, getOrcaPoolInfo } = sdk;
247
- // 尝试与 SOL 配对(常见的 tick spacing: 64, 128)
248
- let poolAddress = await findOrcaPool(mint, WSOL, 64, connection);
249
- if (!poolAddress) {
250
- poolAddress = await findOrcaPool(mint, WSOL, 128, connection);
251
- }
252
- if (!poolAddress)
253
- return null;
254
- const poolInfo = await getOrcaPoolInfo(poolAddress, connection);
255
- // 判断哪个是 base token
256
- const isTokenA = poolInfo.tokenMintA === mint;
257
- return {
258
- platform: 'ORCA_WHIRLPOOL',
259
- poolAddress,
260
- quoteToken: isTokenA ? poolInfo.tokenMintB : poolInfo.tokenMintA,
261
- quoteSymbol: 'SOL',
262
- quoteDecimals: isTokenA ? poolInfo.tokenDecimalsB : poolInfo.tokenDecimalsA,
263
- baseToken: mint,
264
- reserveQuote: '0', // Whirlpool 需要通过 vault 查询
265
- reserveQuoteRaw: 0n,
266
- reserveBase: '0',
267
- reserveBaseRaw: 0n,
268
- price: poolInfo.price,
269
- feeBps: poolInfo.feeRate,
270
- extra: {
271
- tickSpacing: poolInfo.tickSpacing,
272
- currentTick: poolInfo.currentTick,
273
- liquidity: poolInfo.liquidity,
274
- },
275
- };
276
- }
277
- catch (err) {
278
- if (debug)
279
- console.log('[LP Inspect] Orca Whirlpool check failed:', err);
280
- return null;
281
- }
282
- }
283
- /**
284
- * 检测 Raydium 池子
285
- * 直接使用 Raydium 公开 API,更可靠
286
- */
287
- async function detectRaydiumPools(mint, connection, debug) {
288
- const pools = [];
289
- try {
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);
296
- return pools;
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;
305
- if (!Array.isArray(poolArray))
306
- return pools;
307
- if (debug)
308
- console.log('[LP Inspect] Raydium found', poolArray.length, 'pools');
309
- for (const pool of poolArray) {
310
- // 判断池子类型
311
- let platform = 'RAYDIUM_AMM';
312
- if (pool.programId?.includes('CPMMoo')) {
313
- platform = 'RAYDIUM_CPMM';
314
- }
315
- else if (pool.type === 'Concentrated') {
316
- platform = 'RAYDIUM_CLMM';
317
- }
318
- // 判断哪个是 base token
319
- const isBaseA = pool.mintA?.address === mint;
320
- const quoteToken = isBaseA ? pool.mintB?.address : pool.mintA?.address;
321
- const quoteSymbol = isBaseA ? pool.mintB?.symbol : pool.mintA?.symbol;
322
- const quoteDecimals = isBaseA ? pool.mintB?.decimals : pool.mintA?.decimals;
323
- const reserveQuoteNum = isBaseA ? pool.mintAmountB : pool.mintAmountA;
324
- const reserveBaseNum = isBaseA ? pool.mintAmountA : pool.mintAmountB;
325
- if (!quoteToken)
326
- continue;
327
- pools.push({
328
- platform,
329
- poolAddress: pool.id,
330
- quoteToken: quoteToken || '',
331
- quoteSymbol: quoteSymbol || 'UNKNOWN',
332
- quoteDecimals: quoteDecimals || 9,
333
- baseToken: mint,
334
- reserveQuote: String(reserveQuoteNum || 0),
335
- reserveQuoteRaw: BigInt(Math.floor((reserveQuoteNum || 0) * Math.pow(10, quoteDecimals || 9))),
336
- reserveBase: String(reserveBaseNum || 0),
337
- reserveBaseRaw: BigInt(Math.floor((reserveBaseNum || 0) * Math.pow(10, pool.mintB?.decimals || 6))),
338
- price: pool.price,
339
- feeBps: Math.floor((pool.feeRate || 0) * 10000),
340
- extra: {
341
- type: pool.type,
342
- tvl: pool.tvl,
343
- lpMint: pool.lpMint?.address,
344
- },
345
- });
346
- }
347
- }
348
- catch (err) {
349
- if (debug)
350
- console.log('[LP Inspect] Raydium pools check failed:', err);
351
- }
352
- return pools;
353
- }
354
- // ============================================================================
355
- // 主函数
356
- // ============================================================================
357
- /**
358
- * 检测 Solana 代币的 LP 所在平台
359
- *
360
- * @param mint 代币 Mint 地址
361
- * @param options 检测选项
362
- * @returns LP 信息
363
- *
364
- * @example
365
- * ```typescript
366
- * const lpInfo = await inspectSolanaTokenLP('TokenMintAddress...', {
367
- * rpcUrl: 'https://api.mainnet-beta.solana.com',
368
- * debug: true,
369
- * })
370
- *
371
- * if (lpInfo.platform === 'PUMP_BONDING_CURVE') {
372
- * console.log('代币在 Pump.fun 内盘')
373
- * console.log('毕业进度:', lpInfo.bondingCurve?.progress)
374
- * } else if (lpInfo.bestPool) {
375
- * console.log('最佳池子:', lpInfo.bestPool.platform)
376
- * console.log('流动性:', lpInfo.bestPool.reserveQuote)
377
- * }
378
- * ```
379
- */
380
- export async function inspectSolanaTokenLP(mint, options = {}) {
381
- const startTime = Date.now();
382
- if (!options.connection && !options.rpcUrl) {
383
- throw new Error('Either connection or rpcUrl is required in options');
384
- }
385
- const connection = options.connection || createConnection(options.rpcUrl);
386
- const debug = options.debug;
387
- // 初始化结果
388
- const result = {
389
- mint,
390
- platform: 'UNKNOWN',
391
- pools: [],
392
- };
393
- // 获取代币信息
394
- try {
395
- const mintPubkey = new PublicKey(mint);
396
- const mintInfo = await connection.getParsedAccountInfo(mintPubkey);
397
- if (mintInfo.value?.data && 'parsed' in mintInfo.value.data) {
398
- const parsed = mintInfo.value.data.parsed;
399
- const decimals = parsed.info.decimals;
400
- result.decimals = decimals;
401
- result.totalSupplyRaw = BigInt(parsed.info.supply);
402
- result.totalSupply = (Number(result.totalSupplyRaw) / Math.pow(10, decimals)).toString();
403
- }
404
- }
405
- catch (err) {
406
- if (debug)
407
- console.log('[LP Inspect] Failed to get mint info:', err);
408
- }
409
- // ========================================
410
- // 1. 内盘检测(并行)
411
- // ========================================
412
- if (!options.skipBondingCurve) {
413
- const bondingCurveResults = await Promise.allSettled([
414
- detectPumpBondingCurve(mint, connection, debug),
415
- detectMeteoraDbc(mint, connection, debug),
416
- detectOrcaWavebreak(mint, connection, debug),
417
- detectRaydiumLaunchLab(mint, connection, debug),
418
- ]);
419
- // 查找第一个有效的内盘
420
- for (const r of bondingCurveResults) {
421
- if (r.status === 'fulfilled' && r.value && !r.value.complete) {
422
- result.bondingCurve = r.value;
423
- // 设置平台类型
424
- switch (r.value.type) {
425
- case 'pump':
426
- result.platform = 'PUMP_BONDING_CURVE';
427
- break;
428
- case 'meteora_dbc':
429
- result.platform = 'METEORA_DBC';
430
- break;
431
- case 'orca_wavebreak':
432
- result.platform = 'ORCA_WAVEBREAK';
433
- break;
434
- case 'raydium_launchlab':
435
- result.platform = 'RAYDIUM_LAUNCHLAB';
436
- break;
437
- }
438
- result.elapsed = Date.now() - startTime;
439
- return result;
440
- }
441
- }
442
- }
443
- // ========================================
444
- // 2. 外盘检测(并行)
445
- // ========================================
446
- if (!options.skipPools) {
447
- const poolResults = await Promise.allSettled([
448
- detectPumpSwapPool(mint, connection, debug),
449
- detectMeteoraDlmm(mint, connection, debug),
450
- detectOrcaWhirlpool(mint, connection, debug),
451
- detectRaydiumPools(mint, connection, debug),
452
- ]);
453
- // 收集所有有效的池子
454
- for (const r of poolResults) {
455
- if (r.status === 'fulfilled' && r.value) {
456
- if (Array.isArray(r.value)) {
457
- result.pools.push(...r.value);
458
- }
459
- else {
460
- result.pools.push(r.value);
461
- }
462
- }
463
- }
464
- // 按流动性排序
465
- result.pools.sort((a, b) => {
466
- const liquidityA = Number(a.reserveQuoteRaw);
467
- const liquidityB = Number(b.reserveQuoteRaw);
468
- return liquidityB - liquidityA;
469
- });
470
- // 设置最佳池子
471
- if (result.pools.length > 0) {
472
- result.bestPool = result.pools[0];
473
- // 设置平台类型
474
- if (result.pools.length > 1) {
475
- result.platform = 'MULTI_POOL';
476
- }
477
- else {
478
- result.platform = result.bestPool.platform;
479
- }
480
- }
481
- }
482
- result.elapsed = Date.now() - startTime;
483
- return result;
484
- }
485
- /**
486
- * 快速检测代币是否在内盘
487
- *
488
- * @param mint 代币 Mint 地址
489
- * @param options 检测选项
490
- * @returns 如果在内盘返回内盘信息,否则返回 null
491
- */
492
- export async function detectBondingCurve(mint, options = {}) {
493
- if (!options.connection && !options.rpcUrl) {
494
- throw new Error('Either connection or rpcUrl is required in options');
495
- }
496
- const connection = options.connection || createConnection(options.rpcUrl);
497
- const debug = options.debug;
498
- // 并行检测所有内盘
499
- const results = await Promise.allSettled([
500
- detectPumpBondingCurve(mint, connection, debug),
501
- detectMeteoraDbc(mint, connection, debug),
502
- detectOrcaWavebreak(mint, connection, debug),
503
- detectRaydiumLaunchLab(mint, connection, debug),
504
- ]);
505
- // 返回第一个未毕业的内盘
506
- for (const r of results) {
507
- if (r.status === 'fulfilled' && r.value && !r.value.complete) {
508
- return r.value;
509
- }
510
- }
511
- return null;
512
- }
513
- /**
514
- * 判断代币是否已毕业(不在任何内盘)
515
- */
516
- export async function isTokenGraduated(mint, options = {}) {
517
- const bondingCurve = await detectBondingCurve(mint, options);
518
- return bondingCurve === null;
519
- }
520
- /**
521
- * 获取代币的最佳交易池
522
- */
523
- export async function getBestPool(mint, options = {}) {
524
- const lpInfo = await inspectSolanaTokenLP(mint, {
525
- ...options,
526
- skipBondingCurve: true,
527
- });
528
- return lpInfo.bestPool || null;
529
- }
@@ -1,125 +0,0 @@
1
- /**
2
- * Solana SOL 转账功能
3
- * SDK 只负责构建和签名交易,提交到后端服务器广播
4
- * @module sol/utils/transfer
5
- */
6
- import { Connection, Keypair, PublicKey, TransactionInstruction } from '@solana/web3.js';
7
- /**
8
- * 转账项
9
- */
10
- export interface TransferItem {
11
- to: string;
12
- amount: bigint;
13
- }
14
- /**
15
- * 签名后的转账交易
16
- */
17
- export interface SignedTransferTransaction {
18
- /** Base64 编码的交易数据 */
19
- data: string;
20
- /** 交易签名 */
21
- signature: string;
22
- /** 转账详情 */
23
- transfers: TransferItem[];
24
- /** blockhash */
25
- recentBlockhash: string;
26
- /** 最后有效区块高度 */
27
- lastValidBlockHeight: number;
28
- }
29
- /**
30
- * 批量签名结果
31
- */
32
- export interface BatchSignedTransfers {
33
- /** 签名后的交易列表 */
34
- transactions: SignedTransferTransaction[];
35
- /** 总转账数 */
36
- totalTransfers: number;
37
- /** 总交易数 */
38
- totalTransactions: number;
39
- /** 创建时间 */
40
- createdAt: number;
41
- }
42
- /**
43
- * 构建转账指令
44
- * @param from 发送者公钥
45
- * @param to 接收者地址
46
- * @param amount lamports
47
- */
48
- export declare function buildTransferInstruction(from: PublicKey, to: string, amount: bigint): TransactionInstruction;
49
- /**
50
- * 构建批量转账指令
51
- * @param from 发送者公钥
52
- * @param transfers 转账列表
53
- */
54
- export declare function buildTransferInstructions(from: PublicKey, transfers: TransferItem[]): TransactionInstruction[];
55
- /**
56
- * 构建并签名单笔 SOL 转账
57
- * @param connection Solana 连接
58
- * @param from 发送者 Keypair
59
- * @param to 接收者地址
60
- * @param amount lamports
61
- */
62
- export declare function signTransferSOL(connection: Connection, from: Keypair, to: string, amount: bigint): Promise<SignedTransferTransaction>;
63
- /**
64
- * 构建并签名单笔 SOL 转账(使用 SOL 数量)
65
- */
66
- export declare function signTransferSOLAmount(connection: Connection, from: Keypair, to: string, solAmount: number): Promise<SignedTransferTransaction>;
67
- /**
68
- * 构建并签名批量转账(单笔交易,多个指令)
69
- * 单笔交易最多约 20-30 个转账
70
- * @param connection Solana 连接
71
- * @param from 发送者 Keypair
72
- * @param transfers 转账列表
73
- */
74
- export declare function signBatchTransferSOL(connection: Connection, from: Keypair, transfers: TransferItem[]): Promise<SignedTransferTransaction>;
75
- /**
76
- * 构建并签名批量转账(多笔交易)
77
- * 自动分批处理大量转账
78
- * @param connection Solana 连接
79
- * @param from 发送者 Keypair
80
- * @param transfers 转账列表
81
- * @param batchSize 每批大小(默认 20)
82
- */
83
- export declare function signBatchTransferSOLMultiple(connection: Connection, from: Keypair, transfers: TransferItem[], batchSize?: number): Promise<BatchSignedTransfers>;
84
- /**
85
- * 多钱包转账项
86
- */
87
- export interface MultiWalletTransferItem {
88
- from: Keypair;
89
- to: string;
90
- amount: bigint;
91
- }
92
- /**
93
- * 签名多钱包转账(每个钱包一笔交易)
94
- * 用于归集或分发场景
95
- * @param connection Solana 连接
96
- * @param transfers 转账列表
97
- */
98
- export declare function signMultiWalletTransfers(connection: Connection, transfers: MultiWalletTransferItem[]): Promise<BatchSignedTransfers>;
99
- /**
100
- * 归集 SOL(多个钱包转到一个地址)
101
- * @param connection Solana 连接
102
- * @param wallets 钱包列表
103
- * @param toAddress 目标地址
104
- * @param amounts 每个钱包转账金额(lamports),如果为空则转全部(保留 5000 lamports 作为手续费)
105
- */
106
- export declare function signCollectSOL(connection: Connection, wallets: Keypair[], toAddress: string, amounts?: bigint[]): Promise<BatchSignedTransfers>;
107
- /**
108
- * 分发 SOL(一个钱包转到多个地址)
109
- * @param connection Solana 连接
110
- * @param from 发送者 Keypair
111
- * @param distributions 分发列表
112
- */
113
- export declare function signDistributeSOL(connection: Connection, from: Keypair, distributions: TransferItem[]): Promise<BatchSignedTransfers>;
114
- /**
115
- * 将签名结果转换为后端 API 格式
116
- */
117
- export declare function toBackendFormat(result: BatchSignedTransfers): {
118
- transactions: Array<{
119
- data: string;
120
- signature: string;
121
- }>;
122
- totalTransfers: number;
123
- totalTransactions: number;
124
- timestamp: number;
125
- };