Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ describe('OndoActivityRow', () => {
expect(getByText('—')).toBeDefined();
});

it('renders rebalance entry USD without a plus sign for positive amounts', () => {
const { getByText } = render(
<OndoActivityRow
entry={createEntry({ type: 'REBALANCE', usdAmount: '5000.000000' })}
/>,
);

expect(getByText('Rebalance')).toBeDefined();
// formatUsd (rebalance) has no '+'; deposit/withdraw still use mocked formatSignedUsd
expect(getByText(/^\$5,000/)).toBeDefined();
});

it('renders external outflow entry with shortened destAddress', () => {
const { getByText } = render(
<OndoActivityRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
formatRewardsDate,
formatRewardsTimeOnly,
formatSignedUsd,
formatUsd,
getChainHex,
shortenAddress,
} from '../../utils/formatUtils';
Expand All @@ -51,6 +52,24 @@ const LABEL_KEY_MAP: Record<ActivityEntryType, string> = {
const tokenLabel = (token: ActivityTokenDto): string =>
token.tokenSymbol || token.tokenName;

/** Rebalance USD is not portfolio P&L; omit the '+' used for signed inflows/outflows. */
const formatActivityUsd = (
usdAmount: OndoGmActivityEntryDto['usdAmount'],
entryType: ActivityEntryType,
): string => {
if (entryType !== 'REBALANCE') {
return formatSignedUsd(usdAmount);
}
if (usdAmount === null) {
return '—';
}
const num = typeof usdAmount === 'number' ? usdAmount : parseFloat(usdAmount);
if (Number.isNaN(num)) {
return '—';
}
return formatUsd(usdAmount);
};

interface OndoActivityRowProps {
entry: OndoGmActivityEntryDto;
timeOnly?: boolean;
Expand Down Expand Up @@ -123,7 +142,7 @@ const OndoActivityRow: React.FC<OndoActivityRowProps> = ({
{label}
</Text>
<Text variant={TextVariant.BodyMd} fontWeight={FontWeight.Medium}>
{formatSignedUsd(entry.usdAmount)}
{formatActivityUsd(entry.usdAmount, entryType)}
</Text>
</Box>

Expand Down
Loading