forked from glitchful-dev/sol-stake-pool-apy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-prices.bash
executable file
·61 lines (49 loc) · 1.35 KB
/
update-prices.bash
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
#!/bin/bash
set -x
GREP_CMD="grep"
if [[ "$(uname)" == "Darwin" ]]; then
GREP_CMD="ggrep"
fi
result_file="./result.tmp"
now="$(date -Iseconds)"
pnpm run start > "$result_file"
epoch=$($GREP_CMD -oP "^epoch \K[0-9.]*" "$result_file")
if [[ -z $epoch ]]
then
echo "Epoch not found in the result file!"
exit 1
fi
function update_db {
db_file="$1"
search_exp="$2"
if [[ -z $db_file ]] || [[ -z $search_exp ]]
then
echo "Missing arguments, usage: update_db <db-file> <search-exp>"
exit 1
fi
price=$($GREP_CMD -ioP "^$search_exp \K[0-9.]*" "$result_file")
if [[ -z $price ]]
then
echo "Price not found in the result file!"
return
fi
echo "Found price for $search_exp: $price"
echo "$now,$epoch,$price" >> "$db_file"
}
update_db './db/laine.csv' Laine
update_db './db/cogent.csv' Cogent
update_db './db/everstake.csv' Everstake
update_db './db/solblaze.csv' SolBlaze
update_db './db/daopool.csv' DAOPool
update_db './db/jpool.csv' JPool
update_db './db/socean.csv' INF
update_db './db/jito.csv' Jito
update_db './db/lst.csv' LST
update_db './db/edgevana.csv' Edgevana
update_db './db/hub.csv' Hub
update_db './db/lido.csv' Lido
update_db './db/marinade.csv' Marinade
update_db './db/pwrsol.csv' PwrSOL
update_db './db/picosol.csv' PicoSOL
update_db './db/vsol.csv' vSOL
rm "$result_file"