Skip to content

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Abegg committed Jun 19, 2024
1 parent 105ef10 commit af61422
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/fixed.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
20 changes: 8 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export default class PumpFunTrader {
isSimulation: boolean = true
) {
try {
const connection = new Connection(clusterApiUrl('mainnet-beta'), 'confirmed');

const coinData = await getCoinData(mintStr);
if (!coinData) {
console.error('Failed to retrieve coin data...');
Expand All @@ -59,7 +57,7 @@ export default class PumpFunTrader {

const tokenAccountAddress = await getAssociatedTokenAddress(mint, owner, false);

const tokenAccountInfo = await connection.getAccountInfo(tokenAccountAddress);
const tokenAccountInfo = await this.connection.getAccountInfo(tokenAccountAddress);

let tokenAccount: PublicKey;
if (!tokenAccountInfo) {
Expand Down Expand Up @@ -103,12 +101,12 @@ export default class PumpFunTrader {
});
txBuilder.add(instruction);

const transaction = await createTransaction(connection, txBuilder.instructions, payer.publicKey, priorityFeeInSol);
const transaction = await createTransaction(this.connection, txBuilder.instructions, payer.publicKey, priorityFeeInSol);
if (!isSimulation) {
const signature = await sendTransaction(connection, transaction, [payer]);
const signature = await sendTransaction(this.connection, transaction, [payer]);
console.log('Buy transaction confirmed:', signature);
} else if (isSimulation) {
const simulatedResult = await connection.simulateTransaction(transaction);
const simulatedResult = await this.connection.simulateTransaction(transaction);
console.log(simulatedResult);
}
} catch (error) {
Expand All @@ -124,8 +122,6 @@ export default class PumpFunTrader {
isSimulation: boolean = true
) {
try {
const connection = new Connection(clusterApiUrl('mainnet-beta'), 'confirmed');

const coinData = await getCoinData(mintStr);
if (!coinData) {
console.error('Failed to retrieve coin data...');
Expand All @@ -139,7 +135,7 @@ export default class PumpFunTrader {

const tokenAccountAddress = await getAssociatedTokenAddress(mint, owner, false);

const tokenAccountInfo = await connection.getAccountInfo(tokenAccountAddress);
const tokenAccountInfo = await this.connection.getAccountInfo(tokenAccountAddress);

let tokenAccount: PublicKey;
if (!tokenAccountInfo) {
Expand Down Expand Up @@ -177,13 +173,13 @@ export default class PumpFunTrader {
});
txBuilder.add(instruction);

const transaction = await createTransaction(connection, txBuilder.instructions, payer.publicKey, priorityFeeInSol);
const transaction = await createTransaction(this.connection, txBuilder.instructions, payer.publicKey, priorityFeeInSol);

if (!isSimulation) {
const signature = await sendTransaction(connection, transaction, [payer]);
const signature = await sendTransaction(this.connection, transaction, [payer]);
console.log('Sell transaction confirmed:', signature);
} else if (isSimulation) {
const simulatedResult = await connection.simulateTransaction(transaction);
const simulatedResult = await this.connection.simulateTransaction(transaction);
console.log(simulatedResult);
}
} catch (error) {
Expand Down

0 comments on commit af61422

Please sign in to comment.