-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken_volume.php
More file actions
149 lines (147 loc) · 5.53 KB
/
token_volume.php
File metadata and controls
149 lines (147 loc) · 5.53 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
<?php
require_once 'bootstrap.php';
require_once 'include/layout.php';
require_once 'include/components/range_controls.php';
require_once 'include/components/stat_card.php';
include_once 'include/graph.php';
$graphConfigs = require 'include/graph_configs.php';
$currencyCookie = \Siagraph\Utils\CurrencyDisplay::selectedCurrency();
use Siagraph\Utils\ApiClient;
use Siagraph\Utils\Locale;
use Siagraph\Utils\CurrencyDisplay;
$months = 12; // default visible range; slider covers all data
$aggEndpoint = '/api/v1/monthly/aggregates';
$intervalDefault = 'month';
$latestData = ApiClient::fetchJson($aggEndpoint);
$dataError = !is_array($latestData);
$latest = $dataError ? [] : end($latestData);
$asOf = !$dataError && isset($latest['date']) ? $latest['date'] : null;
$ratesByDate = $asOf ? CurrencyDisplay::loadDailyRates($asOf, $asOf) : [];
render_header("SiaGraph - Token Volume"); ?>
<section id="main-content" class="sg-container">
<h1 class="sg-container__heading text-center mb-2"><i class="bi bi-bar-chart me-2"></i>Token Volume</h1>
<?php if ($dataError): ?>
<p class="text-center text-muted">Volume data unavailable.</p>
<?php endif; ?>
<div class="sg-container__row mb-4">
<div class="sg-container__row-content sg-container__row-content--center">
<div class="sg-container__column sg-container__column--one-fourth">
<?php
render_stat_card([
'icon' => 'bi bi-currency-bitcoin',
'label' => 'Siacoin Volume',
'value' => isset($latest['siacoin_volume']) ? CurrencyDisplay::formatMonetary([
'scValue' => (float) $latest['siacoin_volume'] / 1e24,
'currency' => $currencyCookie,
'date' => $asOf,
'ratesByDate' => $ratesByDate,
'decimals' => 0,
'scDecimals' => 0,
]) : 'N/A',
'context' => $asOf ? ('Monthly total as of ' . $asOf) : 'Monthly total',
]);
?>
</div>
<div class="sg-container__column sg-container__column--one-fourth">
<?php
render_stat_card([
'icon' => 'bi bi-cash-stack',
'label' => 'Siafunds Volume',
'value' => isset($latest['siafund_volume']) ? Locale::decimal($latest['siafund_volume']/1e24,0).' SF' : 'N/A',
'context' => $asOf ? ('Monthly total as of ' . $asOf) : 'Monthly total',
]);
?>
</div>
<div class="sg-container__column sg-container__column--one-fourth">
<?php
render_stat_card([
'icon' => 'bi bi-wallet',
'label' => 'Unique TX Addresses',
'value' => isset($latest['unique_transaction_addresses']) ? Locale::integer($latest['unique_transaction_addresses']) : 'N/A',
'context' => $asOf ? ('Monthly total as of ' . $asOf) : 'Monthly total',
]);
?>
</div>
</div>
<div class="sg-container__row">
<div class="sg-container__row-content">
<div class="sg-container__column">
<section class="card">
<h2 class="card__heading">Siacoin Trade Volume</h2>
<?php
renderGraph(
'aggregates-siacoin-volume',
[
$graphConfigs['siacoin_volume']
],
'date',
$aggEndpoint,
null,
'bar',
$intervalDefault,
true,
'true',
$months,
'false',
$currencyCookie
);
?>
</section>
</div>
</div>
</div>
<div class="sg-container__row">
<div class="sg-container__row-content">
<div class="sg-container__column">
<section class="card">
<h2 class="card__heading">Siafunds Trade Volume</h2>
<?php
renderGraph(
'aggregates-siafund-volume',
[
array_merge($graphConfigs['siafund_volume'], ['unitDivisor' => 1, 'decimalPlaces' => 0])
],
'date',
$aggEndpoint,
null,
'bar',
$intervalDefault,
true,
'true',
$months,
'false',
null
);
?>
</section>
</div>
</div>
</div>
<div class="sg-container__row mt-4">
<div class="sg-container__row-content">
<div class="sg-container__column">
<section class="card">
<h2 class="card__heading">Unique Transaction Addresses</h2>
<?php
renderGraph(
'aggregates-unique-tx-addresses',
[
$graphConfigs['unique_transaction_addresses']
],
'date',
$aggEndpoint,
null,
'line',
$intervalDefault,
true,
'true',
$months,
'false',
null
);
?>
</section>
</div>
</div>
</section>
<?php render_footer(); ?>