import { Bank } from '@blockworks-foundation/mango-v4' import useJupiterMints from 'hooks/useJupiterMints' import { ArrowDownRightIcon, ArrowUpLeftIcon, NoSymbolIcon, QuestionMarkCircleIcon, } from '@heroicons/react/20/solid' import useMangoAccount from 'hooks/useMangoAccount' import { useViewport } from 'hooks/useViewport' import { useTranslation } from 'next-i18next' import Image from 'next/legacy/image' import { formatNumericValue } from 'utils/numbers' import { breakpoints } from 'utils/theme' import { Table, Td, Th, TrBody, TrHead } from '../shared/TableElements' import useMangoGroup from 'hooks/useMangoGroup' import ConnectEmptyState from '../shared/ConnectEmptyState' import { useWallet } from '@solana/wallet-adapter-react' import Decimal from 'decimal.js' import { getMaxWithdrawForBank } from '@components/swap/useTokenMax' import { IconButton } from '@components/shared/Button' import { useCallback, useState } from 'react' import BorrowRepayModal from '@components/modals/BorrowRepayModal' import Tooltip from '@components/shared/Tooltip' import BankAmountWithValue from '@components/shared/BankAmountWithValue' import { BankWithBalance } from 'hooks/useBanksWithBalances' const YourBorrowsTable = ({ banks }: { banks: BankWithBalance[] }) => { const { t } = useTranslation(['common', 'trade']) const [showBorrowModal, setShowBorrowModal] = useState(false) const [showRepayModal, setShowRepayModal] = useState(false) const [selectedToken, setSelectedToken] = useState('') const { mangoAccount, mangoAccountAddress } = useMangoAccount() const { group } = useMangoGroup() const { mangoTokens } = useJupiterMints() const { width } = useViewport() const { connected } = useWallet() const showTableView = width ? width > breakpoints.md : false const handleShowActionModals = useCallback( (token: string, action: 'borrow' | 'repay') => { setSelectedToken(token) action === 'borrow' ? setShowBorrowModal(true) : setShowRepayModal(true) }, [] ) return ( <> {banks?.length ? ( showTableView ? (
{t('token')} | {t('borrow:borrowed-amount')} |
|
{t('rate')} |
{logoURI ? (
{bank.name}
|
|
|
{formatNumericValue(bank.getBorrowRateUi(), 2)}% |
|
---|
{bank.name}
{t('borrow:borrowed-amount')}
{t('rate')}
{formatNumericValue(bank.getBorrowRateUi(), 2)}%
{t('borrow:no-borrows')}