import { CheckBoxOutlineBlank, CheckBoxOutlined } from "@mui/icons-material";
import { Box, Checkbox, FormControlLabel, Typography } from "@mui/material";
import { useEffect, useState } from "react";
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
import { DecimalBigNumber } from "../../../helpers/DecimalBigNumber";
import GhostStyledIcon from "../../../components/Icon/GhostIcon";
import Modal from "../../../components/Modal/Modal";
import { PrimaryButton, SecondaryButton } from "../../../components/Button";
import Metric from "../../../components/Metric/Metric";
import { TokenAllowanceGuard } from "../../../components/TokenAllowanceGuard/TokenAllowanceGuard";
import { useWarmupLength, stake, unstake, wrap, unwrap } from "../../../hooks/staking";
import { formatNumber } from "../../../helpers";
import { STAKING_ADDRESSES } from "../../../constants/addresses";
const StakeConfirmationModal = (props) => {
const { warmupLength, warmupExists: needsWarmup } = useWarmupLength(props.chainId);
const [acknowledgedWarmup, setAcknowledgedWarmup] = useState(false);
const [isPending, setIsPending] = useState(false);
useEffect(() => setAcknowledgedWarmup(acknowledgedWarmup || !needsWarmup), [acknowledgedWarmup, needsWarmup])
const AcknowledgeWarmupCheckbox = () => {
if (!needsWarmup) return <>>;
return (
<>
setAcknowledgedWarmup(event.target.checked)}
icon={}
checkedIcon={}
/>
}
label={`I understand the FTSO (eGHST) I’m staking will only be available to claim ${warmupLength.toString()} epochs after my transaction is confirmed`}
/>
>
);
};
const NeedsWarmupDetails = () => {
if (needsWarmup && props.action === "STAKE") {
return (
<>
Why is there a warmup?
>
);
} else {
return <>>;
}
};
const doAction = async () => {
setIsPending(true);
const actionAmount = new DecimalBigNumber(props.amount, props.spendDecimals);
const isRebase = props.upperToken === "STNK";
switch (props.action) {
case "STAKE":
await stake(props.chainId, props.address, actionAmount._value.toBigInt(), isRebase, props.isClaim);
break;
case "UNSTAKE":
await unstake(props.chainId, props.address, actionAmount._value.toBigInt(), props.isTrigger, isRebase);
break;
case "WRAP":
await wrap(props.chainId, props.address, actionAmount._value.toBigInt());
break;
case "UNWRAP":
await unwrap(props.chainId, props.address, actionAmount._value.toBigInt());
break;
default:
console.log("Wrong action to be executed!");
}
setIsPending(false);
props.onClose();
}
return (
>}
headerContent={
{`Confirm ${props.action}`}
}
open={props.open}
onClose={() => isPending ? {} : props.onClose()}
minHeight={"100px"}
>
{props.upperToken}
{props.bottomToken}
{acknowledgedWarmup || props.action !== "STAKE" ?
doAction()}
>
Confirm
:
}
);
};
export default StakeConfirmationModal;