@@ -38,6 +38,7 @@ export default function LendButton(props: Props) {
3838 const assetDepositAmount = accountDeposits . find ( byDenom ( props . data . asset . denom ) ) ?. amount
3939 const address = useStore ( ( s ) => s . address )
4040 const hasWalletBalance = walletBalance && BN ( walletBalance . amount ) . isGreaterThan ( 0 )
41+ const hasAccountDeposit = assetDepositAmount && assetDepositAmount . isGreaterThan ( 0 )
4142 const isDefaultAccount = currentAccount ?. kind === 'default'
4243 const isLendEnabled = ! ! props . data . asset . isAutoLendEnabled
4344 const { isAutoLendEnabledForCurrentAccount } = useAutoLend ( )
@@ -51,6 +52,8 @@ export default function LendButton(props: Props) {
5152 onClick : ( ) => {
5253 openDeposit ( props . data )
5354 } ,
55+ disabled : ! hasWalletBalance ,
56+ disabledTooltip : `You don't have any ${ props . data . asset . symbol } in your wallet.` ,
5457 } ,
5558 ...( isLendEnabled
5659 ? [
@@ -60,10 +63,12 @@ export default function LendButton(props: Props) {
6063 onClick : ( ) => {
6164 openDepositAndLend ( props . data )
6265 } ,
66+ disabled : ! hasWalletBalance ,
67+ disabledTooltip : `You don't have any ${ props . data . asset . symbol } in your wallet.` ,
6368 } ,
6469 ]
6570 : [ ] ) ,
66- ...( isLendEnabled && assetDepositAmount
71+ ...( isLendEnabled && hasAccountDeposit
6772 ? [
6873 {
6974 icon : < ArrowUpLine /> ,
@@ -73,11 +78,19 @@ export default function LendButton(props: Props) {
7378 ]
7479 : [ ] ) ,
7580 ] ,
76- [ assetDepositAmount , isLendEnabled , openLend , openDeposit , openDepositAndLend , props . data ] ,
81+ [
82+ hasWalletBalance ,
83+ hasAccountDeposit ,
84+ isLendEnabled ,
85+ openLend ,
86+ openDeposit ,
87+ openDepositAndLend ,
88+ props . data ,
89+ ] ,
7790 )
7891
79- // If user has wallet balance and it's a default account, show Manage dropdown
80- if ( hasWalletBalance && address && isDefaultAccount ) {
92+ // If user has wallet balance or account deposits and it's a default account, show Manage dropdown
93+ if ( ( hasWalletBalance || hasAccountDeposit ) && address && isDefaultAccount ) {
8194 return (
8295 < div className = 'flex justify-end' >
8396 < DropDownButton items = { ITEMS } text = 'Manage' color = 'tertiary' />
@@ -123,16 +136,20 @@ export default function LendButton(props: Props) {
123136 // If asset doesn't support lending, don't show anything
124137 if ( ! isLendEnabled ) return null
125138
139+ // For lending: user can lend from wallet OR from unlent account deposits
140+ const canLend = hasWalletBalance || hasAccountDeposit
141+ const lendTooltip = ! canLend
142+ ? `You don't have any ${ props . data . asset . symbol } in your wallet or Credit Account.`
143+ : undefined
144+
126145 return (
127146 < div className = 'flex justify-end' >
128147 < ConditionalWrapper
129- condition = { ! hasWalletBalance && ! ! address }
148+ condition = { ! canLend && ! ! address }
130149 wrapper = { ( children ) => (
131150 < Tooltip
132151 type = 'warning'
133- content = {
134- < Text size = 'sm' > { `You don't have any ${ props . data . asset . symbol } in your wallet.` } </ Text >
135- }
152+ content = { < Text size = 'sm' > { lendTooltip } </ Text > }
136153 contentClassName = 'max-w-[200px]'
137154 className = 'ml-auto'
138155 >
@@ -143,7 +160,7 @@ export default function LendButton(props: Props) {
143160 { isAutoLendEnabledForCurrentAccount ? (
144161 < ActionButton
145162 leftIcon = { < ArrowUpLine /> }
146- disabled = { ! hasWalletBalance }
163+ disabled = { ! canLend }
147164 color = 'tertiary'
148165 onClick = { ( e ) => {
149166 openLend ( props . data )
0 commit comments