-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
228 lines (226 loc) · 19.8 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<html><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><title>TESTNET GeneChain Staking</title><link rel=icon href=https://genechain.io/favicon.svg><link rel=icon type=image/png sizes=16x16 href=https://genechain.io/favicon-16x16.png><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css integrity=sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l crossorigin=anonymous><script async src="https://www.googletagmanager.com/gtag/js?id=G-GQ6XKN71SZ"></script><script>window.dataLayer = window.dataLayer || []
function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date())
gtag('config', 'G-GQ6XKN71SZ')</script></head><body><main class=container-fluid><div class="row justify-content-center"><h1 class="col-sm-6 col-lg-8 text-center">GeneChain Staking - <span id=network></span></h1><div class="col-sm-6 col-lg-4 col-xl-3 order-xl-9"><div class="card mb-2"><div class=card-header>Current Account</div><div class=card-body><button class="btn btn-primary btn-lg btn-block" id=connectButton hidden>Click here to connect your wallet</button> <button class="btn btn-primary btn-lg btn-block" id=installButton hidden>Click here to install MetaMask</button><div id=accountDetail hidden><p><strong>Address:</strong><br><samp id=address class=small>-</samp></p><hr><p><strong>Balance:</strong><br><span class=small><samp class=text-muted>- RNA: </samp><samp id=balance>-</samp><br><samp class=text-muted>- ARM: </samp><samp id=balanceARM>-</samp><br><button id=exchangeARM class="btn btn-outline-primary btn-sm">VBC⇋ARM</button><br></span></p><hr><p><strong>Settled Profit:</strong><br><span class=small><samp id=profit>-</samp><samp class="small text-muted">RNA</samp><br><button class="btn btn-sm btn-outline-primary" id=withdrawProfit title="Click here to withdraw your profit" hidden>Withdraw</button> <button class="btn btn-sm btn-outline-primary" id=settleAll title="Click here to settle all your unsettled rewards">Settle All Unsettled Rewards</button><br><small class=text-muted>- This is your settled profit. Unsettled rewards can be found in</small> <span class="badge badge-secondary">Staked Candidates</span><br><small class=text-muted>- Unsettled reward will go into your settled profit only after you settle it.</small><br></span></p></div></div></div><div id=toastHolder></div></div><div class=col-xl-9><section id=stakedCandidates hidden><h2>Staked Candidates</h2><div class=table-responsive-md><table class="table table-striped"><thead class=thead-light><tr><th scope=col>#</th><th scope=col>Address</th><th scope=col>Is Active Validator</th><th scope=col>Unsettled Reward</th><th scope=col>Staked</th><th scope=col>Estimate Reward</th><th scope=col>Action</th></tr></thead><tbody></tbody></table></div><div class=spinner-border role=status><span class=sr-only>Loading...</span></div></section><section id=topCandidates><h2>Top Candidates</h2><div class=table-responsive-md><table class="table table-striped"><thead class=thead-light><tr><th scope=col>#</th><th scope=col>Address</th><th scope=col>Is Active Validator</th><th scope=col>Staking Power</th><th scope=col>Total Staked</th><th scope=col>APY</th><th scope=col>Action</th></tr></thead><tbody></tbody></table></div><div class=spinner-border role=status hidden><span class=sr-only>Loading...</span></div></section></div></div></main><div class="modal fade" id=wrongNetwork data-backdrop=static data-keyboard=false tabindex=-1><div class=modal-dialog><div class=modal-content><div class=modal-header><h5 class=modal-title>Not on GeneChain Adenine testnet</h5></div><div class=modal-body><p>Please change your network to GeneChain Adenine testnet in metamask.</p><p>If this is your first time using GeneChain, please click the button bellow to setup GeneChain Adenine testnet for metamask.</p></div><div class=modal-footer><button id=addNetwork type=button class="btn btn-outline-primary">Add GeneChain Adenine testnet</button></div></div></div></div><script type=text/template id=modal-template><div class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content"> <% if (title) {%> <div class="modal-header <%=titleClasses%>">
<h5 class="modal-title"><%=title%></h5> <% if (closeButton) { %> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button> <%}%> </div> <%}%> <div class="modal-body <%=bodyClasses%>"><%=message%></div> <% if (buttons||closeButton) { %> <div class="modal-footer <%=footClasses%>"> <% if (buttons) { for (button of buttons){%> <button type="button" id="<%=button.id%>" class="btn <%=button.classNames%>"><%=button.text%></button> <%} if (closeButton){%> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> <%}}else if (closeButton){%> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <%}%> </div> <%}%> </div>
</div>
</div></script><script type=text/template id=modal-alert-template> <%if (message) { print("<p>",message,"</p>") } if (error) {%> <div class='alert alert-danger small'><samp class="text-break">
Code: <%=error.code%><br/>
Message: <%=error.message%><br/> <%if(error.details){%> Data: <%=error.details%> <%}%> </samp></div> <%}%> </script><script type=text/template id=toast-template><div class="toast" data-delay="3000" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header <%=titleClasses%>">
<strong class="mr-auto"><%=title%></strong>
<small><%=decor%></small> <% if (closeButton) { %> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button> <%}%> </div>
<div class="toast-body"><%=message%></div>
</div></script><script type=text/template id=candidate-template><td><%= id %></td>
<td class="text-break">
<samp><%= validator %></samp>
</td>
<td>
<span class="<% if (active) print('text-success'); else print('text-muted')%>"> <% if (active) print('Yes'); else print('No')%> </span>
</td>
<td class="text-break"><samp><%= stakePower==0?'-':formatEther(stakePower) %></samp></td>
<td> <%= ready?stakeRNA:'-' %><small class="text-muted">RNA</small><br/> <%= ready?stakeARM:'-' %><small class="text-muted">ARM</small>
</td>
<td> <% if (apy>0) { %> <%= apy.toFixed(2) %>%
<button class="btn btn-link btn-sm p-0" data-toggle="popover" title="Details" data-html="true" data-content='<code class="small">APY = Estimate daily reward * 365 / Total staked RNA</code><hr/>Estimate daily reward: <%= rewardPerDay.toFixed(2) %><small class="text-muted">RNA</small><br/>Total staked RNA: <%=stakeRNA%><small class="text-muted">RNA</small>'>More info</button> <% if (!active) { %> <br/><small class="text-muted">Estimate APY If active</small> <%}%> <% } else print('-') %> </td>
<td> <%if(ready){%> <div class="btn-group" role="group">
<button class="btn btn-outline-primary btn-sm" id="stake">Stake</button>
<button class="btn btn-outline-primary btn-sm" id="unstake">Unstake</button>
</div> <%}else{%> <div class="spinner-border spinner-border-sm text-secondary" role="status">
<span class="sr-only">Loading...</span>
</div> <%}%> </td></script><script type=text/template id=staked-template><td><%= id %></td>
<td class="text-break">
<samp><%= validator %></samp>
</td>
<td>
<span class="<% if (active) print('text-success'); else print('text-muted')%>"> <% print(active?'Yes':'No') %> </span>
</td>
<td class="text-break"> <%= ready?profit:'-' %> <% if (ready&&profit!=0) { %> <br/><button class="btn btn-sm btn-outline-primary" id="settle" data-toggle="tooltip" title="Click here to settle profit">Settle</button> <%}%> </td>
<td> <%= ready?stakedRNA:'-' %><small class="text-muted">RNA</small><br/> <%= ready?stakedARM:'-' %><small class="text-muted">ARM</small>
</td>
<td> <% if (apy>0) { %> Power%: <%= (stakedPower*100/stakePower).toFixed(2) %>%<br/> <% if (active) { %> Estimate daily reward: <%= (rewardPerDay*stakedPower/stakePower).toFixed(2) %><small class="text-muted">RNA</small><br/>
My APY: <%= (rewardPerDay*stakedPower*365*100/stakePower/stakedRNA).toFixed(2) %>%<br/>
<button class="btn btn-link btn-sm p-0" data-toggle="popover" title="Details" data-html="true" data-content='Weight: <%=(stakedPower*100/stakePower).toFixed(2)%>%<br/><code class="small">(My Power / Total Power)</code><br/>Estimate daily reward: <%=(rewardPerDay*stakedPower/stakePower).toFixed(2)%><small class="text-muted">RNA</small><br/><code class="small">(Candidate estimate daily reward * Power weight)</code><br/>My APY: <%= (rewardPerDay*stakedPower*365*100/stakePower/stakedRNA).toFixed(2) %>%<br/><code>(Estimate daily reward * 365 / Staked RNA) * 100%</code><hr/>My Power:<br/><small class="text-monospace"><%= formatEther(stakedPower) %></small><br/>Total Power:<br/><small class="text-monospace"><%= formatEther(stakePower) %></small><br/>Candidate estimate daily reward:<br/><%=rewardPerDay.toFixed(2)%><small class="text-muted">RNA</small>''>More info</button> <%}%> <%} else print('-')%> </td>
<td> <%if(ready){%> <div class="btn-group" role="group">
<button class="btn btn-outline-primary btn-sm" id="stake">Stake</button>
<button class="btn btn-outline-primary btn-sm" id="unstake">Unstake</button>
</div> <%}else{%> <div class="spinner-border spinner-border-sm text-secondary" role="status">
<span class="sr-only">Loading...</span>
</div> <%}%> </td></script><script type=text/template id=stake-template><div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Stake a candidate</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group row">
<label class="col-sm-12 col-form-label">Candidate address:</label>
<div class="col-sm-10 small"><samp><%= validator %></samp></div>
</div>
<div class="form-group row no-gutters m-0">
<label for="rna" class="col-sm-3 col-form-label">RNA to stake:</label>
<div class="col-11 col-sm-2">
<input id="rna" class="form-control" type="number" min="1" placeholder="0"/>
</div>
<label class="col-1 col-form-label text-muted">RNA</label>
<label class="col-sm-9 offset-sm-3 small text-muted">
Balance: <samp class="text-dark"><%=accountData.formatEther(accountData.balance)%></samp><small class="text-muted">RNA</small>
</label>
</div>
<div class="form-group row no-gutters m-0">
<label for="arm" class="col-sm-3 col-form-label">ARM to stake:</label>
<div class="col-11 col-sm-2">
<input id="arm" class="form-control" type="number" min="0" disabled placeholder="0"/>
</div>
<label class="col-1 col-form-label text-muted">ARM</label>
<label class="bg-light col-sm-9 offset-sm-3 small text-muted">
Balance: <samp class="text-dark"><%=accountData.formatEther(accountData.balanceARM)%></samp><small class="text-muted">ARM</small>
Remain Allowance:<samp class="text-dark" id="allowedARM">-</samp><small class="text-muted">ARM</small>
<div class="input-group" id="approveDiv" hidden>
<div class="input-group-prepend"><label for="approveARM" class="input-group-text col-form-label">Limit:</label></div>
<input id="approveARM" class="form-control " type="number" min="0" value="1000" placeholder="0"/>
<div class="input-group-append"><label class="input-group-text">ARM</label></div>
<button id="approve" type="button" class="col-12 col-sm-4 ml-sm-1 btn btn-sm btn-primary">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
Approve
</button>
<br/>
<span>You need to approve an amount of ARM that can be transferred to Ribose system contract before staking.</span>
</div>
</label>
</div>
<small class="form-text text-muted">
You can stake at least 1 RNA or 3 ARMs or both.<br/>
Staking power will be <code>RNA</code> if ARM is less then 3, otherwise, <code>RNA * ln(ARM)</code>
</small>
</form>
</div>
<div class="modal-footer">
<button id="confirm" type="button" class="btn btn-primary">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
Stake
</button>
<button type="button" data-dismiss="modal" class="btn btn-secondary">Cancel</button>
</div>
</div>
</div></script><script type=text/template id=unstake-template><form>
<div class="form-group row">
<label class="col-sm-12 col-form-label">Candidate address:</label>
<div class="col-sm-10 small"><samp><%= validator %></samp></div>
</div>
<div class="form-group row no-gutters m-0">
<label for="rna" class="col-sm-4 col-form-label">RNA to unstake:</label>
<div class="col-11 col-sm-2">
<input id="rna" class="form-control" type="number" min="1" placeholder="0"/>
</div>
<label class="col-1 col-form-label text-muted">RNA</label>
</div>
<div class="form-group row no-gutters">
<label class="col-sm-9 offset-sm-4 small text-muted">Maximum: <%=stakedRNA%><small class="text-muted"> RNA</small></label>
</div>
<div class="form-group row no-gutters m-0">
<label for="arm" class="col-sm-4 col-form-label">ARM to unstake:</label>
<div class="col-11 col-sm-2">
<input id="arm" class="form-control" type="number" min="0" placeholder="0"/>
</div>
<label class="col-1 col-form-label text-muted">ARM</label>
</div>
<div class="form-group row no-gutters">
<label class="col-sm-9 offset-sm-4 small text-muted">Maximum: <%=stakedARM%><small class="text-muted"> ARM</small></label>
</div>
<small class="form-text text-muted">
You can not unstake before block <code><%= lockBlock + 86400 %></code>, current block: <code id="currentBlock"><%print(parseInt(lastBlock.number))%></code>.
</small>
</form></script><script type=text/template id=settle-template><div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Settle Reward</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Candidate address: <br/>
<samp><%= validator %></samp></p>
<p>Estimate reward to settle: <br/>
<samp><%= profit %></samp><small class="text-muted">RNA</small></p>
<small class="text-muted">
Please note: All unsettled reward will be settled.
</small>
</div>
<div class="modal-footer">
<button id="confirm" type="button" class="btn btn-primary">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
Settle
</button>
<button type="button" data-dismiss="modal" class="btn btn-secondary">Cancel</button>
</div>
</div></script><script type=text/template id=exchange-arm-template><p>
<span class="text-muted">Current Balance:</span>
<samp class="small text-dark" id="balanceARM"><%= formatEther(balanceARM) %></samp><small class="text-muted">ARM</small>
<samp class="small text-dark" id="balanceVBC"><span class="spinner-border spinner-border-sm text-secondary" role="status" aria-hidden="true"></span></samp><small class="text-muted">VBC</small><br/>
<span class="text-muted">Staked:</span>
<samp class="small text-dark" id="stakedVBC"><span class="spinner-border spinner-border-sm text-secondary" role="status" aria-hidden="true"></span></samp><small class="text-muted">VBC</small>
<span class="text-muted">Remain Allowance:</span>
<samp class="small text-dark" id="allowedVBC"><span class="spinner-border spinner-border-sm text-secondary" role="status" aria-hidden="true"></span></samp><small class="text-muted">VBC</small>
</p>
<span id="approveSpinner" class="spinner-border spinner-border-sm text-secondary" role="status" aria-hidden="true"></span>
<div class="form-group row no-gutters m-0" id="approveDiv" hidden>
<label for="approveVBC" class="col-sm-1 col-form-label">Limit:</label>
<div class="col-11 col-sm-2">
<input id="approveVBC" class="form-control" type="number" min="0" value="1000" placeholder="0"/>
</div>
<label class="col-1 col-form-label text-muted">VBC</label>
<button id="approve" type="button" class="col-12 col-sm-2 btn btn-sm btn-primary">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
Approve
</button>
<br/>
<small class="text-muted">
You need to approve an amount of VBC that can be transferred to ARM contract before staking.
</small>
</div>
<div class="form-group row no-gutters m-0" id="stakeDiv" hidden>
<div class="col-11 col-sm-2">
<input id="stakeVBC" class="form-control" type="number" min="0" placeholder="0"/>
</div>
<label class="col-1 col-form-label text-muted">ARM</label>
<div class="btn-group col-12 col-sm-4" role="group">
<button id="stake" type="button" class="btn btn-sm btn-outline-primary">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
Mint
</button>
<button id="unstake" type="button" class="btn btn-sm btn-outline-primary">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
Burn
</button>
</div>
<small class="col-12 text-muted">
You can stake VBC to mint ARM and burn ARM to get your VBC back at any time. Mint rate is fixed to 1:1 at the moment.
</small>
</div>
<hr/>
<div class="form-group row no-gutters m-0">
<label for="vbc" class="col-sm-2 col-form-label">Memo:</label>
<div class="col-12 col-sm-6">
<input id="memo" class="form-control" placeholder="-"/>
</div>
<button id="setMemo" type="button" class="col-12 col-sm-2 btn btn-sm btn-outline-primary ml-1">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
Set
</button>
<small class="col-12 text-muted">
Set your radar address as memo so that your staked VBC can be summed while calculating dividend.
</small>
</div></script><script src=./main.56de05a1b2fe1244317a.js></script></body></html>