fix entry price formatting

This commit is contained in:
tjs 2022-11-20 22:11:29 -05:00
parent eb3d915916
commit dbcaeee439
3 changed files with 9 additions and 23 deletions

View File

@ -6,6 +6,7 @@ import Decimal from 'decimal.js'
import useMangoGroup from 'hooks/useMangoGroup'
import useSelectedMarket from 'hooks/useSelectedMarket'
import { useTranslation } from 'next-i18next'
import { numberFormat } from 'utils/numbers'
import { calculateMarketPrice } from 'utils/tradeForm'
import MarketLogos from './MarketLogos'
import PerpSideBadge from './PerpSideBadge'
@ -98,7 +99,12 @@ const PerpPositions = () => {
</div>
</Td>
<Td className="text-right">
<div>{position.quoteEntryNative.toString()}</div>
<div>
$
{numberFormat.format(
position.getEntryPrice(market).toNumber()
)}
</div>
</Td>
</TrBody>
)

View File

@ -7,7 +7,7 @@ const digits9 = new Intl.NumberFormat('en', { maximumFractionDigits: 9 })
export const formatDecimal = (
value: number,
decimals: number = 6,
decimals = 6,
opts = { fixed: false }
): string => {
if (opts?.fixed) return value.toFixed(decimals)
@ -57,26 +57,6 @@ const usdFormatter4 = Intl.NumberFormat('en', {
currency: 'USD',
})
const numberFormatter0 = Intl.NumberFormat('en', {
minimumFractionDigits: 0,
maximumFractionDigits: 0,
})
const numberFormatter2 = Intl.NumberFormat('en', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})
const numberFormatter4 = Intl.NumberFormat('en', {
minimumFractionDigits: 4,
maximumFractionDigits: 4,
})
const numberFormatter6 = Intl.NumberFormat('en', {
minimumFractionDigits: 6,
maximumFractionDigits: 6,
})
export const formatFixedDecimals = (
value: number,
isCurrency?: boolean,

View File

@ -52,7 +52,7 @@
"@blockworks-foundation/mango-v4@https://tylersssss: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@github.com/blockworks-foundation/mango-v4.git#main":
version "0.0.1-beta.6"
resolved "https://tylersssss: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@github.com/blockworks-foundation/mango-v4.git#14e20f9668805f2e287ba0a062660066ec0c6254"
resolved "https://tylersssss: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@github.com/blockworks-foundation/mango-v4.git#57b05259f99d750d3a75f9033080800d5dc450b1"
dependencies:
"@project-serum/anchor" "^0.25.0"
"@project-serum/serum" "^0.13.65"