From 9ceb264c0ab31c482cd8a18afafadd8e3a0a850c Mon Sep 17 00:00:00 2001 From: saml33 Date: Mon, 1 May 2023 12:16:29 +1000 Subject: [PATCH] add token params to token page --- components/token/TokenPage.tsx | 4 +- components/token/TokenParams.tsx | 188 +++++++++++++++++++++++++++++++ public/locales/en/common.json | 1 + public/locales/en/token.json | 20 ++++ public/locales/es/common.json | 1 + public/locales/es/token.json | 20 ++++ public/locales/ru/common.json | 1 + public/locales/ru/token.json | 20 ++++ public/locales/zh/common.json | 1 + public/locales/zh/token.json | 22 +++- public/locales/zh_tw/common.json | 1 + public/locales/zh_tw/token.json | 20 ++++ 12 files changed, 297 insertions(+), 2 deletions(-) create mode 100644 components/token/TokenParams.tsx diff --git a/components/token/TokenPage.tsx b/components/token/TokenPage.tsx index e6deef8a..42988c0d 100644 --- a/components/token/TokenPage.tsx +++ b/components/token/TokenPage.tsx @@ -20,6 +20,7 @@ import CoingeckoStats from './CoingeckoStats' import { useQuery } from '@tanstack/react-query' import FormatNumericValue from '@components/shared/FormatNumericValue' import TopTokenAccounts from './TopTokenAccounts' +import TokenParams from './TokenParams' const DEFAULT_COINGECKO_VALUES = { ath: 0, @@ -191,7 +192,7 @@ const TokenPage = () => { % - {bank ? : null} + {coingeckoTokenInfo?.market_data ? ( {

No CoinGecko data...

)} + ) : loading ? (
diff --git a/components/token/TokenParams.tsx b/components/token/TokenParams.tsx new file mode 100644 index 00000000..bede5385 --- /dev/null +++ b/components/token/TokenParams.tsx @@ -0,0 +1,188 @@ +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 { useTranslation } from 'next-i18next' +import { useMemo } from 'react' +import { formatCurrencyValue, formatNumericValue } 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', ''] + } + }, [bank]) + + return ( +
+
+

{bank.name} Paramaters

+
+
+
+ +

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

+
+
+

+ {bank.initAssetWeight.toFixed(2)} +

+ | +

{bank.initLiabWeight.toFixed(2)}

+
+
+
+ +

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

+
+
+

+ {bank.maintAssetWeight.toFixed(2)} +

+ | +

{bank.maintLiabWeight.toFixed(2)}

+
+
+
+ +

{t('borrow-fee')}

+
+

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

+
+
+ +

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

+
+

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

+
+
+ +

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

+
+

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

+
+
+ +

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

+
+
+

+ {formatCurrencyValue( + toUiDecimalsForQuote(bank.depositWeightScaleStartQuote) + )} +

+ | +

+ {formatCurrencyValue( + toUiDecimalsForQuote(bank.borrowWeightScaleStartQuote) + )} +

+
+
+
+
+
+ +

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

+
+

+ {formatNumericValue( + toUiDecimalsForQuote(I80F48.fromI64(bank.netBorrowsInWindow)) + )} +

+
+
+ +

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

+
+

+ {formatNumericValue( + toUiDecimals(bank.netBorrowLimitPerWindowQuote, 6) + )} +

+
+
+

{t('token:oracle')}

+ +

{oracleProvider}

+ +
+
+
+ +

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

+
+

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

+
+
+ +

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

+
+

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

+
+
+ +

+ {t('token:insurance-rate-curve')} +

+
+

?

+
+
+
+ ) +} + +export default TokenParams diff --git a/public/locales/en/common.json b/public/locales/en/common.json index d259df69..2150c67d 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -145,6 +145,7 @@ "token": "Token", "tokens": "Tokens", "token-collateral-multiplier": "{{token}} Collateral Multiplier", + "tooltip-borrow-fee": "The fee for originating a loan.", "tooltip-borrow-rate": "The variable interest rate you'll pay on your borrowed balance", "tooltip-collateral-value": "The USD amount you can trade or borrow against", "total": "Total", diff --git a/public/locales/en/token.json b/public/locales/en/token.json index e2758037..16ffc463 100644 --- a/public/locales/en/token.json +++ b/public/locales/en/token.json @@ -4,22 +4,42 @@ "borrowing": "Borrowing", "borrows": "Borrows", "borrow-rates": "Borrow Rates", + "borrow-upkeep-fee": "Borrow Upkeep Fee", "chart-unavailable": "Chart Unavailable", "circulating-supply": "Circulating Supply", + "deposit-borrow-scaling-start": "Deposit/Borrow Scaling Start", "deposits": "Deposits", "deposit-rates": "Deposit Rates", "fees-tooltip": "Fees collected for loan origination, loan upkeep and Openbook hosting rebates.", "fdv": "Fully Diluted Value", "go-to-account": "Go To Account", + "init-asset-liability-weight": "Init Asset/Liability Weight", + "insurance-rate-curve": "Insurance Rate Curve", "lending": "Lending", + "maint-asset-liability-weight": "Maint Asset/Liability Weight", "market-cap": "Market Cap", "max-supply": "Max Supply", + "net-borrow-limit-in-period": "Net Borrow Limit in Period", + "net-borrows-in-period": "Net Borrows in Period", "no-borrowers": "No Borrowers...", "no-depositors": "No Depositors...", + "oracle": "Oracle", + "oracle-confidence": "Oracle Confidence", + "oracle-staleness": "Oracle Staleness", "token-details": "Token Details", "token-fees-collected": "Token Fees Collected (M2M)", "token-not-found": "Token Not Found", "token-not-found-desc": "'{{token}}' is either not listed or we're having issues loading the data.", + "tooltip-borrow-upkeep-fee": "", + "tooltip-deposit-borrow-scaling-start": "This acts as a soft limit for deposits and borrows. For deposits, if this value is exceeded the asset weight for opening new positions is scaled down. For borrows, the liability weight for opening new positions is scaled up.", + "tooltip-init-asset-liability-weight": "The contribution a token has to your initial account health. Asset weight increases health and liability weight reduces it. Initial health affects your ability to withdraw and open new positions and is reflected by the amount of free collateral in your account.", + "tooltip-insurance-rate-curve": "", + "tooltip-liquidation-fee": "The fee paid to liqudators when {{symbol}} is liquidated.", + "tooltip-maint-asset-liability-weight": "The contribution a token has to your account health. Asset weight increases health and liability weight reduces it. Maintance health is what's displayed on your account page. If this value reaches zero your account will be liquidated.", + "tooltip-net-borrow-limit-in-period": "", + "tooltip-net-borrows-in-period": "", + "tooltip-oracle-confidence": "How much variation from the true price is tolerated.", + "tooltip-oracle-staleness": "Price is considered valid when it is last udpated within {{slots}} slots.", "top-borrowers": "Top {{symbol}} Borrowers", "top-depositors": "Top {{symbol}} Depositors", "total-supply": "Total Supply", diff --git a/public/locales/es/common.json b/public/locales/es/common.json index d259df69..2150c67d 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -145,6 +145,7 @@ "token": "Token", "tokens": "Tokens", "token-collateral-multiplier": "{{token}} Collateral Multiplier", + "tooltip-borrow-fee": "The fee for originating a loan.", "tooltip-borrow-rate": "The variable interest rate you'll pay on your borrowed balance", "tooltip-collateral-value": "The USD amount you can trade or borrow against", "total": "Total", diff --git a/public/locales/es/token.json b/public/locales/es/token.json index e2758037..16ffc463 100644 --- a/public/locales/es/token.json +++ b/public/locales/es/token.json @@ -4,22 +4,42 @@ "borrowing": "Borrowing", "borrows": "Borrows", "borrow-rates": "Borrow Rates", + "borrow-upkeep-fee": "Borrow Upkeep Fee", "chart-unavailable": "Chart Unavailable", "circulating-supply": "Circulating Supply", + "deposit-borrow-scaling-start": "Deposit/Borrow Scaling Start", "deposits": "Deposits", "deposit-rates": "Deposit Rates", "fees-tooltip": "Fees collected for loan origination, loan upkeep and Openbook hosting rebates.", "fdv": "Fully Diluted Value", "go-to-account": "Go To Account", + "init-asset-liability-weight": "Init Asset/Liability Weight", + "insurance-rate-curve": "Insurance Rate Curve", "lending": "Lending", + "maint-asset-liability-weight": "Maint Asset/Liability Weight", "market-cap": "Market Cap", "max-supply": "Max Supply", + "net-borrow-limit-in-period": "Net Borrow Limit in Period", + "net-borrows-in-period": "Net Borrows in Period", "no-borrowers": "No Borrowers...", "no-depositors": "No Depositors...", + "oracle": "Oracle", + "oracle-confidence": "Oracle Confidence", + "oracle-staleness": "Oracle Staleness", "token-details": "Token Details", "token-fees-collected": "Token Fees Collected (M2M)", "token-not-found": "Token Not Found", "token-not-found-desc": "'{{token}}' is either not listed or we're having issues loading the data.", + "tooltip-borrow-upkeep-fee": "", + "tooltip-deposit-borrow-scaling-start": "This acts as a soft limit for deposits and borrows. For deposits, if this value is exceeded the asset weight for opening new positions is scaled down. For borrows, the liability weight for opening new positions is scaled up.", + "tooltip-init-asset-liability-weight": "The contribution a token has to your initial account health. Asset weight increases health and liability weight reduces it. Initial health affects your ability to withdraw and open new positions and is reflected by the amount of free collateral in your account.", + "tooltip-insurance-rate-curve": "", + "tooltip-liquidation-fee": "The fee paid to liqudators when {{symbol}} is liquidated.", + "tooltip-maint-asset-liability-weight": "The contribution a token has to your account health. Asset weight increases health and liability weight reduces it. Maintance health is what's displayed on your account page. If this value reaches zero your account will be liquidated.", + "tooltip-net-borrow-limit-in-period": "", + "tooltip-net-borrows-in-period": "", + "tooltip-oracle-confidence": "How much variation from the true price is tolerated.", + "tooltip-oracle-staleness": "Price is considered valid when it is last udpated within {{slots}} slots.", "top-borrowers": "Top {{symbol}} Borrowers", "top-depositors": "Top {{symbol}} Depositors", "total-supply": "Total Supply", diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index d259df69..2150c67d 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -145,6 +145,7 @@ "token": "Token", "tokens": "Tokens", "token-collateral-multiplier": "{{token}} Collateral Multiplier", + "tooltip-borrow-fee": "The fee for originating a loan.", "tooltip-borrow-rate": "The variable interest rate you'll pay on your borrowed balance", "tooltip-collateral-value": "The USD amount you can trade or borrow against", "total": "Total", diff --git a/public/locales/ru/token.json b/public/locales/ru/token.json index e2758037..16ffc463 100644 --- a/public/locales/ru/token.json +++ b/public/locales/ru/token.json @@ -4,22 +4,42 @@ "borrowing": "Borrowing", "borrows": "Borrows", "borrow-rates": "Borrow Rates", + "borrow-upkeep-fee": "Borrow Upkeep Fee", "chart-unavailable": "Chart Unavailable", "circulating-supply": "Circulating Supply", + "deposit-borrow-scaling-start": "Deposit/Borrow Scaling Start", "deposits": "Deposits", "deposit-rates": "Deposit Rates", "fees-tooltip": "Fees collected for loan origination, loan upkeep and Openbook hosting rebates.", "fdv": "Fully Diluted Value", "go-to-account": "Go To Account", + "init-asset-liability-weight": "Init Asset/Liability Weight", + "insurance-rate-curve": "Insurance Rate Curve", "lending": "Lending", + "maint-asset-liability-weight": "Maint Asset/Liability Weight", "market-cap": "Market Cap", "max-supply": "Max Supply", + "net-borrow-limit-in-period": "Net Borrow Limit in Period", + "net-borrows-in-period": "Net Borrows in Period", "no-borrowers": "No Borrowers...", "no-depositors": "No Depositors...", + "oracle": "Oracle", + "oracle-confidence": "Oracle Confidence", + "oracle-staleness": "Oracle Staleness", "token-details": "Token Details", "token-fees-collected": "Token Fees Collected (M2M)", "token-not-found": "Token Not Found", "token-not-found-desc": "'{{token}}' is either not listed or we're having issues loading the data.", + "tooltip-borrow-upkeep-fee": "", + "tooltip-deposit-borrow-scaling-start": "This acts as a soft limit for deposits and borrows. For deposits, if this value is exceeded the asset weight for opening new positions is scaled down. For borrows, the liability weight for opening new positions is scaled up.", + "tooltip-init-asset-liability-weight": "The contribution a token has to your initial account health. Asset weight increases health and liability weight reduces it. Initial health affects your ability to withdraw and open new positions and is reflected by the amount of free collateral in your account.", + "tooltip-insurance-rate-curve": "", + "tooltip-liquidation-fee": "The fee paid to liqudators when {{symbol}} is liquidated.", + "tooltip-maint-asset-liability-weight": "The contribution a token has to your account health. Asset weight increases health and liability weight reduces it. Maintance health is what's displayed on your account page. If this value reaches zero your account will be liquidated.", + "tooltip-net-borrow-limit-in-period": "", + "tooltip-net-borrows-in-period": "", + "tooltip-oracle-confidence": "How much variation from the true price is tolerated.", + "tooltip-oracle-staleness": "Price is considered valid when it is last udpated within {{slots}} slots.", "top-borrowers": "Top {{symbol}} Borrowers", "top-depositors": "Top {{symbol}} Depositors", "total-supply": "Total Supply", diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json index d259df69..2150c67d 100644 --- a/public/locales/zh/common.json +++ b/public/locales/zh/common.json @@ -145,6 +145,7 @@ "token": "Token", "tokens": "Tokens", "token-collateral-multiplier": "{{token}} Collateral Multiplier", + "tooltip-borrow-fee": "The fee for originating a loan.", "tooltip-borrow-rate": "The variable interest rate you'll pay on your borrowed balance", "tooltip-collateral-value": "The USD amount you can trade or borrow against", "total": "Total", diff --git a/public/locales/zh/token.json b/public/locales/zh/token.json index 59371430..16ffc463 100644 --- a/public/locales/zh/token.json +++ b/public/locales/zh/token.json @@ -4,22 +4,42 @@ "borrowing": "Borrowing", "borrows": "Borrows", "borrow-rates": "Borrow Rates", + "borrow-upkeep-fee": "Borrow Upkeep Fee", "chart-unavailable": "Chart Unavailable", "circulating-supply": "Circulating Supply", + "deposit-borrow-scaling-start": "Deposit/Borrow Scaling Start", "deposits": "Deposits", "deposit-rates": "Deposit Rates", - "fdv": "Fully Diluted Value", "fees-tooltip": "Fees collected for loan origination, loan upkeep and Openbook hosting rebates.", + "fdv": "Fully Diluted Value", "go-to-account": "Go To Account", + "init-asset-liability-weight": "Init Asset/Liability Weight", + "insurance-rate-curve": "Insurance Rate Curve", "lending": "Lending", + "maint-asset-liability-weight": "Maint Asset/Liability Weight", "market-cap": "Market Cap", "max-supply": "Max Supply", + "net-borrow-limit-in-period": "Net Borrow Limit in Period", + "net-borrows-in-period": "Net Borrows in Period", "no-borrowers": "No Borrowers...", "no-depositors": "No Depositors...", + "oracle": "Oracle", + "oracle-confidence": "Oracle Confidence", + "oracle-staleness": "Oracle Staleness", "token-details": "Token Details", "token-fees-collected": "Token Fees Collected (M2M)", "token-not-found": "Token Not Found", "token-not-found-desc": "'{{token}}' is either not listed or we're having issues loading the data.", + "tooltip-borrow-upkeep-fee": "", + "tooltip-deposit-borrow-scaling-start": "This acts as a soft limit for deposits and borrows. For deposits, if this value is exceeded the asset weight for opening new positions is scaled down. For borrows, the liability weight for opening new positions is scaled up.", + "tooltip-init-asset-liability-weight": "The contribution a token has to your initial account health. Asset weight increases health and liability weight reduces it. Initial health affects your ability to withdraw and open new positions and is reflected by the amount of free collateral in your account.", + "tooltip-insurance-rate-curve": "", + "tooltip-liquidation-fee": "The fee paid to liqudators when {{symbol}} is liquidated.", + "tooltip-maint-asset-liability-weight": "The contribution a token has to your account health. Asset weight increases health and liability weight reduces it. Maintance health is what's displayed on your account page. If this value reaches zero your account will be liquidated.", + "tooltip-net-borrow-limit-in-period": "", + "tooltip-net-borrows-in-period": "", + "tooltip-oracle-confidence": "How much variation from the true price is tolerated.", + "tooltip-oracle-staleness": "Price is considered valid when it is last udpated within {{slots}} slots.", "top-borrowers": "Top {{symbol}} Borrowers", "top-depositors": "Top {{symbol}} Depositors", "total-supply": "Total Supply", diff --git a/public/locales/zh_tw/common.json b/public/locales/zh_tw/common.json index 6d0c3ae7..600fe333 100644 --- a/public/locales/zh_tw/common.json +++ b/public/locales/zh_tw/common.json @@ -145,6 +145,7 @@ "token": "幣種", "token-collateral-multiplier": "{{token}}質押品乘數", "tokens": "幣種", + "tooltip-borrow-fee": "The fee for originating a loan.", "tooltip-borrow-rate": "您將為借入餘額支付的可變利率", "tooltip-collateral-value": "您可以交易或借入的美元金額", "total": "總計", diff --git a/public/locales/zh_tw/token.json b/public/locales/zh_tw/token.json index 64020d75..4071dade 100644 --- a/public/locales/zh_tw/token.json +++ b/public/locales/zh_tw/token.json @@ -2,24 +2,44 @@ "all-time-high": "歷史高價", "all-time-low": "歷史低價", "borrow-rates": "借貸利率", + "borrow-upkeep-fee": "Borrow Upkeep Fee", "borrowing": "借入", "borrows": "借貸", "chart-unavailable": "無法顯示圖表", "circulating-supply": "流通供應量", + "deposit-borrow-scaling-start": "Deposit/Borrow Scaling Start", "deposit-rates": "存款利率", "deposits": "存款", "fdv": "全稀釋市值", "fees-tooltip": "為貸款發放、貸款維護和Openbook收取的費用。", "go-to-account": "檢視帳戶", + "init-asset-liability-weight": "Init Asset/Liability Weight", + "insurance-rate-curve": "Insurance Rate Curve", "lending": "借出", + "maint-asset-liability-weight": "Maint Asset/Liability Weight", "market-cap": "總市值", "max-supply": "最大供應量", + "net-borrow-limit-in-period": "Net Borrow Limit in Period", + "net-borrows-in-period": "Net Borrows in Period", "no-borrowers": "無借貸者...", "no-depositors": "無存款者...", + "oracle": "Oracle", + "oracle-confidence": "Oracle Confidence", + "oracle-staleness": "Oracle Staleness", "token-details": "幣種細節", "token-fees-collected": "Token Fees Collected (M2M)", "token-not-found": "查不到幣種", "token-not-found-desc": "'{{token}}'未列入或我們在加載數據時出錯。", + "tooltip-borrow-upkeep-fee": "", + "tooltip-deposit-borrow-scaling-start": "This acts as a soft limit for deposits and borrows. For deposits, if this value is exceeded the asset weight for opening new positions is scaled down. For borrows, the liability weight for opening new positions is scaled up.", + "tooltip-init-asset-liability-weight": "The contribution a token has to your initial account health. Asset weight increases health and liability weight reduces it. Initial health affects your ability to withdraw and open new positions and is reflected by the amount of free collateral in your account.", + "tooltip-insurance-rate-curve": "", + "tooltip-liquidation-fee": "The fee paid to liqudators when {{symbol}} is liquidated.", + "tooltip-maint-asset-liability-weight": "The contribution a token has to your account health. Asset weight increases health and liability weight reduces it. Maintance health is what's displayed on your account page. If this value reaches zero your account will be liquidated.", + "tooltip-net-borrow-limit-in-period": "", + "tooltip-net-borrows-in-period": "", + "tooltip-oracle-confidence": "How much variation from the true price is tolerated.", + "tooltip-oracle-staleness": "Price is considered valid when it is last udpated within {{slots}} slots.", "top-borrowers": "頂級{{symbol}}借貸者", "top-depositors": "頂級{{symbol}}存款者", "total-supply": "總供應量",