fix(#2554): close out formatting (#2584)

* fix(#2530): fix use order close out - formatting to be done in component

* fix: format number in console-lite
This commit is contained in:
m.ray 2023-01-11 12:10:35 -05:00 committed by GitHub
parent 13ab03c459
commit 31ffa306eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -83,10 +83,11 @@ export const DealTicketSteps = ({ market }: DealTicketMarketProps) => {
order,
});
const estCloseOut = useOrderCloseOut({
const closeOut = useOrderCloseOut({
order,
market,
});
const estCloseOut = closeOut && formatNumber(closeOut, market.decimalPlaces);
const slippage = useCalculateSlippage({ marketId: market.id, order });
const [slippageValue, setSlippageValue] = useState(
slippage ? parseFloat(slippage) : 0

View File

@ -71,7 +71,7 @@ describe('useOrderCloseOut', () => {
wrapper: MockedProvider,
}
);
expect(result.current).toEqual('1.00');
expect(result.current).toEqual('1');
});
it('should return proper empty value', () => {
@ -88,6 +88,6 @@ describe('useOrderCloseOut', () => {
wrapper: MockedProvider,
}
);
expect(result.current).toEqual('0.00');
expect(result.current).toEqual('0');
});
});

View File

@ -1,6 +1,6 @@
import { BigNumber } from 'bignumber.js';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import { addDecimal, formatNumber } from '@vegaprotocol/react-helpers';
import { addDecimal } from '@vegaprotocol/react-helpers';
import * as Schema from '@vegaprotocol/types';
import type { MarketDealTicket } from '@vegaprotocol/market-list';
import {
@ -49,7 +49,7 @@ export const useOrderCloseOut = ({ order, market }: Props): string | null => {
.minus(generalAccountBalance);
const closeOut = marginDifference.div(volume).plus(markPrice);
if (closeOut.isPositive()) {
return formatNumber(closeOut, market.decimalPlaces);
return closeOut.toString();
}
return null;
};