Hide APR for non-borrowable assets in Lend Table (#468)
* 🐛Hide APR in lend table for non-borrowable assets * 🐛Hide APR in lend table for non-borrowable assets
This commit is contained in:
parent
2f9f0f4b02
commit
433fa717a0
@ -9,6 +9,7 @@ import { ChevronDown, ChevronUp } from 'components/Icons'
|
||||
import AssetListTable from 'components/MarketAssetTable'
|
||||
import MarketAssetTableRow from 'components/MarketAssetTable/MarketAssetTableRow'
|
||||
import MarketDetails from 'components/MarketAssetTable/MarketDetails'
|
||||
import Text from 'components/Text'
|
||||
import TitleAndSubCell from 'components/TitleAndSubCell'
|
||||
import { BN_ZERO } from 'constants/math'
|
||||
import { convertLiquidityRateToAPR } from 'utils/formatters'
|
||||
@ -82,6 +83,10 @@ export default function LendingMarketsTable(props: Props) {
|
||||
accessorKey: 'marketLiquidityRate',
|
||||
header: 'APR',
|
||||
cell: ({ row }) => {
|
||||
if (!row.original.borrowEnabled) {
|
||||
return <Text>-</Text>
|
||||
}
|
||||
|
||||
return (
|
||||
<FormattedNumber
|
||||
amount={convertLiquidityRateToAPR(row.original.marketLiquidityRate)}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { useMemo } from 'react'
|
||||
|
||||
import { BN } from 'utils/helpers'
|
||||
import { byDenom } from 'utils/array'
|
||||
import { getAssetByDenom } from 'utils/assets'
|
||||
import useCurrentAccountLends from 'hooks/useCurrentAccountLends'
|
||||
import useDepositEnabledMarkets from 'hooks/useDepositEnabledMarkets'
|
||||
import useDisplayCurrencyPrice from 'hooks/useDisplayCurrencyPrice'
|
||||
import useMarketDeposits from 'hooks/useMarketDeposits'
|
||||
import useMarketLiquidities from 'hooks/useMarketLiquidities'
|
||||
import useDisplayCurrencyPrice from 'hooks/useDisplayCurrencyPrice'
|
||||
import useDepositEnabledMarkets from 'hooks/useDepositEnabledMarkets'
|
||||
import useCurrentAccountLends from 'hooks/useCurrentAccountLends'
|
||||
import { byDenom } from 'utils/array'
|
||||
import { getAssetByDenom } from 'utils/assets'
|
||||
import { BN } from 'utils/helpers'
|
||||
|
||||
function useLendingMarketAssetsTableData(): {
|
||||
accountLentAssets: LendingMarketTableData[]
|
||||
@ -23,7 +23,8 @@ function useLendingMarketAssetsTableData(): {
|
||||
const accountLentAssets: LendingMarketTableData[] = [],
|
||||
availableAssets: LendingMarketTableData[] = []
|
||||
|
||||
markets.forEach(({ denom, cap, liquidityRate, liquidationThreshold, maxLtv }) => {
|
||||
markets.forEach(
|
||||
({ denom, cap, liquidityRate, liquidationThreshold, maxLtv, borrowEnabled }) => {
|
||||
const asset = getAssetByDenom(denom) as Asset
|
||||
const marketDepositAmount = BN(marketDeposits.find(byDenom(denom))?.amount ?? 0)
|
||||
const marketLiquidityAmount = BN(marketLiquidities.find(byDenom(denom))?.amount ?? 0)
|
||||
@ -42,12 +43,14 @@ function useLendingMarketAssetsTableData(): {
|
||||
marketLiquidityRate: liquidityRate,
|
||||
marketLiquidationThreshold: liquidationThreshold,
|
||||
marketMaxLtv: maxLtv,
|
||||
borrowEnabled,
|
||||
}
|
||||
|
||||
;(lendingMarketAsset.accountLentValue ? accountLentAssets : availableAssets).push(
|
||||
lendingMarketAsset,
|
||||
)
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
return { accountLentAssets, availableAssets }
|
||||
}, [markets, marketDeposits, marketLiquidities, accountLentAmounts, convertAmount])
|
||||
|
1
src/types/interfaces/asset.d.ts
vendored
1
src/types/interfaces/asset.d.ts
vendored
@ -86,6 +86,7 @@ interface LendingMarketTableData extends MarketTableData {
|
||||
marketDepositCap: BigNumber
|
||||
accountLentAmount?: string
|
||||
accountLentValue?: BigNumber
|
||||
borrowEnabled: boolean
|
||||
}
|
||||
|
||||
interface MarketTableData {
|
||||
|
Loading…
Reference in New Issue
Block a user