Skip to content

Commit 2db9256

Browse files
authored
Merge branch 'main' into rn-upgrade/0.81.5-no-unit-tests
2 parents 68b4a40 + 5bfeb29 commit 2db9256

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

app/components/UI/Rewards/components/Campaigns/OndoActivityRow.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ describe('OndoActivityRow', () => {
104104
expect(getByText('—')).toBeDefined();
105105
});
106106

107+
it('renders rebalance entry USD without a plus sign for positive amounts', () => {
108+
const { getByText } = render(
109+
<OndoActivityRow
110+
entry={createEntry({ type: 'REBALANCE', usdAmount: '5000.000000' })}
111+
/>,
112+
);
113+
114+
expect(getByText('Rebalance')).toBeDefined();
115+
// formatUsd (rebalance) has no '+'; deposit/withdraw still use mocked formatSignedUsd
116+
expect(getByText(/^\$5,000/)).toBeDefined();
117+
});
118+
107119
it('renders external outflow entry with shortened destAddress', () => {
108120
const { getByText } = render(
109121
<OndoActivityRow

app/components/UI/Rewards/components/Campaigns/OndoActivityRow.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
formatRewardsDate,
3030
formatRewardsTimeOnly,
3131
formatSignedUsd,
32+
formatUsd,
3233
getChainHex,
3334
shortenAddress,
3435
} from '../../utils/formatUtils';
@@ -51,6 +52,24 @@ const LABEL_KEY_MAP: Record<ActivityEntryType, string> = {
5152
const tokenLabel = (token: ActivityTokenDto): string =>
5253
token.tokenSymbol || token.tokenName;
5354

55+
/** Rebalance USD is not portfolio P&L; omit the '+' used for signed inflows/outflows. */
56+
const formatActivityUsd = (
57+
usdAmount: OndoGmActivityEntryDto['usdAmount'],
58+
entryType: ActivityEntryType,
59+
): string => {
60+
if (entryType !== 'REBALANCE') {
61+
return formatSignedUsd(usdAmount);
62+
}
63+
if (usdAmount === null) {
64+
return '—';
65+
}
66+
const num = typeof usdAmount === 'number' ? usdAmount : parseFloat(usdAmount);
67+
if (Number.isNaN(num)) {
68+
return '—';
69+
}
70+
return formatUsd(usdAmount);
71+
};
72+
5473
interface OndoActivityRowProps {
5574
entry: OndoGmActivityEntryDto;
5675
timeOnly?: boolean;
@@ -123,7 +142,7 @@ const OndoActivityRow: React.FC<OndoActivityRowProps> = ({
123142
{label}
124143
</Text>
125144
<Text variant={TextVariant.BodyMd} fontWeight={FontWeight.Medium}>
126-
{formatSignedUsd(entry.usdAmount)}
145+
{formatActivityUsd(entry.usdAmount, entryType)}
127146
</Text>
128147
</Box>
129148

0 commit comments

Comments
 (0)