-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
157 lines (146 loc) · 6.53 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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Miners.Club Cal by KID</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background: linear-gradient(to right, #141E30, #243B55);
color: white;
}
.container {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 15px;
padding: 20px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);
}
.btn-primary {
background: #ff9800;
border: none;
}
.btn-primary:hover {
background: #e68900;
}
h2 {
font-weight: bold;
}
.form-control, .form-select {
background: rgba(255, 255, 255, 0.2);
border: none;
color: white;
}
.form-control:focus, .form-select:focus {
background: rgba(255, 255, 255, 0.3);
}
p span {
font-weight: bold;
color: #FFD700;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function() {
fetchMbcPrice();
});
async function fetchMbcPrice() {
try {
let response = await fetch("https://api.dexscreener.com/latest/dex/pairs/bsc/0x2d7c6794ef5a5234b26ba620c659c0913f4b0609");
let data = await response.json();
let price = parseFloat(data.pairs[0].priceUsd);
let mbcPriceInput = document.getElementById("mbcPrice");
if (mbcPriceInput) {
mbcPriceInput.value = price.toFixed(4);
}
} catch (error) {
alert("获取MBC价格失败,请手动输入。");
console.error("获取MBC价格失败", error);
}
}
function calculate() {
let mbcPrice = parseFloat(document.getElementById("mbcPrice").value);
let growthFactor = parseFloat(document.getElementById("growthFactor").value);
let stakeAmount = parseFloat(document.getElementById("stakeAmount").value);
let apy = parseFloat(document.getElementById("apy").value) / 100;
const selectElement = document.getElementById("apy");
const selectedOption = selectElement.options[selectElement.selectedIndex];
let days = parseFloat(selectedOption.getAttribute('days'));
if (mbcPrice <= 0 || stakeAmount <= 0) {
alert("请输入有效的MBC价格和质押金额");
return;
}
let expectedMbcPrice = mbcPrice * growthFactor;
let actualStakedTotal = stakeAmount + stakeAmount * mbcPrice;
let dailyProfit = (stakeAmount * apy) / 360;
let dailyProfitMbc = ((expectedMbcPrice - mbcPrice) * stakeAmount) / days;
let totalDailyProfit = dailyProfit + dailyProfitMbc;
let totalannualProfit = totalDailyProfit * 360;
let actualApy = totalannualProfit / stakeAmount;
document.getElementById("expectedMbcPrice").innerText = "$" + expectedMbcPrice.toFixed(4);
document.getElementById("actualStakedTotal").innerText = "$" + actualStakedTotal.toFixed(2);
document.getElementById("dailyProfit").innerText = "$" + totalDailyProfit.toFixed(2);
document.getElementById("annualProfit").innerText = "$" + totalannualProfit.toFixed(2);
document.getElementById("actualApy").innerText = (actualApy * 100).toFixed(2) + "%";
document.getElementById("basicApy").innerText = (apy * 100).toFixed(2) + "%";
console.log(actualApy);
}
</script>
</head>
<body>
<div class="container mt-5 p-4">
<h2 class="text-center">Hashbank收益计算器v1.1</h2>
<div class="mb-3">
<label class="form-label">最新MBC价格U:</label>
<input type="number" id="mbcPrice" class="form-control">
</div>
<div class="mb-3">
<label class="form-label">预期涨幅倍数:</label>
<select id="growthFactor" class="form-select">
<option value="0.5">0.5</option>
<option value="1">1</option>
<option value="1.5">1.5</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5" >5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="50" selected>50</option>
<option value="100">100</option>
</select>
</div>
<div class="mb-3">
<label class="form-label">质押金额U:</label>
<input type="number" id="stakeAmount" class="form-control" value="10000" step="1000" min="1000">
</div>
<div class="mb-3">
<label class="form-label">质押天数:</label>
<select id="apy" class="form-select">
<option value="22" days="30">30天</option>
<option value="30" days="90" >90天</option>
<option value="35" days="180">180天</option>
<option value="40" days="360" >360天</option>
<option value="45" days="720" selected>720天</option>
</select>
<p>APY: <span id="basicApy">0.00%</span></p>
</div>
<button class="btn btn-primary w-100" onclick="calculate()">计算</button>
<div class="mt-4">
<h4 class="text-center">计算结果</h4>
<p>实际APY: <span id="actualApy">0.00%</span></p>
<p>每日综合收益U: <span id="dailyProfit">$0.00</span></p>
<p>年综合收益U: <span id="annualProfit">$0.00</span></p>
<br>
<p>实际质押总额U: <span id="actualStakedTotal">$0.00</span></p>
<p>预期MBC价U: <span id="expectedMbcPrice">$0.0000</span></p>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>