diff --git a/packages/core/src/apis/osmosisHistorical/apr/index.ts b/packages/core/src/apis/osmosisHistorical/apr/index.ts index 5d1bf5f..1655d05 100644 --- a/packages/core/src/apis/osmosisHistorical/apr/index.ts +++ b/packages/core/src/apis/osmosisHistorical/apr/index.ts @@ -1,20 +1,20 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { APRResponse, StakingAPRResponse } from "./types"; export type { APRResponse, StakingAPRResponse }; -export const getStakingAPR = async (): Promise => { - return (await osmosisInstance.get("/apr/v2/staking")).data; -}; +export const getStakingAPR = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/apr/v2/staking")).data; + }; -export const getAllAPR = async (): Promise => { - return (await osmosisInstance.get("/apr/v2/all")).data; -}; +export const getAllAPR = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/apr/v2/all")).data; + }; -export const getAPR = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/apr/v2/${poolId}`)).data; -}; +export const getAPR = + (instance: AxiosInstance) => + async ({ poolId }: { poolId: number }): Promise => { + return (await instance.get(`/apr/v2/${poolId}`)).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/fees/index.ts b/packages/core/src/apis/osmosisHistorical/fees/index.ts index 6770be6..7f4b2af 100644 --- a/packages/core/src/apis/osmosisHistorical/fees/index.ts +++ b/packages/core/src/apis/osmosisHistorical/fees/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { HistoricalFeeResponse, PoolFeesResponse, @@ -7,30 +7,29 @@ import type { export type { HistoricalFeeResponse, PoolFeesResponse, TotalFeesResponse }; -export const getTotalFees = async (): Promise => { - return (await osmosisInstance.get("/fees/v1/total")).data; -}; +export const getTotalFees = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/fees/v1/total")).data; + }; -export const getPoolsFees = async (): Promise => { - return (await osmosisInstance.get("/fees/v1/pools")).data; -}; +export const getPoolsFees = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/fees/v1/pools")).data; + }; -export const getPoolFees = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/fees/v1/${poolId}`)).data; -}; +export const getPoolFees = + (instance: AxiosInstance) => + async ({ poolId }: { poolId: number }): Promise => { + return (await instance.get(`/fees/v1/${poolId}`)).data; + }; -export const getHistoricalFees = async (): Promise => { - return (await osmosisInstance.get("/fees/v1/total/historical")).data; -}; +export const getHistoricalFees = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/fees/v1/total/historical")).data; + }; -export const getHistoricalFee = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/fees/v1/historical/${poolId}`)).data; -}; +export const getHistoricalFee = + (instance: AxiosInstance) => + async ({ poolId }: { poolId: number }): Promise => { + return (await instance.get(`/fees/v1/historical/${poolId}`)).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/health/index.ts b/packages/core/src/apis/osmosisHistorical/health/index.ts index afa59d6..a48f6db 100644 --- a/packages/core/src/apis/osmosisHistorical/health/index.ts +++ b/packages/core/src/apis/osmosisHistorical/health/index.ts @@ -1,8 +1,9 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { HealthResponse } from "./types"; export type { HealthResponse }; -export const getHealth = async (): Promise => { - return (await osmosisInstance.get("/health/v1/check")).data; -}; +export const getHealth = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/health/v1/check")).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/ibc/index.ts b/packages/core/src/apis/osmosisHistorical/ibc/index.ts index 2a8e25a..1e83eb1 100644 --- a/packages/core/src/apis/osmosisHistorical/ibc/index.ts +++ b/packages/core/src/apis/osmosisHistorical/ibc/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { AllIbcResponse, IbcDestinationResponse, @@ -17,65 +17,68 @@ export type { IbcSourceResponse, }; -export const getIbcInfo = async (): Promise => { - return (await osmosisInstance.get("/ibc/v1/info")).data; -}; +export const getIbcInfo = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/ibc/v1/info")).data; + }; -export const getAllIbc = async ({ - dex, -}: { - dex?: string; -}): Promise => { - return (await osmosisInstance.get("/ibc/v1/all", { params: { dex } })).data; -}; +export const getAllIbc = + (instance: AxiosInstance) => + async ({ dex }: { dex?: string }): Promise => { + return (await instance.get("/ibc/v1/all", { params: { dex } })).data; + }; -export const getIbcSourceDestination = async ({ - source, - destination, - minutes_trigger, -}: { - source: string; - destination: string; - minutes_trigger: number; -}): Promise => { - return ( - await osmosisInstance.get( - `/ibc/v1/source/${source}/destination${destination}`, - { +export const getIbcSourceDestination = + (instance: AxiosInstance) => + async ({ + source, + destination, + minutes_trigger, + }: { + source: string; + destination: string; + minutes_trigger: number; + }): Promise => { + return ( + await instance.get(`/ibc/v1/source/${source}/destination${destination}`, { params: { minutes_trigger }, - } - ) - ).data; -}; + }) + ).data; + }; -export const getIbcSource = async ({ - source, - minutes_trigger, -}: { - source: string; - minutes_trigger: number; -}): Promise => { - return ( - await osmosisInstance.get(`/ibc/v1/source/${source}`, { - params: { minutes_trigger }, - }) - ).data; -}; +export const getIbcSource = + (instance: AxiosInstance) => + async ({ + source, + minutes_trigger, + }: { + source: string; + minutes_trigger: number; + }): Promise => { + return ( + await instance.get(`/ibc/v1/source/${source}`, { + params: { minutes_trigger }, + }) + ).data; + }; -export const getIbcDestination = async ({ - destination, - minutes_trigger, -}: { - destination: string; - minutes_trigger: number; -}): Promise => { - return ( - await osmosisInstance.get(`/ibc/v1/destination/${destination}`, { - params: { minutes_trigger }, - }) - ).data; -}; +export const getIbcDestination = + (instance: AxiosInstance) => + async ({ + destination, + minutes_trigger, + }: { + destination: string; + minutes_trigger: number; + }): Promise => { + return ( + await instance.get(`/ibc/v1/destination/${destination}`, { + params: { minutes_trigger }, + }) + ).data; + }; -export const getIbcRaw = async (): Promise => { - return (await osmosisInstance.get("/ibc/v1/raw")).data; -}; +export const getIbcRaw = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/ibc/v1/raw")).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/liquidity/index.ts b/packages/core/src/apis/osmosisHistorical/liquidity/index.ts index 92ad4ff..d9c0c9d 100644 --- a/packages/core/src/apis/osmosisHistorical/liquidity/index.ts +++ b/packages/core/src/apis/osmosisHistorical/liquidity/index.ts @@ -1,9 +1,10 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { LiquidityHistoricalChartResponse } from "./types"; export type { LiquidityHistoricalChartResponse }; export const getLiquidityHistoricalChart = + (instance: AxiosInstance) => async (): Promise => { - return (await osmosisInstance.get("/liquidity/v2/historical/chart")).data; + return (await instance.get("/liquidity/v2/historical/chart")).data; }; diff --git a/packages/core/src/apis/osmosisHistorical/overview/index.ts b/packages/core/src/apis/osmosisHistorical/overview/index.ts index fd7e4bd..d032391 100644 --- a/packages/core/src/apis/osmosisHistorical/overview/index.ts +++ b/packages/core/src/apis/osmosisHistorical/overview/index.ts @@ -1,12 +1,14 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { MessageResponse, MetricsResponse } from "./types"; export type { MessageResponse, MetricsResponse }; -export const getMetrics = async (): Promise => { - return (await osmosisInstance.get("/overview/v1/metrics")).data; -}; +export const getMetrics = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/overview/v1/metrics")).data; + }; -export const getMessage = async (): Promise => { - return (await osmosisInstance.get("/overview/v1/message")).data; -}; +export const getMessage = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/overview/v1/message")).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/pairs/index.ts b/packages/core/src/apis/osmosisHistorical/pairs/index.ts index 97a96fd..aabe965 100644 --- a/packages/core/src/apis/osmosisHistorical/pairs/index.ts +++ b/packages/core/src/apis/osmosisHistorical/pairs/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PairsHistoricalChartParams, PairsHistoricalChartResponse, @@ -11,25 +11,28 @@ export type { PairsSummaryResponse, }; -export const getPairsSummary = async (): Promise => { - return (await osmosisInstance.get("/pairs/v1/summary")).data; -}; +export const getPairsSummary = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/pairs/v1/summary")).data; + }; -export const getPairsHistoricalChart = async ({ - poolId, - assetIn, - assetOut, - assetType, - range, -}: PairsHistoricalChartParams): Promise => { - return ( - await osmosisInstance.get(`/pairs/v1/historical/${poolId}/chart`, { - params: { - asset_in: assetIn, - asset_out: assetOut, - asset_type: assetType, - range, - }, - }) - ).data; -}; +export const getPairsHistoricalChart = + (instance: AxiosInstance) => + async ({ + poolId, + assetIn, + assetOut, + assetType, + range, + }: PairsHistoricalChartParams): Promise => { + return ( + await instance.get(`/pairs/v1/historical/${poolId}/chart`, { + params: { + asset_in: assetIn, + asset_out: assetOut, + asset_type: assetType, + range, + }, + }) + ).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/pools/index.ts b/packages/core/src/apis/osmosisHistorical/pools/index.ts index 80c4e40..484f02b 100644 --- a/packages/core/src/apis/osmosisHistorical/pools/index.ts +++ b/packages/core/src/apis/osmosisHistorical/pools/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { AllPoolsResponse, PoolResponse, @@ -13,41 +13,40 @@ export type { PoolVolumeChartResponse, }; -export const getAllPools = async ({ - lowLiquidity, -}: { - lowLiquidity: boolean; -}): Promise => { - return ( - await osmosisInstance.get("/pools/v2/all", { - params: { - low_liquidity: lowLiquidity, - }, - }) - ).data; -}; +export const getAllPools = + (instance: AxiosInstance) => + async ({ + lowLiquidity, + }: { + lowLiquidity: boolean; + }): Promise => { + return ( + await instance.get("/pools/v2/all", { + params: { + low_liquidity: lowLiquidity, + }, + }) + ).data; + }; -export const getPool = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/pools/v2/${poolId}`)).data; -}; +export const getPool = + (instance: AxiosInstance) => + async ({ poolId }: { poolId: number }): Promise => { + return (await instance.get(`/pools/v2/${poolId}`)).data; + }; -export const getPoolLiquidityChart = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/pools/v2/liquidity/${poolId}/chart`)) - .data; -}; +export const getPoolLiquidityChart = + (instance: AxiosInstance) => + async ({ + poolId, + }: { + poolId: number; + }): Promise => { + return (await instance.get(`/pools/v2/liquidity/${poolId}/chart`)).data; + }; -export const getPoolVolumeChart = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/pools/v2/volume/${poolId}/chart`)).data; -}; +export const getPoolVolumeChart = + (instance: AxiosInstance) => + async ({ poolId }: { poolId: number }): Promise => { + return (await instance.get(`/pools/v2/volume/${poolId}/chart`)).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/search/index.ts b/packages/core/src/apis/osmosisHistorical/search/index.ts index 78d2075..bfe5c1e 100644 --- a/packages/core/src/apis/osmosisHistorical/search/index.ts +++ b/packages/core/src/apis/osmosisHistorical/search/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { SearchDenomResponse, SearchExponentResponse, @@ -11,44 +11,38 @@ export type { SearchSymbolResponse, }; -export const getSearchDenom = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return ( - await osmosisInstance.get("/search/v1/denom", { - params: { - symbol, - }, - }) - ).data; -}; +export const getSearchDenom = + (instance: AxiosInstance) => + async ({ symbol }: { symbol: string }): Promise => { + return ( + await instance.get("/search/v1/denom", { + params: { + symbol, + }, + }) + ).data; + }; -export const getSearchSymbol = async ({ - denom, -}: { - denom: string; -}): Promise => { - return ( - await osmosisInstance.get("/search/v1/symbol", { - params: { - denom, - }, - }) - ).data; -}; +export const getSearchSymbol = + (instance: AxiosInstance) => + async ({ denom }: { denom: string }): Promise => { + return ( + await instance.get("/search/v1/symbol", { + params: { + denom, + }, + }) + ).data; + }; -export const getSearchExponent = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return ( - await osmosisInstance.get("/search/v1/exponent", { - params: { - symbol, - }, - }) - ).data; -}; +export const getSearchExponent = + (instance: AxiosInstance) => + async ({ symbol }: { symbol: string }): Promise => { + return ( + await instance.get("/search/v1/exponent", { + params: { + symbol, + }, + }) + ).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/supply/index.ts b/packages/core/src/apis/osmosisHistorical/supply/index.ts index b8e83e5..1eb9af5 100644 --- a/packages/core/src/apis/osmosisHistorical/supply/index.ts +++ b/packages/core/src/apis/osmosisHistorical/supply/index.ts @@ -1,12 +1,14 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { SupplyResponse } from "./types"; export type { SupplyResponse }; -export const getSupplyOsmo = async (): Promise => { - return (await osmosisInstance.get("/supply/v1/osmo")).data; -}; +export const getSupplyOsmo = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/supply/v1/osmo")).data; + }; -export const getSupplyIon = async (): Promise => { - return (await osmosisInstance.get("/supply/v1/ion")).data; -}; +export const getSupplyIon = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/supply/v1/ion")).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/tokens/index.ts b/packages/core/src/apis/osmosisHistorical/tokens/index.ts index 5a9728c..5403ef4 100644 --- a/packages/core/src/apis/osmosisHistorical/tokens/index.ts +++ b/packages/core/src/apis/osmosisHistorical/tokens/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { TokenCountResponse, TokensHistoricalChartParams, @@ -29,101 +29,109 @@ export type { TokensVolumeChartByPoolResponse, }; -export const getAllTokens = async (): Promise => { - return (await osmosisInstance.get("/tokens/v2/all")).data; -}; +export const getAllTokens = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/tokens/v2/all")).data; + }; export const getTokensMarketCap = - async (): Promise => { - return (await osmosisInstance.get("/tokens/v2/mcap")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/tokens/v2/mcap")).data; }; -export const getToken = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/${symbol}`)).data; -}; +export const getToken = + (instance: AxiosInstance) => + async ({ symbol }: { symbol: string }): Promise => { + return (await instance.get(`/tokens/v2/${symbol}`)).data; + }; -export const getTokenHistoricalChart = async ({ - symbol, -}: TokensHistoricalChartParams): Promise => { - return (await osmosisInstance.get(`/tokens/v2/historical/${symbol}/chart`)) - .data; -}; +export const getTokenHistoricalChart = + (instance: AxiosInstance) => + async ({ + symbol, + }: TokensHistoricalChartParams): Promise => { + return (await instance.get(`/tokens/v2/historical/${symbol}/chart`)).data; + }; -export const getTokenLiquidityChart = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/liquidity/${symbol}/chart`)) - .data; -}; +export const getTokenLiquidityChart = + (instance: AxiosInstance) => + async ({ + symbol, + }: { + symbol: string; + }): Promise => { + return (await instance.get(`/tokens/v2/liquidity/${symbol}/chart`)).data; + }; -export const getTokenVolumeChart = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/volume/${symbol}/chart`)).data; -}; +export const getTokenVolumeChart = + (instance: AxiosInstance) => + async ({ + symbol, + }: { + symbol: string; + }): Promise => { + return (await instance.get(`/tokens/v2/volume/${symbol}/chart`)).data; + }; -export const getTokenPrice = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/price/${symbol}`)).data; -}; +export const getTokenPrice = + (instance: AxiosInstance) => + async ({ symbol }: { symbol: string }): Promise => { + return (await instance.get(`/tokens/v2/price/${symbol}`)).data; + }; -export const getTokensTop = async ({ - type, -}: { - type: "gainer" | "losers"; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/top/${type}`)).data; -}; +export const getTokensTop = + (instance: AxiosInstance) => + async ({ + type, + }: { + type: "gainer" | "losers"; + }): Promise => { + return (await instance.get(`/tokens/v2/top/${type}`)).data; + }; -export const getTokensCount = async ({ - poolId, - rangeStart, - rangeStop, -}: { - poolId: string; - rangeStart: string; - rangeStop: string; -}): Promise => { - return ( - await osmosisInstance.get(`/tokens/v2/count/${poolId}`, { - params: { - range_start: rangeStart, - range_stop: rangeStop, - }, - }) - ).data; -}; +export const getTokensCount = + (instance: AxiosInstance) => + async ({ + poolId, + rangeStart, + rangeStop, + }: { + poolId: string; + rangeStart: string; + rangeStop: string; + }): Promise => { + return ( + await instance.get(`/tokens/v2/count/${poolId}`, { + params: { + range_start: rangeStart, + range_stop: rangeStop, + }, + }) + ).data; + }; export const getTokensVolumeGlobal = + (instance: AxiosInstance) => async (): Promise => { - return (await osmosisInstance.get("/tokens/v2/volume/global")).data; + return (await instance.get("/tokens/v2/volume/global")).data; }; -export const getTokensCoinVolumeChart = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/volume/coin/${symbol}/chart`)) - .data; -}; +export const getTokensCoinVolumeChart = + (instance: AxiosInstance) => + async ({ + symbol, + }: { + symbol: string; + }): Promise => { + return (await instance.get(`/tokens/v2/volume/coin/${symbol}/chart`)).data; + }; -export const getTokensVolumeChartByPool = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/volume/${poolId}/coin/chart`)) - .data; -}; +export const getTokensVolumeChartByPool = + (instance: AxiosInstance) => + async ({ + poolId, + }: { + poolId: number; + }): Promise => { + return (await instance.get(`/tokens/v2/volume/${poolId}/coin/chart`)).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/tradingview/index.ts b/packages/core/src/apis/osmosisHistorical/tradingview/index.ts index 565c0fa..f12da33 100644 --- a/packages/core/src/apis/osmosisHistorical/tradingview/index.ts +++ b/packages/core/src/apis/osmosisHistorical/tradingview/index.ts @@ -1,36 +1,38 @@ // TODO: Add return types -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; -export const postTradingViewAuthorize = async (body: { - login: string; - password: string; - scope?: string; -}) => { - return (await osmosisInstance.post("/tradingview/v1/authorize", body)).data; -}; +export const postTradingViewAuthorize = + (instance: AxiosInstance) => + async (body: { login: string; password: string; scope?: string }) => { + return (await instance.post("/tradingview/v1/authorize", body)).data; + }; -export const getTradingViewSymbolInfo = async () => { - return (await osmosisInstance.get("/tradingview/v1/symbol_info")).data; -}; +export const getTradingViewSymbolInfo = + (instance: AxiosInstance) => async () => { + return (await instance.get("/tradingview/v1/symbol_info")).data; + }; -export const getTradingViewHistory = async ({ - symbol, - to, - from, - resolution, -}: { - symbol: string; - to: number; - from: number; - resolution: string; -}) => { - return ( - await osmosisInstance.get("/tradingview/v1/history", { - params: { symbol, to, from, resolution }, - }) - ).data; -}; +export const getTradingViewHistory = + (instance: AxiosInstance) => + async ({ + symbol, + to, + from, + resolution, + }: { + symbol: string; + to: number; + from: number; + resolution: string; + }) => { + return ( + await instance.get("/tradingview/v1/history", { + params: { symbol, to, from, resolution }, + }) + ).data; + }; -export const getTradingViewStreaming = async () => { - return (await osmosisInstance.get("/tradingview/v1/streaming")).data; -}; +export const getTradingViewStreaming = + (instance: AxiosInstance) => async () => { + return (await instance.get("/tradingview/v1/streaming")).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/volume/index.ts b/packages/core/src/apis/osmosisHistorical/volume/index.ts index f057d88..f2491e0 100644 --- a/packages/core/src/apis/osmosisHistorical/volume/index.ts +++ b/packages/core/src/apis/osmosisHistorical/volume/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { TotalVolumeResponse, VolumeHistoricalChartResponse, @@ -7,10 +7,12 @@ import type { export type { TotalVolumeResponse, VolumeHistoricalChartResponse }; export const getVolumeHistoricalChart = + (instance: AxiosInstance) => async (): Promise => { - return (await osmosisInstance.get("/volume/v2/historical/chart")).data; + return (await instance.get("/volume/v2/historical/chart")).data; }; -export const getTotalVolume = async (): Promise => { - return (await osmosisInstance.get("/volume/v2/total")).data; -}; +export const getTotalVolume = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/volume/v2/total")).data; + }; diff --git a/packages/core/src/getOsmosisHistoricalQuery.ts b/packages/core/src/getOsmosisHistoricalQuery.ts index 7556bc8..ee7f464 100644 --- a/packages/core/src/getOsmosisHistoricalQuery.ts +++ b/packages/core/src/getOsmosisHistoricalQuery.ts @@ -1,194 +1,221 @@ +import { AxiosInstance } from "axios"; import * as OsmosisHistorical from "./apis/osmosisHistorical"; +import { osmosisInstance } from "./common"; -export const getOsmosisHistoricalQuery = () => { +export const getOsmosisHistoricalQuery = (instance?: AxiosInstance) => { + const setInstance = (callback: (instance: AxiosInstance) => T) => { + return callback(instance || osmosisInstance); + }; return { /** * GET `/health/v1/check` */ - getHealth: OsmosisHistorical.getHealth, + getHealth: setInstance(OsmosisHistorical.getHealth), /** * GET `/overview/v1/metrics` */ - getMetrics: OsmosisHistorical.getMetrics, + getMetrics: setInstance(OsmosisHistorical.getMetrics), /** * GET `/overview/v1/message` */ - getMessage: OsmosisHistorical.getMessage, + getMessage: setInstance(OsmosisHistorical.getMessage), /** * GET `/ibc/v1/info` */ - getIbcInfo: OsmosisHistorical.getIbcInfo, + getIbcInfo: setInstance(OsmosisHistorical.getIbcInfo), /** * GET `/ibc/v1/all` */ - getAllIbc: OsmosisHistorical.getAllIbc, + getAllIbc: setInstance(OsmosisHistorical.getAllIbc), /** * GET `/ibc/v1/source/{source}/destination{destination}` */ - getIbcSourceDestination: OsmosisHistorical.getIbcSourceDestination, + getIbcSourceDestination: setInstance( + OsmosisHistorical.getIbcSourceDestination + ), /** * GET `/ibc/v1/source/{source}` */ - getIbcSource: OsmosisHistorical.getIbcSource, + getIbcSource: setInstance(OsmosisHistorical.getIbcSource), /** * GET `/ibc/v1/destination/{destination}` */ - getIbcDestination: OsmosisHistorical.getIbcDestination, + getIbcDestination: setInstance(OsmosisHistorical.getIbcDestination), /** * GET `/ibc/v1/raw` */ - getIbcRaw: OsmosisHistorical.getIbcRaw, + getIbcRaw: setInstance(OsmosisHistorical.getIbcRaw), /** * GET `/pairs/v1/summary` */ - getPairsSummary: OsmosisHistorical.getPairsSummary, + getPairsSummary: setInstance(OsmosisHistorical.getPairsSummary), /** * GET `/pairs/v1/historical/{pool_id}/chart` */ - getPairsHistoricalChart: OsmosisHistorical.getPairsHistoricalChart, + getPairsHistoricalChart: setInstance( + OsmosisHistorical.getPairsHistoricalChart + ), /** * GET `/pools/v2/all` */ - getAllPools: OsmosisHistorical.getAllPools, + getAllPools: setInstance(OsmosisHistorical.getAllPools), /** * GET `/pools/v2/{pool_id}` */ - getPool: OsmosisHistorical.getPool, + getPool: setInstance(OsmosisHistorical.getPool), /** * GET `/pools/v2/liquidity/{pool_id}/chart` */ - getPoolLiquidityChart: OsmosisHistorical.getPoolLiquidityChart, + getPoolLiquidityChart: setInstance(OsmosisHistorical.getPoolLiquidityChart), /** * GET `/pools/vs2/volume/{pool_id}/chart` */ - getPoolVolumeChart: OsmosisHistorical.getPoolVolumeChart, + getPoolVolumeChart: setInstance(OsmosisHistorical.getPoolVolumeChart), /** * GET `/tokens/v2/all` */ - getAllTokens: OsmosisHistorical.getAllTokens, + getAllTokens: setInstance(OsmosisHistorical.getAllTokens), /** * GET `/tokens/v2/mcap` */ - getTokensMarketCap: OsmosisHistorical.getTokensMarketCap, + getTokensMarketCap: setInstance(OsmosisHistorical.getTokensMarketCap), /** * GET `/tokens/v2/{symbol}` */ - getToken: OsmosisHistorical.getToken, + getToken: setInstance(OsmosisHistorical.getToken), /** * GET `/tokens/v2/historical/{symbol}/chart` */ - getTokenHistoricalChart: OsmosisHistorical.getTokenHistoricalChart, + getTokenHistoricalChart: setInstance( + OsmosisHistorical.getTokenHistoricalChart + ), /** * GET `/tokens/v2/liquidity/{symbol}/chart` */ - getTokenLiquidityChart: OsmosisHistorical.getTokenLiquidityChart, + getTokenLiquidityChart: setInstance( + OsmosisHistorical.getTokenLiquidityChart + ), /** * GET `/tokens/v2/volume/{symbol}/chart` */ - getTokenVolumeChart: OsmosisHistorical.getTokenVolumeChart, + getTokenVolumeChart: setInstance(OsmosisHistorical.getTokenVolumeChart), /** * GET `/tokens/v2/price/{symbol}` */ - getTokenPrice: OsmosisHistorical.getTokenPrice, + getTokenPrice: setInstance(OsmosisHistorical.getTokenPrice), /** * GET `/tokens/v2/top/{type}` */ - getTokensTop: OsmosisHistorical.getTokensTop, + getTokensTop: setInstance(OsmosisHistorical.getTokensTop), /** * GET `/tokens/v2/count/{pool_id}` */ - getTokensCount: OsmosisHistorical.getTokensCount, + getTokensCount: setInstance(OsmosisHistorical.getTokensCount), /** * GET `/tokens/v2/volume/global` */ - getTokensVolumeGlobal: OsmosisHistorical.getTokensVolumeGlobal, + getTokensVolumeGlobal: setInstance(OsmosisHistorical.getTokensVolumeGlobal), /** * GET `/tokens/v2/volume/coin/{symbol}/chart` */ - getTokensCoinVolumeChart: OsmosisHistorical.getTokensCoinVolumeChart, + getTokensCoinVolumeChart: setInstance( + OsmosisHistorical.getTokensCoinVolumeChart + ), /** * GET `/tokens/v2/volume/{pool_id}/coin/chart` */ - getTokensVolumeChartByPool: OsmosisHistorical.getTokensVolumeChartByPool, + getTokensVolumeChartByPool: setInstance( + OsmosisHistorical.getTokensVolumeChartByPool + ), /** * GET `/liquidity/v2/historical/chart` */ - getLiquidityHistoricalChart: OsmosisHistorical.getLiquidityHistoricalChart, + getLiquidityHistoricalChart: setInstance( + OsmosisHistorical.getLiquidityHistoricalChart + ), /** * GET `/volume/v2/historical/chart` */ - getVolumeHistoricalChart: OsmosisHistorical.getVolumeHistoricalChart, + getVolumeHistoricalChart: setInstance( + OsmosisHistorical.getVolumeHistoricalChart + ), /** * GET `/volume/v2/total` */ - getTotalVolume: OsmosisHistorical.getTotalVolume, + getTotalVolume: setInstance(OsmosisHistorical.getTotalVolume), /** * GET `/fees/v1/total` */ - getTotalFees: OsmosisHistorical.getTotalFees, + getTotalFees: setInstance(OsmosisHistorical.getTotalFees), /** * GET `/fees/v1/pools` */ - getPoolsFees: OsmosisHistorical.getPoolsFees, + getPoolsFees: setInstance(OsmosisHistorical.getPoolsFees), /** * GET `/fees/v1/{pool_id}` */ - getPoolFees: OsmosisHistorical.getPoolFees, + getPoolFees: setInstance(OsmosisHistorical.getPoolFees), /** * GET `/fees/v1/total/historical` */ - getHistoricalFees: OsmosisHistorical.getHistoricalFees, + getHistoricalFees: setInstance(OsmosisHistorical.getHistoricalFees), /** * GET `/fees/v1/historical/{pool_id}` */ - getHistoricalFee: OsmosisHistorical.getHistoricalFee, + getHistoricalFee: setInstance(OsmosisHistorical.getHistoricalFee), /** * GET `/search/v1/denom` */ - getSearchDenom: OsmosisHistorical.getSearchDenom, + getSearchDenom: setInstance(OsmosisHistorical.getSearchDenom), /** * GET `/search/v1/symbol` */ - getSearchSymbol: OsmosisHistorical.getSearchSymbol, + getSearchSymbol: setInstance(OsmosisHistorical.getSearchSymbol), /** * GET `/search/v1/exponent` */ - getSearchExponent: OsmosisHistorical.getSearchExponent, + getSearchExponent: setInstance(OsmosisHistorical.getSearchExponent), /** * GET `/apr/v2/staking` */ - getStakingAPR: OsmosisHistorical.getStakingAPR, + getStakingAPR: setInstance(OsmosisHistorical.getStakingAPR), /** * GET `/apr/v2/all` */ - getAllAPR: OsmosisHistorical.getAllAPR, + getAllAPR: setInstance(OsmosisHistorical.getAllAPR), /** * GET `/apr/v2/{pool_id}` */ - getAPR: OsmosisHistorical.getAPR, + getAPR: setInstance(OsmosisHistorical.getAPR), /** * GET `/supply/v1/osmo` */ - getSupplyOsmo: OsmosisHistorical.getSupplyOsmo, + getSupplyOsmo: setInstance(OsmosisHistorical.getSupplyOsmo), /** * GET `/supply/v1/ion` */ - getSupplyIon: OsmosisHistorical.getSupplyIon, + getSupplyIon: setInstance(OsmosisHistorical.getSupplyIon), /** * POST `/tradingview/v1/authorize` */ - postTradingViewAuthorize: OsmosisHistorical.postTradingViewAuthorize, + postTradingViewAuthorize: setInstance( + OsmosisHistorical.postTradingViewAuthorize + ), /** * GET `/tradingview/v1/symbol_info` */ - getTradingViewSymbolInfo: OsmosisHistorical.getTradingViewSymbolInfo, + getTradingViewSymbolInfo: setInstance( + OsmosisHistorical.getTradingViewSymbolInfo + ), /** * GET `/tradingview/v1/history` */ - getTradingViewHistory: OsmosisHistorical.getTradingViewHistory, + getTradingViewHistory: setInstance(OsmosisHistorical.getTradingViewHistory), /** * GET `/tradingview/v1/streaming` */ - getTradingViewStreaming: OsmosisHistorical.getTradingViewStreaming, + getTradingViewStreaming: setInstance( + OsmosisHistorical.getTradingViewStreaming + ), }; };