ghost-dao-interface/src/containers/Bond/components/BondDiscount.jsx
Uncle Fatso d4446f6fb1
version 0.0.22
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
2025-04-28 14:03:56 +03:00

27 lines
930 B
JavaScript

import { Box, useTheme } from "@mui/material";
import Chip from "../../../components/Chip/Chip";
import { formatNumber } from "../../../helpers";
import { DecimalBigNumber } from "../../../helpers/DecimalBigNumber";
const BondDiscount = ({ discount, textOnly }) => {
const theme = useTheme();
const discountString = `${formatNumber(Number(discount.mul(new DecimalBigNumber("100").toString())), 2)}%`;
return textOnly ? (
<Box
style={{
color: new DecimalBigNumber("0").gt(discount) ? theme.colors.feedback.error : theme.colors.feedback.pnlGain,
}}
>
{discountString}
</Box>
) : (
<Chip
label={`${formatNumber(Number(discount.mul(new DecimalBigNumber("100")).toString()), 2)}%`}
template={new DecimalBigNumber("0").gt(discount) ? "error" : "success"}
/>
);
};
export default BondDiscount;