diff --git a/components/DayHighLow.tsx b/components/DayHighLow.tsx index 58e5ba05..d924dfce 100644 --- a/components/DayHighLow.tsx +++ b/components/DayHighLow.tsx @@ -13,7 +13,9 @@ const DayHighLow = ({ high, low, latest }) => { return (
-
24h Range
+
+ 24h Range +
{formatUsdValue(low?.baseOraclePrice)} diff --git a/components/MarginInfo.tsx b/components/MarginInfo.tsx index 075736a5..d61175bd 100644 --- a/components/MarginInfo.tsx +++ b/components/MarginInfo.tsx @@ -3,8 +3,8 @@ import { ZERO_BN, ZERO_I80F48, } from '@blockworks-foundation/mango-client' -import { HeartIcon } from '@heroicons/react/outline' -import { useMemo } from 'react' +import { useCallback, useMemo, useState } from 'react' +import { HeartIcon } from '@heroicons/react/solid' import useMangoStore, { mangoClient, MNGO_INDEX } from '../stores/useMangoStore' import { formatUsdValue } from '../utils' import { notify } from '../utils/notifications' @@ -12,6 +12,9 @@ import { LinkButton } from './Button' import FloatingElement from './FloatingElement' import { ElementTitle } from './styles' import Tooltip from './Tooltip' +import DepositModal from './DepositModal' +import WithdrawModal from './WithdrawModal' +import Button from './Button' export default function MarginInfo() { const connected = useMangoStore((s) => s.wallet.connected) @@ -20,6 +23,17 @@ export default function MarginInfo() { const mangoAccount = useMangoStore((s) => s.selectedMangoAccount.current) const actions = useMangoStore((s) => s.actions) + const [showDepositModal, setShowDepositModal] = useState(false) + const [showWithdrawModal, setShowWithdrawModal] = useState(false) + + const handleCloseDeposit = useCallback(() => { + setShowDepositModal(false) + }, []) + + const handleCloseWithdraw = useCallback(() => { + setShowWithdrawModal(false) + }, []) + const equity = mangoAccount ? mangoAccount.computeValue(mangoGroup, mangoCache) : ZERO_I80F48 @@ -78,11 +92,11 @@ export default function MarginInfo() { Account
-
+
Equity
{formatUsdValue(+equity)}
-
+
Leverage
@@ -93,7 +107,7 @@ export default function MarginInfo() { x
-
+
Total Assets Value
@@ -105,7 +119,7 @@ export default function MarginInfo() { : '--'}
-
+
Total Liabilities Value
@@ -117,7 +131,7 @@ export default function MarginInfo() { : '--'}
-
+
@@ -145,7 +159,7 @@ export default function MarginInfo() { : 0} Claim @@ -153,57 +167,78 @@ export default function MarginInfo() {
-
-
-
-
-
- } - > -
- Health Ratio -
- - -
-
{maintHealthRatio.toFixed(2)}%
-
-
-
-
30 - ? 'bg-th-green' - : initHealthRatio > 0 - ? 'bg-th-orange' - : 'bg-th-red' - }`} - >
-
-
+
+
+
+ } + > +
+ Health +
+ +
+
+
30 + ? 'bg-th-green' + : initHealthRatio > 0 + ? 'bg-th-orange' + : 'bg-th-red' + }`} + >
+
+
+ {maintHealthRatio.toFixed(2)}% +
+
+
+ +
+ {showDepositModal && ( + + )} + {showWithdrawModal && ( + + )} ) } diff --git a/components/MarketHeader.tsx b/components/MarketHeader.tsx index d7523681..a80fa4ea 100644 --- a/components/MarketHeader.tsx +++ b/components/MarketHeader.tsx @@ -152,13 +152,13 @@ const MarketHeader = () => {
-
Oracle price
+
Oracle price
{oraclePrice ? formatUsdValue(oraclePrice) : '--'}
-
24h Change
+
24h Change
{spotStats?.change ? (
{ )}
-
24h Vol
+
24h Vol
{ohlcv && !loading && volume ? ( volume !== '--' ? ( <> {volume.toFixed(2)} - + {baseSymbol} @@ -202,7 +202,7 @@ const MarketHeader = () => { {selectedMarketName.includes('PERP') ? ( <>
-
+
Avg Funding Rate (1h)
@@ -210,7 +210,9 @@ const MarketHeader = () => {
-
Open Interest
+
+ Open Interest +
{parseOpenInterest(perpStats, selectedMarket)} {baseSymbol}
@@ -219,7 +221,7 @@ const MarketHeader = () => { ) : null}
-
+
{connected && mangoAccount ? : null}
diff --git a/components/MarketPosition.tsx b/components/MarketPosition.tsx index 9bc0c9c5..f2db3bc8 100644 --- a/components/MarketPosition.tsx +++ b/components/MarketPosition.tsx @@ -1,4 +1,4 @@ -import { useCallback, useMemo, useState } from 'react' +import { useMemo } from 'react' import FloatingElement from './FloatingElement' import { ElementTitle } from './styles' import useMangoStore, { mangoClient } from '../stores/useMangoStore' @@ -8,9 +8,7 @@ import { i80f48ToPercent, formatUsdValue, } from '../utils/index' -import DepositModal from './DepositModal' -import WithdrawModal from './WithdrawModal' -import Button from './Button' +import { LinkButton } from './Button' import Tooltip from './Tooltip' import SideBadge from './SideBadge' import { @@ -69,6 +67,7 @@ export default function MarketPosition() { const mangoAccount = useMangoStore((s) => s.selectedMangoAccount.current) const selectedMarket = useMangoStore((s) => s.selectedMarket.current) const marketConfig = useMangoStore((s) => s.selectedMarket.config) + const selectedMarketName = marketConfig.name const connected = useMangoStore((s) => s.wallet.connected) const baseSymbol = marketConfig.baseSymbol const marketName = marketConfig.name @@ -77,9 +76,6 @@ export default function MarketPosition() { (t) => t.marketName === marketName ) - const [showDepositModal, setShowDepositModal] = useState(false) - const [showWithdrawModal, setShowWithdrawModal] = useState(false) - const marketIndex = useMemo(() => { return getMarketIndexBySymbol(mangoGroupConfig, baseSymbol) }, [mangoGroupConfig, baseSymbol]) @@ -90,14 +86,6 @@ export default function MarketPosition() { } }, [marketName, mangoAccount, marketIndex]) - const handleCloseDeposit = useCallback(() => { - setShowDepositModal(false) - }, []) - - const handleCloseWithdraw = useCallback(() => { - setShowWithdrawModal(false) - }, []) - return selectedMarket instanceof PerpMarket ? (
@@ -170,7 +158,7 @@ export default function MarketPosition() {
Unsettled PnL
-
+
{perpAccount ? formatUsdValue( +nativeI80F48ToUi( @@ -182,18 +170,23 @@ export default function MarketPosition() { ) ) : '0'} -
-
-
- {perpAccount ? ( - - ) : null} + Settle + +
@@ -201,7 +194,7 @@ export default function MarketPosition() { <>
- Balances + Balance {mangoGroup ? (
{mangoGroupConfig.tokens @@ -211,10 +204,10 @@ export default function MarketPosition() { const tokenIndex = mangoGroup.getTokenIndex(mintKey) return (
-
+
{symbol}
-
-
- Deposits -
+
+
Deposits
{mangoAccount ? floorToDecimal( @@ -245,10 +236,8 @@ export default function MarketPosition() { )}
-
-
- Borrows -
+
+
Borrows
{mangoAccount ? ceilToDecimal( @@ -269,7 +258,7 @@ export default function MarketPosition() {
Interest Rates
@@ -295,33 +284,8 @@ export default function MarketPosition() { })}
) : null} -
- - -
- {showDepositModal && ( - - )} - {showWithdrawModal && ( - - )} ) } diff --git a/components/TradePageGrid.tsx b/components/TradePageGrid.tsx index a691b407..a0b5a731 100644 --- a/components/TradePageGrid.tsx +++ b/components/TradePageGrid.tsx @@ -24,13 +24,13 @@ export const defaultLayouts = { { i: 'orderbook', x: 6, y: 0, w: 3, h: 17 }, { i: 'tradeForm', x: 9, y: 1, w: 3, h: 14 }, { i: 'marketTrades', x: 6, y: 1, w: 3, h: 13 }, - { i: 'marketPosition', x: 9, y: 3, w: 3, h: 15 }, + { i: 'marketPosition', x: 9, y: 3, w: 3, h: 13 }, { i: 'userInfo', x: 0, y: 2, w: 9, h: 19 }, { i: 'marginInfo', x: 9, y: 4, w: 3, h: 15 }, ], lg: [ - { i: 'tvChart', x: 0, y: 0, w: 8, h: 30, minW: 2 }, - { i: 'marketPosition', x: 8, y: 0, w: 4, h: 15, minW: 2 }, + { i: 'tvChart', x: 0, y: 0, w: 8, h: 28, minW: 2 }, + { i: 'marketPosition', x: 8, y: 0, w: 4, h: 13, minW: 2 }, { i: 'marginInfo', x: 8, y: 1, w: 4, h: 15, minW: 2 }, { i: 'orderbook', x: 0, y: 2, w: 4, h: 17, minW: 2 }, { i: 'tradeForm', x: 4, y: 2, w: 4, h: 17, minW: 3 }, @@ -38,8 +38,8 @@ export const defaultLayouts = { { i: 'userInfo', x: 0, y: 3, w: 12, h: 19, minW: 6 }, ], md: [ - { i: 'tvChart', x: 0, y: 0, w: 8, h: 30, minW: 2 }, - { i: 'marketPosition', x: 8, y: 0, w: 4, h: 15, minW: 2 }, + { i: 'tvChart', x: 0, y: 0, w: 8, h: 28, minW: 2 }, + { i: 'marketPosition', x: 8, y: 0, w: 4, h: 13, minW: 2 }, { i: 'marginInfo', x: 8, y: 1, w: 4, h: 15, minW: 2 }, { i: 'orderbook', x: 0, y: 2, w: 4, h: 17, minW: 2 }, { i: 'tradeForm', x: 4, y: 2, w: 4, h: 17, minW: 3 }, @@ -49,7 +49,7 @@ export const defaultLayouts = { sm: [ { i: 'tvChart', x: 0, y: 0, w: 12, h: 25, minW: 6 }, { i: 'marketPosition', x: 0, y: 1, w: 6, h: 15, minW: 2 }, - { i: 'marginInfo', x: 6, y: 1, w: 6, h: 16, minW: 2 }, + { i: 'marginInfo', x: 6, y: 1, w: 6, h: 15, minW: 2 }, { i: 'tradeForm', x: 0, y: 2, w: 12, h: 13, minW: 3 }, { i: 'orderbook', x: 0, y: 3, w: 6, h: 17, minW: 3 }, { i: 'marketTrades', x: 6, y: 3, w: 6, h: 17, minW: 2 }, @@ -57,8 +57,8 @@ export const defaultLayouts = { ], xs: [ { i: 'tvChart', x: 0, y: 0, w: 0, h: 0, minW: 6 }, - { i: 'marketPosition', x: 0, y: 1, w: 6, h: 15, minW: 2 }, - { i: 'marginInfo', x: 0, y: 2, w: 6, h: 16, minW: 2 }, + { i: 'marketPosition', x: 0, y: 1, w: 6, h: 13, minW: 2 }, + { i: 'marginInfo', x: 0, y: 2, w: 6, h: 15, minW: 2 }, { i: 'tradeForm', x: 0, y: 3, w: 12, h: 13, minW: 3 }, { i: 'orderbook', x: 0, y: 4, w: 6, h: 17, minW: 3 }, { i: 'marketTrades', x: 0, y: 5, w: 6, h: 17, minW: 2 },