import { useMemo } from "react"; import { Grid, Box, Typography } from "@mui/material"; import { useConfig } from "wagmi"; import { useNavigate, createSearchParams } from "react-router-dom"; import { formatNumber } from "../../../helpers"; import { useLiveBonds } from "../../../hooks/bonds/index"; import { useEpoch, useGatekeeperApy } from "../../../hooks/staking"; import { useTokenSymbol, useBalance, useCirculatingSupply } from "../../../hooks/tokens"; import { SecondaryButton } from "../../../components/Button"; import { DecimalBigNumber } from "../../../helpers/DecimalBigNumber"; import { GATEKEEPER_ADDRESSES, EMPTY_ADDRESS } from "../../../constants/addresses"; const ProtocolDetail = ({ isMobileScreen, theme, name, sideName, url, urlParams, description }) => { const navigate = useNavigate(); return ( {name} {sideName} <> {description} urlParams ? navigate({ pathname: url, search: urlParams.toString() }) : navigate(url, { replace: true }) } fullWidth > {name} ) } const ProtocolDetails = ({ chainId, isMobileScreen, theme, }) => { const config = useConfig(); const nativeSymbol = config?.getClient()?.chain?.nativeCurrency?.symbol; const networkName = config?.getClient()?.chain?.name; const { symbol: ftsoSymbol } = useTokenSymbol(chainId, "FTSO"); const { symbol: csprSymbol } = useTokenSymbol(chainId, "CSPR"); const { contractAddress: ftsoAddress } = useBalance(chainId, "FTSO", EMPTY_ADDRESS); const { liveBonds } = useLiveBonds(chainId); const circulatingSupply = useCirculatingSupply(chainId, "STNK"); const gatekeepedApy = useGatekeeperApy(chainId); const { epoch } = useEpoch(chainId); const maxBondDiscountTest = useMemo(() => { const sortedGhostBonds = liveBonds.filter((bond) => !bond.isSoldOut) if (sortedGhostBonds?.length === 0) return "Coming Up"; const maxDiscountBond = sortedGhostBonds.reduce((prev, current) => (prev.discount > current.discount) ? prev : current ); const maxDiscount = maxDiscountBond.discount.mul(new DecimalBigNumber(100, 0)); return `Up to ${formatNumber(maxDiscount, 0)}% Discount`; }, [liveBonds]); const apyInner = useMemo(() => { let apy = Infinity; if (circulatingSupply._value > 0n) { const value = epoch.distribute.div(circulatingSupply); apy = 100 * (Math.pow(1 + parseFloat(value.toString()), 1095) - 1); if (apy === 0) apy = Infinity; } return apy; }, [circulatingSupply, epoch]); const bridgeNumbers = useMemo(() => { const connectedNetworks = Object.keys(GATEKEEPER_ADDRESSES).length; const number = 1 + connectedNetworks * 3; return `(${number}, ${number})`; }, [chainId]); return ( ) } export default ProtocolDetails;