use epoch function because getEpoch is deprecated on the side of smart contracts
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
95130e4118
commit
856bf01ffe
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ghost-dao-interface",
|
||||
"private": true,
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
@ -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) {
|
||||
|
@ -63,7 +63,7 @@ export const StakeContainer = ({ chainId, address, connect }) => {
|
||||
<Box display="flex" alignItems="center" flexDirection="row" gap="5px">
|
||||
<Typography variant="h6">
|
||||
Rebase
|
||||
<Countdown otherwise="Ready" targetDate={new Date(epoch.end * 1000)} />
|
||||
<Countdown otherwise="Ready" targetTime={epoch.end * 1000} />
|
||||
</Typography>
|
||||
|
||||
</Box>
|
||||
|
@ -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 <Metric {..._props} />;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 };
|
||||
|
Loading…
Reference in New Issue
Block a user