add to other amoutwithvalue components
This commit is contained in:
parent
530d0ef2ce
commit
84277736ec
|
@ -21,11 +21,7 @@ import {
|
|||
INPUT_TOKEN_DEFAULT,
|
||||
} from './../utils/constants'
|
||||
import { notify } from './../utils/notifications'
|
||||
import {
|
||||
floorToDecimal,
|
||||
formatDecimal,
|
||||
formatFixedDecimals,
|
||||
} from './../utils/numbers'
|
||||
import { floorToDecimal, formatDecimal } from './../utils/numbers'
|
||||
import ActionTokenList from './account/ActionTokenList'
|
||||
import ButtonGroup from './forms/ButtonGroup'
|
||||
import Label from './forms/Label'
|
||||
|
@ -332,46 +328,33 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) {
|
|||
<p>{t('withdraw-amount')}</p>
|
||||
{isBorrow ? (
|
||||
<AmountWithValue
|
||||
amount={formatDecimal(
|
||||
Number(tokenBalance),
|
||||
bank.mintDecimals
|
||||
)}
|
||||
value={formatFixedDecimals(
|
||||
bank.uiPrice * tokenBalance.toNumber(),
|
||||
true
|
||||
)}
|
||||
amount={tokenBalance}
|
||||
amountDecimals={bank.mintDecimals}
|
||||
value={bank.uiPrice * tokenBalance.toNumber()}
|
||||
/>
|
||||
) : inputAmount ? (
|
||||
<AmountWithValue
|
||||
amount={formatDecimal(
|
||||
Number(inputAmount),
|
||||
bank.mintDecimals
|
||||
)}
|
||||
value={formatFixedDecimals(
|
||||
bank.uiPrice * parseFloat(inputAmount),
|
||||
true
|
||||
)}
|
||||
amount={inputAmount}
|
||||
amountDecimals={bank.mintDecimals}
|
||||
value={bank.uiPrice * parseFloat(inputAmount)}
|
||||
/>
|
||||
) : (
|
||||
<AmountWithValue amount="0" value="$0.00" />
|
||||
<AmountWithValue amount="0" amountDecimals={0} value={0} />
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<p>{t('borrow-amount')}</p>
|
||||
{isBorrow ? (
|
||||
<AmountWithValue
|
||||
amount={formatDecimal(
|
||||
Number(inputAmount) - Number(tokenBalance),
|
||||
bank.mintDecimals
|
||||
)}
|
||||
value={formatFixedDecimals(
|
||||
amount={Number(inputAmount) - Number(tokenBalance)}
|
||||
amountDecimals={bank.mintDecimals}
|
||||
value={
|
||||
bank.uiPrice *
|
||||
(parseFloat(inputAmount) - tokenBalance.toNumber()),
|
||||
true
|
||||
)}
|
||||
(parseFloat(inputAmount) - tokenBalance.toNumber())
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<AmountWithValue amount="0" value="$0.00" />
|
||||
<AmountWithValue amount="0" amountDecimals={0} value={0} />
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
|
|
|
@ -19,11 +19,7 @@ import {
|
|||
INPUT_TOKEN_DEFAULT,
|
||||
} from './../utils/constants'
|
||||
import { notify } from './../utils/notifications'
|
||||
import {
|
||||
floorToDecimal,
|
||||
formatDecimal,
|
||||
formatFixedDecimals,
|
||||
} from './../utils/numbers'
|
||||
import { floorToDecimal, formatFixedDecimals } from './../utils/numbers'
|
||||
import { TokenAccount } from './../utils/tokens'
|
||||
import ActionTokenList from './account/ActionTokenList'
|
||||
import ButtonGroup from './forms/ButtonGroup'
|
||||
|
@ -338,17 +334,12 @@ function DepositForm({ onSuccess, token }: DepositFormProps) {
|
|||
<p>{t('deposit-amount')}</p>
|
||||
{inputAmount ? (
|
||||
<AmountWithValue
|
||||
amount={formatDecimal(
|
||||
Number(inputAmount),
|
||||
bank.mintDecimals
|
||||
)}
|
||||
value={formatFixedDecimals(
|
||||
bank.uiPrice * Number(inputAmount),
|
||||
true
|
||||
)}
|
||||
amount={inputAmount}
|
||||
amountDecimals={bank.mintDecimals}
|
||||
value={bank.uiPrice * Number(inputAmount)}
|
||||
/>
|
||||
) : (
|
||||
<AmountWithValue amount="0" value="$0.00" />
|
||||
<AmountWithValue amount="0" amountDecimals={0} value={0} />
|
||||
)}
|
||||
</div>
|
||||
{/* <div className="flex justify-between">
|
||||
|
|
|
@ -13,11 +13,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|||
import NumberFormat, { NumberFormatValues } from 'react-number-format'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import { notify } from './../utils/notifications'
|
||||
import {
|
||||
floorToDecimal,
|
||||
formatDecimal,
|
||||
formatFixedDecimals,
|
||||
} from './../utils/numbers'
|
||||
import { floorToDecimal, formatDecimal } from './../utils/numbers'
|
||||
import ActionTokenList from './account/ActionTokenList'
|
||||
import ButtonGroup from './forms/ButtonGroup'
|
||||
import Label from './forms/Label'
|
||||
|
@ -306,17 +302,12 @@ function RepayForm({ onSuccess, token }: RepayFormProps) {
|
|||
<p>{t('repayment-amount')}</p>
|
||||
{inputAmount ? (
|
||||
<AmountWithValue
|
||||
amount={formatDecimal(
|
||||
Number(inputAmount),
|
||||
bank.mintDecimals
|
||||
)}
|
||||
value={formatFixedDecimals(
|
||||
bank.uiPrice * Number(inputAmount),
|
||||
true
|
||||
)}
|
||||
amount={inputAmount}
|
||||
amountDecimals={bank.mintDecimals}
|
||||
value={bank.uiPrice * Number(inputAmount)}
|
||||
/>
|
||||
) : (
|
||||
<AmountWithValue amount="0" value="$0.00" />
|
||||
<AmountWithValue amount="0" amountDecimals={0} value={0} />
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
|
|
|
@ -18,11 +18,7 @@ import {
|
|||
INPUT_TOKEN_DEFAULT,
|
||||
} from './../utils/constants'
|
||||
import { notify } from './../utils/notifications'
|
||||
import {
|
||||
floorToDecimal,
|
||||
formatDecimal,
|
||||
formatFixedDecimals,
|
||||
} from './../utils/numbers'
|
||||
import { floorToDecimal } from './../utils/numbers'
|
||||
import ActionTokenList from './account/ActionTokenList'
|
||||
import ButtonGroup from './forms/ButtonGroup'
|
||||
import Label from './forms/Label'
|
||||
|
@ -295,17 +291,12 @@ function WithdrawForm({ onSuccess, token }: WithdrawFormProps) {
|
|||
<p>{t('withdraw-amount')}</p>
|
||||
{inputAmount ? (
|
||||
<AmountWithValue
|
||||
amount={formatDecimal(
|
||||
Number(inputAmount),
|
||||
bank.mintDecimals
|
||||
)}
|
||||
value={formatFixedDecimals(
|
||||
bank.uiPrice * Number(inputAmount),
|
||||
true
|
||||
)}
|
||||
amount={inputAmount}
|
||||
amountDecimals={bank.mintDecimals}
|
||||
value={bank.uiPrice * Number(inputAmount)}
|
||||
/>
|
||||
) : (
|
||||
<AmountWithValue amount="0" value="$0.00" />
|
||||
<AmountWithValue amount="0" amountDecimals={0} value={0} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -119,31 +119,17 @@ const BalancesTable = () => {
|
|||
</Td>
|
||||
<Td className="text-right">
|
||||
<AmountWithValue
|
||||
amount={
|
||||
inOrders
|
||||
? formatDecimal(Number(inOrders), bank.mintDecimals)
|
||||
: '0'
|
||||
}
|
||||
value={formatFixedDecimals(
|
||||
inOrders * bank.uiPrice,
|
||||
true,
|
||||
true
|
||||
)}
|
||||
amount={inOrders}
|
||||
amountDecimals={bank.mintDecimals}
|
||||
value={inOrders * bank.uiPrice}
|
||||
stacked
|
||||
/>
|
||||
</Td>
|
||||
<Td className="text-right">
|
||||
<AmountWithValue
|
||||
amount={
|
||||
unsettled
|
||||
? formatDecimal(Number(unsettled), bank.mintDecimals)
|
||||
: '0'
|
||||
}
|
||||
value={formatFixedDecimals(
|
||||
unsettled * bank.uiPrice,
|
||||
true,
|
||||
true
|
||||
)}
|
||||
amount={unsettled}
|
||||
amountDecimals={bank.mintDecimals}
|
||||
value={unsettled * bank.uiPrice}
|
||||
stacked
|
||||
/>
|
||||
</Td>
|
||||
|
|
|
@ -243,12 +243,8 @@ const TokenStats = () => {
|
|||
{t('total-deposits')}
|
||||
</p>
|
||||
<AmountWithValue
|
||||
amount={formatFixedDecimals(deposits)}
|
||||
value={formatFixedDecimals(
|
||||
deposits * price,
|
||||
true,
|
||||
true
|
||||
)}
|
||||
amount={deposits}
|
||||
value={deposits * price}
|
||||
stacked
|
||||
/>
|
||||
</div>
|
||||
|
@ -257,8 +253,8 @@ const TokenStats = () => {
|
|||
{t('total-borrows')}
|
||||
</p>
|
||||
<AmountWithValue
|
||||
amount={formatFixedDecimals(borrows)}
|
||||
value={formatFixedDecimals(borrows * price, true, true)}
|
||||
amount={borrows}
|
||||
value={borrows * price}
|
||||
stacked
|
||||
/>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue