+ if (hasDebt) return
- return
+ return
}
diff --git a/src/components/v1/Table/borrowings/Columns/BorrowButton.tsx b/src/components/v1/Table/borrowings/Columns/BorrowButton.tsx
new file mode 100644
index 00000000..dc85b35d
--- /dev/null
+++ b/src/components/v1/Table/borrowings/Columns/BorrowButton.tsx
@@ -0,0 +1,50 @@
+import ActionButton from 'components/common/Button/ActionButton'
+import { Plus } from 'components/common/Icons'
+import Text from 'components/common/Text'
+import { Tooltip } from 'components/common/Tooltip'
+import ConditionalWrapper from 'hocs/ConditionalWrapper'
+import useAccount from 'hooks/accounts/useAccount'
+import useStore from 'store'
+
+interface Props {
+ data: BorrowMarketTableData
+}
+export default function BorrowButton(props: Props) {
+ const address = useStore((s) => s.address)
+ const { data: account } = useAccount(address)
+
+ const hasCollateral = account?.lends?.length ?? 0 > 0
+
+ return (
+
+
(
+ {`You don’t have assets deposited in the Red Bank. Please deposit assets before you borrow.`}
+ }
+ contentClassName='max-w-[200px]'
+ className='ml-auto'
+ >
+ {children}
+
+ )}
+ >
+ }
+ disabled={!hasCollateral}
+ color='tertiary'
+ onClick={(e) => {
+ useStore.setState({
+ v1BorrowAndRepayModal: { type: 'borrow', data: props.data },
+ })
+ e.stopPropagation()
+ }}
+ text='Borrow'
+ />
+
+
+ )
+}
diff --git a/src/components/v1/Table/borrowings/Columns/Manage.tsx b/src/components/v1/Table/borrowings/Columns/Manage.tsx
new file mode 100644
index 00000000..b05b896b
--- /dev/null
+++ b/src/components/v1/Table/borrowings/Columns/Manage.tsx
@@ -0,0 +1,47 @@
+import { useMemo } from 'react'
+
+import DropDownButton from 'components/common/Button/DropDownButton'
+import { HandCoins, Plus } from 'components/common/Icons'
+import useWalletBalances from 'hooks/useWalletBalances'
+import useStore from 'store'
+import { byDenom } from 'utils/array'
+
+interface Props {
+ data: BorrowMarketTableData
+}
+
+export default function Manage(props: Props) {
+ const address = useStore((s) => s.address)
+ const { data: balances } = useWalletBalances(address)
+ const hasBalance = !!balances.find(byDenom(props.data.asset.denom))
+
+ const ITEMS: DropDownItem[] = useMemo(
+ () => [
+ {
+ icon:
,
+ text: 'Borrow more',
+ onClick: () =>
+ useStore.setState({
+ v1BorrowAndRepayModal: { type: 'borrow', data: props.data },
+ }),
+ },
+ {
+ icon:
,
+ text: 'Repay',
+ onClick: () =>
+ useStore.setState({
+ v1BorrowAndRepayModal: { type: 'repay', data: props.data },
+ }),
+ disabled: !hasBalance,
+ disabledTooltip: `You don’t have any ${props.data.asset.symbol} in your Wallet.`,
+ },
+ ],
+ [hasBalance, props.data],
+ )
+
+ return (
+
+
+
+ )
+}
diff --git a/src/components/v1/Table/deposits/Columns/Manage.tsx b/src/components/v1/Table/deposits/Columns/Manage.tsx
index f36616ba..728afbf1 100644
--- a/src/components/v1/Table/deposits/Columns/Manage.tsx
+++ b/src/components/v1/Table/deposits/Columns/Manage.tsx
@@ -12,7 +12,6 @@ interface Props {
}
export default function Manage(props: Props) {
- const { openLend, openReclaim } = useLendAndReclaimModal()
const address = useStore((s) => s.address)
const { data: balances } = useWalletBalances(address)
const hasBalance = !!balances.find(byDenom(props.data.asset.denom))
diff --git a/src/store/slices/modal.ts b/src/store/slices/modal.ts
index f0984fd2..76277afe 100644
--- a/src/store/slices/modal.ts
+++ b/src/store/slices/modal.ts
@@ -20,5 +20,6 @@ export default function createModalSlice(set: SetState
, get: GetStat
walletAssetsModal: null,
withdrawFromVaultsModal: null,
v1DepositAndWithdrawModal: null,
+ v1BorrowAndRepayModal: null,
}
}
diff --git a/src/types/interfaces/store/modals.d.ts b/src/types/interfaces/store/modals.d.ts
index d2dd91e3..e0fc378f 100644
--- a/src/types/interfaces/store/modals.d.ts
+++ b/src/types/interfaces/store/modals.d.ts
@@ -7,7 +7,6 @@ interface ModalSlice {
hlsManageModal: HlsManageModal | null
borrowModal: BorrowModal | null
fundAndWithdrawModal: 'fund' | 'withdraw' | null
- v1DepositAndWithdrawModal: V1DepositAndWithdrawModal | null
getStartedModal: boolean
hlsInformationModal: boolean | null
lendAndReclaimModal: LendAndReclaimModalConfig | null
@@ -16,6 +15,8 @@ interface ModalSlice {
vaultModal: VaultModal | null
walletAssetsModal: WalletAssetModal | null
withdrawFromVaultsModal: DepositedVault[] | null
+ v1DepositAndWithdrawModal: V1DepositAndWithdrawModal | null
+ v1BorrowAndRepayModal: V1BorrowAndRepayModal | null
}
interface AlertDialogButton {
@@ -90,3 +91,8 @@ interface V1DepositAndWithdrawModal {
type: 'deposit' | 'withdraw'
data: LendingMarketTableData
}
+
+interface V1BorrowAndRepayModal {
+ type: 'borrow' | 'repay'
+ data: BorrowMarketTableData
+}