Compare commits
No commits in common. "fb0f39e3e6f75c85761f990516757cec22357d0b" and "ab8ca19a6968ee8658f74e26699be04caf909b94" have entirely different histories.
fb0f39e3e6
...
ab8ca19a69
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ghost-dao-interface",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.26",
|
"version": "0.0.23",
|
||||||
"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 { formatCurrency } from "../../helpers";
|
import { formatNumber } from "../../helpers";
|
||||||
|
|
||||||
import { useLiveBonds } from "../../hooks/bonds";
|
import { useLiveBonds } from "../../hooks/bonds";
|
||||||
import { useFtsoPrice } from "../../hooks/prices";
|
import { useFtsoPrice } from "../../hooks/prices";
|
||||||
@ -123,16 +123,17 @@ 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}
|
||||||
symbol={bond.quoteToken.name}
|
baseSymbol={bond.baseToken.name}
|
||||||
priceInUsd={bond.price.marketPriceInUsd}
|
quoteSymbol={bond.quoteToken.name}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<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">
|
||||||
@ -154,11 +155,21 @@ export const BondModal = ({ bond, chainId, address, connect }) => {
|
|||||||
|
|
||||||
const TokenPrice = ({
|
const TokenPrice = ({
|
||||||
token,
|
token,
|
||||||
symbol,
|
chainId,
|
||||||
priceInUsd
|
quoteSymbol,
|
||||||
|
baseSymbol,
|
||||||
}) => {
|
}) => {
|
||||||
return priceInUsd ? (
|
const priceToken = useFtsoPrice(chainId);
|
||||||
<>{formatCurrency(priceInUsd, 2, symbol)}</>
|
const sameToken = quoteSymbol === baseSymbol;
|
||||||
|
|
||||||
|
const price = sameToken
|
||||||
|
? formatNumber(1, 2)
|
||||||
|
: `${formatNumber(priceToken, 2)}`;
|
||||||
|
|
||||||
|
return price ? (
|
||||||
|
<>
|
||||||
|
{price} {quoteSymbol}
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Skeleton width={60} />
|
<Skeleton width={60} />
|
||||||
);
|
);
|
||||||
|
@ -5,7 +5,7 @@ import { DecimalBigNumber } from "../../../helpers/DecimalBigNumber";
|
|||||||
|
|
||||||
const BondDiscount = ({ discount, textOnly }) => {
|
const BondDiscount = ({ discount, textOnly }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const discountString = `${formatNumber(Number(discount.mul(new DecimalBigNumber("100")).toString()), 2)}%`;
|
const discountString = `${formatNumber(Number(discount.mul(new DecimalBigNumber("100").toString())), 2)}%`;
|
||||||
|
|
||||||
return textOnly ? (
|
return textOnly ? (
|
||||||
<Box
|
<Box
|
||||||
@ -17,7 +17,7 @@ const BondDiscount = ({ discount, textOnly }) => {
|
|||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<Chip
|
<Chip
|
||||||
label={discountString}
|
label={`${formatNumber(Number(discount.mul(new DecimalBigNumber("100")).toString()), 2)}%`}
|
||||||
template={new DecimalBigNumber("0").gt(discount) ? "error" : "success"}
|
template={new DecimalBigNumber("0").gt(discount) ? "error" : "success"}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -124,7 +124,7 @@ const BondInputArea = ({
|
|||||||
|
|
||||||
<TokenAllowanceGuard
|
<TokenAllowanceGuard
|
||||||
spendAmount={parsedAmount}
|
spendAmount={parsedAmount}
|
||||||
tokenName={bond.quoteToken.quoteTokenAddress}
|
tokenName={bond.quoteToken.name}
|
||||||
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.tokenAddress.toUpperCase() === bond.quoteToken.quoteTokenAddress.toUpperCase()
|
{bond.baseToken === bond.quoteToken
|
||||||
? `${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>
|
||||||
|
@ -60,11 +60,14 @@ const PoolContainer = ({
|
|||||||
} = useTotalSupply(chainId, pairAddress);
|
} = useTotalSupply(chainId, pairAddress);
|
||||||
const {
|
const {
|
||||||
reserves: pairReserves,
|
reserves: pairReserves,
|
||||||
tokens: tokenAddresses,
|
|
||||||
refetch: pairReservesRefetch,
|
refetch: pairReservesRefetch,
|
||||||
} = useUniswapV2PairReserves(
|
} = useUniswapV2PairReserves(
|
||||||
chainId,
|
chainId,
|
||||||
pairAddress,
|
pairAddress,
|
||||||
|
balanceTop._decimals,
|
||||||
|
balanceBottom._decimals,
|
||||||
|
tokenNameTop,
|
||||||
|
tokenNameBottom,
|
||||||
);
|
);
|
||||||
|
|
||||||
const onSwap = () => {
|
const onSwap = () => {
|
||||||
@ -107,27 +110,19 @@ const PoolContainer = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const estimatedAmountOut = useMemo(() => {
|
const estimatedAmountOut = useMemo(() => {
|
||||||
const pairReserves0 = addressTop.toUpperCase() === tokenAddresses.token0.toUpperCase()
|
|
||||||
? pairReserves.reserve0
|
|
||||||
: pairReserves.reserve1;
|
|
||||||
const pairReserves1 = addressBottom.toUpperCase() === tokenAddresses.token1.toUpperCase()
|
|
||||||
? pairReserves.reserve1
|
|
||||||
: pairReserves.reserve0;
|
|
||||||
|
|
||||||
const zero = new DecimalBigNumber(0n, 0);
|
const zero = new DecimalBigNumber(0n, 0);
|
||||||
const value0 = new DecimalBigNumber(amountTop, balanceTop._decimals)
|
const value0 = new DecimalBigNumber(amountTop, balanceTop._decimals)
|
||||||
const value1 = new DecimalBigNumber(amountBottom, balanceBottom._decimals);
|
const value1 = new DecimalBigNumber(amountBottom, balanceBottom._decimals)
|
||||||
|
|
||||||
const amountToAddA = new DecimalBigNumber(value0._value.toBigInt(), balanceTop._decimals);
|
const amountToAddA = new DecimalBigNumber(value0._value.toBigInt(), balanceTop._decimals);
|
||||||
const amountToAddB = new DecimalBigNumber(value1._value.toBigInt(), balanceBottom._decimals);
|
const amountToAddB = new DecimalBigNumber(value1._value.toBigInt(), balanceBottom._decimals);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
pairReserves0.gt(zero) &&
|
pairReserves.reserve0.gt(zero) &&
|
||||||
pairReserves1.gt(zero) &&
|
pairReserves.reserve1.gt(zero) &&
|
||||||
lpTotalSupply.gt(new DecimalBigNumber(0n, 0))
|
lpTotalSupply.gt(new DecimalBigNumber(0n, 0))
|
||||||
) {
|
) {
|
||||||
const lpTokensFromA = (amountToAddA.mul(lpTotalSupply).div(pairReserves0));
|
const lpTokensFromA = (amountToAddA.mul(lpTotalSupply).div(pairReserves.reserve0));
|
||||||
const lpTokensFromB = (amountToAddB.mul(lpTotalSupply).div(pairReserves1));
|
const lpTokensFromB = (amountToAddB.mul(lpTotalSupply).div(pairReserves.reserve1));
|
||||||
const lpTokensToMint = lpTokensFromA.gt(lpTokensFromB) ? lpTokensFromB : lpTokensFromA;
|
const lpTokensToMint = lpTokensFromA.gt(lpTokensFromB) ? lpTokensFromB : lpTokensFromA;
|
||||||
return lpTokensToMint;
|
return lpTokensToMint;
|
||||||
} else {
|
} else {
|
||||||
|
@ -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 { getTokenAddress, getTokenIcons, getTokenName, getBondNameDisplayName, getTokenPurchaseLink } from "../helpers";
|
import { 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,9 +100,7 @@ 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.sub(priceInUsd).div(baseTokenPerUsd);
|
||||||
? quoteTokenPerUsd.sub(priceInUsd).div(quoteTokenPerUsd)
|
|
||||||
: new DecimalBigNumber("0", quoteTokenDecimals);
|
|
||||||
|
|
||||||
const capacityInBaseToken = capacityInQuote
|
const capacityInBaseToken = capacityInQuote
|
||||||
? new DecimalBigNumber(marketPrice > 0n ? marketCapacity / marketPrice : 0n, 9)
|
? new DecimalBigNumber(marketPrice > 0n ? marketCapacity / marketPrice : 0n, 9)
|
||||||
@ -126,8 +124,7 @@ 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),
|
||||||
@ -143,7 +140,6 @@ 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