Merge branch 'alpha' into main

This commit is contained in:
tjs 2023-01-07 13:59:49 -05:00
commit 0846d82fb9
4 changed files with 14 additions and 14 deletions

View File

@ -15,6 +15,7 @@ import SheenLoader from '../shared/SheenLoader'
import mangoStore from '@store/mangoStore'
import {
countLeadingZeros,
formatDecimal,
formatFixedDecimals,
trimDecimals,
} from '../../utils/numbers'
@ -99,6 +100,7 @@ const SwapHistoryTable = () => {
const inSymbol = formatTokenSymbol(swap_in_symbol)
const outSymbol = formatTokenSymbol(swap_out_symbol)
console.log('mangoTokens', mangoTokens)
if (mangoTokens.length) {
baseLogoURI = mangoTokens.find(
@ -134,7 +136,7 @@ const SwapHistoryTable = () => {
</div>
<div>
<p className="whitespace-nowrap">
{`${swap_in_amount.toFixed(inDecimals)}`}
{`${formatDecimal(swap_in_amount, inDecimals)}`}
<span className="ml-1 font-body text-th-fgd-3">
{inSymbol}
</span>
@ -159,15 +161,13 @@ const SwapHistoryTable = () => {
</div>
<div>
<p className="whitespace-nowrap">
{`${trimDecimals(swap_out_amount, outDecimals)}`}
{`${formatDecimal(swap_out_amount, outDecimals)}`}
<span className="ml-1 font-body text-th-fgd-3">
{outSymbol}
</span>
</p>
<p className="text-xs text-th-fgd-3">
<span className="font-body text-th-fgd-4">
{t('price')}:
</span>{' '}
<p className="text-xs text-th-fgd-4">
<span className="font-body">{t('price')}:</span>{' '}
{formatFixedDecimals(swap_out_price_usd, true)}
</p>
</div>

View File

@ -12,7 +12,7 @@
"postinstall": "tar -xzC public -f vendor/charting_library.tgz;tar -xzC public -f vendor/datafeeds.tgz"
},
"dependencies": {
"@blockworks-foundation/mango-v4": "https://github.com/blockworks-foundation/mango-v4.git#main",
"@blockworks-foundation/mango-v4": "https://github.com/blockworks-foundation/mango-v4.git#ts-client",
"@headlessui/react": "^1.6.6",
"@heroicons/react": "^2.0.10",
"@project-serum/anchor": "0.25.0",

View File

@ -59,28 +59,28 @@ const usdFormatter3 = Intl.NumberFormat('en', {
export const formatFixedDecimals = (
value: number,
isPrice?: boolean,
isUSD?: boolean,
isValue?: boolean
): string => {
let formattedValue
if (value === 0) {
formattedValue = isPrice ? '$0.00' : '0'
formattedValue = isUSD ? '$0.00' : '0'
} else if (isValue) {
formattedValue = usdFormatter2.format(value)
} else if (Math.abs(value) >= 1000) {
formattedValue = isPrice
formattedValue = isUSD
? usdFormatter0.format(value)
: Number(floorToDecimal(value, 0)).toLocaleString(undefined, {
maximumFractionDigits: 0,
})
} else if (Math.abs(value) >= 0.1) {
formattedValue = isPrice
formattedValue = isUSD
? usdFormatter2.format(value)
: Number(floorToDecimal(value, 3)).toLocaleString(undefined, {
maximumFractionDigits: 3,
})
} else {
formattedValue = isPrice
formattedValue = isUSD
? usdFormatter3.format(value)
: Number(floorToDecimal(value, 8)).toLocaleString(undefined, {
maximumFractionDigits: 8,

View File

@ -50,9 +50,9 @@
dependencies:
regenerator-runtime "^0.13.4"
"@blockworks-foundation/mango-v4@https://github.com/blockworks-foundation/mango-v4.git#main":
"@blockworks-foundation/mango-v4@https://github.com/blockworks-foundation/mango-v4.git#ts-client":
version "0.0.1-beta.6"
resolved "https://github.com/blockworks-foundation/mango-v4.git#9efe95cc757bffb77071e92ceac6367bb9098296"
resolved "https://github.com/blockworks-foundation/mango-v4.git#09dccf09fad4b82c831760cb00f78dfda3bbbcf0"
dependencies:
"@project-serum/anchor" "^0.25.0"
"@project-serum/serum" "^0.13.65"