diff --git a/components/DepositTokensButton.tsx b/components/DepositTokensButton.tsx index 4479c76079..4d6aca1409 100644 --- a/components/DepositTokensButton.tsx +++ b/components/DepositTokensButton.tsx @@ -5,7 +5,7 @@ import useUserGovTokenAccountQuery from '@hooks/useUserGovTokenAccount' import { useDepositCallback } from './GovernancePower/Vanilla/useDepositCallback' import useWalletOnePointOh from '@hooks/useWalletOnePointOh' import Modal from './Modal' -import { useState } from 'react' +import { useState, useEffect } from 'react' import useGoverningTokenMint from '@hooks/selectedRealm/useGoverningTokenMint' import { useMintInfoByPubkeyQuery } from '@hooks/queries/mintInfo' import Input from './inputs/Input' @@ -35,7 +35,6 @@ export const DepositTokensButton = ({ const ButtonToUse = as === 'primary' ? Button : SecondaryButton const [openModal, setOpenModal] = useState(false) - const [amount, setAmount] = useState('') const mint = useGoverningTokenMint(role) const mintInfo = useMintInfoByPubkeyQuery(mint).data?.result @@ -44,7 +43,15 @@ export const DepositTokensButton = ({ ? undefined : depositAmount.shiftedBy(-mintInfo.decimals).toNumber() + const [amount, setAmount] = useState('') + + useEffect(() => { + if (humanReadableMax && humanReadableMax > 0) + setAmount(humanReadableMax ? humanReadableMax.toString() : '') + }, [humanReadableMax]) + const deposit = useDepositCallback(role) + return ( <> setOpenModal(false)}>

Deposit tokens

+ setAmount(e.target.value)} + onChange={(e) => { setAmount(e.target.value) }} max={humanReadableMax} />