-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
205 lines (193 loc) Β· 8.26 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OP Chain Profitability Calculator</title>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700;500&display=swap" rel="stylesheet">
<style>
body {
background: linear-gradient(to right, #FF0042, #f1f1f1);
font-family: 'Montserrat', sans-serif;
color: #ffffff;
overflow: hidden; /* Hide overflow to ensure emojis stay within the viewport */
position: relative;
}
.emoji-container { /* Container for emojis */
position: absolute;
width: 100%;
height: 100%;
z-index: -1; /* Place behind the modal */
overflow: hidden;
}
.emoji { /* Styling for individual emojis */
position: absolute;
font-size: 2rem;
opacity: 0;
}
.calculator-container {
width: 80%;
max-width: 600px;
margin: 50px auto;
background: linear-gradient(to right, #E9003C, #e0e0e0);
padding: 20px;
border-radius: 15px;
box-shadow: 0px 0px 30px rgba(201, 87, 87, 0.2); /* Enhanced 3D shadow */
transform: perspective(1000px) translateZ(0); /* 3D effect */
}
.eth-price-container input[type="number"] {
width: 100%;
padding: 5px;
border-radius: 5px;
border: none;
box-shadow: 2px 2px 5px rgba(166, 87, 87, 0.1);
outline: none;
background: transparent;
color: #ffffff;
}
.slider-container input[type="range"] {
-webkit-appearance: none;
width: 100%;
height: 10px;
border-radius: 2.5px;
background: #FF0042;
outline: none;
}
.slider-container input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
border-radius: 50px;
background: #ffffff;
cursor: pointer;
}
.slider-value, label, #ethPriceValue {
color: #ffffff; /* Color set to black */
}
button {
display: block;
width: 100%;
padding: 10px;
margin-top: 20px;
background: #FF0042;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background 0.3s ease;
}
button:hover {
background: #cc0036;
}
#result {
margin-top: 20px;
font-weight: bold;
}
#profitChart {
width: 100%;
height: 300px;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.6.0/chart.min.js"></script>
<script>
function updateSliderValue(sliderId, displayId) {
const value = document.getElementById(sliderId).value;
document.getElementById(displayId).innerText = value.toLocaleString();
}
function drawChart(profitData) {
const ctx = document.getElementById('profitChart').getContext('2d');
const gradient = ctx.createLinearGradient(0, 0, 0, 300);
gradient.addColorStop(0, '#FF0042');
gradient.addColorStop(1, '#f4f4f4');
new Chart(ctx, {
type: 'line',
data: {
labels: profitData.labels,
datasets: [{
label: 'Yearly Dollar Profit',
data: profitData.data,
borderColor: '#FF0042',
backgroundColor: gradient,
borderWidth: 2,
fill: true
}]
},
options: {
scales: {
x: { beginAtZero: true, ticks: { color: '#ffffff' } }, /* X-axis labels color set to black */
y: { beginAtZero: true, ticks: { color: '#ffffff' } } /* Y-axis labels color set to black */
}
}
});
}
function spawnEmojis(isProfitable) {
const emojiContainer = document.querySelector('.emoji-container');
emojiContainer.innerHTML = ''; // Clear existing emojis
// Choose emoji based on profitability
const emoji = isProfitable ? 'π₯³π΄π΅π π£π₯³' : 'ππ΄π';
// Create and animate emojis
for (let i = 0; i < 20; i++) { // Spawn 20 emojis
const emojiElement = document.createElement('div');
emojiElement.className = 'emoji';
emojiElement.innerText = emoji;
emojiElement.style.left = Math.random() * 100 + 'vw'; // Random horizontal position
emojiElement.style.animation = `float ${2 + Math.random() * 3}s linear infinite`; // Random animation duration
emojiElement.style.animationDelay = `-${Math.random() * 3}s`; // Random animation delay
emojiContainer.appendChild(emojiElement);
}
}
function calculateProfit() {
const txnsPerDay = document.getElementById('txnsPerDay').value;
const ethPrice = document.getElementById('ethPrice').value || 0;
const revenuePerTx = 0.00010238 * txnsPerDay;
const costs = (txnsPerDay * 0.00007898) + 1.22;
const profit = revenuePerTx - costs;
const profitShare = profit * 0.7;
const revenueShare = (revenuePerTx * 0.9) - costs;
const monthlyProfit = (profitShare < revenueShare ? profitShare : revenueShare) * 30;
const yearlyProfit = monthlyProfit * 12;
const yearlyDollarProfit = yearlyProfit * ethPrice;
const profitInETH = yearlyDollarProfit / ethPrice;
const isProfitable = yearlyDollarProfit > 0;
const message = yearlyDollarProfit > 0
? `You would be profitable! Yearly Dollar Profit: $${yearlyDollarProfit.toLocaleString(undefined, { minimumFractionDigits: 2 })}, Profit in ETH: ${profitInETH.toLocaleString(undefined, { minimumFractionDigits: 2 })}`
: 'You would not be profitable, consider launching on OP mainnet first and then laddering up to a chain after.';
document.getElementById('result').innerText = message;
const labels = [];
const data = [];
for (let i = 1850; i <= txnsPerDay; i += 5000) {
labels.push(i.toLocaleString());
const revenuePerTxLoop = 0.00010238 * i;
const costsLoop = (i * 0.00007898) + 1.22;
const profitLoop = revenuePerTxLoop - costsLoop;
const profitShareLoop = profitLoop * 0.7;
const revenueShareLoop = (revenuePerTxLoop * 0.9) - costsLoop;
const monthlyProfitLoop = (profitShareLoop < revenueShareLoop ? profitShareLoop : revenueShareLoop) * 30;
const yearlyProfitLoop = monthlyProfitLoop * 12;
const yearlyDollarProfitLoop = yearlyProfitLoop * ethPrice;
data.push(yearlyDollarProfitLoop);
}
drawChart({ labels, data });
}
</script>
</head>
<body>
<div class="calculator-container">
<h1>Should you launch an OPchain? π΄</h1>
<div class="eth-price-container">
<label for="ethPrice">ETH Price (USD): </label>
<input type="number" id="ethPrice" value="1850" min="1000" max="2000000" step="1000">
</div>
<div class="slider-container">
<label for="txnsPerDay">Transactions per Day: </label>
<input type="range" id="txnsPerDay" min="1000" max="2000000" step="100" oninput="updateSliderValue('txnsPerDay', 'txnsPerDayValue')">
<span class="slider-value" id="txnsPerDayValue">1000</span>
</div>
<button onclick="calculateProfit()">Calculate Profit</button>
<p id="result"></p>
<canvas id="profitChart"></canvas>
</div>
</body>
</html>