Autolend fix (#454)

* fix: abbreviate the wallet amount

* fix: autolending setting
This commit is contained in:
Linkie Link 2023-09-11 17:23:24 +02:00 committed by GitHub
parent 46b2634993
commit dade91f67e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 7 deletions

View File

@ -44,8 +44,8 @@ export default function AccountFundContent(props: Props) {
const [fundingAssets, setFundingAssets] = useState<BNCoin[]>([])
const { data: marketAssets } = useMarketAssets()
const { data: walletBalances } = useWalletBalances(props.address)
const { autoLendEnabledAccountIds } = useAutoLend()
const [isLending, toggleIsLending] = useToggle(false)
const { autoLendEnabledAccountIds, enableAutoLendAccountId } = useAutoLend()
const [isLending, toggleIsLending] = useToggle(lendAssets)
const { simulateDeposits } = useUpdatedAccount(props.account)
const baseAsset = getBaseAsset()
@ -126,11 +126,19 @@ export default function AccountFundContent(props: Props) {
}, [])
useEffect(() => {
toggleIsLending(autoLendEnabledAccountIds.includes(props.accountId))
}, [props.accountId, autoLendEnabledAccountIds, toggleIsLending])
const autoLendEnabled = autoLendEnabledAccountIds.includes(props.accountId)
if (lendAssets && !autoLendEnabled) enableAutoLendAccountId(props.accountId)
toggleIsLending(autoLendEnabled)
}, [
props.accountId,
autoLendEnabledAccountIds,
toggleIsLending,
lendAssets,
enableAutoLendAccountId,
])
useEffect(() => {
if (accounts?.length === 1 && isLending && !lendAssets) setLendAssets(true)
if (accounts?.length === 1 && isLending) setLendAssets(true)
}, [isLending, accounts, lendAssets, setLendAssets])
const depositCapReachedCoins = useMemo(() => {

View File

@ -7,6 +7,7 @@ import DesktopNavigation from 'components/Navigation/DesktopNavigation'
import RewardsCenter from 'components/RewardsCenter'
import Settings from 'components/Settings'
import Wallet from 'components/Wallet'
import useCurrentAccount from 'hooks/useCurrentAccount'
import useStore from 'store'
export const menuTree: { pages: Page[]; label: string }[] = [
@ -19,6 +20,7 @@ export const menuTree: { pages: Page[]; label: string }[] = [
export default function DesktopHeader() {
const address = useStore((s) => s.address)
const focusComponent = useStore((s) => s.focusComponent)
const currentAccount = useCurrentAccount()
function handleCloseFocusMode() {
if (focusComponent && focusComponent.onClose) focusComponent.onClose()
@ -50,8 +52,8 @@ export default function DesktopHeader() {
</div>
) : (
<div className='flex gap-4'>
{currentAccount && <RewardsCenter />}
{address && <AccountMenu />}
{address && <RewardsCenter />}
<Wallet />
<Settings />
</div>

View File

@ -111,7 +111,7 @@ export default function WalletConnectedButton() {
) : (
<FormattedNumber
amount={walletAmount.toNumber()}
options={{ suffix: ` ${baseAsset.symbol}` }}
options={{ suffix: ` ${baseAsset.symbol}`, abbreviated: true }}
animate
/>
)}