Skip to content

Commit 887f158

Browse files
committed
fix(perps): use PRICE_RANGES_UNIVERSAL for compact order row prices
Open orders displayed trigger/limit prices with fixed 2 decimals via PRICE_RANGES_MINIMAL_VIEW. Changed to PRICE_RANGES_UNIVERSAL to match market price precision (0 for BTC, 2 for mid-range, up to 6 for micro-cap tokens).
1 parent 1c2233f commit 887f158

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

app/components/UI/Perps/components/PerpsCompactOrderRow/PerpsCompactOrderRow.test.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jest.mock('../../../../../component-library/hooks', () => ({
2222
jest.mock('../../utils/formatUtils', () => ({
2323
formatPositionSize: jest.fn((value) => value),
2424
formatPerpsFiat: jest.fn((value) => `$${value.toFixed(2)}`),
25-
PRICE_RANGES_MINIMAL_VIEW: {},
25+
PRICE_RANGES_UNIVERSAL: [{ id: 'universal' }],
2626
}));
2727

2828
jest.mock('@metamask/perps-controller', () => ({
@@ -157,6 +157,17 @@ describe('PerpsCompactOrderRow', () => {
157157
expect(formatPerpsFiat).toHaveBeenCalledWith(50000, expect.any(Object));
158158
});
159159

160+
it('formats price with PRICE_RANGES_UNIVERSAL for market-appropriate decimals', () => {
161+
const { formatPerpsFiat, PRICE_RANGES_UNIVERSAL } = jest.requireMock(
162+
'../../utils/formatUtils',
163+
);
164+
render(<PerpsCompactOrderRow order={mockLimitBuyOrder} />);
165+
166+
expect(formatPerpsFiat).toHaveBeenCalledWith(50000, {
167+
ranges: PRICE_RANGES_UNIVERSAL,
168+
});
169+
});
170+
160171
it('calls onPress when tapped', () => {
161172
const mockOnPress = jest.fn();
162173
render(

app/components/UI/Perps/components/PerpsCompactOrderRow/PerpsCompactOrderRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useStyles } from '../../../../../component-library/hooks';
88
import {
99
formatPositionSize,
1010
formatPerpsFiat,
11-
PRICE_RANGES_MINIMAL_VIEW,
11+
PRICE_RANGES_UNIVERSAL,
1212
} from '../../utils/formatUtils';
1313
import { getPerpsDisplaySymbol, type Order } from '@metamask/perps-controller';
1414
import { strings } from '../../../../../../locales/i18n';
@@ -49,7 +49,7 @@ const PerpsCompactOrderRow: React.FC<PerpsCompactOrderRowProps> = ({
4949
const formattedPrice =
5050
priceValue !== null
5151
? formatPerpsFiat(priceValue, {
52-
ranges: PRICE_RANGES_MINIMAL_VIEW,
52+
ranges: PRICE_RANGES_UNIVERSAL,
5353
})
5454
: strings('perps.order.market');
5555

0 commit comments

Comments
 (0)