From 12611eebcfc5aebd0fac4dc10c1e16049e740b1f Mon Sep 17 00:00:00 2001 From: totop716 Date: Thu, 29 Jun 2023 10:46:03 -0400 Subject: [PATCH] fix reward amount after undeposit from the farm and remove unused gasupdater --- src/App.tsx | 2 -- src/hooks/useGasPrice.ts | 27 ------------------------ src/hooks/useIncentiveSubgraph.ts | 4 ++-- src/state/application/gasUpdater.ts | 32 ----------------------------- 4 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 src/state/application/gasUpdater.ts diff --git a/src/App.tsx b/src/App.tsx index 884e811f5..b84d303b6 100755 --- a/src/App.tsx +++ b/src/App.tsx @@ -62,7 +62,6 @@ import 'slick-carousel/slick/slick-theme.css'; import './i18n'; import { mainTheme } from './theme'; import Background from 'layouts/Background'; -import GasUpdater from 'state/application/gasUpdater'; import { RedirectExternal } from 'components/RedirectExternal/RedirectExternal'; import NotFound404Page from 'pages/NotFound404Page'; @@ -98,7 +97,6 @@ function Updaters() { - ); } diff --git a/src/hooks/useGasPrice.ts b/src/hooks/useGasPrice.ts index 39ee10f42..3b9be945c 100644 --- a/src/hooks/useGasPrice.ts +++ b/src/hooks/useGasPrice.ts @@ -1,28 +1 @@ -import { useState } from 'react'; - export const GAS_PRICE_MULTIPLIER = 1_000_000_000; - -export function useGasPrice() { - const [gasPrice, setGasPrice] = useState<{ - fetched: null | number; - override: boolean; - }>({ fetched: null, override: false }); - const [gasPriceLoading, setGasPriceLoading] = useState(false); - - async function fetchGasPrice() { - setGasPriceLoading(true); - - try { - const gasPriceReq = await fetch( - 'https://gasstation-mainnet.matic.network/', - ); - const { standard } = await gasPriceReq.json(); - setGasPrice({ fetched: standard, override: standard < 36 }); - } catch (err) { - console.error('Gas price fetching failed', err.code, err.message); - } - setGasPriceLoading(false); - } - - return { fetchGasPrice, gasPrice, gasPriceLoading }; -} diff --git a/src/hooks/useIncentiveSubgraph.ts b/src/hooks/useIncentiveSubgraph.ts index d022c5816..1e6be6e62 100644 --- a/src/hooks/useIncentiveSubgraph.ts +++ b/src/hooks/useIncentiveSubgraph.ts @@ -491,10 +491,10 @@ export function useFarmingSubgraph() { pool: newPool, eternalEarned: rewardRes ? formatUnits(rewardRes.reward, _rewardToken.decimals) - : undefined, + : 0, eternalBonusEarned: rewardRes ? formatUnits(rewardRes.bonusReward, _bonusRewardToken.decimals) - : undefined, + : 0, }; } else { const res = await fetch( diff --git a/src/state/application/gasUpdater.ts b/src/state/application/gasUpdater.ts deleted file mode 100644 index 333e70b36..000000000 --- a/src/state/application/gasUpdater.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { useEffect } from 'react'; -import { useGasPrice } from '../../hooks/useGasPrice'; -import { useActiveWeb3React } from 'hooks'; - -import { updateGasPrice } from './actions'; -import { ChainId } from '@uniswap/sdk'; -import { useAppDispatch, useAppSelector } from 'state'; - -export default function GasUpdater(): null { - const dispatch = useAppDispatch(); - - const { chainId } = useActiveWeb3React(); - - const block = useAppSelector((state) => { - return state.application.blockNumber[chainId ?? ChainId.MATIC]; - }); - - const { fetchGasPrice, gasPrice, gasPriceLoading } = useGasPrice(); - - useEffect(() => { - fetchGasPrice(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [block]); - - useEffect(() => { - if (!gasPrice.fetched) return; - dispatch(updateGasPrice(gasPrice)); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [gasPrice, gasPriceLoading]); - - return null; -}