Skip to content

Commit a5c1de1

Browse files
authored
Merge pull request #162 from LightningDotSpace/develop
Release: develop -> main
2 parents 6dc818d + be9248a commit a5c1de1

5 files changed

Lines changed: 19 additions & 19 deletions

File tree

e2e/mock-server.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,12 @@ function generateBtcHistory(range) {
6262
for (let i = cfg.count; i >= 0; i--) {
6363
const ts = new Date(now - i * cfg.step).toISOString();
6464
const onchain = parseFloat((0.35 + Math.sin(i * 0.2) * 0.02).toFixed(8));
65-
const lndOnchain = parseFloat((0.35 + Math.sin(i * 0.25) * 0.01).toFixed(8));
66-
const lightning = parseFloat((1.28 + Math.sin(i * 0.3) * 0.03).toFixed(8));
65+
const lndMinusCustomer = parseFloat((0.07 + Math.sin(i * 0.25) * 0.02).toFixed(8));
6766
const citrea = parseFloat((0.60 + Math.sin(i * 0.15) * 0.01).toFixed(8));
6867
const wbtc = parseFloat((0.004 + Math.sin(i * 0.1) * 0.001).toFixed(8));
6968
const wbtce = parseFloat((0.001 + Math.sin(i * 0.35) * 0.0005).toFixed(8));
70-
const netBalance = parseFloat((onchain + lndOnchain + lightning + citrea + wbtc + wbtce).toFixed(8));
71-
points.push({ timestamp: ts, netBalance, onchain, lndOnchain, lightning, citrea, wbtc, wbtce });
69+
const netBalance = parseFloat((onchain + lndMinusCustomer + citrea + wbtc + wbtce).toFixed(8));
70+
points.push({ timestamp: ts, netBalance, onchain, lndMinusCustomer, citrea, wbtc, wbtce });
7271
}
7372
return points;
7473
}

src/assets/monitoring-btc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
.negative { color: #ef5350; }
5858
.loading { color: #888; font-style: italic; padding: 20px 0; }
5959
.error { color: #ef5350; padding: 20px 0; }
60+
.note { font-size: 11px; color: #666; font-style: italic; }
6061
.chart-container { position: relative; width: 100%; height: 300px; margin-bottom: 30px; }
6162
.range-buttons { margin-bottom: 12px; }
6263
.range-buttons button {

src/assets/monitoring-btc.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ function render(data) {
132132
html += '</table>';
133133
html += '</div>';
134134

135+
html += '<div class="section">';
136+
html += '<p class="note">In the chart above, "LND Minus Customer" is calculated as LND Wallet + LN Channels - Customer Balance.</p>';
137+
html += '</div>';
138+
135139
content.innerHTML = html;
136140

137141
var onchainRow = document.getElementById('onchain-row');
@@ -176,26 +180,23 @@ function renderChart(points) {
176180

177181
var labels = [];
178182
var onchainData = [];
179-
var lndOnchainData = [];
180-
var lightningData = [];
183+
var lndMinusCustomerData = [];
181184
var citreaData = [];
182185
var wbtcData = [];
183186
var wbtceData = [];
184187

185188
for (var i = 0; i < points.length; i++) {
186189
labels.push(new Date(points[i].timestamp));
187190
onchainData.push(points[i].onchain);
188-
lndOnchainData.push(points[i].lndOnchain);
189-
lightningData.push(points[i].lightning);
191+
lndMinusCustomerData.push(points[i].lndMinusCustomer);
190192
citreaData.push(points[i].citrea);
191193
wbtcData.push(points[i].wbtc);
192194
wbtceData.push(points[i].wbtce);
193195
}
194196

195197
var components = [
196198
{ label: 'Onchain BTC', data: onchainData, color: '#4fc3f7' },
197-
{ label: 'LND Onchain', data: lndOnchainData, color: '#00e5ff' },
198-
{ label: 'Lightning', data: lightningData, color: '#fdd835' },
199+
{ label: 'LND Minus Customer', data: lndMinusCustomerData, color: '#fdd835' },
199200
{ label: 'cBTC (Citrea)', data: citreaData, color: '#ff9800' },
200201
{ label: 'WBTC (Ethereum)', data: wbtcData, color: '#66bb6a' },
201202
{ label: 'WBTCe (Citrea)', data: wbtceData, color: '#ab47bc' },
@@ -249,6 +250,7 @@ function renderChart(points) {
249250
},
250251
y: {
251252
stacked: true,
253+
beginAtZero: true,
252254
grid: { color: '#1a1a1a' },
253255
ticks: {
254256
color: '#555',

src/assets/monitoring-usd.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ function renderChart(points) {
183183
},
184184
y: {
185185
stacked: true,
186+
beginAtZero: true,
186187
grid: { color: '#1a1a1a' },
187188
ticks: {
188189
color: '#555',

src/subdomains/monitoring/controllers/monitoring.controller.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class MonitoringController {
151151
@ApiExcludeEndpoint()
152152
async btcHistory(
153153
@Query('range') range: string,
154-
): Promise<{ points: { timestamp: string; netBalance: number; onchain: number; lndOnchain: number; lightning: number; citrea: number; wbtc: number; wbtce: number }[]; range: string }> {
154+
): Promise<{ points: { timestamp: string; netBalance: number; onchain: number; lndMinusCustomer: number; citrea: number; wbtc: number; wbtce: number }[]; range: string }> {
155155
const { fromDate, grouping } = this.parseRange(range);
156156

157157
const [balanceHistory, evmHistory, seedBalance, seedEvmBalances] = await Promise.all([
@@ -217,7 +217,7 @@ export class MonitoringController {
217217
evmHistory: { timestamp: string; blockchain: string; nativeBalance: number; tokenBalances: string }[],
218218
seedBalance?: { timestamp: string; onchainBalance: number; lndOnchainBalance: number; lightningBalance: number; citreaBalance: number; customerBalance: number },
219219
seedEvmBalances?: { timestamp: string; blockchain: string; nativeBalance: number; tokenBalances: string }[],
220-
): { timestamp: string; netBalance: number; onchain: number; lndOnchain: number; lightning: number; citrea: number; wbtc: number; wbtce: number }[] {
220+
): { timestamp: string; netBalance: number; onchain: number; lndMinusCustomer: number; citrea: number; wbtc: number; wbtce: number }[] {
221221
const allTimestamps = new Set<string>();
222222
for (const b of balanceHistory) allTimestamps.add(new Date(b.timestamp).toISOString());
223223
for (const e of evmHistory) allTimestamps.add(new Date(e.timestamp).toISOString());
@@ -230,7 +230,7 @@ export class MonitoringController {
230230
let balIdx = 0;
231231
let evmIdx = 0;
232232

233-
const points: { timestamp: string; netBalance: number; onchain: number; lndOnchain: number; lightning: number; citrea: number; wbtc: number; wbtce: number }[] = [];
233+
const points: { timestamp: string; netBalance: number; onchain: number; lndMinusCustomer: number; citrea: number; wbtc: number; wbtce: number }[] = [];
234234

235235
for (const ts of sorted) {
236236
while (balIdx < balanceHistory.length && new Date(balanceHistory[balIdx].timestamp).toISOString() <= ts) {
@@ -244,10 +244,8 @@ export class MonitoringController {
244244
}
245245

246246
const onchain = lastBalance ? Number(lastBalance.onchainBalance) / 1e8 : 0;
247-
const lndOnchain = lastBalance ? Number(lastBalance.lndOnchainBalance) / 1e8 : 0;
248-
const lightning = lastBalance ? Number(lastBalance.lightningBalance) / 1e8 : 0;
247+
const lndMinusCustomer = lastBalance ? (Number(lastBalance.lndOnchainBalance) + Number(lastBalance.lightningBalance) - Number(lastBalance.customerBalance)) / 1e8 : 0;
249248
const citrea = lastBalance ? Number(lastBalance.citreaBalance) / 1e8 : 0;
250-
const customer = lastBalance ? Number(lastBalance.customerBalance) / 1e8 : 0;
251249

252250
let wbtc = 0;
253251
let wbtce = 0;
@@ -266,10 +264,9 @@ export class MonitoringController {
266264

267265
points.push({
268266
timestamp: ts,
269-
netBalance: onchain + lndOnchain + lightning + citrea + wbtc + wbtce - customer,
267+
netBalance: onchain + lndMinusCustomer + citrea + wbtc + wbtce,
270268
onchain,
271-
lndOnchain,
272-
lightning,
269+
lndMinusCustomer,
273270
citrea,
274271
wbtc,
275272
wbtce,

0 commit comments

Comments
 (0)