From e226bec4f5c436a4323d28565e28f2fdda3b9598 Mon Sep 17 00:00:00 2001 From: asalef10 Date: Thu, 5 Jun 2025 19:54:05 +0300 Subject: [PATCH 1/8] Add total staked display in RewardsCard component and implement total staked fetching in useVesting hook --- .../stakingPage/components/RewardsCard.tsx | 30 +++++++++++++++++++ src/pages/stakingPage/hooks/useVesting.ts | 27 +++++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/pages/stakingPage/components/RewardsCard.tsx b/src/pages/stakingPage/components/RewardsCard.tsx index 9051f46..66aa1fc 100644 --- a/src/pages/stakingPage/components/RewardsCard.tsx +++ b/src/pages/stakingPage/components/RewardsCard.tsx @@ -6,6 +6,8 @@ import { GrixLogo } from '@/components/commons/Logo'; import { EthLogo } from '@/components/commons/Logo/EthLogo'; import { claim, compound } from '@/web3Config/staking/hooks'; +import { useVesting } from '../hooks/useVesting'; + type RewardsCardProps = { data: { claimable: string; @@ -27,6 +29,7 @@ export const RewardsCard = ({ data, refetchData }: RewardsCardProps): JSX.Elemen const [isClaiming, setIsClaiming] = useState(false); const [isCompounding, setIsCompounding] = useState(false); const [grixPrice, setGrixPrice] = useState(null); + const { totalStaked } = useVesting(); const toast = useToast(); // Fetch GRIX price from CoinGecko @@ -143,6 +146,32 @@ export const RewardsCard = ({ data, refetchData }: RewardsCardProps): JSX.Elemen )} + + + + + + Total Staked + + + + {Number(totalStaked).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })}{' '} + GRIX + {grixPrice && Number(totalStaked) > 0 && ( + +  ($ + {(Number(totalStaked) * grixPrice).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + ) + + )} + + + ); diff --git a/src/pages/stakingPage/hooks/useVesting.ts b/src/pages/stakingPage/hooks/useVesting.ts index 32063ea..a2cc58b 100644 --- a/src/pages/stakingPage/hooks/useVesting.ts +++ b/src/pages/stakingPage/hooks/useVesting.ts @@ -1,7 +1,10 @@ import { useCallback, useEffect, useState } from 'react'; -import { parseEther } from 'viem'; +import { erc20Abi, formatEther, parseEther } from 'viem'; import { useAccount } from 'wagmi'; +import { readContract } from 'wagmi/actions'; +import { normalizeAddress } from '@/utils/web3Util'; +import { wagmiConfig } from '@/web3Config/reownConfig'; import { stakingContracts } from '@/web3Config/staking/config'; import { approveVesting, @@ -24,8 +27,26 @@ export const useVesting = () => { const [esGrixBalance, setEsGrixBalance] = useState('0'); const [grixBalance, setGrixBalance] = useState('0'); const [vestingData, setVestingData] = useState(null); + const [totalStaked, setTotalStaked] = useState('0'); const [isLoading, setIsLoading] = useState(false); + const fetchTotalStaked = useCallback(async () => { + try { + // Get total GRIX tokens staked in the vester contract + const balance = await readContract(wagmiConfig, { + abi: erc20Abi, + address: normalizeAddress(stakingContracts.grixToken.address), + functionName: 'balanceOf', + args: [normalizeAddress(stakingContracts.rewardTracker.address)], + }); + + const amount = formatEther(balance); + setTotalStaked(amount); + } catch (error) { + setTotalStaked('0'); + } + }, []); + const fetchVestingData = useCallback(async () => { if (!address) return; @@ -35,6 +56,7 @@ export const useVesting = () => { getTokenBalance(stakingContracts.esGRIXToken.address, address), getTokenBalance(stakingContracts.grixToken.address, address), getVestingData(address), + fetchTotalStaked(), ]); setVestingAllowance(allowance.toString()); @@ -45,7 +67,7 @@ export const useVesting = () => { setVestingData(null); throw error; } - }, [address]); + }, [address, fetchTotalStaked]); useEffect(() => { void fetchVestingData(); @@ -80,6 +102,7 @@ export const useVesting = () => { esGrixBalance, grixBalance, vestingData, + totalStaked, isLoading, handleVest, fetchVestingData, From f448fc6473c1dea23f5fa3cc15be0cdd7682b703 Mon Sep 17 00:00:00 2001 From: asalef10 Date: Thu, 5 Jun 2025 20:19:43 +0300 Subject: [PATCH 2/8] refactor --- src/pages/stakingPage/components/RewardsCard.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/stakingPage/components/RewardsCard.tsx b/src/pages/stakingPage/components/RewardsCard.tsx index 66aa1fc..df17b6f 100644 --- a/src/pages/stakingPage/components/RewardsCard.tsx +++ b/src/pages/stakingPage/components/RewardsCard.tsx @@ -156,8 +156,8 @@ export const RewardsCard = ({ data, refetchData }: RewardsCardProps): JSX.Elemen {Number(totalStaked).toLocaleString(undefined, { - minimumFractionDigits: 2, - maximumFractionDigits: 2, + minimumFractionDigits: 1, + maximumFractionDigits: 1, })}{' '} GRIX {grixPrice && Number(totalStaked) > 0 && ( From fad39b58d67129748616990f7e2e883325af3c88 Mon Sep 17 00:00:00 2001 From: asalef10 Date: Thu, 5 Jun 2025 20:32:20 +0300 Subject: [PATCH 3/8] lint --- src/pages/stakingPage/components/RewardsCard.tsx | 1 - src/pages/stakingPage/hooks/useVesting.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/stakingPage/components/RewardsCard.tsx b/src/pages/stakingPage/components/RewardsCard.tsx index df17b6f..159680f 100644 --- a/src/pages/stakingPage/components/RewardsCard.tsx +++ b/src/pages/stakingPage/components/RewardsCard.tsx @@ -204,7 +204,6 @@ export const RewardsCard = ({ data, refetchData }: RewardsCardProps): JSX.Elemen > Compound - ); diff --git a/src/pages/stakingPage/hooks/useVesting.ts b/src/pages/stakingPage/hooks/useVesting.ts index a2cc58b..4c57edc 100644 --- a/src/pages/stakingPage/hooks/useVesting.ts +++ b/src/pages/stakingPage/hooks/useVesting.ts @@ -39,7 +39,7 @@ export const useVesting = () => { functionName: 'balanceOf', args: [normalizeAddress(stakingContracts.rewardTracker.address)], }); - + const amount = formatEther(balance); setTotalStaked(amount); } catch (error) { From 84ac6fd2aee017e3429291f6cdd9eb9272fb9467 Mon Sep 17 00:00:00 2001 From: asalef10 Date: Mon, 9 Jun 2025 17:23:46 +0300 Subject: [PATCH 4/8] update apr calculate --- src/web3Config/staking/hooks.ts | 71 +++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/src/web3Config/staking/hooks.ts b/src/web3Config/staking/hooks.ts index 2e56df2..a23d5d7 100644 --- a/src/web3Config/staking/hooks.ts +++ b/src/web3Config/staking/hooks.ts @@ -250,32 +250,53 @@ export const getTotalStaked = async (userAddress: string) => { }; //Staking APR Formula = (ETH rewards + esGS emissions annualized) / (Total GS + esGS staked) * 100 export const calculateAPR = async () => { - // Get total staked amount using totalSupply from the reward tracker - const totalStaked = await readContract(wagmiConfig, { - abi: rewardTrackerAbi, - address: normalizeAddress(stakingContracts.rewardTracker.address), - functionName: 'totalSupply', - args: [], - }); - - if (totalStaked === 0n) return 0; - - // Get ETH reward rate from rewardDistributor - const ethRewardRate = await getTokenPerInterval(); - - // Get esGrix emission rate (assuming it's from the reward distributor as well) - const esGrixRewardRate = await getTokenPerInterval(); - - // Calculate annual rewards (seconds in a year * tokens per interval) - const SECONDS_PER_YEAR = 365n * 24n * 60n * 60n; - const annualEthRewards = ethRewardRate * SECONDS_PER_YEAR; - const annualEsGrixRewards = esGrixRewardRate * SECONDS_PER_YEAR; - const totalAnnualRewards = annualEthRewards + annualEsGrixRewards; - - // Calculate APR: (totalAnnualRewards / totalStaked) * 100 - const apr = (totalAnnualRewards * 100n) / (totalStaked as bigint); + try { + // Get total staked amount using totalSupply from the reward tracker + const totalStaked = await readContract(wagmiConfig, { + abi: rewardTrackerAbi, + address: normalizeAddress(stakingContracts.rewardTracker.address), + functionName: 'totalSupply', + args: [], + }); - return Number(apr); + if (totalStaked === 0n) return 0; + + // Get core tracker to access fee distributor for ETH rewards + const coreTracker = await getCoreTracker(); + + // Get esGRIX emission rate from the main reward distributor + const esGrixRewardRate = await getTokenPerInterval(); + + // Get ETH reward rate from the fee distributor + let ethRewardRate = 0n; + if (coreTracker.feeDistributor && coreTracker.feeDistributor !== '0x0000000000000000000000000000000000000000') { + try { + ethRewardRate = await readContract(wagmiConfig, { + abi: rewardDistributorAbi, + address: normalizeAddress(coreTracker.feeDistributor), + functionName: 'tokensPerInterval', + args: [], + }); + } catch (error) { + console.error('Error fetching ETH reward rate:', error); + } + } + + // Calculate annual rewards (seconds in a year * tokens per interval) + const SECONDS_PER_YEAR = 365n * 24n * 60n * 60n; + const annualEthRewards = ethRewardRate * SECONDS_PER_YEAR; + const annualEsGrixRewards = esGrixRewardRate * SECONDS_PER_YEAR; + const totalAnnualRewards = annualEthRewards + annualEsGrixRewards; + + // Calculate APR: (totalAnnualRewards / totalStaked) * 100 + const apr = (totalAnnualRewards * 10000n) / (totalStaked as bigint); + + // Convert to percentage with 2 decimal places + return Number(apr) / 100; + } catch (error) { + console.error('Error calculating APR:', error); + return 0; + } }; // Add vesting allowance check export const checkVestingAllowance = async (owner: string, token: string) => { From 7eb936d12d07d1fc62abc8c21b0884a7f72b17f2 Mon Sep 17 00:00:00 2001 From: asalef10 Date: Mon, 9 Jun 2025 17:35:21 +0300 Subject: [PATCH 5/8] Use grix api token --- src/pages/stakingPage/components/RewardsCard.tsx | 11 ++++++++--- src/pages/stakingPage/components/VestingModal.tsx | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/pages/stakingPage/components/RewardsCard.tsx b/src/pages/stakingPage/components/RewardsCard.tsx index 159680f..ed32b58 100644 --- a/src/pages/stakingPage/components/RewardsCard.tsx +++ b/src/pages/stakingPage/components/RewardsCard.tsx @@ -36,9 +36,14 @@ export const RewardsCard = ({ data, refetchData }: RewardsCardProps): JSX.Elemen useEffect(() => { const fetchPrice = async () => { try { - const res = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=grix&vs_currencies=usd'); - const json = (await res.json()) as DexScreenerResponse; - const price = json.grix.usd; + const res = await fetch('https://z61hgkwkn8.execute-api.us-east-1.amazonaws.com/dev/assetprice?asset=GRIX', { + headers: { + 'x-api-key': import.meta.env.VITE_GRIX_API_KEY, + origin: 'https://app.grix.finance', + }, + }); + const json = await res.json(); + const price = json.assetPrice; setGrixPrice(price); } catch { setGrixPrice(null); diff --git a/src/pages/stakingPage/components/VestingModal.tsx b/src/pages/stakingPage/components/VestingModal.tsx index e5344a7..a93f552 100644 --- a/src/pages/stakingPage/components/VestingModal.tsx +++ b/src/pages/stakingPage/components/VestingModal.tsx @@ -52,9 +52,14 @@ export const VestingModal = ({ useEffect(() => { const fetchPrice = async () => { try { - const res = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=grix&vs_currencies=usd'); - const json = (await res.json()) as DexScreenerResponse; - const price = json.grix.usd; + const res = await fetch('https://z61hgkwkn8.execute-api.us-east-1.amazonaws.com/dev/assetprice?asset=GRIX', { + headers: { + 'x-api-key': import.meta.env.VITE_GRIX_API_KEY, + origin: 'https://app.grix.finance', + }, + }); + const json = await res.json(); + const price = json.assetPrice; setGrixPrice(price); } catch { setGrixPrice(null); From 00695ca15eb20bfe1f8db474f13911dd8dad6970 Mon Sep 17 00:00:00 2001 From: asalef10 Date: Mon, 9 Jun 2025 22:19:06 +0300 Subject: [PATCH 6/8] Add total staked and GRIX price fetching to StakingCard component - Implemented functions to fetch total GRIX and esGRIX staked amounts. - Added state management for total staked amount and GRIX price. - Updated data fetching logic to include total staked and GRIX price. - Enhanced StakingCardContent to display total staked amount and its value in USD. --- .../stakingPage/components/StakingCard.tsx | 46 +++++++++++++++++-- .../components/StakingCardContent.tsx | 28 +++++++++++ src/web3Config/staking/hooks.ts | 30 ++++++++++++ 3 files changed, 101 insertions(+), 3 deletions(-) diff --git a/src/pages/stakingPage/components/StakingCard.tsx b/src/pages/stakingPage/components/StakingCard.tsx index 7f32ae3..1a785a9 100644 --- a/src/pages/stakingPage/components/StakingCard.tsx +++ b/src/pages/stakingPage/components/StakingCard.tsx @@ -11,6 +11,8 @@ import { getEsGrixStakedAmount, getStakedAmount, getTokenBalance, + getTotalEsGrixStaked, + getTotalGrixStaked, stakeEsGRIX, stakeGRIX, unstakeEsGRIX, @@ -42,6 +44,8 @@ export const StakingCard: React.FC = ({ const [needsApproval, setNeedsApproval] = useState(true); const [availableBalance, setAvailableBalance] = useState('0'); const [stakedAmount, setStakedAmount] = useState('0'); + const [totalStakedInProtocol, setTotalStakedInProtocol] = useState('0'); + const [grixPrice, setGrixPrice] = useState(null); const [apr, setApr] = useState(0); const toast = useToast(); const tokenAddress = type === 'gx' ? stakingContracts.grixToken.address : stakingContracts.esGRIXToken.address; @@ -90,19 +94,53 @@ export const StakingCard: React.FC = ({ setApr(calculatedAPR); }, []); + const fetchTotalStaked = useCallback(async () => { + try { + if (type === 'gx') { + const total = await getTotalGrixStaked(); + setTotalStakedInProtocol(total); + } else { + const total = await getTotalEsGrixStaked(); + setTotalStakedInProtocol(total); + } + } catch (error) { + setTotalStakedInProtocol('0'); + } + }, [type]); + + const fetchGrixPrice = useCallback(async () => { + try { + const res = await fetch('https://z61hgkwkn8.execute-api.us-east-1.amazonaws.com/dev/assetprice?asset=GRIX', { + headers: { + 'x-api-key': import.meta.env.VITE_GRIX_API_KEY, + origin: 'https://app.grix.finance', + }, + }); + const json = await res.json(); + const price = json.assetPrice; + setGrixPrice(price); + } catch { + setGrixPrice(null); + } + }, []); + useEffect(() => { void fetchBalance(); void fetchStakedAmount(); void fetchAPR(); + void fetchTotalStaked(); + void fetchGrixPrice(); const interval = setInterval(() => { void fetchBalance(); void fetchStakedAmount(); void fetchAPR(); + void fetchTotalStaked(); + void fetchGrixPrice(); }, 30000); return () => clearInterval(interval); - }, [fetchBalance, fetchStakedAmount, fetchAPR, refreshTrigger]); + }, [fetchBalance, fetchStakedAmount, fetchAPR, fetchTotalStaked, fetchGrixPrice, refreshTrigger]); const isAmountValid = useCallback(() => { if (!amount) return false; @@ -155,12 +193,12 @@ export const StakingCard: React.FC = ({ const refreshAllData = useCallback( async (triggerParentRefresh = true) => { - await Promise.all([fetchBalance(), fetchStakedAmount(), fetchAPR()]); + await Promise.all([fetchBalance(), fetchStakedAmount(), fetchAPR(), fetchTotalStaked(), fetchGrixPrice()]); if (triggerParentRefresh) { onActionComplete(); } }, - [fetchBalance, fetchStakedAmount, fetchAPR, onActionComplete] + [fetchBalance, fetchStakedAmount, fetchAPR, fetchTotalStaked, fetchGrixPrice, onActionComplete] ); useEffect(() => { @@ -238,6 +276,8 @@ export const StakingCard: React.FC = ({ description={description} stakedAmount={stakedAmount} availableBalance={availableBalance} + totalStakedInProtocol={totalStakedInProtocol} + grixPrice={grixPrice} apr={apr} amount={amount} handleInputChange={handleInputChange} diff --git a/src/pages/stakingPage/components/StakingCardContent.tsx b/src/pages/stakingPage/components/StakingCardContent.tsx index a1e2c47..bd61414 100644 --- a/src/pages/stakingPage/components/StakingCardContent.tsx +++ b/src/pages/stakingPage/components/StakingCardContent.tsx @@ -12,6 +12,8 @@ type StakingCardContentProps = { description: string; stakedAmount: string; availableBalance: string; + totalStakedInProtocol: string; + grixPrice: number | null; apr: number; amount: string; handleInputChange: (e: React.ChangeEvent) => void; @@ -33,6 +35,8 @@ export const StakingCardContent: React.FC = ({ description, stakedAmount, availableBalance, + totalStakedInProtocol, + grixPrice, apr, amount, handleInputChange, @@ -115,6 +119,30 @@ export const StakingCardContent: React.FC = ({ {apr.toFixed(2)}% + + + + Total Staked + + + + {Number(totalStakedInProtocol).toLocaleString(undefined, { + minimumFractionDigits: 1, + maximumFractionDigits: 1, + })} + + {grixPrice && Number(totalStakedInProtocol) > 0 && ( + + ($ + {(Number(totalStakedInProtocol) * grixPrice).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + ) + + )} + + diff --git a/src/web3Config/staking/hooks.ts b/src/web3Config/staking/hooks.ts index a23d5d7..68d7c26 100644 --- a/src/web3Config/staking/hooks.ts +++ b/src/web3Config/staking/hooks.ts @@ -185,6 +185,36 @@ export const getStakedAmount = async (userAddress: string) => { } }; +// Get total GRIX staked in the protocol +export const getTotalGrixStaked = async () => { + try { + const balance = await readContract(wagmiConfig, { + abi: erc20Abi, + address: normalizeAddress(stakingContracts.grixToken.address), + functionName: 'balanceOf', + args: [normalizeAddress(stakingContracts.rewardTracker.address)], + }); + return formatEther(balance); + } catch (error) { + return '0'; + } +}; + +// Get total esGRIX staked in the protocol +export const getTotalEsGrixStaked = async () => { + try { + const balance = await readContract(wagmiConfig, { + abi: erc20Abi, + address: normalizeAddress(stakingContracts.esGRIXToken.address), + functionName: 'balanceOf', + args: [normalizeAddress(stakingContracts.rewardTracker.address)], + }); + return formatEther(balance); + } catch (error) { + return '0'; + } +}; + // Update the getEsGrixStakedAmount function to correctly fetch esGRIX staked amount export const getEsGrixStakedAmount = async (userAddress: string) => { try { From 338a687d5636ecb371c3d53c8a877dd5cf1ba1d2 Mon Sep 17 00:00:00 2001 From: asalef10 Date: Mon, 9 Jun 2025 22:29:19 +0300 Subject: [PATCH 7/8] lint --- src/pages/stakingPage/components/RewardsCard.tsx | 9 ++------- src/pages/stakingPage/components/StakingCard.tsx | 3 ++- src/pages/stakingPage/components/VestingModal.tsx | 9 ++------- src/types/api.ts | 5 +++++ src/web3Config/staking/hooks.ts | 8 ++++---- 5 files changed, 15 insertions(+), 19 deletions(-) create mode 100644 src/types/api.ts diff --git a/src/pages/stakingPage/components/RewardsCard.tsx b/src/pages/stakingPage/components/RewardsCard.tsx index ed32b58..65ba5c7 100644 --- a/src/pages/stakingPage/components/RewardsCard.tsx +++ b/src/pages/stakingPage/components/RewardsCard.tsx @@ -4,6 +4,7 @@ import { useAccount } from 'wagmi'; import { GrixLogo } from '@/components/commons/Logo'; import { EthLogo } from '@/components/commons/Logo/EthLogo'; +import { AssetPriceResponse } from '@/types/api'; import { claim, compound } from '@/web3Config/staking/hooks'; import { useVesting } from '../hooks/useVesting'; @@ -18,12 +19,6 @@ type RewardsCardProps = { refetchData: () => Promise; }; -type DexScreenerResponse = { - grix: { - usd: number; - }; -}; - export const RewardsCard = ({ data, refetchData }: RewardsCardProps): JSX.Element => { const { address } = useAccount(); const [isClaiming, setIsClaiming] = useState(false); @@ -42,7 +37,7 @@ export const RewardsCard = ({ data, refetchData }: RewardsCardProps): JSX.Elemen origin: 'https://app.grix.finance', }, }); - const json = await res.json(); + const json = (await res.json()) as AssetPriceResponse; const price = json.assetPrice; setGrixPrice(price); } catch { diff --git a/src/pages/stakingPage/components/StakingCard.tsx b/src/pages/stakingPage/components/StakingCard.tsx index 1a785a9..0f46e1e 100644 --- a/src/pages/stakingPage/components/StakingCard.tsx +++ b/src/pages/stakingPage/components/StakingCard.tsx @@ -3,6 +3,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { parseEther } from 'viem'; import { useAccount } from 'wagmi'; +import { AssetPriceResponse } from '@/types/api'; import { stakingContracts } from '@/web3Config/staking/config'; import { approveStaking, @@ -116,7 +117,7 @@ export const StakingCard: React.FC = ({ origin: 'https://app.grix.finance', }, }); - const json = await res.json(); + const json = (await res.json()) as AssetPriceResponse; const price = json.assetPrice; setGrixPrice(price); } catch { diff --git a/src/pages/stakingPage/components/VestingModal.tsx b/src/pages/stakingPage/components/VestingModal.tsx index a93f552..efdd940 100644 --- a/src/pages/stakingPage/components/VestingModal.tsx +++ b/src/pages/stakingPage/components/VestingModal.tsx @@ -18,6 +18,7 @@ import { useEffect, useState } from 'react'; import { FaEquals, FaPlus } from 'react-icons/fa'; import { GrixLogo } from '@/components/commons/Logo'; +import { AssetPriceResponse } from '@/types/api'; type VestingModalProps = { isOpen: boolean; @@ -29,12 +30,6 @@ type VestingModalProps = { claimableRewards: string; }; -type DexScreenerResponse = { - grix: { - usd: number; - }; -}; - export const VestingModal = ({ isOpen, onClose, @@ -58,7 +53,7 @@ export const VestingModal = ({ origin: 'https://app.grix.finance', }, }); - const json = await res.json(); + const json = (await res.json()) as AssetPriceResponse; const price = json.assetPrice; setGrixPrice(price); } catch { diff --git a/src/types/api.ts b/src/types/api.ts new file mode 100644 index 0000000..55b354c --- /dev/null +++ b/src/types/api.ts @@ -0,0 +1,5 @@ +// API Response Types + +export type AssetPriceResponse = { + assetPrice: number; +}; \ No newline at end of file diff --git a/src/web3Config/staking/hooks.ts b/src/web3Config/staking/hooks.ts index 68d7c26..fb1e36a 100644 --- a/src/web3Config/staking/hooks.ts +++ b/src/web3Config/staking/hooks.ts @@ -307,8 +307,8 @@ export const calculateAPR = async () => { functionName: 'tokensPerInterval', args: [], }); - } catch (error) { - console.error('Error fetching ETH reward rate:', error); + } catch { + // Error fetching ETH reward rate } } @@ -323,8 +323,8 @@ export const calculateAPR = async () => { // Convert to percentage with 2 decimal places return Number(apr) / 100; - } catch (error) { - console.error('Error calculating APR:', error); + } catch { + // Error calculating APR return 0; } }; From dcb00ea45e1c148891b71a1c74985f165ce2e077 Mon Sep 17 00:00:00 2001 From: asalef10 Date: Mon, 9 Jun 2025 22:33:30 +0300 Subject: [PATCH 8/8] lint --- src/types/api.ts | 2 +- src/web3Config/staking/hooks.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/types/api.ts b/src/types/api.ts index 55b354c..7a08743 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -2,4 +2,4 @@ export type AssetPriceResponse = { assetPrice: number; -}; \ No newline at end of file +}; diff --git a/src/web3Config/staking/hooks.ts b/src/web3Config/staking/hooks.ts index fb1e36a..3f3f699 100644 --- a/src/web3Config/staking/hooks.ts +++ b/src/web3Config/staking/hooks.ts @@ -293,10 +293,10 @@ export const calculateAPR = async () => { // Get core tracker to access fee distributor for ETH rewards const coreTracker = await getCoreTracker(); - + // Get esGRIX emission rate from the main reward distributor const esGrixRewardRate = await getTokenPerInterval(); - + // Get ETH reward rate from the fee distributor let ethRewardRate = 0n; if (coreTracker.feeDistributor && coreTracker.feeDistributor !== '0x0000000000000000000000000000000000000000') {