mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-09 20:12:06 +10:00
Add MIN_POOL_SIZE environment variable and implement pool size check
This commit is contained in:
@ -10,4 +10,5 @@ CHECK_IF_MINT_IS_RENOUNCED=false
|
||||
AUTO_SELL=true
|
||||
MAX_SELL_RETRIES=5
|
||||
AUTO_SELL_DELAY=1000
|
||||
LOG_LEVEL=info
|
||||
LOG_LEVEL=info
|
||||
MIN_POOL_SIZE=10
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -122,6 +122,9 @@ dist
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# PNPM
|
||||
pnpm-lock.yaml
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
|
||||
25
buy.ts
25
buy.ts
@ -34,6 +34,7 @@ import pino from 'pino';
|
||||
import bs58 from 'bs58';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import BN from 'bn.js';
|
||||
|
||||
const transport = pino.transport({
|
||||
target: 'pino-pretty',
|
||||
@ -165,6 +166,28 @@ export async function processRaydiumPool(id: PublicKey, poolState: LiquidityStat
|
||||
return;
|
||||
}
|
||||
|
||||
let poolSize = new BN(poolState.swapQuoteInAmount);
|
||||
|
||||
poolSize = poolSize.div(new BN(10 ** quoteToken.decimals));
|
||||
|
||||
const MIN_POOL_SIZE = new BN(retrieveEnvVariable('MIN_POOL_SIZE', logger));
|
||||
|
||||
logger.info(
|
||||
`Processing pool: ${id.toString()} with ${poolSize.toString()} ${quoteToken.symbol} in liquidity`,
|
||||
);
|
||||
|
||||
if (poolSize.lt(new BN(MIN_POOL_SIZE))) {
|
||||
logger.warn(
|
||||
{
|
||||
mint: poolState.baseMint,
|
||||
pooled: poolSize.toString() + ' ' + quoteToken.symbol,
|
||||
},
|
||||
`Skipping pool, smaller than ${MIN_POOL_SIZE} ${quoteToken.symbol}`,
|
||||
`Swap quote in amount: ${poolSize.toString()}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (CHECK_IF_MINT_IS_RENOUNCED) {
|
||||
const mintOption = await checkMintable(poolState.baseMint);
|
||||
|
||||
@ -373,6 +396,8 @@ async function sell(accountId: PublicKey, mint: PublicKey, amount: BigNumberish)
|
||||
);
|
||||
sold = true;
|
||||
} catch (e: any) {
|
||||
// wait for a bit before retrying
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
retries++;
|
||||
logger.debug(e);
|
||||
logger.error({ mint }, `Failed to sell token, retry: ${retries}/${MAX_SELL_RETRIES}`);
|
||||
|
||||
Reference in New Issue
Block a user