소스 검색

Merge branch 'dockerized'

BoiiButBot 1 년 전
부모
커밋
0b22f1f396
4개의 변경된 파일53개의 추가작업 그리고 4개의 파일을 삭제
  1. 14 0
      .dockerignore
  2. 4 1
      .env.copy
  3. 23 0
      Dockerfile
  4. 12 3
      buy.ts

+ 14 - 0
.dockerignore

@@ -0,0 +1,14 @@
+# Ignore node_modules folder
+node_modules/
+
+# Ignore npm debug log
+npm-debug.log
+
+# Ignore yarn debug log
+yarn-debug.log
+
+# Ignore yarn error log
+yarn-error.log
+
+# Ignore .env file
+.env

+ 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

+ 23 - 0
Dockerfile

@@ -0,0 +1,23 @@
+# Use node.js as base image
+FROM node:latest
+
+# Set the working directory
+WORKDIR /usr/src/app
+
+# Copy package.json and package-lock.json to the working directory
+COPY package*.json ./
+
+# Install the dependencies
+RUN npm install
+
+# Copy the source code to the working directory (except the files in .dockerignore)
+COPY . .
+
+# Copy the .env.copy file to .env
+RUN cp .env.copy .env
+
+# Expose the port
+EXPOSE 3000
+
+# Start the application
+CMD ["npm", "run", "buy"]

+ 12 - 3
buy.ts

@@ -259,9 +259,18 @@ export async function processRaydiumPool(updatedAccountInfo: KeyedAccountInfo) {
     }
 
     await buy(updatedAccountInfo.accountId, accountData);
-    // wait for 5 seconds before selling
-    await new Promise((resolve) => setTimeout(resolve, 5000));
-    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`);
   }