From 9e562e5d2330a5dffd534bad3db0806d1f5e99cc Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Thu, 26 Sep 2024 13:38:44 +0330 Subject: [PATCH] Always get GIV price from gnosis subgraph related to https://github.com/Giveth/giveth-dapps-v2/issues/4680 --- src/components/modals/GIVdropHarvestModal.tsx | 2 +- src/hooks/useGivPrice.tsx | 4 ++-- src/hooks/useTokenPrice.tsx | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/modals/GIVdropHarvestModal.tsx b/src/components/modals/GIVdropHarvestModal.tsx index 46d0e5681b..f0ed5d0db5 100644 --- a/src/components/modals/GIVdropHarvestModal.tsx +++ b/src/components/modals/GIVdropHarvestModal.tsx @@ -90,7 +90,7 @@ export const GIVdropHarvestModal: FC = ({ const chainId = chain?.id; const sdh = new SubgraphDataHelper(currentValues.data); const givTokenDistroBalance = sdh.getGIVTokenDistroBalance(); - const { data: givPrice } = useFetchGIVPrice(chainId); + const { data: givPrice } = useFetchGIVPrice(); useEffect(() => { const bnGIVback = BigInt(givTokenDistroBalance.givback); diff --git a/src/hooks/useGivPrice.tsx b/src/hooks/useGivPrice.tsx index f90e944293..b0153d89de 100644 --- a/src/hooks/useGivPrice.tsx +++ b/src/hooks/useGivPrice.tsx @@ -2,8 +2,8 @@ import { useQuery } from '@tanstack/react-query'; import config from '@/configuration'; import { fetchGnosisTokenPrices } from '@/services/token'; -export const useFetchGIVPrice = (chainId?: number) => { - const _chainId = chainId || config.GNOSIS_NETWORK_NUMBER; +export const useFetchGIVPrice = () => { + const _chainId = config.GNOSIS_NETWORK_NUMBER; const tokenAddress = config.EVM_NETWORKS_CONFIG[_chainId]?.tokenAddressOnUniswapV2; return useQuery({ diff --git a/src/hooks/useTokenPrice.tsx b/src/hooks/useTokenPrice.tsx index 91efa2286c..18d2d351cd 100644 --- a/src/hooks/useTokenPrice.tsx +++ b/src/hooks/useTokenPrice.tsx @@ -32,7 +32,7 @@ export const useTokenPrice = (token?: ITokenPrice) => { const { walletChainType } = useGeneralWallet(); const { chain } = useAccount(); const chainId = chain?.id; - const { data: givPrice } = useFetchGIVPrice(chainId); + const { data: givPrice } = useFetchGIVPrice(); const givTokenPrice = givPrice ? new BigNumber(givPrice).toNumber() : 0; const isMainnet = chainId === config.MAINNET_NETWORK_NUMBER; @@ -44,8 +44,8 @@ export const useTokenPrice = (token?: ITokenPrice) => { stableCoins.includes(token.symbol.toUpperCase())) ) { setTokenPrice(1); - } else if (token?.symbol === 'GIV') { - setTokenPrice(givTokenPrice || 0); + } else if (token?.symbol === 'GIV' && givTokenPrice) { + setTokenPrice(givTokenPrice); } else if (token?.coingeckoId) { setTokenPrice( (await fetchPriceWithCoingeckoId(token.coingeckoId)) || 0,