pump-trader 1.1.8 → 1.1.9

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/index.ts CHANGED
@@ -22,10 +22,14 @@ import {
22
22
  } from "@solana/spl-token";
23
23
 
24
24
  import BN from "bn.js";
25
- import bs58 from "bs58";
26
-
27
25
  /* ================= 类型定义 ================= */
28
26
 
27
+ /** Wallet 接口:兼容 Keypair(自动签名)和前端钱包适配器(弹出确认) */
28
+ export type Wallet = Keypair | {
29
+ publicKey: PublicKey;
30
+ signTransaction<T extends Transaction>(tx: T): Promise<T>;
31
+ };
32
+
29
33
  interface TradeOptions {
30
34
  maxSolPerTx: bigint;
31
35
  slippage: {
@@ -313,14 +317,16 @@ function parsePoolKeys(data: Buffer) {
313
317
 
314
318
  export class PumpTrader {
315
319
  private connection: Connection;
316
- private wallet: Keypair;
320
+ private _wallet: Keypair | { publicKey: PublicKey; signTransaction<T extends Transaction>(tx: T): Promise<T> };
321
+ public publicKey: PublicKey;
317
322
  private global: PublicKey;
318
323
  private globalState: GlobalState | null;
319
324
  private tokenProgramCache: Map<string, TokenProgramType>;
320
325
 
321
- constructor(rpc: string, privateKey: string) {
326
+ constructor(rpc: string, wallet: Wallet) {
322
327
  this.connection = new Connection(rpc, "confirmed");
323
- this.wallet = Keypair.fromSecretKey(bs58.decode(privateKey));
328
+ this._wallet = wallet;
329
+ this.publicKey = wallet.publicKey;
324
330
  this.global = PublicKey.findProgramAddressSync(
325
331
  [SEEDS.GLOBAL],
326
332
  PROGRAM_IDS.PUMP,
@@ -329,6 +335,14 @@ export class PumpTrader {
329
335
  this.tokenProgramCache = new Map();
330
336
  }
331
337
 
338
+ private async signTx(tx: Transaction): Promise<Transaction> {
339
+ if (this._wallet instanceof Keypair) {
340
+ tx.sign(this._wallet);
341
+ return tx;
342
+ }
343
+ return this._wallet.signTransaction(tx);
344
+ }
345
+
332
346
  /* ---------- Token Program 检测 ---------- */
333
347
 
334
348
  /**
@@ -741,17 +755,17 @@ export class PumpTrader {
741
755
  async tokenBalance(tokenAddr?: string): Promise<
742
756
  | number
743
757
  | Array<{
744
- mint: string;
745
- amount: number;
746
- decimals: number;
747
- uiAmount: number;
748
- }>
758
+ mint: string;
759
+ amount: number;
760
+ decimals: number;
761
+ uiAmount: number;
762
+ }>
749
763
  > {
750
764
  if (tokenAddr) {
751
765
  // 查询单个代币
752
766
  const mint = new PublicKey(tokenAddr);
753
767
  const tokenAccounts = await this.connection.getParsedTokenAccountsByOwner(
754
- this.wallet.publicKey,
768
+ this.publicKey,
755
769
  { mint },
756
770
  );
757
771
  return (
@@ -772,7 +786,7 @@ export class PumpTrader {
772
786
  Array<{ mint: string; amount: number; decimals: number; uiAmount: number }>
773
787
  > {
774
788
  const tokenAccounts = await this.connection.getParsedTokenAccountsByOwner(
775
- this.wallet.publicKey,
789
+ this.publicKey,
776
790
  { programId: TOKEN_PROGRAM_ID },
777
791
  );
778
792
 
@@ -792,16 +806,16 @@ export class PumpTrader {
792
806
  };
793
807
  })
794
808
  .filter((item) => item !== null) as Array<{
795
- mint: string;
796
- amount: bigint;
797
- decimals: number;
798
- uiAmount: number;
799
- }>;
809
+ mint: string;
810
+ amount: bigint;
811
+ decimals: number;
812
+ uiAmount: number;
813
+ }>;
800
814
 
801
815
  // 同时查询 TOKEN_2022_PROGRAM_ID
802
816
  const token2022Accounts =
803
817
  await this.connection.getParsedTokenAccountsByOwner(
804
- this.wallet.publicKey,
818
+ this.publicKey,
805
819
  { programId: TOKEN_2022_PROGRAM_ID },
806
820
  );
807
821
 
@@ -821,11 +835,11 @@ export class PumpTrader {
821
835
  };
822
836
  })
823
837
  .filter((item) => item !== null) as Array<{
824
- mint: string;
825
- amount: bigint;
826
- decimals: number;
827
- uiAmount: number;
828
- }>;
838
+ mint: string;
839
+ amount: bigint;
840
+ decimals: number;
841
+ uiAmount: number;
842
+ }>;
829
843
 
830
844
  // 合并并去重
831
845
  const allBalances = [...balances, ...token2022Balances];
@@ -847,7 +861,7 @@ export class PumpTrader {
847
861
  }
848
862
 
849
863
  async solBalance(): Promise<number> {
850
- const balance = await this.connection.getBalance(this.wallet.publicKey);
864
+ const balance = await this.connection.getBalance(this.publicKey);
851
865
  return balance / 1e9;
852
866
  }
853
867
 
@@ -861,7 +875,7 @@ export class PumpTrader {
861
875
  const program = tokenProgram || TOKEN_2022_PROGRAM_ID;
862
876
  const ata = getAssociatedTokenAddressSync(
863
877
  mint,
864
- this.wallet.publicKey,
878
+ this.publicKey,
865
879
  false,
866
880
  program,
867
881
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -871,9 +885,9 @@ export class PumpTrader {
871
885
  if (!acc) {
872
886
  tx.add(
873
887
  createAssociatedTokenAccountInstruction(
874
- this.wallet.publicKey,
888
+ this.publicKey,
875
889
  ata,
876
- this.wallet.publicKey,
890
+ this.publicKey,
877
891
  mint,
878
892
  program,
879
893
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -1068,7 +1082,7 @@ export class PumpTrader {
1068
1082
  const [userVolumeAccumulator] = PublicKey.findProgramAddressSync(
1069
1083
  [
1070
1084
  Buffer.from("user_volume_accumulator"),
1071
- this.wallet.publicKey.toBuffer(),
1085
+ this.publicKey.toBuffer(),
1072
1086
  ],
1073
1087
  PROGRAM_IDS.PUMP,
1074
1088
  );
@@ -1108,7 +1122,7 @@ export class PumpTrader {
1108
1122
  bonding,
1109
1123
  associatedBondingCurve,
1110
1124
  userAta,
1111
- wallet: this.wallet.publicKey,
1125
+ wallet: this.publicKey,
1112
1126
  creatorVault,
1113
1127
  eventAuthority: PROGRAM_IDS.EVENT_AUTHORITY,
1114
1128
  pumpProgram: PROGRAM_IDS.PUMP,
@@ -1131,8 +1145,8 @@ export class PumpTrader {
1131
1145
  const { blockhash, lastValidBlockHeight } =
1132
1146
  await this.connection.getLatestBlockhash("finalized");
1133
1147
  tx.recentBlockhash = blockhash;
1134
- tx.feePayer = this.wallet.publicKey;
1135
- tx.sign(this.wallet);
1148
+ tx.feePayer = this.publicKey;
1149
+ await this.signTx(tx);
1136
1150
 
1137
1151
  const signature = await this.connection.sendRawTransaction(
1138
1152
  tx.serialize(),
@@ -1177,11 +1191,11 @@ export class PumpTrader {
1177
1191
  totalSolOut <= tradeOpt.maxSolPerTx
1178
1192
  ? [totalTokenIn]
1179
1193
  : this.splitIntoN(
1180
- totalTokenIn,
1181
- Number(
1182
- (totalSolOut + tradeOpt.maxSolPerTx - 1n) / tradeOpt.maxSolPerTx,
1183
- ),
1184
- );
1194
+ totalTokenIn,
1195
+ Number(
1196
+ (totalSolOut + tradeOpt.maxSolPerTx - 1n) / tradeOpt.maxSolPerTx,
1197
+ ),
1198
+ );
1185
1199
 
1186
1200
  const pendingTransactions: PendingTransaction[] = [];
1187
1201
  const failedTransactions: FailedTransaction[] = [];
@@ -1196,7 +1210,7 @@ export class PumpTrader {
1196
1210
 
1197
1211
  const userAta = getAssociatedTokenAddressSync(
1198
1212
  mint,
1199
- this.wallet.publicKey,
1213
+ this.publicKey,
1200
1214
  false,
1201
1215
  tokenProgram.programId,
1202
1216
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -1215,7 +1229,7 @@ export class PumpTrader {
1215
1229
  const [userVolumeAccumulator] = PublicKey.findProgramAddressSync(
1216
1230
  [
1217
1231
  Buffer.from("user_volume_accumulator"),
1218
- this.wallet.publicKey.toBuffer(),
1232
+ this.publicKey.toBuffer(),
1219
1233
  ],
1220
1234
  PROGRAM_IDS.PUMP,
1221
1235
  );
@@ -1248,7 +1262,7 @@ export class PumpTrader {
1248
1262
  bonding,
1249
1263
  associatedBondingCurve,
1250
1264
  userAta,
1251
- wallet: this.wallet.publicKey,
1265
+ wallet: this.publicKey,
1252
1266
  creatorVault,
1253
1267
  eventAuthority: PROGRAM_IDS.EVENT_AUTHORITY,
1254
1268
  pumpProgram: PROGRAM_IDS.PUMP,
@@ -1271,8 +1285,8 @@ export class PumpTrader {
1271
1285
  const { blockhash, lastValidBlockHeight } =
1272
1286
  await this.connection.getLatestBlockhash("finalized");
1273
1287
  tx.recentBlockhash = blockhash;
1274
- tx.feePayer = this.wallet.publicKey;
1275
- tx.sign(this.wallet);
1288
+ tx.feePayer = this.publicKey;
1289
+ await this.signTx(tx);
1276
1290
 
1277
1291
  const signature = await this.connection.sendRawTransaction(
1278
1292
  tx.serialize(),
@@ -1337,11 +1351,11 @@ export class PumpTrader {
1337
1351
  );
1338
1352
  const userQuoteAta = isSolQuote
1339
1353
  ? await this.ensureWSOLAta(
1340
- tx,
1341
- this.wallet.publicKey,
1342
- "buy",
1343
- maxQuoteIn,
1344
- )
1354
+ tx,
1355
+ this.publicKey,
1356
+ "buy",
1357
+ maxQuoteIn,
1358
+ )
1345
1359
  : await this.ensureAta(tx, quoteMint, quoteTokenProgramId);
1346
1360
 
1347
1361
  const buyIx = this.createAmmBuyInstruction(
@@ -1358,8 +1372,8 @@ export class PumpTrader {
1358
1372
  tx.add(
1359
1373
  createCloseAccountInstruction(
1360
1374
  userQuoteAta,
1361
- this.wallet.publicKey,
1362
- this.wallet.publicKey,
1375
+ this.publicKey,
1376
+ this.publicKey,
1363
1377
  ),
1364
1378
  );
1365
1379
  }
@@ -1367,8 +1381,8 @@ export class PumpTrader {
1367
1381
  const { blockhash, lastValidBlockHeight } =
1368
1382
  await this.connection.getLatestBlockhash("finalized");
1369
1383
  tx.recentBlockhash = blockhash;
1370
- tx.feePayer = this.wallet.publicKey;
1371
- tx.sign(this.wallet);
1384
+ tx.feePayer = this.publicKey;
1385
+ await this.signTx(tx);
1372
1386
 
1373
1387
  const signature = await this.connection.sendRawTransaction(
1374
1388
  tx.serialize(),
@@ -1413,11 +1427,11 @@ export class PumpTrader {
1413
1427
  totalSolOut <= tradeOpt.maxSolPerTx
1414
1428
  ? [totalTokenIn]
1415
1429
  : this.splitIntoN(
1416
- totalTokenIn,
1417
- Number(
1418
- (totalSolOut + tradeOpt.maxSolPerTx - 1n) / tradeOpt.maxSolPerTx,
1419
- ),
1420
- );
1430
+ totalTokenIn,
1431
+ Number(
1432
+ (totalSolOut + tradeOpt.maxSolPerTx - 1n) / tradeOpt.maxSolPerTx,
1433
+ ),
1434
+ );
1421
1435
 
1422
1436
  const pendingTransactions: PendingTransaction[] = [];
1423
1437
  const failedTransactions: FailedTransaction[] = [];
@@ -1445,7 +1459,7 @@ export class PumpTrader {
1445
1459
  tokenProgram.programId,
1446
1460
  );
1447
1461
  const userQuoteAta = isSolQuote
1448
- ? await this.ensureWSOLAta(tx, this.wallet.publicKey, "sell")
1462
+ ? await this.ensureWSOLAta(tx, this.publicKey, "sell")
1449
1463
  : await this.ensureAta(tx, quoteMint, quoteTokenProgramId);
1450
1464
 
1451
1465
  const sellIx = this.createAmmSellInstruction(
@@ -1462,8 +1476,8 @@ export class PumpTrader {
1462
1476
  tx.add(
1463
1477
  createCloseAccountInstruction(
1464
1478
  userQuoteAta,
1465
- this.wallet.publicKey,
1466
- this.wallet.publicKey,
1479
+ this.publicKey,
1480
+ this.publicKey,
1467
1481
  ),
1468
1482
  );
1469
1483
  }
@@ -1471,8 +1485,8 @@ export class PumpTrader {
1471
1485
  const { blockhash, lastValidBlockHeight } =
1472
1486
  await this.connection.getLatestBlockhash("finalized");
1473
1487
  tx.recentBlockhash = blockhash;
1474
- tx.feePayer = this.wallet.publicKey;
1475
- tx.sign(this.wallet);
1488
+ tx.feePayer = this.publicKey;
1489
+ await this.signTx(tx);
1476
1490
 
1477
1491
  const signature = await this.connection.sendRawTransaction(
1478
1492
  tx.serialize(),
@@ -1623,7 +1637,7 @@ export class PumpTrader {
1623
1637
  const [userVolumeAccumulator] = PublicKey.findProgramAddressSync(
1624
1638
  [
1625
1639
  Buffer.from("user_volume_accumulator"),
1626
- this.wallet.publicKey.toBuffer(),
1640
+ this.publicKey.toBuffer(),
1627
1641
  ],
1628
1642
  PROGRAM_IDS.PUMP_AMM,
1629
1643
  );
@@ -1679,7 +1693,7 @@ export class PumpTrader {
1679
1693
  programId: PROGRAM_IDS.PUMP_AMM,
1680
1694
  keys: [
1681
1695
  { pubkey: pool, isSigner: false, isWritable: true },
1682
- { pubkey: this.wallet.publicKey, isSigner: true, isWritable: true },
1696
+ { pubkey: this.publicKey, isSigner: true, isWritable: true },
1683
1697
  { pubkey: globalConfig.address, isSigner: false, isWritable: false },
1684
1698
  { pubkey: poolKeys.baseMint, isSigner: false, isWritable: false },
1685
1699
  { pubkey: poolKeys.quoteMint, isSigner: false, isWritable: false },
@@ -1786,7 +1800,7 @@ export class PumpTrader {
1786
1800
  const [userVolumeAccumulator] = PublicKey.findProgramAddressSync(
1787
1801
  [
1788
1802
  Buffer.from("user_volume_accumulator"),
1789
- this.wallet.publicKey.toBuffer(),
1803
+ this.publicKey.toBuffer(),
1790
1804
  ],
1791
1805
  PROGRAM_IDS.PUMP_AMM,
1792
1806
  );
@@ -1824,7 +1838,7 @@ export class PumpTrader {
1824
1838
  programId: PROGRAM_IDS.PUMP_AMM,
1825
1839
  keys: [
1826
1840
  { pubkey: pool, isSigner: false, isWritable: true },
1827
- { pubkey: this.wallet.publicKey, isSigner: true, isWritable: true },
1841
+ { pubkey: this.publicKey, isSigner: true, isWritable: true },
1828
1842
  { pubkey: globalConfig.address, isSigner: false, isWritable: false },
1829
1843
  { pubkey: poolKeys.baseMint, isSigner: false, isWritable: false },
1830
1844
  { pubkey: poolKeys.quoteMint, isSigner: false, isWritable: false },
@@ -2126,7 +2140,7 @@ export class PumpTrader {
2126
2140
  const [userVolumeAccumulator] = PublicKey.findProgramAddressSync(
2127
2141
  [
2128
2142
  Buffer.from("user_volume_accumulator"),
2129
- this.wallet.publicKey.toBuffer(),
2143
+ this.publicKey.toBuffer(),
2130
2144
  ],
2131
2145
  PROGRAM_IDS.PUMP,
2132
2146
  );
@@ -2163,7 +2177,7 @@ export class PumpTrader {
2163
2177
 
2164
2178
  const associatedQuoteUser = getAssociatedTokenAddressSync(
2165
2179
  quoteMint,
2166
- this.wallet.publicKey,
2180
+ this.publicKey,
2167
2181
  false,
2168
2182
  quoteTokenProgramId,
2169
2183
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2190,7 +2204,7 @@ export class PumpTrader {
2190
2204
  if (quoteMint.equals(SOL_MINT)) {
2191
2205
  await this.ensureWSOLAta(
2192
2206
  tx,
2193
- this.wallet.publicKey,
2207
+ this.publicKey,
2194
2208
  "buy",
2195
2209
  maxQuoteCost,
2196
2210
  );
@@ -2198,7 +2212,7 @@ export class PumpTrader {
2198
2212
  // For non-SOL quote (e.g. USDC), ensure user has the quote token ATA
2199
2213
  const userQuoteAta = getAssociatedTokenAddressSync(
2200
2214
  quoteMint,
2201
- this.wallet.publicKey,
2215
+ this.publicKey,
2202
2216
  false,
2203
2217
  quoteTokenProgramId,
2204
2218
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2207,9 +2221,9 @@ export class PumpTrader {
2207
2221
  if (!acc) {
2208
2222
  tx.add(
2209
2223
  createAssociatedTokenAccountInstruction(
2210
- this.wallet.publicKey,
2224
+ this.publicKey,
2211
2225
  userQuoteAta,
2212
- this.wallet.publicKey,
2226
+ this.publicKey,
2213
2227
  quoteMint,
2214
2228
  quoteTokenProgramId,
2215
2229
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2240,7 +2254,7 @@ export class PumpTrader {
2240
2254
  bondingCurve: bonding,
2241
2255
  associatedBaseBondingCurve,
2242
2256
  associatedQuoteBondingCurve,
2243
- user: this.wallet.publicKey,
2257
+ user: this.publicKey,
2244
2258
  associatedBaseUser: userBaseAta,
2245
2259
  associatedQuoteUser,
2246
2260
  creatorVault,
@@ -2266,7 +2280,7 @@ export class PumpTrader {
2266
2280
  if (quoteMint.equals(SOL_MINT)) {
2267
2281
  const wsolAta = getAssociatedTokenAddressSync(
2268
2282
  SOL_MINT,
2269
- this.wallet.publicKey,
2283
+ this.publicKey,
2270
2284
  false,
2271
2285
  TOKEN_PROGRAM_ID,
2272
2286
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2274,8 +2288,8 @@ export class PumpTrader {
2274
2288
  tx.add(
2275
2289
  createCloseAccountInstruction(
2276
2290
  wsolAta,
2277
- this.wallet.publicKey,
2278
- this.wallet.publicKey,
2291
+ this.publicKey,
2292
+ this.publicKey,
2279
2293
  ),
2280
2294
  );
2281
2295
  }
@@ -2283,8 +2297,8 @@ export class PumpTrader {
2283
2297
  const { blockhash, lastValidBlockHeight } =
2284
2298
  await this.connection.getLatestBlockhash("finalized");
2285
2299
  tx.recentBlockhash = blockhash;
2286
- tx.feePayer = this.wallet.publicKey;
2287
- tx.sign(this.wallet);
2300
+ tx.feePayer = this.publicKey;
2301
+ await this.signTx(tx);
2288
2302
 
2289
2303
  const signature = await this.connection.sendRawTransaction(
2290
2304
  tx.serialize(),
@@ -2328,12 +2342,12 @@ export class PumpTrader {
2328
2342
  totalQuoteOut <= tradeOpt.maxSolPerTx
2329
2343
  ? [totalTokenIn]
2330
2344
  : this.splitIntoN(
2331
- totalTokenIn,
2332
- Number(
2333
- (totalQuoteOut + tradeOpt.maxSolPerTx - 1n) /
2334
- tradeOpt.maxSolPerTx,
2335
- ),
2336
- );
2345
+ totalTokenIn,
2346
+ Number(
2347
+ (totalQuoteOut + tradeOpt.maxSolPerTx - 1n) /
2348
+ tradeOpt.maxSolPerTx,
2349
+ ),
2350
+ );
2337
2351
 
2338
2352
  const pendingTransactions: PendingTransaction[] = [];
2339
2353
  const failedTransactions: FailedTransaction[] = [];
@@ -2369,7 +2383,7 @@ export class PumpTrader {
2369
2383
  const [userVolumeAccumulator] = PublicKey.findProgramAddressSync(
2370
2384
  [
2371
2385
  Buffer.from("user_volume_accumulator"),
2372
- this.wallet.publicKey.toBuffer(),
2386
+ this.publicKey.toBuffer(),
2373
2387
  ],
2374
2388
  PROGRAM_IDS.PUMP,
2375
2389
  );
@@ -2406,7 +2420,7 @@ export class PumpTrader {
2406
2420
 
2407
2421
  const associatedQuoteUser = getAssociatedTokenAddressSync(
2408
2422
  quoteMint,
2409
- this.wallet.publicKey,
2423
+ this.publicKey,
2410
2424
  false,
2411
2425
  quoteTokenProgramId,
2412
2426
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2414,7 +2428,7 @@ export class PumpTrader {
2414
2428
 
2415
2429
  const userBaseAta = getAssociatedTokenAddressSync(
2416
2430
  baseMint,
2417
- this.wallet.publicKey,
2431
+ this.publicKey,
2418
2432
  false,
2419
2433
  baseTokenProgram.programId,
2420
2434
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2441,7 +2455,7 @@ export class PumpTrader {
2441
2455
  if (!quoteMint.equals(SOL_MINT)) {
2442
2456
  const userQuoteAta = getAssociatedTokenAddressSync(
2443
2457
  quoteMint,
2444
- this.wallet.publicKey,
2458
+ this.publicKey,
2445
2459
  false,
2446
2460
  quoteTokenProgramId,
2447
2461
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2450,9 +2464,9 @@ export class PumpTrader {
2450
2464
  if (!acc) {
2451
2465
  tx.add(
2452
2466
  createAssociatedTokenAccountInstruction(
2453
- this.wallet.publicKey,
2467
+ this.publicKey,
2454
2468
  userQuoteAta,
2455
- this.wallet.publicKey,
2469
+ this.publicKey,
2456
2470
  quoteMint,
2457
2471
  quoteTokenProgramId,
2458
2472
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2477,7 +2491,7 @@ export class PumpTrader {
2477
2491
  bondingCurve: bonding,
2478
2492
  associatedBaseBondingCurve,
2479
2493
  associatedQuoteBondingCurve,
2480
- user: this.wallet.publicKey,
2494
+ user: this.publicKey,
2481
2495
  associatedBaseUser: userBaseAta,
2482
2496
  associatedQuoteUser,
2483
2497
  creatorVault,
@@ -2501,8 +2515,8 @@ export class PumpTrader {
2501
2515
  const { blockhash, lastValidBlockHeight } =
2502
2516
  await this.connection.getLatestBlockhash("finalized");
2503
2517
  tx.recentBlockhash = blockhash;
2504
- tx.feePayer = this.wallet.publicKey;
2505
- tx.sign(this.wallet);
2518
+ tx.feePayer = this.publicKey;
2519
+ await this.signTx(tx);
2506
2520
 
2507
2521
  const signature = await this.connection.sendRawTransaction(
2508
2522
  tx.serialize(),
@@ -2591,8 +2605,8 @@ export class PumpTrader {
2591
2605
  const { blockhash, lastValidBlockHeight } =
2592
2606
  await this.connection.getLatestBlockhash("finalized");
2593
2607
  tx.recentBlockhash = blockhash;
2594
- tx.feePayer = this.wallet.publicKey;
2595
- tx.sign(this.wallet);
2608
+ tx.feePayer = this.publicKey;
2609
+ await this.signTx(tx);
2596
2610
 
2597
2611
  const signature = await this.connection.sendRawTransaction(tx.serialize());
2598
2612
  await this.confirmTransactionWithPolling(signature, lastValidBlockHeight);
@@ -2744,9 +2758,15 @@ export class PumpTrader {
2744
2758
  }
2745
2759
  }
2746
2760
 
2747
- // 公开wallet方法
2748
- getWallet() {
2749
- return this.wallet;
2761
+ /**
2762
+ * 获取原始 wallet 对象(Keypair 或前端 WalletAdapter)
2763
+ */
2764
+ getWallet(): Wallet {
2765
+ return this._wallet;
2766
+ }
2767
+
2768
+ getPublicKey(): PublicKey {
2769
+ return this.publicKey;
2750
2770
  }
2751
2771
 
2752
2772
  getConnection() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pump-trader",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "PumpFun 交易库 - 自动判断 Token Program 和内盘/外盘",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",