diff --git a/src/pages/portfolio/AccountDetailsAndHistory.tsx b/src/pages/portfolio/AccountDetailsAndHistory.tsx index 64954d1..6a27424 100644 --- a/src/pages/portfolio/AccountDetailsAndHistory.tsx +++ b/src/pages/portfolio/AccountDetailsAndHistory.tsx @@ -131,7 +131,7 @@ export const AccountDetailsAndHistory = () => { key: 'BuyingPower', labelKey: STRING_KEYS.BUYING_POWER, type: OutputType.Fiat, - value: buyingPower?.current, + value: MustBigNumber(buyingPower?.current).lt(0) ? undefined : buyingPower?.current, // show '-' when buying power is negative }, ].filter(isTruthy); diff --git a/src/views/AccountInfo/AccountInfoConnectedState.tsx b/src/views/AccountInfo/AccountInfoConnectedState.tsx index 495e808..e9e5e85 100644 --- a/src/views/AccountInfo/AccountInfoConnectedState.tsx +++ b/src/views/AccountInfo/AccountInfoConnectedState.tsx @@ -151,7 +151,10 @@ export const AccountInfoConnectedState = () => { ), label: stringGetter({ key: STRING_KEYS.BUYING_POWER }), type: OutputType.Fiat, - value: buyingPower, + value: + MustBigNumber(buyingPower?.current).lt(0) && buyingPower?.postOrder === null + ? undefined + : buyingPower, }, ].map( ({ diff --git a/src/views/forms/AccountManagementForms/DepositForm/DepositButtonAndReceipt.tsx b/src/views/forms/AccountManagementForms/DepositForm/DepositButtonAndReceipt.tsx index 07d0cb1..39baf6e 100644 --- a/src/views/forms/AccountManagementForms/DepositForm/DepositButtonAndReceipt.tsx +++ b/src/views/forms/AccountManagementForms/DepositForm/DepositButtonAndReceipt.tsx @@ -1,5 +1,5 @@ import { type Dispatch, type SetStateAction, useState, type ReactNode } from 'react'; -import styled, { type AnyStyledComponent, } from 'styled-components'; +import styled, { type AnyStyledComponent } from 'styled-components'; import { shallowEqual, useSelector } from 'react-redux'; import type { RouteData } from '@0xsquid/sdk'; @@ -32,6 +32,8 @@ import { WithReceipt } from '@/components/WithReceipt'; import { getSubaccountBuyingPower, getSubaccountEquity } from '@/state/accountSelectors'; import { getTransferInputs } from '@/state/inputsSelectors'; +import { MustBigNumber } from '@/lib/numbers'; + import { SlippageEditor } from '../SlippageEditor'; type ElementProps = { @@ -131,7 +133,7 @@ export const DepositButtonAndReceipt = ({ value: ( { const stringGetter = useStringGetter(); @@ -49,6 +50,8 @@ export const AccountMenu = () => { const { evmAddress, walletType, dydxAddress, hdKey } = useAccounts(); + const usdcBalance = freeCollateral?.current || 0; + const onRecoverKeys = () => { dispatch(openDialog({ type: DialogTypes.Onboarding })); }; @@ -122,7 +125,11 @@ export const AccountMenu = () => { - +
@@ -135,11 +142,16 @@ export const AccountMenu = () => {
- +
@@ -217,22 +229,25 @@ const AssetActions = memo( asset, dispatch, withOnboarding, + hasBalance, }: { asset: DydxChainAsset; dispatch: Dispatch; withOnboarding?: boolean; + hasBalance?: boolean; }) => ( {[ - withOnboarding && { - dialogType: DialogTypes.Withdraw, - iconName: IconName.Withdraw, - }, + withOnboarding && + hasBalance && { + dialogType: DialogTypes.Withdraw, + iconName: IconName.Withdraw, + }, withOnboarding && { dialogType: DialogTypes.Deposit, iconName: IconName.Deposit, }, - { + hasBalance && { dialogType: DialogTypes.Transfer, dialogProps: { selectedAsset: asset }, iconName: IconName.Send,