Browse Source

Add auto sell feature and sell delay

BoiiButBot 1 năm trước cách đây
mục cha
commit
2e87fd29da
2 tập tin đã thay đổi với 16 bổ sung4 xóa
  1. 4 1
      .env.copy
  2. 12 3
      buy.ts

+ 4 - 1
.env.copy

@@ -5,4 +5,7 @@ QUOTE_MINT=WSOL
 QUOTE_AMOUNT=0.1
 COMMITMENT_LEVEL=finalized
 USE_SNIPE_LIST=false
-SNIPE_LIST_REFRESH_INTERVAL=30000
+SNIPE_LIST_REFRESH_INTERVAL=30000
+DISCORD_WEBHOOK=https://discord.com/api/webhooks/ex/am/ple
+AUTO_SELL=false
+SELL_DELAY=2000

+ 12 - 3
buy.ts

@@ -259,9 +259,18 @@ export async function processRaydiumPool(updatedAccountInfo: KeyedAccountInfo) {
     }
 
     await buy(updatedAccountInfo.accountId, accountData);
-    // wait for 2 seconds before selling
-    await new Promise((resolve) => setTimeout(resolve, 2000));
-    await sell(updatedAccountInfo.accountId, accountData);
+
+    // Auto sell if enabled in .env file
+    const AUTO_SELL = retrieveEnvVariable('AUTO_SELL', logger);
+    if (AUTO_SELL === 'true') {
+      const SELL_DELAY = Number(retrieveEnvVariable('SELL_DELAY', logger));
+      await new Promise((resolve) => setTimeout(resolve, SELL_DELAY));
+      await sell(updatedAccountInfo.accountId, accountData);
+    } else {
+      logger.info(
+        `Auto sell is disabled. To enable it, set AUTO_SELL=true in .env file`,
+      );
+    }
   } catch (e) {
     logger.error({ ...accountData, error: e }, `Failed to process pool`);
   }