Skip to content

Commit

Permalink
fix(app): convert price for space-pussy (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimakorzhovnik authored Sep 6, 2024
1 parent 9fc4385 commit b477119
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/hooks/warp/api/useConnectBostrom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { Networks } from 'src/types/networks';
function useConnectBostrom() {
const { data: queryClient } = useQuery({
queryKey: ['cyberClient', 'connect', Networks.BOSTROM],
queryFn: async () => {
return CyberClient.connect(RPC_URL);
},
queryFn: () => CyberClient.connect(RPC_URL),
enabled: CHAIN_ID !== Networks.BOSTROM,
});

Expand Down
4 changes: 1 addition & 3 deletions src/hooks/warp/api/useGetPoolsWarp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { Networks } from 'src/types/networks';
function useGetPoolsWarp(queryClient?: CyberClient) {
const { data } = useQuery({
queryKey: ['useFindPool', 'pools', Networks.BOSTROM],
queryFn: async () => {
return queryClient?.pools() as Option<QueryLiquidityPoolsResponse>;
},
queryFn: () => queryClient?.pools() as Option<QueryLiquidityPoolsResponse>,
enabled: Boolean(queryClient),
});

Expand Down
15 changes: 7 additions & 8 deletions src/hooks/warp/useConvertMarketData.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import { useEffect, useState } from 'react';
import { useMemo } from 'react';
import { ObjKeyValue } from 'src/types/data';
import BigNumber from 'bignumber.js';
import { DENOM_LIQUID } from 'src/constants/config';
import useFindPoolPrice from './useFindPoolPrice';

const LIQUID_PRICE = 1;

function useConvertMarketData(marketData: ObjKeyValue) {
const [resultData, setResultData] = useState({});
const poolPrice = useFindPoolPrice();

useEffect(() => {
const resultData = useMemo(() => {
if (!poolPrice || !Object.keys(marketData).length) {
return;
return {};
}

const reduceMarketData = Object.entries(marketData).reduce(
return Object.entries(marketData).reduce(
(acc, [key, value]) => ({
...acc,
[key]:
key === DENOM_LIQUID
? 1
? LIQUID_PRICE
: new BigNumber(value).multipliedBy(poolPrice).toNumber(),
}),
{}
);

setResultData(reduceMarketData);
}, [poolPrice, marketData]);

return resultData;
Expand Down

0 comments on commit b477119

Please sign in to comment.