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 AssetListTable from 'components/MarketAssetTable'
|
||||||
import MarketAssetTableRow from 'components/MarketAssetTable/MarketAssetTableRow'
|
import MarketAssetTableRow from 'components/MarketAssetTable/MarketAssetTableRow'
|
||||||
import MarketDetails from 'components/MarketAssetTable/MarketDetails'
|
import MarketDetails from 'components/MarketAssetTable/MarketDetails'
|
||||||
|
import Text from 'components/Text'
|
||||||
import TitleAndSubCell from 'components/TitleAndSubCell'
|
import TitleAndSubCell from 'components/TitleAndSubCell'
|
||||||
import { BN_ZERO } from 'constants/math'
|
import { BN_ZERO } from 'constants/math'
|
||||||
import { convertLiquidityRateToAPR } from 'utils/formatters'
|
import { convertLiquidityRateToAPR } from 'utils/formatters'
|
||||||
@ -82,6 +83,10 @@ export default function LendingMarketsTable(props: Props) {
|
|||||||
accessorKey: 'marketLiquidityRate',
|
accessorKey: 'marketLiquidityRate',
|
||||||
header: 'APR',
|
header: 'APR',
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
|
if (!row.original.borrowEnabled) {
|
||||||
|
return <Text>-</Text>
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormattedNumber
|
<FormattedNumber
|
||||||
amount={convertLiquidityRateToAPR(row.original.marketLiquidityRate)}
|
amount={convertLiquidityRateToAPR(row.original.marketLiquidityRate)}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
|
|
||||||
import { BN } from 'utils/helpers'
|
import useCurrentAccountLends from 'hooks/useCurrentAccountLends'
|
||||||
import { byDenom } from 'utils/array'
|
import useDepositEnabledMarkets from 'hooks/useDepositEnabledMarkets'
|
||||||
import { getAssetByDenom } from 'utils/assets'
|
import useDisplayCurrencyPrice from 'hooks/useDisplayCurrencyPrice'
|
||||||
import useMarketDeposits from 'hooks/useMarketDeposits'
|
import useMarketDeposits from 'hooks/useMarketDeposits'
|
||||||
import useMarketLiquidities from 'hooks/useMarketLiquidities'
|
import useMarketLiquidities from 'hooks/useMarketLiquidities'
|
||||||
import useDisplayCurrencyPrice from 'hooks/useDisplayCurrencyPrice'
|
import { byDenom } from 'utils/array'
|
||||||
import useDepositEnabledMarkets from 'hooks/useDepositEnabledMarkets'
|
import { getAssetByDenom } from 'utils/assets'
|
||||||
import useCurrentAccountLends from 'hooks/useCurrentAccountLends'
|
import { BN } from 'utils/helpers'
|
||||||
|
|
||||||
function useLendingMarketAssetsTableData(): {
|
function useLendingMarketAssetsTableData(): {
|
||||||
accountLentAssets: LendingMarketTableData[]
|
accountLentAssets: LendingMarketTableData[]
|
||||||
@ -23,34 +23,37 @@ function useLendingMarketAssetsTableData(): {
|
|||||||
const accountLentAssets: LendingMarketTableData[] = [],
|
const accountLentAssets: LendingMarketTableData[] = [],
|
||||||
availableAssets: LendingMarketTableData[] = []
|
availableAssets: LendingMarketTableData[] = []
|
||||||
|
|
||||||
markets.forEach(({ denom, cap, liquidityRate, liquidationThreshold, maxLtv }) => {
|
markets.forEach(
|
||||||
const asset = getAssetByDenom(denom) as Asset
|
({ denom, cap, liquidityRate, liquidationThreshold, maxLtv, borrowEnabled }) => {
|
||||||
const marketDepositAmount = BN(marketDeposits.find(byDenom(denom))?.amount ?? 0)
|
const asset = getAssetByDenom(denom) as Asset
|
||||||
const marketLiquidityAmount = BN(marketLiquidities.find(byDenom(denom))?.amount ?? 0)
|
const marketDepositAmount = BN(marketDeposits.find(byDenom(denom))?.amount ?? 0)
|
||||||
const accountLentAmount = accountLentAmounts.find(byDenom(denom))?.amount
|
const marketLiquidityAmount = BN(marketLiquidities.find(byDenom(denom))?.amount ?? 0)
|
||||||
const accountLentValue = accountLentAmount
|
const accountLentAmount = accountLentAmounts.find(byDenom(denom))?.amount
|
||||||
? convertAmount(asset, accountLentAmount)
|
const accountLentValue = accountLentAmount
|
||||||
: undefined
|
? convertAmount(asset, accountLentAmount)
|
||||||
|
: undefined
|
||||||
|
|
||||||
const lendingMarketAsset: LendingMarketTableData = {
|
const lendingMarketAsset: LendingMarketTableData = {
|
||||||
asset,
|
asset,
|
||||||
marketDepositAmount,
|
marketDepositAmount,
|
||||||
accountLentValue,
|
accountLentValue,
|
||||||
accountLentAmount,
|
accountLentAmount,
|
||||||
marketLiquidityAmount,
|
marketLiquidityAmount,
|
||||||
marketDepositCap: cap.max,
|
marketDepositCap: cap.max,
|
||||||
marketLiquidityRate: liquidityRate,
|
marketLiquidityRate: liquidityRate,
|
||||||
marketLiquidationThreshold: liquidationThreshold,
|
marketLiquidationThreshold: liquidationThreshold,
|
||||||
marketMaxLtv: maxLtv,
|
marketMaxLtv: maxLtv,
|
||||||
}
|
borrowEnabled,
|
||||||
|
}
|
||||||
|
|
||||||
;(lendingMarketAsset.accountLentValue ? accountLentAssets : availableAssets).push(
|
;(lendingMarketAsset.accountLentValue ? accountLentAssets : availableAssets).push(
|
||||||
lendingMarketAsset,
|
lendingMarketAsset,
|
||||||
)
|
)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
return { accountLentAssets, availableAssets }
|
return { accountLentAssets, availableAssets }
|
||||||
}, [markets, marketDeposits, marketLiquidities, accountLentAmounts, convertAmount])
|
}, [markets, marketDeposits, marketLiquidities, accountLentAmounts, convertAmount])
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useLendingMarketAssetsTableData
|
export default useLendingMarketAssetsTableData
|
3
src/types/interfaces/asset.d.ts
vendored
3
src/types/interfaces/asset.d.ts
vendored
@ -86,6 +86,7 @@ interface LendingMarketTableData extends MarketTableData {
|
|||||||
marketDepositCap: BigNumber
|
marketDepositCap: BigNumber
|
||||||
accountLentAmount?: string
|
accountLentAmount?: string
|
||||||
accountLentValue?: BigNumber
|
accountLentValue?: BigNumber
|
||||||
|
borrowEnabled: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MarketTableData {
|
interface MarketTableData {
|
||||||
@ -95,4 +96,4 @@ interface MarketTableData {
|
|||||||
marketLiquidityRate: number
|
marketLiquidityRate: number
|
||||||
marketLiquidityAmount: BigNumber
|
marketLiquidityAmount: BigNumber
|
||||||
marketLiquidationThreshold: number
|
marketLiquidationThreshold: number
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user