mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-19 11:11:11 +10:00
Add MIN_POOL_SIZE environment variable and implement pool size check
This commit is contained in:
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