diff --git a/.changeset/dist.md b/.changeset/dist.md new file mode 100644 index 0000000..4e0ecc1 --- /dev/null +++ b/.changeset/dist.md @@ -0,0 +1,5 @@ +--- +'@degenfrends/solana-pumpfun-trader': patch +--- + +## @degenfrends/solana-pumpfun-trader: Discord fixes diff --git a/dist/index.d.mts b/dist/index.d.mts index 9476f76..2bc0c21 100644 --- a/dist/index.d.mts +++ b/dist/index.d.mts @@ -14,14 +14,14 @@ declare class PumpFunTrader { constructor(solanaRpcUrl?: string, logger?: any); setSolanaRpcUrl(solanaRpcUrl: string): this; setLogger(logger: any): this; - buy(privateKey: string, tokenAddress: string, amount: number, priorityFee?: number, slippage?: number, isSimulation?: boolean): Promise; + buy(privateKey: string, tokenAddress: string, amount: number, priorityFee?: number, slippage?: number, isSimulation?: boolean): Promise; sell(privateKey: string, tokenAddress: string, tokenBalance: number, priorityFee?: number, slippage?: number, isSimulation?: boolean): Promise; - createAndSendTransaction(txBuilder: Transaction, privateKey: string, priorityFee?: number, isSimulation?: boolean): Promise; + createAndSendTransaction(txBuilder: Transaction, privateKey: string, priorityFee?: number, isSimulation?: boolean): Promise; getBuyInstruction(privateKey: string, tokenAddress: string, amount: number, slippage: number | undefined, txBuilder: Transaction): Promise<{ instruction: TransactionInstruction; tokenAmount: number; } | undefined>; - getSellInstruction(privateKey: string, tokenAddress: string, tokenBalance: number, priorityFee?: number, slippage?: number): Promise; + getSellInstruction(privateKey: string, tokenAddress: string, tokenBalance: number, slippage?: number): Promise; } export { ASSOC_TOKEN_ACC_PROG, FEE_RECIPIENT, GLOBAL, PUMP_FUN_ACCOUNT, PUMP_FUN_PROGRAM, RENT, SYSTEM_PROGRAM_ID, TOKEN_PROGRAM_ID, PumpFunTrader as default }; diff --git a/dist/index.d.ts b/dist/index.d.ts index 9476f76..2bc0c21 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -14,14 +14,14 @@ declare class PumpFunTrader { constructor(solanaRpcUrl?: string, logger?: any); setSolanaRpcUrl(solanaRpcUrl: string): this; setLogger(logger: any): this; - buy(privateKey: string, tokenAddress: string, amount: number, priorityFee?: number, slippage?: number, isSimulation?: boolean): Promise; + buy(privateKey: string, tokenAddress: string, amount: number, priorityFee?: number, slippage?: number, isSimulation?: boolean): Promise; sell(privateKey: string, tokenAddress: string, tokenBalance: number, priorityFee?: number, slippage?: number, isSimulation?: boolean): Promise; - createAndSendTransaction(txBuilder: Transaction, privateKey: string, priorityFee?: number, isSimulation?: boolean): Promise; + createAndSendTransaction(txBuilder: Transaction, privateKey: string, priorityFee?: number, isSimulation?: boolean): Promise; getBuyInstruction(privateKey: string, tokenAddress: string, amount: number, slippage: number | undefined, txBuilder: Transaction): Promise<{ instruction: TransactionInstruction; tokenAmount: number; } | undefined>; - getSellInstruction(privateKey: string, tokenAddress: string, tokenBalance: number, priorityFee?: number, slippage?: number): Promise; + getSellInstruction(privateKey: string, tokenAddress: string, tokenBalance: number, slippage?: number): Promise; } export { ASSOC_TOKEN_ACC_PROG, FEE_RECIPIENT, GLOBAL, PUMP_FUN_ACCOUNT, PUMP_FUN_PROGRAM, RENT, SYSTEM_PROGRAM_ID, TOKEN_PROGRAM_ID, PumpFunTrader as default }; diff --git a/dist/index.js b/dist/index.js index 174db16..36b4187 100644 --- a/dist/index.js +++ b/dist/index.js @@ -166,22 +166,24 @@ var PumpFunTrader = class { return; } txBuilder.add(instruction.instruction); - await this.createAndSendTransaction(txBuilder, privateKey, priorityFee, isSimulation); + const signature = await this.createAndSendTransaction(txBuilder, privateKey, priorityFee, isSimulation); + this.logger.log("Sell transaction confirmed:", signature); + return signature; } catch (error) { this.logger.log(error); } } async sell(privateKey, tokenAddress, tokenBalance, priorityFee = 0, slippage = 0.25, isSimulation = true) { try { - const instruction = await this.getSellInstruction(privateKey, tokenAddress, tokenBalance, priorityFee, slippage); + const instruction = await this.getSellInstruction(privateKey, tokenAddress, tokenBalance, slippage); const txBuilder = new import_web34.Transaction(); if (!instruction) { this.logger.error("Failed to retrieve sell instruction..."); return; } txBuilder.add(instruction); - const payer = await getKeyPairFromPrivateKey(privateKey); - await this.createAndSendTransaction(txBuilder, privateKey, priorityFee, isSimulation); + const signature = await this.createAndSendTransaction(txBuilder, privateKey, priorityFee, isSimulation); + this.logger.log("Sell transaction confirmed:", signature); } catch (error) { this.logger.log(error); } @@ -194,6 +196,7 @@ var PumpFunTrader = class { walletPrivateKey ]); this.logger.log("Buy transaction confirmed:", signature); + return signature; } else if (isSimulation == true) { const simulatedResult = await this.connection.simulateTransaction(transaction); this.logger.log(simulatedResult); @@ -302,7 +305,7 @@ var PumpFunTrader = class { tokenAmount: tokenOut }; } - async getSellInstruction(privateKey, tokenAddress, tokenBalance, priorityFee = 0, slippage = 0.25) { + async getSellInstruction(privateKey, tokenAddress, tokenBalance, slippage = 0.25) { const coinData = await getCoinData(tokenAddress); if (!coinData) { this.logger.error("Failed to retrieve coin data..."); diff --git a/dist/index.mjs b/dist/index.mjs index 757e4b6..ea80538 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -126,22 +126,24 @@ var PumpFunTrader = class { return; } txBuilder.add(instruction.instruction); - await this.createAndSendTransaction(txBuilder, privateKey, priorityFee, isSimulation); + const signature = await this.createAndSendTransaction(txBuilder, privateKey, priorityFee, isSimulation); + this.logger.log("Sell transaction confirmed:", signature); + return signature; } catch (error) { this.logger.log(error); } } async sell(privateKey, tokenAddress, tokenBalance, priorityFee = 0, slippage = 0.25, isSimulation = true) { try { - const instruction = await this.getSellInstruction(privateKey, tokenAddress, tokenBalance, priorityFee, slippage); + const instruction = await this.getSellInstruction(privateKey, tokenAddress, tokenBalance, slippage); const txBuilder = new Transaction2(); if (!instruction) { this.logger.error("Failed to retrieve sell instruction..."); return; } txBuilder.add(instruction); - const payer = await getKeyPairFromPrivateKey(privateKey); - await this.createAndSendTransaction(txBuilder, privateKey, priorityFee, isSimulation); + const signature = await this.createAndSendTransaction(txBuilder, privateKey, priorityFee, isSimulation); + this.logger.log("Sell transaction confirmed:", signature); } catch (error) { this.logger.log(error); } @@ -154,6 +156,7 @@ var PumpFunTrader = class { walletPrivateKey ]); this.logger.log("Buy transaction confirmed:", signature); + return signature; } else if (isSimulation == true) { const simulatedResult = await this.connection.simulateTransaction(transaction); this.logger.log(simulatedResult); @@ -262,7 +265,7 @@ var PumpFunTrader = class { tokenAmount: tokenOut }; } - async getSellInstruction(privateKey, tokenAddress, tokenBalance, priorityFee = 0, slippage = 0.25) { + async getSellInstruction(privateKey, tokenAddress, tokenBalance, slippage = 0.25) { const coinData = await getCoinData(tokenAddress); if (!coinData) { this.logger.error("Failed to retrieve coin data...");