diff --git a/README.md b/README.md index 46903a392..f04e5f36c 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,8 @@ yarn build:ipfs ## Adding a new route API +**Deprecated: do not add new endpoints to next api** + - create a new file in `pages/api/` folder - use `wrapRequest` function from `@lidofinance/next-api-wrapper` package. - use default wrappers from `utilsApi/nextApiWrappers.ts` if needed (e.g. `defaultErrorHandler` for handle errors) diff --git a/shared/hooks/useLidoStats.ts b/shared/hooks/useLidoStats.ts index 08105d736..afbb8f322 100644 --- a/shared/hooks/useLidoStats.ts +++ b/shared/hooks/useLidoStats.ts @@ -1,13 +1,12 @@ import { useMemo } from 'react'; -import { useSDK, useLidoSWR } from '@lido-sdk/react'; +import { useLidoSWR } from '@lido-sdk/react'; import { config } from 'config'; import { DATA_UNAVAILABLE } from 'consts/text'; import { STRATEGY_LAZY } from 'consts/swr-strategies'; -import { prependBasePath } from 'utils'; import { standardFetcher } from 'utils/standardFetcher'; -export type ResponseData = { +type ResponseData = { uniqueAnytimeHolders: string; uniqueHolders: string; totalStaked: string; @@ -22,12 +21,9 @@ export const useLidoStats = (): { }; initialLoading: boolean; } => { - const { chainId } = useSDK(); - const apiShortLidoStatsPath = `api/short-lido-stats?chainId=${chainId}`; + const url = `${config.ethAPIBasePath}/v1/protocol/steth/stats`; const lidoStats = useLidoSWR( - config.ipfsMode - ? `${config.widgetApiBasePathForIpfs}/${apiShortLidoStatsPath}` - : prependBasePath(apiShortLidoStatsPath), + url, standardFetcher, STRATEGY_LAZY, ); diff --git a/utils/get-one-inch-rate.ts b/utils/get-one-inch-rate.ts index 2608152a7..52924b76a 100644 --- a/utils/get-one-inch-rate.ts +++ b/utils/get-one-inch-rate.ts @@ -2,7 +2,6 @@ import { BigNumber } from 'ethers'; import { TOKENS } from '@lido-sdk/constants'; import { config } from 'config'; import { standardFetcher } from './standardFetcher'; -import { prependBasePath } from './prependBasePath'; type GetOneInchRateParams = { token: TOKENS.STETH | TOKENS.WSTETH | 'ETH'; @@ -15,15 +14,11 @@ export const getOneInchRate = async ({ }: GetOneInchRateParams) => { const params = new URLSearchParams({ token }); if (amount) params.append('amount', amount.toString()); - const apiOneInchRatePath = `api/oneinch-rate?${params.toString()}`; + const url = `${config.ethAPIBasePath}/v1/swap/one-inch?${params.toString()}`; const data = await standardFetcher<{ rate: number; toReceive: string; - }>( - config.ipfsMode - ? `${config.widgetApiBasePathForIpfs}/${apiOneInchRatePath}` - : prependBasePath(apiOneInchRatePath), - ); + }>(url); return { rate: data.rate, toReceive: BigNumber.from(data.toReceive), diff --git a/utils/index.ts b/utils/index.ts index 34f4e3ba3..4bb0f1b78 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -2,7 +2,6 @@ export * from './appCookies'; export * from './formatBalance'; export * from './formatBalanceString'; export * from './logger'; -export * from './prependBasePath'; export * from './weiToEth'; export * from './nprogress'; export * from './getErrorMessage'; diff --git a/utils/prependBasePath.ts b/utils/prependBasePath.ts deleted file mode 100644 index a08050e9b..000000000 --- a/utils/prependBasePath.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { config } from 'config'; - -export const prependBasePath = (route: string): string => { - return `${config.basePath ?? ''}/${route}`; -};