assembly/composables/protocols/useUniverseOverview.ts
2021-12-03 16:45:02 +08:00

32 lines
622 B
TypeScript

import { onMounted, ref, useContext } from '@nuxtjs/composition-api';
const overview = ref<OverviewModel>({
tvl: 0, totalProfits: 0, totalGasSaved: 0
});
type OverviewModel = {
tvl: number
totalProfits: number
totalGasSaved: number
}
export function useUniverseOverview() {
const { $axios } = useContext();
const fetchOverview = async () => {
const { data } = await $axios
.$get<{ data: OverviewModel }>("https://defi-test-api.webwxk.com/singleVault/universe/instadapp/overview")
overview.value = data;
};
onMounted(() => {
fetchOverview();
});
return {
overview
};
}