mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-09 20:12:06 +10:00
Remove pnpm
Remove work script command Reuse poolkeys for sell
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@ -130,4 +130,8 @@ dist
|
|||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
|
|
||||||
.idea
|
.idea
|
||||||
|
TODO
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm-lock.yaml
|
||||||
20
buy.ts
20
buy.ts
@ -210,7 +210,8 @@ export async function processRaydiumPool(
|
|||||||
const timeout = parseInt(SELL_DELAY, 10);
|
const timeout = parseInt(SELL_DELAY, 10);
|
||||||
await new Promise((resolve) => setTimeout(resolve, timeout));
|
await new Promise((resolve) => setTimeout(resolve, timeout));
|
||||||
|
|
||||||
await sell(id, poolState);
|
let poolKeys = existingTokenAccounts.get(poolState.baseMint.toString())!.poolKeys;
|
||||||
|
await sell(id, poolState, poolKeys as LiquidityPoolKeys);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error({ ...poolState, error: e }, `Failed to process pool`);
|
logger.error({ ...poolState, error: e }, `Failed to process pool`);
|
||||||
@ -312,6 +313,7 @@ const maxRetries = 60;
|
|||||||
async function sell(
|
async function sell(
|
||||||
accountId: PublicKey,
|
accountId: PublicKey,
|
||||||
accountData: LiquidityStateV4,
|
accountData: LiquidityStateV4,
|
||||||
|
poolKeys: LiquidityPoolKeys,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const tokenAccount = existingTokenAccounts.get(
|
const tokenAccount = existingTokenAccounts.get(
|
||||||
accountData.baseMint.toString(),
|
accountData.baseMint.toString(),
|
||||||
@ -328,14 +330,9 @@ async function sell(
|
|||||||
if (balanceResponse !== null && Number(balanceResponse) > 0 && !balanceFound) {
|
if (balanceResponse !== null && Number(balanceResponse) > 0 && !balanceFound) {
|
||||||
balanceFound = true;
|
balanceFound = true;
|
||||||
|
|
||||||
tokenAccount.poolKeys = createPoolKeys(
|
|
||||||
accountId,
|
|
||||||
accountData,
|
|
||||||
tokenAccount.market!,
|
|
||||||
);
|
|
||||||
const { innerTransaction, address } = Liquidity.makeSwapFixedInInstruction(
|
const { innerTransaction, address } = Liquidity.makeSwapFixedInInstruction(
|
||||||
{
|
{
|
||||||
poolKeys: tokenAccount.poolKeys,
|
poolKeys: poolKeys,
|
||||||
userKeys: {
|
userKeys: {
|
||||||
tokenAccountIn: tokenAccount.address,
|
tokenAccountIn: tokenAccount.address,
|
||||||
tokenAccountOut: quoteTokenAssociatedAddress,
|
tokenAccountOut: quoteTokenAssociatedAddress,
|
||||||
@ -344,7 +341,7 @@ async function sell(
|
|||||||
amountIn: new BN(balanceResponse),
|
amountIn: new BN(balanceResponse),
|
||||||
minAmountOut: 0,
|
minAmountOut: 0,
|
||||||
},
|
},
|
||||||
tokenAccount.poolKeys.version,
|
poolKeys.version,
|
||||||
);
|
);
|
||||||
|
|
||||||
const latestBlockhash = await solanaConnection.getLatestBlockhash({
|
const latestBlockhash = await solanaConnection.getLatestBlockhash({
|
||||||
@ -356,12 +353,6 @@ async function sell(
|
|||||||
instructions: [
|
instructions: [
|
||||||
ComputeBudgetProgram.setComputeUnitLimit({ units: 400000 }),
|
ComputeBudgetProgram.setComputeUnitLimit({ units: 400000 }),
|
||||||
ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 200000 }),
|
ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 200000 }),
|
||||||
createAssociatedTokenAccountIdempotentInstruction(
|
|
||||||
wallet.publicKey,
|
|
||||||
tokenAccount.address,
|
|
||||||
wallet.publicKey,
|
|
||||||
accountData.baseMint,
|
|
||||||
),
|
|
||||||
...innerTransaction.instructions,
|
...innerTransaction.instructions,
|
||||||
],
|
],
|
||||||
}).compileToV0Message();
|
}).compileToV0Message();
|
||||||
@ -384,6 +375,7 @@ async function sell(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// logger.error(`Error while selling: ${error}`);
|
||||||
}
|
}
|
||||||
retries++;
|
retries++;
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
|
|||||||
@ -2,8 +2,7 @@
|
|||||||
"name": "solana-sniper-bot",
|
"name": "solana-sniper-bot",
|
||||||
"author": "Filip Dundjer",
|
"author": "Filip Dundjer",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"buy": "ts-node buy.ts",
|
"buy": "ts-node buy.ts"
|
||||||
"work": "ts-node worker/watcher.ts"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@raydium-io/raydium-sdk": "^1.3.1-beta.47",
|
"@raydium-io/raydium-sdk": "^1.3.1-beta.47",
|
||||||
|
|||||||
Reference in New Issue
Block a user