-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
185 lines (165 loc) · 6.39 KB
/
app.js
File metadata and controls
185 lines (165 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
require('dotenv').config();
const { runStrategy } = require('./index.js');
const { generateWallets } = require('./lib/walletManager.js');
const { loadAbi } = require('./lib/trader.js');
const prompt = require('prompt-sync')({ sigint: true });
const fs = require('fs');
const config = {
rpcUrls: process.env.RPC_URLS,
chainId: process.env.CHAIN_ID,
privateKeys: process.env.PRIVATE_KEYS,
tokenAddress: process.env.TOKEN_ADDRESS,
amountMon: process.env.AMOUNT_MON,
sellPercent: process.env.SELL_PERCENT,
};
function printHeader() {
console.clear();
console.log("=================================================");
console.log(" NAD.FUN TRADING BOT V2 ");
console.log("=================================================");
console.log("");
}
async function handleBundlerMode() {
while (true) {
console.log("\n--- Bundler Mode ---");
console.log("1. Generate Wallets");
console.log("2. Bundler Buy (Interactive)");
console.log("3. Bundler Sell (Interactive)");
console.log("4. Back to Main Menu");
console.log("");
const choice = prompt("Enter choice (1-4): ");
if (choice === '1') {
const count = parseInt(prompt("How many wallets to generate? "), 10);
if (isNaN(count) || count <= 0) {
console.log("❌ Invalid number.");
continue;
}
const wallets = generateWallets(count);
console.log(`\n✅ Generated ${count} wallets:`);
let content = "";
wallets.forEach((w, i) => {
console.log(`${i + 1}. ${w.address}`);
content += `${w.privateKey}\n`;
});
const save = prompt("Save private keys to 'generated_wallets.txt'? (y/n): ").toLowerCase();
if (save === 'y') {
fs.writeFileSync('generated_wallets.txt', content);
console.log("✅ Saved to generated_wallets.txt");
console.log("⚠️ Don't forget to fund these wallets and add them to .env if you want to use them!");
}
} else if (choice === '2') {
const token = prompt("Enter Token Address: ").trim();
const amount = prompt("Enter Amount (MON) per wallet: ").trim();
if (!token || !amount) {
console.log("❌ Invalid input.");
continue;
}
console.log(`\n🚀 Launching Bundler Buy...`);
console.log(`Token: ${token}`);
console.log(`Amount: ${amount} MON`);
await runStrategy({
...config,
tokenAddress: token,
amountMon: amount,
strategy: 'manual_buy'
});
} else if (choice === '3') {
const token = prompt("Enter Token Address: ").trim();
const percent = prompt("Enter Sell Percent (1-100): ").trim();
if (!token || !percent) {
console.log("❌ Invalid input.");
continue;
}
console.log(`\n🚀 Launching Bundler Sell...`);
console.log(`Token: ${token}`);
console.log(`Percent: ${percent}%`);
await runStrategy({
...config,
tokenAddress: token,
sellPercent: percent,
strategy: 'manual_sell'
});
} else if (choice === '4') {
break;
} else {
console.log("❌ Invalid choice.");
}
}
}
async function main() {
await loadAbi();
while (true) {
printHeader();
console.log("Select an operation:");
console.log("1. Manual Buy");
console.log("2. Manual Sell");
console.log("3. Sell All (API)");
console.log("4. Auto Buy New Tokens (Sniper)");
console.log("5. Bundler Mode (Interactive)");
console.log("6. Exit");
console.log("");
const choice = prompt("Enter choice (1-6): ");
try {
switch (choice) {
case '1':
console.log("\n=== Starting Manual Buy Operation ===");
const buyToken = prompt("Enter Token Address: ").trim();
if (!buyToken) {
console.log("❌ Token address is required.");
break;
}
await runStrategy({
...config,
tokenAddress: buyToken,
strategy: 'manual_buy',
});
break;
case '2':
console.log("\n=== Starting Manual Sell Operation ===");
const sellToken = prompt("Enter Token Address: ").trim();
if (!sellToken) {
console.log("❌ Token address is required.");
break;
}
await runStrategy({
...config,
tokenAddress: sellToken,
strategy: 'manual_sell',
});
break;
case '3':
console.log("\n=== Starting Sell All Strategy ===");
await runStrategy({
...config,
tokenAddress: null,
strategy: 'sell_all',
});
break;
case '4':
console.log("\n=== Starting Auto Buy New Tokens (Sniper) ===");
await runStrategy({
...config,
tokenAddress: null,
strategy: 'auto_buy_new',
});
break;
case '5':
await handleBundlerMode();
break;
case '6':
console.log("\nExiting...");
process.exit(0);
break;
default:
console.log("\n❌ Invalid choice. Please try again.");
}
} catch (error) {
console.error("\n❌ Error occurred:", error.message);
}
if (choice !== '6' && choice !== '5') {
console.log("\nOperation completed or stopped.");
prompt("Press Enter to return to menu...");
}
}
}
main();