pump-trader 1.1.8 → 1.2.1

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/index.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import { Connection, PublicKey, Transaction, TransactionInstruction, Keypair } from "@solana/web3.js";
2
+ /** Wallet 接口:兼容 Keypair(自动签名)和前端钱包适配器(弹出确认) */
3
+ export type Wallet = Keypair | {
4
+ publicKey: PublicKey;
5
+ signTransaction<T extends Transaction>(tx: T): Promise<T>;
6
+ };
2
7
  interface TradeOptions {
3
8
  maxSolPerTx: bigint;
4
9
  slippage: {
@@ -35,6 +40,9 @@ interface BondingCurveState {
35
40
  complete: boolean;
36
41
  isMayhemMode?: boolean;
37
42
  isCashbackCoin?: boolean;
43
+ quoteMint?: PublicKey;
44
+ virtualQuoteReserves?: bigint;
45
+ realQuoteReserves?: bigint;
38
46
  }
39
47
  interface BondingInfo {
40
48
  bonding: PublicKey;
@@ -84,15 +92,18 @@ interface MetadataInfo {
84
92
  }
85
93
  export declare class PumpTrader {
86
94
  private connection;
87
- private wallet;
95
+ private _wallet;
96
+ publicKey: PublicKey;
88
97
  private global;
89
98
  private globalState;
90
99
  private tokenProgramCache;
91
- constructor(rpc: string, privateKey: string);
100
+ constructor(rpc: string, wallet: Wallet);
101
+ private signTx;
92
102
  /**
93
103
  * 自动检测代币使用的 token program
94
104
  */
95
105
  detectTokenProgram(tokenAddr: string): Promise<TokenProgramType>;
106
+ detectQuoteTokenProgram(quoteMint: PublicKey): Promise<PublicKey>;
96
107
  /**
97
108
  * 检测代币是否在外盘 (AMM)
98
109
  */
@@ -105,6 +116,9 @@ export declare class PumpTrader {
105
116
  getBondingPda(mint: PublicKey): PublicKey;
106
117
  deriveBondingCurveV2(mint: PublicKey): PublicKey;
107
118
  private pickFeeRecipient;
119
+ private pickBuybackFeeRecipient;
120
+ private pickReservedFeeRecipient;
121
+ getSharingConfigPda(mint: PublicKey): PublicKey;
108
122
  private buildBondingBuyKeys;
109
123
  private buildBondingSellKeys;
110
124
  loadBonding(mint: PublicKey): Promise<BondingInfo>;
@@ -147,17 +161,21 @@ export declare class PumpTrader {
147
161
  splitIntoN(total: bigint, n: number): bigint[];
148
162
  /**
149
163
  * 自动判断内盘/外盘并执行买入
164
+ * @param useV2 - use buy_v2 instruction (supports USDC quote) instead of legacy buy
165
+ * @param quoteMint - quote mint for V2 (SOL_MINT for SOL-paired, or USDC mint for USDC-paired)
150
166
  */
151
- autoBuy(tokenAddr: string, totalSolIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
167
+ autoBuy(tokenAddr: string, totalSolIn: bigint, tradeOpt: TradeOptions, useV2?: boolean, quoteMint?: PublicKey): Promise<TradeResult>;
152
168
  /**
153
169
  * 自动判断内盘/外盘并执行卖出
170
+ * @param useV2 - use sell_v2 instruction (supports USDC quote) instead of legacy sell
171
+ * @param quoteMint - quote mint for V2 (SOL_MINT for SOL-paired, or USDC mint for USDC-paired)
154
172
  */
155
- autoSell(tokenAddr: string, totalTokenIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
173
+ autoSell(tokenAddr: string, totalTokenIn: bigint, tradeOpt: TradeOptions, useV2?: boolean, quoteMint?: PublicKey): Promise<TradeResult>;
156
174
  buy(tokenAddr: string, totalSolIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
157
175
  sell(tokenAddr: string, totalTokenIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
158
- ammBuy(tokenAddr: string, totalSolIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
159
- ammSell(tokenAddr: string, totalTokenIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
160
- getAmmPoolInfo(mint: PublicKey): Promise<PoolInfo>;
176
+ ammBuy(tokenAddr: string, totalSolIn: bigint, tradeOpt: TradeOptions, quoteMint?: PublicKey): Promise<TradeResult>;
177
+ ammSell(tokenAddr: string, totalTokenIn: bigint, tradeOpt: TradeOptions, quoteMint?: PublicKey): Promise<TradeResult>;
178
+ getAmmPoolInfo(mint: PublicKey, quoteMint?: PublicKey): Promise<PoolInfo>;
161
179
  parseAmmGlobalConfig(data: Buffer, address: PublicKey): {
162
180
  address: PublicKey;
163
181
  admin: PublicKey;
@@ -167,10 +185,39 @@ export declare class PumpTrader {
167
185
  deriveAmmPoolV2(baseMint: PublicKey): PublicKey;
168
186
  createAmmBuyInstruction(poolInfo: PoolInfo, userBaseAta: PublicKey, userQuoteAta: PublicKey, baseAmountOut: bigint, maxQuoteAmountIn: bigint, tokenProgramId: PublicKey): TransactionInstruction;
169
187
  createAmmSellInstruction(poolInfo: PoolInfo, userBaseAta: PublicKey, userQuoteAta: PublicKey, baseAmountIn: bigint, minQuoteAmountOut: bigint, tokenProgramId: PublicKey): TransactionInstruction;
188
+ /**
189
+ * Build accounts for buy_v2 instruction (27 accounts)
190
+ * Ref: https://github.com/pump-fun/pump-public-docs/blob/main/docs/instructions/BUY.md
191
+ */
192
+ private buildBondingBuyV2Keys;
193
+ /**
194
+ * Build accounts for sell_v2 instruction (26 accounts)
195
+ * Ref: https://github.com/pump-fun/pump-public-docs/blob/main/docs/instructions/SELL.md
196
+ */
197
+ private buildBondingSellV2Keys;
198
+ /**
199
+ * Buy using buy_v2 instruction (supports both SOL-paired and USDC-paired coins)
200
+ * For SOL-paired coins: quoteMint = SOL_MINT, quoteTokenProgram = TOKEN_PROGRAM_ID
201
+ * For USDC-paired coins: quoteMint = USDC mint, quoteTokenProgram = TOKEN_PROGRAM_ID
202
+ */
203
+ buyV2(tokenAddr: string, totalQuoteIn: bigint, tradeOpt: TradeOptions, quoteMint?: PublicKey): Promise<TradeResult>;
204
+ /**
205
+ * Sell using sell_v2 instruction (supports both SOL-paired and USDC-paired coins)
206
+ */
207
+ sellV2(tokenAddr: string, totalTokenIn: bigint, tradeOpt: TradeOptions, quoteMint?: PublicKey): Promise<TradeResult>;
208
+ /**
209
+ * Collect creator fees from bonding curve creator vault (collect_creator_fee_v2)
210
+ * Ref: https://github.com/pump-fun/pump-public-docs/blob/main/docs/instructions/COLLECT_CREATOR_FEE.md
211
+ */
212
+ collectCreatorFeeV2(creator: PublicKey, quoteMint?: PublicKey): Promise<string>;
170
213
  confirmTransactionWithPolling(signature: string, lastValidBlockHeight: number, maxAttempts?: number, delayMs?: number): Promise<string>;
171
214
  listenTrades(callback: (event: TradeEvent) => void, mintFilter?: PublicKey | null): number;
172
215
  fetchMeta(tokenAddr: string): Promise<MetadataInfo | null>;
173
- getWallet(): Keypair;
216
+ /**
217
+ * 获取原始 wallet 对象(Keypair 或前端 WalletAdapter)
218
+ */
219
+ getWallet(): Wallet;
220
+ getPublicKey(): PublicKey;
174
221
  getConnection(): Connection;
175
222
  /**
176
223
  * 清除token program缓存
@@ -181,4 +228,4 @@ export declare class PumpTrader {
181
228
  */
182
229
  getCachedTokenProgram(tokenAddr: string): TokenProgramType | undefined;
183
230
  }
184
- export type { TradeOptions, PendingTransaction, FailedTransaction, TradeResult, BondingCurveState, BondingInfo, PoolReserves, TradeEvent, GlobalState, TokenProgramType, PoolInfo, MetadataInfo };
231
+ export type { TradeOptions, PendingTransaction, FailedTransaction, TradeResult, BondingCurveState, BondingInfo, PoolReserves, TradeEvent, GlobalState, TokenProgramType, PoolInfo, MetadataInfo, };