-
Notifications
You must be signed in to change notification settings - Fork 1
/
stake_pools.erb
174 lines (164 loc) · 6.58 KB
/
stake_pools.erb
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
<%
params['stake'] ||= 1
stake = params['stake']
ep = "stake-pools-list?stake=#{stake}"
sort_by = params[:sort_by] if params[:sort_by]
case sort_by
# Common
when "blocks"
sp = stake_pools.sort_by {|s| -s['metrics']['produced_blocks']['quantity']}
when "cost"
sp = stake_pools.sort_by {|s| -s['cost']['quantity']}
when "margin"
sp = stake_pools.sort_by {|s| -s['margin']['quantity']}
# cardano-node specific
when "pledge"
sp = stake_pools.sort_by {|s| -s['pledge']['quantity']}
when "stake"
sp = stake_pools.sort_by {|s| -s['metrics']['relative_stake']['quantity']}
when "non_myopic_member_rewards"
sp = stake_pools.sort_by {|s| -s['metrics']['non_myopic_member_rewards']['quantity']}
when "saturation"
sp = stake_pools.sort_by {|s| -s['metrics']['saturation']}
# Jorm specific
when "saturation_jorm"
sp = stake_pools.sort_by {|s| -s['saturation']}
when "apparent_performance"
sp = stake_pools.sort_by {|s| -s['apparent_performance']}
when "desirability"
sp = stake_pools.sort_by {|s| -s['desirability']}
else
sp = stake_pools
end
%>
<div class="list-group">
<div class="list-group-item">
<form action="/stake-pools-list" method="GET" >
<div class="form-row">
<div class="col-2">
<div class="form-group">
<input type="text" class="form-control" name="stake" id="stake" placeholder="Intended stake" value="<%= stake %>">
<small id="help" class="form-text text-muted">
Intended stake in lovelace.
</small>
</div>
</div>
<div class="col">
<div class="form-group">
<button type="submit" class="btn btn-success">List Stake Pools</button>
</div>
</div>
</div>
</form>
</div>
<div class="list-group-item">
<%= "Stake pools: #{stake_pools.size}" %>
<% if stake_pools.size > 0 %>
| <small><a href="<%= ep %>&sort_by=blocks">by produced blocks</a></small>
| <small><a href="<%= ep %>&sort_by=cost">by cost</a></small>
| <small><a href="<%= ep %>&sort_by=margin">by margin</a></small>
<%# cardano-node specific: %>
<% unless stake_pools.first['metrics']['relative_stake'].nil? %>
| <small><a href="<%= ep %>&sort_by=stake">by relative stake</a></small>
<% end %>
<% unless stake_pools.first['metrics']['non_myopic_member_rewards'].nil? %>
| <small><a href="<%= ep %>&sort_by=non_myopic_member_rewards">by non-myopic member rewards</a></small>
<% end %>
<% unless stake_pools.first['metrics']['saturation'].nil? %>
| <small><a href="<%= ep %>&sort_by=saturation">by saturation</a></small>
<% end %>
<% unless stake_pools.first['pledge'].nil? %>
| <small><a href="<%= ep %>&sort_by=pledge">by pledge</a></small>
<% end %>
<%# jorm specific: %>
<% unless stake_pools.first['desirability'].nil? %>
| <small><a href="<%= ep %>&sort_by=desirability">by desirability</a></small>
<% end %>
<% unless stake_pools.first['apparent_performance'].nil? %>
| <small><a href="<%= ep %>&sort_by=apparent_performance">by apparent performance</a></small>
<% end %>
<% unless stake_pools.first['saturation'].nil? %>
| <small><a href="<%= ep %>&sort_by=saturation_jorm">by saturation</a></small>
<% end %>
<% end %>
</div>
<% sp.each_with_index do |s, i| %>
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1"><%= "#{i + 1}: #{s['id']}" %></h5>
</div>
<small><b>Margin:</b> <%= s['margin']['quantity'] %>%</small><br/>
<small><b>Cost:</b> <%= s['cost']['quantity'] %> lovelace</small><br/>
<%# Jormungandr: %>
<% if s['saturation'] %>
<small><b>Saturation:</b> <%= s['saturation'] %>%</small><br/>
<% end %>
<% if s['apparent_performance'] %>
<small><b>Apparent performance:</b> <%= s['apparent_performance'] %>%</small><br/>
<% end %>
<%# end %>
<%# Cardano-node: %>
<% if s['pledge'] %>
<small><b>Pledge:</b> <%= "#{s['pledge']['quantity']} #{s['pledge']['unit']}" %></small><br/>
<% end %>
<%# end %>
<% if s['metrics'] %>
<small><b>Metrics:</b></small></br>
<%# Cardano-node metrics: %>
<% if s['metrics']['saturation'] %>
<small> <b>Saturation:</b> <%= s['metrics']['saturation'] %></small><br/>
<% end %>
<% if s['metrics']['non_myopic_member_rewards'] %>
<small> <b>Non-myopic member rewards:</b>
<%= "#{s['metrics']['non_myopic_member_rewards']['quantity']} #{s['metrics']['non_myopic_member_rewards']['unit']}" %>
</small><br/>
<% end %>
<% if s['metrics']['produced_blocks'] %>
<small> <b>Produced blocks:</b>
<%= s['metrics']['produced_blocks']['quantity'] %>
</small><br/>
<% end %>
<% if s['metrics']['relative_stake'] %>
<small> <b>Relative stake:</b>
<%= "#{s['metrics']['relative_stake']['quantity']}%" %>
</small><br/>
<% end %>
<%# end %>
<%# Jormungandr metrics: %>
<% if s['metrics']['controlled_stake'] %>
<small> <b>Controlled Stake:</b>
<%= s['metrics']['controlled_stake']['quantity'] %>
</small><br/>
<% end %>
<%# end %>
<% end %>
<% if s['metadata'] %>
<small><b>Metadata:</b></small></br>
<small> <b>Homepage:</b>
<a href="<%= s['metadata']['homepage']%>" target="_blank"><%= s['metadata']['homepage']%></a>
</small></br>
<small> <b>Name:</b>
<%= s['metadata']['name']%>
</small></br>
<small> <b>Owner:</b>
<%= s['metadata']['owner']%>
</small></br>
<small> <b>Pledge address:</b>
<%= s['metadata']['pledge_address']%>
</small></br>
<small> <b>Ticker:</b>
<%= s['metadata']['ticker']%>
</small></br>
<small> <b>Description:</b>
<%= s['metadata']['description']%>
</small></br>
<% else %>
<small><b style="text-color:red">No metadata.</b></small></br>
<% end %>
<small>
<a href="/stake-pools-join?sid=<%= s['id']%>">join</a>
| <a href="/stake-pools-quit">quit</a>
</small>
</div>
<% end %>
</div>