import { useState } from "react"; import { Box, Typography } from "@mui/material"; import { styled, useTheme } from "@mui/material/styles"; import SettingsIcon from '@mui/icons-material/Settings'; import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; import toast from "react-hot-toast"; import GhostStyledIcon from "../../../components/Icon/GhostIcon"; import Metric from "../../../components/Metric/Metric"; import Modal from "../../../components/Modal/Modal"; import TokenStack from "../../../components/TokenStack/TokenStack"; import DataRow from "../../../components/DataRow/DataRow"; import { PrimaryButton } from "../../../components/Button"; import BondDiscount from "./BondDiscount"; import BondVesting from "./BondVesting"; import BondSlippage from "./BondSlippage"; import { purchaseBond } from "../../../hooks/bonds"; const StyledBox = styled(Box, { shouldForwardProp: prop => prop !== "template", })(({ theme }) => { return { root: {}, }; }); const BondConfirmModal = ({ chainId, bond, slippage, recipientAddress, spendAmountValue, spendAmount, receiveAmount, sender, handleSettingsOpen, isOpen, handleConfirmClose }) => { const theme = useTheme(); const [isPending, setIsPending] = useState(false); const onSubmit = async () => { setIsPending(true); const shares = 100000; const one = BigInt(shares * 100); const floatSlippage = slippage === "" ? 0 : parseFloat(slippage); const bigIntSlippage = one + BigInt(Math.round(floatSlippage * shares)); const maxPrice = bond.price.inBaseToken._value * bigIntSlippage / one; const referral = import.meta.env.VITE_APP_REFERRAL_ADDRESS; await purchaseBond( chainId, bond.id, spendAmountValue._value.toBigInt(), maxPrice, recipientAddress, sender, referral ); setIsPending(false); handleConfirmClose(); } return ( {bond.quoteToken.name} } onClose={!isPending && handleConfirmClose} topLeft={} > <> {bond.quoteToken.name} {bond.baseToken.name} } /> } /> } /> {isPending ? "Bonding..." : "Confirm Bond Purchase"} ); }; export default BondConfirmModal;