Skip to content

Commit f7b99cc

Browse files
committed
Change tvl api
1 parent 1a79fd5 commit f7b99cc

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

components/modules/rollup/RollupCharts.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { abbreviate, formatBytes, sortArrayOfObjects, spaces, tia } from "@/serv
1717
1818
/** API */
1919
import { fetchRollupSeries } from "@/services/api/stats"
20-
import { fetchRollups } from "@/services/api/rollup"
20+
import { fetchRollups, fetchRollupTVL } from "@/services/api/rollup"
2121
2222
/** Store */
2323
import { useSettingsStore } from "@/store/settings"
@@ -599,7 +599,11 @@ const getTVLSeries = async () => {
599599
periodValue = 30
600600
}
601601
602-
const tvlSeriesRawData = await fetchData(props.rollup, 'tvl', from, tf)
602+
const tvlSeriesRawData = await fetchRollupTVL({
603+
slug: props.rollup.slug,
604+
period: tf,
605+
from,
606+
})
603607
604608
const tvlSeriesMap = {}
605609
tvlSeriesRawData.forEach((item) => {

services/api/rollup.js

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

44
export const fetchRollups = async ({ categories, limit, offset, sort, sort_by }) => {
55
try {
@@ -110,3 +110,17 @@ export const fetchRollupsDailyStats = async ({ limit, offset, sort, sort_by }) =
110110
console.error(error)
111111
}
112112
}
113+
114+
export const fetchRollupTVL = async ({ slug, period, from, to }) => {
115+
try {
116+
const url = new URL(`${tvlServiceURL}/tvl/${slug}/${period}`)
117+
118+
if (from) url.searchParams.append("from", from)
119+
if (to) url.searchParams.append("to", to)
120+
121+
const data = await $fetch(url.href)
122+
return data
123+
} catch (error) {
124+
console.error(error)
125+
}
126+
}

services/api/stats.js

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

44
export const fetch24hDiffs = async ({ name }) => {
55
try {
@@ -70,11 +70,12 @@ export const fetchTVS = async ({ period, from, to }) => {
7070
let url = ""
7171

7272
if (period) {
73-
url = new URL(`${useServerURL()}/stats/tvs/${period}`)
73+
url = new URL(`${tvlServiceURL}/tvs/${period}`)
74+
7475
if (from) url.searchParams.append("from", from)
7576
if (to) url.searchParams.append("to", to)
7677
} else {
77-
url = new URL(`${useServerURL()}/stats/tvs`)
78+
url = new URL(`${tvlServiceURL}/tvs`)
7879
}
7980

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

services/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,5 @@ export const getStartChainDate = () => {
107107
}
108108
}
109109

110+
export const tvlServiceURL = "https://tvl.celenium.io/v1"
110111
export const blockscoutURL = "https://celestia-l2-router.k8s-dev.blockscout.com/api/v1/celestia/l2BatchMetadata"

0 commit comments

Comments
 (0)