import { Bank, I80F48, toUiDecimals, toUiDecimalsForQuote, } from '@blockworks-foundation/mango-v4' import Tooltip from '@components/shared/Tooltip' import { ArrowTopRightOnSquareIcon } from '@heroicons/react/20/solid' import { BN } from '@coral-xyz/anchor' import mangoStore from '@store/mangoStore' import { getOracleProvider } from 'hooks/useOracleProvider' import { useTranslation } from 'next-i18next' import { useMemo } from 'react' import { formatCurrencyValue } from 'utils/numbers' import CollateralWeightDisplay from '@components/shared/CollateralWeightDisplay' const TokenParams = ({ bank }: { bank: Bank }) => { const { t } = useTranslation(['common', 'activity', 'token']) const [oracleProvider, oracleLinkPath] = useMemo(() => { if (!bank) return ['Unavaliable', ''] return getOracleProvider(bank) }, [bank]) const mintInfo = useMemo(() => { const group = mangoStore.getState().group if (!bank || !group) return return group.mintInfosMapByMint.get(bank.mint.toString()) }, [bank]) return (

{`${bank.name} ${t('token:parameters')}`}

{t('token:init-asset-liability-weight')}

|

{bank.scaledInitLiabWeight(bank.price).toFixed(2)}x

{t('token:maint-asset-liability-weight')}

{bank.maintAssetWeight.toFixed(2)}x

|

{bank.maintLiabWeight.toFixed(2)}x

{t('borrow-fee')}

{(100 * bank.loanOriginationFeeRate.toNumber()).toFixed(2)}%

{t('token:borrow-upkeep-rate')}

{(100 * bank.loanFeeRate.toNumber()).toFixed(2)}%

{t('activity:liquidation-fee')}

{(bank.liquidationFee.toNumber() * 100).toFixed(2)}%

{mintInfo ? (

{t('trade:insured', { token: '' })}

{mintInfo.groupInsuranceFund ? t('yes') : t('no')}

) : null}

{t('token:deposit-borrow-scaling-start')}

{bank.name === 'USDC' ? `$${toUiDecimalsForQuote( bank.depositWeightScaleStartQuote, ).toExponential(1)}` : formatCurrencyValue( toUiDecimalsForQuote(bank.depositWeightScaleStartQuote), )}

|

{bank.name === 'USDC' ? `$${toUiDecimalsForQuote( bank.depositWeightScaleStartQuote, ).toExponential(1)}` : formatCurrencyValue( toUiDecimalsForQuote(bank.borrowWeightScaleStartQuote), )}

{t('token:net-borrow-period')}

{bank.netBorrowLimitWindowSizeTs.div(new BN(3600)).toNumber()}h

{t('token:net-borrows-in-period')}

{formatCurrencyValue( toUiDecimalsForQuote( I80F48.fromI64(bank.netBorrowsInWindow).mul(bank.price), ), )}

{t('token:net-borrow-limit-in-period')}

{formatCurrencyValue( toUiDecimals(bank.netBorrowLimitPerWindowQuote, 6), )}

{t('token:oracle')}

{oracleLinkPath ? ( {oracleProvider} ) : (

{oracleProvider}

)}

{t('token:oracle-confidence')}

{(100 * bank.oracleConfig.confFilter.toNumber()).toFixed(2)}%

{t('token:oracle-staleness')}

{bank.oracleConfig.maxStalenessSlots.toNumber()}{' '} Slots

) } export default TokenParams