enable claims from the warmup based on new smart contract logic
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
ff43a26e0d
commit
1c25be075c
@ -28,7 +28,8 @@ import { formatNumber, formatCurrency } from "../../../helpers";
|
|||||||
import { STAKING_ADDRESSES } from "../../../constants/addresses";
|
import { STAKING_ADDRESSES } from "../../../constants/addresses";
|
||||||
import { useCurrentIndex, useWarmupInfo } from "../../../hooks/staking";
|
import { useCurrentIndex, useWarmupInfo } from "../../../hooks/staking";
|
||||||
import { useBalanceForShares, useTokenSymbol } from "../../../hooks/tokens";
|
import { useBalanceForShares, useTokenSymbol } from "../../../hooks/tokens";
|
||||||
import { useGhstPrice } from "../../../hooks/prices";
|
import { useGhstPrice, useStnkPrice } from "../../../hooks/prices";
|
||||||
|
import { isNetworkLegacy } from "../../../constants";
|
||||||
|
|
||||||
import ClaimConfirmationModal from "./ClaimConfirmationModal";
|
import ClaimConfirmationModal from "./ClaimConfirmationModal";
|
||||||
|
|
||||||
@ -55,6 +56,8 @@ export const ClaimsArea = ({ chainId, address, epoch }) => {
|
|||||||
const [isPayoutGhst, _] = useState(true);
|
const [isPayoutGhst, _] = useState(true);
|
||||||
|
|
||||||
const ghstPrice = useGhstPrice(chainId);
|
const ghstPrice = useGhstPrice(chainId);
|
||||||
|
const stnkPrice = useStnkPrice(chainId);
|
||||||
|
|
||||||
const { warmupInfo: claim, refetch: claimRefetch } = useWarmupInfo(chainId, address);
|
const { warmupInfo: claim, refetch: claimRefetch } = useWarmupInfo(chainId, address);
|
||||||
const { currentIndex, refetch: currentIndexRefetch } = useCurrentIndex(chainId);
|
const { currentIndex, refetch: currentIndexRefetch } = useCurrentIndex(chainId);
|
||||||
const { balanceForShares } = useBalanceForShares(chainId, "STNK", claim.shares);
|
const { balanceForShares } = useBalanceForShares(chainId, "STNK", claim.shares);
|
||||||
@ -63,6 +66,14 @@ export const ClaimsArea = ({ chainId, address, epoch }) => {
|
|||||||
const { symbol: stnkSymbol } = useTokenSymbol(chainId, "STNK");
|
const { symbol: stnkSymbol } = useTokenSymbol(chainId, "STNK");
|
||||||
const { symbol: ghstSymbol } = useTokenSymbol(chainId, "GHST");
|
const { symbol: ghstSymbol } = useTokenSymbol(chainId, "GHST");
|
||||||
|
|
||||||
|
const claimableBalance = useMemo(() => {
|
||||||
|
if (isNetworkLegacy(chainId)) {
|
||||||
|
return isPayoutGhst ? balanceForShares.div(currentIndex) : balanceForShares;
|
||||||
|
}
|
||||||
|
const toClaim = new DecimalBigNumber(claim.shares, 18);
|
||||||
|
return isPayoutGhst ? toClaim : toClaim.mul(currentIndex);
|
||||||
|
}, [chainId, claim, currentIndex, balanceForShares]);
|
||||||
|
|
||||||
const closeConfirmationModal = () => {
|
const closeConfirmationModal = () => {
|
||||||
setConfirmationModalOpen(false);
|
setConfirmationModalOpen(false);
|
||||||
claimRefetch();
|
claimRefetch();
|
||||||
@ -80,7 +91,7 @@ export const ClaimsArea = ({ chainId, address, epoch }) => {
|
|||||||
onClose={() => closeConfirmationModal()}
|
onClose={() => closeConfirmationModal()}
|
||||||
chainid={chainId}
|
chainid={chainId}
|
||||||
receiver={address}
|
receiver={address}
|
||||||
receiveAmount={claim.expiry > epoch.number ? claim.deposit : isPayoutGhst ? balanceForShares.div(currentIndex) : balanceForShares}
|
receiveAmount={claim.expiry > epoch.number ? claim.deposit : claimableBalance}
|
||||||
outputToken={claim.expiry > epoch.number ? ftsoSymbol : isPayoutGhst ? ghstSymbol : stnkSymbol}
|
outputToken={claim.expiry > epoch.number ? ftsoSymbol : isPayoutGhst ? ghstSymbol : stnkSymbol}
|
||||||
stnkSymbol={stnkSymbol}
|
stnkSymbol={stnkSymbol}
|
||||||
ghstSymbol={ghstSymbol}
|
ghstSymbol={ghstSymbol}
|
||||||
@ -107,34 +118,35 @@ export const ClaimsArea = ({ chainId, address, epoch }) => {
|
|||||||
{isSmallScreen ? (
|
{isSmallScreen ? (
|
||||||
<MobileClaimInfo
|
<MobileClaimInfo
|
||||||
setConfirmationModalOpen={setConfirmationModalOpen}
|
setConfirmationModalOpen={setConfirmationModalOpen}
|
||||||
prepareBalance={isPayoutGhst ? balanceForShares.div(currentIndex) : balanceForShares}
|
prepareBalance={claimableBalance}
|
||||||
isPayoutGhst={isPayoutGhst}
|
isPayoutGhst={isPayoutGhst}
|
||||||
claim={claim}
|
claim={claim}
|
||||||
epoch={epoch}
|
epoch={epoch}
|
||||||
isClaimable={claim.expiry > epoch.number}
|
isClaimable={claim.expiry > epoch.number}
|
||||||
stnkSymbol={stnkSymbol}
|
stnkSymbol={stnkSymbol}
|
||||||
ghstSymbol={ghstSymbol}
|
ghstSymbol={ghstSymbol}
|
||||||
|
tokenPrice={isPayoutGhst ? ghstPrice : stnkPrice}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Table>
|
<Table>
|
||||||
<StyledTableHeader className={classes.stakePoolHeaderText}>
|
<StyledTableHeader className={classes.stakePoolHeaderText}>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell style={{ width: "200px", padding: "8px 0" }}>Asset</TableCell>
|
<TableCell style={{ width: "200px", padding: "8px 0" }}>Asset</TableCell>
|
||||||
<TableCell style={{ width: "200px", padding: "8px 0" }}>Amount</TableCell>
|
<TableCell style={{ width: "200px", padding: "8px 0" }}>Staked Amount</TableCell>
|
||||||
<TableCell style={{ width: "150px", padding: "8px 0" }}>Claimable In</TableCell>
|
<TableCell style={{ width: "150px", padding: "8px 0" }}>Claimable In</TableCell>
|
||||||
<TableCell></TableCell>
|
<TableCell></TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</StyledTableHeader>
|
</StyledTableHeader>
|
||||||
<ClaimInfo
|
<ClaimInfo
|
||||||
setConfirmationModalOpen={setConfirmationModalOpen}
|
setConfirmationModalOpen={setConfirmationModalOpen}
|
||||||
prepareBalance={isPayoutGhst ? balanceForShares.div(currentIndex) : balanceForShares}
|
prepareBalance={claimableBalance}
|
||||||
isPayoutGhst={isPayoutGhst}
|
isPayoutGhst={isPayoutGhst}
|
||||||
claim={claim}
|
claim={claim}
|
||||||
epoch={epoch}
|
epoch={epoch}
|
||||||
isClaimable={claim.expiry > epoch.number}
|
isClaimable={claim.expiry > epoch.number}
|
||||||
stnkSymbol={stnkSymbol}
|
stnkSymbol={stnkSymbol}
|
||||||
ghstSymbol={ghstSymbol}
|
ghstSymbol={ghstSymbol}
|
||||||
ghstPrice={ghstPrice}
|
tokenPrice={isPayoutGhst ? ghstPrice : stnkPrice}
|
||||||
/>
|
/>
|
||||||
</Table>
|
</Table>
|
||||||
|
|
||||||
@ -153,7 +165,7 @@ const ClaimInfo = ({
|
|||||||
isPayoutGhst,
|
isPayoutGhst,
|
||||||
stnkSymbol,
|
stnkSymbol,
|
||||||
ghstSymbol,
|
ghstSymbol,
|
||||||
ghstPrice
|
tokenPrice
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<TableBody>
|
<TableBody>
|
||||||
@ -171,7 +183,7 @@ const ClaimInfo = ({
|
|||||||
{formatCurrency(prepareBalance, 5, isPayoutGhst ? ghstSymbol : stnkSymbol)}
|
{formatCurrency(prepareBalance, 5, isPayoutGhst ? ghstSymbol : stnkSymbol)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body2" gutterBottom={false} style={{ lineHeight: 1.4 }}>
|
<Typography variant="body2" gutterBottom={false} style={{ lineHeight: 1.4 }}>
|
||||||
{formatCurrency(prepareBalance * ghstPrice, 2)}
|
{formatCurrency(prepareBalance * tokenPrice, 2)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell style={{ padding: "8px 8px 8px 0" }}>
|
<TableCell style={{ padding: "8px 8px 8px 0" }}>
|
||||||
@ -188,7 +200,17 @@ const ClaimInfo = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const MobileClaimInfo = ({ setConfirmationModalOpen, prepareBalance, epoch, claim, isPayoutGhst, isClaimable, ghstSymbol, stnkSymbol }) => {
|
const MobileClaimInfo = ({
|
||||||
|
setConfirmationModalOpen,
|
||||||
|
prepareBalance,
|
||||||
|
epoch,
|
||||||
|
claim,
|
||||||
|
isPayoutGhst,
|
||||||
|
isClaimable,
|
||||||
|
ghstSymbol,
|
||||||
|
stnkSymbol,
|
||||||
|
tokenPrice,
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Box mt="10px">
|
<Box mt="10px">
|
||||||
<Box display="flex" flexDirection="row" alignItems="center" style={{ whiteSpace: "nowrap" }}>
|
<Box display="flex" flexDirection="row" alignItems="center" style={{ whiteSpace: "nowrap" }}>
|
||||||
@ -199,10 +221,15 @@ const MobileClaimInfo = ({ setConfirmationModalOpen, prepareBalance, epoch, clai
|
|||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<DataRow
|
<DataRow
|
||||||
title="Amount"
|
title="Staked Amount"
|
||||||
balance={formatNumber(prepareBalance, 7)}
|
balance={formatNumber(prepareBalance, 7)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<DataRow
|
||||||
|
title="Price Estimation"
|
||||||
|
balance={formatCurrency(prepareBalance * tokenPrice, 2)}
|
||||||
|
/>
|
||||||
|
|
||||||
<DataRow
|
<DataRow
|
||||||
title="Claimed in"
|
title="Claimed in"
|
||||||
balance={prettifySecondsInDays(epoch.length * (claim.expiry - epoch.number))}
|
balance={prettifySecondsInDays(epoch.length * (claim.expiry - epoch.number))}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user