Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/components/futarchyFi/marketPage/MarketPageShowcase.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2902,6 +2902,21 @@ const MarketPageShowcase = ({ hidden = false, debugMode = false, proposal = null
native: rawBalances.native // Native xDAI balance
}), [rawBalances]);

// Detect whether the user holds any active conditional-token position
const hasActivePosition = useMemo(() => {
try {
const currDiff = ethers.utils.parseUnits(
positions?.currencyYes?.total || '0', 18
).sub(ethers.utils.parseUnits(positions?.currencyNo?.total || '0', 18));
const compDiff = ethers.utils.parseUnits(
positions?.companyYes?.total || '0', 18
).sub(ethers.utils.parseUnits(positions?.companyNo?.total || '0', 18));
return !currDiff.isZero() || !compDiff.isZero();
} catch {
return false;
}
}, [positions]);

// Balance manager handles wallet disconnection automatically

const [showEventDetails, setShowEventDetails] = useState(false);
Expand Down Expand Up @@ -4553,6 +4568,8 @@ const MarketPageShowcase = ({ hidden = false, debugMode = false, proposal = null
const handleTransactionComplete = (transactionDetails) => {
// Refresh balances or any other state that needs updating
refetchBalances();
// Auto-switch to Position tab so the user sees their updated position
setActiveTab('position');
};

// Add selectedAction state
Expand Down Expand Up @@ -5282,6 +5299,9 @@ const MarketPageShowcase = ({ hidden = false, debugMode = false, proposal = null
}`}
>
Position
{hasActivePosition && (
<span className="inline-block w-1.5 h-1.5 ml-1 rounded-full bg-futarchyGreen9" />
)}
</button>
</>
)}
Expand Down