Skip to content

Commit

Permalink
update OsmosisHistoricalQuery to receive custom Axios Instance
Browse files Browse the repository at this point in the history
  • Loading branch information
gnujoow committed Jan 6, 2023
1 parent e4138ef commit 7397596
Show file tree
Hide file tree
Showing 14 changed files with 423 additions and 380 deletions.
28 changes: 14 additions & 14 deletions packages/core/src/apis/osmosisHistorical/apr/index.ts
Original file line number Diff line number Diff line change
@@ -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<StakingAPRResponse> => {
return (await osmosisInstance.get("/apr/v2/staking")).data;
};
export const getStakingAPR =
(instance: AxiosInstance) => async (): Promise<StakingAPRResponse> => {
return (await instance.get("/apr/v2/staking")).data;
};

export const getAllAPR = async (): Promise<APRResponse> => {
return (await osmosisInstance.get("/apr/v2/all")).data;
};
export const getAllAPR =
(instance: AxiosInstance) => async (): Promise<APRResponse> => {
return (await instance.get("/apr/v2/all")).data;
};

export const getAPR = async ({
poolId,
}: {
poolId: number;
}): Promise<APRResponse> => {
return (await osmosisInstance.get(`/apr/v2/${poolId}`)).data;
};
export const getAPR =
(instance: AxiosInstance) =>
async ({ poolId }: { poolId: number }): Promise<APRResponse> => {
return (await instance.get(`/apr/v2/${poolId}`)).data;
};
47 changes: 23 additions & 24 deletions packages/core/src/apis/osmosisHistorical/fees/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { osmosisInstance } from "../../../common";
import { AxiosInstance } from "axios";
import type {
HistoricalFeeResponse,
PoolFeesResponse,
Expand All @@ -7,30 +7,29 @@ import type {

export type { HistoricalFeeResponse, PoolFeesResponse, TotalFeesResponse };

export const getTotalFees = async (): Promise<TotalFeesResponse> => {
return (await osmosisInstance.get("/fees/v1/total")).data;
};
export const getTotalFees =
(instance: AxiosInstance) => async (): Promise<TotalFeesResponse> => {
return (await instance.get("/fees/v1/total")).data;
};

export const getPoolsFees = async (): Promise<PoolFeesResponse> => {
return (await osmosisInstance.get("/fees/v1/pools")).data;
};
export const getPoolsFees =
(instance: AxiosInstance) => async (): Promise<PoolFeesResponse> => {
return (await instance.get("/fees/v1/pools")).data;
};

export const getPoolFees = async ({
poolId,
}: {
poolId: number;
}): Promise<PoolFeesResponse> => {
return (await osmosisInstance.get(`/fees/v1/${poolId}`)).data;
};
export const getPoolFees =
(instance: AxiosInstance) =>
async ({ poolId }: { poolId: number }): Promise<PoolFeesResponse> => {
return (await instance.get(`/fees/v1/${poolId}`)).data;
};

export const getHistoricalFees = async (): Promise<HistoricalFeeResponse> => {
return (await osmosisInstance.get("/fees/v1/total/historical")).data;
};
export const getHistoricalFees =
(instance: AxiosInstance) => async (): Promise<HistoricalFeeResponse> => {
return (await instance.get("/fees/v1/total/historical")).data;
};

export const getHistoricalFee = async ({
poolId,
}: {
poolId: number;
}): Promise<HistoricalFeeResponse> => {
return (await osmosisInstance.get(`/fees/v1/historical/${poolId}`)).data;
};
export const getHistoricalFee =
(instance: AxiosInstance) =>
async ({ poolId }: { poolId: number }): Promise<HistoricalFeeResponse> => {
return (await instance.get(`/fees/v1/historical/${poolId}`)).data;
};
9 changes: 5 additions & 4 deletions packages/core/src/apis/osmosisHistorical/health/index.ts
Original file line number Diff line number Diff line change
@@ -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<HealthResponse> => {
return (await osmosisInstance.get("/health/v1/check")).data;
};
export const getHealth =
(instance: AxiosInstance) => async (): Promise<HealthResponse> => {
return (await instance.get("/health/v1/check")).data;
};
117 changes: 60 additions & 57 deletions packages/core/src/apis/osmosisHistorical/ibc/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { osmosisInstance } from "../../../common";
import { AxiosInstance } from "axios";
import type {
AllIbcResponse,
IbcDestinationResponse,
Expand All @@ -17,65 +17,68 @@ export type {
IbcSourceResponse,
};

export const getIbcInfo = async (): Promise<IbcInfoResponse> => {
return (await osmosisInstance.get("/ibc/v1/info")).data;
};
export const getIbcInfo =
(instance: AxiosInstance) => async (): Promise<IbcInfoResponse> => {
return (await instance.get("/ibc/v1/info")).data;
};

export const getAllIbc = async ({
dex,
}: {
dex?: string;
}): Promise<AllIbcResponse> => {
return (await osmosisInstance.get("/ibc/v1/all", { params: { dex } })).data;
};
export const getAllIbc =
(instance: AxiosInstance) =>
async ({ dex }: { dex?: string }): Promise<AllIbcResponse> => {
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<IbcSourceDestinationResponse> => {
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<IbcSourceDestinationResponse> => {
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<IbcSourceResponse> => {
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<IbcSourceResponse> => {
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<IbcDestinationResponse> => {
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<IbcDestinationResponse> => {
return (
await instance.get(`/ibc/v1/destination/${destination}`, {
params: { minutes_trigger },
})
).data;
};

export const getIbcRaw = async (): Promise<IbcRawResponse> => {
return (await osmosisInstance.get("/ibc/v1/raw")).data;
};
export const getIbcRaw =
(instance: AxiosInstance) => async (): Promise<IbcRawResponse> => {
return (await instance.get("/ibc/v1/raw")).data;
};
5 changes: 3 additions & 2 deletions packages/core/src/apis/osmosisHistorical/liquidity/index.ts
Original file line number Diff line number Diff line change
@@ -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<LiquidityHistoricalChartResponse> => {
return (await osmosisInstance.get("/liquidity/v2/historical/chart")).data;
return (await instance.get("/liquidity/v2/historical/chart")).data;
};
16 changes: 9 additions & 7 deletions packages/core/src/apis/osmosisHistorical/overview/index.ts
Original file line number Diff line number Diff line change
@@ -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<MetricsResponse> => {
return (await osmosisInstance.get("/overview/v1/metrics")).data;
};
export const getMetrics =
(instance: AxiosInstance) => async (): Promise<MetricsResponse> => {
return (await instance.get("/overview/v1/metrics")).data;
};

export const getMessage = async (): Promise<MessageResponse> => {
return (await osmosisInstance.get("/overview/v1/message")).data;
};
export const getMessage =
(instance: AxiosInstance) => async (): Promise<MessageResponse> => {
return (await instance.get("/overview/v1/message")).data;
};
47 changes: 25 additions & 22 deletions packages/core/src/apis/osmosisHistorical/pairs/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { osmosisInstance } from "../../../common";
import { AxiosInstance } from "axios";
import type {
PairsHistoricalChartParams,
PairsHistoricalChartResponse,
Expand All @@ -11,25 +11,28 @@ export type {
PairsSummaryResponse,
};

export const getPairsSummary = async (): Promise<PairsSummaryResponse> => {
return (await osmosisInstance.get("/pairs/v1/summary")).data;
};
export const getPairsSummary =
(instance: AxiosInstance) => async (): Promise<PairsSummaryResponse> => {
return (await instance.get("/pairs/v1/summary")).data;
};

export const getPairsHistoricalChart = async ({
poolId,
assetIn,
assetOut,
assetType,
range,
}: PairsHistoricalChartParams): Promise<PairsHistoricalChartResponse> => {
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<PairsHistoricalChartResponse> => {
return (
await instance.get(`/pairs/v1/historical/${poolId}/chart`, {
params: {
asset_in: assetIn,
asset_out: assetOut,
asset_type: assetType,
range,
},
})
).data;
};
Loading

0 comments on commit 7397596

Please sign in to comment.