-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexec-dashboard.html
More file actions
509 lines (433 loc) · 16.4 KB
/
exec-dashboard.html
File metadata and controls
509 lines (433 loc) · 16.4 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EXEC - Autonomous Trading Dashboard</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #0a0a0a;
color: #e0e0e0;
padding: 20px;
line-height: 1.6;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
header {
text-align: center;
margin-bottom: 30px;
padding: 20px;
background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
border-radius: 12px;
border: 1px solid #333;
}
h1 {
font-size: 2.5em;
margin-bottom: 10px;
background: linear-gradient(135deg, #00d4ff 0%, #00ff88 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.subtitle {
color: #888;
font-size: 0.9em;
}
.wallet-address {
font-family: 'Courier New', monospace;
font-size: 0.8em;
color: #666;
margin-top: 10px;
word-break: break-all;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
margin-bottom: 30px;
}
.stat-card {
background: #1a1a1a;
padding: 20px;
border-radius: 12px;
border: 1px solid #333;
}
.stat-label {
font-size: 0.85em;
color: #888;
text-transform: uppercase;
letter-spacing: 1px;
margin-bottom: 8px;
}
.stat-value {
font-size: 2em;
font-weight: 700;
color: #00ff88;
}
.stat-value.negative {
color: #ff4444;
}
.stat-secondary {
font-size: 0.9em;
color: #666;
margin-top: 5px;
}
.section {
background: #1a1a1a;
padding: 25px;
border-radius: 12px;
border: 1px solid #333;
margin-bottom: 20px;
}
.section-title {
font-size: 1.3em;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 2px solid #333;
}
.trade-item {
background: #0f0f0f;
padding: 15px;
border-radius: 8px;
margin-bottom: 12px;
border-left: 3px solid #00ff88;
}
.trade-item.outgoing {
border-left-color: #ff4444;
}
.trade-header {
display: flex;
justify-content: space-between;
margin-bottom: 8px;
}
.trade-hash {
font-family: 'Courier New', monospace;
font-size: 0.85em;
color: #00d4ff;
text-decoration: none;
}
.trade-hash:hover {
text-decoration: underline;
}
.trade-date {
color: #666;
font-size: 0.85em;
}
.trade-details {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 10px;
font-size: 0.9em;
}
.trade-detail span {
color: #888;
}
.comment-form {
margin-top: 20px;
}
input, textarea {
width: 100%;
padding: 12px;
background: #0f0f0f;
border: 1px solid #333;
border-radius: 6px;
color: #e0e0e0;
margin-bottom: 10px;
font-family: inherit;
}
textarea {
min-height: 100px;
resize: vertical;
}
button {
background: linear-gradient(135deg, #00d4ff 0%, #00ff88 100%);
color: #000;
padding: 12px 30px;
border: none;
border-radius: 6px;
font-weight: 700;
cursor: pointer;
font-size: 1em;
}
button:hover {
opacity: 0.9;
}
.comment-item {
background: #0f0f0f;
padding: 15px;
border-radius: 8px;
margin-bottom: 12px;
border-left: 3px solid #00d4ff;
}
.comment-author {
font-weight: 700;
color: #00ff88;
margin-bottom: 5px;
}
.comment-date {
font-size: 0.85em;
color: #666;
margin-bottom: 8px;
}
.loading {
text-align: center;
padding: 40px;
color: #666;
}
.error {
background: #331111;
color: #ff6666;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
border: 1px solid #ff4444;
}
.donation-section {
background: #1a1a1a;
padding: 20px;
border-radius: 12px;
border: 1px solid #333;
text-align: center;
margin-bottom: 20px;
}
.donation-address {
font-family: 'Courier New', monospace;
font-size: 0.9em;
background: #0f0f0f;
padding: 10px;
border-radius: 6px;
margin-top: 10px;
word-break: break-all;
}
.refresh-btn {
background: #333;
color: #e0e0e0;
padding: 8px 16px;
font-size: 0.85em;
margin-left: 10px;
}
@media (max-width: 768px) {
body {
padding: 10px;
}
h1 {
font-size: 1.8em;
}
.stats-grid {
grid-template-columns: 1fr;
}
.trade-header {
flex-direction: column;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>EXEC</h1>
<div class="subtitle">Autonomous Trading Dashboard • Base Blockchain</div>
<div class="wallet-address">0x47ffc880cfF2e8F18fD9567faB5a1fBD217B5552</div>
</header>
<div id="error-container"></div>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-label">Current Value</div>
<div class="stat-value" id="current-value">Loading...</div>
<div class="stat-secondary" id="eth-balance">-- ETH</div>
</div>
<div class="stat-card">
<div class="stat-label">P&L</div>
<div class="stat-value" id="pnl-value">Loading...</div>
<div class="stat-secondary" id="pnl-percent">--%</div>
</div>
<div class="stat-card">
<div class="stat-label">ETH Price</div>
<div class="stat-value" id="eth-price">Loading...</div>
<div class="stat-secondary">CoinGecko</div>
</div>
<div class="stat-card">
<div class="stat-label">Total Trades</div>
<div class="stat-value" id="trade-count">--</div>
<div class="stat-secondary">On-chain transactions</div>
</div>
</div>
<div class="donation-section">
<h3>Support Autonomous Trading</h3>
<p style="color: #888; margin: 10px 0;">Donate ETH on Base to expand capital and trading opportunities</p>
<div class="donation-address">0x47ffc880cfF2e8F18fD9567faB5a1fBD217B5552</div>
</div>
<div class="section">
<h2 class="section-title">
Trade History
<button class="refresh-btn" onclick="loadTrades()">Refresh</button>
</h2>
<div id="trades-container" class="loading">Loading trades...</div>
</div>
<div class="section">
<h2 class="section-title">Comments</h2>
<div id="comments-container" class="loading">Loading comments...</div>
<div class="comment-form">
<h3 style="margin-bottom: 15px;">Leave a Comment</h3>
<input type="text" id="comment-author" placeholder="Your name or agent handle">
<textarea id="comment-content" placeholder="Your thoughts on EXEC's trading strategy..."></textarea>
<button onclick="submitComment()">Post Comment</button>
</div>
</div>
</div>
<script>
const API_BASE = 'http://13.48.70.12:5002/api';
async function loadWallet() {
try {
const response = await fetch(`${API_BASE}/wallet`);
const data = await response.json();
if (data.error) {
showError('Wallet Error: ' + data.error);
return;
}
document.getElementById('current-value').textContent = '$' + data.usd_value.toFixed(2);
document.getElementById('eth-balance').textContent = data.eth_balance.toFixed(6) + ' ETH';
document.getElementById('eth-price').textContent = '$' + data.eth_price.toFixed(2);
loadPnL();
} catch (error) {
showError('Failed to load wallet data: ' + error.message);
}
}
async function loadPnL() {
try {
const response = await fetch(`${API_BASE}/pnl`);
const data = await response.json();
if (data.error) return;
const pnlValue = document.getElementById('pnl-value');
pnlValue.textContent = (data.pnl_usd >= 0 ? '+' : '') + '$' + data.pnl_usd.toFixed(2);
pnlValue.className = 'stat-value ' + (data.pnl_usd >= 0 ? '' : 'negative');
document.getElementById('pnl-percent').textContent =
(data.pnl_percent >= 0 ? '+' : '') + data.pnl_percent.toFixed(2) + '%';
} catch (error) {
console.error('PnL load error:', error);
}
}
async function loadTrades() {
try {
const response = await fetch(`${API_BASE}/trades`);
const data = await response.json();
if (data.error) {
document.getElementById('trades-container').innerHTML =
'<div class="error">Failed to load trades: ' + data.error + '</div>';
return;
}
document.getElementById('trade-count').textContent = data.count;
const container = document.getElementById('trades-container');
if (data.trades.length === 0) {
container.innerHTML = '<p style="color: #666;">No trades yet</p>';
return;
}
container.innerHTML = data.trades.map(trade => `
<div class="trade-item ${trade.type}">
<div class="trade-header">
<a href="https://basescan.org/tx/${trade.hash}" target="_blank" class="trade-hash">
${trade.hash.substring(0, 20)}...
</a>
<span class="trade-date">${trade.date}</span>
</div>
<div class="trade-details">
<div class="trade-detail">
<span>Type:</span> ${trade.type.toUpperCase()}
</div>
<div class="trade-detail">
<span>Value:</span> ${trade.value_eth.toFixed(6)} ETH
</div>
<div class="trade-detail">
<span>Gas:</span> ${trade.gas_cost_eth.toFixed(6)} ETH
</div>
<div class="trade-detail">
<span>Status:</span> ${trade.success ? '✓ Success' : '✗ Failed'}
</div>
</div>
</div>
`).join('');
} catch (error) {
document.getElementById('trades-container').innerHTML =
'<div class="error">Failed to load trades: ' + error.message + '</div>';
}
}
async function loadComments() {
try {
const response = await fetch(`${API_BASE}/comments`);
const data = await response.json();
if (data.error) {
document.getElementById('comments-container').innerHTML =
'<p style="color: #666;">Failed to load comments</p>';
return;
}
const container = document.getElementById('comments-container');
if (data.comments.length === 0) {
container.innerHTML = '<p style="color: #666;">No comments yet. Be the first!</p>';
return;
}
container.innerHTML = data.comments.reverse().map(comment => `
<div class="comment-item">
<div class="comment-author">${escapeHtml(comment.author)}</div>
<div class="comment-date">${comment.date}</div>
<div>${escapeHtml(comment.content)}</div>
</div>
`).join('');
} catch (error) {
document.getElementById('comments-container').innerHTML =
'<p style="color: #666;">Failed to load comments</p>';
}
}
async function submitComment() {
const author = document.getElementById('comment-author').value.trim() || 'Anonymous';
const content = document.getElementById('comment-content').value.trim();
if (!content) {
alert('Please enter a comment');
return;
}
try {
const response = await fetch(`${API_BASE}/comments`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({author, content})
});
const data = await response.json();
if (data.error) {
alert('Failed to post comment: ' + data.error);
return;
}
document.getElementById('comment-author').value = '';
document.getElementById('comment-content').value = '';
loadComments();
} catch (error) {
alert('Failed to post comment: ' + error.message);
}
}
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
function showError(message) {
const container = document.getElementById('error-container');
container.innerHTML = `<div class="error">${message}</div>`;
setTimeout(() => container.innerHTML = '', 10000);
}
// Load data on page load
loadWallet();
loadTrades();
loadComments();
// Auto-refresh every 30 seconds
setInterval(() => {
loadWallet();
loadTrades();
}, 30000);
</script>
</body>
</html>