four-flap-meme-sdk 1.4.20 → 1.4.21
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.
- package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
- package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +3 -38
- package/dist/sol/constants.d.ts +0 -126
- package/dist/sol/constants.js +0 -145
- package/dist/sol/dex/index.d.ts +0 -8
- package/dist/sol/dex/index.js +0 -12
- package/dist/sol/dex/meteora/client.d.ts +0 -76
- package/dist/sol/dex/meteora/client.js +0 -219
- package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
- package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
- package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
- package/dist/sol/dex/meteora/damm-v1.js +0 -315
- package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
- package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
- package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
- package/dist/sol/dex/meteora/damm-v2.js +0 -632
- package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
- package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
- package/dist/sol/dex/meteora/dbc.d.ts +0 -192
- package/dist/sol/dex/meteora/dbc.js +0 -619
- package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
- package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
- package/dist/sol/dex/meteora/dlmm.d.ts +0 -157
- package/dist/sol/dex/meteora/dlmm.js +0 -671
- package/dist/sol/dex/meteora/index.d.ts +0 -25
- package/dist/sol/dex/meteora/index.js +0 -65
- package/dist/sol/dex/meteora/types.d.ts +0 -787
- package/dist/sol/dex/meteora/types.js +0 -110
- package/dist/sol/dex/orca/index.d.ts +0 -10
- package/dist/sol/dex/orca/index.js +0 -16
- package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
- package/dist/sol/dex/orca/orca-bundle.js +0 -173
- package/dist/sol/dex/orca/orca.d.ts +0 -65
- package/dist/sol/dex/orca/orca.js +0 -474
- package/dist/sol/dex/orca/types.d.ts +0 -263
- package/dist/sol/dex/orca/types.js +0 -38
- package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
- package/dist/sol/dex/orca/wavebreak-bundle.js +0 -198
- package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
- package/dist/sol/dex/orca/wavebreak-types.js +0 -23
- package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
- package/dist/sol/dex/orca/wavebreak.js +0 -497
- package/dist/sol/dex/pump/index.d.ts +0 -9
- package/dist/sol/dex/pump/index.js +0 -14
- package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
- package/dist/sol/dex/pump/pump-bundle.js +0 -383
- package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
- package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
- package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
- package/dist/sol/dex/pump/pump-swap.js +0 -199
- package/dist/sol/dex/pump/pump.d.ts +0 -35
- package/dist/sol/dex/pump/pump.js +0 -352
- package/dist/sol/dex/pump/types.d.ts +0 -215
- package/dist/sol/dex/pump/types.js +0 -5
- package/dist/sol/dex/raydium/index.d.ts +0 -8
- package/dist/sol/dex/raydium/index.js +0 -12
- package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
- package/dist/sol/dex/raydium/launchlab.js +0 -210
- package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
- package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
- package/dist/sol/dex/raydium/raydium.d.ts +0 -40
- package/dist/sol/dex/raydium/raydium.js +0 -366
- package/dist/sol/dex/raydium/types.d.ts +0 -240
- package/dist/sol/dex/raydium/types.js +0 -5
- package/dist/sol/index.d.ts +0 -10
- package/dist/sol/index.js +0 -16
- package/dist/sol/jito/bundle.d.ts +0 -90
- package/dist/sol/jito/bundle.js +0 -263
- package/dist/sol/jito/index.d.ts +0 -7
- package/dist/sol/jito/index.js +0 -7
- package/dist/sol/jito/tip.d.ts +0 -51
- package/dist/sol/jito/tip.js +0 -83
- package/dist/sol/jito/types.d.ts +0 -100
- package/dist/sol/jito/types.js +0 -5
- package/dist/sol/token/create-complete.d.ts +0 -115
- package/dist/sol/token/create-complete.js +0 -235
- package/dist/sol/token/create-token.d.ts +0 -57
- package/dist/sol/token/create-token.js +0 -230
- package/dist/sol/token/index.d.ts +0 -9
- package/dist/sol/token/index.js +0 -14
- package/dist/sol/token/metadata-upload.d.ts +0 -86
- package/dist/sol/token/metadata-upload.js +0 -173
- package/dist/sol/token/metadata.d.ts +0 -92
- package/dist/sol/token/metadata.js +0 -274
- package/dist/sol/token/types.d.ts +0 -153
- package/dist/sol/token/types.js +0 -5
- package/dist/sol/types.d.ts +0 -176
- package/dist/sol/types.js +0 -7
- package/dist/sol/utils/balance.d.ts +0 -160
- package/dist/sol/utils/balance.js +0 -638
- package/dist/sol/utils/connection.d.ts +0 -78
- package/dist/sol/utils/connection.js +0 -168
- package/dist/sol/utils/index.d.ts +0 -9
- package/dist/sol/utils/index.js +0 -9
- package/dist/sol/utils/lp-inspect.d.ts +0 -129
- package/dist/sol/utils/lp-inspect.js +0 -900
- package/dist/sol/utils/transfer.d.ts +0 -125
- package/dist/sol/utils/transfer.js +0 -220
- package/dist/sol/utils/wallet.d.ts +0 -107
- package/dist/sol/utils/wallet.js +0 -210
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pump.fun 核心功能
|
|
3
|
-
* 代币创建、买卖(Bonding Curve 阶段)
|
|
4
|
-
* @module sol/dex/pump/pump
|
|
5
|
-
*/
|
|
6
|
-
import { Keypair, PublicKey, Transaction, } from '@solana/web3.js';
|
|
7
|
-
import BN from 'bn.js';
|
|
8
|
-
import { PUMP_SDK, OnlinePumpSdk, bondingCurvePda, getBuyTokenAmountFromSolAmount, getSellSolAmountFromTokenAmount, newBondingCurve, } from '@pump-fun/pump-sdk';
|
|
9
|
-
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
10
|
-
/**
|
|
11
|
-
* 默认滑点(1%)
|
|
12
|
-
*/
|
|
13
|
-
const DEFAULT_SLIPPAGE_BPS = 100;
|
|
14
|
-
/**
|
|
15
|
-
* 获取 Bonding Curve 信息
|
|
16
|
-
*/
|
|
17
|
-
export async function getBondingCurveInfo(connection, mint) {
|
|
18
|
-
try {
|
|
19
|
-
const mintPubkey = new PublicKey(mint);
|
|
20
|
-
const bondingCurve = bondingCurvePda(mintPubkey);
|
|
21
|
-
const onlineSdk = new OnlinePumpSdk(connection);
|
|
22
|
-
const bcData = await onlineSdk.fetchBondingCurve(mintPubkey);
|
|
23
|
-
return {
|
|
24
|
-
mint,
|
|
25
|
-
bondingCurve: bondingCurve.toBase58(),
|
|
26
|
-
virtualSolReserves: BigInt(bcData.virtualSolReserves.toString()),
|
|
27
|
-
virtualTokenReserves: BigInt(bcData.virtualTokenReserves.toString()),
|
|
28
|
-
realSolReserves: BigInt(bcData.realSolReserves.toString()),
|
|
29
|
-
realTokenReserves: BigInt(bcData.realTokenReserves.toString()),
|
|
30
|
-
tokenTotalSupply: BigInt(bcData.tokenTotalSupply.toString()),
|
|
31
|
-
complete: bcData.complete,
|
|
32
|
-
creator: bcData.creator.toBase58(),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* 构建并签名 Pump 代币创建交易
|
|
41
|
-
*/
|
|
42
|
-
export async function signPumpCreateToken(connection, params) {
|
|
43
|
-
try {
|
|
44
|
-
const { name, symbol, uri, creator, mintKeypair = Keypair.generate(), mayhemMode = false, initialBuyAmount, } = params;
|
|
45
|
-
const onlineSdk = new OnlinePumpSdk(connection);
|
|
46
|
-
const global = await onlineSdk.fetchGlobal();
|
|
47
|
-
let instructions;
|
|
48
|
-
if (initialBuyAmount && initialBuyAmount > 0) {
|
|
49
|
-
// 创建并购买
|
|
50
|
-
const solAmount = new BN(initialBuyAmount.toString());
|
|
51
|
-
// 使用新的 bonding curve 计算代币数量
|
|
52
|
-
const initialBondingCurve = newBondingCurve(global);
|
|
53
|
-
const tokenAmount = getBuyTokenAmountFromSolAmount({
|
|
54
|
-
global,
|
|
55
|
-
feeConfig: null,
|
|
56
|
-
mintSupply: null,
|
|
57
|
-
bondingCurve: initialBondingCurve,
|
|
58
|
-
amount: solAmount,
|
|
59
|
-
});
|
|
60
|
-
// 使用 PUMP_SDK(离线)构建指令
|
|
61
|
-
instructions = await PUMP_SDK.createV2AndBuyInstructions({
|
|
62
|
-
global,
|
|
63
|
-
mint: mintKeypair.publicKey,
|
|
64
|
-
name,
|
|
65
|
-
symbol,
|
|
66
|
-
uri,
|
|
67
|
-
creator: creator.publicKey,
|
|
68
|
-
user: creator.publicKey,
|
|
69
|
-
amount: tokenAmount,
|
|
70
|
-
solAmount,
|
|
71
|
-
mayhemMode,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
// 仅创建
|
|
76
|
-
const createIx = await PUMP_SDK.createV2Instruction({
|
|
77
|
-
mint: mintKeypair.publicKey,
|
|
78
|
-
name,
|
|
79
|
-
symbol,
|
|
80
|
-
uri,
|
|
81
|
-
creator: creator.publicKey,
|
|
82
|
-
user: creator.publicKey,
|
|
83
|
-
mayhemMode,
|
|
84
|
-
});
|
|
85
|
-
instructions = [createIx];
|
|
86
|
-
}
|
|
87
|
-
// 构建交易
|
|
88
|
-
const { blockhash } = await connection.getLatestBlockhash('finalized');
|
|
89
|
-
const transaction = new Transaction();
|
|
90
|
-
transaction.add(...instructions);
|
|
91
|
-
transaction.recentBlockhash = blockhash;
|
|
92
|
-
transaction.feePayer = creator.publicKey;
|
|
93
|
-
// 签名
|
|
94
|
-
transaction.sign(creator, mintKeypair);
|
|
95
|
-
const serialized = transaction.serialize();
|
|
96
|
-
return {
|
|
97
|
-
success: true,
|
|
98
|
-
mint: mintKeypair.publicKey.toBase58(),
|
|
99
|
-
mintKeypair,
|
|
100
|
-
bondingCurve: bondingCurvePda(mintKeypair.publicKey).toBase58(),
|
|
101
|
-
signedTransaction: {
|
|
102
|
-
data: Buffer.from(serialized).toString('base64'),
|
|
103
|
-
signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : '',
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
return {
|
|
109
|
-
success: false,
|
|
110
|
-
error: error.message,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* 构建并签名 Pump 买入交易
|
|
116
|
-
*/
|
|
117
|
-
export async function signPumpBuy(connection, params) {
|
|
118
|
-
try {
|
|
119
|
-
const { mint, buyer, solAmount, slippageBps = DEFAULT_SLIPPAGE_BPS, } = params;
|
|
120
|
-
const mintPubkey = new PublicKey(mint);
|
|
121
|
-
const onlineSdk = new OnlinePumpSdk(connection);
|
|
122
|
-
// 获取状态
|
|
123
|
-
const global = await onlineSdk.fetchGlobal();
|
|
124
|
-
const { bondingCurveAccountInfo, bondingCurve, associatedUserAccountInfo } = await onlineSdk.fetchBuyState(mintPubkey, buyer.publicKey);
|
|
125
|
-
// 计算代币数量
|
|
126
|
-
const solAmountBN = new BN(solAmount.toString());
|
|
127
|
-
const tokenAmount = getBuyTokenAmountFromSolAmount({
|
|
128
|
-
global,
|
|
129
|
-
feeConfig: null,
|
|
130
|
-
mintSupply: bondingCurve.tokenTotalSupply,
|
|
131
|
-
bondingCurve,
|
|
132
|
-
amount: solAmountBN,
|
|
133
|
-
});
|
|
134
|
-
// 使用 PUMP_SDK 构建买入指令
|
|
135
|
-
const instructions = await PUMP_SDK.buyInstructions({
|
|
136
|
-
global,
|
|
137
|
-
bondingCurveAccountInfo,
|
|
138
|
-
bondingCurve,
|
|
139
|
-
associatedUserAccountInfo,
|
|
140
|
-
mint: mintPubkey,
|
|
141
|
-
user: buyer.publicKey,
|
|
142
|
-
amount: tokenAmount,
|
|
143
|
-
solAmount: solAmountBN,
|
|
144
|
-
slippage: slippageBps / 100, // SDK 使用百分比,如 1 = 1%
|
|
145
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
146
|
-
});
|
|
147
|
-
// 构建交易
|
|
148
|
-
const { blockhash } = await connection.getLatestBlockhash('finalized');
|
|
149
|
-
const transaction = new Transaction();
|
|
150
|
-
transaction.add(...instructions);
|
|
151
|
-
transaction.recentBlockhash = blockhash;
|
|
152
|
-
transaction.feePayer = buyer.publicKey;
|
|
153
|
-
transaction.sign(buyer);
|
|
154
|
-
const serialized = transaction.serialize();
|
|
155
|
-
return {
|
|
156
|
-
success: true,
|
|
157
|
-
signedTransaction: {
|
|
158
|
-
data: Buffer.from(serialized).toString('base64'),
|
|
159
|
-
signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : '',
|
|
160
|
-
},
|
|
161
|
-
expectedAmount: BigInt(tokenAmount.toString()),
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
catch (error) {
|
|
165
|
-
return {
|
|
166
|
-
success: false,
|
|
167
|
-
error: error.message,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* 构建并签名 Pump 卖出交易
|
|
173
|
-
*/
|
|
174
|
-
export async function signPumpSell(connection, params) {
|
|
175
|
-
try {
|
|
176
|
-
const { mint, seller, tokenAmount, slippageBps = DEFAULT_SLIPPAGE_BPS, } = params;
|
|
177
|
-
const mintPubkey = new PublicKey(mint);
|
|
178
|
-
const onlineSdk = new OnlinePumpSdk(connection);
|
|
179
|
-
// 获取状态
|
|
180
|
-
const global = await onlineSdk.fetchGlobal();
|
|
181
|
-
const { bondingCurveAccountInfo, bondingCurve } = await onlineSdk.fetchSellState(mintPubkey, seller.publicKey);
|
|
182
|
-
// 计算 SOL 数量
|
|
183
|
-
const tokenAmountBN = new BN(tokenAmount.toString());
|
|
184
|
-
const solAmount = getSellSolAmountFromTokenAmount({
|
|
185
|
-
global,
|
|
186
|
-
feeConfig: null,
|
|
187
|
-
mintSupply: bondingCurve.tokenTotalSupply,
|
|
188
|
-
bondingCurve,
|
|
189
|
-
amount: tokenAmountBN,
|
|
190
|
-
});
|
|
191
|
-
// 使用 PUMP_SDK 构建卖出指令
|
|
192
|
-
const instructions = await PUMP_SDK.sellInstructions({
|
|
193
|
-
global,
|
|
194
|
-
bondingCurveAccountInfo,
|
|
195
|
-
bondingCurve,
|
|
196
|
-
mint: mintPubkey,
|
|
197
|
-
user: seller.publicKey,
|
|
198
|
-
amount: tokenAmountBN,
|
|
199
|
-
solAmount,
|
|
200
|
-
slippage: slippageBps / 100,
|
|
201
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
202
|
-
mayhemMode: false,
|
|
203
|
-
});
|
|
204
|
-
// 构建交易
|
|
205
|
-
const { blockhash } = await connection.getLatestBlockhash('finalized');
|
|
206
|
-
const transaction = new Transaction();
|
|
207
|
-
transaction.add(...instructions);
|
|
208
|
-
transaction.recentBlockhash = blockhash;
|
|
209
|
-
transaction.feePayer = seller.publicKey;
|
|
210
|
-
transaction.sign(seller);
|
|
211
|
-
const serialized = transaction.serialize();
|
|
212
|
-
return {
|
|
213
|
-
success: true,
|
|
214
|
-
signedTransaction: {
|
|
215
|
-
data: Buffer.from(serialized).toString('base64'),
|
|
216
|
-
signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : '',
|
|
217
|
-
},
|
|
218
|
-
expectedAmount: BigInt(solAmount.toString()),
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
catch (error) {
|
|
222
|
-
return {
|
|
223
|
-
success: false,
|
|
224
|
-
error: error.message,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* 批量买入
|
|
230
|
-
*/
|
|
231
|
-
export async function signPumpBatchBuy(connection, params) {
|
|
232
|
-
try {
|
|
233
|
-
const { mint, buyers, slippageBps = DEFAULT_SLIPPAGE_BPS } = params;
|
|
234
|
-
const signedTransactions = [];
|
|
235
|
-
let successCount = 0;
|
|
236
|
-
let failedCount = 0;
|
|
237
|
-
for (const { wallet, solAmount } of buyers) {
|
|
238
|
-
const result = await signPumpBuy(connection, {
|
|
239
|
-
mint,
|
|
240
|
-
buyer: wallet,
|
|
241
|
-
solAmount,
|
|
242
|
-
slippageBps,
|
|
243
|
-
});
|
|
244
|
-
if (result.success && result.signedTransaction) {
|
|
245
|
-
signedTransactions.push({
|
|
246
|
-
data: result.signedTransaction.data,
|
|
247
|
-
signature: result.signedTransaction.signature,
|
|
248
|
-
wallet: wallet.publicKey.toBase58(),
|
|
249
|
-
});
|
|
250
|
-
successCount++;
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
failedCount++;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return {
|
|
257
|
-
success: failedCount === 0,
|
|
258
|
-
signedTransactions,
|
|
259
|
-
successCount,
|
|
260
|
-
failedCount,
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
catch (error) {
|
|
264
|
-
return {
|
|
265
|
-
success: false,
|
|
266
|
-
error: error.message,
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* 批量卖出
|
|
272
|
-
*/
|
|
273
|
-
export async function signPumpBatchSell(connection, params) {
|
|
274
|
-
try {
|
|
275
|
-
const { mint, sellers, slippageBps = DEFAULT_SLIPPAGE_BPS } = params;
|
|
276
|
-
const signedTransactions = [];
|
|
277
|
-
let successCount = 0;
|
|
278
|
-
let failedCount = 0;
|
|
279
|
-
for (const { wallet, tokenAmount } of sellers) {
|
|
280
|
-
const result = await signPumpSell(connection, {
|
|
281
|
-
mint,
|
|
282
|
-
seller: wallet,
|
|
283
|
-
tokenAmount,
|
|
284
|
-
slippageBps,
|
|
285
|
-
});
|
|
286
|
-
if (result.success && result.signedTransaction) {
|
|
287
|
-
signedTransactions.push({
|
|
288
|
-
data: result.signedTransaction.data,
|
|
289
|
-
signature: result.signedTransaction.signature,
|
|
290
|
-
wallet: wallet.publicKey.toBase58(),
|
|
291
|
-
});
|
|
292
|
-
successCount++;
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
failedCount++;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
return {
|
|
299
|
-
success: failedCount === 0,
|
|
300
|
-
signedTransactions,
|
|
301
|
-
successCount,
|
|
302
|
-
failedCount,
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
catch (error) {
|
|
306
|
-
return {
|
|
307
|
-
success: false,
|
|
308
|
-
error: error.message,
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* 提取创建者收益
|
|
314
|
-
*/
|
|
315
|
-
export async function signPumpCollectFee(connection, params) {
|
|
316
|
-
try {
|
|
317
|
-
const { creator } = params;
|
|
318
|
-
const onlineSdk = new OnlinePumpSdk(connection);
|
|
319
|
-
// 获取可提取金额(两个程序的总和)
|
|
320
|
-
const balance = await onlineSdk.getCreatorVaultBalanceBothPrograms(creator.publicKey);
|
|
321
|
-
if (balance.isZero()) {
|
|
322
|
-
return {
|
|
323
|
-
success: false,
|
|
324
|
-
error: 'No fees to collect',
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
// 构建提取指令
|
|
328
|
-
const instructions = await onlineSdk.collectCoinCreatorFeeInstructions(creator.publicKey);
|
|
329
|
-
// 构建交易
|
|
330
|
-
const { blockhash } = await connection.getLatestBlockhash('finalized');
|
|
331
|
-
const transaction = new Transaction();
|
|
332
|
-
transaction.add(...instructions);
|
|
333
|
-
transaction.recentBlockhash = blockhash;
|
|
334
|
-
transaction.feePayer = creator.publicKey;
|
|
335
|
-
transaction.sign(creator);
|
|
336
|
-
const serialized = transaction.serialize();
|
|
337
|
-
return {
|
|
338
|
-
success: true,
|
|
339
|
-
signedTransaction: {
|
|
340
|
-
data: Buffer.from(serialized).toString('base64'),
|
|
341
|
-
signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : '',
|
|
342
|
-
},
|
|
343
|
-
expectedAmount: BigInt(balance.toString()),
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
catch (error) {
|
|
347
|
-
return {
|
|
348
|
-
success: false,
|
|
349
|
-
error: error.message,
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pump.fun 类型定义
|
|
3
|
-
* @module sol/dex/pump/types
|
|
4
|
-
*/
|
|
5
|
-
import { Keypair } from '@solana/web3.js';
|
|
6
|
-
/**
|
|
7
|
-
* Pump 代币创建参数
|
|
8
|
-
*/
|
|
9
|
-
export interface PumpCreateTokenParams {
|
|
10
|
-
/** 代币名称 */
|
|
11
|
-
name: string;
|
|
12
|
-
/** 代币符号 */
|
|
13
|
-
symbol: string;
|
|
14
|
-
/** 元数据 URI(IPFS) */
|
|
15
|
-
uri: string;
|
|
16
|
-
/** 创建者 Keypair */
|
|
17
|
-
creator: Keypair;
|
|
18
|
-
/** Mint Keypair(可选,不提供则自动生成) */
|
|
19
|
-
mintKeypair?: Keypair;
|
|
20
|
-
/** 是否使用 Mayhem 模式 */
|
|
21
|
-
mayhemMode?: boolean;
|
|
22
|
-
/** 创建时同时购买的 SOL 数量(可选) */
|
|
23
|
-
initialBuyAmount?: bigint;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Pump 代币创建结果
|
|
27
|
-
*/
|
|
28
|
-
export interface PumpCreateTokenResult {
|
|
29
|
-
success: boolean;
|
|
30
|
-
/** Mint 地址 */
|
|
31
|
-
mint?: string;
|
|
32
|
-
/** Mint Keypair */
|
|
33
|
-
mintKeypair?: Keypair;
|
|
34
|
-
/** Bonding Curve 地址 */
|
|
35
|
-
bondingCurve?: string;
|
|
36
|
-
/** 签名后的交易 */
|
|
37
|
-
signedTransaction?: {
|
|
38
|
-
data: string;
|
|
39
|
-
signature: string;
|
|
40
|
-
};
|
|
41
|
-
error?: string;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Pump 买入参数
|
|
45
|
-
*/
|
|
46
|
-
export interface PumpBuyParams {
|
|
47
|
-
/** 代币 Mint 地址 */
|
|
48
|
-
mint: string;
|
|
49
|
-
/** 购买者 Keypair */
|
|
50
|
-
buyer: Keypair;
|
|
51
|
-
/** SOL 数量(lamports) */
|
|
52
|
-
solAmount: bigint;
|
|
53
|
-
/** 滑点(基点,如 100 = 1%) */
|
|
54
|
-
slippageBps?: number;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Pump 卖出参数
|
|
58
|
-
*/
|
|
59
|
-
export interface PumpSellParams {
|
|
60
|
-
/** 代币 Mint 地址 */
|
|
61
|
-
mint: string;
|
|
62
|
-
/** 卖出者 Keypair */
|
|
63
|
-
seller: Keypair;
|
|
64
|
-
/** 代币数量(最小单位) */
|
|
65
|
-
tokenAmount: bigint;
|
|
66
|
-
/** 滑点(基点,如 100 = 1%) */
|
|
67
|
-
slippageBps?: number;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Pump 交易结果
|
|
71
|
-
*/
|
|
72
|
-
export interface PumpSwapResult {
|
|
73
|
-
success: boolean;
|
|
74
|
-
/** 签名后的交易 */
|
|
75
|
-
signedTransaction?: {
|
|
76
|
-
data: string;
|
|
77
|
-
signature: string;
|
|
78
|
-
};
|
|
79
|
-
/** 预计获得的数量 */
|
|
80
|
-
expectedAmount?: bigint;
|
|
81
|
-
error?: string;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Pump 批量买入参数
|
|
85
|
-
*/
|
|
86
|
-
export interface PumpBatchBuyParams {
|
|
87
|
-
/** 代币 Mint 地址 */
|
|
88
|
-
mint: string;
|
|
89
|
-
/** 买入列表 */
|
|
90
|
-
buyers: Array<{
|
|
91
|
-
wallet: Keypair;
|
|
92
|
-
solAmount: bigint;
|
|
93
|
-
}>;
|
|
94
|
-
/** 滑点(基点) */
|
|
95
|
-
slippageBps?: number;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Pump 批量卖出参数
|
|
99
|
-
*/
|
|
100
|
-
export interface PumpBatchSellParams {
|
|
101
|
-
/** 代币 Mint 地址 */
|
|
102
|
-
mint: string;
|
|
103
|
-
/** 卖出列表 */
|
|
104
|
-
sellers: Array<{
|
|
105
|
-
wallet: Keypair;
|
|
106
|
-
tokenAmount: bigint;
|
|
107
|
-
}>;
|
|
108
|
-
/** 滑点(基点) */
|
|
109
|
-
slippageBps?: number;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Pump 批量交易结果
|
|
113
|
-
*/
|
|
114
|
-
export interface PumpBatchSwapResult {
|
|
115
|
-
success: boolean;
|
|
116
|
-
/** 签名后的交易列表 */
|
|
117
|
-
signedTransactions?: Array<{
|
|
118
|
-
data: string;
|
|
119
|
-
signature: string;
|
|
120
|
-
wallet: string;
|
|
121
|
-
}>;
|
|
122
|
-
/** 成功数量 */
|
|
123
|
-
successCount?: number;
|
|
124
|
-
/** 失败数量 */
|
|
125
|
-
failedCount?: number;
|
|
126
|
-
error?: string;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Bonding Curve 信息
|
|
130
|
-
*/
|
|
131
|
-
export interface BondingCurveInfo {
|
|
132
|
-
/** Mint 地址 */
|
|
133
|
-
mint: string;
|
|
134
|
-
/** Bonding Curve 地址 */
|
|
135
|
-
bondingCurve: string;
|
|
136
|
-
/** 虚拟 SOL 储备 */
|
|
137
|
-
virtualSolReserves: bigint;
|
|
138
|
-
/** 虚拟代币储备 */
|
|
139
|
-
virtualTokenReserves: bigint;
|
|
140
|
-
/** 真实 SOL 储备 */
|
|
141
|
-
realSolReserves: bigint;
|
|
142
|
-
/** 真实代币储备 */
|
|
143
|
-
realTokenReserves: bigint;
|
|
144
|
-
/** 代币总供应量 */
|
|
145
|
-
tokenTotalSupply: bigint;
|
|
146
|
-
/** 是否已完成(迁移到 Raydium) */
|
|
147
|
-
complete: boolean;
|
|
148
|
-
/** 创建者 */
|
|
149
|
-
creator: string;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Pump Swap LP 添加参数
|
|
153
|
-
*/
|
|
154
|
-
export interface PumpSwapAddLpParams {
|
|
155
|
-
/** 代币 Mint 地址 */
|
|
156
|
-
mint: string;
|
|
157
|
-
/** 提供者 Keypair */
|
|
158
|
-
provider: Keypair;
|
|
159
|
-
/** Base 代币数量 */
|
|
160
|
-
baseAmount: bigint;
|
|
161
|
-
/** Quote 代币数量(SOL) */
|
|
162
|
-
quoteAmount: bigint;
|
|
163
|
-
/** 滑点(基点) */
|
|
164
|
-
slippageBps?: number;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Pump Swap LP 移除参数
|
|
168
|
-
*/
|
|
169
|
-
export interface PumpSwapRemoveLpParams {
|
|
170
|
-
/** 代币 Mint 地址 */
|
|
171
|
-
mint: string;
|
|
172
|
-
/** 提供者 Keypair */
|
|
173
|
-
provider: Keypair;
|
|
174
|
-
/** LP Token 数量 */
|
|
175
|
-
lpTokenAmount: bigint;
|
|
176
|
-
/** 滑点(基点) */
|
|
177
|
-
slippageBps?: number;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Pump Swap LP 结果
|
|
181
|
-
*/
|
|
182
|
-
export interface PumpSwapLpResult {
|
|
183
|
-
success: boolean;
|
|
184
|
-
/** Pool 地址 */
|
|
185
|
-
poolAddress?: string;
|
|
186
|
-
/** LP Token Mint 地址 */
|
|
187
|
-
lpMint?: string;
|
|
188
|
-
/** 签名后的交易 */
|
|
189
|
-
signedTransaction?: {
|
|
190
|
-
data: string;
|
|
191
|
-
signature: string;
|
|
192
|
-
};
|
|
193
|
-
error?: string;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* 创建者收益提取参数
|
|
197
|
-
*/
|
|
198
|
-
export interface PumpCollectFeeParams {
|
|
199
|
-
/** 创建者 Keypair */
|
|
200
|
-
creator: Keypair;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* 创建者收益提取结果
|
|
204
|
-
*/
|
|
205
|
-
export interface PumpCollectFeeResult {
|
|
206
|
-
success: boolean;
|
|
207
|
-
/** 签名后的交易 */
|
|
208
|
-
signedTransaction?: {
|
|
209
|
-
data: string;
|
|
210
|
-
signature: string;
|
|
211
|
-
};
|
|
212
|
-
/** 预计提取金额 */
|
|
213
|
-
expectedAmount?: bigint;
|
|
214
|
-
error?: string;
|
|
215
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Raydium DEX 模块导出
|
|
3
|
-
* @module sol/dex/raydium
|
|
4
|
-
*/
|
|
5
|
-
// 类型
|
|
6
|
-
export * from './types.js';
|
|
7
|
-
// 核心功能(交换、LP)
|
|
8
|
-
export * from './raydium.js';
|
|
9
|
-
// LaunchLab(代币创建)
|
|
10
|
-
export * from './launchlab.js';
|
|
11
|
-
// Bundle 批量签名
|
|
12
|
-
export * from './raydium-bundle.js';
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Raydium LaunchLab 代币创建
|
|
3
|
-
* @module sol/dex/raydium/launchlab
|
|
4
|
-
*/
|
|
5
|
-
import { Connection, Keypair } from '@solana/web3.js';
|
|
6
|
-
import type { RaydiumLaunchLabParams, RaydiumLaunchLabResult } from './types.js';
|
|
7
|
-
/**
|
|
8
|
-
* 获取 LaunchLab 配置列表
|
|
9
|
-
*/
|
|
10
|
-
export declare function getLaunchLabConfigs(connection: Connection): Promise<Array<{
|
|
11
|
-
id: string;
|
|
12
|
-
curveType: number;
|
|
13
|
-
mintB: string;
|
|
14
|
-
migrateFee: bigint;
|
|
15
|
-
tradeFeeRate: number;
|
|
16
|
-
}>>;
|
|
17
|
-
/**
|
|
18
|
-
* 构建并签名 LaunchLab 创建代币交易
|
|
19
|
-
*/
|
|
20
|
-
export declare function signRaydiumLaunchLabCreate(connection: Connection, params: RaydiumLaunchLabParams): Promise<RaydiumLaunchLabResult>;
|
|
21
|
-
/**
|
|
22
|
-
* 构建 LaunchLab 买入交易
|
|
23
|
-
*/
|
|
24
|
-
export declare function signRaydiumLaunchLabBuy(connection: Connection, params: {
|
|
25
|
-
poolId: string;
|
|
26
|
-
mintA: string;
|
|
27
|
-
amountIn: bigint;
|
|
28
|
-
minAmountOut?: bigint;
|
|
29
|
-
slippageBps?: number;
|
|
30
|
-
wallet: Keypair;
|
|
31
|
-
}): Promise<{
|
|
32
|
-
success: boolean;
|
|
33
|
-
signedTransaction?: string;
|
|
34
|
-
estimatedAmountOut?: bigint;
|
|
35
|
-
error?: string;
|
|
36
|
-
}>;
|
|
37
|
-
/**
|
|
38
|
-
* 构建 LaunchLab 卖出交易
|
|
39
|
-
*/
|
|
40
|
-
export declare function signRaydiumLaunchLabSell(connection: Connection, params: {
|
|
41
|
-
poolId: string;
|
|
42
|
-
mintA: string;
|
|
43
|
-
amountIn: bigint;
|
|
44
|
-
minAmountOut?: bigint;
|
|
45
|
-
slippageBps?: number;
|
|
46
|
-
wallet: Keypair;
|
|
47
|
-
}): Promise<{
|
|
48
|
-
success: boolean;
|
|
49
|
-
signedTransaction?: string;
|
|
50
|
-
estimatedAmountOut?: bigint;
|
|
51
|
-
error?: string;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* 获取 LaunchLab 池子信息
|
|
55
|
-
*/
|
|
56
|
-
export declare function getLaunchLabPoolInfo(connection: Connection, poolId: string): Promise<{
|
|
57
|
-
id: string;
|
|
58
|
-
mintA: string;
|
|
59
|
-
mintB: string;
|
|
60
|
-
status: number;
|
|
61
|
-
virtualA: bigint;
|
|
62
|
-
virtualB: bigint;
|
|
63
|
-
realA: bigint;
|
|
64
|
-
realB: bigint;
|
|
65
|
-
supply: bigint;
|
|
66
|
-
totalSellA: bigint;
|
|
67
|
-
price: number;
|
|
68
|
-
} | null>;
|