Skip to content
Closed
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
21 changes: 21 additions & 0 deletions src/components/common/TradeDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ const TradeDialog: React.FC<TradeDialogProps> = ({
const amountValid = validationError === null;
const showError = touched && validationError !== null;

const estimatedProceedsStroops = useMemo(() => {
if (side !== 'sell') return null;
if (!keyPriceStroops || !Number.isFinite(keyPriceStroops)) return null;
if (!parsedAmount || !Number.isFinite(parsedAmount) || parsedAmount <= 0) return null;
return keyPriceStroops * parsedAmount;
}, [side, keyPriceStroops, parsedAmount]);

const title = side === 'buy' ? 'Buy keys' : 'Sell keys';
const confirmLabel = side === 'buy' ? 'Confirm buy' : 'Confirm sell';
const estimatedNetworkFee = formatTransactionFeeDisplay(
Expand Down Expand Up @@ -177,6 +184,20 @@ const TradeDialog: React.FC<TradeDialogProps> = ({
className="text-white/45"
/>
)}
{side === 'sell' && (
<div className="text-xs text-white/45">
{estimatedProceedsStroops != null ? (
<>
Approximate proceeds:{' '}
<span className="font-semibold text-amber-300/90 tabular-nums">
{formatDisplayKeyPrice(estimatedProceedsStroops)}
</span>
</>
) : (
'Approximate proceeds unavailable'
)}
</div>
)}
</div>

{/*
Expand Down
Loading