From a8435616b083c53fa44514d4f3b3058a2c2b5872 Mon Sep 17 00:00:00 2001 From: tjs Date: Sat, 7 Jan 2023 13:59:11 -0500 Subject: [PATCH 1/2] use latest client --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7ce2b157..2c54dd29 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 98aa7027..3609932d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" From b4e63ffcb69c6806ae99b23342bf69df6fa2b9c4 Mon Sep 17 00:00:00 2001 From: tjs Date: Sat, 7 Jan 2023 13:59:32 -0500 Subject: [PATCH 2/2] add commas to swap history --- components/swap/SwapHistoryTable.tsx | 12 ++++++------ utils/numbers.ts | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/components/swap/SwapHistoryTable.tsx b/components/swap/SwapHistoryTable.tsx index 02ca33d7..d6a20c6d 100644 --- a/components/swap/SwapHistoryTable.tsx +++ b/components/swap/SwapHistoryTable.tsx @@ -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 = () => {

- {`${swap_in_amount.toFixed(inDecimals)}`} + {`${formatDecimal(swap_in_amount, inDecimals)}`} {inSymbol} @@ -159,15 +161,13 @@ const SwapHistoryTable = () => {

- {`${trimDecimals(swap_out_amount, outDecimals)}`} + {`${formatDecimal(swap_out_amount, outDecimals)}`} {outSymbol}

-

- - {t('price')}: - {' '} +

+ {t('price')}:{' '} {formatFixedDecimals(swap_out_price_usd, true)}

diff --git a/utils/numbers.ts b/utils/numbers.ts index 930e51da..2c3d0255 100644 --- a/utils/numbers.ts +++ b/utils/numbers.ts @@ -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,