Skip to content

Commit

Permalink
Merge pull request #1127 from oraidex/fix/pools-page-list-token
Browse files Browse the repository at this point in the history
Refactor PoolList and useGetPoolList components to streamline imports…
  • Loading branch information
vuonghuuhung authored Jan 13, 2025
2 parents 2ffedda + 70d3e28 commit 4d97fa5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/pages/Pool-V3/components/PoolList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { BigDecimal, toDisplay, DOGE_BNB_ORAICHAIN_DENOM } from '@oraichain/oraidex-common';
import { BigDecimal, toDisplay } from '@oraichain/oraidex-common';
import { isMobile } from '@walletconnect/browser-utils';
import Loading from 'assets/gif/loading.gif';
import DownIcon from 'assets/icons/down-arrow-v2.svg?react';
import SortDownIcon from 'assets/icons/down_icon.svg?react';
import IconInfo from 'assets/icons/infomationIcon.svg?react';
import UpIcon from 'assets/icons/up-arrow.svg?react';
import SortUpIcon from 'assets/icons/up_icon.svg?react';
import NoDataDark from 'assets/images/NoDataPool.svg?react';
import NoData from 'assets/images/NoDataPoolLight.svg?react';
import classNames from 'classnames';
import LoadingBox from 'components/LoadingBox';
import Pagination from 'components/Pagination';
Expand Down
13 changes: 7 additions & 6 deletions src/pages/Pool-V3/hooks/useGetPoolList.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { parseAssetInfo } from '@oraichain/oraidex-common';
import { PoolWithPoolKey } from '@oraichain/oraidex-contracts-sdk/build/OraiswapV3.types';
import { useQuery } from '@tanstack/react-query';
import { inspectTokenFromOraiCommonApi } from 'helper';
import { CoinGeckoPrices } from 'hooks/useCoingecko';
import SingletonOraiswapV3 from 'libs/contractSingleton';
import { getPools } from 'pages/Pools/hooks';
import { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { addToOraichainTokens } from 'reducer/token';
import { RootState, store } from 'store/configure';
import { RootState } from 'store/configure';
import { PoolInfoResponse } from 'types/pool';
import { calcPrice } from '../components/PriceRangePlot/utils';
import { extractAddress, formatPoolData } from '../helpers/format';
import { inspectTokenFromOraiCommonApi } from 'helper';

export const useGetPoolList = (coingeckoPrices: CoinGeckoPrices<string>) => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -92,20 +92,21 @@ export const useGetPoolList = (coingeckoPrices: CoinGeckoPrices<string>) => {
if (tokenAddresses.has(HMSTR_DENOM)) tokenAddresses.delete(HMSTR_DENOM);
if (tokenAddresses.size > 0) {
const tokenAddressesArray = [...tokenAddresses];
const tokenChunks = [];
const tokenChunksPromise = [];
for (let i = 0; i < tokenAddressesArray.length; i += 30) {
const chunk = tokenAddressesArray.slice(i, i + 30);
tokenChunks.push(inspectTokenFromOraiCommonApi(chunk));
tokenChunksPromise.push(inspectTokenFromOraiCommonApi(chunk));
}
dispatch(addToOraichainTokens(tokenChunks.flat()));
const tokens = await Promise.all(tokenChunksPromise);
dispatch(addToOraichainTokens(tokens.flat()));
}

const listPools = (poolList || []).map((p) => formatPoolData(p));

const fmtPools = (await Promise.all(listPools)).filter((e) => e.isValid);
setDataPool(fmtPools);
})();
}, [poolList, coingeckoPrices]);
}, [poolList]);

return {
poolList: dataPool || [],
Expand Down

0 comments on commit 4d97fa5

Please sign in to comment.