diff --git a/components/account/ActionTokenList.tsx b/components/account/ActionTokenList.tsx
index 9c5cf817..2fc1f388 100644
--- a/components/account/ActionTokenList.tsx
+++ b/components/account/ActionTokenList.tsx
@@ -16,33 +16,39 @@ const ActionTokenList = ({
sortByKey,
showBorrowRates,
showDepositRates,
+ valueKey,
}: {
banks: BankParams[]
onSelect: (x: string) => void
- sortByKey: 'maxAmount' | 'walletBalance' | 'accountBalance'
+ sortByKey: 'maxAmount' | 'walletBalanceValue' | 'accountBalanceValue'
showBorrowRates?: boolean
showDepositRates?: boolean
+ valueKey: 'maxAmount' | 'walletBalance' | 'accountBalance'
}) => {
const mangoAccount = mangoStore((s) => s.mangoAccount.current)
return mangoAccount ? (
<>
- {banks?.length
- ? banks
- .filter((b: BankParams) => !!b)
- .sort((a: any, b: any) => b[sortByKey] - a[sortByKey])
- .map((bank: any) => (
-
- ))
- : null}
+ {banks?.length ? (
+ banks
+ .filter((b: BankParams) => !!b)
+ .sort((a: any, b: any) => b[sortByKey] - a[sortByKey])
+ .map((bank: any) => (
+
+ ))
+ ) : (
+
+ Nothing to select
+
+ )}
>
) : null
diff --git a/components/modals/BorrowModal.tsx b/components/modals/BorrowModal.tsx
index 71ce6477..135a03d9 100644
--- a/components/modals/BorrowModal.tsx
+++ b/components/modals/BorrowModal.tsx
@@ -178,6 +178,7 @@ function BorrowModal({ isOpen, onClose, token }: ModalCombinedProps) {
onSelect={handleSelectToken}
showBorrowRates
sortByKey="maxAmount"
+ valueKey="maxAmount"
/>
{
const banks = group?.banksMapByName
? Array.from(group?.banksMapByName, ([key, value]) => {
@@ -153,6 +154,7 @@ function DepositModal({ isOpen, onClose, token }: ModalCombinedProps) {
walletBalance.maxAmount,
walletBalance.maxDecimals
),
+ walletBalanceValue: walletBalance.maxAmount * value[0]?.uiPrice,
}
})
: []
@@ -182,7 +184,8 @@ function DepositModal({ isOpen, onClose, token }: ModalCombinedProps) {
banks={banks}
onSelect={handleSelectToken}
showDepositRates
- sortByKey="walletBalance"
+ sortByKey="walletBalanceValue"
+ valueKey="walletBalance"
/>
{
}
}, [mangoAccount, showSetupStep, onClose])
+ // TODO extract into a shared hook for DepositModal.tsx
const banks = useMemo(() => {
- return group?.banksMapByName
+ const banks = group?.banksMapByName
? Array.from(group?.banksMapByName, ([key, value]) => {
const walletBalance = walletBalanceForToken(walletTokens, key)
return {
@@ -158,9 +159,11 @@ const UserSetupModal = ({ isOpen, onClose }: ModalProps) => {
walletBalance.maxAmount,
walletBalance.maxDecimals
),
+ walletBalanceValue: walletBalance.maxAmount * value[0]?.uiPrice,
}
})
: []
+ return banks.filter((b) => b.walletBalance > 0)
}, [group?.banksMapByName, walletTokens])
return (
@@ -426,7 +429,8 @@ const UserSetupModal = ({ isOpen, onClose }: ModalProps) => {
banks={banks}
onSelect={setDepositToken}
showDepositRates
- sortByKey="walletBalance"
+ sortByKey="walletBalanceValue"
+ valueKey="walletBalance"
/>
) : null}
diff --git a/components/modals/WithdrawModal.tsx b/components/modals/WithdrawModal.tsx
index 9832e19e..dce92e95 100644
--- a/components/modals/WithdrawModal.tsx
+++ b/components/modals/WithdrawModal.tsx
@@ -118,6 +118,10 @@ function WithdrawModal({ isOpen, onClose, token }: ModalCombinedProps) {
key,
value,
accountBalance: accountBalance ? accountBalance : 0,
+ accountBalanceValue:
+ accountBalance && value[0]?.uiPrice
+ ? accountBalance * value[0]?.uiPrice
+ : 0,
}
})
: []
@@ -145,7 +149,8 @@ function WithdrawModal({ isOpen, onClose, token }: ModalCombinedProps) {