fixes of representation for bond prices
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
fb0f39e3e6
commit
7f0b59aa8c
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ghost-dao-interface",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.26",
|
"version": "0.0.27",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
@ -113,21 +113,14 @@ export const BondModal = ({ bond, chainId, address, connect }) => {
|
|||||||
"--"
|
"--"
|
||||||
) : (
|
) : (
|
||||||
<BondPrice
|
<BondPrice
|
||||||
price={bond.price.inBaseToken}
|
price={bond.price.inUsd}
|
||||||
symbol={bond.quoteToken.name}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Metric
|
<Metric
|
||||||
label="Market Price"
|
label="Market Price"
|
||||||
metric={
|
metric={<TokenPrice priceInUsd={bond.price.marketPriceInUsd} />}
|
||||||
<TokenPrice
|
|
||||||
token={bond.baseToken}
|
|
||||||
symbol={bond.quoteToken.name}
|
|
||||||
priceInUsd={bond.price.marketPriceInUsd}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Metric
|
<Metric
|
||||||
label="Discount"
|
label="Discount"
|
||||||
@ -152,13 +145,9 @@ export const BondModal = ({ bond, chainId, address, connect }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const TokenPrice = ({
|
const TokenPrice = ({ priceInUsd }) => {
|
||||||
token,
|
|
||||||
symbol,
|
|
||||||
priceInUsd
|
|
||||||
}) => {
|
|
||||||
return priceInUsd ? (
|
return priceInUsd ? (
|
||||||
<>{formatCurrency(priceInUsd, 2, symbol)}</>
|
<>{formatCurrency(priceInUsd, 2)}</>
|
||||||
) : (
|
) : (
|
||||||
<Skeleton width={60} />
|
<Skeleton width={60} />
|
||||||
);
|
);
|
||||||
|
@ -95,10 +95,7 @@ const BondCard = ({ bond, secondsTo }) => {
|
|||||||
{bond.isSoldOut ? (
|
{bond.isSoldOut ? (
|
||||||
"--"
|
"--"
|
||||||
) : (
|
) : (
|
||||||
<BondPrice
|
<BondPrice price={bond.price.inUsd} />
|
||||||
price={bond.price.inBaseToken}
|
|
||||||
symbol={quoteTokenName}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
@ -191,10 +188,7 @@ const BondRow = ({ bond, secondsTo }) => {
|
|||||||
{bond.isSoldOut ? (
|
{bond.isSoldOut ? (
|
||||||
"--"
|
"--"
|
||||||
) : (
|
) : (
|
||||||
<BondPrice
|
<BondPrice price={bond.price.inUsd} />
|
||||||
price={bond.price.inBaseToken}
|
|
||||||
symbol={quoteTokenName}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const BondPrice = ({ price, symbol }) => {
|
import { formatCurrency } from "../../../helpers";
|
||||||
|
|
||||||
|
const BondPrice = ({ price }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>{formatCurrency(price, 2)}</>
|
||||||
{price.toString({ decimals: 2, format: true, trim: false })} {symbol}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ export const useLiveBonds = (chainId) => {
|
|||||||
|
|
||||||
const quoteTokenPerBaseToken = new DecimalBigNumber(marketPrice, 9);
|
const quoteTokenPerBaseToken = new DecimalBigNumber(marketPrice, 9);
|
||||||
const priceInUsd = quoteTokenPerUsd.mul(quoteTokenPerBaseToken);
|
const priceInUsd = quoteTokenPerUsd.mul(quoteTokenPerBaseToken);
|
||||||
const discount = quoteTokenPerUsd._value > 0n
|
const discount = baseTokenPerUsd._value > 0n
|
||||||
? quoteTokenPerUsd.sub(priceInUsd).div(quoteTokenPerUsd)
|
? baseTokenPerUsd.sub(priceInUsd).div(baseTokenPerUsd)
|
||||||
: new DecimalBigNumber("0", quoteTokenDecimals);
|
: new DecimalBigNumber("0", baseTokenPerUsd._decimals);
|
||||||
|
|
||||||
const capacityInBaseToken = capacityInQuote
|
const capacityInBaseToken = capacityInQuote
|
||||||
? new DecimalBigNumber(marketPrice > 0n ? marketCapacity / marketPrice : 0n, 9)
|
? new DecimalBigNumber(marketPrice > 0n ? marketCapacity / marketPrice : 0n, 9)
|
||||||
@ -143,7 +143,7 @@ export const useLiveBonds = (chainId) => {
|
|||||||
price: {
|
price: {
|
||||||
inUsd: priceInUsd,
|
inUsd: priceInUsd,
|
||||||
inBaseToken: quoteTokenPerBaseToken,
|
inBaseToken: quoteTokenPerBaseToken,
|
||||||
marketPriceInUsd: quoteTokenPerUsd
|
marketPriceInUsd: baseTokenPerUsd
|
||||||
},
|
},
|
||||||
capacity: {
|
capacity: {
|
||||||
inBaseToken: capacityInBaseToken,
|
inBaseToken: capacityInBaseToken,
|
||||||
|
Loading…
Reference in New Issue
Block a user