chore(trading): use quantum for liquidity supplied (#5099)

This commit is contained in:
m.ray 2023-10-23 12:24:26 +03:00 committed by GitHub
parent ae02b153f8
commit 20e1522088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 15 deletions

View File

@ -86,6 +86,7 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
<MarketLiquiditySupplied <MarketLiquiditySupplied
marketId={market.id} marketId={market.id}
assetDecimals={asset?.decimals || 0} assetDecimals={asset?.decimals || 0}
quantum={asset.quantum}
/> />
{market.tradableInstrument.instrument.product.__typename === 'Future' && ( {market.tradableInstrument.instrument.product.__typename === 'Future' && (
<HeaderStat <HeaderStat

View File

@ -18,7 +18,7 @@ import BigNumber from 'bignumber.js';
import { useCheckLiquidityStatus } from '@vegaprotocol/liquidity'; import { useCheckLiquidityStatus } from '@vegaprotocol/liquidity';
import { AuctionTrigger, MarketTradingMode } from '@vegaprotocol/types'; import { AuctionTrigger, MarketTradingMode } from '@vegaprotocol/types';
import { import {
addDecimalsFormatNumber, addDecimalsFormatNumberQuantum,
formatNumberPercentage, formatNumberPercentage,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
@ -30,12 +30,14 @@ interface Props {
marketId?: string; marketId?: string;
noUpdate?: boolean; noUpdate?: boolean;
assetDecimals: number; assetDecimals: number;
quantum: string;
} }
export const MarketLiquiditySupplied = ({ export const MarketLiquiditySupplied = ({
marketId, marketId,
assetDecimals, assetDecimals,
noUpdate = false, noUpdate = false,
quantum,
}: Props) => { }: Props) => {
const [market, setMarket] = useState<MarketData>(); const [market, setMarket] = useState<MarketData>();
const { params } = useNetworkParams([ const { params } = useNetworkParams([
@ -79,11 +81,12 @@ export const MarketLiquiditySupplied = ({
}); });
const supplied = market?.suppliedStake const supplied = market?.suppliedStake
? addDecimalsFormatNumber( ? addDecimalsFormatNumberQuantum(
new BigNumber(market?.suppliedStake) new BigNumber(market?.suppliedStake)
.multipliedBy(stakeToCcyVolume || 1) .multipliedBy(stakeToCcyVolume || 1)
.toString(), .toString(),
assetDecimals assetDecimals,
quantum
) )
: '-'; : '-';
@ -108,9 +111,10 @@ export const MarketLiquiditySupplied = ({
<span>{t('Supplied stake')}</span> <span>{t('Supplied stake')}</span>
<span> <span>
{market?.suppliedStake {market?.suppliedStake
? addDecimalsFormatNumber( ? addDecimalsFormatNumberQuantum(
new BigNumber(market?.suppliedStake).toString(), market?.suppliedStake,
assetDecimals assetDecimals,
quantum
) )
: '-'} : '-'}
</span> </span>
@ -119,9 +123,10 @@ export const MarketLiquiditySupplied = ({
<span>{t('Target stake')}</span> <span>{t('Target stake')}</span>
<span> <span>
{market?.targetStake {market?.targetStake
? addDecimalsFormatNumber( ? addDecimalsFormatNumberQuantum(
new BigNumber(market?.targetStake).toString(), market?.targetStake,
assetDecimals assetDecimals,
quantum
) )
: '-'} : '-'}
</span> </span>

View File

@ -43,7 +43,7 @@ import {
REDUCE_ONLY_TOOLTIP, REDUCE_ONLY_TOOLTIP,
stopSubmit, stopSubmit,
getNotionalSize, getNotionalSize,
getAssetUnit, getBaseQuoteUnit,
} from './deal-ticket'; } from './deal-ticket';
import { TypeToggle } from './type-selector'; import { TypeToggle } from './type-selector';
import { import {
@ -854,7 +854,7 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
}, [watch, market.id, updateStoredFormValues]); }, [watch, market.id, updateStoredFormValues]);
const quoteName = getQuoteName(market); const quoteName = getQuoteName(market);
const assetUnit = getAssetUnit( const assetUnit = getBaseQuoteUnit(
market.tradableInstrument.instrument.metadata.tags market.tradableInstrument.instrument.metadata.tags
); );

View File

@ -127,7 +127,7 @@ const getDefaultValues = (
...storedValues, ...storedValues,
}); });
export const getAssetUnit = (tags?: string[] | null) => export const getBaseQuoteUnit = (tags?: string[] | null) =>
tags tags
?.find((tag) => tag.startsWith('base:') || tag.startsWith('ticker:')) ?.find((tag) => tag.startsWith('base:') || tag.startsWith('ticker:'))
?.replace(/^[^:]*:/, ''); ?.replace(/^[^:]*:/, '');
@ -273,9 +273,7 @@ export const DealTicket = ({
const assetSymbol = getAsset(market).symbol; const assetSymbol = getAsset(market).symbol;
const assetUnit = getAssetUnit( const assetUnit = getQuoteName(market);
market.tradableInstrument.instrument.metadata.tags
);
const summaryError = useMemo(() => { const summaryError = useMemo(() => {
if (!pubKey) { if (!pubKey) {