four-flap-meme-sdk 1.4.62 → 1.4.64

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 (111) hide show
  1. package/dist/abis/common.d.ts +1 -1
  2. package/dist/abis/common.js +2 -1
  3. package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +4 -0
  4. package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +133 -78
  5. package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
  6. package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
  7. package/dist/flap/portal-bundle-merkle/swap-buy-first.d.ts +4 -0
  8. package/dist/flap/portal-bundle-merkle/swap-buy-first.js +160 -41
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.js +0 -1
  11. package/dist/pancake/bundle-buy-first.d.ts +4 -0
  12. package/dist/pancake/bundle-buy-first.js +185 -35
  13. package/package.json +3 -38
  14. package/dist/sol/constants.d.ts +0 -126
  15. package/dist/sol/constants.js +0 -145
  16. package/dist/sol/dex/index.d.ts +0 -8
  17. package/dist/sol/dex/index.js +0 -12
  18. package/dist/sol/dex/meteora/client.d.ts +0 -76
  19. package/dist/sol/dex/meteora/client.js +0 -219
  20. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
  21. package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
  22. package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
  23. package/dist/sol/dex/meteora/damm-v1.js +0 -315
  24. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
  25. package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
  26. package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
  27. package/dist/sol/dex/meteora/damm-v2.js +0 -632
  28. package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
  29. package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
  30. package/dist/sol/dex/meteora/dbc.d.ts +0 -192
  31. package/dist/sol/dex/meteora/dbc.js +0 -619
  32. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
  33. package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
  34. package/dist/sol/dex/meteora/dlmm.d.ts +0 -157
  35. package/dist/sol/dex/meteora/dlmm.js +0 -671
  36. package/dist/sol/dex/meteora/index.d.ts +0 -25
  37. package/dist/sol/dex/meteora/index.js +0 -65
  38. package/dist/sol/dex/meteora/types.d.ts +0 -787
  39. package/dist/sol/dex/meteora/types.js +0 -110
  40. package/dist/sol/dex/orca/index.d.ts +0 -10
  41. package/dist/sol/dex/orca/index.js +0 -16
  42. package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
  43. package/dist/sol/dex/orca/orca-bundle.js +0 -173
  44. package/dist/sol/dex/orca/orca.d.ts +0 -65
  45. package/dist/sol/dex/orca/orca.js +0 -474
  46. package/dist/sol/dex/orca/types.d.ts +0 -263
  47. package/dist/sol/dex/orca/types.js +0 -38
  48. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
  49. package/dist/sol/dex/orca/wavebreak-bundle.js +0 -198
  50. package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
  51. package/dist/sol/dex/orca/wavebreak-types.js +0 -23
  52. package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
  53. package/dist/sol/dex/orca/wavebreak.js +0 -497
  54. package/dist/sol/dex/pump/index.d.ts +0 -9
  55. package/dist/sol/dex/pump/index.js +0 -14
  56. package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
  57. package/dist/sol/dex/pump/pump-bundle.js +0 -383
  58. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
  59. package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
  60. package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
  61. package/dist/sol/dex/pump/pump-swap.js +0 -199
  62. package/dist/sol/dex/pump/pump.d.ts +0 -35
  63. package/dist/sol/dex/pump/pump.js +0 -352
  64. package/dist/sol/dex/pump/types.d.ts +0 -215
  65. package/dist/sol/dex/pump/types.js +0 -5
  66. package/dist/sol/dex/raydium/index.d.ts +0 -8
  67. package/dist/sol/dex/raydium/index.js +0 -12
  68. package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
  69. package/dist/sol/dex/raydium/launchlab.js +0 -210
  70. package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
  71. package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
  72. package/dist/sol/dex/raydium/raydium.d.ts +0 -40
  73. package/dist/sol/dex/raydium/raydium.js +0 -366
  74. package/dist/sol/dex/raydium/types.d.ts +0 -240
  75. package/dist/sol/dex/raydium/types.js +0 -5
  76. package/dist/sol/index.d.ts +0 -10
  77. package/dist/sol/index.js +0 -16
  78. package/dist/sol/jito/bundle.d.ts +0 -90
  79. package/dist/sol/jito/bundle.js +0 -263
  80. package/dist/sol/jito/index.d.ts +0 -7
  81. package/dist/sol/jito/index.js +0 -7
  82. package/dist/sol/jito/tip.d.ts +0 -51
  83. package/dist/sol/jito/tip.js +0 -83
  84. package/dist/sol/jito/types.d.ts +0 -100
  85. package/dist/sol/jito/types.js +0 -5
  86. package/dist/sol/token/create-complete.d.ts +0 -115
  87. package/dist/sol/token/create-complete.js +0 -235
  88. package/dist/sol/token/create-token.d.ts +0 -57
  89. package/dist/sol/token/create-token.js +0 -230
  90. package/dist/sol/token/index.d.ts +0 -9
  91. package/dist/sol/token/index.js +0 -14
  92. package/dist/sol/token/metadata-upload.d.ts +0 -86
  93. package/dist/sol/token/metadata-upload.js +0 -173
  94. package/dist/sol/token/metadata.d.ts +0 -92
  95. package/dist/sol/token/metadata.js +0 -274
  96. package/dist/sol/token/types.d.ts +0 -153
  97. package/dist/sol/token/types.js +0 -5
  98. package/dist/sol/types.d.ts +0 -176
  99. package/dist/sol/types.js +0 -7
  100. package/dist/sol/utils/balance.d.ts +0 -160
  101. package/dist/sol/utils/balance.js +0 -638
  102. package/dist/sol/utils/connection.d.ts +0 -78
  103. package/dist/sol/utils/connection.js +0 -168
  104. package/dist/sol/utils/index.d.ts +0 -9
  105. package/dist/sol/utils/index.js +0 -9
  106. package/dist/sol/utils/lp-inspect.d.ts +0 -129
  107. package/dist/sol/utils/lp-inspect.js +0 -900
  108. package/dist/sol/utils/transfer.d.ts +0 -125
  109. package/dist/sol/utils/transfer.js +0 -220
  110. package/dist/sol/utils/wallet.d.ts +0 -107
  111. package/dist/sol/utils/wallet.js +0 -210
@@ -1,380 +0,0 @@
1
- /**
2
- * Pump Swap 批量签名(用于 Jito Bundle)
3
- * 代币毕业后在 Pump Swap 池子进行交易
4
- * @module sol/dex/pump/pump-swap-bundle
5
- */
6
- import { PublicKey, Transaction, } from '@solana/web3.js';
7
- import BN from 'bn.js';
8
- import { OnlinePumpAmmSdk, PUMP_AMM_SDK, canonicalPumpPoolPda, buyBaseInput, buyQuoteInput, sellBaseInput, } from '@pump-fun/pump-swap-sdk';
9
- import { buildTipInstruction, getRandomTipAccount } from '../../jito/tip.js';
10
- /**
11
- * 构建 Pump Swap 批量买入(Jito Bundle)
12
- *
13
- * @param connection Solana 连接
14
- * @param params 参数
15
- */
16
- export async function signPumpSwapBundleBuy(connection, params) {
17
- try {
18
- const { mint, buyers, tipPayer, tipLamports = BigInt(10000), slippagePercent = 1, } = params;
19
- if (buyers.length === 0) {
20
- return { success: false, error: 'No buyers provided' };
21
- }
22
- const mintPubkey = new PublicKey(mint);
23
- const onlineSdk = new OnlinePumpAmmSdk(connection);
24
- // 获取池子地址(Pump 代币毕业后的 canonical pool)
25
- const poolKey = canonicalPumpPoolPda(mintPubkey);
26
- // 获取 blockhash
27
- const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('finalized');
28
- const serializedTransactions = [];
29
- const allSignatures = [];
30
- const tipAccount = getRandomTipAccount();
31
- // 为每个买家构建交易
32
- for (const { wallet, solAmount } of buyers) {
33
- // 获取该用户的 swap 状态
34
- const swapState = await onlineSdk.swapSolanaState(poolKey, wallet.publicKey);
35
- const { baseMint, baseMintAccount, feeConfig, globalConfig, pool, poolBaseAmount, poolQuoteAmount, } = swapState;
36
- const { coinCreator, creator } = pool;
37
- // 使用 SOL 输入计算可获得的代币数量
38
- const solAmountBN = new BN(solAmount.toString());
39
- const { base, maxQuote } = buyQuoteInput({
40
- quote: solAmountBN,
41
- slippage: slippagePercent,
42
- baseReserve: poolBaseAmount,
43
- quoteReserve: poolQuoteAmount,
44
- baseMintAccount,
45
- baseMint,
46
- coinCreator,
47
- creator,
48
- feeConfig,
49
- globalConfig,
50
- });
51
- // 构建买入指令
52
- const instructions = await PUMP_AMM_SDK.buyInstructions(swapState, base, maxQuote);
53
- // 构建交易
54
- const transaction = new Transaction();
55
- transaction.add(...instructions);
56
- transaction.recentBlockhash = blockhash;
57
- transaction.feePayer = wallet.publicKey;
58
- transaction.sign(wallet);
59
- const serialized = transaction.serialize();
60
- serializedTransactions.push({
61
- data: Buffer.from(serialized).toString('base64'),
62
- isVersioned: false,
63
- signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : undefined,
64
- });
65
- if (transaction.signature) {
66
- allSignatures.push(Buffer.from(transaction.signature).toString('base64'));
67
- }
68
- }
69
- // 添加 Tip 交易
70
- const tipTx = new Transaction().add(buildTipInstruction(tipPayer.publicKey, tipLamports, tipAccount));
71
- tipTx.recentBlockhash = blockhash;
72
- tipTx.feePayer = tipPayer.publicKey;
73
- tipTx.sign(tipPayer);
74
- serializedTransactions.push({
75
- data: Buffer.from(tipTx.serialize()).toString('base64'),
76
- isVersioned: false,
77
- signature: tipTx.signature ? Buffer.from(tipTx.signature).toString('base64') : undefined,
78
- });
79
- if (tipTx.signature) {
80
- allSignatures.push(Buffer.from(tipTx.signature).toString('base64'));
81
- }
82
- return {
83
- success: true,
84
- bundleData: {
85
- transactions: serializedTransactions,
86
- signatures: allSignatures,
87
- tip: {
88
- account: tipAccount,
89
- lamports: tipLamports,
90
- },
91
- recentBlockhash: blockhash,
92
- lastValidBlockHeight,
93
- createdAt: Date.now(),
94
- },
95
- };
96
- }
97
- catch (error) {
98
- return {
99
- success: false,
100
- error: error.message,
101
- };
102
- }
103
- }
104
- /**
105
- * 构建 Pump Swap 批量卖出(Jito Bundle)
106
- */
107
- export async function signPumpSwapBundleSell(connection, params) {
108
- try {
109
- const { mint, sellers, tipPayer, tipLamports = BigInt(10000), slippagePercent = 1, } = params;
110
- if (sellers.length === 0) {
111
- return { success: false, error: 'No sellers provided' };
112
- }
113
- const mintPubkey = new PublicKey(mint);
114
- const onlineSdk = new OnlinePumpAmmSdk(connection);
115
- // 获取池子地址
116
- const poolKey = canonicalPumpPoolPda(mintPubkey);
117
- // 获取 blockhash
118
- const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('finalized');
119
- const serializedTransactions = [];
120
- const allSignatures = [];
121
- const tipAccount = getRandomTipAccount();
122
- // 为每个卖家构建交易
123
- for (const { wallet, tokenAmount } of sellers) {
124
- // 获取该用户的 swap 状态
125
- const swapState = await onlineSdk.swapSolanaState(poolKey, wallet.publicKey);
126
- const { baseMint, baseMintAccount, feeConfig, globalConfig, pool, poolBaseAmount, poolQuoteAmount, } = swapState;
127
- const { coinCreator, creator } = pool;
128
- // 计算卖出可获得的 SOL
129
- const tokenAmountBN = new BN(tokenAmount.toString());
130
- const { minQuote } = sellBaseInput({
131
- base: tokenAmountBN,
132
- slippage: slippagePercent,
133
- baseReserve: poolBaseAmount,
134
- quoteReserve: poolQuoteAmount,
135
- baseMintAccount,
136
- baseMint,
137
- coinCreator,
138
- creator,
139
- feeConfig,
140
- globalConfig,
141
- });
142
- // 构建卖出指令
143
- const instructions = await PUMP_AMM_SDK.sellInstructions(swapState, tokenAmountBN, minQuote);
144
- // 构建交易
145
- const transaction = new Transaction();
146
- transaction.add(...instructions);
147
- transaction.recentBlockhash = blockhash;
148
- transaction.feePayer = wallet.publicKey;
149
- transaction.sign(wallet);
150
- const serialized = transaction.serialize();
151
- serializedTransactions.push({
152
- data: Buffer.from(serialized).toString('base64'),
153
- isVersioned: false,
154
- signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : undefined,
155
- });
156
- if (transaction.signature) {
157
- allSignatures.push(Buffer.from(transaction.signature).toString('base64'));
158
- }
159
- }
160
- // 添加 Tip 交易
161
- const tipTx = new Transaction().add(buildTipInstruction(tipPayer.publicKey, tipLamports, tipAccount));
162
- tipTx.recentBlockhash = blockhash;
163
- tipTx.feePayer = tipPayer.publicKey;
164
- tipTx.sign(tipPayer);
165
- serializedTransactions.push({
166
- data: Buffer.from(tipTx.serialize()).toString('base64'),
167
- isVersioned: false,
168
- signature: tipTx.signature ? Buffer.from(tipTx.signature).toString('base64') : undefined,
169
- });
170
- if (tipTx.signature) {
171
- allSignatures.push(Buffer.from(tipTx.signature).toString('base64'));
172
- }
173
- return {
174
- success: true,
175
- bundleData: {
176
- transactions: serializedTransactions,
177
- signatures: allSignatures,
178
- tip: {
179
- account: tipAccount,
180
- lamports: tipLamports,
181
- },
182
- recentBlockhash: blockhash,
183
- lastValidBlockHeight,
184
- createdAt: Date.now(),
185
- },
186
- };
187
- }
188
- catch (error) {
189
- return {
190
- success: false,
191
- error: error.message,
192
- };
193
- }
194
- }
195
- /**
196
- * 构建 Pump Swap 批量买入(按代币数量)
197
- * 指定想买多少代币,计算需要多少 SOL
198
- */
199
- export async function signPumpSwapBundleBuyByTokenAmount(connection, params) {
200
- try {
201
- const { mint, buyers, tipPayer, tipLamports = BigInt(10000), slippagePercent = 1, } = params;
202
- if (buyers.length === 0) {
203
- return { success: false, error: 'No buyers provided' };
204
- }
205
- const mintPubkey = new PublicKey(mint);
206
- const onlineSdk = new OnlinePumpAmmSdk(connection);
207
- const poolKey = canonicalPumpPoolPda(mintPubkey);
208
- const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('finalized');
209
- const serializedTransactions = [];
210
- const allSignatures = [];
211
- const tipAccount = getRandomTipAccount();
212
- for (const { wallet, tokenAmount } of buyers) {
213
- const swapState = await onlineSdk.swapSolanaState(poolKey, wallet.publicKey);
214
- const { baseMint, baseMintAccount, feeConfig, globalConfig, pool, poolBaseAmount, poolQuoteAmount, } = swapState;
215
- const { coinCreator, creator } = pool;
216
- // 使用代币数量计算需要的 SOL
217
- const tokenAmountBN = new BN(tokenAmount.toString());
218
- const { maxQuote } = buyBaseInput({
219
- base: tokenAmountBN,
220
- slippage: slippagePercent,
221
- baseReserve: poolBaseAmount,
222
- quoteReserve: poolQuoteAmount,
223
- baseMintAccount,
224
- baseMint,
225
- coinCreator,
226
- creator,
227
- feeConfig,
228
- globalConfig,
229
- });
230
- const instructions = await PUMP_AMM_SDK.buyInstructions(swapState, tokenAmountBN, maxQuote);
231
- const transaction = new Transaction();
232
- transaction.add(...instructions);
233
- transaction.recentBlockhash = blockhash;
234
- transaction.feePayer = wallet.publicKey;
235
- transaction.sign(wallet);
236
- const serialized = transaction.serialize();
237
- serializedTransactions.push({
238
- data: Buffer.from(serialized).toString('base64'),
239
- isVersioned: false,
240
- signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : undefined,
241
- });
242
- if (transaction.signature) {
243
- allSignatures.push(Buffer.from(transaction.signature).toString('base64'));
244
- }
245
- }
246
- // Tip
247
- const tipTx = new Transaction().add(buildTipInstruction(tipPayer.publicKey, tipLamports, tipAccount));
248
- tipTx.recentBlockhash = blockhash;
249
- tipTx.feePayer = tipPayer.publicKey;
250
- tipTx.sign(tipPayer);
251
- serializedTransactions.push({
252
- data: Buffer.from(tipTx.serialize()).toString('base64'),
253
- isVersioned: false,
254
- signature: tipTx.signature ? Buffer.from(tipTx.signature).toString('base64') : undefined,
255
- });
256
- if (tipTx.signature) {
257
- allSignatures.push(Buffer.from(tipTx.signature).toString('base64'));
258
- }
259
- return {
260
- success: true,
261
- bundleData: {
262
- transactions: serializedTransactions,
263
- signatures: allSignatures,
264
- tip: { account: tipAccount, lamports: tipLamports },
265
- recentBlockhash: blockhash,
266
- lastValidBlockHeight,
267
- createdAt: Date.now(),
268
- },
269
- };
270
- }
271
- catch (error) {
272
- return { success: false, error: error.message };
273
- }
274
- }
275
- /**
276
- * 构建 Pump Swap 批量卖出(按 SOL 数量)
277
- * 指定想获得多少 SOL,计算需要卖多少代币
278
- */
279
- export async function signPumpSwapBundleSellBySolAmount(connection, params) {
280
- try {
281
- const { mint, sellers, tipPayer, tipLamports = BigInt(10000), slippagePercent = 1, } = params;
282
- if (sellers.length === 0) {
283
- return { success: false, error: 'No sellers provided' };
284
- }
285
- const mintPubkey = new PublicKey(mint);
286
- const onlineSdk = new OnlinePumpAmmSdk(connection);
287
- const poolKey = canonicalPumpPoolPda(mintPubkey);
288
- const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('finalized');
289
- const serializedTransactions = [];
290
- const allSignatures = [];
291
- const tipAccount = getRandomTipAccount();
292
- // 需要导入 sellQuoteInput
293
- const { sellQuoteInput } = await import('@pump-fun/pump-swap-sdk');
294
- for (const { wallet, solAmount } of sellers) {
295
- const swapState = await onlineSdk.swapSolanaState(poolKey, wallet.publicKey);
296
- const { baseMint, baseMintAccount, feeConfig, globalConfig, pool, poolBaseAmount, poolQuoteAmount, } = swapState;
297
- const { coinCreator, creator } = pool;
298
- // 使用 SOL 数量计算需要卖的代币
299
- const solAmountBN = new BN(solAmount.toString());
300
- const { base, minQuote } = sellQuoteInput({
301
- quote: solAmountBN,
302
- slippage: slippagePercent,
303
- baseReserve: poolBaseAmount,
304
- quoteReserve: poolQuoteAmount,
305
- baseMintAccount,
306
- baseMint,
307
- coinCreator,
308
- creator,
309
- feeConfig,
310
- globalConfig,
311
- });
312
- const instructions = await PUMP_AMM_SDK.sellInstructions(swapState, base, minQuote);
313
- const transaction = new Transaction();
314
- transaction.add(...instructions);
315
- transaction.recentBlockhash = blockhash;
316
- transaction.feePayer = wallet.publicKey;
317
- transaction.sign(wallet);
318
- const serialized = transaction.serialize();
319
- serializedTransactions.push({
320
- data: Buffer.from(serialized).toString('base64'),
321
- isVersioned: false,
322
- signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : undefined,
323
- });
324
- if (transaction.signature) {
325
- allSignatures.push(Buffer.from(transaction.signature).toString('base64'));
326
- }
327
- }
328
- // Tip
329
- const tipTx = new Transaction().add(buildTipInstruction(tipPayer.publicKey, tipLamports, tipAccount));
330
- tipTx.recentBlockhash = blockhash;
331
- tipTx.feePayer = tipPayer.publicKey;
332
- tipTx.sign(tipPayer);
333
- serializedTransactions.push({
334
- data: Buffer.from(tipTx.serialize()).toString('base64'),
335
- isVersioned: false,
336
- signature: tipTx.signature ? Buffer.from(tipTx.signature).toString('base64') : undefined,
337
- });
338
- if (tipTx.signature) {
339
- allSignatures.push(Buffer.from(tipTx.signature).toString('base64'));
340
- }
341
- return {
342
- success: true,
343
- bundleData: {
344
- transactions: serializedTransactions,
345
- signatures: allSignatures,
346
- tip: { account: tipAccount, lamports: tipLamports },
347
- recentBlockhash: blockhash,
348
- lastValidBlockHeight,
349
- createdAt: Date.now(),
350
- },
351
- };
352
- }
353
- catch (error) {
354
- return { success: false, error: error.message };
355
- }
356
- }
357
- /**
358
- * 获取 Pump Swap 池子信息
359
- */
360
- export async function getPumpSwapBundlePoolInfo(connection, mint) {
361
- try {
362
- const mintPubkey = new PublicKey(mint);
363
- const onlineSdk = new OnlinePumpAmmSdk(connection);
364
- const poolKey = canonicalPumpPoolPda(mintPubkey);
365
- // 使用 swapSolanaState 获取完整的池子信息(包括储备量)
366
- // 使用一个临时地址作为 user(不影响查询)
367
- const swapState = await onlineSdk.swapSolanaState(poolKey, mintPubkey);
368
- return {
369
- poolAddress: poolKey.toBase58(),
370
- baseReserve: BigInt(swapState.poolBaseAmount.toString()),
371
- quoteReserve: BigInt(swapState.poolQuoteAmount.toString()),
372
- lpSupply: BigInt(swapState.pool.lpSupply.toString()),
373
- baseMint: swapState.pool.baseMint.toBase58(),
374
- quoteMint: swapState.pool.quoteMint.toBase58(),
375
- };
376
- }
377
- catch (error) {
378
- return null;
379
- }
380
- }
@@ -1,46 +0,0 @@
1
- /**
2
- * Pump Swap LP 管理(Pool 阶段)
3
- * 添加/移除流动性,买卖
4
- * @module sol/dex/pump/pump-swap
5
- */
6
- import { Connection, Keypair } from '@solana/web3.js';
7
- import type { PumpSwapAddLpParams, PumpSwapRemoveLpParams, PumpSwapLpResult, PumpSwapResult } from './types.js';
8
- /**
9
- * 获取 Pump Swap Pool 信息
10
- */
11
- export declare function getPumpSwapPoolInfo(connection: Connection, mint: string): Promise<{
12
- poolAddress: string;
13
- lpMint: string;
14
- lpSupply: bigint;
15
- baseMint: string;
16
- quoteMint: string;
17
- creator: string;
18
- } | null>;
19
- /**
20
- * 构建并签名添加 LP 交易
21
- */
22
- export declare function signPumpSwapAddLp(connection: Connection, params: PumpSwapAddLpParams): Promise<PumpSwapLpResult>;
23
- /**
24
- * 构建并签名移除 LP 交易
25
- */
26
- export declare function signPumpSwapRemoveLp(connection: Connection, params: PumpSwapRemoveLpParams): Promise<PumpSwapLpResult>;
27
- /**
28
- * Pump Swap 买入(Pool 阶段,非 Bonding Curve)
29
- * 用 SOL 买代币
30
- */
31
- export declare function signPumpSwapBuy(connection: Connection, params: {
32
- mint: string;
33
- buyer: Keypair;
34
- solAmount: bigint;
35
- slippageBps?: number;
36
- }): Promise<PumpSwapResult>;
37
- /**
38
- * Pump Swap 卖出(Pool 阶段,非 Bonding Curve)
39
- * 卖代币换 SOL
40
- */
41
- export declare function signPumpSwapSell(connection: Connection, params: {
42
- mint: string;
43
- seller: Keypair;
44
- tokenAmount: bigint;
45
- slippageBps?: number;
46
- }): Promise<PumpSwapResult>;
@@ -1,199 +0,0 @@
1
- /**
2
- * Pump Swap LP 管理(Pool 阶段)
3
- * 添加/移除流动性,买卖
4
- * @module sol/dex/pump/pump-swap
5
- */
6
- import { PublicKey, Transaction, } from '@solana/web3.js';
7
- import BN from 'bn.js';
8
- import { OnlinePumpAmmSdk, PUMP_AMM_SDK, canonicalPumpPoolPda, lpMintPda, } from '@pump-fun/pump-swap-sdk';
9
- /**
10
- * 默认滑点(1%)
11
- */
12
- const DEFAULT_SLIPPAGE = 0.01;
13
- /**
14
- * 获取 Pump Swap Pool 信息
15
- */
16
- export async function getPumpSwapPoolInfo(connection, mint) {
17
- try {
18
- const mintPubkey = new PublicKey(mint);
19
- const poolPda = canonicalPumpPoolPda(mintPubkey);
20
- const lpMint = lpMintPda(poolPda);
21
- const onlineSdk = new OnlinePumpAmmSdk(connection);
22
- const pool = await onlineSdk.fetchPool(poolPda);
23
- return {
24
- poolAddress: poolPda.toBase58(),
25
- lpMint: lpMint.toBase58(),
26
- lpSupply: BigInt(pool.lpSupply.toString()),
27
- baseMint: pool.baseMint.toBase58(),
28
- quoteMint: pool.quoteMint.toBase58(),
29
- creator: pool.creator.toBase58(),
30
- };
31
- }
32
- catch (error) {
33
- return null;
34
- }
35
- }
36
- /**
37
- * 构建并签名添加 LP 交易
38
- */
39
- export async function signPumpSwapAddLp(connection, params) {
40
- try {
41
- const { mint, provider, baseAmount, slippageBps = 100, } = params;
42
- const mintPubkey = new PublicKey(mint);
43
- const poolPda = canonicalPumpPoolPda(mintPubkey);
44
- const lpMint = lpMintPda(poolPda);
45
- const onlineSdk = new OnlinePumpAmmSdk(connection);
46
- // 获取流动性状态
47
- const liquidityState = await onlineSdk.liquiditySolanaState(poolPda, provider.publicKey);
48
- // 使用 base 输入计算 quote 和 lpToken
49
- const baseAmountBN = new BN(baseAmount.toString());
50
- const slippage = slippageBps / 10000;
51
- const { quote, lpToken } = PUMP_AMM_SDK.depositAutocompleteQuoteAndLpTokenFromBase(liquidityState, baseAmountBN, slippage);
52
- // 构建 deposit 指令
53
- const instructions = await PUMP_AMM_SDK.depositInstructions(liquidityState, lpToken, slippage);
54
- // 构建交易
55
- const { blockhash } = await connection.getLatestBlockhash('finalized');
56
- const transaction = new Transaction();
57
- transaction.add(...instructions);
58
- transaction.recentBlockhash = blockhash;
59
- transaction.feePayer = provider.publicKey;
60
- transaction.sign(provider);
61
- const serialized = transaction.serialize();
62
- return {
63
- success: true,
64
- poolAddress: poolPda.toBase58(),
65
- lpMint: lpMint.toBase58(),
66
- signedTransaction: {
67
- data: Buffer.from(serialized).toString('base64'),
68
- signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : '',
69
- },
70
- };
71
- }
72
- catch (error) {
73
- return {
74
- success: false,
75
- error: error.message,
76
- };
77
- }
78
- }
79
- /**
80
- * 构建并签名移除 LP 交易
81
- */
82
- export async function signPumpSwapRemoveLp(connection, params) {
83
- try {
84
- const { mint, provider, lpTokenAmount, slippageBps = 100, } = params;
85
- const mintPubkey = new PublicKey(mint);
86
- const poolPda = canonicalPumpPoolPda(mintPubkey);
87
- const lpMint = lpMintPda(poolPda);
88
- const onlineSdk = new OnlinePumpAmmSdk(connection);
89
- // 获取流动性状态
90
- const liquidityState = await onlineSdk.liquiditySolanaState(poolPda, provider.publicKey);
91
- const lpTokenAmountBN = new BN(lpTokenAmount.toString());
92
- const slippage = slippageBps / 10000;
93
- // 计算输出(注意方法名大小写)
94
- const { base, quote } = PUMP_AMM_SDK.withdrawAutoCompleteBaseAndQuoteFromLpToken(liquidityState, lpTokenAmountBN, slippage);
95
- // 构建 withdraw 指令
96
- const instructions = await PUMP_AMM_SDK.withdrawInstructions(liquidityState, lpTokenAmountBN, slippage);
97
- // 构建交易
98
- const { blockhash } = await connection.getLatestBlockhash('finalized');
99
- const transaction = new Transaction();
100
- transaction.add(...instructions);
101
- transaction.recentBlockhash = blockhash;
102
- transaction.feePayer = provider.publicKey;
103
- transaction.sign(provider);
104
- const serialized = transaction.serialize();
105
- return {
106
- success: true,
107
- poolAddress: poolPda.toBase58(),
108
- lpMint: lpMint.toBase58(),
109
- signedTransaction: {
110
- data: Buffer.from(serialized).toString('base64'),
111
- signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : '',
112
- },
113
- };
114
- }
115
- catch (error) {
116
- return {
117
- success: false,
118
- error: error.message,
119
- };
120
- }
121
- }
122
- /**
123
- * Pump Swap 买入(Pool 阶段,非 Bonding Curve)
124
- * 用 SOL 买代币
125
- */
126
- export async function signPumpSwapBuy(connection, params) {
127
- try {
128
- const { mint, buyer, solAmount, slippageBps = 100, } = params;
129
- const mintPubkey = new PublicKey(mint);
130
- const poolPda = canonicalPumpPoolPda(mintPubkey);
131
- const onlineSdk = new OnlinePumpAmmSdk(connection);
132
- // 获取 swap 状态
133
- const swapState = await onlineSdk.swapSolanaState(poolPda, buyer.publicKey);
134
- // 使用 quote 输入(SOL)买入 base(代币)
135
- const quoteAmountBN = new BN(solAmount.toString());
136
- const slippage = slippageBps / 10000;
137
- const instructions = await PUMP_AMM_SDK.buyQuoteInput(swapState, quoteAmountBN, slippage);
138
- // 构建交易
139
- const { blockhash } = await connection.getLatestBlockhash('finalized');
140
- const transaction = new Transaction();
141
- transaction.add(...instructions);
142
- transaction.recentBlockhash = blockhash;
143
- transaction.feePayer = buyer.publicKey;
144
- transaction.sign(buyer);
145
- const serialized = transaction.serialize();
146
- return {
147
- success: true,
148
- signedTransaction: {
149
- data: Buffer.from(serialized).toString('base64'),
150
- signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : '',
151
- },
152
- };
153
- }
154
- catch (error) {
155
- return {
156
- success: false,
157
- error: error.message,
158
- };
159
- }
160
- }
161
- /**
162
- * Pump Swap 卖出(Pool 阶段,非 Bonding Curve)
163
- * 卖代币换 SOL
164
- */
165
- export async function signPumpSwapSell(connection, params) {
166
- try {
167
- const { mint, seller, tokenAmount, slippageBps = 100, } = params;
168
- const mintPubkey = new PublicKey(mint);
169
- const poolPda = canonicalPumpPoolPda(mintPubkey);
170
- const onlineSdk = new OnlinePumpAmmSdk(connection);
171
- // 获取 swap 状态
172
- const swapState = await onlineSdk.swapSolanaState(poolPda, seller.publicKey);
173
- // 使用 base 输入(代币)卖出换 quote(SOL)
174
- const baseAmountBN = new BN(tokenAmount.toString());
175
- const slippage = slippageBps / 10000;
176
- const instructions = await PUMP_AMM_SDK.sellBaseInput(swapState, baseAmountBN, slippage);
177
- // 构建交易
178
- const { blockhash } = await connection.getLatestBlockhash('finalized');
179
- const transaction = new Transaction();
180
- transaction.add(...instructions);
181
- transaction.recentBlockhash = blockhash;
182
- transaction.feePayer = seller.publicKey;
183
- transaction.sign(seller);
184
- const serialized = transaction.serialize();
185
- return {
186
- success: true,
187
- signedTransaction: {
188
- data: Buffer.from(serialized).toString('base64'),
189
- signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : '',
190
- },
191
- };
192
- }
193
- catch (error) {
194
- return {
195
- success: false,
196
- error: error.message,
197
- };
198
- }
199
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * Pump.fun 核心功能
3
- * 代币创建、买卖(Bonding Curve 阶段)
4
- * @module sol/dex/pump/pump
5
- */
6
- import { Connection } from '@solana/web3.js';
7
- import type { PumpCreateTokenParams, PumpCreateTokenResult, PumpBuyParams, PumpSellParams, PumpSwapResult, PumpBatchBuyParams, PumpBatchSellParams, PumpBatchSwapResult, BondingCurveInfo, PumpCollectFeeParams, PumpCollectFeeResult } from './types.js';
8
- /**
9
- * 获取 Bonding Curve 信息
10
- */
11
- export declare function getBondingCurveInfo(connection: Connection, mint: string): Promise<BondingCurveInfo | null>;
12
- /**
13
- * 构建并签名 Pump 代币创建交易
14
- */
15
- export declare function signPumpCreateToken(connection: Connection, params: PumpCreateTokenParams): Promise<PumpCreateTokenResult>;
16
- /**
17
- * 构建并签名 Pump 买入交易
18
- */
19
- export declare function signPumpBuy(connection: Connection, params: PumpBuyParams): Promise<PumpSwapResult>;
20
- /**
21
- * 构建并签名 Pump 卖出交易
22
- */
23
- export declare function signPumpSell(connection: Connection, params: PumpSellParams): Promise<PumpSwapResult>;
24
- /**
25
- * 批量买入
26
- */
27
- export declare function signPumpBatchBuy(connection: Connection, params: PumpBatchBuyParams): Promise<PumpBatchSwapResult>;
28
- /**
29
- * 批量卖出
30
- */
31
- export declare function signPumpBatchSell(connection: Connection, params: PumpBatchSellParams): Promise<PumpBatchSwapResult>;
32
- /**
33
- * 提取创建者收益
34
- */
35
- export declare function signPumpCollectFee(connection: Connection, params: PumpCollectFeeParams): Promise<PumpCollectFeeResult>;