mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2026-06-22 04:11:27 +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
|
AUTO_SELL=true
|
||||||
MAX_SELL_RETRIES=5
|
MAX_SELL_RETRIES=5
|
||||||
AUTO_SELL_DELAY=1000
|
AUTO_SELL_DELAY=1000
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
|
MIN_POOL_SIZE=10
|
||||||
@@ -122,6 +122,9 @@ dist
|
|||||||
# Stores VSCode versions used for testing VSCode extensions
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
.vscode-test
|
.vscode-test
|
||||||
|
|
||||||
|
# PNPM
|
||||||
|
pnpm-lock.yaml
|
||||||
|
|
||||||
# yarn v2
|
# yarn v2
|
||||||
.yarn/cache
|
.yarn/cache
|
||||||
.yarn/unplugged
|
.yarn/unplugged
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import pino from 'pino';
|
|||||||
import bs58 from 'bs58';
|
import bs58 from 'bs58';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import BN from 'bn.js';
|
||||||
|
|
||||||
const transport = pino.transport({
|
const transport = pino.transport({
|
||||||
target: 'pino-pretty',
|
target: 'pino-pretty',
|
||||||
@@ -165,6 +166,28 @@ export async function processRaydiumPool(id: PublicKey, poolState: LiquidityStat
|
|||||||
return;
|
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) {
|
if (CHECK_IF_MINT_IS_RENOUNCED) {
|
||||||
const mintOption = await checkMintable(poolState.baseMint);
|
const mintOption = await checkMintable(poolState.baseMint);
|
||||||
|
|
||||||
@@ -373,6 +396,8 @@ async function sell(accountId: PublicKey, mint: PublicKey, amount: BigNumberish)
|
|||||||
);
|
);
|
||||||
sold = true;
|
sold = true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
// wait for a bit before retrying
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
retries++;
|
retries++;
|
||||||
logger.debug(e);
|
logger.debug(e);
|
||||||
logger.error({ mint }, `Failed to sell token, retry: ${retries}/${MAX_SELL_RETRIES}`);
|
logger.error({ mint }, `Failed to sell token, retry: ${retries}/${MAX_SELL_RETRIES}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user