Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/eighty-results-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@venusprotocol/evm": minor
---

Added rates tab
4 changes: 4 additions & 0 deletions apps/evm/src/clients/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ export * from './queries/getRiskDashboardLiquidationsDistribution';
export * from './queries/getRiskDashboardLiquidationsDistribution/useGetRiskDashboardLiquidationsDistribution';
export * from './queries/getRiskDashboardMarketSnapshots';
export * from './queries/getRiskDashboardMarketSnapshots/useGetRiskDashboardMarketSnapshots';
export * from './queries/getRiskDashboardRatesHistory';
export * from './queries/getRiskDashboardRatesHistory/useGetRiskDashboardRatesHistory';
export * from './queries/getRiskDashboardStablecoinRates';
export * from './queries/getRiskDashboardStablecoinRates/useGetRiskDashboardStablecoinRates';
export * from './queries/getRiskDashboardWalletAggregates';
export * from './queries/getRiskDashboardWalletAggregates/useGetRiskDashboardWalletAggregates';
export * from './queries/getRiskDashboardTopWallets';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { VError } from 'libs/errors';
import type { ChainId } from 'types';
import { restService } from 'utilities';
import type { Address } from 'viem';
import type { RiskDashboardMarketSnapshotKind } from '../getRiskDashboardMarketSnapshots';

export interface ApiRiskDashboardRatesHistoryMarketPoint {
marketAddress: Address;
underlyingAddress: Address | null;
supplyRatePerBlockMantissa: string;
borrowRatePerBlockMantissa: string;
supplyApy: number;
borrowApy: number;
supplyUsdCents: string;
borrowsUsdCents: string;
}

export interface ApiRiskDashboardRatesHistorySlot {
blockNumber: string;
blockTimestamp: string;
byMarket: ApiRiskDashboardRatesHistoryMarketPoint[];
}

export interface GetRiskDashboardRatesHistoryInput {
chainId: ChainId;
topTokens?: boolean;
}

export interface GetRiskDashboardRatesHistoryResponse {
chainId: string;
kind: RiskDashboardMarketSnapshotKind;
series: ApiRiskDashboardRatesHistorySlot[];
}

export async function getRiskDashboardRatesHistory({
chainId,
topTokens,
}: GetRiskDashboardRatesHistoryInput) {
const response = await restService<GetRiskDashboardRatesHistoryResponse>({
endpoint: '/risk-dashboard/rates-history',
method: 'GET',
params: { chainId, ...(topTokens ? { topTokens: true } : {}) },
});

const payload = response.data;

if (payload && 'error' in payload) {
throw new VError({
type: 'unexpected',
code: 'somethingWentWrong',
data: { exception: payload.error },
});
}

if (!payload) {
throw new VError({ type: 'unexpected', code: 'somethingWentWrong' });
}

return payload;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { type QueryObserverOptions, useQuery } from '@tanstack/react-query';

import FunctionKey from 'constants/functionKey';
import { useChainId } from 'libs/wallet';
import type { ChainId } from 'types';
import { type GetRiskDashboardRatesHistoryResponse, getRiskDashboardRatesHistory } from '.';

export type UseGetRiskDashboardRatesHistoryQueryKey = [
FunctionKey.GET_RISK_DASHBOARD_RATES_HISTORY,
{ chainId: ChainId; topTokens?: boolean },
];

type Options = QueryObserverOptions<
GetRiskDashboardRatesHistoryResponse,
Error,
GetRiskDashboardRatesHistoryResponse,
GetRiskDashboardRatesHistoryResponse,
UseGetRiskDashboardRatesHistoryQueryKey
>;

export const useGetRiskDashboardRatesHistory = (
{ topTokens }: { topTokens?: boolean } = {},
options?: Partial<Options>,
) => {
const { chainId } = useChainId();

return useQuery({
queryKey: [FunctionKey.GET_RISK_DASHBOARD_RATES_HISTORY, { chainId, topTokens }],
queryFn: () => getRiskDashboardRatesHistory({ chainId, topTokens }),
...options,
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { VError } from 'libs/errors';
import type { ChainId } from 'types';
import { restService } from 'utilities';
import type { Address } from 'viem';
import type { RiskDashboardMarketSnapshotKind } from '../getRiskDashboardMarketSnapshots';

export interface ApiRiskDashboardStablecoinRatesAssetPoint {
marketAddress: Address;
underlyingAddress: Address;
supplyUsdCents: string;
borrowsUsdCents: string;
supplyShare: number;
borrowShare: number;
}

export interface ApiRiskDashboardStablecoinRatesSlot {
blockNumber: string;
blockTimestamp: string;
supplyRatePerBlockMantissa: string;
borrowRatePerBlockMantissa: string;
supplyApy: number;
borrowApy: number;
totalSupplyUsdCents: string;
totalBorrowsUsdCents: string;
byAsset: ApiRiskDashboardStablecoinRatesAssetPoint[];
}

export interface GetRiskDashboardStablecoinRatesInput {
chainId: ChainId;
}

export interface GetRiskDashboardStablecoinRatesResponse {
chainId: string;
kind: RiskDashboardMarketSnapshotKind;
series: ApiRiskDashboardStablecoinRatesSlot[];
}

export async function getRiskDashboardStablecoinRates({
chainId,
}: GetRiskDashboardStablecoinRatesInput) {
const response = await restService<GetRiskDashboardStablecoinRatesResponse>({
endpoint: '/risk-dashboard/stablecoin-rates',
method: 'GET',
params: { chainId },
});

const payload = response.data;

if (payload && 'error' in payload) {
throw new VError({
type: 'unexpected',
code: 'somethingWentWrong',
data: { exception: payload.error },
});
}

if (!payload) {
throw new VError({ type: 'unexpected', code: 'somethingWentWrong' });
}

return payload;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { type QueryObserverOptions, useQuery } from '@tanstack/react-query';

import FunctionKey from 'constants/functionKey';
import { useChainId } from 'libs/wallet';
import type { ChainId } from 'types';
import { type GetRiskDashboardStablecoinRatesResponse, getRiskDashboardStablecoinRates } from '.';

export type UseGetRiskDashboardStablecoinRatesQueryKey = [
FunctionKey.GET_RISK_DASHBOARD_STABLECOIN_RATES,
{ chainId: ChainId },
];

type Options = QueryObserverOptions<
GetRiskDashboardStablecoinRatesResponse,
Error,
GetRiskDashboardStablecoinRatesResponse,
GetRiskDashboardStablecoinRatesResponse,
UseGetRiskDashboardStablecoinRatesQueryKey
>;

export const useGetRiskDashboardStablecoinRates = (options?: Partial<Options>) => {
const { chainId } = useChainId();

return useQuery({
queryKey: [FunctionKey.GET_RISK_DASHBOARD_STABLECOIN_RATES, { chainId }],
queryFn: () => getRiskDashboardStablecoinRates({ chainId }),
...options,
});
};
2 changes: 2 additions & 0 deletions apps/evm/src/constants/functionKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ enum FunctionKey {
GET_RISK_DASHBOARD_LIQUIDATIONS_SUMMARY = 'GET_RISK_DASHBOARD_LIQUIDATIONS_SUMMARY',
GET_RISK_DASHBOARD_LIQUIDATIONS_DAILY = 'GET_RISK_DASHBOARD_LIQUIDATIONS_DAILY',
GET_RISK_DASHBOARD_LIQUIDATIONS_DISTRIBUTION = 'GET_RISK_DASHBOARD_LIQUIDATIONS_DISTRIBUTION',
GET_RISK_DASHBOARD_RATES_HISTORY = 'GET_RISK_DASHBOARD_RATES_HISTORY',
GET_RISK_DASHBOARD_STABLECOIN_RATES = 'GET_RISK_DASHBOARD_STABLECOIN_RATES',
GET_IMAGE_ACCENT_COLOR = 'GET_IMAGE_ACCENT_COLOR',
}

Expand Down
41 changes: 41 additions & 0 deletions apps/evm/src/libs/translations/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,46 @@
"title": "Markets",
"unavailable": "Markets data unavailable."
},
"rates": {
"apyChart": {
"borrows": {
"noData": "No historical snapshots yet.",
"title": "Borrow APY by Asset over Time",
"unavailable": "Borrow APY unavailable."
},
"supply": {
"noData": "No historical snapshots yet.",
"title": "Supply APY by Asset over Time",
"unavailable": "Supply APY unavailable."
}
},
"dominance": {
"borrows": {
"noData": "No historical snapshots yet.",
"title": "Stablecoin Borrow Dominance over Time",
"unavailable": "Borrow dominance unavailable."
},
"supply": {
"noData": "No historical snapshots yet.",
"title": "Stablecoin Supply Dominance over Time",
"unavailable": "Supply dominance unavailable."
}
},
"stablecoinRates": {
"borrowLabel": "Borrow APY",
"noData": "No historical snapshots yet.",
"supplyLabel": "Supply APY",
"title": "Weighted Average Stablecoin Rates over Time",
"unavailable": "Stablecoin rates unavailable."
},
"totals": {
"borrowLabel": "Total Borrows",
"noData": "No historical snapshots yet.",
"supplyLabel": "Total Supply",
"title": "Total Stablecoin Supply vs Borrows over Time",
"unavailable": "Stablecoin totals unavailable."
}
},
"riskParametersTable": {
"columns": {
"asset": "Asset",
Expand All @@ -1850,6 +1890,7 @@
"liquidations": "Liquidations",
"markets": "Markets",
"overview": "Overview",
"rates": "Rates",
"wallets": "Wallets"
},
"title": "Venus Stats",
Expand Down
41 changes: 41 additions & 0 deletions apps/evm/src/libs/translations/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,46 @@
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
},
"rates": {
"apyChart": {
"borrows": {
"noData": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
},
"supply": {
"noData": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
}
},
"dominance": {
"borrows": {
"noData": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
},
"supply": {
"noData": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
}
},
"stablecoinRates": {
"borrowLabel": "TRANSLATION NEEDED",
"noData": "TRANSLATION NEEDED",
"supplyLabel": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
},
"totals": {
"borrowLabel": "TRANSLATION NEEDED",
"noData": "TRANSLATION NEEDED",
"supplyLabel": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
}
},
"riskParametersTable": {
"columns": {
"asset": "TRANSLATION NEEDED",
Expand All @@ -1850,6 +1890,7 @@
"liquidations": "TRANSLATION NEEDED",
"markets": "TRANSLATION NEEDED",
"overview": "TRANSLATION NEEDED",
"rates": "TRANSLATION NEEDED",
"wallets": "TRANSLATION NEEDED"
},
"title": "Venus 統計",
Expand Down
41 changes: 41 additions & 0 deletions apps/evm/src/libs/translations/translations/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,46 @@
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
},
"rates": {
"apyChart": {
"borrows": {
"noData": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
},
"supply": {
"noData": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
}
},
"dominance": {
"borrows": {
"noData": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
},
"supply": {
"noData": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
}
},
"stablecoinRates": {
"borrowLabel": "TRANSLATION NEEDED",
"noData": "TRANSLATION NEEDED",
"supplyLabel": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
},
"totals": {
"borrowLabel": "TRANSLATION NEEDED",
"noData": "TRANSLATION NEEDED",
"supplyLabel": "TRANSLATION NEEDED",
"title": "TRANSLATION NEEDED",
"unavailable": "TRANSLATION NEEDED"
}
},
"riskParametersTable": {
"columns": {
"asset": "TRANSLATION NEEDED",
Expand All @@ -1850,6 +1890,7 @@
"liquidations": "TRANSLATION NEEDED",
"markets": "TRANSLATION NEEDED",
"overview": "TRANSLATION NEEDED",
"rates": "TRANSLATION NEEDED",
"wallets": "TRANSLATION NEEDED"
},
"title": "สถิติ Venus",
Expand Down
Loading
Loading