use quote token address directly during LP bond purchase and minor fixes for the price output
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
bb98a8aea7
commit
a52372dbe5
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ghost-dao-interface",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.24",
|
"version": "0.0.25",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
@ -18,7 +18,7 @@ import NotFound from "../NotFound/NotFound";
|
|||||||
|
|
||||||
import { DecimalBigNumber } from "../../helpers/DecimalBigNumber";
|
import { DecimalBigNumber } from "../../helpers/DecimalBigNumber";
|
||||||
import { NetworkId } from "../../constants";
|
import { NetworkId } from "../../constants";
|
||||||
import { formatNumber } from "../../helpers";
|
import { formatCurrency } from "../../helpers";
|
||||||
|
|
||||||
import { useLiveBonds } from "../../hooks/bonds";
|
import { useLiveBonds } from "../../hooks/bonds";
|
||||||
import { useFtsoPrice } from "../../hooks/prices";
|
import { useFtsoPrice } from "../../hooks/prices";
|
||||||
@ -123,17 +123,16 @@ export const BondModal = ({ bond, chainId, address, connect }) => {
|
|||||||
label="Market Price"
|
label="Market Price"
|
||||||
metric={
|
metric={
|
||||||
<TokenPrice
|
<TokenPrice
|
||||||
chainId={chainId}
|
|
||||||
token={bond.baseToken}
|
token={bond.baseToken}
|
||||||
baseSymbol={bond.baseToken.name}
|
symbol={bond.quoteToken.name}
|
||||||
quoteSymbol={bond.quoteToken.name}
|
priceInUsd={bond.price.marketPriceInUsd}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Metric
|
<Metric
|
||||||
label="Discount"
|
label="Discount"
|
||||||
metric={<BondDiscount discount={bond.discount} textOnly />}
|
metric={<BondDiscount discount={bond.discount} textOnly />}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box width="100%" mt="24px">
|
<Box width="100%" mt="24px">
|
||||||
@ -155,21 +154,11 @@ export const BondModal = ({ bond, chainId, address, connect }) => {
|
|||||||
|
|
||||||
const TokenPrice = ({
|
const TokenPrice = ({
|
||||||
token,
|
token,
|
||||||
chainId,
|
symbol,
|
||||||
quoteSymbol,
|
priceInUsd
|
||||||
baseSymbol,
|
|
||||||
}) => {
|
}) => {
|
||||||
const priceToken = useFtsoPrice(chainId);
|
return priceInUsd ? (
|
||||||
const sameToken = quoteSymbol === baseSymbol;
|
<>{formatCurrency(priceInUsd, 2, symbol)}</>
|
||||||
|
|
||||||
const price = sameToken
|
|
||||||
? formatNumber(1, 2)
|
|
||||||
: `${formatNumber(priceToken, 2)}`;
|
|
||||||
|
|
||||||
return price ? (
|
|
||||||
<>
|
|
||||||
{price} {quoteSymbol}
|
|
||||||
</>
|
|
||||||
) : (
|
) : (
|
||||||
<Skeleton width={60} />
|
<Skeleton width={60} />
|
||||||
);
|
);
|
||||||
|
@ -124,7 +124,7 @@ const BondInputArea = ({
|
|||||||
|
|
||||||
<TokenAllowanceGuard
|
<TokenAllowanceGuard
|
||||||
spendAmount={parsedAmount}
|
spendAmount={parsedAmount}
|
||||||
tokenName={bond.quoteToken.name}
|
tokenName={bond.quoteToken.quoteTokenAddress}
|
||||||
owner={address}
|
owner={address}
|
||||||
spender={BOND_DEPOSITORY_ADDRESSES[chainId]}
|
spender={BOND_DEPOSITORY_ADDRESSES[chainId]}
|
||||||
decimals={parsedAmount._decimals}
|
decimals={parsedAmount._decimals}
|
||||||
@ -186,7 +186,7 @@ const BondInputArea = ({
|
|||||||
tooltip={`The maximum quantity of payout token offered via bonds at this moment in time`}
|
tooltip={`The maximum quantity of payout token offered via bonds at this moment in time`}
|
||||||
balance={
|
balance={
|
||||||
<span>
|
<span>
|
||||||
{bond.baseToken === bond.quoteToken
|
{bond.baseToken.tokenAddress.toUpperCase() === bond.quoteToken.quoteTokenAddress.toUpperCase()
|
||||||
? `${formatCurrency(baseTokenString, formatDecimals, "FTSO")}`
|
? `${formatCurrency(baseTokenString, formatDecimals, "FTSO")}`
|
||||||
: `${formatCurrency(baseTokenString, formatDecimals, "FTSO")} (≈${formatCurrency(quoteTokenString, formatDecimals, "GHST")})`}
|
: `${formatCurrency(baseTokenString, formatDecimals, "FTSO")} (≈${formatCurrency(quoteTokenString, formatDecimals, "GHST")})`}
|
||||||
</span>
|
</span>
|
||||||
|
@ -9,7 +9,7 @@ import { abi as BondAbi } from "../../abi/GhostBondDepository.json";
|
|||||||
import { abi as TreasuryAbi } from "../../abi/GhostTreasury.json";
|
import { abi as TreasuryAbi } from "../../abi/GhostTreasury.json";
|
||||||
|
|
||||||
import { useFtsoPrice } from "../prices";
|
import { useFtsoPrice } from "../prices";
|
||||||
import { getTokenIcons, getTokenName, getBondNameDisplayName, getTokenPurchaseLink } from "../helpers";
|
import { getTokenAddress, getTokenIcons, getTokenName, getBondNameDisplayName, getTokenPurchaseLink } from "../helpers";
|
||||||
import { DecimalBigNumber } from "../../helpers/DecimalBigNumber";
|
import { DecimalBigNumber } from "../../helpers/DecimalBigNumber";
|
||||||
import { shorten } from "../../helpers";
|
import { shorten } from "../../helpers";
|
||||||
|
|
||||||
@ -100,7 +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 = baseTokenPerUsd.sub(priceInUsd).div(baseTokenPerUsd);
|
const discount = quoteTokenPerUsd._value > 0n
|
||||||
|
? quoteTokenPerUsd.sub(priceInUsd).div(quoteTokenPerUsd)
|
||||||
|
: quoteTokenPerUsd;
|
||||||
|
|
||||||
const capacityInBaseToken = capacityInQuote
|
const capacityInBaseToken = capacityInQuote
|
||||||
? new DecimalBigNumber(marketPrice > 0n ? marketCapacity / marketPrice : 0n, 9)
|
? new DecimalBigNumber(marketPrice > 0n ? marketCapacity / marketPrice : 0n, 9)
|
||||||
@ -124,7 +126,8 @@ export const useLiveBonds = (chainId) => {
|
|||||||
baseToken: {
|
baseToken: {
|
||||||
name: "FTSO",
|
name: "FTSO",
|
||||||
purchaseUrl: getTokenPurchaseLink(chainId, ""),
|
purchaseUrl: getTokenPurchaseLink(chainId, ""),
|
||||||
icons: ["FTSO"]
|
icons: ["FTSO"],
|
||||||
|
tokenAddress: getTokenAddress(chainId, "FTSO")
|
||||||
},
|
},
|
||||||
quoteToken: {
|
quoteToken: {
|
||||||
name: getTokenName(chainId, quoteTokenAddress),
|
name: getTokenName(chainId, quoteTokenAddress),
|
||||||
@ -140,6 +143,7 @@ export const useLiveBonds = (chainId) => {
|
|||||||
price: {
|
price: {
|
||||||
inUsd: priceInUsd,
|
inUsd: priceInUsd,
|
||||||
inBaseToken: quoteTokenPerBaseToken,
|
inBaseToken: quoteTokenPerBaseToken,
|
||||||
|
marketPriceInUsd: quoteTokenPerUsd
|
||||||
},
|
},
|
||||||
capacity: {
|
capacity: {
|
||||||
inBaseToken: capacityInBaseToken,
|
inBaseToken: capacityInBaseToken,
|
||||||
|
Loading…
Reference in New Issue
Block a user