fix record in history for unstake and add liquidity

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2026-11-15 15:26:32 +03:00
parent feb3c34455
commit 3b2dd422fa
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
7 changed files with 208 additions and 41 deletions

View File

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

View File

@ -89,6 +89,7 @@ export const ClaimBonds = ({ chainId, address, secondsTo }) => {
breakoutFromBonding({ defaultFunction, toExecute, amount, warmupLeft })
}
await notesRefetch();
setPendingIndexes([]);
setIsPending(false);
}

View File

@ -123,7 +123,6 @@ const BondModalClaim = ({ chainId, isOpen, close, config, historyRecord }) => {
/>
</Box>
<Box display="flex" flexDirection="column" justifyContent="space-between" width="100%">
<Box display="flex" justifyContent="space-between" width="100%">
<Typography>Receiver</Typography>

View File

@ -10,14 +10,16 @@ import GhostStyledIcon from "../../components/Icon/GhostIcon";
import { PrimaryButton } from "../../components/Button";
import { abi as UniswapV2PairAbi } from "../../abi/UniswapV2Pair.json";
import { formatNumber, shorten } from "../../helpers";
import { formatNumber, formatCurrency, shorten } from "../../helpers";
import { DecimalBigNumber } from "../../helpers/DecimalBigNumber";
import { useLocalStorage } from "../../hooks/localstorage";
import TokenBox from "./TokenBox";
const DexViewModal = ({ chainId, isOpen, close, config, historyRecord }) => {
const DexSwapViewModal = ({ chainId, isOpen, close, config, historyRecord }) => {
if (historyRecord === null) return null;
const { data: receipt, isLoading, error } = useTransactionReceipt({
const { data: receipt } = useTransactionReceipt({
hash: historyRecord?.txHash,
query: {
enabled: !!historyRecord?.txHash && isOpen,
@ -163,4 +165,195 @@ const DexViewModal = ({ chainId, isOpen, close, config, historyRecord }) => {
)
}
const DexAddViewModal = ({ chainId, isOpen, close, config, historyRecord }) => {
if (historyRecord === null) return null;
const { data: receipt } = useTransactionReceipt({
hash: historyRecord?.txHash,
query: {
enabled: !!historyRecord?.txHash && isOpen,
}
});
const allDecodedLogs = useMemo(() => {
if (!receipt?.logs) return [];
return receipt.logs.map((log) => {
try {
const decoded = decodeEventLog({
abi: UniswapV2PairAbi,
data: log.data,
topics: log.topics,
});
return {
eventName: decoded.eventName,
args: decoded.args,
address: log.address
};
} catch (e) {
return null;
}
}).filter(Boolean);
}, [receipt]);
const mintInfo = useMemo(() => {
const mintEvent = allDecodedLogs.find(l => l.eventName === 'Mint');
if (!mintEvent) return null;
const tokenTransfers = allDecodedLogs.filter(
l => l.eventName === 'Transfer' && l.address.toLowerCase() !== mintEvent.address.toLowerCase()
);
const lpMintTransfer = allDecodedLogs.find(
l =>
l.eventName === 'Transfer' &&
l.address.toLowerCase() === mintEvent.address.toLowerCase() &&
l.args.from === "0x0000000000000000000000000000000000000000"
);
const token0Log = tokenTransfers.find(t => t.args.value === mintEvent.args.amount0);
const token1Log = tokenTransfers.find(
t => t.args.value === mintEvent.args.amount1 && t !== token0Log
);
return {
pairAddress: mintEvent.address,
sender: mintEvent.args.sender,
recipient: lpMintTransfer?.args?.to || receipt?.from,
token0Address: token0Log?.address,
token1Address: token1Log?.address,
amount0: mintEvent.args.amount0,
amount1: mintEvent.args.amount1,
lpAmount: lpMintTransfer?.args?.value ?? 0n,
};
}, [allDecodedLogs, receipt]);
const { data: token0 } = useToken({
address: mintInfo?.token0Address,
scopeKey: `token-${mintInfo ? mintInfo.token0Address : ""}-${chainId}`,
chainId
});
const { data: token1 } = useToken({
address: mintInfo?.token1Address,
scopeKey: `token-${mintInfo ? mintInfo.token1Address : ""}-${chainId}`,
chainId
});
const chainInfo = useMemo(() => {
const client = config?.getClient();
return {
url: client?.chain?.blockExplorers?.default?.url,
symbol: client?.chain?.nativeCurrency?.symbol,
};
}, [config]);
return (
<Modal
maxWidth="420px"
minHeight="200px"
open={isOpen}
headerText={
<>
{mintInfo && "DEX Add Liquidity"}
{!mintInfo && "Parsing Transaction Hash"}
</>
}
onClose={() => close()}
>
{mintInfo && (
<Box display="flex" flexDirection="column" gap="15px">
<Box width="100%" display="flex" flexDirection="column" justifyContent="space-between" alignItems="flex-start">
<Box display="flex" justifyContent="space-between" width="100%">
<Typography>Recipient</Typography>
<Link
href={`${chainInfo.url}/address/${mintInfo.recipient}`}
target="_blank"
rel="noopener noreferrer"
>
<Typography>{shorten(mintInfo.recipient, 12, -10)}</Typography>
</Link>
</Box>
<Box display="flex" justifyContent="space-between" width="100%">
<Typography>Liquidity Pool</Typography>
<Link
href={`${chainInfo.url}/address/${mintInfo.pairAddress}`}
target="_blank"
rel="noopener noreferrer"
>
<Typography>{shorten(mintInfo.pairAddress, 12, -10)}</Typography>
</Link>
</Box>
<Box display="flex" justifyContent="space-between" width="100%">
<Typography>Liquidity Amount</Typography>
<Typography>{formatCurrency(new DecimalBigNumber(mintInfo.lpAmount, 18), 10, "LP")}</Typography>
</Box>
</Box>
<Box width="100%" display="flex" flexDirection="row" justifyContent="space-around" alignItems="center">
<TokenBox
tokenAmount={mintInfo.amount0}
tokenSymbol={token0 ? token0.symbol : "Unknown"}
decimals={token0 ? token0.decimals : 18}
chainTokenSymbol={token0?.symbol?.toUpperCase() === "WETH" ? undefined : chainInfo.symbol}
/>
<Typography variant="h6">+</Typography>
<TokenBox
tokenAmount={mintInfo.amount1}
tokenSymbol={token1 ? token1.symbol : "Unknown"}
decimals={token1 ? token1.decimals : 18}
chainTokenSymbol={token1?.symbol?.toUpperCase() === "WETH" ? undefined : chainInfo.symbol}
/>
</Box>
<PrimaryButton
fullWidth
component="a"
href={`${chainInfo.url}/tx/${historyRecord.txHash}`}
target="_blank"
rel="noopener noreferrer"
>
View Transaction Details
</PrimaryButton>
</Box>
)}
</Modal>
)
}
const DexViewModal = ({ chainId, isOpen, close, config, historyRecord }) => {
const { CONSTANTS } = useLocalStorage();
switch (historyRecord.name) {
case CONSTANTS.dex.swap:
return (
<DexSwapViewModal
chainId={chainId}
isOpen={isOpen}
close={close}
config={config}
historyRecord={historyRecord}
/>
);
case CONSTANTS.dex.add:
return (
<DexAddViewModal
chainId={chainId}
isOpen={isOpen}
close={close}
config={config}
historyRecord={historyRecord}
/>
);
default:
return null;
}
}
export default DexViewModal;

View File

@ -241,7 +241,7 @@ const HistoryList = ({ chainId, storedTransactions, historyType, config, eraseRe
</TableContainer>
)
}
}, [isSmallScreen, storedTransactions, config]);
}, [isSmallScreen, currentTime, storedTransactions, config]);
return (
<>

View File

@ -16,34 +16,7 @@ import { formatNumber, shorten } from "../../helpers";
import { useTokenSymbol } from "../../hooks/tokens";
import { getTokenDecimals } from "../../hooks/helpers";
const TokenBox = ({ tokenAmount, tokenSymbol, decimals, chainTokenSymbol }) => {
return (
<Box display="flex" flexDirection="column" width="70px">
<Token
parentSx={{
height: "80px",
"& svg:nth-of-type(2)": {
transform: "translate(10%, -50%)",
zIndex: 100,
}
}}
sx={{ transform: "scale(1.65)", }}
chainTokenName={chainTokenSymbol}
name={tokenSymbol}
/>
<Box display="flex" flexDirection="column" alignItems="center">
<Typography>{tokenSymbol}</Typography>
<Typography>{formatNumber(
new DecimalBigNumber(tokenAmount ? tokenAmount : 0n, decimals),
5
)}</Typography>
</Box>
</Box>
)
}
import TokenBox from "./TokenBox";
const StakingViewModal = ({ chainId, isOpen, close, config, historyRecord }) => {
if (historyRecord === null) return null;
@ -78,7 +51,7 @@ const StakingViewModal = ({ chainId, isOpen, close, config, historyRecord }) =>
}, [receipt]);
const stakeInfo = useMemo(() => {
return allDecodedLogs.find(l => l.eventName === 'Staked');
return allDecodedLogs.find(l => l.eventName === 'Staked' || l.eventName === 'Unstaked');
}, [allDecodedLogs]);
const { symbol: ftsoSymbol } = useTokenSymbol(chainId, "FTSO");
@ -100,7 +73,7 @@ const StakingViewModal = ({ chainId, isOpen, close, config, historyRecord }) =>
open={isOpen}
headerText={
<>
{stakeInfo && "Staked"}
{stakeInfo && historyRecord.name}
{!stakeInfo && "Parsing Transaction Hash"}
</>
}

View File

@ -210,13 +210,14 @@ export const getTokenPurchaseLink = (chainId, tokenAddress, chainName) => {
let purchaseUrl = `https://app.dao.ghostchain.io/#/${chainName}/dex/uniswap`;
switch (tokenAddress) {
case RESERVE_ADDRESSES[chainId]:
purchaseUrl = `https://app.dao.ghostchain.io/#/${chainName}/faucet`;
if (chainId == 63) {
purchaseUrl = `https://app.dao.ghostchain.io/#/${chainName}/wrapper`;
}
purchaseUrl = `https://ghostchain.io/faucet/`;
break;
case FTSO_RESERVE_LP_ADDRESSES[chainId]:
purchaseUrl += `?pool=true&from=${RESERVE_ADDRESSES[chainId]}&to=${FTSO_ADDRESSES[chainId]}`;
const reserve = RESERVE_ADDRESSES[chainId] === WETH_ADDRESSES[chainId]
? "0x0000000000000000000000000000000000000000"
: RESERVE_ADDRESSES[chainId];
purchaseUrl += `?pool=true&from=${reserve}&to=${FTSO_ADDRESSES[chainId]}`;
break;
}
return purchaseUrl;