* feat: added Buy/Sell token ratio to the TradingView header * fix: changed the order in the trading view description * feat: added minute timeframe to the chart * fix: changed WBTC to WBTC/USD pyth price feed * fix: adjusted HLS health curve * fix: made HLS accounts unselectable * copy: changed the APY range and Strategy text * tidy: fix the tables layout to be more readable * fix: change the precision of the Trading chart header * feat: added summary collapsable * fix: removed Debt Column for active HLS positions * fix: added Memo to TVChart * fix: adjust Trade page layout * tidy: refactor table meta * fix: DisplayCurrency is able to take options now * tidy: remove unneeded typesafety * fix: adjusted according feedback * env: enabled autoRepay and updated version
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { Row } from '@tanstack/react-table'
|
|
|
|
import AmountAndValue from 'components/AmountAndValue'
|
|
import Loading from 'components/Loading'
|
|
import { BN_ZERO } from 'constants/math'
|
|
import { byDenom } from 'utils/array'
|
|
import { getEnabledMarketAssets } from 'utils/assets'
|
|
import { demagnify } from 'utils/formatters'
|
|
|
|
export const LIQUIDITY_META = {
|
|
accessorKey: 'liquidity',
|
|
header: 'Liquidity Available',
|
|
id: 'liquidity',
|
|
meta: { className: 'w-40' },
|
|
}
|
|
|
|
export const liquiditySortingFn = (
|
|
a: Row<BorrowMarketTableData>,
|
|
b: Row<BorrowMarketTableData>,
|
|
): number => {
|
|
const assetA = a.original.asset
|
|
const assetB = b.original.asset
|
|
const liquidityA = demagnify(a.original.liquidity?.amount ?? 0, assetA)
|
|
const liquidityB = demagnify(b.original.liquidity?.amount ?? 0, assetB)
|
|
|
|
return liquidityA - liquidityB
|
|
}
|
|
|
|
interface Props {
|
|
data: BorrowMarketTableData
|
|
}
|
|
|
|
export default function Liquidity(props: Props) {
|
|
const { liquidity, asset: borrowAsset } = props.data
|
|
const marketAssets = getEnabledMarketAssets()
|
|
const asset = marketAssets.find(byDenom(borrowAsset.denom))
|
|
|
|
if (!asset) return null
|
|
|
|
if (liquidity === null) {
|
|
return <Loading />
|
|
}
|
|
|
|
return <AmountAndValue asset={asset} amount={liquidity.amount ?? BN_ZERO} />
|
|
}
|