Skip to content

Commit

Permalink
use suggestedDecimals in PnL graphic (Kwenta#1738)
Browse files Browse the repository at this point in the history
* fix

* fix

* add formatDollar fxn

* fix

* fix

* fix lint warning

* use formatDollars instead of formatNumber

Co-authored-by: platschi <platschi@posteo.org>
  • Loading branch information
abhisheknaiidu and platschi authored Dec 15, 2022
1 parent fa42f12 commit 40e7b61
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sections/futures/ShareModal/PositionMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { selectFuturesType } from 'state/futures/selectors';
import { useAppSelector } from 'state/hooks';
import { positionHistoryState } from 'store/futures';
import getLocale from 'utils/formatters/getLocale';
import { formatDollars, zeroBN } from 'utils/formatters/number';

type PositionMetadataProps = {
marketAsset: string;
Expand Down Expand Up @@ -86,7 +87,7 @@ const PositionMetadata: FC<PositionMetadataProps> = ({ marketAsset }) => {
(position) => position.isOpen && position.asset === marketAsset
);

avgEntryPrice = currentPosition?.avgEntryPrice.toNumber().toFixed(2) ?? '';
avgEntryPrice = currentPosition?.avgEntryPrice.toNumber().toString() ?? '';
const openTimestamp = currentPosition?.openTimestamp ?? 0;

openAtDate = format(openTimestamp, 'PP', { locale: getLocale() });
Expand Down Expand Up @@ -119,14 +120,18 @@ const PositionMetadata: FC<PositionMetadataProps> = ({ marketAsset }) => {
<ContainerText className="header">
{t('futures.modals.share.position-metadata.avg-open-price')}
</ContainerText>
<ContainerText className="date-or-price">{avgEntryPrice}</ContainerText>
<ContainerText className="date-or-price">
{formatDollars(avgEntryPrice ?? zeroBN, {
isAssetPrice: true,
})}
</ContainerText>
</BottomLeftContainer>
<BottomRightContainer>
<ContainerText className="header">
{t('futures.modals.share.position-metadata.current-price')}
</ContainerText>
<ContainerText className="date-or-price">
{marketAssetRate.toNumber().toFixed(2)}
{formatDollars(marketAssetRate ?? '', { isAssetPrice: true })}
</ContainerText>
</BottomRightContainer>
</>
Expand Down

0 comments on commit 40e7b61

Please sign in to comment.