Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

[WIP] V2 Dashboard #83

Open
wants to merge 118 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
696cee5
V2 initial setup working
rodrigopivi Jan 18, 2021
2a1cad8
Update api to unify endpoints, fix asset_stats endpoint, feedback fixes
rodrigopivi Jan 19, 2021
97256be
update with feedback, remove lib/api, only one endpoint for all payload
rodrigopivi Jan 20, 2021
c14b4a6
added time periods toggle and feedback fixes
rodrigopivi Jan 20, 2021
bec3203
add styling and all option
rodrigopivi Jan 20, 2021
894d10f
v2 branch
rodrigopivi Jan 25, 2021
3dca19b
Upgrade node nvm and dependencies
rodrigopivi Jan 26, 2021
ea889fd
Merge pull request #84 from delphidigital/rod/v2-update-node-and-deps
rodrigopivi Jan 27, 2021
1191b3b
Add liquidity depth over time and logaritmic-linear switch
rodrigopivi Jan 27, 2021
9767e2b
pool depth time period and log scale done
rodrigopivi Jan 27, 2021
91f48f8
working with history depths and history swaps
rodrigopivi Jan 29, 2021
075eeec
format y axis labels
rodrigopivi Jan 29, 2021
303d7c0
Add pool list checkbox colors search and sort
rodrigopivi Feb 1, 2021
8498bfe
refactor api polling, 365 day intervals polling, top performers
rodrigopivi Feb 8, 2021
ae077c0
Merge pull request #85 from delphidigital/rod/v2-liquidity-depth-over…
rodrigopivi Feb 8, 2021
d1a1b93
historical pool data tool, runedata info
rodrigopivi Feb 11, 2021
88a986c
no coingecko prices and more charts
rodrigopivi Feb 15, 2021
4934bd8
updates, deeplink, runedatainfo charts ready
rodrigopivi Feb 18, 2021
66cc8e1
improvements
rodrigopivi Feb 18, 2021
449c95b
heroku dev deps need to be prod
rodrigopivi Feb 19, 2021
7204742
heroku redis worker
rodrigopivi Feb 19, 2021
3bd55c8
heroku nuxt setup
rodrigopivi Feb 19, 2021
4daf0a3
redis
rodrigopivi Feb 19, 2021
31def69
heroku debugging
rodrigopivi Feb 19, 2021
5db23bc
tt
rodrigopivi Feb 22, 2021
368e31a
fix
rodrigopivi Feb 22, 2021
90df30c
redis url
rodrigopivi Feb 22, 2021
e852693
redis debugging
rodrigopivi Feb 22, 2021
4293fdf
nuxt fix
rodrigopivi Feb 22, 2021
42e71b8
remove logs
rodrigopivi Feb 22, 2021
89431b0
nuxt typo
rodrigopivi Feb 22, 2021
2bbac02
frontend fetcher url fix
rodrigopivi Feb 22, 2021
e9bf562
fix env vars
rodrigopivi Feb 22, 2021
55aea59
nuxt issues
rodrigopivi Feb 22, 2021
48fce18
fix heroku app url env
rodrigopivi Feb 22, 2021
00b9f71
ui fixes
rodrigopivi Feb 22, 2021
54e409f
fix network components, solvency, churn info and nodes
rodrigopivi Feb 23, 2021
39ae4b4
update heroku readme
rodrigopivi Feb 23, 2021
0d7a886
fix edge cases for NaN in calculatioons
rodrigopivi Feb 24, 2021
8727300
update testnet address, and some ui fixes
rodrigopivi Feb 25, 2021
c06e998
charts styling
rodrigopivi Feb 25, 2021
179003d
add network tab components
rodrigopivi Mar 2, 2021
3aefe89
network components v2 ready
rodrigopivi Mar 4, 2021
f10949c
small fix
rodrigopivi Mar 5, 2021
4149bc0
deterministic chart
rodrigopivi Mar 5, 2021
7b37b9b
chart styling
rodrigopivi Mar 5, 2021
c70cf92
activity levens and block rewards per day components
rodrigopivi Mar 5, 2021
ef702c5
pools volume chart
rodrigopivi Mar 10, 2021
539f892
time switch for volume pools and highcharts fix for stacked
rodrigopivi Mar 10, 2021
bfb9048
add churn preflight and styling
rodrigopivi Mar 10, 2021
9f0ab91
preflight status
rodrigopivi Mar 11, 2021
3e18278
update node ip, APY and imp loss
rodrigopivi Mar 12, 2021
529a3ab
css fix
rodrigopivi Mar 12, 2021
17c55a7
add twitter links
rodrigopivi Mar 15, 2021
e648c64
ui fixes
rodrigopivi Mar 16, 2021
5c6c618
column tooltip
rodrigopivi Mar 17, 2021
58af6f8
location of rune, nodes, fixes
rodrigopivi Mar 17, 2021
57b0c4f
add ROI and APY from backend
rodrigopivi Mar 18, 2021
cc94f2d
thorchain dev activity
Mar 19, 2021
380b8b6
feedback updates network tab, solvency, queue, deterministic
Mar 22, 2021
7d48aa4
update new testnet ip, add cirq supply and cirq supply component progres
Mar 24, 2021
588295f
gracias
Mar 25, 2021
6e69f42
update with feedback fixes
Mar 26, 2021
97d099e
cirq supply source and fixes
Mar 28, 2021
a11a1b1
feedback fixes
Mar 29, 2021
4521f39
update location chart
Mar 29, 2021
6aac0b2
improvements for mobile view
Mar 29, 2021
7e57e11
refactoring and improvements
Apr 1, 2021
c9d097b
apy moving average, fixes, tooltips
Apr 2, 2021
ba974d1
volume by pool time options update, pool list showing date, responsiv…
Apr 5, 2021
e2df4cd
add correllation
Apr 6, 2021
a8c6206
add mainnet v2
Apr 7, 2021
0bef461
automatic nodeip updating
Apr 8, 2021
2875287
updates
Apr 8, 2021
4a51c29
fix det price and node ips after reset
Apr 10, 2021
3bb218d
feedback fixes
Apr 12, 2021
bff3e08
moving average APY 1W
Apr 12, 2021
e9c010f
add disclamer and 1month hourly for pool list
Apr 12, 2021
674b73f
add v1 location of rune
Apr 12, 2021
d5a0c81
cors fix
Apr 12, 2021
ff11a2f
locatino of rune improvements
Apr 12, 2021
6a0ec5d
fix totakStaked v1 singlechain
Apr 13, 2021
96b34ab
feedback and bugfixes
Apr 13, 2021
daff14e
fix deterministic rune price add v1 data to location and perc of rune
Apr 13, 2021
ec711f7
det price, rune locked fixes
Apr 14, 2021
fb17931
fix volume 24h, small fixes, depth
Apr 15, 2021
c71a7c7
fixes runedata info in percent
Apr 15, 2021
371378c
fix v/d avg, add standby countdown
Apr 15, 2021
ddf85fe
moving average linecharts
Apr 15, 2021
e4adba9
pools depth summary description, volume average title
Apr 16, 2021
7902760
display style
Apr 16, 2021
daef128
add singlechain v1 pooled rune
Apr 17, 2021
2247628
update thorchain base ips
Apr 20, 2021
357f6e4
fix runevault balances
Apr 20, 2021
fb40d22
fix testnet fetch
Apr 20, 2021
7ad509a
fetch every 5m
Apr 20, 2021
8f2ff9a
fix network solvency multi chain query
Apr 20, 2021
8d5e3dc
remove rune solvency and improve first page load times
Apr 22, 2021
8d04602
multiply block daily rewards by 100
Apr 23, 2021
cd0869d
calc indicators on save api data
Apr 26, 2021
f160a37
add compression
Apr 28, 2021
2669b90
use promise all for multi promises
Apr 28, 2021
4613695
throttle api overview
Apr 28, 2021
e38d527
update polling frecuency
Apr 28, 2021
be0ce3e
no throttle
Apr 28, 2021
ff916a2
fix top performers responsiveness
Apr 29, 2021
34f907f
code cleanup
Apr 29, 2021
e50e2e9
add lazy hydration, faster first page load
Apr 29, 2021
739a436
validate each node ip address is at seeds list
Apr 29, 2021
fda634d
pick random ip if not available node
May 3, 2021
848c2af
dont update node ips
May 3, 2021
415c52d
update redis node ips automatically
May 3, 2021
2be545f
force node ips
May 3, 2021
f432196
no sleep between fetch
May 4, 2021
bd8e25c
update colors, pool list scroll, earnings per day fix
May 13, 2021
75ac53b
display fix
May 20, 2021
b147b63
fix memory object during SSR
Jun 22, 2021
6b62fe6
no testnet
rodrigopivi Jun 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,37 @@ module.exports = {
'dot-notation': ['error', { allowPattern: '^[a-zA-Z0-9]+(_[a-zA-Z0-9]+)+$' }],
semi: ['error', 'always'],
'import/no-unresolved': 'off',
'import/extensions': [
'error',
'always',
{
js: 'never',
jsx: 'never',
mjs: 'neve',
},
],
'max-len': [
'error', {
ignorePattern: 'd="([\\s\\S]*?)"', // for svg
ignoreTemplateLiterals: true,
ignoreStrings: true,
ignoreComments: true,
code: 110,
},
],
'vue/max-len': [
'error', {
ignoreTemplateLiterals: true,
ignoreStrings: true,
ignoreHTMLAttributeValues: true,
ignoreHTMLTextContents: true,
ignoreComments: true,
code: 110,
template: 110,
comments: 110,
},
],
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
'no-console': 0,
'no-param-reassign': [
'error',
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.15.4
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: npx nuxt start
worker: npm run fetch
46 changes: 39 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# delphi-thorchain

## Install node version manager
Install instructions at https://github.com/nvm-sh/nvm, then:
```bash
$ nvm install && nvm use
```

## Build Setup

```bash
Expand All @@ -20,26 +26,52 @@ brew services start redis
$ yarn fetch

# or do it manually
$ DATA_SOURCE=api node scripts/saveApiResponses.mjs
$ node scripts/saveApiResponses.mjs
```

### Run the app

```bash
# serve with hot reload at localhost:3021
$ yarn develop

# or manually
$ DATA_SOURCE=cache PORT=3021 yarn dev
```

### Environment variables
- PORT: port to run the app on.
- DATA_SOURCE: where to get data from (either "api" to request real sources or "cache" to use data stored in Redis).
- CACHE_URL: url to query cached data from, defaults to 'http://localhost:3021'.
- TESTNET_NODE_IP: node ip to be used for testnet api queries, defaults to '168.119.21.60'.
- APP_URL: url to query cached data from, defaults to 'http://localhost:3021'.
- TESTNET_NODE_IP: node ip to be used for testnet api queries, defaults to '18.193.249.209' (from https://testnet.seed.thorchain.info/ or https://testnet.midgard.thorchain.info/v2/network).
- CHAOSNET_NODE_IP: node ip to be used for chaosnet api queries, defaults to ' '18.159.173.48'.
- SENDGRID_API_KEY: Sendgrid's API key used to send error notification emails.
- NOTIFICATION_MINUTE_TIME_INTERVAL: interval in minutes between notification emails (30 minutes by default).

For detailed explanation on how things work, check out [Nuxt.js docs](https://nuxtjs.org).


### Heroku

Use heroku cli:
```
heroku git:remote -a thorchain-v2-dashboard
```

Validate or edit ~/.git/config to verify that the remote heroku points to the correct instance:
```
[remote "heroku"]
url = https://git.heroku.com/thorchain-v2-dashboard.git
fetch = +refs/heads/*:refs/remotes/heroku/*
```

Then scale the worker and web:
```
heroku ps:scale web=1 worker=1
```

Then push-deploy the branch to heroku app
```
git push heroku rod/v2-dashboard:master
```

For logs:
```
heroku logs --tail
```
147 changes: 83 additions & 64 deletions api/index.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,101 @@
import express from 'express';
import { promisify } from 'util';
import redisClient from '../lib/redisClient.mjs';

const client = redisClient;
const getAsync = promisify(client.get).bind(client);

const app = express();
const thorchain = express.Router();
const chaosnet = express.Router();
const testnet = express.Router();

app.use(function(_req, res, next) {
res.header("Access-Control-Allow-Origin", '*');
res.header("Access-Control-Allow-Credentials", true);
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header("Access-Control-Allow-Headers", 'Origin,X-Requested-With,Content-Type,Accept,content-type,application/json');
next();
});

async function loadCached(id) {
const rawdata = await getAsync(`thorchain::${id}`);
const rawdata = await redisClient.getAsync(`thorchain::${id}`);
return JSON.parse(rawdata);
}

thorchain.all('/thorchain/pools', async (req, res) => {
const data = await loadCached(`${req.blockchain}::pools`);
res.json(data);
});

thorchain.all('/v1/pools/detail', async (req, res) => {
const data = await loadCached(`${req.blockchain}::pools-${req.query.asset}`);
res.json(data);
});

thorchain.all('/v1/stats', async (req, res) => {
const data = await loadCached(`${req.blockchain}::stats`);
res.json(data);
});

thorchain.all('/v1/network', async (req, res) => {
const data = await loadCached(`${req.blockchain}::network`);
res.json(data);
});

thorchain.all('/v1/thorchain/constants', async (req, res) => {
const data = await loadCached(`${req.blockchain}::constants`);
res.json(data);
});

thorchain.all('/thorchain/nodeaccounts', async (req, res) => {
const data = await loadCached(`${req.blockchain}::nodeAccounts`);
res.json(data);
});

thorchain.all('/thorchain/mimir', async (req, res) => {
const data = await loadCached(`${req.blockchain}::mimir`);
res.json(data);
});

thorchain.all('/thorchain/lastblock', async (req, res) => {
const data = await loadCached(`${req.blockchain}::lastBlock`);
res.json(data);
});

thorchain.all('/thorchain/vaults/asgard', async (req, res) => {
const data = await loadCached(`${req.blockchain}::asgardVaults`);
res.json(data);
});

thorchain.all('/int/marketdata', async (req, res) => {
const data = await loadCached(`${req.blockchain}::marketData`);
res.json(data);
});

thorchain.all('/int/runevaultBalance', async (req, res) => {
const data = await loadCached(`${req.blockchain}::runevaultBalance`);
res.json(data);
});

thorchain.all('/int/extra', async (req, res) => {
const version = await loadCached(`${req.blockchain}::version`);
const binanceAccounts = await loadCached(`${req.blockchain}::binanceAccounts`);

thorchain.all('/overview', async (req, res) => {
const pools = await loadCached(`${req.blockchain}::pools`);
// NOTE: provide by default all available pools info in advance
const poolIds = pools.filter(i => (i.status || '').toLowerCase() === 'available').map(i => i.asset);
const poolsPromises = poolIds.map((poolId) => (
new Promise((res, rej) => (
loadCached(`${req.blockchain}::pools-${poolId}`).then(poolStats => res({
poolId, poolStats
})).catch(rej)
))
));
const payloadPromises = [
loadCached(`${req.blockchain}::queue`),
loadCached(`${req.blockchain}::nodeAccounts`),
loadCached(`${req.blockchain}::lastBlock`),
loadCached(`${req.blockchain}::mimir`),
loadCached(`${req.blockchain}::asgardVaults`),
loadCached(`${req.blockchain}::network`),
loadCached(`${req.blockchain}::marketData`),
loadCached(`${req.blockchain}::constants`),
loadCached(`${req.blockchain}::runevaultBalance`),
loadCached(`${req.blockchain}::v1SinglechainStats`),
loadCached(`${req.blockchain}::v1SinglechainNetwork`),
loadCached(`${req.blockchain}::taPeriods`),
loadCached(`${req.blockchain}::version`),
loadCached(`${req.blockchain}::binanceAccounts`),
loadCached(`${req.blockchain}::stats`),
loadCached(`${req.blockchain}::poolHistoryDepths`),
loadCached(`${req.blockchain}::poolHistorySwaps`),
loadCached(`${req.blockchain}::allPoolsHistoryEarnings`),
loadCached(`${req.blockchain}::chainBalances`),
...poolsPromises,
];
const [
queue,
nodes,
lastBlock,
mimir,
asgardVaults,
network,
market,
constants,
runevaultBalance,
v1SinglechainStats,
v1SinglechainNetwork,
taPeriods,
version,
binanceAccounts,
stats,
availablePoolHistoryDepths,
availablePoolHistorySwaps,
allPoolsHistoryEarnings,
chainBalances,
...availablePoolStats
] = await Promise.all(payloadPromises);
res.json({
queue: queue || {},
pools: pools || [],
stats,
nodes,
lastBlock,
mimir,
asgardVaults,
network,
market,
constants,
runevaultBalance,
version,
binanceAccounts,
availablePoolStats,
availablePoolHistoryDepths,
availablePoolHistorySwaps,
taPeriods,
allPoolsHistoryEarnings,
v1SinglechainStats,
v1SinglechainNetwork,
chainBalances,
});
});

Expand Down
73 changes: 73 additions & 0 deletions assets/css/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,76 @@ $pureg-sm: 35.5em;
$pureg-md: 48em;
$pureg-lg: 64em;
$pureg-xl: 80em;

$namespace: 'customdatepkr';
$default-color: #ccc !default;
$primary-color: #9993f0 !default;
$today-color: mix(#353c50, $primary-color, 10%) !default;
$popup-z-index: 2001 !default;
$input-border-color: #ccc !default;
$input-color: #555 !default;
$input-hover-border-color: rgba(120,124,170,0.95) !default;
$disabled-color: #ccc !default;
$disabled-background-color: #f3f3f3 !default;
$border-color: rgba(112, 115, 150, 0.65) !default;
$calendar-active-color: #fff !default;
$calendar-active-background-color: $primary-color !default;
$calendar-hover-color: $default-color !default;
$calendar-hover-background-color: rgba(137, 140, 177, 0.7) !default;
$calendar-in-range-color: $default-color !default;
$calendar-in-range-background-color: mix(rgb(112, 115, 150), $calendar-active-background-color, 85%) !default;
$time-active-color: $primary-color !default;
$time-active-background-color: transparent !default;
$time-hover-color: $default-color !default;
$time-hover-background-color: mix(rgb(112, 115, 150), $calendar-active-background-color, 95%) !default;
$input-border-radius: 4px !default;
$sidebar-margin-left: 100px !default;

@import '~vue2-datepicker/scss/index.scss';
.customdatepkr-datepicker-main {
background-color: #30354b !important;
}
.customdatepkr-input {
background-color: #262f4a;
font-family: Montserrat, sans-serif;
border: 1px solid rgba(112, 115, 150, 0.65);
padding: 4px 8px 4px 25px;
border-radius: 16px;
font-size: 14px;
font-weight: 600;
color: white;
caret-color: white;
line-height: 20px;
height: 38px;
width: 100%;

:focus {
outline:none;
border:1px solid rgba(120,124,170,0.95);
}
}
.customdatepkr-icon-calendar,
.customdatepkr-icon-clear {
color: rgba(255, 255, 255, 0.8);
}
.customdatepkr-datepicker {
width: 100%;
}
.deeplink-selector, .tweet__link {
color: white;
height: 30px;
background-color: $color-bg-tint;
border-radius: 15px;
padding: 0 16px;
cursor: pointer;
opacity: 0.6;
display: flex;
align-items: center;
&:active {
color: white;
}
margin-right: 8px;
&:last-child {
margin-right: 0;
}
}
8 changes: 5 additions & 3 deletions components/Common/AppHighchart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ export default {
// stuff properly and fails if called at the wrong time. Just retrying the update
// seems to work just fine. Not worth it to dig deeper into the issue for now.
try {
this.chart.update(newData);
if (this.chart) {
this.chart.update(newData);
}
} catch (e) {
this.chart.update(newData);
console.error(e);
}
}
},
},
mounted() {
if (typeof window === 'object') {
if (typeof Highcharts === 'object' && typeof window === 'object') {
this.chart = Highcharts.chart(this.$refs.chart, this.chartOptions);
this.updatedAt = new Date();
}
Expand Down
4 changes: 2 additions & 2 deletions components/Common/BlockchainToggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export default {
},
methods: {
toggleBlockchain() {
const blockchain = this.$route.params.blockchain === 'chaosnet' ? 'testnet' : 'chaosnet';
const name = this.$route.name;
const { name, params } = this.$route;
const blockchain = params.blockchain === 'chaosnet' ? 'testnet' : 'chaosnet';
this.$store.commit('thorchain/loadingOn');
this.$router.push({ name, params: { blockchain } });
},
Expand Down
Loading