diff --git a/packages/server/src/queries/complex/orderbooks/index.ts b/packages/server/src/queries/complex/orderbooks/index.ts index 60b3f0f99d..25641c026e 100644 --- a/packages/server/src/queries/complex/orderbooks/index.ts +++ b/packages/server/src/queries/complex/orderbooks/index.ts @@ -2,5 +2,4 @@ export * from "./active-orders"; export * from "./denoms"; export * from "./maker-fee"; export * from "./orderbook-state"; -export * from "./spot-price"; export * from "./tick-state"; diff --git a/packages/server/src/queries/complex/orderbooks/spot-price.ts b/packages/server/src/queries/complex/orderbooks/spot-price.ts deleted file mode 100644 index 1bc94fce99..0000000000 --- a/packages/server/src/queries/complex/orderbooks/spot-price.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Dec } from "@keplr-wallet/unit"; -import { Chain } from "@osmosis-labs/types"; -import cachified, { CacheEntry } from "cachified"; -import { LRUCache } from "lru-cache"; - -import { DEFAULT_LRU_OPTIONS } from "../../../utils/cache"; -import { queryOrderbookSpotPrice } from "../../osmosis"; - -const orderbookSpotPriceCache = new LRUCache( - DEFAULT_LRU_OPTIONS -); - -export function getOrderbookSpotPrice({ - orderbookAddress, - chainList, - quoteAssetDenom, - baseAssetDenom, -}: { - orderbookAddress: string; - quoteAssetDenom: string; - baseAssetDenom: string; - chainList: Chain[]; -}) { - return cachified({ - cache: orderbookSpotPriceCache, - key: `orderbookSpotPrice-${orderbookAddress}-${quoteAssetDenom}-${baseAssetDenom}`, - ttl: 1000 * 60 * 2, // 2 minutes - getFreshValue: () => - queryOrderbookSpotPrice({ - orderbookAddress, - chainList, - quoteAssetDenom, - baseAssetDenom, - }).then(({ data }) => new Dec(data.spot_price)), - }); -} diff --git a/packages/trpc/src/orderbook-router.ts b/packages/trpc/src/orderbook-router.ts index 2c9858c46e..3755414f31 100644 --- a/packages/trpc/src/orderbook-router.ts +++ b/packages/trpc/src/orderbook-router.ts @@ -5,7 +5,6 @@ import { getOrderbookActiveOrders, getOrderbookDenoms, getOrderbookMakerFee, - getOrderbookSpotPrice, getOrderbookState, getOrderbookTickState, getOrderbookTickUnrealizedCancels, @@ -285,26 +284,6 @@ export const orderbookRouter = createTRPCRouter({ limit: input.limit, }); }), - getSpotPrice: publicProcedure - .input( - z - .object({ - quoteAssetDenom: z.string(), - baseAssetDenom: z.string(), - }) - .required() - .and(OsmoAddressSchema.required()) - ) - .query(async ({ input, ctx }) => { - const { quoteAssetDenom, baseAssetDenom, osmoAddress } = input; - const spotPrice = await getOrderbookSpotPrice({ - orderbookAddress: osmoAddress, - quoteAssetDenom: quoteAssetDenom, - baseAssetDenom: baseAssetDenom, - chainList: ctx.chainList, - }); - return spotPrice; - }), getOrderbookState: publicProcedure .input(OsmoAddressSchema.required()) .query(async ({ input, ctx }) => { diff --git a/packages/web/hooks/limit-orders/use-orderbook.ts b/packages/web/hooks/limit-orders/use-orderbook.ts index b10e1213d9..54da0d7be9 100644 --- a/packages/web/hooks/limit-orders/use-orderbook.ts +++ b/packages/web/hooks/limit-orders/use-orderbook.ts @@ -302,38 +302,3 @@ export const useOrderbookAllActiveOrders = ({ isFetching, }; }; - -/** - * Hook to fetch the current spot price of a given pair from an orderbook. - * - * The spot price is determined by the provided quote asset and base asset. - * - * For a BID the quote asset is the base asset and the base asset is the quote asset of the orderbook. - * - * For an ASK the quote asset is the quote asset and the base asset is the base asset of the orderbook. - * - * @param {string} orderbookAddress - The contract address of the orderbook. - * @param {string} quoteAssetDenom - The token out asset denom. - * @param {string} baseAssetDenom - The token in asset denom. - * @returns {Object} An object containing the spot price and the loading state. - */ -export const useOrderbookSpotPrice = ({ - orderbookAddress, - quoteAssetDenom, - baseAssetDenom, -}: { - orderbookAddress: string; - quoteAssetDenom: string; - baseAssetDenom: string; -}) => { - const { data: spotPrice, isLoading } = - api.edge.orderbooks.getSpotPrice.useQuery({ - osmoAddress: orderbookAddress, - quoteAssetDenom, - baseAssetDenom, - }); - return { - spotPrice, - isLoading, - }; -};