diff --git a/components/modals/UserSetupModal.tsx b/components/modals/UserSetupModal.tsx index a85ce969..aa2ae295 100644 --- a/components/modals/UserSetupModal.tsx +++ b/components/modals/UserSetupModal.tsx @@ -23,6 +23,8 @@ import { walletBalanceForToken } from './DepositModal' import { floorToDecimal } from '../../utils/numbers' import { handleWalletConnect } from '../wallet/ConnectWalletButton' import { IS_ONBOARDED_KEY } from '../../utils/constants' +import ButtonGroup from '../forms/ButtonGroup' +import Decimal from 'decimal.js' const UserSetupModal = ({ isOpen, onClose }: ModalProps) => { const { t } = useTranslation() @@ -39,6 +41,7 @@ const UserSetupModal = ({ isOpen, onClose }: ModalProps) => { const [depositToken, setDepositToken] = useState('') const [depositAmount, setDepositAmount] = useState('') const [submitDeposit, setSubmitDeposit] = useState(false) + const [sizePercentage, setSizePercentage] = useState('') const [, setIsOnboarded] = useLocalStorageState(IS_ONBOARDED_KEY) const walletTokens = mangoStore((s) => s.wallet.tokens) @@ -155,6 +158,7 @@ const UserSetupModal = ({ isOpen, onClose }: ModalProps) => { return { key, value, + tokenDecimals: walletBalance.maxDecimals, walletBalance: floorToDecimal( walletBalance.maxAmount, walletBalance.maxDecimals @@ -166,6 +170,27 @@ const UserSetupModal = ({ isOpen, onClose }: ModalProps) => { return banks }, [group?.banksMapByName, walletTokens]) + const tokenMax = useMemo(() => { + const bank = banks.find((bank) => bank.key === depositToken) + if (bank) { + return { amount: bank.walletBalance, decimals: bank.tokenDecimals } + } + return { amount: 0, decimals: 0 } + }, [banks, depositToken]) + + const handleSizePercentage = useCallback( + (percentage: string) => { + setSizePercentage(percentage) + let amount = new Decimal(tokenMax.amount).mul(percentage).div(100) + if (percentage !== '100') { + amount = floorToDecimal(amount, tokenMax.decimals) + } + + setDepositAmount(amount.toString()) + }, + [tokenMax] + ) + return (
@@ -386,7 +411,30 @@ const UserSetupModal = ({ isOpen, onClose }: ModalProps) => {

Fund Your Account

- {!depositToken ? ( diff --git a/components/shared/Notification.tsx b/components/shared/Notification.tsx index a1945213..9a0e02ae 100644 --- a/components/shared/Notification.tsx +++ b/components/shared/Notification.tsx @@ -4,7 +4,7 @@ import { ExternalLinkIcon, InformationCircleIcon, XCircleIcon, -} from '@heroicons/react/outline' +} from '@heroicons/react/solid' import mangoStore, { CLUSTER } from '../../store/mangoStore' import { Notification, notify } from '../../utils/notifications' import Loading from './Loading' @@ -137,9 +137,7 @@ const Notification = ({ notification }: { notification: Notification }) => { ) : null} {type === 'info' && ( - + )} {type === 'error' && ( @@ -149,9 +147,9 @@ const Notification = ({ notification }: { notification: Notification }) => { )}
-
+

{parsedTitle || title} -

+

{description ? (

{description} @@ -169,7 +167,7 @@ const Notification = ({ notification }: { notification: Notification }) => { target="_blank" rel="noreferrer" > -

+
{type === 'error' ? txid : `${txid.slice(0, 14)}...${txid.slice(txid.length - 14)}`}