From 856bf01ffe1fa3d7c56cfb63fc1db9e15e3153ff Mon Sep 17 00:00:00 2001 From: Uncle Fatso Date: Fri, 13 Jun 2025 14:52:06 +0300 Subject: [PATCH] use epoch function because getEpoch is deprecated on the side of smart contracts Signed-off-by: Uncle Fatso --- package.json | 2 +- src/components/Countdown/Countdown.jsx | 4 ++-- src/containers/Stake/StakeContainer.jsx | 2 +- src/containers/Stake/components/Metric.jsx | 4 ++-- src/hooks/staking/index.js | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 987225b..a528549 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ghost-dao-interface", "private": true, - "version": "0.1.1", + "version": "0.1.2", "type": "module", "scripts": { "dev": "vite", diff --git a/src/components/Countdown/Countdown.jsx b/src/components/Countdown/Countdown.jsx index a44d89b..8b25e22 100644 --- a/src/components/Countdown/Countdown.jsx +++ b/src/components/Countdown/Countdown.jsx @@ -1,9 +1,9 @@ import React, { useEffect, useState } from "react"; -const CountdownTimer = ({ otherwise, targetDate }) => { +const CountdownTimer = ({ otherwise, targetTime }) => { const calculateTimeLeft = () => { const now = new Date(); - const difference = targetDate.getTime() - now.getTime(); + const difference = targetTime - now.getTime(); let timeLeft = { hours: 0, minutes: 0 }; if (difference > 0) { diff --git a/src/containers/Stake/StakeContainer.jsx b/src/containers/Stake/StakeContainer.jsx index 6388ea5..b03bdbc 100644 --- a/src/containers/Stake/StakeContainer.jsx +++ b/src/containers/Stake/StakeContainer.jsx @@ -63,7 +63,7 @@ export const StakeContainer = ({ chainId, address, connect }) => { Rebase  - + diff --git a/src/containers/Stake/components/Metric.jsx b/src/containers/Stake/components/Metric.jsx index 6bb2d12..96afecf 100644 --- a/src/containers/Stake/components/Metric.jsx +++ b/src/containers/Stake/components/Metric.jsx @@ -16,7 +16,7 @@ export const CurrentIndex = props => { tooltip: `The current index indicates the amount of FTSO a holder would possess if they had staked and maintained 1 FTSO since its launch.`, }; - if (currentIndex) _props.metric = `${formatNumber(currentIndex, 2)} FTSO`; + if (currentIndex) _props.metric = `${formatNumber(currentIndex, 2)}`; else _props.isLoading = true; return ; @@ -28,7 +28,7 @@ export const Apy = props => { let apy = Infinity; if (circulatingSupply._value > 0n) { const value = props.distribute.div(circulatingSupply); - apy = Math.pow(1 + parseFloat(value.toString()), 1095) - 1; + apy = 100 * (Math.pow(1 + parseFloat(value.toString()), 1095) - 1); if (apy === 0) apy = Infinity; } diff --git a/src/hooks/staking/index.js b/src/hooks/staking/index.js index 00e4753..b540a97 100644 --- a/src/hooks/staking/index.js +++ b/src/hooks/staking/index.js @@ -29,16 +29,16 @@ export const useEpoch = (chainId) => { const { data: epochRaw, refetch } = useReadContract({ abi: StakingAbi, address: STAKING_ADDRESSES[chainId], - functionName: "getEpoch", - scopeKey: `getEpoch-${chainId}`, + functionName: "epoch", + scopeKey: `epoch-${chainId}`, chainId: chainId, }); const epoch = { - length: Number(epochRaw && epochRaw.length ? epochRaw.length : 0), - number: Number(epochRaw && epochRaw.number ? epochRaw.number : 0), - end: Number(epochRaw && epochRaw.end ? epochRaw.end : 0), - distribute: epochRaw && epochRaw.distribute ? new DecimalBigNumber(epochRaw.distribute, 9) : new DecimalBigNumber(0n, 9), + length: Number(epochRaw?.at(0) ? epochRaw.at(0) : 0), + number: Number(epochRaw?.at(1) ? epochRaw.at(1) : 0), + end: Number(epochRaw?.at(2) ? epochRaw.at(2) : 0), + distribute: new DecimalBigNumber(epochRaw?.at(3) ? epochRaw.at(3) : 0n, 9), }; return { epoch, refetch };