add token params to token page

This commit is contained in:
saml33 2023-05-01 12:16:29 +10:00
parent 0f50637927
commit 9ceb264c0a
12 changed files with 297 additions and 2 deletions

View File

@ -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 = () => {
%
</span>
</div>
{bank ? <TopTokenAccounts bank={bank} /> : null}
<TopTokenAccounts bank={bank} />
{coingeckoTokenInfo?.market_data ? (
<CoingeckoStats
bank={bank}
@ -209,6 +210,7 @@ const TokenPage = () => {
<p>No CoinGecko data...</p>
</div>
)}
<TokenParams bank={bank} />
</>
) : loading ? (
<div className="space-y-3 px-6 py-4">

View File

@ -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 (
<div className="grid grid-cols-1 border-b border-th-bkg-3 md:grid-cols-2">
<div className="col-span-1 border-b border-th-bkg-3 px-6 py-4 md:col-span-2">
<h2 className="text-base">{bank.name} Paramaters</h2>
</div>
<div className="col-span-1 px-6 py-4 md:border-r md:border-th-bkg-3">
<div className="flex justify-between pb-4">
<Tooltip content={t('token:tooltip-init-asset-liability-weight')}>
<p className="tooltip-underline">
{t('token:init-asset-liability-weight')}
</p>
</Tooltip>
<div className="flex space-x-2">
<p className="font-mono text-th-fgd-2">
{bank.initAssetWeight.toFixed(2)}
</p>
<span className="text-th-fgd-4">|</span>
<p>{bank.initLiabWeight.toFixed(2)}</p>
</div>
</div>
<div className="flex justify-between border-t border-th-bkg-3 py-4">
<Tooltip content={t('token:tooltip-maint-asset-liability-weight')}>
<p className="tooltip-underline">
{t('token:maint-asset-liability-weight')}
</p>
</Tooltip>
<div className="flex space-x-2">
<p className="font-mono text-th-fgd-2">
{bank.maintAssetWeight.toFixed(2)}
</p>
<span className="text-th-fgd-4">|</span>
<p>{bank.maintLiabWeight.toFixed(2)}</p>
</div>
</div>
<div className="flex justify-between border-t border-th-bkg-3 py-4">
<Tooltip content={t('tooltip-borrow-fee')}>
<p className="tooltip-underline">{t('borrow-fee')}</p>
</Tooltip>
<p className="font-mono text-th-fgd-2">
{(100 * bank.loanOriginationFeeRate.toNumber()).toFixed(2)}%
</p>
</div>
<div className="flex justify-between border-t border-th-bkg-3 py-4">
<Tooltip content={t('token:tooltip-borrow-upkeep-fee')}>
<p className="tooltip-underline">{t('token:borrow-upkeep-fee')}</p>
</Tooltip>
<p className="font-mono text-th-fgd-2">
{(100 * bank.loanFeeRate.toNumber()).toFixed(2)}%
</p>
</div>
<div className="flex justify-between border-t border-th-bkg-3 py-4">
<Tooltip
content={t('token:tooltip-liquidation-fee', { symbol: bank.name })}
>
<p className="tooltip-underline">{t('activity:liquidation-fee')}</p>
</Tooltip>
<p className="font-mono text-th-fgd-2">
{(bank.liquidationFee.toNumber() * 100).toFixed(2)}%
</p>
</div>
<div className="flex justify-between border-y border-th-bkg-3 py-4 md:border-b-0">
<Tooltip content={t('token:tooltip-deposit-borrow-scaling-start')}>
<p className="tooltip-underline">
{t('token:deposit-borrow-scaling-start')}
</p>
</Tooltip>
<div className="flex space-x-2">
<p className="font-mono text-th-fgd-2">
{formatCurrencyValue(
toUiDecimalsForQuote(bank.depositWeightScaleStartQuote)
)}
</p>
<span className="text-th-fgd-4">|</span>
<p className="font-mono text-th-fgd-2">
{formatCurrencyValue(
toUiDecimalsForQuote(bank.borrowWeightScaleStartQuote)
)}
</p>
</div>
</div>
</div>
<div className="col-span-1 px-6 pb-4 md:pt-4">
<div className="flex justify-between pb-4">
<Tooltip content={t('token:tooltip-net-borrows-in-period')}>
<p className="tooltip-underline">
{t('token:net-borrows-in-period')}
</p>
</Tooltip>
<p className="font-mono text-th-fgd-2">
{formatNumericValue(
toUiDecimalsForQuote(I80F48.fromI64(bank.netBorrowsInWindow))
)}
</p>
</div>
<div className="flex justify-between border-t border-th-bkg-3 py-4">
<Tooltip content={t('token:tooltip-net-borrow-limit-in-period')}>
<p className="tooltip-underline">
{t('token:net-borrow-limit-in-period')}
</p>
</Tooltip>
<p className="font-mono text-th-fgd-2">
{formatNumericValue(
toUiDecimals(bank.netBorrowLimitPerWindowQuote, 6)
)}
</p>
</div>
<div className="flex justify-between border-t border-th-bkg-3 py-4">
<p>{t('token:oracle')}</p>
<a
className="flex items-center"
href={oracleLinkPath}
target="_blank"
rel="noopener noreferrer"
>
<p className="mr-1.5 text-th-fgd-2">{oracleProvider}</p>
<ArrowTopRightOnSquareIcon className="h-4 w-4" />
</a>
</div>
<div className="flex justify-between border-t border-th-bkg-3 py-4">
<Tooltip content={t('token:tooltip-oracle-confidence')}>
<p className="tooltip-underline">{t('token:oracle-confidence')}</p>
</Tooltip>
<p className="font-mono text-th-fgd-2">
{(100 * bank.oracleConfig.confFilter.toNumber()).toFixed(2)}%
</p>
</div>
<div className="flex justify-between border-t border-th-bkg-3 py-4">
<Tooltip
content={t('token:tooltip-oracle-staleness', {
slots: bank.oracleConfig.maxStalenessSlots.toNumber(),
})}
>
<p className="tooltip-underline">{t('token:oracle-staleness')}</p>
</Tooltip>
<p className="font-mono text-th-fgd-2">
{bank.oracleConfig.maxStalenessSlots.toNumber()}{' '}
<span className="font-body text-th-fgd-4">Slots</span>
</p>
</div>
<div className="flex justify-between border-t border-th-bkg-3 py-4">
<Tooltip content={t('token:tooltip-insurance-rate-curve')}>
<p className="tooltip-underline">
{t('token:insurance-rate-curve')}
</p>
</Tooltip>
<p className="font-mono text-th-fgd-2">?</p>
</div>
</div>
</div>
)
}
export default TokenParams

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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": "總計",

View File

@ -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": "總供應量",