forked from BETAIL-BOYS/TradeFlow-Web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-high-slippage.html
More file actions
242 lines (224 loc) · 11 KB
/
test-high-slippage.html
File metadata and controls
242 lines (224 loc) · 11 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>High Slippage Warning Test</title>
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
background: #1e293b;
font-family: system-ui, -apple-system, sans-serif;
}
</style>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const { useState } = React;
function HighSlippageWarning({ isOpen, onClose, onConfirm, priceImpact }) {
const [confirmText, setConfirmText] = useState("");
const isConfirmEnabled = confirmText === "CONFIRM";
if (!isOpen) return null;
const handleConfirm = () => {
if (isConfirmEnabled) {
onConfirm();
onClose();
setConfirmText("");
}
};
const handleClose = () => {
onClose();
setConfirmText("");
};
return React.createElement('div', {
className: "fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4"
}, [
React.createElement('div', {
key: 'modal',
className: "bg-slate-800 rounded-2xl border border-slate-700 p-6 max-w-md w-full"
}, [
// Header
React.createElement('div', {
key: 'header',
className: "flex justify-between items-center mb-6"
}, [
React.createElement('h2', {
key: 'title',
className: "text-xl font-semibold text-white"
}, "High Price Impact Warning"),
React.createElement('button', {
key: 'close',
onClick: handleClose,
className: "text-slate-400 hover:text-white transition-colors"
}, React.createElement('svg', {
className: "w-6 h-6",
fill: "none",
stroke: "currentColor",
viewBox: "0 0 24 24"
}, React.createElement('path', {
strokeLinecap: "round",
strokeLinejoin: "round",
strokeWidth: 2,
d: "M6 18L18 6M6 6l12 12"
})))
]),
// Warning Icon
React.createElement('div', {
key: 'icon',
className: "flex justify-center mb-6"
}, React.createElement('div', {
className: "w-16 h-16 bg-red-500/20 rounded-full flex items-center justify-center"
}, React.createElement('svg', {
className: "w-8 h-8 text-red-500",
fill: "none",
stroke: "currentColor",
viewBox: "0 0 24 24"
}, React.createElement('path', {
strokeLinecap: "round",
strokeLinejoin: "round",
strokeWidth: 2,
d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
})))),
// Warning Message
React.createElement('div', {
key: 'message',
className: "text-center mb-6"
}, [
React.createElement('p', {
key: 'warning',
className: "text-red-500 font-bold text-lg mb-2"
}, "High Price Impact. You will lose a significant portion of your funds."),
React.createElement('p', {
key: 'impact',
className: "text-slate-300"
}, `This trade has a price impact of ${priceImpact.toFixed(2)}%`),
React.createElement('p', {
key: 'explanation',
className: "text-slate-400 text-sm mt-2"
}, "This means you'll receive significantly less than expected due to low liquidity.")
]),
// Confirmation Input
React.createElement('div', {
key: 'input',
className: "mb-6"
}, [
React.createElement('label', {
key: 'label',
className: "block text-sm text-slate-400 mb-2"
}, 'Type "CONFIRM" to proceed with this risky trade:'),
React.createElement('input', {
key: 'textfield',
type: "text",
value: confirmText,
onChange: (e) => setConfirmText(e.target.value),
placeholder: "CONFIRM",
className: "w-full bg-slate-700 border border-slate-600 rounded-lg px-4 py-2 text-white placeholder-slate-400 focus:outline-none focus:border-red-500"
})
]),
// Action Buttons
React.createElement('div', {
key: 'buttons',
className: "flex gap-3"
}, [
React.createElement('button', {
key: 'cancel',
onClick: handleClose,
className: "flex-1 bg-slate-700 hover:bg-slate-600 text-white font-medium rounded-lg transition-colors py-2"
}, "Cancel"),
React.createElement('button', {
key: 'confirm',
onClick: handleConfirm,
disabled: !isConfirmEnabled,
className: `flex-1 font-medium rounded-lg transition-colors py-2 ${
isConfirmEnabled
? "bg-red-600 hover:bg-red-700 text-white"
: "bg-slate-700 text-slate-400 cursor-not-allowed"
}`
}, "Swap Anyway")
]),
// Additional Warning
React.createElement('div', {
key: 'additional-warning',
className: "mt-4 p-3 bg-red-500/10 border border-red-500/20 rounded-lg"
}, React.createElement('p', {
className: "text-xs text-red-400 text-center"
}, "⚠️ This action cannot be undone. You are trading at a significant disadvantage."))
])
]);
}
function TestApp() {
const [isModalOpen, setIsModalOpen] = useState(false);
const [testPriceImpact, setTestPriceImpact] = useState(7.5);
return React.createElement('div', {
className: "min-h-screen flex items-center justify-center p-8"
}, [
React.createElement('div', {
key: 'test-container',
className: "bg-slate-800 rounded-2xl border border-slate-700 p-8 max-w-md w-full"
}, [
React.createElement('h1', {
key: 'title',
className: "text-2xl font-bold text-white mb-6 text-center"
}, "High Slippage Warning Test"),
React.createElement('div', {
key: 'controls',
className: "space-y-4 mb-6"
}, [
React.createElement('div', {
key: 'price-impact-control',
className: "space-y-2"
}, [
React.createElement('label', {
key: 'label',
className: "block text-sm text-slate-400"
}, `Price Impact: ${testPriceImpact.toFixed(2)}%`),
React.createElement('input', {
key: 'slider',
type: "range",
min: "0",
max: "15",
step: "0.5",
value: testPriceImpact,
onChange: (e) => setTestPriceImpact(parseFloat(e.target.value)),
className: "w-full"
})
]),
React.createElement('button', {
key: 'trigger-btn',
onClick: () => setIsModalOpen(true),
className: "w-full bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors py-3"
}, "Trigger High Slippage Warning")
]),
React.createElement('div', {
key: 'info',
className: "p-4 bg-slate-900/50 rounded-lg"
}, [
React.createElement('h3', {
key: 'info-title',
className: "text-white font-medium mb-2"
}, "Test Results:"),
React.createElement('p', {
key: 'info-text',
className: "text-sm text-slate-400"
}, testPriceImpact > 5
? "✅ Modal will trigger (price impact > 5%)"
: "❌ Modal will not trigger (price impact ≤ 5%)")
])
]),
React.createElement(HighSlippageWarning, {
key: 'modal',
isOpen: isModalOpen,
onClose: () => setIsModalOpen(false),
onConfirm: () => alert("High slippage trade confirmed!"),
priceImpact: testPriceImpact
})
]);
}
ReactDOM.render(React.createElement(TestApp), document.getElementById('root'));
</script>
</body>
</html>