-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
243 lines (207 loc) · 6.88 KB
/
config.ts
File metadata and controls
243 lines (207 loc) · 6.88 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// config.ts - Configuration for Solana Arbitrage Bot with Triangular Scanner
import { Connection } from '@solana/web3.js';
// Configuration interface
export interface ArbConfig {
// Connection settings
rpc: {
heliusRpcUrl: string;
heliusWsUrl: string;
commitment: 'processed' | 'confirmed' | 'finalized';
timeout: number;
};
// Wallet settings
wallet: {
privateKeyPath: string;
gasBuffer: number; // SOL to reserve for gas fees
};
// Arbitrage settings
arbitrage: {
minimumProfitThreshold: number; // Minimum profit percentage to execute trade (e.g. 0.008 = 0.8%)
maxTradeSize: number; // Maximum SOL value to trade
slippageTolerance: number; // Slippage tolerance in percentage (e.g. 0.5 = 0.5%)
routeTimeout: number; // Milliseconds to consider a found route still valid
monitoringInterval: number; // Milliseconds between opportunity scans
maxConcurrentScans: number; // Maximum number of concurrent scans
};
// Token settings
tokens: {
basePairs: string[]; // Base token pairs to use for arbitrage (e.g. WSOL, USDC)
maxTokensToScan: number; // Maximum number of tokens to include in scanning
tokenBlacklist: string[]; // Token addresses to exclude
solMint: string; // SOL mint address
};
// DEX settings
dexes: {
[dex: string]: boolean; // Which DEXes to include
};
// Paper trading settings
paperTrading: {
enabled: boolean;
initialBalance: {
[tokenMint: string]: number;
};
slippageAdjustment: number;
gasFeesSimulation: boolean;
recordDirectory: string;
successRate: number;
latencyMs: number;
reportInterval: number;
};
// Monitoring & alerting
monitoring: {
logLevel: 'debug' | 'info' | 'warn' | 'error';
saveLogsToFile: boolean;
logDirectory: string;
alertOnProfit: boolean;
profitAlertThreshold: number;
alertWebhook?: string;
};
// Performance settings
performance: {
useCache: boolean;
cacheTimeout: number;
maxRouteDepth: number; // Maximum number of hops in a route
};
// Mempool monitoring settings
mempool: {
enabled: boolean;
transactionTypes: string[];
filterByToken: boolean;
targetTokens: string[];
minTransactionValue: number;
};
// Triangular scanner settings
triangleScanner: {
enabled: boolean;
reportDir: string;
tokenCacheTime: number;
requestInterval: number;
maxRoutesPerScan: number;
};
birdeyeApiKey: string;
}
const HELIUS_KEY = process.env.HELIUS_KEY || 'NOT_SET'
const BIRDEYE_KEY = process.env.BIRDEYE_KEY || 'NOT_SET'
// Direct configuration
export const config: ArbConfig = {
birdeyeApiKey: BIRDEYE_KEY,
rpc: {
heliusRpcUrl: 'https://mainnet.helius-rpc.com/?api-key=' + HELIUS_KEY,
heliusWsUrl: 'wss://mainnet.helius-rpc.com/?api-key=' + HELIUS_KEY,
commitment: 'confirmed',
timeout: 30000,
},
wallet: {
privateKeyPath: process.env.PRIVATE_KEY_PATH || './wallet-key.json',
gasBuffer: 0.01, // 0.01 SOL
},
tokenFilter: {
// Only include tokens that have been verified
verifiedOnly: true,
// Minimum liquidity required in USD (estimated)
liquidityThreshold: 10000, // $10K
// Specifically excluded token addresses (even if they pass other filters)
excludedTokens: [
// Add known problematic tokens here
// Add any other tokens causing issues
],
// Tokens to explicitly include, even if they would normally be filtered out
// These are high-volume "pump" tokens or other tokens that might be filtered
includedTokens: [
// Popular meme coins
// Add any other tokens you want to include
],
// Maximum number of tokens to include in scanning
maxTokensToScan: 50
},
arbitrage: {
// The token to use as the source for all arbitrage routes
sourceToken: 'So11111111111111111111111111111111111111112', // SOL
// Minimum profit percentage required to execute (as decimal, e.g., 0.01 = 1%)
minimumProfitThreshold: 0.0005, // 0.05%
// Maximum trade size in SOL (or source token)
maxTradeSize: 100, // 10 SOL
// Time in ms before an opportunity is considered expired
routeTimeout: 10000, // 10 seconds
// How often to scan for opportunities (in milliseconds)
scanIntervalMs: 5000, // 5 seconds
// Whether to scan for more complex 4-hop routes (computationally expensive)
findFourHopRoutes: true,
slippageTolerance: 0.01, // 0.01%
monitoringInterval: parseInt(process.env.MONITORING_INTERVAL || '60000'), // 60 seconds
maxConcurrentScans: 2,
},
tokens: {
basePairs: [
'So11111111111111111111111111111111111111112', // WSOL
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', // USDT
],
maxTokensToScan: 50,
tokenBlacklist: [
// Add any tokens you want to exclude here
],
solMint: 'So11111111111111111111111111111111111111112',
},
dexes: {
jupiterAggregator: true,
raydium: true,
orca: true,
aldrin: false,
crema: true,
meteora: true,
openbook: false,
},
paperTrading: {
enabled: process.env.PAPER_TRADING === 'true' || true,
initialBalance: {
'So11111111111111111111111111111111111111112': 10, // 10 WSOL
},
slippageAdjustment: 0.0001, // 0.01%
gasFeesSimulation: true,
recordDirectory: './paper-trading-records',
successRate: 0.95, // 95% success rate
latencyMs: 300, // 300ms simulated latency
reportInterval: 3600000, // Generate reports hourly
},
monitoring: {
logLevel: (process.env.LOG_LEVEL as any) || 'debug',
saveLogsToFile: true,
logDirectory: './logs',
alertOnProfit: true,
profitAlertThreshold: 0.1, // Alert for profits > 0.1 SOL
alertWebhook: undefined,
},
performance: {
useCache: true,
cacheTimeout: 60000, // 1 minute
maxRouteDepth: 4, // Max 4 hops in a route
},
// Mempool settings
mempool: {
enabled: process.env.MEMPOOL_ENABLED === 'true' || true,
transactionTypes: ['swap', 'liquidity'],
filterByToken: true,
targetTokens: [
'So11111111111111111111111111111111111111112', // WSOL
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', // USDT
],
minTransactionValue: 1000, // Minimum transaction value to monitor (in USD)
},
// Triangular scanner settings
triangleScanner: {
enabled: true, // Enable triangular scanner by default
reportDir: './arbitrage-reports',
tokenCacheTime: 86400000, // 24 hours in milliseconds
requestInterval: 200, // 200ms between requests to avoid rate limits
maxRoutesPerScan: 100, // Maximum routes to scan per iteration
},
};
// Create connection from config
export function createConnection(): Connection {
return new Connection(config.rpc.heliusRpcUrl, {
commitment: config.rpc.commitment,
confirmTransactionInitialTimeout: config.rpc.timeout,
});
}