Skip to content

Commit 7618943

Browse files
committed
Handle new tvl/tvs service
1 parent 64409cf commit 7618943

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

pages/stats/[metric].vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,13 @@ const fetchData = async () => {
248248
fetchTVL({ slug: "celestia", period: selectedTimeframe.value.timeframe }),
249249
])
250250
251-
tvsData.forEach(d => {
251+
supplyData.forEach(d => {
252252
let res = {}
253+
const tvsValue = parseFloat(tvsData.find(s => s.time === d.time)?.close || 0)
253254
res.time = d.time
254-
res.supply = parseFloat(supplyData.find(s => s.time === d.time)?.value) || 0
255-
res.rollupTvl = parseFloat(d.close) - res.supply
256-
res.value = parseFloat(d.close)
255+
res.supply = parseFloat(d.value) || 0
256+
res.rollupTvl = tvsValue - res.supply
257+
res.value = tvsValue
257258
258259
data.push(res)
259260
})

services/api/rollup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** Services */
2-
import { githubServiceURL, tvlServiceURL, tvlServiceURL_new, useServerURL } from "@/services/config"
2+
import { githubServiceURL, tvlServiceURL, useServerURL } from "@/services/config"
33

44
export const fetchRollups = async ({ categories, type, tags, limit, offset, sort, sort_by }) => {
55
try {
@@ -121,7 +121,7 @@ export const fetchRollupsDailyStats = async ({ limit, offset, sort, sort_by }) =
121121

122122
export const fetchRollupTVL = async ({ dataSource, slug, period, from, to }) => {
123123
try {
124-
const url = new URL(`${tvlServiceURL_new}/tvl/${dataSource}/${slug}/${period}`)
124+
const url = new URL(`${tvlServiceURL}/tvl/${dataSource}/${slug}/${period}`)
125125

126126
if (from) url.searchParams.append("from", from)
127127
if (to) url.searchParams.append("to", to)

services/api/stats.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,16 @@ export const fetchTVL = async ({ slug, period, from, to }) => {
6969
try {
7070
let url = ""
7171

72-
if (period) {
72+
if (slug !== "celestia") {
7373
url = new URL(`${tvlServiceURL}/tvl/${slug}/${period}`)
7474

7575
if (from) url.searchParams.append("from", from)
7676
if (to) url.searchParams.append("to", to)
7777
} else {
78-
url = new URL(`${tvlServiceURL}/tvl`)
78+
url = new URL(`${tvlServiceURL}/supply/${period}`)
79+
80+
if (from) url.searchParams.append("from", from)
81+
if (to) url.searchParams.append("to", to)
7982
}
8083

8184
const data = await $fetch(url.href)

services/config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ export const getStartChainDate = () => {
123123

124124
export const blockscoutURL = "https://celestia-l2-router.k8s-dev.blockscout.com/api/v1/celestia/l2BatchMetadata"
125125
export const nodeStatsURL = "https://node-stats.celenium.io/v1"
126-
export const tvlServiceURL = "https://tvl.celenium.io/v1"
127-
export const tvlServiceURL_new = "https://tvl-new.celenium.io/v1"
126+
export const tvlServiceURL = "https://tvl-new.celenium.io/v1"
128127
export const githubServiceURL = "https://github.celenium.io/v1"
129128
export const quoteServiceURL = "https://quote.celenium.io/v1"
130129
export const faucetURL = {

0 commit comments

Comments
 (0)