diff --git a/components/BalancesTable.tsx b/components/BalancesTable.tsx index d654038f..f2319d9b 100644 --- a/components/BalancesTable.tsx +++ b/components/BalancesTable.tsx @@ -5,7 +5,7 @@ import { notify } from '../utils/notifications' import { Table, Thead, Tbody, Tr, Th, Td } from 'react-super-responsive-table' import { InformationCircleIcon } from '@heroicons/react/outline' import Tooltip from './Tooltip' -import { sleep } from '../utils' +import { floorToDecimal, sleep } from '../utils' import { Market } from '@project-serum/serum' import { getTokenBySymbol, @@ -159,7 +159,8 @@ const BalancesTable = () => { className={`px-6 py-3 whitespace-nowrap text-sm text-th-fgd-1`} > {+balance.marginDeposits > 0 - ? balance.marginDeposits.toFixed( + ? floorToDecimal( + balance.marginDeposits.toNumber(), tokenConfig.decimals ) : 0} diff --git a/components/MarketPosition.tsx b/components/MarketPosition.tsx index d30cd908..9bc0c9c5 100644 --- a/components/MarketPosition.tsx +++ b/components/MarketPosition.tsx @@ -2,7 +2,12 @@ import { useCallback, useMemo, useState } from 'react' import FloatingElement from './FloatingElement' import { ElementTitle } from './styles' import useMangoStore, { mangoClient } from '../stores/useMangoStore' -import { i80f48ToPercent, tokenPrecision, formatUsdValue } from '../utils/index' +import { + ceilToDecimal, + floorToDecimal, + i80f48ToPercent, + formatUsdValue, +} from '../utils/index' import DepositModal from './DepositModal' import WithdrawModal from './WithdrawModal' import Button from './Button' @@ -17,7 +22,7 @@ import { ZERO_BN, } from '@blockworks-foundation/mango-client' import useTradeHistory from '../hooks/useTradeHistory' -import { getAvgEntryPrice, getBreakEvenPrice } from './PositionsTable' +import { getAvgEntryPrice, getBreakEvenPrice } from './PerpPositionsTable' import { notify } from '../utils/notifications' const handleSettlePnl = async ( @@ -225,14 +230,19 @@ export default function MarketPosition() {
{mangoAccount - ? mangoAccount - .getUiDeposit( - mangoGroupCache.rootBankCache[tokenIndex], - mangoGroup, - tokenIndex - ) - .toFixed(tokenPrecision[symbol]) - : (0).toFixed(tokenPrecision[symbol])} + ? floorToDecimal( + mangoAccount + .getUiDeposit( + mangoGroupCache.rootBankCache[tokenIndex], + mangoGroup, + tokenIndex + ) + .toNumber(), + mangoGroup.tokens[tokenIndex].decimals + ) + : (0).toFixed( + mangoGroup.tokens[tokenIndex].decimals + )}
@@ -241,14 +251,19 @@ export default function MarketPosition() {
{mangoAccount - ? mangoAccount - .getUiBorrow( - mangoGroupCache.rootBankCache[tokenIndex], - mangoGroup, - tokenIndex - ) - .toFixed(tokenPrecision[symbol]) - : (0).toFixed(tokenPrecision[symbol])} + ? ceilToDecimal( + mangoAccount + .getUiBorrow( + mangoGroupCache.rootBankCache[tokenIndex], + mangoGroup, + tokenIndex + ) + .toNumber(), + mangoGroup.tokens[tokenIndex].decimals + ) + : (0).toFixed( + mangoGroup.tokens[tokenIndex].decimals + )}
diff --git a/components/PositionsTable.tsx b/components/PerpPositionsTable.tsx similarity index 100% rename from components/PositionsTable.tsx rename to components/PerpPositionsTable.tsx diff --git a/components/TradeHistoryTable.tsx b/components/TradeHistoryTable.tsx index 2b815e7f..1a319a78 100644 --- a/components/TradeHistoryTable.tsx +++ b/components/TradeHistoryTable.tsx @@ -239,7 +239,7 @@ const TradeHistoryTable = () => {
) : (
- No {marketConfig.name} trade history + No trade history {asPath === '/account' ? ( Make a trade diff --git a/components/UserInfo.tsx b/components/UserInfo.tsx index eaa91790..3b69d4cb 100644 --- a/components/UserInfo.tsx +++ b/components/UserInfo.tsx @@ -2,7 +2,7 @@ import { useState } from 'react' import FloatingElement from './FloatingElement' import OpenOrdersTable from './OpenOrdersTable' import BalancesTable from './BalancesTable' -import PositionsTable from './PositionsTable' +import PositionsTable from './PerpPositionsTable' import TradeHistoryTable from './TradeHistoryTable' // import { Position } from '../public/charting_library/charting_library' // import FeeDiscountsTable from './FeeDiscountsTable' diff --git a/components/account-page/AccountOverview.tsx b/components/account-page/AccountOverview.tsx index d10d089d..2326d000 100644 --- a/components/account-page/AccountOverview.tsx +++ b/components/account-page/AccountOverview.tsx @@ -32,7 +32,7 @@ import { Market } from '@project-serum/serum' import SideBadge from '../SideBadge' import Button, { LinkButton } from '../Button' import Switch from '../Switch' -import PositionsTable from '../PositionsTable' +import PositionsTable from '../PerpPositionsTable' import DepositModal from '../DepositModal' import WithdrawModal from '../WithdrawModal'