four-flap-meme-sdk 1.5.55 → 1.5.58

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 (153) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -1
  3. package/dist/sol/constants.d.ts +150 -0
  4. package/dist/sol/constants.js +188 -0
  5. package/dist/sol/dex/blockrazor/client.d.ts +51 -0
  6. package/dist/sol/dex/blockrazor/client.js +96 -0
  7. package/dist/sol/dex/blockrazor/constants.d.ts +34 -0
  8. package/dist/sol/dex/blockrazor/constants.js +55 -0
  9. package/dist/sol/dex/blockrazor/geyser.d.ts +128 -0
  10. package/dist/sol/dex/blockrazor/geyser.js +530 -0
  11. package/dist/sol/dex/blockrazor/index.d.ts +18 -0
  12. package/dist/sol/dex/blockrazor/index.js +23 -0
  13. package/dist/sol/dex/blockrazor/send.d.ts +135 -0
  14. package/dist/sol/dex/blockrazor/send.js +254 -0
  15. package/dist/sol/dex/blockrazor/types.d.ts +191 -0
  16. package/dist/sol/dex/blockrazor/types.js +5 -0
  17. package/dist/sol/dex/index.d.ts +10 -0
  18. package/dist/sol/dex/index.js +16 -0
  19. package/dist/sol/dex/jup/client.d.ts +33 -0
  20. package/dist/sol/dex/jup/client.js +110 -0
  21. package/dist/sol/dex/jup/index.d.ts +16 -0
  22. package/dist/sol/dex/jup/index.js +148 -0
  23. package/dist/sol/dex/jup/legacy.d.ts +623 -0
  24. package/dist/sol/dex/jup/legacy.js +416 -0
  25. package/dist/sol/dex/jup/lend.d.ts +640 -0
  26. package/dist/sol/dex/jup/lend.js +603 -0
  27. package/dist/sol/dex/jup/portfolio.d.ts +362 -0
  28. package/dist/sol/dex/jup/portfolio.js +367 -0
  29. package/dist/sol/dex/jup/price.d.ts +173 -0
  30. package/dist/sol/dex/jup/price.js +220 -0
  31. package/dist/sol/dex/jup/recurring.d.ts +437 -0
  32. package/dist/sol/dex/jup/recurring.js +320 -0
  33. package/dist/sol/dex/jup/send.d.ts +282 -0
  34. package/dist/sol/dex/jup/send.js +295 -0
  35. package/dist/sol/dex/jup/studio.d.ts +457 -0
  36. package/dist/sol/dex/jup/studio.js +488 -0
  37. package/dist/sol/dex/jup/tokens.d.ts +767 -0
  38. package/dist/sol/dex/jup/tokens.js +697 -0
  39. package/dist/sol/dex/jup/trigger.d.ts +511 -0
  40. package/dist/sol/dex/jup/trigger.js +397 -0
  41. package/dist/sol/dex/jup/types.d.ts +433 -0
  42. package/dist/sol/dex/jup/types.js +5 -0
  43. package/dist/sol/dex/jup/ultra.d.ts +646 -0
  44. package/dist/sol/dex/jup/ultra.js +853 -0
  45. package/dist/sol/dex/meteora/client.d.ts +76 -0
  46. package/dist/sol/dex/meteora/client.js +219 -0
  47. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +61 -0
  48. package/dist/sol/dex/meteora/damm-v1-bundle.js +112 -0
  49. package/dist/sol/dex/meteora/damm-v1.d.ts +118 -0
  50. package/dist/sol/dex/meteora/damm-v1.js +315 -0
  51. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +82 -0
  52. package/dist/sol/dex/meteora/damm-v2-bundle.js +242 -0
  53. package/dist/sol/dex/meteora/damm-v2.d.ts +172 -0
  54. package/dist/sol/dex/meteora/damm-v2.js +632 -0
  55. package/dist/sol/dex/meteora/dbc-bundle.d.ts +123 -0
  56. package/dist/sol/dex/meteora/dbc-bundle.js +304 -0
  57. package/dist/sol/dex/meteora/dbc.d.ts +192 -0
  58. package/dist/sol/dex/meteora/dbc.js +619 -0
  59. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +39 -0
  60. package/dist/sol/dex/meteora/dlmm-bundle.js +189 -0
  61. package/dist/sol/dex/meteora/dlmm.d.ts +157 -0
  62. package/dist/sol/dex/meteora/dlmm.js +671 -0
  63. package/dist/sol/dex/meteora/index.d.ts +25 -0
  64. package/dist/sol/dex/meteora/index.js +65 -0
  65. package/dist/sol/dex/meteora/types.d.ts +787 -0
  66. package/dist/sol/dex/meteora/types.js +110 -0
  67. package/dist/sol/dex/orca/index.d.ts +10 -0
  68. package/dist/sol/dex/orca/index.js +16 -0
  69. package/dist/sol/dex/orca/orca-bundle.d.ts +41 -0
  70. package/dist/sol/dex/orca/orca-bundle.js +173 -0
  71. package/dist/sol/dex/orca/orca.d.ts +65 -0
  72. package/dist/sol/dex/orca/orca.js +474 -0
  73. package/dist/sol/dex/orca/types.d.ts +263 -0
  74. package/dist/sol/dex/orca/types.js +38 -0
  75. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +34 -0
  76. package/dist/sol/dex/orca/wavebreak-bundle.js +198 -0
  77. package/dist/sol/dex/orca/wavebreak-types.d.ts +227 -0
  78. package/dist/sol/dex/orca/wavebreak-types.js +23 -0
  79. package/dist/sol/dex/orca/wavebreak.d.ts +78 -0
  80. package/dist/sol/dex/orca/wavebreak.js +497 -0
  81. package/dist/sol/dex/pump/index.d.ts +9 -0
  82. package/dist/sol/dex/pump/index.js +14 -0
  83. package/dist/sol/dex/pump/pump-bundle.d.ts +92 -0
  84. package/dist/sol/dex/pump/pump-bundle.js +383 -0
  85. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +103 -0
  86. package/dist/sol/dex/pump/pump-swap-bundle.js +380 -0
  87. package/dist/sol/dex/pump/pump-swap.d.ts +46 -0
  88. package/dist/sol/dex/pump/pump-swap.js +199 -0
  89. package/dist/sol/dex/pump/pump.d.ts +35 -0
  90. package/dist/sol/dex/pump/pump.js +352 -0
  91. package/dist/sol/dex/pump/types.d.ts +215 -0
  92. package/dist/sol/dex/pump/types.js +5 -0
  93. package/dist/sol/dex/raydium/index.d.ts +8 -0
  94. package/dist/sol/dex/raydium/index.js +12 -0
  95. package/dist/sol/dex/raydium/launchlab.d.ts +68 -0
  96. package/dist/sol/dex/raydium/launchlab.js +210 -0
  97. package/dist/sol/dex/raydium/raydium-bundle.d.ts +64 -0
  98. package/dist/sol/dex/raydium/raydium-bundle.js +324 -0
  99. package/dist/sol/dex/raydium/raydium.d.ts +40 -0
  100. package/dist/sol/dex/raydium/raydium.js +366 -0
  101. package/dist/sol/dex/raydium/types.d.ts +240 -0
  102. package/dist/sol/dex/raydium/types.js +5 -0
  103. package/dist/sol/index.d.ts +11 -0
  104. package/dist/sol/index.js +18 -0
  105. package/dist/sol/jito/bundle.d.ts +90 -0
  106. package/dist/sol/jito/bundle.js +263 -0
  107. package/dist/sol/jito/index.d.ts +7 -0
  108. package/dist/sol/jito/index.js +7 -0
  109. package/dist/sol/jito/tip.d.ts +51 -0
  110. package/dist/sol/jito/tip.js +83 -0
  111. package/dist/sol/jito/types.d.ts +100 -0
  112. package/dist/sol/jito/types.js +5 -0
  113. package/dist/sol/nozomi/client.d.ts +63 -0
  114. package/dist/sol/nozomi/client.js +222 -0
  115. package/dist/sol/nozomi/index.d.ts +8 -0
  116. package/dist/sol/nozomi/index.js +8 -0
  117. package/dist/sol/nozomi/tip.d.ts +50 -0
  118. package/dist/sol/nozomi/tip.js +80 -0
  119. package/dist/sol/nozomi/types.d.ts +96 -0
  120. package/dist/sol/nozomi/types.js +5 -0
  121. package/dist/sol/token/create-complete.d.ts +115 -0
  122. package/dist/sol/token/create-complete.js +235 -0
  123. package/dist/sol/token/create-token.d.ts +57 -0
  124. package/dist/sol/token/create-token.js +230 -0
  125. package/dist/sol/token/index.d.ts +9 -0
  126. package/dist/sol/token/index.js +14 -0
  127. package/dist/sol/token/metadata-upload.d.ts +86 -0
  128. package/dist/sol/token/metadata-upload.js +173 -0
  129. package/dist/sol/token/metadata.d.ts +92 -0
  130. package/dist/sol/token/metadata.js +274 -0
  131. package/dist/sol/token/types.d.ts +153 -0
  132. package/dist/sol/token/types.js +5 -0
  133. package/dist/sol/types.d.ts +176 -0
  134. package/dist/sol/types.js +7 -0
  135. package/dist/sol/utils/balance.d.ts +160 -0
  136. package/dist/sol/utils/balance.js +638 -0
  137. package/dist/sol/utils/connection.d.ts +78 -0
  138. package/dist/sol/utils/connection.js +168 -0
  139. package/dist/sol/utils/index.d.ts +9 -0
  140. package/dist/sol/utils/index.js +9 -0
  141. package/dist/sol/utils/lp-inspect.d.ts +80 -0
  142. package/dist/sol/utils/lp-inspect.js +256 -0
  143. package/dist/sol/utils/transfer.d.ts +196 -0
  144. package/dist/sol/utils/transfer.js +307 -0
  145. package/dist/sol/utils/wallet.d.ts +107 -0
  146. package/dist/sol/utils/wallet.js +210 -0
  147. package/dist/xlayer/aa-account.js +2 -2
  148. package/dist/xlayer/dex.js +1 -1
  149. package/dist/xlayer/portal-ops.js +1 -1
  150. package/package.json +44 -5
  151. package/README.zh-CN.pdf +0 -0
  152. package/dist/flap/portal-bundle-merkle/encryption.d.ts +0 -16
  153. package/dist/flap/portal-bundle-merkle/encryption.js +0 -146
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Solana RPC 连接管理
3
+ * @module sol/utils/connection
4
+ */
5
+ import { Connection, Commitment } from '@solana/web3.js';
6
+ /**
7
+ * 创建 Solana 连接
8
+ *
9
+ * 重要:必须传入用户选择的 RPC URL,SDK 不提供默认 RPC
10
+ * 前端应从 RPC 设置中获取用户配置的节点
11
+ *
12
+ * @param rpcUrl RPC URL(必填)
13
+ * @param commitment Commitment 级别(可选,默认 confirmed)
14
+ *
15
+ * @example
16
+ * const connection = createConnection('https://user-selected-rpc.com')
17
+ *
18
+ * @throws Error 如果没有传入 rpcUrl
19
+ */
20
+ export declare function createConnection(rpcUrl: string, commitment?: Commitment): Connection;
21
+ /**
22
+ * 获取账户 SOL 余额
23
+ * @param connection Solana 连接
24
+ * @param address 账户地址
25
+ * @returns 余额(lamports)
26
+ */
27
+ export declare function getBalance(connection: Connection, address: string): Promise<bigint>;
28
+ /**
29
+ * 获取账户 SOL 余额(格式化)
30
+ * @param connection Solana 连接
31
+ * @param address 账户地址
32
+ * @returns 余额(SOL)
33
+ */
34
+ export declare function getBalanceInSol(connection: Connection, address: string): Promise<number>;
35
+ /**
36
+ * 获取最新 blockhash
37
+ * @param connection Solana 连接
38
+ */
39
+ export declare function getLatestBlockhash(connection: Connection): Promise<{
40
+ blockhash: string;
41
+ lastValidBlockHeight: number;
42
+ }>;
43
+ /**
44
+ * 获取当前 slot
45
+ * @param connection Solana 连接
46
+ */
47
+ export declare function getCurrentSlot(connection: Connection): Promise<number>;
48
+ /**
49
+ * 检查账户是否存在
50
+ * @param connection Solana 连接
51
+ * @param address 账户地址
52
+ */
53
+ export declare function accountExists(connection: Connection, address: string): Promise<boolean>;
54
+ /**
55
+ * 获取账户信息
56
+ * @param connection Solana 连接
57
+ * @param address 账户地址
58
+ */
59
+ export declare function getAccountInfo(connection: Connection, address: string): Promise<import("@solana/web3.js").AccountInfo<Buffer<ArrayBufferLike>> | null>;
60
+ /**
61
+ * 获取最小租金豁免余额
62
+ * @param connection Solana 连接
63
+ * @param dataSize 账户数据大小
64
+ */
65
+ export declare function getMinimumBalanceForRentExemption(connection: Connection, dataSize: number): Promise<bigint>;
66
+ /**
67
+ * 等待交易确认
68
+ * @param connection Solana 连接
69
+ * @param signature 交易签名
70
+ * @param timeout 超时时间(毫秒)
71
+ */
72
+ export declare function waitForConfirmation(connection: Connection, signature: string, timeout?: number): Promise<boolean>;
73
+ /**
74
+ * 获取交易状态
75
+ * @param connection Solana 连接
76
+ * @param signature 交易签名
77
+ */
78
+ export declare function getTransactionStatus(connection: Connection, signature: string): Promise<'pending' | 'confirmed' | 'failed'>;
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Solana RPC 连接管理
3
+ * @module sol/utils/connection
4
+ */
5
+ import { Connection, PublicKey } from '@solana/web3.js';
6
+ import { TX_CONFIG, lamportsToSol } from '../constants.js';
7
+ /**
8
+ * 创建 Solana 连接
9
+ *
10
+ * 重要:必须传入用户选择的 RPC URL,SDK 不提供默认 RPC
11
+ * 前端应从 RPC 设置中获取用户配置的节点
12
+ *
13
+ * @param rpcUrl RPC URL(必填)
14
+ * @param commitment Commitment 级别(可选,默认 confirmed)
15
+ *
16
+ * @example
17
+ * const connection = createConnection('https://user-selected-rpc.com')
18
+ *
19
+ * @throws Error 如果没有传入 rpcUrl
20
+ */
21
+ export function createConnection(rpcUrl, commitment = TX_CONFIG.DEFAULT_COMMITMENT) {
22
+ if (!rpcUrl) {
23
+ throw new Error('RPC URL is required. Please pass the user-configured RPC URL from frontend settings.');
24
+ }
25
+ return new Connection(rpcUrl, {
26
+ commitment,
27
+ confirmTransactionInitialTimeout: TX_CONFIG.CONFIRMATION_TIMEOUT,
28
+ });
29
+ }
30
+ /**
31
+ * 获取账户 SOL 余额
32
+ * @param connection Solana 连接
33
+ * @param address 账户地址
34
+ * @returns 余额(lamports)
35
+ */
36
+ export async function getBalance(connection, address) {
37
+ try {
38
+ const publicKey = new PublicKey(address);
39
+ const balance = await connection.getBalance(publicKey);
40
+ return BigInt(balance);
41
+ }
42
+ catch (error) {
43
+ throw new Error(`Failed to get balance: ${error.message}`);
44
+ }
45
+ }
46
+ /**
47
+ * 获取账户 SOL 余额(格式化)
48
+ * @param connection Solana 连接
49
+ * @param address 账户地址
50
+ * @returns 余额(SOL)
51
+ */
52
+ export async function getBalanceInSol(connection, address) {
53
+ const lamports = await getBalance(connection, address);
54
+ return lamportsToSol(lamports);
55
+ }
56
+ /**
57
+ * 获取最新 blockhash
58
+ * @param connection Solana 连接
59
+ */
60
+ export async function getLatestBlockhash(connection) {
61
+ try {
62
+ const result = await connection.getLatestBlockhash('finalized');
63
+ return {
64
+ blockhash: result.blockhash,
65
+ lastValidBlockHeight: result.lastValidBlockHeight,
66
+ };
67
+ }
68
+ catch (error) {
69
+ throw new Error(`Failed to get blockhash: ${error.message}`);
70
+ }
71
+ }
72
+ /**
73
+ * 获取当前 slot
74
+ * @param connection Solana 连接
75
+ */
76
+ export async function getCurrentSlot(connection) {
77
+ try {
78
+ return await connection.getSlot();
79
+ }
80
+ catch (error) {
81
+ throw new Error(`Failed to get slot: ${error.message}`);
82
+ }
83
+ }
84
+ /**
85
+ * 检查账户是否存在
86
+ * @param connection Solana 连接
87
+ * @param address 账户地址
88
+ */
89
+ export async function accountExists(connection, address) {
90
+ try {
91
+ const publicKey = new PublicKey(address);
92
+ const accountInfo = await connection.getAccountInfo(publicKey);
93
+ return accountInfo !== null;
94
+ }
95
+ catch {
96
+ return false;
97
+ }
98
+ }
99
+ /**
100
+ * 获取账户信息
101
+ * @param connection Solana 连接
102
+ * @param address 账户地址
103
+ */
104
+ export async function getAccountInfo(connection, address) {
105
+ try {
106
+ const publicKey = new PublicKey(address);
107
+ return await connection.getAccountInfo(publicKey);
108
+ }
109
+ catch (error) {
110
+ throw new Error(`Failed to get account info: ${error.message}`);
111
+ }
112
+ }
113
+ /**
114
+ * 获取最小租金豁免余额
115
+ * @param connection Solana 连接
116
+ * @param dataSize 账户数据大小
117
+ */
118
+ export async function getMinimumBalanceForRentExemption(connection, dataSize) {
119
+ try {
120
+ const lamports = await connection.getMinimumBalanceForRentExemption(dataSize);
121
+ return BigInt(lamports);
122
+ }
123
+ catch (error) {
124
+ throw new Error(`Failed to get rent exemption: ${error.message}`);
125
+ }
126
+ }
127
+ /**
128
+ * 等待交易确认
129
+ * @param connection Solana 连接
130
+ * @param signature 交易签名
131
+ * @param timeout 超时时间(毫秒)
132
+ */
133
+ export async function waitForConfirmation(connection, signature, timeout = TX_CONFIG.CONFIRMATION_TIMEOUT) {
134
+ try {
135
+ const result = await connection.confirmTransaction({
136
+ signature,
137
+ blockhash: (await getLatestBlockhash(connection)).blockhash,
138
+ lastValidBlockHeight: (await getLatestBlockhash(connection)).lastValidBlockHeight,
139
+ }, 'confirmed');
140
+ return !result.value.err;
141
+ }
142
+ catch (error) {
143
+ console.error(`Transaction confirmation failed: ${error.message}`);
144
+ return false;
145
+ }
146
+ }
147
+ /**
148
+ * 获取交易状态
149
+ * @param connection Solana 连接
150
+ * @param signature 交易签名
151
+ */
152
+ export async function getTransactionStatus(connection, signature) {
153
+ try {
154
+ const status = await connection.getSignatureStatus(signature);
155
+ if (!status.value)
156
+ return 'pending';
157
+ if (status.value.err)
158
+ return 'failed';
159
+ if (status.value.confirmationStatus === 'confirmed' ||
160
+ status.value.confirmationStatus === 'finalized') {
161
+ return 'confirmed';
162
+ }
163
+ return 'pending';
164
+ }
165
+ catch {
166
+ return 'pending';
167
+ }
168
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Solana 工具函数导出
3
+ * @module sol/utils
4
+ */
5
+ export * from './connection.js';
6
+ export * from './wallet.js';
7
+ export * from './transfer.js';
8
+ export * from './balance.js';
9
+ export * from './lp-inspect.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Solana 工具函数导出
3
+ * @module sol/utils
4
+ */
5
+ export * from './connection.js';
6
+ export * from './wallet.js';
7
+ export * from './transfer.js';
8
+ export * from './balance.js';
9
+ export * from './lp-inspect.js';
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Solana LP 检测工具
3
+ * 自动判断代币在哪个平台(内盘/外盘)
4
+ * @module sol/utils/lp-inspect
5
+ */
6
+ import { Connection } from '@solana/web3.js';
7
+ /** Solana LP 平台类型 */
8
+ export type SolanaLPPlatform = 'PUMP_BONDING_CURVE' | 'METEORA_DBC' | 'RAYDIUM_LAUNCHLAB' | 'JUPITER_AGGREGATED' | 'PUMP_SWAP' | 'MULTI_POOL' | 'UNKNOWN';
9
+ /** 内盘(Bonding Curve)信息 */
10
+ export interface SolanaBondingCurveInfo {
11
+ type: 'pump' | 'meteora_dbc' | 'raydium_launchlab';
12
+ address: string;
13
+ complete: boolean;
14
+ reserveQuote: string;
15
+ reserveQuoteRaw: bigint;
16
+ reserveToken: string;
17
+ reserveTokenRaw: bigint;
18
+ realQuoteReserve?: string;
19
+ realQuoteReserveRaw?: bigint;
20
+ realTokenReserve?: string;
21
+ realTokenReserveRaw?: bigint;
22
+ liquidity?: number;
23
+ price?: number;
24
+ progress?: number;
25
+ creator?: string;
26
+ }
27
+ /** 外盘池子信息 (整合 Jupiter 数据) */
28
+ export interface SolanaPoolInfo {
29
+ platform: SolanaLPPlatform;
30
+ poolAddress: string;
31
+ quoteToken: string;
32
+ quoteSymbol: string;
33
+ quoteDecimals: number;
34
+ baseToken: string;
35
+ reserveQuote: string;
36
+ reserveQuoteRaw: bigint;
37
+ price?: number;
38
+ mcap?: number;
39
+ liquidity?: number;
40
+ fdv?: number;
41
+ isVerified?: boolean;
42
+ extra?: Record<string, any>;
43
+ }
44
+ /** Solana LP 检测结果 */
45
+ export interface SolanaLPInfo {
46
+ mint: string;
47
+ platform: SolanaLPPlatform;
48
+ decimals?: number;
49
+ totalSupply?: string;
50
+ totalSupplyRaw?: bigint;
51
+ bondingCurve?: SolanaBondingCurveInfo;
52
+ bestPool?: SolanaPoolInfo;
53
+ pools: SolanaPoolInfo[];
54
+ elapsed?: number;
55
+ }
56
+ /** 检测选项 */
57
+ export interface SolanaInspectOptions {
58
+ rpcUrl?: string;
59
+ connection?: Connection;
60
+ skipBondingCurve?: boolean;
61
+ skipPools?: boolean;
62
+ debug?: boolean;
63
+ timeout?: number;
64
+ }
65
+ /**
66
+ * 检测 Solana 代币的 LP 信息
67
+ */
68
+ export declare function inspectSolanaTokenLP(mint: string, options?: SolanaInspectOptions): Promise<SolanaLPInfo>;
69
+ /**
70
+ * 快速检测代币是否在内盘
71
+ */
72
+ export declare function detectBondingCurve(mint: string, options?: SolanaInspectOptions): Promise<SolanaBondingCurveInfo | null>;
73
+ /**
74
+ * 获取代币流动性 (USD)
75
+ */
76
+ export declare function getTokenLiquidity(mint: string, options?: SolanaInspectOptions): Promise<number>;
77
+ /**
78
+ * 判断代币是否已毕业
79
+ */
80
+ export declare function isTokenGraduated(mint: string, options?: SolanaInspectOptions): Promise<boolean>;
@@ -0,0 +1,256 @@
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
+ import { getTokenInfoV2 } from '../dex/jup/tokens.js';
9
+ // ============================================================================
10
+ // 常量
11
+ // ============================================================================
12
+ const WSOL = 'So11111111111111111111111111111111111111112';
13
+ // ============================================================================
14
+ // 内盘检测
15
+ // ============================================================================
16
+ /**
17
+ * 检测 Pump.fun Bonding Curve
18
+ */
19
+ async function detectPumpBondingCurve(mint, connection, debug) {
20
+ try {
21
+ const { getBondingCurveInfo } = await import('../dex/pump/pump.js');
22
+ const info = await getBondingCurveInfo(connection, mint);
23
+ if (!info)
24
+ return null;
25
+ const price = Number(info.virtualSolReserves) / Number(info.virtualTokenReserves);
26
+ const GRADUATION_THRESHOLD = 85000000000n;
27
+ const progress = Math.min(100, Number(info.realSolReserves * 100n / GRADUATION_THRESHOLD));
28
+ return {
29
+ type: 'pump',
30
+ address: info.bondingCurve,
31
+ complete: info.complete,
32
+ reserveQuote: (Number(info.virtualSolReserves) / 1e9).toFixed(4),
33
+ reserveQuoteRaw: info.virtualSolReserves,
34
+ reserveToken: (Number(info.virtualTokenReserves) / 1e6).toFixed(0),
35
+ reserveTokenRaw: info.virtualTokenReserves,
36
+ realQuoteReserve: (Number(info.realSolReserves) / 1e9).toFixed(4),
37
+ realQuoteReserveRaw: info.realSolReserves,
38
+ realTokenReserve: (Number(info.realTokenReserves) / 1e6).toFixed(0),
39
+ realTokenReserveRaw: info.realTokenReserves,
40
+ price,
41
+ progress,
42
+ creator: info.creator,
43
+ };
44
+ }
45
+ catch (err) {
46
+ if (debug)
47
+ console.log('[LP Inspect] Pump bonding curve check failed:', err);
48
+ return null;
49
+ }
50
+ }
51
+ /**
52
+ * 检测 Meteora DBC
53
+ */
54
+ async function detectMeteoraDbc(mint, connection, debug) {
55
+ try {
56
+ const { findDbcPoolByBaseMint, getDbcPoolInfo } = await import('../dex/meteora/dbc.js');
57
+ const poolAddress = await findDbcPoolByBaseMint(mint, connection);
58
+ if (!poolAddress)
59
+ return null;
60
+ const poolInfo = await getDbcPoolInfo(poolAddress, connection);
61
+ return {
62
+ type: 'meteora_dbc',
63
+ address: poolAddress,
64
+ complete: poolInfo.isMigrated,
65
+ reserveQuote: poolInfo.quoteReserve,
66
+ reserveQuoteRaw: BigInt(poolInfo.quoteReserve),
67
+ reserveToken: poolInfo.baseReserve,
68
+ reserveTokenRaw: BigInt(poolInfo.baseReserve),
69
+ realQuoteReserve: poolInfo.quoteReserve,
70
+ realQuoteReserveRaw: BigInt(poolInfo.quoteReserve),
71
+ realTokenReserve: poolInfo.baseReserve,
72
+ realTokenReserveRaw: BigInt(poolInfo.baseReserve),
73
+ price: poolInfo.currentPrice,
74
+ progress: poolInfo.progressPercent,
75
+ creator: poolInfo.creator,
76
+ };
77
+ }
78
+ catch (err) {
79
+ if (debug)
80
+ console.log('[LP Inspect] Meteora DBC check failed:', err);
81
+ return null;
82
+ }
83
+ }
84
+ /**
85
+ * 检测 Raydium LaunchLab
86
+ */
87
+ async function detectRaydiumLaunchLab(mint, connection, debug) {
88
+ try {
89
+ const { LaunchpadPool, LaunchpadConfig, getPdaLaunchpadPoolId, LAUNCHPAD_PROGRAM, Curve, } = await import('@raydium-io/raydium-sdk-v2');
90
+ const { NATIVE_MINT } = await import('@solana/spl-token');
91
+ const poolId = getPdaLaunchpadPoolId(LAUNCHPAD_PROGRAM, new PublicKey(mint), NATIVE_MINT).publicKey;
92
+ const poolAccountInfo = await connection.getAccountInfo(poolId);
93
+ if (!poolAccountInfo)
94
+ return null;
95
+ const poolInfo = LaunchpadPool.decode(poolAccountInfo.data);
96
+ const configAccountInfo = await connection.getAccountInfo(poolInfo.configId);
97
+ if (!configAccountInfo)
98
+ return null;
99
+ const configInfo = LaunchpadConfig.decode(configAccountInfo.data);
100
+ const currentPrice = Curve.getPrice({
101
+ poolInfo,
102
+ curveType: configInfo.curveType,
103
+ decimalA: poolInfo.mintDecimalsA,
104
+ decimalB: poolInfo.mintDecimalsB,
105
+ }).toNumber();
106
+ const isMigrated = poolInfo.status !== undefined && poolInfo.status >= 2;
107
+ return {
108
+ type: 'raydium_launchlab',
109
+ address: poolId.toBase58(),
110
+ complete: isMigrated,
111
+ reserveQuote: (Number(poolInfo.totalFundRaisingB || 0) / 1e9).toFixed(4),
112
+ reserveQuoteRaw: BigInt(poolInfo.totalFundRaisingB?.toString() || '0'),
113
+ reserveToken: "0", // Simplified
114
+ reserveTokenRaw: 0n,
115
+ realQuoteReserve: (Number(poolInfo.totalFundRaisingB || 0) / 1e9).toFixed(4),
116
+ realQuoteReserveRaw: BigInt(poolInfo.totalFundRaisingB?.toString() || '0'),
117
+ price: currentPrice,
118
+ creator: poolInfo.creator?.toBase58(),
119
+ };
120
+ }
121
+ catch (err) {
122
+ if (debug)
123
+ console.log('[LP Inspect] Raydium LaunchLab check failed:', err);
124
+ return null;
125
+ }
126
+ }
127
+ // ============================================================================
128
+ // 外盘检测 (Jupiter API)
129
+ // ============================================================================
130
+ /**
131
+ * 使用 Jupiter API 检测外盘信息
132
+ */
133
+ async function detectWithJupiter(mint, debug) {
134
+ try {
135
+ const info = await getTokenInfoV2(mint);
136
+ if (!info || !info.liquidity || info.liquidity < 100) {
137
+ return null;
138
+ }
139
+ return {
140
+ platform: 'JUPITER_AGGREGATED',
141
+ poolAddress: info.graduatedPool || '',
142
+ quoteToken: WSOL,
143
+ quoteSymbol: 'SOL',
144
+ quoteDecimals: 9,
145
+ baseToken: mint,
146
+ reserveQuote: info.liquidity.toFixed(2),
147
+ reserveQuoteRaw: BigInt(Math.floor(info.liquidity)),
148
+ price: info.usdPrice ?? undefined,
149
+ mcap: info.mcap ?? undefined,
150
+ liquidity: info.liquidity,
151
+ fdv: info.fdv ?? undefined,
152
+ isVerified: info.isVerified ?? false,
153
+ extra: {
154
+ launchpad: info.launchpad,
155
+ organicScore: info.organicScore,
156
+ stats24h: info.stats24h,
157
+ reserveBase: info.liquidity && info.usdPrice ? (info.liquidity / 2 / info.usdPrice).toString() : undefined,
158
+ }
159
+ };
160
+ }
161
+ catch (err) {
162
+ if (debug)
163
+ console.log('[LP Inspect] Jupiter check failed:', err);
164
+ return null;
165
+ }
166
+ }
167
+ // ============================================================================
168
+ // 主函数
169
+ // ============================================================================
170
+ /**
171
+ * 检测 Solana 代币的 LP 信息
172
+ */
173
+ export async function inspectSolanaTokenLP(mint, options = {}) {
174
+ const startTime = Date.now();
175
+ const connection = options.connection || createConnection(options.rpcUrl);
176
+ const debug = options.debug;
177
+ const result = {
178
+ mint,
179
+ platform: 'UNKNOWN',
180
+ pools: [],
181
+ };
182
+ // 0. 获取代币基本信息
183
+ try {
184
+ const mintInfo = await connection.getParsedAccountInfo(new PublicKey(mint));
185
+ if (mintInfo.value?.data && 'parsed' in mintInfo.value.data) {
186
+ const parsed = mintInfo.value.data.parsed;
187
+ result.decimals = parsed.info.decimals;
188
+ result.totalSupplyRaw = BigInt(parsed.info.supply);
189
+ result.totalSupply = (Number(result.totalSupplyRaw) / Math.pow(10, result.decimals)).toString();
190
+ }
191
+ }
192
+ catch { }
193
+ // 1. 内盘检测
194
+ if (!options.skipBondingCurve) {
195
+ const [pump, meteora, raydium] = await Promise.all([
196
+ detectPumpBondingCurve(mint, connection, debug),
197
+ detectMeteoraDbc(mint, connection, debug),
198
+ detectRaydiumLaunchLab(mint, connection, debug),
199
+ ]);
200
+ const bc = pump || meteora || raydium;
201
+ if (bc && !bc.complete) {
202
+ // 计算内盘估算流动性 (USD)
203
+ try {
204
+ const { getSolPrice } = await import('../dex/jup/price.js');
205
+ const solPrice = await getSolPrice();
206
+ if (solPrice) {
207
+ const realSol = Number(bc.realQuoteReserve || 0);
208
+ bc.liquidity = realSol * solPrice * 2; // 简单估算:SOL价值 * 2
209
+ }
210
+ }
211
+ catch { }
212
+ result.bondingCurve = bc;
213
+ result.platform = bc.type === 'pump' ? 'PUMP_BONDING_CURVE' :
214
+ bc.type === 'meteora_dbc' ? 'METEORA_DBC' : 'RAYDIUM_LAUNCHLAB';
215
+ result.elapsed = Date.now() - startTime;
216
+ return result;
217
+ }
218
+ }
219
+ // 2. 外盘检测 (Jupiter)
220
+ if (!options.skipPools) {
221
+ const jupPool = await detectWithJupiter(mint, debug);
222
+ if (jupPool) {
223
+ result.bestPool = jupPool;
224
+ result.pools = [jupPool];
225
+ result.platform = jupPool.platform;
226
+ }
227
+ }
228
+ result.elapsed = Date.now() - startTime;
229
+ return result;
230
+ }
231
+ /**
232
+ * 快速检测代币是否在内盘
233
+ */
234
+ export async function detectBondingCurve(mint, options = {}) {
235
+ const connection = options.connection || createConnection(options.rpcUrl);
236
+ const results = await Promise.all([
237
+ detectPumpBondingCurve(mint, connection, options.debug),
238
+ detectMeteoraDbc(mint, connection, options.debug),
239
+ detectRaydiumLaunchLab(mint, connection, options.debug),
240
+ ]);
241
+ return results.find(r => r && !r.complete) || null;
242
+ }
243
+ /**
244
+ * 获取代币流动性 (USD)
245
+ */
246
+ export async function getTokenLiquidity(mint, options = {}) {
247
+ const info = await inspectSolanaTokenLP(mint, options);
248
+ return info.bestPool?.liquidity || 0;
249
+ }
250
+ /**
251
+ * 判断代币是否已毕业
252
+ */
253
+ export async function isTokenGraduated(mint, options = {}) {
254
+ const bc = await detectBondingCurve(mint, options);
255
+ return bc === null;
256
+ }