Skip to content
Open
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 @@ -912,7 +912,8 @@ const PerpsOrderViewContentBase: React.FC = () => {
variant={TextVariant.BodyMD}
color={TextColor.Default}
>
{orderForm.limitPrice
{orderForm.limitPrice !== undefined &&
orderForm.limitPrice !== null
? formatPerpsFiat(orderForm.limitPrice, {
ranges: PRICE_RANGES_UNIVERSAL,
})
Expand Down Expand Up @@ -1006,7 +1007,7 @@ const PerpsOrderViewContentBase: React.FC = () => {
</TouchableOpacity>
</View>
<Text variant={TextVariant.BodyMD} color={TextColor.Alternative}>
{marginRequired
{marginRequired !== undefined && marginRequired !== null
? formatPerpsFiat(marginRequired, {
ranges: PRICE_RANGES_MINIMAL_VIEW,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Text, {
import { useStyles } from '../../../../../component-library/hooks';
import PerpsPositionCard from '../../components/PerpsPositionCard';
import PerpsTPSLBottomSheet from '../../components/PerpsTPSLBottomSheet';
import { PERPS_CONSTANTS } from '../../constants/perpsConfig';
import type { Position } from '../../controllers/types';
import { usePerpsLivePositions, usePerpsTPSLUpdate } from '../../hooks';
import { usePerpsLiveAccount } from '../../hooks/stream';
Expand Down Expand Up @@ -172,9 +173,12 @@ const PerpsPositionsView: React.FC = () => {
{strings('perps.position.account.total_balance')}
</Text>
<Text variant={TextVariant.BodySMMedium} color={TextColor.Default}>
{formatPerpsFiat(account?.totalBalance || '0', {
ranges: PRICE_RANGES_MINIMAL_VIEW,
})}
{account?.totalBalance !== undefined &&
account?.totalBalance !== null
? formatPerpsFiat(account.totalBalance, {
ranges: PRICE_RANGES_MINIMAL_VIEW,
})
: PERPS_CONSTANTS.FALLBACK_DATA_DISPLAY}
</Text>
</View>

Expand All @@ -183,9 +187,12 @@ const PerpsPositionsView: React.FC = () => {
{strings('perps.position.account.available_balance')}
</Text>
<Text variant={TextVariant.BodySMMedium} color={TextColor.Default}>
{formatPerpsFiat(account?.availableBalance || '0', {
ranges: PRICE_RANGES_MINIMAL_VIEW,
})}
{account?.availableBalance !== undefined &&
account?.availableBalance !== null
? formatPerpsFiat(account.availableBalance, {
ranges: PRICE_RANGES_MINIMAL_VIEW,
})
: PERPS_CONSTANTS.FALLBACK_DATA_DISPLAY}
</Text>
</View>

Expand All @@ -194,9 +201,11 @@ const PerpsPositionsView: React.FC = () => {
{strings('perps.position.account.margin_used')}
</Text>
<Text variant={TextVariant.BodySMMedium} color={TextColor.Default}>
{formatPerpsFiat(account?.marginUsed || '0', {
ranges: PRICE_RANGES_MINIMAL_VIEW,
})}
{account?.marginUsed !== undefined && account?.marginUsed !== null
? formatPerpsFiat(account.marginUsed, {
ranges: PRICE_RANGES_MINIMAL_VIEW,
})
: PERPS_CONSTANTS.FALLBACK_DATA_DISPLAY}
</Text>
</View>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ describe('PerpsOrderTransactionView', () => {
expect(getByText('Hyperliquid fee')).toBeTruthy();
expect(getByText('Total fee')).toBeTruthy();
expect(getByText('$3')).toBeTruthy();
expect(getByText('$7.5')).toBeTruthy();
expect(getByText('$10.5')).toBeTruthy();
expect(getByText('$7.50')).toBeTruthy();
expect(getByText('$10.50')).toBeTruthy();
});

it('should show zero fees when order is not filled', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,26 @@ const PerpsPositionTransactionView: React.FC = () => {
),
)}`,
},
transaction.fill?.entryPrice && {
label:
transaction.fill?.action === 'Closed'
? strings('perps.transactions.position.close_price')
: strings('perps.transactions.position.entry_price'),
value: `${formatPerpsFiat(transaction.fill?.entryPrice || '0')}`,
},
transaction.fill?.entryPrice !== undefined &&
transaction.fill?.entryPrice !== null && {
label:
transaction.fill?.action === 'Closed'
? strings('perps.transactions.position.close_price')
: strings('perps.transactions.position.entry_price'),
value: formatPerpsFiat(transaction.fill.entryPrice),
},
].filter(Boolean);

// Secondary detail rows - only show if values exist
const secondaryDetailRows = [
transaction.fill?.fee && {
label: strings('perps.transactions.position.fees'),
value: `${
BigNumber(transaction.fill?.fee).isGreaterThan(0.01)
? formatPerpsFiat(transaction.fill?.fee || '0')
: `$${transaction.fill?.fee || '0'}`
}`,
textColor: TextColor.Default,
},
transaction.fill?.fee !== undefined &&
transaction.fill?.fee !== null && {
label: strings('perps.transactions.position.fees'),
value: BigNumber(transaction.fill.fee).isGreaterThan(0.01)
? formatPerpsFiat(transaction.fill.fee)
: `$${transaction.fill.fee}`,
textColor: TextColor.Default,
},
].filter(Boolean);

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ const PerpsLimitPriceBottomSheet: React.FC<PerpsLimitPriceBottomSheetProps> = ({
{/* Current market price below input */}
<Text style={styles.marketPriceText}>
{asset}-USD{' '}
{currentPrice
{currentPrice !== undefined && currentPrice !== null
? formatPerpsFiat(currentPrice, {
ranges: PRICE_RANGES_UNIVERSAL,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ const PerpsOpenOrderCard: React.FC<PerpsOpenOrderCardProps> = ({
{strings('perps.order.take_profit')}
</Text>
<Text variant={TextVariant.BodyMD} color={TextColor.Default}>
{order.takeProfitPrice
{order.takeProfitPrice !== undefined &&
order.takeProfitPrice !== null
? formatPerpsFiat(order.takeProfitPrice, {
ranges: PRICE_RANGES_UNIVERSAL,
})
Expand All @@ -294,7 +295,8 @@ const PerpsOpenOrderCard: React.FC<PerpsOpenOrderCardProps> = ({
{strings('perps.order.stop_loss')}
</Text>
<Text variant={TextVariant.BodyMD} color={TextColor.Default}>
{order.stopLossPrice
{order.stopLossPrice !== undefined &&
order.stopLossPrice !== null
? formatPerpsFiat(order.stopLossPrice, {
ranges: PRICE_RANGES_UNIVERSAL,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ const PerpsPositionCard: React.FC<PerpsPositionCardProps> = ({

return (
<Text variant={TextVariant.BodyMD} color={TextColor.Default}>
{price
{price !== undefined && price !== null
? formatPerpsFiat(price, {
ranges: PRICE_RANGES_UNIVERSAL,
})
Expand Down Expand Up @@ -385,7 +385,8 @@ const PerpsPositionCard: React.FC<PerpsPositionCardProps> = ({
{strings('perps.position.card.liquidation_price')}
</Text>
<Text variant={TextVariant.BodyMD} color={TextColor.Default}>
{position.liquidationPrice
{position.liquidationPrice !== undefined &&
position.liquidationPrice !== null
? formatPerpsFiat(position.liquidationPrice, {
ranges: PRICE_RANGES_UNIVERSAL,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ const PerpsTPSLBottomSheet: React.FC<PerpsTPSLBottomSheetProps> = ({
{strings('perps.tpsl.entry_price')}
</Text>
<Text variant={TextVariant.BodyMD} color={TextColor.Default}>
{position.entryPrice &&
{position.entryPrice !== undefined &&
position.entryPrice !== null &&
position.entryPrice !== 'null' &&
position.entryPrice !== '0.00'
? formatPerpsFiat(position.entryPrice, {
Expand All @@ -410,7 +411,7 @@ const PerpsTPSLBottomSheet: React.FC<PerpsTPSLBottomSheetProps> = ({
: strings('perps.tpsl.current_price')}
</Text>
<Text variant={TextVariant.BodyMD} color={TextColor.Default}>
{currentPrice
{currentPrice !== undefined && currentPrice !== null
? formatPerpsFiat(currentPrice, {
ranges: PRICE_RANGES_UNIVERSAL,
})
Expand All @@ -422,7 +423,8 @@ const PerpsTPSLBottomSheet: React.FC<PerpsTPSLBottomSheetProps> = ({
{strings('perps.tpsl.liquidation_price')}
</Text>
<Text variant={TextVariant.BodyMD} color={TextColor.Default}>
{displayLiquidationPrice &&
{displayLiquidationPrice !== undefined &&
displayLiquidationPrice !== null &&
displayLiquidationPrice !== 'null' &&
displayLiquidationPrice !== '0.00'
? formatPerpsFiat(displayLiquidationPrice, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
formatPerpsFiat,
formatPnl,
formatPercentage,
PRICE_RANGES_MINIMAL_VIEW,
} from '../../utils/formatUtils';
import { PerpsTabViewSelectorsIDs } from '../../../../../../e2e/selectors/Perps/Perps.selectors';
import { BigNumber } from 'bignumber.js';
Expand Down Expand Up @@ -176,7 +177,9 @@ export const PerpsTabControlBar: React.FC<PerpsTabControlBarProps> = ({
color={TextColor.Default}
testID={PerpsTabViewSelectorsIDs.BALANCE_VALUE}
>
{formatPerpsFiat(availableBalance)}
{formatPerpsFiat(availableBalance, {
ranges: PRICE_RANGES_MINIMAL_VIEW,
})}
</Text>
<Icon
name={IconName.ArrowRight}
Expand Down
Loading
Loading