From 7733a6cd3bed5acb7b5a8d236a8c94d4f5f7519d Mon Sep 17 00:00:00 2001 From: Uncle Fatso Date: Fri, 20 Feb 2026 18:57:04 +0300 Subject: [PATCH] fix for the min collateral needed Signed-off-by: Uncle Fatso --- package.json | 2 +- src/hooks/governance/index.js | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 5747130..5d67954 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ghost-dao-interface", "private": true, - "version": "0.5.29", + "version": "0.5.30", "type": "module", "scripts": { "dev": "vite", diff --git a/src/hooks/governance/index.js b/src/hooks/governance/index.js index a29f631..0e82777 100644 --- a/src/hooks/governance/index.js +++ b/src/hooks/governance/index.js @@ -96,6 +96,7 @@ export const useMinQuorum = (chainId) => { export const useProposalThreshold = (chainId, name) => { const decimals = getTokenDecimals(name); + const { proposalCount } = useProposalCount(chainId); const { data } = useReadContract({ abi: GovernorStorageAbi, @@ -113,18 +114,18 @@ export const useProposalThreshold = (chainId, name) => { chainId: chainId, }); + const lastIndex = proposalCount === 0n ? 0n : proposalCount - 1n; + const { proposalId } = useProposalDetailsAt(chainId, lastIndex, { + enabled: proposalCount !== 0n + }); + const { state } = useProposalState(chainId, proposalId, { + enabled: proposalCount !== 0n && !!proposalId + }); + let threshold = new DecimalBigNumber(data ?? 0n, decimals); - const { proposalCount } = useProposalCount(chainId); - - if (proposalCount !== 0n) { - const lastIndex = proposalCount === 0n ? 0n : proposalCount - 1n - const { proposalId } = useProposalDetailsAt(chainId, lastIndex); - const { state } = useProposalState(chainId, proposalId); - - if (state < 2) { - threshold = new DecimalBigNumber(activeProposedLock ?? 0n, decimals); - } + if (proposalCount !== 0n && state !== undefined && state < 2) { + threshold = new DecimalBigNumber(activeProposedLock ?? 0n, decimals); } return { threshold };