Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bisq dashboard #381

Merged
merged 29 commits into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
eeb7447
Bisq markets dashboard. Base views. WIP.
softsimon Feb 26, 2021
38e8669
Bisq markets dashboard: 24H Volume. WIP.
softsimon Feb 28, 2021
2fca34f
Bisq markets dashboard: Offers list. WIP.
softsimon Mar 4, 2021
d99fd5d
Bisq markets dashboard: Market backend tracking. WIP.
softsimon Mar 5, 2021
1d4ed85
Bisq markets: Volume and other fixes.
softsimon Mar 10, 2021
308dd2c
Bisq markets: Recent trades. Separate Bisq master page.
softsimon Mar 13, 2021
146fcfc
Bisq markets: Hide altcoins when not in official bisq markets mode
softsimon Mar 13, 2021
8e29a4c
Bisq markets: Titles
softsimon Mar 14, 2021
da77dbe
Bisq markets: General trading volume graph.
softsimon Mar 15, 2021
dc36bfc
Adding Bisq markets logo.
softsimon Mar 20, 2021
1ae0023
Merge branch 'simon/cpfp-frontend' into simon/bisq-dashboard
softsimon Mar 20, 2021
fcf7955
Merge branch 'master' into simon/bisq-dashboard
softsimon Apr 12, 2021
344d124
Updated package.json.
softsimon Apr 13, 2021
6b5b80f
Update chart colors.
softsimon Apr 19, 2021
6ccac1d
Merge pull request #467 from knorrium/fix_infinite_scrolling
wiz Apr 20, 2021
d4508bd
Add loading spinners.
softsimon Apr 21, 2021
5cb98b9
Make unique URLs for graph timespans
softsimon Apr 21, 2021
2d4dff6
Display 100 latest trades.
softsimon Apr 22, 2021
04ec5e9
Sort table by number of trades as default sort option, make other col…
softsimon Apr 23, 2021
b8fe7b6
Merge branch 'master' into simon/bisq-dashboard
softsimon Apr 23, 2021
165aa6e
Don't hide API docs on mobile.
softsimon Apr 23, 2021
95a8015
Hide latest altcoin trades when not using official bisq markets.
softsimon Apr 24, 2021
c1fc081
Add whitespaces to missing data points.
softsimon Apr 24, 2021
5878a2e
Unified Bisq config
softsimon Apr 24, 2021
da050ee
Swap BTC/Fiat columns.
softsimon Apr 25, 2021
56518b9
Updated titles
softsimon Apr 25, 2021
001bddd
Bisq Markets i18n
softsimon Apr 25, 2021
3a957ec
Merge branch 'master' into simon/bisq-dashboard
softsimon Apr 25, 2021
5cd5280
Updated i18n
softsimon Apr 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions backend/mempool-config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@
"ENABLED": true,
"TX_PER_SECOND_SAMPLE_PERIOD": 150
},
"BISQ_BLOCKS": {
"ENABLED": false,
"DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db/json"
},
"BISQ_MARKETS": {
"BISQ": {
"ENABLED": false,
"DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db"
}
Expand Down
6 changes: 3 additions & 3 deletions backend/src/api/bisq/bisq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { StaticPool } from 'node-worker-threads-pool';
import logger from '../../logger';

class Bisq {
private static BLOCKS_JSON_FILE_PATH = config.BISQ_BLOCKS.DATA_PATH + '/all/blocks.json';
private static BLOCKS_JSON_FILE_PATH = config.BISQ.DATA_PATH + '/json/all/blocks.json';
private latestBlockHeight = 0;
private blocks: BisqBlock[] = [];
private transactions: BisqTransaction[] = [];
Expand Down Expand Up @@ -98,7 +98,7 @@ class Bisq {
this.topDirectoryWatcher.close();
}
let fsWait: NodeJS.Timeout | null = null;
this.topDirectoryWatcher = fs.watch(config.BISQ_BLOCKS.DATA_PATH, () => {
this.topDirectoryWatcher = fs.watch(config.BISQ.DATA_PATH + '/json', () => {
if (fsWait) {
clearTimeout(fsWait);
}
Expand Down Expand Up @@ -126,7 +126,7 @@ class Bisq {
return;
}
let fsWait: NodeJS.Timeout | null = null;
this.subdirectoryWatcher = fs.watch(config.BISQ_BLOCKS.DATA_PATH + '/all', () => {
this.subdirectoryWatcher = fs.watch(config.BISQ.DATA_PATH + '/json/all', () => {
if (fsWait) {
clearTimeout(fsWait);
}
Expand Down
24 changes: 24 additions & 0 deletions backend/src/api/bisq/markets-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,30 @@ class BisqMarketsApi {
}
}

getVolumesByTime(time: number): MarketVolume[] {
const timestamp_from = new Date().getTime() / 1000 - time;
const timestamp_to = new Date().getTime() / 1000;

const trades = this.getTradesByCriteria(undefined, timestamp_to, timestamp_from,
undefined, undefined, undefined, 'asc', Number.MAX_SAFE_INTEGER);

const markets: any = {};

for (const trade of trades) {
if (!markets[trade._market]) {
markets[trade._market] = {
'volume': 0,
'num_trades': 0,
};
}

markets[trade._market]['volume'] += this.fiatCurrenciesIndexed[trade.currency] ? trade._tradeAmount : trade._tradeVolume;
markets[trade._market]['num_trades']++;
}

return markets;
}

private getTradesSummarized(trades: TradesData[], timestamp_from: number, interval?: string): SummarizedIntervals {
const intervals: any = {};
const intervals_prices: any = {};
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/bisq/markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import logger from '../../logger';

class Bisq {
private static FOLDER_WATCH_CHANGE_DETECTION_DEBOUNCE = 4000;
private static MARKET_JSON_PATH = config.BISQ_MARKETS.DATA_PATH;
private static MARKET_JSON_PATH = config.BISQ.DATA_PATH;
private static MARKET_JSON_FILE_PATHS = {
activeCryptoCurrency: '/active_crypto_currency_list.json',
activeFiatCurrency: '/active_fiat_currency_list.json',
Expand Down
8 changes: 8 additions & 0 deletions backend/src/api/websocket-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ class WebsocketHandler {
client['track-donation'] = parsedMessage['track-donation'];
}

if (parsedMessage['track-bisq-market']) {
if (/^[a-z]{3}_[a-z]{3}$/.test(parsedMessage['track-bisq-market'])) {
client['track-bisq-market'] = parsedMessage['track-bisq-market'];
} else {
client['track-bisq-market'] = null;
}
}

if (Object.keys(response).length) {
client.send(JSON.stringify(response));
}
Expand Down
18 changes: 4 additions & 14 deletions backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ interface IConfig {
ENABLED: boolean;
TX_PER_SECOND_SAMPLE_PERIOD: number;
};
BISQ_BLOCKS: {
ENABLED: boolean;
DATA_PATH: string;
};
BISQ_MARKETS: {
BISQ: {
ENABLED: boolean;
DATA_PATH: string;
};
Expand Down Expand Up @@ -114,11 +110,7 @@ const defaults: IConfig = {
'ENABLED': true,
'TX_PER_SECOND_SAMPLE_PERIOD': 150
},
'BISQ_BLOCKS': {
'ENABLED': false,
'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db/json'
},
'BISQ_MARKETS': {
'BISQ': {
'ENABLED': false,
'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db'
},
Expand All @@ -133,8 +125,7 @@ class Config implements IConfig {
DATABASE: IConfig['DATABASE'];
SYSLOG: IConfig['SYSLOG'];
STATISTICS: IConfig['STATISTICS'];
BISQ_BLOCKS: IConfig['BISQ_BLOCKS'];
BISQ_MARKETS: IConfig['BISQ_MARKETS'];
BISQ: IConfig['BISQ'];

constructor() {
const configs = this.merge(configFile, defaults);
Expand All @@ -146,8 +137,7 @@ class Config implements IConfig {
this.DATABASE = configs.DATABASE;
this.SYSLOG = configs.SYSLOG;
this.STATISTICS = configs.STATISTICS;
this.BISQ_BLOCKS = configs.BISQ_BLOCKS;
this.BISQ_MARKETS = configs.BISQ_MARKETS;
this.BISQ = configs.BISQ;
}

merge = (...objects: object[]): IConfig => {
Expand Down
13 changes: 3 additions & 10 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,10 @@ class Server {
this.setUpHttpApiRoutes();
this.runMainUpdateLoop();

if (config.BISQ_BLOCKS.ENABLED) {
if (config.BISQ.ENABLED) {
bisq.startBisqService();
bisq.setPriceCallbackFunction((price) => websocketHandler.setExtraInitProperties('bsq-price', price));
blocks.setNewBlockCallback(bisq.handleNewBitcoinBlock.bind(bisq));
}

if (config.BISQ_MARKETS.ENABLED) {
bisqMarkets.startBisqService();
}

Expand Down Expand Up @@ -210,7 +207,7 @@ class Server {
;
}

if (config.BISQ_BLOCKS.ENABLED) {
if (config.BISQ.ENABLED) {
this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/stats', routes.getBisqStats)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/tx/:txId', routes.getBisqTransaction)
Expand All @@ -219,11 +216,6 @@ class Server {
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/blocks/:index/:length', routes.getBisqBlocks)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/address/:address', routes.getBisqAddress)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/txs/:index/:length', routes.getBisqTransactions)
;
}

if (config.BISQ_MARKETS.ENABLED) {
this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/currencies', routes.getBisqMarketCurrencies.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/depth', routes.getBisqMarketDepth.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/hloc', routes.getBisqMarketHloc.bind(routes))
Expand All @@ -232,6 +224,7 @@ class Server {
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/ticker', routes.getBisqMarketTicker.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/trades', routes.getBisqMarketTrades.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/volumes', routes.getBisqMarketVolumes.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/volumes/7d', routes.getBisqMarketVolumes7d.bind(routes))
;
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Logger {
}

private getNetwork(): string {
if (config.BISQ_BLOCKS.ENABLED) {
if (config.BISQ.ENABLED) {
return 'bisq';
}
if (config.MEMPOOL.NETWORK && config.MEMPOOL.NETWORK !== 'mainnet') {
Expand Down
1 change: 1 addition & 0 deletions backend/src/mempool.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export interface WebsocketResponse {
'track-tx': string;
'track-address': string;
'watch-mempool': boolean;
'track-bisq-market': string;
}

export interface VbytesPerSecond {
Expand Down
9 changes: 9 additions & 0 deletions backend/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,15 @@ class Routes {
}
}

public getBisqMarketVolumes7d(req: Request, res: Response) {
const result = bisqMarket.getVolumesByTime(604800);
if (result) {
res.json(result);
} else {
res.status(500).json(this.getBisqMarketErrorResponse('getBisqMarketVolumes7d error'));
}
}

private parseRequestParameters(requestParams: object, params: RequiredSpec): { [name: string]: any; } {
const final = {};
for (const i in params) {
Expand Down
49 changes: 38 additions & 11 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"clipboard": "^2.0.4",
"domino": "^2.1.6",
"express": "^4.17.1",
"lightweight-charts": "^3.3.0",
"ngx-bootrap-multiselect": "^2.0.0",
"ngx-infinite-scroll": "^10.0.1",
"qrcode": "^1.4.4",
Expand Down
15 changes: 14 additions & 1 deletion frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import { DashboardComponent } from './dashboard/dashboard.component';
import { LatestBlocksComponent } from './components/latest-blocks/latest-blocks.component';
import { ApiDocsComponent } from './components/api-docs/api-docs.component';
import { TermsOfServiceComponent } from './components/terms-of-service/terms-of-service.component';
import { BisqMasterPageComponent } from './components/bisq-master-page/bisq-master-page.component';

const routes: Routes = [
let routes: Routes = [
{
path: '',
component: MasterPageComponent,
Expand Down Expand Up @@ -283,6 +284,18 @@ const routes: Routes = [
},
];

const browserWindow = window || {};
// @ts-ignore
const browserWindowEnv = browserWindow.__env || {};

if (browserWindowEnv && browserWindowEnv.OFFICIAL_BISQ_MARKETS) {
routes = [{
path: '',
component: BisqMasterPageComponent,
loadChildren: () => import('./bisq/bisq.module').then(m => m.BisqModule)
}];
}

@NgModule({
imports: [RouterModule.forRoot(routes, {
initialNavigation: 'enabled'
Expand Down