add available vault balance to token stats

This commit is contained in:
saml33 2023-01-09 12:31:34 +11:00
parent 3d6f30b7fb
commit 434967b0a1
6 changed files with 73 additions and 29 deletions

View File

@ -65,6 +65,11 @@ const TokenStats = () => {
<Th className="text-left">{t('token')}</Th>
<Th className="text-right">{t('total-deposits')}</Th>
<Th className="text-right">{t('total-borrows')}</Th>
<Th className="text-right">
<Tooltip content="The amount available to borrow">
<span className="tooltip-underline">{t('available')}</span>
</Tooltip>
</Th>
<Th>
<div className="flex justify-end">
<Tooltip content="The deposit rate (green) will automatically be paid on positive balances and the borrow rate (red) will automatically be charged on negative balances.">
@ -83,18 +88,13 @@ const TokenStats = () => {
</Th>
<Th>
<div className="flex justify-end text-right">
<Tooltip content={t('asset-weight-desc')}>
<Tooltip content={t('asset-liability-weight-desc')}>
<span className="tooltip-underline">
{t('asset-weight')}
{t('asset-liability-weight')}
</span>
</Tooltip>
</div>
</Th>
<Th>
<div className="flex items-center justify-end">
<span className="text-right">{t('liability-weight')}</span>
</div>
</Th>
</TrHead>
</thead>
<tbody>
@ -110,6 +110,8 @@ const TokenStats = () => {
const deposits = bank.uiDeposits()
const borrows = bank.uiBorrows()
const price = bank.uiPrice
const available =
deposits - deposits * bank.minVaultToDepositsRatio - borrows
return (
<TrBody key={key}>
@ -142,7 +144,19 @@ const TokenStats = () => {
</div>
</Td>
<Td>
<div className="flex justify-end space-x-2">
<div className="flex flex-col text-right">
<p>
{available > 0 ? formatFixedDecimals(available) : '0'}
</p>
<p className="text-th-fgd-4">
{available > 0
? formatFixedDecimals(available * price, false, true)
: '$0.00'}
</p>
</div>
</Td>
<Td>
<div className="flex justify-end space-x-1.5">
<p className="text-th-up">
{formatDecimal(bank.getDepositRateUi(), 2, {
fixed: true,
@ -173,12 +187,9 @@ const TokenStats = () => {
</div>
</Td>
<Td>
<div className="text-right">
<div className="flex justify-end space-x-1.5 text-right">
<p>{bank.initAssetWeight.toFixed(2)}</p>
</div>
</Td>
<Td>
<div className="text-right">
<span className="text-th-fgd-4">|</span>
<p>{bank.initLiabWeight.toFixed(2)}</p>
</div>
</Td>
@ -210,6 +221,8 @@ const TokenStats = () => {
const deposits = bank.uiDeposits()
const borrows = bank.uiBorrows()
const price = bank.uiPrice
const available =
deposits - deposits * bank.minVaultToDepositsRatio - borrows
return (
<div key={key} className="border-b border-th-bkg-3 px-6 py-4">
<div className="flex items-center justify-between">
@ -299,20 +312,41 @@ const TokenStats = () => {
</p>
</div>
<div className="col-span-1">
<p className="text-xs text-th-fgd-3">
{t('asset-weight')}
</p>
<p className="font-mono text-th-fgd-1">
{bank.initAssetWeight.toFixed(2)}
<Tooltip content="The amount available to borrow">
<p className="tooltip-underline text-xs text-th-fgd-3">
{t('available')}
</p>
</Tooltip>
<p className="text-th-fgd-1">
{available > 0 ? formatFixedDecimals(available) : '0'}{' '}
<span className="text-th-fgd-4">
(
{available > 0
? formatFixedDecimals(
available * price,
false,
true
)
: '$0.00'}
)
</span>
</p>
</div>
<div className="col-span-1">
<p className="text-xs text-th-fgd-3">
{t('liability-weight')}
</p>
<p className="font-mono text-th-fgd-1">
{bank.initLiabWeight.toFixed(2)}
</p>
<Tooltip content={t('asset-liability-weight-desc')}>
<p className="tooltip-underline text-xs text-th-fgd-3">
{t('asset-liability-weight')}
</p>
</Tooltip>
<div className="flex space-x-1.5 text-right font-mono">
<p className="text-th-fgd-1">
{bank.initAssetWeight.toFixed(2)}
</p>
<span className="text-th-fgd-4">|</span>
<p className="text-th-fgd-1">
{bank.initLiabWeight.toFixed(2)}
</p>
</div>
</div>
<div className="col-span-1">
<LinkButton

View File

@ -15,8 +15,10 @@
"add-new-account": "Add New Account",
"amount": "Amount",
"amount-owed": "Amount Owed",
"asset-liability-weight": "Asset/Liability Weights",
"asset-liability-weight-desc": "Asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral. Liability weight does the opposite (adds to the value of the liability in your health calculation).",
"asset-weight": "Asset Weight",
"asset-weight-desc": "The asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral.",
"asset-weight-desc": "Asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral.",
"available": "Available",
"available-balance": "Available Balance",
"balance": "Balance",

View File

@ -15,8 +15,10 @@
"add-new-account": "Add New Account",
"amount": "Amount",
"amount-owed": "Amount Owed",
"asset-liability-weight": "Asset/Liability Weights",
"asset-liability-weight-desc": "Asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral. Liability weight does the opposite (adds to the value of the liability in your health calculation).",
"asset-weight": "Asset Weight",
"asset-weight-desc": "The asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral.",
"asset-weight-desc": "Asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral.",
"available": "Available",
"available-balance": "Available Balance",
"balance": "Balance",

View File

@ -15,8 +15,10 @@
"add-new-account": "Add New Account",
"amount": "Amount",
"amount-owed": "Amount Owed",
"asset-liability-weight": "Asset/Liability Weights",
"asset-liability-weight-desc": "Asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral. Liability weight does the opposite (adds to the value of the liability in your health calculation).",
"asset-weight": "Asset Weight",
"asset-weight-desc": "The asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral.",
"asset-weight-desc": "Asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral.",
"available": "Available",
"available-balance": "Available Balance",
"balance": "Balance",

View File

@ -15,8 +15,10 @@
"add-new-account": "Add New Account",
"amount": "Amount",
"amount-owed": "Amount Owed",
"asset-liability-weight": "Asset/Liability Weights",
"asset-liability-weight-desc": "Asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral. Liability weight does the opposite (adds to the value of the liability in your health calculation).",
"asset-weight": "Asset Weight",
"asset-weight-desc": "The asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral.",
"asset-weight-desc": "Asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral.",
"available": "Available",
"available-balance": "Available Balance",
"balance": "Balance",

View File

@ -15,8 +15,10 @@
"add-new-account": "Add New Account",
"amount": "Amount",
"amount-owed": "Amount Owed",
"asset-liability-weight": "Asset/Liability Weights",
"asset-liability-weight-desc": "Asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral. Liability weight does the opposite (adds to the value of the liability in your health calculation).",
"asset-weight": "Asset Weight",
"asset-weight-desc": "The asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral.",
"asset-weight-desc": "Asset weight applies a haircut to the value of the collateral in your account health calculation. The lower the asset weight, the less the asset counts towards collateral.",
"available": "Available",
"available-balance": "Available Balance",
"balance": "Balance",