diff --git a/components/modals/PerpMarketDetailsModal.tsx b/components/modals/PerpMarketDetailsModal.tsx
index d68b3227..6c51c3c8 100644
--- a/components/modals/PerpMarketDetailsModal.tsx
+++ b/components/modals/PerpMarketDetailsModal.tsx
@@ -3,6 +3,8 @@ import Modal from '../shared/Modal'
import { useTranslation } from 'next-i18next'
import { PerpMarket } from '@blockworks-foundation/mango-v4'
import Button from '@components/shared/Button'
+import useOracleProvider from 'hooks/useOracleProvider'
+import { ArrowTopRightOnSquareIcon } from '@heroicons/react/20/solid'
// import Tooltip from '@components/shared/Tooltip'
interface PerpMarketDetailsModalProps {
@@ -17,6 +19,9 @@ const PerpMarketDetailsModal = ({
market,
}: ModalCombinedProps) => {
const { t } = useTranslation(['common', 'trade'])
+ const { oracleProvider, oracleLinkPath } = useOracleProvider()
+
+ console.log(oracleProvider, oracleLinkPath)
return market ? (
{t('trade:oracle')}
+ {oracleLinkPath ? ( + + {oracleProvider} +{oracleProvider}
+ )} +{t('trade:max-leverage')}
5x
{t('trade:oracle')}
+ {oracleLinkPath ? ( + + {oracleProvider} +{oracleProvider}
+ )} +- {title} -
+ {tooltipContent ? ( ++ {title} +
+{title}
+ )} {mouseData ? ({oracleProvider}
+ )} +{groupInsuranceFund ? t('yes') : t('no')} @@ -112,7 +136,7 @@ const PerpMarketSettingsTable = () => { ) : (
{t('trade:oracle')}
+ {oracleLinkPath ? ( + + + {oracleProvider} + ++ {oracleProvider} +
+ )} +{oracleProvider}
+ )} +{mintInfo?.groupInsuranceFund ? t('yes') : t('no')} @@ -129,6 +151,7 @@ const TokenSettingsTable = () => { (t) => t.address === bank.mint.toString() )?.logoURI } + const [oracleProvider, oracleLinkPath] = getOracleProvider(bank) // const mintInfo = group.mintInfosMapByMint.get( // bank.mint.toString() // ) @@ -207,6 +230,26 @@ const TokenSettingsTable = () => { %
+{t('trade:oracle')}
+ {oracleLinkPath ? ( + + + {oracleProvider} + ++ {oracleProvider} +
+ )} +{t('token:market-cap')}
diff --git a/components/token/TokenParams.tsx b/components/token/TokenParams.tsx index bede5385..65420d17 100644 --- a/components/token/TokenParams.tsx +++ b/components/token/TokenParams.tsx @@ -1,42 +1,29 @@ import { Bank, I80F48, - OracleProvider, toUiDecimals, toUiDecimalsForQuote, } from '@blockworks-foundation/mango-v4' import Tooltip from '@components/shared/Tooltip' import { ArrowTopRightOnSquareIcon } from '@heroicons/react/20/solid' +import { BN } from '@project-serum/anchor' +import { getOracleProvider } from 'hooks/useOracleProvider' import { useTranslation } from 'next-i18next' import { useMemo } from 'react' -import { formatCurrencyValue, formatNumericValue } from 'utils/numbers' +import { formatCurrencyValue } from 'utils/numbers' const TokenParams = ({ bank }: { bank: Bank }) => { const { t } = useTranslation(['common', 'activity', 'token']) const [oracleProvider, oracleLinkPath] = useMemo(() => { - switch (bank.oracleProvider) { - case OracleProvider.Pyth: - return [ - 'Pyth', - `https://pyth.network/price-feeds/crypto-${bank.name.toLowerCase()}-usd`, - ] - case OracleProvider.Switchboard: - return [ - 'Switchboard', - `https://switchboard.xyz/explorer/3/${bank.oracle.toString()}`, - ] - case OracleProvider.Stub: - return ['Stub', ''] - default: - return ['Unknown', ''] - } + if (!bank) return ['Unavaliable', ''] + return getOracleProvider(bank) }, [bank]) return (
{t('token:borrow-upkeep-fee')}
+{t('token:borrow-upkeep-rate')}
{(100 * bank.loanFeeRate.toNumber()).toFixed(2)}% @@ -116,14 +103,25 @@ const TokenParams = ({ bank }: { bank: Bank }) => {
{t('token:net-borrow-period')}
++ {bank.netBorrowLimitWindowSizeTs.div(new BN(3600)).toNumber()}hrs +
+{t('token:net-borrows-in-period')}
- {formatNumericValue( - toUiDecimalsForQuote(I80F48.fromI64(bank.netBorrowsInWindow)) + {formatCurrencyValue( + toUiDecimalsForQuote( + I80F48.fromI64(bank.netBorrowsInWindow).toNumber() * + bank.uiPrice + ) )}
- {formatNumericValue( + {formatCurrencyValue( toUiDecimals(bank.netBorrowLimitPerWindowQuote, 6) )}
@@ -147,7 +145,7 @@ const TokenParams = ({ bank }: { bank: Bank }) => { target="_blank" rel="noopener noreferrer" > -{oracleProvider}
+ {oracleProvider}- {t('token:insurance-rate-curve')} -
-?
-