diff --git a/packages/page-treasury/src/Overview/Summary.tsx b/packages/page-treasury/src/Overview/Summary.tsx
index 05e1a57f96..fceab19186 100644
--- a/packages/page-treasury/src/Overview/Summary.tsx
+++ b/packages/page-treasury/src/Overview/Summary.tsx
@@ -3,7 +3,7 @@
import type { BN } from '@polkadot/util';
-import React from 'react';
+import React, { useMemo } from 'react';
import { CardSummary, SummaryBox } from '@polkadot/react-components';
import { useApi, useBestNumber, useCall, useTreasury } from '@polkadot/react-hooks';
@@ -22,36 +22,61 @@ function Summary ({ approvalCount, proposalCount }: Props): React.ReactElement
(api.query.treasury.proposalCount);
+ const { burn, pendingBounties, pendingProposals, spendPeriod, value } = useTreasury();
- const { burn, spendPeriod, value } = useTreasury();
+ const spendable = useMemo(
+ () => value && value.sub(pendingBounties).sub(pendingProposals),
+ [value, pendingBounties, pendingProposals]
+ );
return (
- ('proposals')}>
+ ('open')}
+ >
{formatNumber(proposalCount)}
- ('total')}>
+ ('approved')}
+ >
+ {formatNumber(approvalCount)}
+
+ ('total')}
+ >
{formatNumber(totalProposals || 0)}
-
- ('approved')}>
- {formatNumber(approvalCount)}
-
-
- {value && (
- ('available')}>
+ {!pendingProposals.isZero() && (
+ ('approved')}
+ >
+
+ )}
+ {!pendingBounties.isZero() && (
+ ('bounties')}
+ >
+
)}
{burn && (
('next burn')}
>
)}
+ {value && spendable && (
+
+ ('spendable / available')}
+ progress={{
+ hideValue: true,
+ total: value,
+ value: spendable
+ }}
+ >
+
+ <> / >
+
+
+
+ )}
{bestNumber && spendPeriod?.gtn(0) && (
(() => ({
+ pendingBounties: BN_ZERO,
+ pendingProposals: BN_ZERO,
spendPeriod: api.consts.treasury
? api.consts.treasury.spendPeriod
: BN_ZERO,
@@ -36,14 +41,18 @@ function useTreasuryImpl (): Result {
EMPTY_U8A_32
).subarray(0, 32)
}));
+ const bounties = useCall(api.derive.bounties?.bounties);
+ const treasuryProposals = useCall(api.derive.treasury.proposals);
const treasuryBalance = useCall(api.derive.balances?.account, [result.treasuryAccount]);
useEffect((): void => {
treasuryBalance && api.consts.treasury &&
- setResult(({ spendPeriod, treasuryAccount }) => ({
+ setResult(({ pendingBounties, pendingProposals, spendPeriod, treasuryAccount }) => ({
burn: treasuryBalance.freeBalance.gt(BN_ZERO) && !api.consts.treasury.burn.isZero()
? api.consts.treasury.burn.mul(treasuryBalance.freeBalance).div(BN_MILLION)
: BN_ZERO,
+ pendingBounties,
+ pendingProposals,
spendPeriod,
treasuryAccount,
value: treasuryBalance.freeBalance.gt(BN_ZERO)
@@ -52,6 +61,27 @@ function useTreasuryImpl (): Result {
}));
}, [api, treasuryBalance]);
+ useEffect((): void => {
+ treasuryProposals &&
+ setResult((prev) => ({
+ ...prev,
+ pendingProposals: treasuryProposals.approvals.reduce((total, { proposal: { value } }) =>
+ total.iadd(value), new BN(0)
+ ),
+ totalProposals: treasuryProposals.proposalCount.toNumber()
+ }));
+ }, [treasuryProposals]);
+
+ useEffect((): void => {
+ bounties &&
+ setResult((prev) => ({
+ ...prev,
+ pendingBounties: bounties.reduce((total, { bounty: { value } }) =>
+ total.iadd(value), new BN(0)
+ )
+ }));
+ }, [bounties]);
+
return result;
}