Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
640ac254a6 |
@@ -1,107 +0,0 @@
|
||||
{
|
||||
"changes": {
|
||||
"decimalPlaces": "5",
|
||||
"positionDecimalPlaces": "5",
|
||||
"linearSlippageFactor": "0.001",
|
||||
"quadraticSlippageFactor": "0",
|
||||
"lpPriceRange": "10",
|
||||
"instrument": {
|
||||
"name": "Token test market",
|
||||
"code": "Token.24h",
|
||||
"future": {
|
||||
"settlementAsset": "816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc",
|
||||
"quoteName": "fUSDC",
|
||||
"dataSourceSpecForSettlementData": {
|
||||
"external": {
|
||||
"oracle": {
|
||||
"signers": [
|
||||
{
|
||||
"pubKey": {
|
||||
"key": "70d14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680"
|
||||
}
|
||||
}
|
||||
],
|
||||
"filters": [
|
||||
{
|
||||
"key": {
|
||||
"name": "prices.BTC.value",
|
||||
"type": "TYPE_INTEGER",
|
||||
"numberDecimalPlaces": "0"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"operator": "OPERATOR_GREATER_THAN",
|
||||
"value": "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"dataSourceSpecForTradingTermination": {
|
||||
"external": {
|
||||
"oracle": {
|
||||
"signers": [
|
||||
{
|
||||
"pubKey": {
|
||||
"key": "70d14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680"
|
||||
}
|
||||
}
|
||||
],
|
||||
"filters": [
|
||||
{
|
||||
"key": {
|
||||
"name": "trading.terminated.ETH5",
|
||||
"type": "TYPE_BOOLEAN"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"operator": "OPERATOR_EQUALS",
|
||||
"value": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"dataSourceSpecBinding": {
|
||||
"settlementDataProperty": "prices.BTC.value",
|
||||
"tradingTerminationProperty": "trading.terminated.ETH5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"metadata": ["sector:food", "sector:materials", "source:docs.vega.xyz"],
|
||||
"priceMonitoringParameters": {
|
||||
"triggers": [
|
||||
{
|
||||
"horizon": "43200",
|
||||
"probability": "0.9999999",
|
||||
"auctionExtension": "600"
|
||||
}
|
||||
]
|
||||
},
|
||||
"liquidityMonitoringParameters": {
|
||||
"targetStakeParameters": {
|
||||
"timeWindow": "3600",
|
||||
"scalingFactor": 10
|
||||
},
|
||||
"triggeringRatio": "0.7",
|
||||
"auctionExtension": "1"
|
||||
},
|
||||
"logNormal": {
|
||||
"tau": 0.0001140771161,
|
||||
"riskAversionParameter": 0.001,
|
||||
"params": {
|
||||
"mu": 0,
|
||||
"r": 0.016,
|
||||
"sigma": 0.8
|
||||
}
|
||||
},
|
||||
"successor": {
|
||||
"parentMarketId": "",
|
||||
"insurancePoolFraction": "0.75"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,7 +220,7 @@ context(
|
||||
function () {
|
||||
const proposalTitle = 'Test new market proposal';
|
||||
goToMakeNewProposal(governanceProposalType.NEW_MARKET);
|
||||
cy.getByTestId(newProposalTitle).type(proposalTitle);
|
||||
cy.getByTestId(newProposalTitle).type('Test new market proposal');
|
||||
cy.getByTestId(newProposalDescription).type('E2E test for proposals');
|
||||
cy.fixture('/proposals/new-market').then((newMarketProposal) => {
|
||||
const newMarketPayload = JSON.stringify(newMarketProposal);
|
||||
@@ -606,94 +606,6 @@ context(
|
||||
});
|
||||
});
|
||||
|
||||
it('able to submit successor market proposal', function () {
|
||||
const proposalTitle = 'Test successor market proposal';
|
||||
|
||||
cy.createMarket();
|
||||
cy.reload();
|
||||
waitForSpinner();
|
||||
cy.getByTestId('closed-proposals').within(() => {
|
||||
cy.contains('Add Lorem Ipsum market')
|
||||
.parentsUntil(proposalListItem)
|
||||
.last()
|
||||
.within(() => {
|
||||
cy.getByTestId(viewProposalBtn).click();
|
||||
});
|
||||
});
|
||||
getProposalInformationFromTable('ID').invoke('text').as('parentMarketId');
|
||||
goToMakeNewProposal(governanceProposalType.NEW_MARKET);
|
||||
cy.getByTestId(newProposalTitle).type(proposalTitle);
|
||||
cy.getByTestId(newProposalDescription).type(
|
||||
'E2E test for successor market'
|
||||
);
|
||||
cy.fixture('/proposals/successor-market').then((newMarketProposal) => {
|
||||
newMarketProposal.changes.successor.parentMarketId =
|
||||
this.parentMarketId;
|
||||
const newMarketPayload = JSON.stringify(newMarketProposal);
|
||||
cy.getByTestId(newProposalTerms).type(newMarketPayload, {
|
||||
parseSpecialCharSequences: false,
|
||||
delay: 2,
|
||||
});
|
||||
});
|
||||
cy.getByTestId(proposalDownloadBtn)
|
||||
.should('be.visible')
|
||||
.click()
|
||||
.then(() => {
|
||||
cy.wrap(
|
||||
getDownloadedProposalJsonPath('vega-new-market-proposal-')
|
||||
).then((filePath) => {
|
||||
goToMakeNewProposal(governanceProposalType.RAW);
|
||||
submitUniqueRawProposal({ proposalBody: filePath });
|
||||
});
|
||||
});
|
||||
navigateTo(navigation.proposals);
|
||||
getProposalFromTitle(proposalTitle).within(() => {
|
||||
// 3003-PMAN-008
|
||||
cy.getByTestId('proposal-successor-info')
|
||||
.should('have.text', 'Successor market to: TEST.24h')
|
||||
.find('a')
|
||||
.should('have.attr', 'href')
|
||||
.and('contain', this.parentMarketId);
|
||||
cy.getByTestId('view-proposal-btn').click();
|
||||
});
|
||||
// #3003-PMAN-010
|
||||
cy.getByTestId(proposalJsonToggle).click();
|
||||
cy.get('.language-json').within(() => {
|
||||
cy.get('.hljs-attr').should('contain.text', 'parentMarketId');
|
||||
cy.get('.hljs-string').should('contain.text', this.parentMarketId);
|
||||
cy.get('.hljs-attr').should('contain.text', 'insurancePoolFraction');
|
||||
cy.get('.hljs-string').should('contain.text', '0.75');
|
||||
});
|
||||
cy.getByTestId('proposal-market-data').within(() => {
|
||||
cy.getByTestId('proposal-market-data-toggle').click();
|
||||
cy.contains('Key details').click();
|
||||
// 3003-PMAN-009
|
||||
getMarketProposalDetailsFromTable('Parent Market ID').should(
|
||||
'have.text',
|
||||
this.parentMarketId
|
||||
);
|
||||
getMarketProposalDetailsFromTable('Insurance Pool Fraction').should(
|
||||
'have.text',
|
||||
'0.75'
|
||||
);
|
||||
getMarketProposalDetailsFromTable('Trading Mode').should(
|
||||
'have.text',
|
||||
'No trading'
|
||||
);
|
||||
});
|
||||
// 3003-PMAN-011
|
||||
cy.contains('Parent Market ID').realHover();
|
||||
cy.getByTestId('tooltip-content').should(
|
||||
'contain.text',
|
||||
'The ID of the market this market succeeds.'
|
||||
);
|
||||
cy.contains('Insurance Pool Fraction').realHover();
|
||||
cy.getByTestId('tooltip-content').should(
|
||||
'contain.text',
|
||||
'The fraction of the insurance pool balance that is carried over from the parent market to the successor.'
|
||||
);
|
||||
});
|
||||
|
||||
after('Disassociate from second wallet key if present', function () {
|
||||
cy.reload();
|
||||
waitForSpinner();
|
||||
|
||||
@@ -96,14 +96,12 @@ context('rewards - flow', { tags: '@slow' }, function () {
|
||||
.within(() => {
|
||||
cy.get('h2').first().should('contain.text', 'EPOCH');
|
||||
cy.getByTestId('individual-rewards-asset').should('have.text', 'Vega');
|
||||
cy.getByTestId('ACCOUNT_TYPE_GLOBAL_REWARD', rewardsTimeOut).should(
|
||||
'contain.text',
|
||||
'0.4415'
|
||||
);
|
||||
cy.getByTestId('ACCOUNT_TYPE_FEES_INFRASTRUCTURE').should(
|
||||
'contain.text',
|
||||
'0.0004'
|
||||
);
|
||||
cy.getByTestId('ACCOUNT_TYPE_GLOBAL_REWARD', rewardsTimeOut)
|
||||
.should('contain.text', '0.4415')
|
||||
.and('contain.text', '(44.15%)');
|
||||
cy.getByTestId('ACCOUNT_TYPE_FEES_INFRASTRUCTURE')
|
||||
.should('contain.text', '0.0004')
|
||||
.and('contain.text', '(44.15%)');
|
||||
cy.getByTestId('total').should('have.text', '0.4419');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -339,7 +339,7 @@ context(
|
||||
cy.getByTestId(vegaWalletCurrencyTitle)
|
||||
.contains(name)
|
||||
.parent()
|
||||
.siblings(txTimeout)
|
||||
.siblings()
|
||||
.should((elementAmount) => {
|
||||
const displayedAmount = parseFloat(elementAmount.text());
|
||||
expect(displayedAmount).be.gte(expectedAmount);
|
||||
|
||||
@@ -107,7 +107,7 @@ export function dissociateFromSecondWalletKey() {
|
||||
cy.getByTestId('vega-in-wallet')
|
||||
.first()
|
||||
.within(() => {
|
||||
cy.getByTestId('eth-wallet-associated-balances', txTimeout)
|
||||
cy.getByTestId('eth-wallet-associated-balances')
|
||||
.last()
|
||||
.within(() => {
|
||||
cy.getByTestId('associated-key')
|
||||
|
||||
@@ -78,21 +78,13 @@ export function stakingPageAssociateTokens(
|
||||
}
|
||||
cy.get(tokenAmountInputBox, epochTimeout).type(amount);
|
||||
if (approve) {
|
||||
cy.getByTestId('wallet-associate').then((walletAssociateField) => {
|
||||
if (
|
||||
walletAssociateField.find('[data-testid="token-input-approve-button"]')
|
||||
.length
|
||||
) {
|
||||
cy.get(tokenInputApprove, txTimeout).should('be.enabled').click();
|
||||
cy.contains('Approve $VEGA Tokens for staking on Vega').should(
|
||||
'be.visible'
|
||||
);
|
||||
cy.contains(
|
||||
'Approve $VEGA Tokens for staking on Vega',
|
||||
txTimeout
|
||||
).should('not.exist');
|
||||
}
|
||||
});
|
||||
cy.get(tokenInputApprove, txTimeout).should('be.enabled').click();
|
||||
cy.contains('Approve $VEGA Tokens for staking on Vega').should(
|
||||
'be.visible'
|
||||
);
|
||||
cy.contains('Approve $VEGA Tokens for staking on Vega', txTimeout).should(
|
||||
'not.exist'
|
||||
);
|
||||
}
|
||||
cy.get(tokenSubmitButton, txTimeout).should('be.enabled').click();
|
||||
|
||||
|
||||
@@ -488,19 +488,7 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
</InputError>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex gap-2 pb-2 justify-end">
|
||||
<Checkbox
|
||||
name="reduce-only"
|
||||
checked={true}
|
||||
disabled={true}
|
||||
label={
|
||||
<Tooltip description={<span>{t(REDUCE_ONLY_TOOLTIP)}</span>}>
|
||||
<span className="text-xs">{t('Reduce only')}</span>
|
||||
</Tooltip>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="mb-2">
|
||||
<div className="flex gap-2 pb-2 justify-between">
|
||||
<Controller
|
||||
name="expire"
|
||||
control={control}
|
||||
@@ -511,11 +499,21 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
onCheckedChange={onCheckedChange}
|
||||
checked={value}
|
||||
name="expire"
|
||||
label={'Expire'}
|
||||
label={<span className="text-xs">{t('Expire')}</span>}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<Checkbox
|
||||
name="reduce-only"
|
||||
checked={true}
|
||||
disabled={true}
|
||||
label={
|
||||
<Tooltip description={<span>{t(REDUCE_ONLY_TOOLTIP)}</span>}>
|
||||
<span className="text-xs">{t('Reduce only')}</span>
|
||||
</Tooltip>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{expire && (
|
||||
<>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from './order-actions-dropdown';
|
||||
@@ -0,0 +1,13 @@
|
||||
import {
|
||||
ActionsDropdown,
|
||||
TradingDropdownCopyItem,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
|
||||
export const OrderActionsDropdown = ({ id }: { id: string }) => {
|
||||
return (
|
||||
<ActionsDropdown data-testid="order-actions-content">
|
||||
<TradingDropdownCopyItem value={id} text={t('Copy order ID')} />
|
||||
</ActionsDropdown>
|
||||
);
|
||||
};
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
import type { OrderTxUpdateFieldsFragment } from '@vegaprotocol/wallet';
|
||||
import { OrderEditDialog } from '../order-list/order-edit-dialog';
|
||||
import type { Order } from '../order-data-provider';
|
||||
import { OrderViewDialog } from '../order-list/order-view-dialog';
|
||||
|
||||
export enum Filter {
|
||||
'Open' = 'Open',
|
||||
@@ -43,7 +42,6 @@ export const OrderListManager = ({
|
||||
}: OrderListManagerProps) => {
|
||||
const gridRef = useRef<AgGridReact | null>(null);
|
||||
const [editOrder, setEditOrder] = useState<Order | null>(null);
|
||||
const [viewOrder, setViewOrder] = useState<Order | null>(null);
|
||||
const create = useVegaTransactionStore((state) => state.create);
|
||||
const hasAmendableOrder = useHasAmendableOrder(marketId);
|
||||
const variables =
|
||||
@@ -91,7 +89,6 @@ export const OrderListManager = ({
|
||||
filter={filter}
|
||||
onCancel={cancel}
|
||||
onEdit={setEditOrder}
|
||||
onView={setViewOrder}
|
||||
onMarketClick={onMarketClick}
|
||||
onOrderTypeClick={onOrderTypeClick}
|
||||
isReadOnly={isReadOnly}
|
||||
@@ -137,14 +134,6 @@ export const OrderListManager = ({
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{viewOrder && (
|
||||
<OrderViewDialog
|
||||
isOpen={Boolean(viewOrder)}
|
||||
order={viewOrder}
|
||||
onChange={() => setViewOrder(null)}
|
||||
onMarketClick={onMarketClick}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -27,7 +27,6 @@ const defaultProps: OrderListTableProps = {
|
||||
rowData: [],
|
||||
onEdit: jest.fn(),
|
||||
onCancel: jest.fn(),
|
||||
onView: jest.fn(),
|
||||
isReadOnly: false,
|
||||
};
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@ const Template: Story = (args) => {
|
||||
onEdit={() => {
|
||||
return;
|
||||
}}
|
||||
onView={() => {
|
||||
return;
|
||||
}}
|
||||
isReadOnly={false}
|
||||
/>
|
||||
</div>
|
||||
@@ -52,9 +49,6 @@ const Template2: Story = (args) => {
|
||||
rowData={args.data}
|
||||
onCancel={cancel}
|
||||
onEdit={setEditOrder}
|
||||
onView={() => {
|
||||
return;
|
||||
}}
|
||||
isReadOnly={false}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -6,14 +6,7 @@ import {
|
||||
} from '@vegaprotocol/utils';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import * as Schema from '@vegaprotocol/types';
|
||||
import {
|
||||
ActionsDropdown,
|
||||
ButtonLink,
|
||||
TradingDropdownCopyItem,
|
||||
DropdownMenuItem,
|
||||
VegaIcon,
|
||||
VegaIconNames,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { ButtonLink } from '@vegaprotocol/ui-toolkit';
|
||||
import type { ForwardedRef } from 'react';
|
||||
import { memo, forwardRef, useMemo } from 'react';
|
||||
import {
|
||||
@@ -34,6 +27,7 @@ import type {
|
||||
} from '@vegaprotocol/datagrid';
|
||||
import type { AgGridReact } from 'ag-grid-react';
|
||||
import type { Order } from '../order-data-provider';
|
||||
import { OrderActionsDropdown } from '../order-actions-dropdown';
|
||||
import { Filter } from '../order-list-manager';
|
||||
import type { ColDef } from 'ag-grid-community';
|
||||
|
||||
@@ -41,7 +35,6 @@ export type OrderListTableProps = TypedDataAgGrid<Order> & {
|
||||
marketId?: string;
|
||||
onCancel: (order: Order) => void;
|
||||
onEdit: (order: Order) => void;
|
||||
onView: (order: Order) => void;
|
||||
onMarketClick?: (marketId: string, metaKey?: boolean) => void;
|
||||
onOrderTypeClick?: (marketId: string, metaKey?: boolean) => void;
|
||||
filter?: Filter;
|
||||
@@ -53,15 +46,7 @@ export const OrderListTable = memo<
|
||||
>(
|
||||
forwardRef<AgGridReact, OrderListTableProps>(
|
||||
(
|
||||
{
|
||||
onCancel,
|
||||
onEdit,
|
||||
onView,
|
||||
onMarketClick,
|
||||
onOrderTypeClick,
|
||||
filter,
|
||||
...props
|
||||
},
|
||||
{ onCancel, onEdit, onMarketClick, onOrderTypeClick, filter, ...props },
|
||||
ref
|
||||
) => {
|
||||
const showAllActions = props.isReadOnly
|
||||
@@ -310,20 +295,7 @@ export const OrderListTable = memo<
|
||||
</ButtonLink>
|
||||
</>
|
||||
)}
|
||||
<ActionsDropdown data-testid="market-actions-content">
|
||||
<TradingDropdownCopyItem
|
||||
value={data.id}
|
||||
text={t('Copy order ID')}
|
||||
/>
|
||||
<DropdownMenuItem
|
||||
key={'view-order'}
|
||||
data-testid="view-order"
|
||||
onClick={() => onView(data)}
|
||||
>
|
||||
<VegaIcon name={VegaIconNames.INFO} size={16} />
|
||||
{t('View order details')}
|
||||
</DropdownMenuItem>
|
||||
</ActionsDropdown>
|
||||
<OrderActionsDropdown id={data?.id} />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
@@ -333,7 +305,6 @@ export const OrderListTable = memo<
|
||||
filter,
|
||||
onCancel,
|
||||
onEdit,
|
||||
onView,
|
||||
onMarketClick,
|
||||
onOrderTypeClick,
|
||||
props.isReadOnly,
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { OrderViewDialog } from './order-view-dialog';
|
||||
import type { Order } from '../order-data-provider';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import {
|
||||
MarketState,
|
||||
MarketTradingMode,
|
||||
OrderStatus,
|
||||
OrderTimeInForce,
|
||||
OrderType,
|
||||
Side,
|
||||
} from '@vegaprotocol/types';
|
||||
|
||||
describe('OrderViewDialog', () => {
|
||||
it('should render the order view dialog if the order is provided', async () => {
|
||||
const order: Order = {
|
||||
id: '7f2a78f370062e41683d26a0fcc4521b2bd4b747530b78bc6bc86195db0e5fb3',
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: 'b66cd4be223dfd900a4750bb5175e17d8f678996877d262be4c749a99e22a970',
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 3,
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS,
|
||||
fees: {
|
||||
__typename: 'Fees',
|
||||
factors: {
|
||||
__typename: 'FeeFactors',
|
||||
makerFee: '0.0002',
|
||||
infrastructureFee: '0.0005',
|
||||
liquidityFee: '0.001',
|
||||
},
|
||||
},
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
__typename: 'Instrument',
|
||||
id: '',
|
||||
name: 'Tesla Quarterly (Sep 2023)',
|
||||
code: 'TSLA.QM21',
|
||||
metadata: {
|
||||
__typename: 'InstrumentMetadata',
|
||||
tags: [
|
||||
'formerly:5A86B190C384997F',
|
||||
'quote:EURO',
|
||||
'ticker:TSLA',
|
||||
'class:equities/single-stock-futures',
|
||||
'sector:tech',
|
||||
'listing_venue:NASDAQ',
|
||||
'country:US',
|
||||
'auto:tsla',
|
||||
],
|
||||
},
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
__typename: 'Asset',
|
||||
id: '177e8f6c25a955bd18475084b99b2b1d37f28f3dec393fab7755a7e69c3d8c3b',
|
||||
symbol: 'tEURO',
|
||||
name: 'tEURO Fairground',
|
||||
decimals: 5,
|
||||
quantum: '1',
|
||||
},
|
||||
quoteName: 'EURO',
|
||||
dataSourceSpecForTradingTermination: {
|
||||
__typename: 'DataSourceSpec',
|
||||
id: '3f5941ba047dabb3bec23f112db0a8cc8aecbbbc6b34d1366d9383ed1b0f39df',
|
||||
data: {
|
||||
__typename: 'DataSourceDefinition',
|
||||
sourceType: {
|
||||
__typename: 'DataSourceDefinitionExternal',
|
||||
sourceType: {
|
||||
__typename: 'DataSourceSpecConfiguration',
|
||||
signers: [
|
||||
{
|
||||
__typename: 'Signer',
|
||||
signer: {
|
||||
__typename: 'PubKey',
|
||||
key: '69464e35bcb8e8a2900ca0f87acaf252d50cf2ab2fc73694845a16b7c8a0dc6f',
|
||||
},
|
||||
},
|
||||
],
|
||||
filters: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
dataSourceSpecForSettlementData: {
|
||||
__typename: 'DataSourceSpec',
|
||||
id: '05ca5485678aa7c705aa6a683fd062714cbcfdac2d1a27641cd27b66168d9c1d',
|
||||
data: {
|
||||
__typename: 'DataSourceDefinition',
|
||||
sourceType: {
|
||||
__typename: 'DataSourceDefinitionExternal',
|
||||
sourceType: {
|
||||
__typename: 'DataSourceSpecConfiguration',
|
||||
signers: [
|
||||
{
|
||||
__typename: 'Signer',
|
||||
signer: {
|
||||
__typename: 'PubKey',
|
||||
key: '69464e35bcb8e8a2900ca0f87acaf252d50cf2ab2fc73694845a16b7c8a0dc6f',
|
||||
},
|
||||
},
|
||||
],
|
||||
filters: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
dataSourceSpecBinding: {
|
||||
__typename: 'DataSourceSpecToFutureBinding',
|
||||
settlementDataProperty: 'prices.TSLA.value',
|
||||
tradingTerminationProperty: 'termination.TSLA.value',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
open: '2023-07-19T12:05:25.822854221Z',
|
||||
close: null,
|
||||
},
|
||||
},
|
||||
type: OrderType.TYPE_LIMIT,
|
||||
side: Side.SIDE_BUY,
|
||||
size: '10000',
|
||||
status: OrderStatus.STATUS_ACTIVE,
|
||||
rejectionReason: null,
|
||||
price: '15000000',
|
||||
timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTT,
|
||||
remaining: '5000',
|
||||
expiresAt: null,
|
||||
createdAt: '2023-08-01T14:47:34.977742Z',
|
||||
updatedAt: null,
|
||||
postOnly: false,
|
||||
reduceOnly: false,
|
||||
liquidityProvision: null,
|
||||
peggedOrder: null,
|
||||
icebergOrder: {
|
||||
__typename: 'IcebergOrder',
|
||||
peakSize: '5000',
|
||||
minimumVisibleSize: '2000',
|
||||
reservedRemaining: '5000',
|
||||
},
|
||||
__typename: 'Order',
|
||||
};
|
||||
|
||||
render(
|
||||
<BrowserRouter>
|
||||
<OrderViewDialog order={order} onChange={jest.fn()} isOpen={true} />
|
||||
</BrowserRouter>
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('order-market-label')).toHaveTextContent(
|
||||
'Market'
|
||||
);
|
||||
expect(screen.getByTestId('order-market-value')).toHaveTextContent(
|
||||
'Tesla Quarterly (Sep 2023)'
|
||||
);
|
||||
expect(screen.getByTestId('order-type-label')).toHaveTextContent('Type');
|
||||
expect(screen.getByTestId('order-type-value')).toHaveTextContent('Limit');
|
||||
expect(screen.getByTestId('order-price-label')).toHaveTextContent('Price');
|
||||
expect(screen.getByTestId('order-price-value')).toHaveTextContent('150.00');
|
||||
expect(screen.getByTestId('order-size-label')).toHaveTextContent('Size');
|
||||
expect(screen.getByTestId('order-size-value')).toHaveTextContent('+10.00');
|
||||
expect(screen.getByTestId('order-remaining-label')).toHaveTextContent(
|
||||
'Remaining'
|
||||
);
|
||||
expect(screen.getByTestId('order-remaining-value')).toHaveTextContent(
|
||||
'+5.00'
|
||||
);
|
||||
expect(
|
||||
screen.getByTestId('order-iceberg-order-reserved-remaining-value')
|
||||
).toHaveTextContent('5.00');
|
||||
});
|
||||
});
|
||||
@@ -1,280 +0,0 @@
|
||||
import {
|
||||
addDecimalsFormatNumber,
|
||||
getDateTimeFormat,
|
||||
} from '@vegaprotocol/utils';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { Size } from '@vegaprotocol/datagrid';
|
||||
import * as Schema from '@vegaprotocol/types';
|
||||
import {
|
||||
ButtonLink,
|
||||
Dialog,
|
||||
KeyValueTable,
|
||||
KeyValueTableRow,
|
||||
Tooltip,
|
||||
VegaIcon,
|
||||
VegaIconNames,
|
||||
truncateMiddle,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import type { Order } from '../order-data-provider';
|
||||
import CopyToClipboard from 'react-copy-to-clipboard';
|
||||
import { useCopyTimeout } from '@vegaprotocol/react-helpers';
|
||||
|
||||
interface OrderViewDialogProps {
|
||||
isOpen: boolean;
|
||||
order: Order;
|
||||
onChange: (open: boolean) => void;
|
||||
onMarketClick?: (marketId: string, metaKey?: boolean) => void;
|
||||
}
|
||||
|
||||
export const OrderViewDialog = ({
|
||||
isOpen,
|
||||
order,
|
||||
onChange,
|
||||
onMarketClick,
|
||||
}: OrderViewDialogProps) => {
|
||||
const [, setCopied] = useCopyTimeout();
|
||||
return (
|
||||
<Dialog open={isOpen} title={t('Order details')} onChange={onChange}>
|
||||
<KeyValueTable>
|
||||
<KeyValueTableRow key={'order-market'}>
|
||||
<div data-testid={'order-market-label'}>{t('Market')}</div>
|
||||
<div data-testid={`order-market-value`}>
|
||||
{onMarketClick ? (
|
||||
<ButtonLink
|
||||
onClick={() => order.market && onMarketClick(order.market?.id)}
|
||||
>
|
||||
{order.market?.tradableInstrument.instrument.name}
|
||||
</ButtonLink>
|
||||
) : (
|
||||
order.market?.tradableInstrument.instrument.name
|
||||
)}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
<KeyValueTableRow key={'order-type'}>
|
||||
<div data-testid={'order-type-label'}>{t('Type')}</div>
|
||||
<div data-testid={`order-type-value`}>
|
||||
{Schema.OrderTypeMapping[order.type as Schema.OrderType]}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
{order.market && (
|
||||
<KeyValueTableRow key={'order-price'}>
|
||||
<div data-testid={'order-price-label'}>{t('Price')}</div>
|
||||
<div data-testid={`order-price-value`}>
|
||||
{addDecimalsFormatNumber(
|
||||
order.price,
|
||||
order.market.decimalPlaces as number
|
||||
)}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
)}
|
||||
{order.market && (
|
||||
<KeyValueTableRow key={'order-size'}>
|
||||
<div data-testid={'order-size-label'}>{t('Size')}</div>
|
||||
<div data-testid={`order-size-value`}>
|
||||
<Size
|
||||
value={order.size}
|
||||
side={order.side}
|
||||
positionDecimalPlaces={
|
||||
order.market.positionDecimalPlaces as number
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
)}
|
||||
{order.market && (
|
||||
<KeyValueTableRow key={'order-remaining'} className="mb-4">
|
||||
<div data-testid={'order-remaining-label'}>{t('Remaining')}</div>
|
||||
<div data-testid={`order-remaining-value`}>
|
||||
<Size
|
||||
value={order.remaining}
|
||||
side={order.side}
|
||||
positionDecimalPlaces={
|
||||
order.market.positionDecimalPlaces as number
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
)}
|
||||
<KeyValueTableRow key={'order-status'}>
|
||||
<div data-testid={'order-status-label'}>{t('Status')}</div>
|
||||
<div data-testid={`order-status-value`}>
|
||||
{Schema.OrderStatusMapping[order.status as Schema.OrderStatus]}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
{order.rejectionReason && (
|
||||
<KeyValueTableRow key={'order-rejection-reason'}>
|
||||
<div data-testid={'order-rejection-reason-label'}>
|
||||
{t('rejection reason')}
|
||||
</div>
|
||||
<div data-testid={`order-rejection-reason-value`}>
|
||||
{
|
||||
Schema.OrderRejectionReasonMapping[
|
||||
order.rejectionReason as Schema.OrderRejectionReason
|
||||
]
|
||||
}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
)}
|
||||
<KeyValueTableRow key={'order-id'}>
|
||||
<div data-testid={'order-id-label'}>{t('Order ID')}</div>
|
||||
<div data-testid={`order-id-value`}>
|
||||
{truncateMiddle(order.id, 10)}
|
||||
<CopyToClipboard text={order.id} onCopy={() => setCopied(true)}>
|
||||
<button
|
||||
type="button"
|
||||
data-testid="copy-order-id"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<span className="sr-only">{t('Copy')}</span>
|
||||
<VegaIcon name={VegaIconNames.COPY} />
|
||||
</button>
|
||||
</CopyToClipboard>
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
<KeyValueTableRow key={'order-created'}>
|
||||
<div data-testid={'order-created-label'}>{t('Created')}</div>
|
||||
<div data-testid={`order-created-value`}>
|
||||
{getDateTimeFormat().format(new Date(order.createdAt))}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
{order.updatedAt && (
|
||||
<KeyValueTableRow key={'order-updated'}>
|
||||
<div data-testid={'order-updated-label'}>{t('Updated')}</div>
|
||||
<div data-testid={`order-updated-value`}>
|
||||
{getDateTimeFormat().format(new Date(order.updatedAt))}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
)}
|
||||
{order.expiresAt && (
|
||||
<KeyValueTableRow key={'order-expires'}>
|
||||
<div data-testid={'order-expires-label'}>{t('Expires')}</div>
|
||||
<div data-testid={`order-expires-value`}>
|
||||
{getDateTimeFormat().format(new Date(order.expiresAt))}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
)}
|
||||
|
||||
<KeyValueTableRow key={'order-time-in-force'} className="mt-4">
|
||||
<div data-testid={'order-time-in-force-label'}>
|
||||
{t('Time in force')}
|
||||
</div>
|
||||
<div data-testid={`order-time-in-force-value`}>
|
||||
{
|
||||
Schema.OrderTimeInForceMapping[
|
||||
order.timeInForce as Schema.OrderTimeInForce
|
||||
]
|
||||
}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
|
||||
<KeyValueTableRow key={'order-post-only'}>
|
||||
<div data-testid={'order-post-only-label'}>{t('Post only')}</div>
|
||||
<div data-testid={`order-post-only-value`}>
|
||||
{order.postOnly ? t('Yes') : t('-')}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
|
||||
<KeyValueTableRow key={'order-reduce-only'}>
|
||||
<div data-testid={'order-reduce-only-label'}>{t('Reduce only')}</div>
|
||||
<div data-testid={`order-reduce-only-value`}>
|
||||
{order.reduceOnly ? t('Yes') : t('-')}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
|
||||
<KeyValueTableRow key={'order-pegged'}>
|
||||
<div data-testid={'order-pegged-label'}>{t('Pegged')}</div>
|
||||
<div data-testid={`order-pegged-value`}>
|
||||
{order.peggedOrder ? t('Yes') : t('-')}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
|
||||
<KeyValueTableRow key={'order-liquidity-provision'}>
|
||||
<div data-testid={'order-liquidity-provision-label'}>
|
||||
{t('Liquidity provision')}
|
||||
</div>
|
||||
<div data-testid={`order-liquidity-provision-value`}>
|
||||
{order.liquidityProvision ? t('Yes') : t('-')}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
</KeyValueTable>
|
||||
|
||||
<KeyValueTableRow key={'order-iceberg-order'}>
|
||||
<div data-testid={'order-iceberg-order-label'}>
|
||||
{t('Iceberg order')}
|
||||
</div>
|
||||
<div data-testid={`order-iceberg-order-value`}>
|
||||
{order.icebergOrder ? t('Yes') : t('-')}
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
{order.icebergOrder && (
|
||||
<KeyValueTableRow
|
||||
key={'order-iceberg-order-peak-size'}
|
||||
className="ml-4"
|
||||
>
|
||||
<div data-testid={'order-iceberg-order-peak-size-label'}>
|
||||
<Tooltip
|
||||
description={t(
|
||||
'The maximum volume that can be traded at once. Must be less than the total size of the order.'
|
||||
)}
|
||||
>
|
||||
<span>{t('Peak size')}</span>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div data-testid={`order-iceberg-order-peak-size-value`}>
|
||||
<Size
|
||||
value={order.icebergOrder.peakSize}
|
||||
side={order.side}
|
||||
positionDecimalPlaces={
|
||||
order.market?.positionDecimalPlaces as number
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
)}
|
||||
{order.icebergOrder && (
|
||||
<KeyValueTableRow
|
||||
key={'order-iceberg-order-minimum-visible-size'}
|
||||
className="ml-4"
|
||||
>
|
||||
<div data-testid={'order-iceberg-order-minimum-visible-size-label'}>
|
||||
<Tooltip
|
||||
description={t(
|
||||
'When the order trades and its size falls below this threshold, it will be reset to the peak size and moved to the back of the priority order. Must be less than or equal to peak size, and greater than 0.'
|
||||
)}
|
||||
>
|
||||
<span>{t('Minimum size')}</span>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div data-testid={`order-iceberg-order-minimum-visible-size-value`}>
|
||||
<Size
|
||||
value={order.icebergOrder.minimumVisibleSize}
|
||||
side={order.side}
|
||||
positionDecimalPlaces={
|
||||
order.market?.positionDecimalPlaces as number
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
)}
|
||||
{order.icebergOrder && (
|
||||
<KeyValueTableRow
|
||||
key={'order-iceberg-order-reserved-remaining'}
|
||||
className="ml-4"
|
||||
>
|
||||
<div data-testid={'order-iceberg-order-reserved-remaining-label'}>
|
||||
{t('Reserved remaining')}
|
||||
</div>
|
||||
<div data-testid={`order-iceberg-order-reserved-remaining-value`}>
|
||||
<Size
|
||||
value={order.icebergOrder.reservedRemaining}
|
||||
side={order.side}
|
||||
positionDecimalPlaces={
|
||||
order.market?.positionDecimalPlaces as number
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</KeyValueTableRow>
|
||||
)}
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user