pump-trader 1.1.5 → 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/dist/index.d.ts +57 -13
- package/dist/index.js +751 -162
- package/index.js +524 -298
- package/index.ts +1361 -307
- package/package.json +1 -1
- package/tests/instruction-accounts.test.ts +0 -92
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: {
|
|
@@ -33,9 +38,11 @@ interface BondingCurveState {
|
|
|
33
38
|
realSolReserves: bigint;
|
|
34
39
|
tokenTotalSupply: bigint;
|
|
35
40
|
complete: boolean;
|
|
36
|
-
quoteMint?: PublicKey;
|
|
37
41
|
isMayhemMode?: boolean;
|
|
38
42
|
isCashbackCoin?: boolean;
|
|
43
|
+
quoteMint?: PublicKey;
|
|
44
|
+
virtualQuoteReserves?: bigint;
|
|
45
|
+
realQuoteReserves?: bigint;
|
|
39
46
|
}
|
|
40
47
|
interface BondingInfo {
|
|
41
48
|
bonding: PublicKey;
|
|
@@ -85,15 +92,18 @@ interface MetadataInfo {
|
|
|
85
92
|
}
|
|
86
93
|
export declare class PumpTrader {
|
|
87
94
|
private connection;
|
|
88
|
-
private
|
|
95
|
+
private _wallet;
|
|
96
|
+
publicKey: PublicKey;
|
|
89
97
|
private global;
|
|
90
98
|
private globalState;
|
|
91
99
|
private tokenProgramCache;
|
|
92
|
-
constructor(rpc: string,
|
|
100
|
+
constructor(rpc: string, wallet: Wallet);
|
|
101
|
+
private signTx;
|
|
93
102
|
/**
|
|
94
103
|
* 自动检测代币使用的 token program
|
|
95
104
|
*/
|
|
96
105
|
detectTokenProgram(tokenAddr: string): Promise<TokenProgramType>;
|
|
106
|
+
detectQuoteTokenProgram(quoteMint: PublicKey): Promise<PublicKey>;
|
|
97
107
|
/**
|
|
98
108
|
* 检测代币是否在外盘 (AMM)
|
|
99
109
|
*/
|
|
@@ -106,6 +116,9 @@ export declare class PumpTrader {
|
|
|
106
116
|
getBondingPda(mint: PublicKey): PublicKey;
|
|
107
117
|
deriveBondingCurveV2(mint: PublicKey): PublicKey;
|
|
108
118
|
private pickFeeRecipient;
|
|
119
|
+
private pickBuybackFeeRecipient;
|
|
120
|
+
private pickReservedFeeRecipient;
|
|
121
|
+
getSharingConfigPda(mint: PublicKey): PublicKey;
|
|
109
122
|
private buildBondingBuyKeys;
|
|
110
123
|
private buildBondingSellKeys;
|
|
111
124
|
loadBonding(mint: PublicKey): Promise<BondingInfo>;
|
|
@@ -117,9 +130,7 @@ export declare class PumpTrader {
|
|
|
117
130
|
price: number;
|
|
118
131
|
completed: boolean;
|
|
119
132
|
}>;
|
|
120
|
-
getAmmPrice(mint: PublicKey
|
|
121
|
-
private getEffectiveQuoteMint;
|
|
122
|
-
private getMintDecimals;
|
|
133
|
+
getAmmPrice(mint: PublicKey): Promise<number>;
|
|
123
134
|
/**
|
|
124
135
|
* 查询代币余额
|
|
125
136
|
* @param tokenAddr - 代币地址(可选),如果不传则返回所有代币
|
|
@@ -150,17 +161,21 @@ export declare class PumpTrader {
|
|
|
150
161
|
splitIntoN(total: bigint, n: number): bigint[];
|
|
151
162
|
/**
|
|
152
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)
|
|
153
166
|
*/
|
|
154
|
-
autoBuy(tokenAddr: string, totalSolIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
|
|
167
|
+
autoBuy(tokenAddr: string, totalSolIn: bigint, tradeOpt: TradeOptions, useV2?: boolean, quoteMint?: PublicKey): Promise<TradeResult>;
|
|
155
168
|
/**
|
|
156
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)
|
|
157
172
|
*/
|
|
158
|
-
autoSell(tokenAddr: string, totalTokenIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
|
|
173
|
+
autoSell(tokenAddr: string, totalTokenIn: bigint, tradeOpt: TradeOptions, useV2?: boolean, quoteMint?: PublicKey): Promise<TradeResult>;
|
|
159
174
|
buy(tokenAddr: string, totalSolIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
|
|
160
175
|
sell(tokenAddr: string, totalTokenIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
|
|
161
|
-
ammBuy(tokenAddr: string, totalSolIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
|
|
162
|
-
ammSell(tokenAddr: string, totalTokenIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult>;
|
|
163
|
-
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>;
|
|
164
179
|
parseAmmGlobalConfig(data: Buffer, address: PublicKey): {
|
|
165
180
|
address: PublicKey;
|
|
166
181
|
admin: PublicKey;
|
|
@@ -170,10 +185,39 @@ export declare class PumpTrader {
|
|
|
170
185
|
deriveAmmPoolV2(baseMint: PublicKey): PublicKey;
|
|
171
186
|
createAmmBuyInstruction(poolInfo: PoolInfo, userBaseAta: PublicKey, userQuoteAta: PublicKey, baseAmountOut: bigint, maxQuoteAmountIn: bigint, tokenProgramId: PublicKey): TransactionInstruction;
|
|
172
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>;
|
|
173
213
|
confirmTransactionWithPolling(signature: string, lastValidBlockHeight: number, maxAttempts?: number, delayMs?: number): Promise<string>;
|
|
174
214
|
listenTrades(callback: (event: TradeEvent) => void, mintFilter?: PublicKey | null): number;
|
|
175
215
|
fetchMeta(tokenAddr: string): Promise<MetadataInfo | null>;
|
|
176
|
-
|
|
216
|
+
/**
|
|
217
|
+
* 获取原始 wallet 对象(Keypair 或前端 WalletAdapter)
|
|
218
|
+
*/
|
|
219
|
+
getWallet(): Wallet;
|
|
220
|
+
getPublicKey(): PublicKey;
|
|
177
221
|
getConnection(): Connection;
|
|
178
222
|
/**
|
|
179
223
|
* 清除token program缓存
|
|
@@ -184,4 +228,4 @@ export declare class PumpTrader {
|
|
|
184
228
|
*/
|
|
185
229
|
getCachedTokenProgram(tokenAddr: string): TokenProgramType | undefined;
|
|
186
230
|
}
|
|
187
|
-
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, };
|