|
@@ -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}`);
|