Skip to content

Commit

Permalink
dist
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Abegg committed Jun 19, 2024
1 parent 0a6850b commit 0855477
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/dist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@degenfrends/solana-pumpfun-trader': patch
---

## @degenfrends/solana-pumpfun-trader: Discord fixes
6 changes: 3 additions & 3 deletions dist/index.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;
buy(privateKey: string, tokenAddress: string, amount: number, priorityFee?: number, slippage?: number, isSimulation?: boolean): Promise<string | null | undefined>;
sell(privateKey: string, tokenAddress: string, tokenBalance: number, priorityFee?: number, slippage?: number, isSimulation?: boolean): Promise<void>;
createAndSendTransaction(txBuilder: Transaction, privateKey: string, priorityFee?: number, isSimulation?: boolean): Promise<void>;
createAndSendTransaction(txBuilder: Transaction, privateKey: string, priorityFee?: number, isSimulation?: boolean): Promise<string | null | undefined>;
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<TransactionInstruction | undefined>;
getSellInstruction(privateKey: string, tokenAddress: string, tokenBalance: number, slippage?: number): Promise<TransactionInstruction | undefined>;
}

export { ASSOC_TOKEN_ACC_PROG, FEE_RECIPIENT, GLOBAL, PUMP_FUN_ACCOUNT, PUMP_FUN_PROGRAM, RENT, SYSTEM_PROGRAM_ID, TOKEN_PROGRAM_ID, PumpFunTrader as default };
6 changes: 3 additions & 3 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;
buy(privateKey: string, tokenAddress: string, amount: number, priorityFee?: number, slippage?: number, isSimulation?: boolean): Promise<string | null | undefined>;
sell(privateKey: string, tokenAddress: string, tokenBalance: number, priorityFee?: number, slippage?: number, isSimulation?: boolean): Promise<void>;
createAndSendTransaction(txBuilder: Transaction, privateKey: string, priorityFee?: number, isSimulation?: boolean): Promise<void>;
createAndSendTransaction(txBuilder: Transaction, privateKey: string, priorityFee?: number, isSimulation?: boolean): Promise<string | null | undefined>;
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<TransactionInstruction | undefined>;
getSellInstruction(privateKey: string, tokenAddress: string, tokenBalance: number, slippage?: number): Promise<TransactionInstruction | undefined>;
}

export { ASSOC_TOKEN_ACC_PROG, FEE_RECIPIENT, GLOBAL, PUMP_FUN_ACCOUNT, PUMP_FUN_PROGRAM, RENT, SYSTEM_PROGRAM_ID, TOKEN_PROGRAM_ID, PumpFunTrader as default };
13 changes: 8 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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...");
Expand Down
13 changes: 8 additions & 5 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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...");
Expand Down

0 comments on commit 0855477

Please sign in to comment.