markdown multiplication for correct representation of bond price, including LP bonds

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2025-06-05 17:23:37 +03:00
parent 42ebad8697
commit 3b11ac0162
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
4 changed files with 30 additions and 3 deletions

View File

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

File diff suppressed because one or more lines are too long

View File

@ -48,6 +48,10 @@ export const GHOST_GOVERNANCE_ADDRESSES = {
[NetworkId.TESTNET_SEPOLIA]: "0xD40E6442Ee01c234CD8AaF335122CfbB2aec8548", [NetworkId.TESTNET_SEPOLIA]: "0xD40E6442Ee01c234CD8AaF335122CfbB2aec8548",
}; };
export const BONDING_CALCULATOR_ADDRESSES = {
[NetworkId.TESTNET_SEPOLIA]: "0x29a6bb5De7a1049632E107544CaEF05e518451e7",
}
export const UNISWAP_V2_ROUTER = { export const UNISWAP_V2_ROUTER = {
[NetworkId.TESTNET_SEPOLIA]: "0xee567fe1712faf6149d80da1e6934e354124cfe3", [NetworkId.TESTNET_SEPOLIA]: "0xee567fe1712faf6149d80da1e6934e354124cfe3",
}; };

View File

@ -4,9 +4,14 @@ import toast from "react-hot-toast";
import { config } from "../../config"; import { config } from "../../config";
import { BOND_DEPOSITORY_ADDRESSES, DAO_TREASURY_ADDRESSES } from "../../constants/addresses"; import {
BOND_DEPOSITORY_ADDRESSES,
DAO_TREASURY_ADDRESSES,
BONDING_CALCULATOR_ADDRESSES,
} from "../../constants/addresses";
import { abi as BondAbi } from "../../abi/GhostBondDepository.json"; 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 { abi as BondingCalculatorAbi } from "../../abi/GhostBondingCalculator.json";
import { useFtsoPrice } from "../prices"; import { useFtsoPrice } from "../prices";
import { getTokenAddress, getTokenIcons, getTokenName, getBondNameDisplayName, getTokenPurchaseLink } from "../helpers"; import { getTokenAddress, getTokenIcons, getTokenName, getBondNameDisplayName, getTokenPurchaseLink } from "../helpers";
@ -85,6 +90,20 @@ export const useLiveBonds = (chainId) => {
}) })
}); });
const { data: markdowns } = useReadContracts({
contracts: markets?.map((_, index) => {
const quoteTokenAddress = markets?.at(index).result?.at(1) ? markets.at(index).result.at(1) : "";
return {
abi: BondingCalculatorAbi,
address: BONDING_CALCULATOR_ADDRESSES[chainId],
functionName: "markdown",
args: [quoteTokenAddress],
scopeKey: `markdown-${quoteTokenAddress}-${chainId}`,
chainId: chainId,
}
})
});
const liveBonds = liveIndexesRaw ? liveIndexesRaw.map((bondIndex, index) => { const liveBonds = liveIndexesRaw ? liveIndexesRaw.map((bondIndex, index) => {
const id = Number(bondIndex); const id = Number(bondIndex);
@ -97,9 +116,12 @@ export const useLiveBonds = (chainId) => {
const quoteTokenPerUsd = quotePrices?.at(index).result const quoteTokenPerUsd = quotePrices?.at(index).result
? new DecimalBigNumber(quotePrices.at(index).result * (10n ** 9n), quoteTokenDecimals) ? new DecimalBigNumber(quotePrices.at(index).result * (10n ** 9n), quoteTokenDecimals)
: new DecimalBigNumber(0n, quoteTokenDecimals); : new DecimalBigNumber(0n, quoteTokenDecimals);
const markdown = markdowns?.at(index).result
? new DecimalBigNumber(markdowns.at(index).result, quoteTokenDecimals)
: new DecimalBigNumber(1n, 0);
const quoteTokenPerBaseToken = new DecimalBigNumber(marketPrice, 9); const quoteTokenPerBaseToken = new DecimalBigNumber(marketPrice, 9);
const priceInUsd = quoteTokenPerUsd.mul(quoteTokenPerBaseToken); const priceInUsd = quoteTokenPerUsd.mul(quoteTokenPerBaseToken).mul(markdown);
const discount = baseTokenPerUsd._value > 0n const discount = baseTokenPerUsd._value > 0n
? baseTokenPerUsd.sub(priceInUsd).div(baseTokenPerUsd) ? baseTokenPerUsd.sub(priceInUsd).div(baseTokenPerUsd)
: new DecimalBigNumber("0", baseTokenPerUsd._decimals); : new DecimalBigNumber("0", baseTokenPerUsd._decimals);