fix(trading): iceberg order fills (#4460)
This commit is contained in:
parent
d18a0c7e15
commit
674baa1ee3
@ -6,7 +6,7 @@ import type { PartialDeep } from 'type-fest';
|
||||
import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
|
||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import type { OrderListTableProps } from '../';
|
||||
import type { OrderFieldsFragment, OrderListTableProps } from '../';
|
||||
import { OrderListTable } from '../';
|
||||
import {
|
||||
generateOrder,
|
||||
@ -110,6 +110,39 @@ describe('OrderListTable', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should apply correct formatting applied for an iceberg order', async () => {
|
||||
const icebergOrder = {
|
||||
...limitOrder,
|
||||
icebergOrder: {
|
||||
__typename: 'IcebergOrder',
|
||||
minimumVisibleSize: '100',
|
||||
peakSize: '50',
|
||||
reservedRemaining: '50',
|
||||
} as OrderFieldsFragment['icebergOrder'],
|
||||
};
|
||||
await act(async () => {
|
||||
render(generateJsx({ rowData: [icebergOrder] }));
|
||||
});
|
||||
const cells = screen.getAllByRole('gridcell');
|
||||
const expectedValues: string[] = [
|
||||
icebergOrder.market?.tradableInstrument.instrument.code || '',
|
||||
'0.05',
|
||||
'0.10',
|
||||
Schema.OrderTypeMapping[
|
||||
icebergOrder.type || Schema.OrderType.TYPE_LIMIT
|
||||
] + ' (Iceberg)',
|
||||
Schema.OrderStatusMapping[icebergOrder.status],
|
||||
'-',
|
||||
`${
|
||||
Schema.OrderTimeInForceCode[icebergOrder.timeInForce]
|
||||
}: ${getDateTimeFormat().format(new Date(icebergOrder.expiresAt ?? ''))}`,
|
||||
getDateTimeFormat().format(new Date(icebergOrder.createdAt)),
|
||||
];
|
||||
expectedValues.forEach((expectedValue, i) =>
|
||||
expect(cells[i]).toHaveTextContent(expectedValue)
|
||||
);
|
||||
});
|
||||
|
||||
it('should apply correct formatting for a rejected order', async () => {
|
||||
const rejectedOrder = {
|
||||
...marketOrder,
|
||||
|
@ -69,6 +69,18 @@ export const OrderListTable = memo<
|
||||
cellClass: 'font-mono text-right',
|
||||
type: 'rightAligned',
|
||||
valueGetter: ({ data }: VegaValueGetterParams<Order>) => {
|
||||
if (data?.icebergOrder) {
|
||||
return data?.size && data.market
|
||||
? toBigNum(
|
||||
(
|
||||
BigInt(data.size) -
|
||||
BigInt(data.remaining) -
|
||||
BigInt(data.icebergOrder.reservedRemaining)
|
||||
).toString(),
|
||||
data.market.positionDecimalPlaces ?? 0
|
||||
).toNumber()
|
||||
: undefined;
|
||||
}
|
||||
return data?.size && data.market
|
||||
? toBigNum(
|
||||
(BigInt(data.size) - BigInt(data.remaining)).toString(),
|
||||
|
Loading…
Reference in New Issue
Block a user