Skip to content

Commit

Permalink
Merge pull request #4789 from Giveth/4680_fix_giv_price_on_polygon_zk…
Browse files Browse the repository at this point in the history
…evm_Chain

Hotfix fix getting giv price on polygon-zkevm chain
  • Loading branch information
mohammadranjbarz authored Sep 26, 2024
2 parents f7179a7 + 9e562e5 commit cb2a533
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/modals/GIVdropHarvestModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const GIVdropHarvestModal: FC<IGIVdropHarvestModal> = ({
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);
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useGivPrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useTokenPrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down

0 comments on commit cb2a533

Please sign in to comment.