Autolend fix (#454)
* fix: abbreviate the wallet amount * fix: autolending setting
This commit is contained in:
parent
46b2634993
commit
dade91f67e
@ -44,8 +44,8 @@ export default function AccountFundContent(props: Props) {
|
|||||||
const [fundingAssets, setFundingAssets] = useState<BNCoin[]>([])
|
const [fundingAssets, setFundingAssets] = useState<BNCoin[]>([])
|
||||||
const { data: marketAssets } = useMarketAssets()
|
const { data: marketAssets } = useMarketAssets()
|
||||||
const { data: walletBalances } = useWalletBalances(props.address)
|
const { data: walletBalances } = useWalletBalances(props.address)
|
||||||
const { autoLendEnabledAccountIds } = useAutoLend()
|
const { autoLendEnabledAccountIds, enableAutoLendAccountId } = useAutoLend()
|
||||||
const [isLending, toggleIsLending] = useToggle(false)
|
const [isLending, toggleIsLending] = useToggle(lendAssets)
|
||||||
const { simulateDeposits } = useUpdatedAccount(props.account)
|
const { simulateDeposits } = useUpdatedAccount(props.account)
|
||||||
|
|
||||||
const baseAsset = getBaseAsset()
|
const baseAsset = getBaseAsset()
|
||||||
@ -126,11 +126,19 @@ export default function AccountFundContent(props: Props) {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
toggleIsLending(autoLendEnabledAccountIds.includes(props.accountId))
|
const autoLendEnabled = autoLendEnabledAccountIds.includes(props.accountId)
|
||||||
}, [props.accountId, autoLendEnabledAccountIds, toggleIsLending])
|
if (lendAssets && !autoLendEnabled) enableAutoLendAccountId(props.accountId)
|
||||||
|
toggleIsLending(autoLendEnabled)
|
||||||
|
}, [
|
||||||
|
props.accountId,
|
||||||
|
autoLendEnabledAccountIds,
|
||||||
|
toggleIsLending,
|
||||||
|
lendAssets,
|
||||||
|
enableAutoLendAccountId,
|
||||||
|
])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (accounts?.length === 1 && isLending && !lendAssets) setLendAssets(true)
|
if (accounts?.length === 1 && isLending) setLendAssets(true)
|
||||||
}, [isLending, accounts, lendAssets, setLendAssets])
|
}, [isLending, accounts, lendAssets, setLendAssets])
|
||||||
|
|
||||||
const depositCapReachedCoins = useMemo(() => {
|
const depositCapReachedCoins = useMemo(() => {
|
||||||
|
@ -7,6 +7,7 @@ import DesktopNavigation from 'components/Navigation/DesktopNavigation'
|
|||||||
import RewardsCenter from 'components/RewardsCenter'
|
import RewardsCenter from 'components/RewardsCenter'
|
||||||
import Settings from 'components/Settings'
|
import Settings from 'components/Settings'
|
||||||
import Wallet from 'components/Wallet'
|
import Wallet from 'components/Wallet'
|
||||||
|
import useCurrentAccount from 'hooks/useCurrentAccount'
|
||||||
import useStore from 'store'
|
import useStore from 'store'
|
||||||
|
|
||||||
export const menuTree: { pages: Page[]; label: string }[] = [
|
export const menuTree: { pages: Page[]; label: string }[] = [
|
||||||
@ -19,6 +20,7 @@ export const menuTree: { pages: Page[]; label: string }[] = [
|
|||||||
export default function DesktopHeader() {
|
export default function DesktopHeader() {
|
||||||
const address = useStore((s) => s.address)
|
const address = useStore((s) => s.address)
|
||||||
const focusComponent = useStore((s) => s.focusComponent)
|
const focusComponent = useStore((s) => s.focusComponent)
|
||||||
|
const currentAccount = useCurrentAccount()
|
||||||
|
|
||||||
function handleCloseFocusMode() {
|
function handleCloseFocusMode() {
|
||||||
if (focusComponent && focusComponent.onClose) focusComponent.onClose()
|
if (focusComponent && focusComponent.onClose) focusComponent.onClose()
|
||||||
@ -50,8 +52,8 @@ export default function DesktopHeader() {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className='flex gap-4'>
|
<div className='flex gap-4'>
|
||||||
|
{currentAccount && <RewardsCenter />}
|
||||||
{address && <AccountMenu />}
|
{address && <AccountMenu />}
|
||||||
{address && <RewardsCenter />}
|
|
||||||
<Wallet />
|
<Wallet />
|
||||||
<Settings />
|
<Settings />
|
||||||
</div>
|
</div>
|
||||||
|
@ -111,7 +111,7 @@ export default function WalletConnectedButton() {
|
|||||||
) : (
|
) : (
|
||||||
<FormattedNumber
|
<FormattedNumber
|
||||||
amount={walletAmount.toNumber()}
|
amount={walletAmount.toNumber()}
|
||||||
options={{ suffix: ` ${baseAsset.symbol}` }}
|
options={{ suffix: ` ${baseAsset.symbol}`, abbreviated: true }}
|
||||||
animate
|
animate
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user