From be031cc0fe9ccf2ba43c45205ae31e4a91526915 Mon Sep 17 00:00:00 2001 From: Tyler Shipe Date: Sat, 24 Jul 2021 16:15:27 -0400 Subject: [PATCH] consistency with user info tabs --- components/BalancesTable.tsx | 98 ++++++++++++++----------- components/PositionsTable.tsx | 30 +++++--- components/TradeHistoryTable.tsx | 121 ++++++------------------------- components/WithdrawModal.tsx | 16 +--- hooks/useBalances.tsx | 4 +- hooks/useWallet.tsx | 1 - yarn.lock | 14 ++-- 7 files changed, 108 insertions(+), 176 deletions(-) diff --git a/components/BalancesTable.tsx b/components/BalancesTable.tsx index dad46d64..11abf4cc 100644 --- a/components/BalancesTable.tsx +++ b/components/BalancesTable.tsx @@ -7,11 +7,15 @@ import { InformationCircleIcon } from '@heroicons/react/outline' import Tooltip from './Tooltip' import { sleep } from '../utils' import { Market } from '@project-serum/serum' -import { ZERO_I80F48 } from '@blockworks-foundation/mango-client' +import { + getTokenBySymbol, + ZERO_I80F48, +} from '@blockworks-foundation/mango-client' const BalancesTable = () => { const balances = useBalances() const actions = useMangoStore((s) => s.actions) + const mangoGroupConfig = useMangoStore((s) => s.selectedMangoGroup.config) async function handleSettleAll() { const mangoAccount = useMangoStore.getState().selectedMangoAccount.current @@ -117,53 +121,59 @@ const BalancesTable = () => { - {balances.map((balance, index) => ( - { + const tokenConfig = getTokenBySymbol( + mangoGroupConfig, + balance.symbol.toUpperCase() + ) + return ( + - - + + - {balance.symbol} - - - {balance.marginDeposits.toFixed()} - - - {balance.borrows.toFixed()} - - - {balance.orders} - - - {balance.unsettled} - - - {balance.net.toFixed()} - - - ))} + {balance.symbol} + + + {balance.marginDeposits.toFixed(tokenConfig.decimals)} + + + {balance.borrows.toFixed(tokenConfig.decimals)} + + + {balance.orders} + + + {balance.unsettled} + + + {balance.net.toFixed(tokenConfig.decimals)} + + + ) + })} diff --git a/components/PositionsTable.tsx b/components/PositionsTable.tsx index dc371781..04c58dea 100644 --- a/components/PositionsTable.tsx +++ b/components/PositionsTable.tsx @@ -49,7 +49,6 @@ const PositionsTable = () => { perpAccount.basePosition.eq(new BN(0)) ) ) - console.log('perp acc length', filteredPerpAccounts.length) const handleSettlePnl = async ( perpMarket: PerpMarket, @@ -98,7 +97,7 @@ const PositionsTable = () => { - Market + Perp Market Side @@ -140,13 +139,22 @@ const PositionsTable = () => { - - {marketConfig.name} + +
+ +
{marketConfig.name}
+
- + { } /> - + {perpMarket.baseLotsToNumber( perpAccount.basePosition )} - + {nativeI80F48ToUi( perpAccount.quotePosition, marketConfig.quoteDecimals ).toFixed()} - + $ {nativeI80F48ToUi( perpAccount.getPnl(perpMarketInfo, price), marketConfig.quoteDecimals ).toFixed()} - + {perpAccount .getHealth( perpMarketInfo, @@ -185,7 +193,7 @@ const PositionsTable = () => { ) .toFixed(3)} - +