fixes of representation for bond prices

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2025-05-12 19:10:32 +03:00
parent fb0f39e3e6
commit 7f0b59aa8c
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
5 changed files with 15 additions and 32 deletions

View File

@ -1,7 +1,7 @@
{
"name": "ghost-dao-interface",
"private": true,
"version": "0.0.26",
"version": "0.0.27",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -113,21 +113,14 @@ export const BondModal = ({ bond, chainId, address, connect }) => {
"--"
) : (
<BondPrice
price={bond.price.inBaseToken}
symbol={bond.quoteToken.name}
price={bond.price.inUsd}
/>
)
}
/>
<Metric
label="Market Price"
metric={
<TokenPrice
token={bond.baseToken}
symbol={bond.quoteToken.name}
priceInUsd={bond.price.marketPriceInUsd}
/>
}
metric={<TokenPrice priceInUsd={bond.price.marketPriceInUsd} />}
/>
<Metric
label="Discount"
@ -152,13 +145,9 @@ export const BondModal = ({ bond, chainId, address, connect }) => {
);
};
const TokenPrice = ({
token,
symbol,
priceInUsd
}) => {
const TokenPrice = ({ priceInUsd }) => {
return priceInUsd ? (
<>{formatCurrency(priceInUsd, 2, symbol)}</>
<>{formatCurrency(priceInUsd, 2)}</>
) : (
<Skeleton width={60} />
);

View File

@ -95,10 +95,7 @@ const BondCard = ({ bond, secondsTo }) => {
{bond.isSoldOut ? (
"--"
) : (
<BondPrice
price={bond.price.inBaseToken}
symbol={quoteTokenName}
/>
<BondPrice price={bond.price.inUsd} />
)}
</Typography>
</Box>
@ -191,10 +188,7 @@ const BondRow = ({ bond, secondsTo }) => {
{bond.isSoldOut ? (
"--"
) : (
<BondPrice
price={bond.price.inBaseToken}
symbol={quoteTokenName}
/>
<BondPrice price={bond.price.inUsd} />
)}
</Typography>
</TableCell>

View File

@ -1,8 +1,8 @@
const BondPrice = ({ price, symbol }) => {
import { formatCurrency } from "../../../helpers";
const BondPrice = ({ price }) => {
return (
<>
{price.toString({ decimals: 2, format: true, trim: false })} {symbol}
</>
<>{formatCurrency(price, 2)}</>
);
};

View File

@ -100,9 +100,9 @@ export const useLiveBonds = (chainId) => {
const quoteTokenPerBaseToken = new DecimalBigNumber(marketPrice, 9);
const priceInUsd = quoteTokenPerUsd.mul(quoteTokenPerBaseToken);
const discount = quoteTokenPerUsd._value > 0n
? quoteTokenPerUsd.sub(priceInUsd).div(quoteTokenPerUsd)
: new DecimalBigNumber("0", quoteTokenDecimals);
const discount = baseTokenPerUsd._value > 0n
? baseTokenPerUsd.sub(priceInUsd).div(baseTokenPerUsd)
: new DecimalBigNumber("0", baseTokenPerUsd._decimals);
const capacityInBaseToken = capacityInQuote
? new DecimalBigNumber(marketPrice > 0n ? marketCapacity / marketPrice : 0n, 9)
@ -143,7 +143,7 @@ export const useLiveBonds = (chainId) => {
price: {
inUsd: priceInUsd,
inBaseToken: quoteTokenPerBaseToken,
marketPriceInUsd: quoteTokenPerUsd
marketPriceInUsd: baseTokenPerUsd
},
capacity: {
inBaseToken: capacityInBaseToken,