diff --git a/src/components/Account/AccountFund.tsx b/src/components/Account/AccountFund.tsx index c8bfa6d2..ff9eccf7 100644 --- a/src/components/Account/AccountFund.tsx +++ b/src/components/Account/AccountFund.tsx @@ -5,13 +5,12 @@ import Button from 'components/Button' import Card from 'components/Card' import FullOverlayContent from 'components/FullOverlayContent' import { Plus } from 'components/Icons' -import SwitchWithLabel from 'components/SwitchWithLabel' +import SwitchAutoLend from 'components/Switch/SwitchAutoLend' import Text from 'components/Text' import TokenInputWithSlider from 'components/TokenInput/TokenInputWithSlider' import WalletBridges from 'components/Wallet/WalletBridges' import { BN_ZERO } from 'constants/math' import useAccounts from 'hooks/useAccounts' -import useAutoLendEnabledAccountIds from 'hooks/useAutoLendEnabledAccountIds' import useCurrentAccount from 'hooks/useCurrentAccount' import useToggle from 'hooks/useToggle' import useWalletBalances from 'hooks/useWalletBalances' @@ -34,8 +33,6 @@ export default function AccountFund() { const [fundingAssets, setFundingAssets] = useState([]) const { data: walletBalances } = useWalletBalances(address) const baseAsset = getBaseAsset() - const { autoLendEnabledAccountIds, toggleAutoLend } = useAutoLendEnabledAccountIds() - const isAutoLendEnabled = autoLendEnabledAccountIds.includes(accountId ?? '0') const hasAssetSelected = fundingAssets.length > 0 const hasFundingAssets = fundingAssets.length > 0 && fundingAssets.every((a) => a.toCoin().amount !== '0') @@ -88,7 +85,7 @@ export default function AccountFund() { const updateFundingAssets = useCallback( (amount: BigNumber, denom: string) => { - const assetToUpdate = fundingAssets.find((asset) => asset.denom === denom) + const assetToUpdate = fundingAssets.find(byDenom(denom)) if (assetToUpdate) { assetToUpdate.amount = amount setFundingAssets([...fundingAssets.filter((a) => a.denom !== denom), assetToUpdate]) @@ -116,21 +113,21 @@ export default function AccountFund() { copy='In order to start trading with this account, you need to deposit funds.' docs='fund' > - + {!hasAssetSelected && Please select an asset.} - {selectedDenoms.map((denom) => { - const asset = getAssetByDenom(denom) as Asset + {fundingAssets.map((coin) => { + const asset = getAssetByDenom(coin.denom) as Asset - const balance = walletBalances.find(byDenom(asset.denom))?.amount ?? '0' + const balance = walletBalances.find(byDenom(coin.denom))?.amount ?? '0' return (
updateFundingAssets(amount, asset.denom)} - amount={BN_ZERO} + amount={coin.amount ?? BN_ZERO} max={BN(balance)} balances={walletBalances} maxText='Max' @@ -140,24 +137,19 @@ export default function AccountFund() { })}