fix formatfixeddecimals rounding

This commit is contained in:
saml33 2023-01-09 12:50:46 +11:00
parent 3d6f30b7fb
commit 93738b0dcc
6 changed files with 18 additions and 18 deletions

View File

@ -215,7 +215,7 @@ const TokenList = () => {
: '0'}
</p>
<p className="text-sm text-th-fgd-4">
{formatFixedDecimals(inOrders * oraclePrice, false, true)}
{formatFixedDecimals(inOrders * oraclePrice, true, true)}
</p>
</Td>
<Td className="text-right">
@ -240,7 +240,7 @@ const TokenList = () => {
: '0'}
</p>
<p className="text-sm text-th-fgd-4">
{formatFixedDecimals(interestValue, false, true)}
{formatFixedDecimals(interestValue, true, true)}
</p>
</div>
</Td>
@ -395,7 +395,7 @@ const MobileTokenListItem = ({ bank }: { bank: Bank }) => {
{inOrders ? formatDecimal(inOrders, bank.mintDecimals) : '0'}
</p>
<p className="ml-1 text-th-fgd-4">
({formatFixedDecimals(inOrders * oraclePrice, false, true)})
({formatFixedDecimals(inOrders * oraclePrice, true, true)})
</p>
</div>
</div>
@ -406,7 +406,7 @@ const MobileTokenListItem = ({ bank }: { bank: Bank }) => {
{unsettled ? formatDecimal(unsettled, bank.mintDecimals) : '0'}
</p>
<p className="ml-1 text-th-fgd-4">
({formatFixedDecimals(unsettled * oraclePrice, false, true)})
({formatFixedDecimals(unsettled * oraclePrice, true, true)})
</p>
</div>
</div>
@ -419,7 +419,7 @@ const MobileTokenListItem = ({ bank }: { bank: Bank }) => {
: '0'}
</p>
<p className="ml-1 text-th-fgd-4">
({formatFixedDecimals(interestValue, false, true)})
({formatFixedDecimals(interestValue, true, true)})
</p>
</div>
</div>

View File

@ -242,7 +242,7 @@ const AccountPage = () => {
play
delay={0.05}
duration={1}
numbers={formatFixedDecimals(accountValue, false, true)}
numbers={formatFixedDecimals(accountValue, true, true)}
/>
) : (
<FlipNumbers
@ -255,7 +255,7 @@ const AccountPage = () => {
/>
)
) : (
<span>{formatFixedDecimals(accountValue, false, true)}</span>
<span>{formatFixedDecimals(accountValue, true, true)}</span>
)}
</div>
<div className="flex items-center space-x-1.5">
@ -447,7 +447,7 @@ const AccountPage = () => {
</p>
</Tooltip>
<p className="mt-1 mb-0.5 text-left text-2xl font-bold text-th-fgd-1 lg:text-xl xl:text-2xl">
{formatFixedDecimals(accountPnl, false, true)}
{formatFixedDecimals(accountPnl, true, true)}
</p>
<div className="flex space-x-1">
<Change change={oneDayPnlChange} prefix="$" size="small" />
@ -478,7 +478,7 @@ const AccountPage = () => {
</p>
</Tooltip>
<p className="mt-1 mb-0.5 text-2xl font-bold text-th-fgd-1 lg:text-xl xl:text-2xl">
{formatFixedDecimals(interestTotalValue, false, true)}
{formatFixedDecimals(interestTotalValue, true, true)}
</p>
<div className="flex space-x-1">
<Change change={oneDayInterestChange} prefix="$" size="small" />

View File

@ -120,7 +120,7 @@ const BalancesTable = () => {
: '0'}
</p>
<p className="text-sm text-th-fgd-4">
{formatFixedDecimals(inOrders * bank.uiPrice, false, true)}
{formatFixedDecimals(inOrders * bank.uiPrice, true, true)}
</p>
</Td>
<Td className="text-right font-mono">
@ -130,7 +130,7 @@ const BalancesTable = () => {
: '0'}
</p>
<p className="text-sm text-th-fgd-4">
{formatFixedDecimals(unsettled * bank.uiPrice, false, true)}
{formatFixedDecimals(unsettled * bank.uiPrice, true, true)}
</p>
</Td>
</TrBody>

View File

@ -129,7 +129,7 @@ const TokenStats = () => {
<div className="flex flex-col text-right">
<p>{formatFixedDecimals(deposits)}</p>
<p className="text-th-fgd-4">
{formatFixedDecimals(deposits * price, false, true)}
{formatFixedDecimals(deposits * price, true, true)}
</p>
</div>
</Td>
@ -137,7 +137,7 @@ const TokenStats = () => {
<div className="flex flex-col text-right">
<p>{formatFixedDecimals(borrows)}</p>
<p className="text-th-fgd-4">
{formatFixedDecimals(borrows * price, false, true)}
{formatFixedDecimals(borrows * price, true, true)}
</p>
</div>
</Td>
@ -232,7 +232,7 @@ const TokenStats = () => {
{formatFixedDecimals(deposits)}
</p>
<p className="text-right text-th-fgd-4">
{formatFixedDecimals(deposits * price, false, true)}
{formatFixedDecimals(deposits * price, true, true)}
</p>
</div>
<div>
@ -243,7 +243,7 @@ const TokenStats = () => {
{formatFixedDecimals(borrows)}
</p>
<p className="text-right text-th-fgd-4">
{formatFixedDecimals(borrows * price, false, true)}
{formatFixedDecimals(borrows * price, true, true)}
</p>
</div>
<IconButton

View File

@ -324,7 +324,7 @@ const OpenOrders = () => {
</>
)}
<Td className="w-[16.67%] text-right">
{formatFixedDecimals(o.size * o.price, false, true)}
{formatFixedDecimals(o.size * o.price, true, true)}
</Td>
{connected ? (
<Td className="w-[16.67%]">

View File

@ -60,12 +60,12 @@ const usdFormatter3 = Intl.NumberFormat('en', {
export const formatFixedDecimals = (
value: number,
isUSD?: boolean,
isValue?: boolean
is2DP?: boolean
): string => {
let formattedValue
if (value === 0) {
formattedValue = isUSD ? '$0.00' : '0'
} else if (isValue) {
} else if (is2DP) {
formattedValue = usdFormatter2.format(value)
} else if (Math.abs(value) >= 1000) {
formattedValue = isUSD