Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bb64e5383 |
@@ -14,6 +14,8 @@ on:
|
||||
- synchronize
|
||||
jobs:
|
||||
node-modules:
|
||||
# All jobs depend on node_modules, so none should run if the PR is in draft
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-22.04
|
||||
name: 'Cache yarn modules'
|
||||
steps:
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
github-sha:
|
||||
required: false
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
@@ -109,7 +109,7 @@ jobs:
|
||||
#----------------------------------------------
|
||||
- name: Run tests
|
||||
working-directory: ./console-test
|
||||
run: poetry run pytest -v -s
|
||||
run: poetry run pytest -v -s --numprocesses 2 --dist loadfile --durations=20
|
||||
- name: Check files
|
||||
run: |
|
||||
ls -al .
|
||||
|
||||
@@ -26,6 +26,7 @@ function getSuccessorTxBody(parentMarketId) {
|
||||
positionDecimalPlaces: '5',
|
||||
linearSlippageFactor: '0.001',
|
||||
quadraticSlippageFactor: '0',
|
||||
lpPriceRange: '10',
|
||||
instrument: {
|
||||
name: 'Token test market',
|
||||
code: 'TEST.24h',
|
||||
|
||||
@@ -13,12 +13,6 @@ query ExplorerMarket($id: ID!) {
|
||||
decimals
|
||||
}
|
||||
}
|
||||
... on Perpetual {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
decimals
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-7
@@ -8,7 +8,7 @@ export type ExplorerMarketQueryVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type ExplorerMarketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', decimals: number } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', decimals: number } } | { __typename?: 'Spot' } } } } | null };
|
||||
export type ExplorerMarketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', decimals: number } } } } } | null };
|
||||
|
||||
|
||||
export const ExplorerMarketDocument = gql`
|
||||
@@ -27,12 +27,6 @@ export const ExplorerMarketDocument = gql`
|
||||
decimals
|
||||
}
|
||||
}
|
||||
... on Perpetual {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
decimals
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ describe('Market link component', () => {
|
||||
instrument: {
|
||||
name: 'test-label',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
quoteName: 'dai',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,14 +3,13 @@ import type { MarketInfoWithData } from '@vegaprotocol/markets';
|
||||
import {
|
||||
PriceMonitoringBoundsInfoPanel,
|
||||
SuccessionLineInfoPanel,
|
||||
getDataSourceSpecForSettlementData,
|
||||
getDataSourceSpecForTradingTermination,
|
||||
} from '@vegaprotocol/markets';
|
||||
import {
|
||||
LiquidityInfoPanel,
|
||||
LiquidityMonitoringParametersInfoPanel,
|
||||
InstrumentInfoPanel,
|
||||
KeyDetailsInfoPanel,
|
||||
LiquidityPriceRangeInfoPanel,
|
||||
MetadataInfoPanel,
|
||||
OracleInfoPanel,
|
||||
RiskFactorsInfoPanel,
|
||||
@@ -19,21 +18,20 @@ import {
|
||||
SettlementAssetInfoPanel,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { MarketInfoTable } from '@vegaprotocol/markets';
|
||||
import type { DataSourceFragment } from '@vegaprotocol/markets';
|
||||
import type { DataSourceDefinition } from '@vegaprotocol/types';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
|
||||
export const MarketDetails = ({ market }: { market: MarketInfoWithData }) => {
|
||||
if (!market) return null;
|
||||
const { product } = market.tradableInstrument.instrument;
|
||||
const settlementDataSource = getDataSourceSpecForSettlementData(product);
|
||||
const terminationDataSource = getDataSourceSpecForTradingTermination(product);
|
||||
|
||||
const getSigners = ({ data }: DataSourceFragment) => {
|
||||
const settlementData = market.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.data as DataSourceDefinition;
|
||||
const terminationData = market.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForTradingTermination.data as DataSourceDefinition;
|
||||
|
||||
const getSigners = (data: DataSourceDefinition) => {
|
||||
if (data.sourceType.__typename === 'DataSourceDefinitionExternal') {
|
||||
const signers =
|
||||
('signers' in data.sourceType.sourceType &&
|
||||
data.sourceType.sourceType.signers) ||
|
||||
[];
|
||||
const signers = data.sourceType.sourceType.signers || [];
|
||||
|
||||
return signers.map(({ signer }, i) => {
|
||||
return (
|
||||
@@ -45,13 +43,10 @@ export const MarketDetails = ({ market }: { market: MarketInfoWithData }) => {
|
||||
return [];
|
||||
};
|
||||
|
||||
const showTwoOracles =
|
||||
settlementDataSource &&
|
||||
terminationDataSource &&
|
||||
isEqual(
|
||||
getSigners(settlementDataSource),
|
||||
getSigners(terminationDataSource)
|
||||
);
|
||||
const showTwoOracles = isEqual(
|
||||
getSigners(settlementData),
|
||||
getSigners(terminationData)
|
||||
);
|
||||
|
||||
const headerClassName = 'font-alpha calt text-xl mt-4 border-b-2 pb-2';
|
||||
|
||||
@@ -96,6 +91,8 @@ export const MarketDetails = ({ market }: { market: MarketInfoWithData }) => {
|
||||
<LiquidityMonitoringParametersInfoPanel market={market} />
|
||||
<h2 className={headerClassName}>{t('Liquidity')}</h2>
|
||||
<LiquidityInfoPanel market={market} />
|
||||
<h2 className={headerClassName}>{t('Liquidity price range')}</h2>
|
||||
<LiquidityPriceRangeInfoPanel market={market} />
|
||||
{showTwoOracles ? (
|
||||
<>
|
||||
<h2 className={headerClassName}>{t('Settlement oracle')}</h2>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import { getAsset, type MarketFieldsFragment } from '@vegaprotocol/markets';
|
||||
import type { MarketFieldsFragment } from '@vegaprotocol/markets';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { ButtonLink } from '@vegaprotocol/ui-toolkit';
|
||||
import type { AgGridReact } from 'ag-grid-react';
|
||||
@@ -73,7 +73,8 @@ export const MarketsTable = ({ data }: MarketsTableProps) => {
|
||||
MarketFieldsFragment,
|
||||
'tradableInstrument.instrument.product.settlementAsset.symbol'
|
||||
>) => {
|
||||
const value = data && getAsset(data);
|
||||
const value =
|
||||
data?.tradableInstrument.instrument.product.settlementAsset;
|
||||
return value ? (
|
||||
<ButtonLink
|
||||
onClick={(e) => {
|
||||
|
||||
@@ -31,9 +31,6 @@ fragment ExplorerDeterministicOrderFields on Order {
|
||||
... on Future {
|
||||
quoteName
|
||||
}
|
||||
... on Perpetual {
|
||||
quoteName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as Types from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type ExplorerDeterministicOrderFieldsFragment = { __typename?: 'Order', id: string, type?: Types.OrderType | null, reference: string, status: Types.OrderStatus, version: string, createdAt: any, updatedAt?: any | null, expiresAt?: any | null, timeInForce: Types.OrderTimeInForce, price: string, side: Types.Side, remaining: string, size: string, rejectionReason?: Types.OrderRejectionReason | null, peggedOrder?: { __typename?: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null, party: { __typename?: 'Party', id: string }, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, product: { __typename?: 'Future', quoteName: string } | { __typename?: 'Perpetual', quoteName: string } | { __typename?: 'Spot' } } } } };
|
||||
export type ExplorerDeterministicOrderFieldsFragment = { __typename?: 'Order', id: string, type?: Types.OrderType | null, reference: string, status: Types.OrderStatus, version: string, createdAt: any, updatedAt?: any | null, expiresAt?: any | null, timeInForce: Types.OrderTimeInForce, price: string, side: Types.Side, remaining: string, size: string, rejectionReason?: Types.OrderRejectionReason | null, peggedOrder?: { __typename?: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null, party: { __typename?: 'Party', id: string }, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, product: { __typename?: 'Future', quoteName: string } } } } };
|
||||
|
||||
export type ExplorerDeterministicOrderQueryVariables = Types.Exact<{
|
||||
orderId: Types.Scalars['ID'];
|
||||
@@ -11,7 +11,7 @@ export type ExplorerDeterministicOrderQueryVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type ExplorerDeterministicOrderQuery = { __typename?: 'Query', orderByID: { __typename?: 'Order', id: string, type?: Types.OrderType | null, reference: string, status: Types.OrderStatus, version: string, createdAt: any, updatedAt?: any | null, expiresAt?: any | null, timeInForce: Types.OrderTimeInForce, price: string, side: Types.Side, remaining: string, size: string, rejectionReason?: Types.OrderRejectionReason | null, peggedOrder?: { __typename?: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null, party: { __typename?: 'Party', id: string }, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, product: { __typename?: 'Future', quoteName: string } | { __typename?: 'Perpetual', quoteName: string } | { __typename?: 'Spot' } } } } } };
|
||||
export type ExplorerDeterministicOrderQuery = { __typename?: 'Query', orderByID: { __typename?: 'Order', id: string, type?: Types.OrderType | null, reference: string, status: Types.OrderStatus, version: string, createdAt: any, updatedAt?: any | null, expiresAt?: any | null, timeInForce: Types.OrderTimeInForce, price: string, side: Types.Side, remaining: string, size: string, rejectionReason?: Types.OrderRejectionReason | null, peggedOrder?: { __typename?: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null, party: { __typename?: 'Party', id: string }, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, product: { __typename?: 'Future', quoteName: string } } } } } };
|
||||
|
||||
export const ExplorerDeterministicOrderFieldsFragmentDoc = gql`
|
||||
fragment ExplorerDeterministicOrderFields on Order {
|
||||
@@ -47,9 +47,6 @@ export const ExplorerDeterministicOrderFieldsFragmentDoc = gql`
|
||||
... on Future {
|
||||
quoteName
|
||||
}
|
||||
... on Perpetual {
|
||||
quoteName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,6 @@ function renderExistingAmend(
|
||||
instrument: {
|
||||
name: 'test-label',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
quoteName: 'dai',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -33,8 +33,6 @@ const PriceInMarket = ({
|
||||
label = addDecimalsFormatNumber(price, data.market.decimalPlaces);
|
||||
} else if (
|
||||
decimalSource === 'SETTLEMENT_ASSET' &&
|
||||
data.market &&
|
||||
'settlementAsset' in data.market.tradableInstrument.instrument.product &&
|
||||
data.market?.tradableInstrument.instrument.product.settlementAsset
|
||||
) {
|
||||
label = addDecimalsFormatNumber(
|
||||
|
||||
@@ -11,14 +11,6 @@ fragment ExplorerOracleForMarketsMarket on Market {
|
||||
id
|
||||
}
|
||||
}
|
||||
... on Perpetual {
|
||||
dataSourceSpecForSettlementData {
|
||||
id
|
||||
}
|
||||
dataSourceSpecForSettlementSchedule {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,19 +5,19 @@ import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type ExplorerOracleDataConnectionFragment = { __typename?: 'OracleSpec', dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } };
|
||||
|
||||
export type ExplorerOracleDataSourceFragment = { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } };
|
||||
export type ExplorerOracleDataSourceFragment = { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } };
|
||||
|
||||
export type ExplorerOracleSpecsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type ExplorerOracleSpecsQuery = { __typename?: 'Query', oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } } | null> | null } | null };
|
||||
export type ExplorerOracleSpecsQuery = { __typename?: 'Query', oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } } | null> | null } | null };
|
||||
|
||||
export type ExplorerOracleSpecByIdQueryVariables = Types.Exact<{
|
||||
id: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type ExplorerOracleSpecByIdQuery = { __typename?: 'Query', oracleSpec?: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } | null };
|
||||
export type ExplorerOracleSpecByIdQuery = { __typename?: 'Query', oracleSpec?: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } | null };
|
||||
|
||||
export const ExplorerOracleDataConnectionFragmentDoc = gql`
|
||||
fragment ExplorerOracleDataConnection on OracleSpec {
|
||||
|
||||
@@ -3,12 +3,12 @@ import * as Types from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type ExplorerOracleForMarketsMarketFragment = { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', product: { __typename?: 'Future', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string } } | { __typename?: 'Perpetual', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string } } | { __typename?: 'Spot' } } } };
|
||||
export type ExplorerOracleForMarketsMarketFragment = { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', product: { __typename?: 'Future', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string } } } } };
|
||||
|
||||
export type ExplorerOracleFormMarketsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type ExplorerOracleFormMarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', product: { __typename?: 'Future', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string } } | { __typename?: 'Perpetual', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string } } | { __typename?: 'Spot' } } } } }> } | null };
|
||||
export type ExplorerOracleFormMarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', product: { __typename?: 'Future', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string } } } } } }> } | null };
|
||||
|
||||
export const ExplorerOracleForMarketsMarketFragmentDoc = gql`
|
||||
fragment ExplorerOracleForMarketsMarket on Market {
|
||||
@@ -24,14 +24,6 @@ export const ExplorerOracleForMarketsMarketFragmentDoc = gql`
|
||||
id
|
||||
}
|
||||
}
|
||||
... on Perpetual {
|
||||
dataSourceSpecForSettlementData {
|
||||
id
|
||||
}
|
||||
dataSourceSpecForSettlementSchedule {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ interface OracleMarketsProps {
|
||||
}
|
||||
|
||||
/**
|
||||
* Slightly misleading names, OracleMarkets lists the market (almost always singular)
|
||||
* Slightly misleadlingly names, OracleMarkets lists the market (almost always singular)
|
||||
* to which an oracle is attached. It also checks what it triggers, by checking on the
|
||||
* market whether it is attached to the dataSourceSpecForSettlementData or ..TradingTermination
|
||||
*/
|
||||
@@ -27,10 +27,8 @@ export function OracleMarkets({ id }: OracleMarketsProps) {
|
||||
const m = markets.find((m) => {
|
||||
const p = m.tradableInstrument.instrument.product;
|
||||
if (
|
||||
((p.__typename === 'Future' || p.__typename === 'Perpetual') &&
|
||||
p.dataSourceSpecForSettlementData.id === id) ||
|
||||
('dataSourceSpecForTradingTermination' in p &&
|
||||
p.dataSourceSpecForTradingTermination.id === id)
|
||||
p?.dataSourceSpecForSettlementData?.id === id ||
|
||||
p?.dataSourceSpecForTradingTermination?.id === id
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -63,32 +61,8 @@ export function getLabel(
|
||||
m: ExplorerOracleForMarketsMarketFragment | null
|
||||
): string {
|
||||
const settlementId =
|
||||
((m?.tradableInstrument?.instrument?.product?.__typename === 'Future' ||
|
||||
m?.tradableInstrument?.instrument?.product?.__typename === 'Perpetual') &&
|
||||
m?.tradableInstrument?.instrument?.product
|
||||
?.dataSourceSpecForSettlementData?.id) ||
|
||||
null;
|
||||
m?.tradableInstrument?.instrument?.product?.dataSourceSpecForSettlementData
|
||||
?.id || null;
|
||||
|
||||
const terminationId =
|
||||
(m?.tradableInstrument?.instrument?.product?.__typename === 'Future' &&
|
||||
m?.tradableInstrument?.instrument?.product
|
||||
?.dataSourceSpecForTradingTermination?.id) ||
|
||||
null;
|
||||
|
||||
const settlementScheduleId =
|
||||
(m?.tradableInstrument?.instrument?.product?.__typename === 'Perpetual' &&
|
||||
m?.tradableInstrument?.instrument?.product
|
||||
?.dataSourceSpecForSettlementSchedule?.id) ||
|
||||
null;
|
||||
|
||||
switch (id) {
|
||||
case settlementId:
|
||||
return 'Settlement for';
|
||||
case terminationId:
|
||||
return 'Termination for';
|
||||
case settlementScheduleId:
|
||||
return 'Settlement schedule for';
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
return id === settlementId ? 'Settlement for' : 'Termination for';
|
||||
}
|
||||
|
||||
@@ -67,9 +67,6 @@ export function OracleSigners({ sourceType }: OracleDetailsSignersProps) {
|
||||
if (sourceType.__typename !== 'DataSourceDefinitionExternal') {
|
||||
return null;
|
||||
}
|
||||
if (!('signers' in sourceType.sourceType)) {
|
||||
return null;
|
||||
}
|
||||
const signers = sourceType.sourceType.signers;
|
||||
|
||||
if (!signers || signers.length === 0) {
|
||||
|
||||
@@ -23,9 +23,6 @@ fragment ExplorerPartyAssetsAccounts on AccountBalance {
|
||||
... on Future {
|
||||
quoteName
|
||||
}
|
||||
... on Perpetual {
|
||||
quoteName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ import * as Types from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type ExplorerPartyAssetsAccountsFragment = { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', name: string, id: string, decimals: number, symbol: string, source: { __typename: 'BuiltinAsset' } | { __typename: 'ERC20', contractAddress: string } }, market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, product: { __typename?: 'Future', quoteName: string } | { __typename?: 'Perpetual', quoteName: string } | { __typename?: 'Spot' } } } } | null };
|
||||
export type ExplorerPartyAssetsAccountsFragment = { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', name: string, id: string, decimals: number, symbol: string, source: { __typename: 'BuiltinAsset' } | { __typename: 'ERC20', contractAddress: string } }, market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, product: { __typename?: 'Future', quoteName: string } } } } | null };
|
||||
|
||||
export type ExplorerPartyAssetsQueryVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type ExplorerPartyAssetsQuery = { __typename?: 'Query', partiesConnection?: { __typename?: 'PartyConnection', edges: Array<{ __typename?: 'PartyEdge', node: { __typename?: 'Party', id: string, delegationsConnection?: { __typename?: 'DelegationsConnection', edges?: Array<{ __typename?: 'DelegationEdge', node: { __typename?: 'Delegation', amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } } } | null> | null } | null, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string, linkings: { __typename?: 'StakesConnection', edges?: Array<{ __typename?: 'StakeLinkingEdge', node: { __typename?: 'StakeLinking', type: Types.StakeLinkingType, status: Types.StakeLinkingStatus, amount: string } } | null> | null } }, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', name: string, id: string, decimals: number, symbol: string, source: { __typename: 'BuiltinAsset' } | { __typename: 'ERC20', contractAddress: string } }, market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, product: { __typename?: 'Future', quoteName: string } | { __typename?: 'Perpetual', quoteName: string } | { __typename?: 'Spot' } } } } | null } } | null> | null } | null } }> } | null };
|
||||
export type ExplorerPartyAssetsQuery = { __typename?: 'Query', partiesConnection?: { __typename?: 'PartyConnection', edges: Array<{ __typename?: 'PartyEdge', node: { __typename?: 'Party', id: string, delegationsConnection?: { __typename?: 'DelegationsConnection', edges?: Array<{ __typename?: 'DelegationEdge', node: { __typename?: 'Delegation', amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } } } | null> | null } | null, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string, linkings: { __typename?: 'StakesConnection', edges?: Array<{ __typename?: 'StakeLinkingEdge', node: { __typename?: 'StakeLinking', type: Types.StakeLinkingType, status: Types.StakeLinkingStatus, amount: string } } | null> | null } }, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', name: string, id: string, decimals: number, symbol: string, source: { __typename: 'BuiltinAsset' } | { __typename: 'ERC20', contractAddress: string } }, market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, product: { __typename?: 'Future', quoteName: string } } } } | null } } | null> | null } | null } }> } | null };
|
||||
|
||||
export const ExplorerPartyAssetsAccountsFragmentDoc = gql`
|
||||
fragment ExplorerPartyAssetsAccounts on AccountBalance {
|
||||
@@ -38,9 +38,6 @@ export const ExplorerPartyAssetsAccountsFragmentDoc = gql`
|
||||
... on Future {
|
||||
quoteName
|
||||
}
|
||||
... on Perpetual {
|
||||
quoteName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -1453,6 +1453,11 @@ export interface components {
|
||||
readonly liquidityMonitoringParameters?: components['schemas']['vegaLiquidityMonitoringParameters'];
|
||||
/** @description Log normal risk model parameters, valid only if MODEL_LOG_NORMAL is selected. */
|
||||
readonly logNormal?: components['schemas']['vegaLogNormalRiskModel'];
|
||||
/**
|
||||
* @description Percentage move up and down from the mid price which specifies the range of
|
||||
* price levels over which automated liquidity provision orders will be deployed.
|
||||
*/
|
||||
readonly lpPriceRange?: string;
|
||||
/** @description Optional new futures market metadata, tags. */
|
||||
readonly metadata?: readonly string[];
|
||||
/**
|
||||
@@ -1848,6 +1853,11 @@ export interface components {
|
||||
readonly liquidityMonitoringParameters?: components['schemas']['vegaLiquidityMonitoringParameters'];
|
||||
/** @description Log normal risk model parameters, valid only if MODEL_LOG_NORMAL is selected. */
|
||||
readonly logNormal?: components['schemas']['vegaLogNormalRiskModel'];
|
||||
/**
|
||||
* @description Percentage move up and down from the mid price which specifies the range of
|
||||
* price levels over which automated liquidity provision orders will be deployed.
|
||||
*/
|
||||
readonly lpPriceRange?: string;
|
||||
/** @description Optional futures market metadata, tags. */
|
||||
readonly metadata?: readonly string[];
|
||||
/** @description Price monitoring parameters. */
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"positionDecimalPlaces": "5",
|
||||
"linearSlippageFactor": "0.001",
|
||||
"quadraticSlippageFactor": "0",
|
||||
"lpPriceRange": "10",
|
||||
"instrument": {
|
||||
"name": "Token test market",
|
||||
"code": "TEST.24h",
|
||||
@@ -103,12 +104,6 @@
|
||||
"r": 0.016,
|
||||
"sigma": 0.5
|
||||
}
|
||||
},
|
||||
"liquiditySlaParameters": {
|
||||
"priceRange": "0.95",
|
||||
"commitmentMinTimeFraction": "0.5",
|
||||
"performanceHysteresisEpochs": 2,
|
||||
"slaCompetitionFactor": "0.75"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"positionDecimalPlaces": "5",
|
||||
"linearSlippageFactor": "0.001",
|
||||
"quadraticSlippageFactor": "0",
|
||||
"lpPriceRange": "10",
|
||||
"instrument": {
|
||||
"name": "Token test market",
|
||||
"code": "Token.24h",
|
||||
@@ -97,12 +98,6 @@
|
||||
"r": 0.016,
|
||||
"sigma": 0.8
|
||||
}
|
||||
},
|
||||
"liquiditySlaParameters": {
|
||||
"priceRange": "0.95",
|
||||
"commitmentMinTimeFraction": "0.5",
|
||||
"performanceHysteresisEpochs": 2,
|
||||
"slaCompetitionFactor": "0.75"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"positionDecimalPlaces": "5",
|
||||
"linearSlippageFactor": "0.001",
|
||||
"quadraticSlippageFactor": "0",
|
||||
"lpPriceRange": "10",
|
||||
"instrument": {
|
||||
"name": "Token test market",
|
||||
"code": "Token.24h",
|
||||
@@ -98,12 +99,6 @@
|
||||
"sigma": 0.8
|
||||
}
|
||||
},
|
||||
"liquiditySlaParameters": {
|
||||
"priceRange": "0.95",
|
||||
"commitmentMinTimeFraction": "0.5",
|
||||
"performanceHysteresisEpochs": 2,
|
||||
"slaCompetitionFactor": "0.75"
|
||||
},
|
||||
"successor": {
|
||||
"parentMarketId": "",
|
||||
"insurancePoolFraction": "0.75"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"lpPriceRange": "11",
|
||||
"instrument": {
|
||||
"code": "Token.24h",
|
||||
"future": {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"lpPriceRange": "10",
|
||||
"linearSlippageFactor": "0.001",
|
||||
"quadraticSlippageFactor": "0",
|
||||
"instrument": {
|
||||
@@ -97,11 +98,5 @@
|
||||
"r": 0.016,
|
||||
"sigma": 0.3
|
||||
}
|
||||
},
|
||||
"liquiditySlaParameters": {
|
||||
"priceRange": "0.95",
|
||||
"commitmentMinTimeFraction": "0.5",
|
||||
"performanceHysteresisEpochs": 2,
|
||||
"slaCompetitionFactor": "0.75"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ const proposalType = 'proposal-type';
|
||||
const proposalDetails = 'proposal-details';
|
||||
const newProposalSubmitButton = 'proposal-submit';
|
||||
const proposalVoteDeadline = 'proposal-vote-deadline';
|
||||
const proposalEnactmentDeadline = 'proposal-enactment-deadline';
|
||||
const proposalParameterSelect = 'proposal-parameter-select';
|
||||
const proposalMarketSelect = 'proposal-market-select';
|
||||
const newProposalTitle = 'proposal-title';
|
||||
@@ -228,8 +227,6 @@ context(
|
||||
parseSpecialCharSequences: false,
|
||||
delay: 2,
|
||||
});
|
||||
cy.getByTestId(proposalVoteDeadline).clear().type('2');
|
||||
cy.getByTestId(proposalEnactmentDeadline).clear().type('3');
|
||||
});
|
||||
cy.getByTestId(proposalDownloadBtn)
|
||||
.should('be.visible')
|
||||
@@ -637,8 +634,6 @@ context(
|
||||
parseSpecialCharSequences: false,
|
||||
delay: 2,
|
||||
});
|
||||
cy.getByTestId(proposalVoteDeadline).clear().type('2');
|
||||
cy.getByTestId(proposalEnactmentDeadline).clear().type('3');
|
||||
});
|
||||
cy.getByTestId(proposalDownloadBtn)
|
||||
.should('be.visible')
|
||||
|
||||
@@ -105,13 +105,8 @@ export function createNewMarketProposalTxBody(): ProposalSubmissionBody {
|
||||
decimalPlaces: '5',
|
||||
positionDecimalPlaces: '5',
|
||||
linearSlippageFactor: '0.001',
|
||||
liquiditySlaParameters: {
|
||||
priceRange: '0.5',
|
||||
commitmentMinTimeFraction: '0.1',
|
||||
performanceHysteresisEpochs: 0,
|
||||
slaCompetitionFactor: '0.1',
|
||||
},
|
||||
quadraticSlippageFactor: '0',
|
||||
lpPriceRange: '10',
|
||||
instrument: {
|
||||
name: 'Token test market',
|
||||
code: 'TEST.24h',
|
||||
@@ -240,12 +235,7 @@ export function createSuccessorMarketProposalTxBody(
|
||||
positionDecimalPlaces: '5',
|
||||
linearSlippageFactor: '0.001',
|
||||
quadraticSlippageFactor: '0',
|
||||
liquiditySlaParameters: {
|
||||
priceRange: '0.5',
|
||||
commitmentMinTimeFraction: '0.1',
|
||||
performanceHysteresisEpochs: 0,
|
||||
slaCompetitionFactor: '0.1',
|
||||
},
|
||||
lpPriceRange: '10',
|
||||
instrument: {
|
||||
name: 'Token test market',
|
||||
code: 'TEST.24h',
|
||||
|
||||
+48
-66
@@ -5,6 +5,7 @@ import {
|
||||
InstrumentInfoPanel,
|
||||
KeyDetailsInfoPanel,
|
||||
LiquidityMonitoringParametersInfoPanel,
|
||||
LiquidityPriceRangeInfoPanel,
|
||||
MetadataInfoPanel,
|
||||
OracleInfoPanel,
|
||||
PriceMonitoringBoundsInfoPanel,
|
||||
@@ -12,10 +13,6 @@ import {
|
||||
RiskModelInfoPanel,
|
||||
RiskParametersInfoPanel,
|
||||
SettlementAssetInfoPanel,
|
||||
getDataSourceSpecForSettlementSchedule,
|
||||
getDataSourceSpecForSettlementData,
|
||||
getDataSourceSpecForTradingTermination,
|
||||
getSigners,
|
||||
} from '@vegaprotocol/markets';
|
||||
import {
|
||||
Button,
|
||||
@@ -27,6 +24,7 @@ import {
|
||||
import { SubHeading } from '../../../../components/heading';
|
||||
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
||||
import type { MarketInfo } from '@vegaprotocol/markets';
|
||||
import type { DataSourceDefinition } from '@vegaprotocol/types';
|
||||
import { create } from 'zustand';
|
||||
|
||||
type MarketDataDialogState = {
|
||||
@@ -61,31 +59,20 @@ export const ProposalMarketData = ({
|
||||
return null;
|
||||
}
|
||||
|
||||
const { product } = marketData.tradableInstrument.instrument;
|
||||
|
||||
const settlementData = getDataSourceSpecForSettlementData(product);
|
||||
const settlementScheduleData =
|
||||
getDataSourceSpecForSettlementSchedule(product);
|
||||
const terminationData = getDataSourceSpecForTradingTermination(product);
|
||||
|
||||
const parentProduct = parentMarketData?.tradableInstrument.instrument.product;
|
||||
const settlementData = marketData.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.data as DataSourceDefinition;
|
||||
const parentSettlementData =
|
||||
parentProduct && getDataSourceSpecForSettlementData(parentProduct);
|
||||
const parentSettlementScheduleData =
|
||||
parentProduct && getDataSourceSpecForSettlementSchedule(parentProduct);
|
||||
parentMarketData?.tradableInstrument.instrument?.product
|
||||
?.dataSourceSpecForSettlementData?.data;
|
||||
const terminationData = marketData.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForTradingTermination.data as DataSourceDefinition;
|
||||
const parentTerminationData =
|
||||
parentProduct && getDataSourceSpecForTradingTermination(parentProduct);
|
||||
|
||||
// TODO add settlementScheduleData for Perp Proposal
|
||||
parentMarketData?.tradableInstrument.instrument?.product
|
||||
?.dataSourceSpecForTradingTermination?.data;
|
||||
|
||||
const isParentSettlementDataEqual =
|
||||
parentSettlementData !== undefined &&
|
||||
isEqual(settlementData, parentSettlementData);
|
||||
|
||||
const isParentSettlementScheduleDataEqual =
|
||||
parentSettlementData !== undefined &&
|
||||
isEqual(settlementScheduleData, parentSettlementScheduleData);
|
||||
|
||||
const isParentTerminationDataEqual =
|
||||
parentTerminationData !== undefined &&
|
||||
isEqual(terminationData, parentTerminationData);
|
||||
@@ -98,6 +85,20 @@ export const ProposalMarketData = ({
|
||||
parentMarketData?.priceMonitoringSettings?.parameters?.triggers
|
||||
);
|
||||
|
||||
const getSigners = (data: DataSourceDefinition) => {
|
||||
if (data.sourceType.__typename === 'DataSourceDefinitionExternal') {
|
||||
const signers = data.sourceType.sourceType.signers || [];
|
||||
|
||||
return signers.map(({ signer }) => {
|
||||
return (
|
||||
(signer.__typename === 'ETHAddress' && signer.address) ||
|
||||
(signer.__typename === 'PubKey' && signer.key)
|
||||
);
|
||||
});
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="relative" data-testid="proposal-market-data">
|
||||
<CollapsibleToggle
|
||||
@@ -128,9 +129,10 @@ export const ProposalMarketData = ({
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
|
||||
{settlementData &&
|
||||
terminationData &&
|
||||
isEqual(getSigners(settlementData), getSigners(terminationData)) ? (
|
||||
{isEqual(
|
||||
getSigners(settlementData),
|
||||
getSigners(terminationData)
|
||||
) ? (
|
||||
<>
|
||||
<h2 className={marketDataHeaderStyles}>{t('Oracle')}</h2>
|
||||
|
||||
@@ -138,17 +140,14 @@ export const ProposalMarketData = ({
|
||||
market={marketData}
|
||||
type="settlementData"
|
||||
parentMarket={
|
||||
isParentSettlementDataEqual ||
|
||||
isParentSettlementScheduleDataEqual
|
||||
? undefined
|
||||
: parentMarketData
|
||||
isParentSettlementDataEqual ? undefined : parentMarketData
|
||||
}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t('Settlement oracle')}
|
||||
{t('Settlement Oracle')}
|
||||
</h2>
|
||||
<OracleInfoPanel
|
||||
market={marketData}
|
||||
@@ -158,41 +157,16 @@ export const ProposalMarketData = ({
|
||||
}
|
||||
/>
|
||||
|
||||
{marketData.tradableInstrument.instrument.product.__typename ===
|
||||
'Future' && (
|
||||
<div>
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t('Termination oracle')}
|
||||
</h2>
|
||||
<OracleInfoPanel
|
||||
market={marketData}
|
||||
type="termination"
|
||||
parentMarket={
|
||||
isParentTerminationDataEqual
|
||||
? undefined
|
||||
: parentMarketData
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{marketData.tradableInstrument.instrument.product.__typename ===
|
||||
'Perpetual' && (
|
||||
<div>
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t('Settlement schedule oracle')}
|
||||
</h2>
|
||||
<OracleInfoPanel
|
||||
market={marketData}
|
||||
type="settlementSchedule"
|
||||
parentMarket={
|
||||
isParentSettlementScheduleDataEqual
|
||||
? undefined
|
||||
: parentMarketData
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t('Termination Oracle')}
|
||||
</h2>
|
||||
<OracleInfoPanel
|
||||
market={marketData}
|
||||
type="termination"
|
||||
parentMarket={
|
||||
isParentTerminationDataEqual ? undefined : parentMarketData
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -270,6 +244,14 @@ export const ProposalMarketData = ({
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t('Liquidity price range')}
|
||||
</h2>
|
||||
<LiquidityPriceRangeInfoPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -20,6 +20,7 @@ query Proposal($proposalId: ID!) {
|
||||
... on NewMarket {
|
||||
decimalPlaces
|
||||
metadata
|
||||
lpPriceRange
|
||||
riskParameters {
|
||||
... on LogNormalRiskModel {
|
||||
riskAversionParameter
|
||||
@@ -151,6 +152,7 @@ query Proposal($proposalId: ID!) {
|
||||
}
|
||||
}
|
||||
positionDecimalPlaces
|
||||
lpPriceRange
|
||||
linearSlippageFactor
|
||||
quadraticSlippageFactor
|
||||
}
|
||||
@@ -160,13 +162,37 @@ query Proposal($proposalId: ID!) {
|
||||
instrument {
|
||||
code
|
||||
product {
|
||||
... on UpdateFutureProduct {
|
||||
quoteName
|
||||
dataSourceSpecForSettlementData {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionInternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfigurationTime {
|
||||
quoteName
|
||||
dataSourceSpecForSettlementData {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionInternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfigurationTime {
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
}
|
||||
}
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
type
|
||||
}
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
@@ -174,125 +200,52 @@ query Proposal($proposalId: ID!) {
|
||||
}
|
||||
}
|
||||
}
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
}
|
||||
}
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
type
|
||||
}
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# dataSourceSpecForTradingTermination {
|
||||
# sourceType {
|
||||
# ... on DataSourceDefinitionInternal {
|
||||
# sourceType {
|
||||
# ... on DataSourceSpecConfigurationTime {
|
||||
# conditions {
|
||||
# operator
|
||||
# value
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# ... on DataSourceDefinitionExternal {
|
||||
# sourceType {
|
||||
# ... on DataSourceSpecConfiguration {
|
||||
# signers {
|
||||
# signer {
|
||||
# ... on PubKey {
|
||||
# key
|
||||
# }
|
||||
# ... on ETHAddress {
|
||||
# address
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# filters {
|
||||
# key {
|
||||
# name
|
||||
# type
|
||||
# }
|
||||
# conditions {
|
||||
# operator
|
||||
# value
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
tradingTerminationProperty
|
||||
}
|
||||
}
|
||||
... on UpdatePerpetualProduct {
|
||||
quoteName
|
||||
dataSourceSpecForSettlementData {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionInternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfigurationTime {
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
}
|
||||
}
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
type
|
||||
}
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
settlementScheduleProperty
|
||||
}
|
||||
# dataSourceSpecForTradingTermination {
|
||||
# sourceType {
|
||||
# ... on DataSourceDefinitionInternal {
|
||||
# sourceType {
|
||||
# ... on DataSourceSpecConfigurationTime {
|
||||
# conditions {
|
||||
# operator
|
||||
# value
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# ... on DataSourceDefinitionExternal {
|
||||
# sourceType {
|
||||
# ... on DataSourceSpecConfiguration {
|
||||
# signers {
|
||||
# signer {
|
||||
# ... on PubKey {
|
||||
# key
|
||||
# }
|
||||
# ... on ETHAddress {
|
||||
# address
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# filters {
|
||||
# key {
|
||||
# name
|
||||
# type
|
||||
# }
|
||||
# conditions {
|
||||
# operator
|
||||
# value
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
tradingTerminationProperty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -3,12 +3,12 @@ import * as Types from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type ProposalFieldsFragment = { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } };
|
||||
export type ProposalFieldsFragment = { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } };
|
||||
|
||||
export type ProposalsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type ProposalsQuery = { __typename?: 'Query', proposalsConnection?: { __typename?: 'ProposalsConnection', edges?: Array<{ __typename?: 'ProposalEdge', node: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } } | null> | null } | null };
|
||||
export type ProposalsQuery = { __typename?: 'Query', proposalsConnection?: { __typename?: 'ProposalsConnection', edges?: Array<{ __typename?: 'ProposalEdge', node: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } } | null> | null } | null };
|
||||
|
||||
export const ProposalFieldsFragmentDoc = gql`
|
||||
fragment ProposalFields on Proposal {
|
||||
|
||||
+28
-7
@@ -35,7 +35,6 @@ import { HealthDialog } from '../../health-dialog';
|
||||
import { Status } from '../../status';
|
||||
import { intentForStatus } from '../../../lib/utils';
|
||||
import { formatDistanceToNow } from 'date-fns';
|
||||
import { getAsset } from '@vegaprotocol/markets';
|
||||
|
||||
export const MarketList = () => {
|
||||
const { data, error, loading } = useMarketsLiquidity();
|
||||
@@ -52,7 +51,12 @@ export const MarketList = () => {
|
||||
return (
|
||||
<>
|
||||
<span className="leading-3">{value}</span>
|
||||
<span className="leading-3">{getAsset(data).symbol}</span>
|
||||
<span className="leading-3">
|
||||
{
|
||||
data?.tradableInstrument?.instrument?.product?.settlementAsset
|
||||
?.symbol
|
||||
}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
},
|
||||
@@ -83,7 +87,12 @@ export const MarketList = () => {
|
||||
value,
|
||||
data,
|
||||
}: VegaValueFormatterParams<Market, 'data.markPrice'>) =>
|
||||
value && data ? formatWithAsset(value, getAsset(data)) : '-',
|
||||
value && data
|
||||
? formatWithAsset(
|
||||
value,
|
||||
data.tradableInstrument.instrument.product.settlementAsset
|
||||
)
|
||||
: '-',
|
||||
},
|
||||
|
||||
{
|
||||
@@ -114,7 +123,8 @@ export const MarketList = () => {
|
||||
value && data
|
||||
? `${addDecimalsFormatNumber(
|
||||
value,
|
||||
getAsset(data).decimals || 0
|
||||
data.tradableInstrument.instrument.product.settlementAsset
|
||||
.decimals
|
||||
)} (${displayChange(data.volumeChange)})`
|
||||
: '-',
|
||||
headerTooltip: t('The trade volume over the last 24h'),
|
||||
@@ -128,7 +138,10 @@ export const MarketList = () => {
|
||||
data,
|
||||
}: VegaValueFormatterParams<Market, 'liquidityCommitted'>) =>
|
||||
data && value
|
||||
? formatWithAsset(value.toString(), getAsset(data))
|
||||
? formatWithAsset(
|
||||
value.toString(),
|
||||
data.tradableInstrument.instrument.product.settlementAsset
|
||||
)
|
||||
: '-',
|
||||
headerTooltip: t('The amount of funds allocated to provide liquidity'),
|
||||
},
|
||||
@@ -140,7 +153,12 @@ export const MarketList = () => {
|
||||
value,
|
||||
data,
|
||||
}: VegaValueFormatterParams<Market, 'target'>) =>
|
||||
data && value ? formatWithAsset(value, getAsset(data)) : '-',
|
||||
data && value
|
||||
? formatWithAsset(
|
||||
value,
|
||||
data.tradableInstrument.instrument.product.settlementAsset
|
||||
)
|
||||
: '-',
|
||||
headerTooltip: t(
|
||||
'The ideal committed liquidity to operate the market. If total commitment currently below this level then LPs can set the fee level with new commitment.'
|
||||
),
|
||||
@@ -212,7 +230,10 @@ export const MarketList = () => {
|
||||
}) => (
|
||||
<HealthBar
|
||||
target={data.target}
|
||||
decimals={getAsset(data).decimals || 0}
|
||||
decimals={
|
||||
data.tradableInstrument.instrument.product.settlementAsset
|
||||
.decimals
|
||||
}
|
||||
levels={data.feeLevels}
|
||||
intent={intentForStatus(value)}
|
||||
/>
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
sumLiquidityCommitted,
|
||||
lpAggregatedDataProvider,
|
||||
} from '@vegaprotocol/liquidity';
|
||||
import { getAsset, marketWithDataProvider } from '@vegaprotocol/markets';
|
||||
import { marketWithDataProvider } from '@vegaprotocol/markets';
|
||||
import type { MarketWithData } from '@vegaprotocol/markets';
|
||||
|
||||
import { Market } from './market';
|
||||
@@ -19,8 +19,10 @@ import { LPProvidersGrid } from './providers';
|
||||
const formatMarket = (market: MarketWithData) => {
|
||||
return {
|
||||
name: market?.tradableInstrument.instrument.name,
|
||||
symbol: getAsset(market).symbol,
|
||||
settlementAsset: getAsset(market),
|
||||
symbol:
|
||||
market?.tradableInstrument.instrument.product.settlementAsset.symbol,
|
||||
settlementAsset:
|
||||
market?.tradableInstrument.instrument.product.settlementAsset,
|
||||
targetStake: market?.data?.targetStake,
|
||||
tradingMode: market?.data?.marketTradingMode,
|
||||
trigger: market?.data?.trigger,
|
||||
|
||||
@@ -7,7 +7,6 @@ const marketTradingModeStyle = {
|
||||
[Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION]: '#0046CD',
|
||||
[Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION]: '#CF0064',
|
||||
[Schema.MarketTradingMode.TRADING_MODE_NO_TRADING]: '#CF0064',
|
||||
[Schema.MarketTradingMode.TRADING_MODE_SUSPENDED_VIA_GOVERNANCE]: '#CF0064',
|
||||
};
|
||||
|
||||
export const getColorForStatus = (status: Schema.MarketTradingMode) =>
|
||||
@@ -19,8 +18,6 @@ const marketTradingModeIntent = {
|
||||
[Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION]: Intent.Primary,
|
||||
[Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION]: Intent.Danger,
|
||||
[Schema.MarketTradingMode.TRADING_MODE_NO_TRADING]: Intent.Danger,
|
||||
[Schema.MarketTradingMode.TRADING_MODE_SUSPENDED_VIA_GOVERNANCE]:
|
||||
Intent.Danger,
|
||||
};
|
||||
|
||||
export const intentForStatus = (status: Schema.MarketTradingMode) => {
|
||||
|
||||
@@ -122,7 +122,6 @@ const mockTradingPage = (
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
dataSourceSpecForSettlementData: {
|
||||
data: {
|
||||
sourceType: {
|
||||
|
||||
+5
-5
@@ -3,21 +3,21 @@ NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
|
||||
NX_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613
|
||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/stagnet1/vegawallet-stagnet1.toml
|
||||
NX_VEGA_ENV=STAGNET1
|
||||
NX_VEGA_EXPLORER_URL=https://explorer.stagnet1.vega.rocks
|
||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/fairground/vegawallet-fairground.toml
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
||||
NX_VEGA_NETWORKS={\"MAINNET\":\"https://console.vega.xyz\",\"TESTNET\":\"https://console.fairground.wtf\",\"STAGNET1\":\"https://trading.stagnet1.vega.rocks\"}
|
||||
NX_VEGA_TOKEN_URL=https://governance.stagnet1.vega.rocks
|
||||
NX_VEGA_TOKEN_URL=https://governance.fairground.wtf
|
||||
NX_VEGA_WALLET_URL=http://localhost:1789
|
||||
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
||||
NX_VEGA_REPO_URL=https://github.com/vegaprotocol/vega/releases
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||
NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports
|
||||
NX_VEGA_CONSOLE_URL=https://console.fairground.wtf
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
||||
|
||||
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
NX_STOP_ORDERS=true
|
||||
|
||||
@@ -3,89 +3,63 @@ import { useEnvironment } from '@vegaprotocol/environment';
|
||||
import { ButtonLink, Link } from '@vegaprotocol/ui-toolkit';
|
||||
import { MarketProposalNotification } from '@vegaprotocol/proposals';
|
||||
import type { Market } from '@vegaprotocol/markets';
|
||||
import {
|
||||
fromNanoSeconds,
|
||||
getExpiryDate,
|
||||
getMarketExpiryDate,
|
||||
} from '@vegaprotocol/utils';
|
||||
import { getExpiryDate, getMarketExpiryDate } from '@vegaprotocol/utils';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import {
|
||||
Last24hPriceChange,
|
||||
Last24hVolume,
|
||||
getAsset,
|
||||
getDataSourceSpecForSettlementSchedule,
|
||||
marketInfoProvider,
|
||||
useFundingPeriodsQuery,
|
||||
useFundingRate,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { Last24hPriceChange, Last24hVolume } from '@vegaprotocol/markets';
|
||||
import { MarketState as State } from '@vegaprotocol/types';
|
||||
import { HeaderStat } from '../../components/header';
|
||||
import { MarketMarkPrice } from '../../components/market-mark-price';
|
||||
import { HeaderStatMarketTradingMode } from '../../components/market-trading-mode';
|
||||
import { MarketState } from '../../components/market-state';
|
||||
import { MarketLiquiditySupplied } from '../../components/liquidity-supplied';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||
|
||||
interface MarketHeaderStatsProps {
|
||||
market: Market;
|
||||
market: Market | null;
|
||||
}
|
||||
|
||||
export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
||||
const { VEGA_EXPLORER_URL } = useEnvironment();
|
||||
const { open: openAssetDetailsDialog } = useAssetDetailsDialogStore();
|
||||
|
||||
const asset = getAsset(market);
|
||||
const asset = market?.tradableInstrument.instrument.product?.settlementAsset;
|
||||
|
||||
return (
|
||||
<>
|
||||
{market.tradableInstrument.instrument.product.__typename === 'Future' && (
|
||||
<HeaderStat
|
||||
heading={t('Expiry')}
|
||||
description={
|
||||
<HeaderStat
|
||||
heading={t('Expiry')}
|
||||
description={
|
||||
market && (
|
||||
<ExpiryTooltipContent
|
||||
market={market}
|
||||
explorerUrl={VEGA_EXPLORER_URL}
|
||||
/>
|
||||
}
|
||||
testId="market-expiry"
|
||||
>
|
||||
<ExpiryLabel market={market} />
|
||||
</HeaderStat>
|
||||
)}
|
||||
{market.tradableInstrument.instrument.product.__typename ===
|
||||
'Perpetual' && (
|
||||
<HeaderStat
|
||||
heading={`${t('Funding')} / ${t('Countdown')}`}
|
||||
testId="market-funding"
|
||||
>
|
||||
<div className="flex justify-between gap-2">
|
||||
<FundingRate marketId={market.id} />
|
||||
<FundingCountdown marketId={market.id} />
|
||||
</div>
|
||||
</HeaderStat>
|
||||
)}
|
||||
)
|
||||
}
|
||||
testId="market-expiry"
|
||||
>
|
||||
<ExpiryLabel market={market} />
|
||||
</HeaderStat>
|
||||
<HeaderStat heading={t('Price')} testId="market-price">
|
||||
<MarketMarkPrice
|
||||
marketId={market.id}
|
||||
decimalPlaces={market.decimalPlaces}
|
||||
marketId={market?.id}
|
||||
decimalPlaces={market?.decimalPlaces}
|
||||
/>
|
||||
</HeaderStat>
|
||||
<HeaderStat heading={t('Change (24h)')} testId="market-change">
|
||||
<Last24hPriceChange
|
||||
marketId={market.id}
|
||||
decimalPlaces={market.decimalPlaces}
|
||||
marketId={market?.id}
|
||||
decimalPlaces={market?.decimalPlaces}
|
||||
/>
|
||||
</HeaderStat>
|
||||
<HeaderStat heading={t('Volume (24h)')} testId="market-volume">
|
||||
<Last24hVolume
|
||||
marketId={market.id}
|
||||
positionDecimalPlaces={market.positionDecimalPlaces}
|
||||
marketId={market?.id}
|
||||
positionDecimalPlaces={market?.positionDecimalPlaces}
|
||||
/>
|
||||
</HeaderStat>
|
||||
<HeaderStatMarketTradingMode
|
||||
marketId={market.id}
|
||||
initialTradingMode={market.tradingMode}
|
||||
marketId={market?.id}
|
||||
initialTradingMode={market?.tradingMode}
|
||||
/>
|
||||
<MarketState market={market} />
|
||||
{asset ? (
|
||||
@@ -105,84 +79,27 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
||||
</HeaderStat>
|
||||
) : null}
|
||||
<MarketLiquiditySupplied
|
||||
marketId={market.id}
|
||||
marketId={market?.id}
|
||||
assetDecimals={asset?.decimals || 0}
|
||||
/>
|
||||
<MarketProposalNotification marketId={market.id} />
|
||||
<MarketProposalNotification marketId={market?.id} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
type ExpiryLabelProps = {
|
||||
market: Market;
|
||||
};
|
||||
|
||||
export const FundingRate = ({ marketId }: { marketId: string }) => {
|
||||
const { data: fundingRate } = useFundingRate(marketId);
|
||||
return (
|
||||
<div data-testid="funding-rate">
|
||||
{fundingRate ? `${(Number(fundingRate) * 100).toFixed(4)}%` : '-'}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const padStart = (n: number) => n.toString().padStart(2, '0');
|
||||
|
||||
export const FundingCountdown = ({ marketId }: { marketId: string }) => {
|
||||
const { data: fundingPeriods } = useFundingPeriodsQuery({
|
||||
variables: {
|
||||
marketId: marketId,
|
||||
pagination: { first: 1 },
|
||||
},
|
||||
});
|
||||
const { data: marketInfo } = useDataProvider({
|
||||
dataProvider: marketInfoProvider,
|
||||
variables: { marketId },
|
||||
});
|
||||
|
||||
const [now, setNow] = useState(Date.now());
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => setNow(Date.now()), 1000);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
const node = fundingPeriods?.fundingPeriods.edges?.[0]?.node;
|
||||
let startTime: number | undefined = undefined;
|
||||
if (node && node.startTime && !node.endTime) {
|
||||
startTime = fromNanoSeconds(node.startTime).getTime();
|
||||
}
|
||||
let diffFormatted = t('Unknown');
|
||||
let every: number | undefined = undefined;
|
||||
const sourceType =
|
||||
marketInfo &&
|
||||
getDataSourceSpecForSettlementSchedule(
|
||||
marketInfo.tradableInstrument.instrument.product
|
||||
)?.data.sourceType.sourceType;
|
||||
|
||||
if (sourceType?.__typename === 'DataSourceSpecConfigurationTimeTrigger') {
|
||||
every = sourceType.triggers?.[0]?.every ?? undefined;
|
||||
if (every) {
|
||||
every *= 1000;
|
||||
}
|
||||
}
|
||||
if (startTime && every) {
|
||||
const diff = every - ((now - startTime) % every);
|
||||
const hours = (diff / 3.6e6) | 0;
|
||||
const mins = ((diff % 3.6e6) / 6e4) | 0;
|
||||
const secs = Math.round((diff % 6e4) / 1e3);
|
||||
diffFormatted = `${padStart(hours)}:${padStart(mins)}:${padStart(secs)}`;
|
||||
}
|
||||
return <div data-testid="funding-countdown">{diffFormatted}</div>;
|
||||
market: Market | null;
|
||||
};
|
||||
|
||||
const ExpiryLabel = ({ market }: ExpiryLabelProps) => {
|
||||
const content = market.tradableInstrument.instrument.metadata.tags
|
||||
? getExpiryDate(
|
||||
market.tradableInstrument.instrument.metadata.tags,
|
||||
market.marketTimestamps.close,
|
||||
market.state
|
||||
)
|
||||
: '-';
|
||||
const content =
|
||||
market && market.tradableInstrument.instrument.metadata.tags
|
||||
? getExpiryDate(
|
||||
market.tradableInstrument.instrument.metadata.tags,
|
||||
market.marketTimestamps.close,
|
||||
market.state
|
||||
)
|
||||
: '-';
|
||||
return <div data-testid="trading-expiry">{content}</div>;
|
||||
};
|
||||
|
||||
@@ -195,12 +112,10 @@ const ExpiryTooltipContent = ({
|
||||
market,
|
||||
explorerUrl,
|
||||
}: ExpiryTooltipContentProps) => {
|
||||
if (market.marketTimestamps.close === null) {
|
||||
if (market?.marketTimestamps.close === null) {
|
||||
const oracleId =
|
||||
market.tradableInstrument.instrument.product.__typename === 'Future'
|
||||
? market.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForTradingTermination?.id
|
||||
: undefined;
|
||||
market.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForTradingTermination?.id;
|
||||
|
||||
const metadataExpiryDate = getMarketExpiryDate(
|
||||
market.tradableInstrument.instrument.metadata.tags
|
||||
|
||||
@@ -4,7 +4,7 @@ import { t } from '@vegaprotocol/i18n';
|
||||
import { useScreenDimensions } from '@vegaprotocol/react-helpers';
|
||||
import { useThrottledDataProvider } from '@vegaprotocol/data-provider';
|
||||
import { AsyncRenderer, ExternalLink, Splash } from '@vegaprotocol/ui-toolkit';
|
||||
import { getAsset, marketDataProvider, useMarket } from '@vegaprotocol/markets';
|
||||
import { marketDataProvider, useMarket } from '@vegaprotocol/markets';
|
||||
import { useGlobalStore, usePageTitleStore } from '../../stores';
|
||||
import { TradeGrid } from './trade-grid';
|
||||
import { TradePanels } from './trade-panels';
|
||||
@@ -81,16 +81,26 @@ export const MarketPage = () => {
|
||||
}
|
||||
}, [setViews, view, currentRouteId, largeScreen]);
|
||||
|
||||
const pinnedAsset = data && getAsset(data);
|
||||
|
||||
const tradeView = useMemo(() => {
|
||||
if (pinnedAsset) {
|
||||
if (largeScreen) {
|
||||
return <TradeGrid market={data} pinnedAsset={pinnedAsset} />;
|
||||
}
|
||||
return <TradePanels market={data} pinnedAsset={pinnedAsset} />;
|
||||
if (largeScreen) {
|
||||
return (
|
||||
<TradeGrid
|
||||
market={data}
|
||||
pinnedAsset={
|
||||
data?.tradableInstrument.instrument.product.settlementAsset
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}, [largeScreen, data, pinnedAsset]);
|
||||
return (
|
||||
<TradePanels
|
||||
market={data}
|
||||
pinnedAsset={
|
||||
data?.tradableInstrument.instrument.product.settlementAsset
|
||||
}
|
||||
/>
|
||||
);
|
||||
}, [largeScreen, data]);
|
||||
|
||||
if (!data && marketId) {
|
||||
return (
|
||||
|
||||
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||
import type { PinnedAsset } from '@vegaprotocol/accounts';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { OracleBanner, useMarket } from '@vegaprotocol/markets';
|
||||
import { OracleBanner } from '@vegaprotocol/markets';
|
||||
import type { Market } from '@vegaprotocol/markets';
|
||||
import { Filter } from '@vegaprotocol/orders';
|
||||
import { Tab, LocalStoragePersistTabs as Tabs } from '@vegaprotocol/ui-toolkit';
|
||||
@@ -34,7 +34,6 @@ const MainGrid = memo(
|
||||
marketId: string;
|
||||
pinnedAsset?: PinnedAsset;
|
||||
}) => {
|
||||
const { data: market } = useMarket(marketId);
|
||||
const [sizes, handleOnLayoutChange] = usePaneLayout({ id: 'top' });
|
||||
const [sizesMiddle, handleOnMiddleLayoutChange] = usePaneLayout({
|
||||
id: 'middle-1',
|
||||
@@ -69,13 +68,6 @@ const MainGrid = memo(
|
||||
<Tab id="liquidity" name={t('Liquidity')}>
|
||||
<TradingViews.liquidity.component marketId={marketId} />
|
||||
</Tab>
|
||||
{market &&
|
||||
market.tradableInstrument.instrument.product.__typename ===
|
||||
'Perpetual' ? (
|
||||
<Tab id="funding" name={t('Funding')}>
|
||||
<TradingViews.funding.component marketId={marketId} />
|
||||
</Tab>
|
||||
) : null}
|
||||
</Tabs>
|
||||
</TradeGridChild>
|
||||
</ResizableGridPanel>
|
||||
|
||||
@@ -13,7 +13,6 @@ import { FillsContainer } from '../../components/fills-container';
|
||||
import { PositionsContainer } from '../../components/positions-container';
|
||||
import { AccountsContainer } from '../../components/accounts-container';
|
||||
import { LiquidityContainer } from '../../components/liquidity-container';
|
||||
import { FundingContainer } from '../../components/funding-container';
|
||||
import type { OrderContainerProps } from '../../components/orders-container';
|
||||
import { OrdersContainer } from '../../components/orders-container';
|
||||
import { StopOrdersContainer } from '../../components/stop-orders-container';
|
||||
@@ -51,10 +50,6 @@ export const TradingViews = {
|
||||
label: 'Liquidity',
|
||||
component: requiresMarket(LiquidityContainer),
|
||||
},
|
||||
funding: {
|
||||
label: 'Funding',
|
||||
component: requiresMarket(FundingContainer),
|
||||
},
|
||||
orderbook: {
|
||||
label: 'Orderbook',
|
||||
component: requiresMarket(OrderbookContainer),
|
||||
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
OracleSpecDataConnectionDocument,
|
||||
MarketsDataDocument,
|
||||
MarketsDocument,
|
||||
getAsset,
|
||||
} from '@vegaprotocol/markets';
|
||||
import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
|
||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||
@@ -49,13 +48,10 @@ describe('Closed', () => {
|
||||
tags: [settlementDateTag],
|
||||
},
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
dataSourceSpecForSettlementData: {
|
||||
__typename: 'DataSourceSpec',
|
||||
id: settlementDataId,
|
||||
data: {
|
||||
sourceType: {
|
||||
__typename: 'DataSourceDefinitionExternal',
|
||||
sourceType: {
|
||||
filters: [
|
||||
{
|
||||
@@ -168,8 +164,7 @@ describe('Closed', () => {
|
||||
Date.now = originalNow;
|
||||
});
|
||||
|
||||
// eslint-disable-next-line jest/no-disabled-tests
|
||||
it.skip('renders correctly formatted and filtered rows', async () => {
|
||||
it('renders correctly formatted and filtered rows', async () => {
|
||||
await act(async () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
@@ -201,8 +196,6 @@ describe('Closed', () => {
|
||||
expect(headers).toHaveLength(expectedHeaders.length);
|
||||
expect(headers.map((h) => h.textContent?.trim())).toEqual(expectedHeaders);
|
||||
|
||||
const assetSymbol = getAsset(market).symbol;
|
||||
|
||||
const cells = screen.getAllByRole('gridcell');
|
||||
const expectedValues = [
|
||||
market.tradableInstrument.instrument.code,
|
||||
@@ -217,7 +210,7 @@ describe('Closed', () => {
|
||||
addDecimalsFormatNumber(marketsData!.markPrice, market.decimalPlaces),
|
||||
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
||||
addDecimalsFormatNumber(property.value, market.decimalPlaces),
|
||||
assetSymbol,
|
||||
market.tradableInstrument.instrument.product.settlementAsset.symbol,
|
||||
'', // actions row
|
||||
];
|
||||
cells.forEach((cell, i) => {
|
||||
@@ -228,7 +221,7 @@ describe('Closed', () => {
|
||||
it('only renders settled and terminated markets', async () => {
|
||||
const mixedMarkets = [
|
||||
{
|
||||
// include as settled
|
||||
// inlclude as settled
|
||||
__typename: 'MarketEdge' as const,
|
||||
node: createMarketFragment({
|
||||
id: 'include-0',
|
||||
|
||||
@@ -7,26 +7,26 @@ import type {
|
||||
import { AgGridLazy as AgGrid, COL_DEFS } from '@vegaprotocol/datagrid';
|
||||
import { useMemo } from 'react';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import type { Asset } from '@vegaprotocol/types';
|
||||
import type { ProductType } from '@vegaprotocol/types';
|
||||
import { MarketState, MarketStateMapping } from '@vegaprotocol/types';
|
||||
import {
|
||||
addDecimalsFormatNumber,
|
||||
getMarketExpiryDate,
|
||||
} from '@vegaprotocol/utils';
|
||||
import { closedMarketsWithDataProvider, getAsset } from '@vegaprotocol/markets';
|
||||
import type { DataSourceFilterFragment } from '@vegaprotocol/markets';
|
||||
import type {
|
||||
DataSourceFilterFragment,
|
||||
MarketMaybeWithData,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { closedMarketsWithDataProvider } from '@vegaprotocol/markets';
|
||||
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
||||
import { SettlementDateCell } from './settlement-date-cell';
|
||||
import { SettlementPriceCell } from './settlement-price-cell';
|
||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||
import { MarketCodeCell } from './market-code-cell';
|
||||
import { MarketActionsDropdown } from './market-table-actions';
|
||||
import { MarketCodeCell } from './market-code-cell';
|
||||
|
||||
type SettlementAsset = Pick<
|
||||
Asset,
|
||||
'decimals' | 'name' | 'quantum' | 'id' | 'symbol'
|
||||
>;
|
||||
type SettlementAsset =
|
||||
MarketMaybeWithData['tradableInstrument']['instrument']['product']['settlementAsset'];
|
||||
|
||||
interface Row {
|
||||
id: string;
|
||||
@@ -41,7 +41,7 @@ interface Row {
|
||||
markPrice: string | undefined;
|
||||
settlementDataOracleId: string;
|
||||
settlementDataSpecBinding: string;
|
||||
settlementDataSourceFilter: DataSourceFilterFragment | undefined;
|
||||
setlementDataSourceFilter: DataSourceFilterFragment | undefined;
|
||||
tradingTerminationOracleId: string;
|
||||
settlementAsset: SettlementAsset;
|
||||
productType: ProductType | undefined;
|
||||
@@ -59,26 +59,18 @@ export const Closed = () => {
|
||||
const instrument = market.tradableInstrument.instrument;
|
||||
|
||||
const spec =
|
||||
(instrument.product.__typename === 'Future' ||
|
||||
instrument.product.__typename === 'Perpetual') &&
|
||||
instrument.product.dataSourceSpecForSettlementData.data.sourceType
|
||||
.__typename === 'DataSourceDefinitionExternal'
|
||||
? instrument.product.dataSourceSpecForSettlementData.data.sourceType
|
||||
.sourceType
|
||||
: undefined;
|
||||
const filters = (spec && 'filters' in spec && spec.filters) || [];
|
||||
const filters = spec?.filters || [];
|
||||
|
||||
const settlementDataSpecBinding =
|
||||
instrument.product.__typename === 'Future' ||
|
||||
instrument.product.__typename === 'Perpetual'
|
||||
? instrument.product.dataSourceSpecBinding.settlementDataProperty
|
||||
: '';
|
||||
const filter =
|
||||
filters && Array.isArray(filters)
|
||||
? filters?.find((filter) => {
|
||||
return filter.key.name === settlementDataSpecBinding;
|
||||
})
|
||||
: undefined;
|
||||
instrument.product.dataSourceSpecBinding.settlementDataProperty;
|
||||
const filter = filters?.find((filter) => {
|
||||
return filter.key.name === settlementDataSpecBinding;
|
||||
});
|
||||
|
||||
const row: Row = {
|
||||
id: market.id,
|
||||
@@ -92,17 +84,12 @@ export const Closed = () => {
|
||||
bestOfferPrice: market.data?.bestOfferPrice,
|
||||
markPrice: market.data?.markPrice,
|
||||
settlementDataOracleId:
|
||||
instrument.product.__typename === 'Future' ||
|
||||
instrument.product.__typename === 'Perpetual'
|
||||
? instrument.product.dataSourceSpecForSettlementData.id
|
||||
: '',
|
||||
instrument.product.dataSourceSpecForSettlementData.id,
|
||||
settlementDataSpecBinding,
|
||||
settlementDataSourceFilter: filter,
|
||||
setlementDataSourceFilter: filter,
|
||||
tradingTerminationOracleId:
|
||||
instrument.product.__typename === 'Future'
|
||||
? instrument.product.dataSourceSpecForTradingTermination.id
|
||||
: '',
|
||||
settlementAsset: getAsset({ tradableInstrument: { instrument } }),
|
||||
instrument.product.dataSourceSpecForTradingTermination.id,
|
||||
settlementAsset: instrument.product.settlementAsset,
|
||||
productType: instrument.product.__typename,
|
||||
successorMarketID: market.successorMarketID,
|
||||
parentMarketID: market.parentMarketID,
|
||||
@@ -234,7 +221,7 @@ const ClosedMarketsDataGrid = ({
|
||||
<SettlementPriceCell
|
||||
oracleSpecId={value}
|
||||
settlementDataSpecBinding={data?.settlementDataSpecBinding}
|
||||
filter={data?.settlementDataSourceFilter}
|
||||
filter={data?.setlementDataSourceFilter}
|
||||
/>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { useEnvironment } from '@vegaprotocol/environment';
|
||||
import { Icon } from '@vegaprotocol/ui-toolkit';
|
||||
import type { IconName } from '@blueprintjs/icons';
|
||||
import type { Market } from '@vegaprotocol/markets';
|
||||
import {
|
||||
getMatchingOracleProvider,
|
||||
getVerifiedStatusIcon,
|
||||
useOracleProofs,
|
||||
} from '@vegaprotocol/markets';
|
||||
|
||||
export const OracleStatus = ({
|
||||
dataSourceSpecForSettlementData,
|
||||
dataSourceSpecForTradingTermination,
|
||||
}: Pick<
|
||||
Market['tradableInstrument']['instrument']['product'],
|
||||
'dataSourceSpecForSettlementData' | 'dataSourceSpecForTradingTermination'
|
||||
>) => {
|
||||
const { ORACLE_PROOFS_URL } = useEnvironment();
|
||||
const { data: providers } = useOracleProofs(ORACLE_PROOFS_URL);
|
||||
|
||||
if (providers) {
|
||||
const settlementDataProvider = getMatchingOracleProvider(
|
||||
dataSourceSpecForSettlementData.data,
|
||||
providers
|
||||
);
|
||||
const tradingTerminationDataProvider = getMatchingOracleProvider(
|
||||
dataSourceSpecForTradingTermination.data,
|
||||
providers
|
||||
);
|
||||
let maliciousOracleProvider = null;
|
||||
|
||||
if (settlementDataProvider?.oracle.status !== 'GOOD') {
|
||||
maliciousOracleProvider = settlementDataProvider;
|
||||
} else if (tradingTerminationDataProvider?.oracle.status !== 'GOOD') {
|
||||
maliciousOracleProvider = tradingTerminationDataProvider;
|
||||
}
|
||||
|
||||
if (!maliciousOracleProvider) return null;
|
||||
|
||||
const { icon } = getVerifiedStatusIcon(maliciousOracleProvider);
|
||||
|
||||
return <Icon size={3} name={icon as IconName} className="ml-1" />;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
@@ -16,7 +16,7 @@ import type {
|
||||
MarketMaybeWithDataAndCandles,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { MarketActionsDropdown } from './market-table-actions';
|
||||
import { calcCandleVolume, getAsset } from '@vegaprotocol/markets';
|
||||
import { calcCandleVolume } from '@vegaprotocol/markets';
|
||||
import { MarketCodeCell } from './market-code-cell';
|
||||
|
||||
const { MarketTradingMode, AuctionTrigger } = Schema;
|
||||
@@ -151,7 +151,8 @@ export const useColumnDefs = () => {
|
||||
MarketMaybeWithData,
|
||||
'tradableInstrument.instrument.product.settlementAsset.symbol'
|
||||
>) => {
|
||||
const value = data && getAsset(data);
|
||||
const value =
|
||||
data?.tradableInstrument.instrument.product.settlementAsset;
|
||||
return value ? (
|
||||
<ButtonLink
|
||||
onClick={(e) => {
|
||||
@@ -210,7 +211,9 @@ export const useColumnDefs = () => {
|
||||
return (
|
||||
<MarketActionsDropdown
|
||||
marketId={data.id}
|
||||
assetId={getAsset(data).id}
|
||||
assetId={
|
||||
data.tradableInstrument.instrument.product.settlementAsset.id
|
||||
}
|
||||
successorMarketID={data.successorMarketID}
|
||||
parentMarketID={data.parentMarketID}
|
||||
/>
|
||||
|
||||
@@ -30,9 +30,9 @@ import {
|
||||
useThemeSwitcher,
|
||||
} from '@vegaprotocol/react-helpers';
|
||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||
import { getAsset, type Market } from '@vegaprotocol/markets';
|
||||
import type { Market } from '@vegaprotocol/markets';
|
||||
|
||||
export const DateRange = {
|
||||
const DateRange = {
|
||||
RANGE_1D: '1D',
|
||||
RANGE_7D: '7D',
|
||||
RANGE_1M: '1M',
|
||||
@@ -47,7 +47,7 @@ const dateRangeToggleItems = Object.entries(DateRange).map(([_, value]) => ({
|
||||
value: value,
|
||||
}));
|
||||
|
||||
export const calculateStartDate = (range: string): string | undefined => {
|
||||
const calculateStartDate = (range: string): string | undefined => {
|
||||
const now = new Date();
|
||||
switch (range) {
|
||||
case DateRange.RANGE_1D:
|
||||
@@ -131,12 +131,11 @@ const AccountHistoryManager = ({
|
||||
DateRange.RANGE_1M
|
||||
);
|
||||
const [market, setMarket] = useState<Market | null>(null);
|
||||
|
||||
const marketFilterCb = useCallback(
|
||||
(item: Market) => {
|
||||
const itemAsset = getAsset(item);
|
||||
return !asset?.id || itemAsset?.id === asset?.id;
|
||||
},
|
||||
(item: Market) =>
|
||||
!asset?.id ||
|
||||
item.tradableInstrument.instrument.product.settlementAsset.id ===
|
||||
asset?.id,
|
||||
[asset?.id]
|
||||
);
|
||||
const markets = useMemo<Market[] | null>(() => {
|
||||
@@ -156,8 +155,8 @@ const AccountHistoryManager = ({
|
||||
const resolveMarket = useCallback(
|
||||
(m: Market) => {
|
||||
setMarket(m);
|
||||
const itemAsset = getAsset(m);
|
||||
const newAssetId = itemAsset?.id;
|
||||
const newAssetId =
|
||||
m.tradableInstrument.instrument.product.settlementAsset.id;
|
||||
const newAsset = assets.find((item) => item.id === newAssetId);
|
||||
if ((!asset || (assets && newAssetId !== asset.id)) && newAsset) {
|
||||
setAssetId(newAsset.id);
|
||||
@@ -242,7 +241,11 @@ const AccountHistoryManager = ({
|
||||
setAssetId(a.id);
|
||||
|
||||
// if the selected asset is different to the selected market clear the market
|
||||
if (market && a.id !== getAsset(market).id) {
|
||||
if (
|
||||
a.id !==
|
||||
market?.tradableInstrument.instrument.product
|
||||
.settlementAsset.id
|
||||
) {
|
||||
setMarket(null);
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
import { fromNanoSeconds } from '@vegaprotocol/utils';
|
||||
|
||||
import compact from 'lodash/compact';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
import 'pennant/dist/style.css';
|
||||
import { useFundingPeriodsQuery } from '@vegaprotocol/markets';
|
||||
import { LineChart } from 'pennant';
|
||||
import { useMemo } from 'react';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { useThemeSwitcher } from '@vegaprotocol/react-helpers';
|
||||
import { Splash } from '@vegaprotocol/ui-toolkit';
|
||||
import {
|
||||
DateRange,
|
||||
calculateStartDate,
|
||||
} from '../../client-pages/portfolio/account-history-container';
|
||||
|
||||
export const FundingContainer = ({ marketId }: { marketId: string }) => {
|
||||
const { theme } = useThemeSwitcher();
|
||||
const variables = useMemo(
|
||||
() => ({
|
||||
marketId: marketId || '',
|
||||
dateRange: { start: calculateStartDate(DateRange.RANGE_7D) },
|
||||
}),
|
||||
[marketId]
|
||||
);
|
||||
const { data } = useFundingPeriodsQuery({
|
||||
variables,
|
||||
skip: !marketId,
|
||||
});
|
||||
const values: { cols: [string, string]; rows: [Date, number][] } | null =
|
||||
useMemo(() => {
|
||||
if (!data?.fundingPeriods.edges.length) {
|
||||
return null;
|
||||
}
|
||||
const rows = compact(data?.fundingPeriods.edges)
|
||||
.filter((edge) => edge.node.endTime)
|
||||
.reduce((acc, edge) => {
|
||||
if (edge.node.endTime) {
|
||||
acc?.push({
|
||||
endTime: fromNanoSeconds(edge.node.endTime),
|
||||
fundingRate: Number(edge.node.fundingRate),
|
||||
});
|
||||
}
|
||||
return acc;
|
||||
}, [] as { endTime: Date; fundingRate: number }[]);
|
||||
return {
|
||||
cols: ['Date', t('Funding rate')],
|
||||
rows: sortBy(rows, 'endTime').map((d) => [d.endTime, d.fundingRate]),
|
||||
};
|
||||
}, [data?.fundingPeriods.edges]);
|
||||
if (!data || !values?.rows.length) {
|
||||
return <Splash> {t('No funding history data')}</Splash>;
|
||||
}
|
||||
return <LineChart data={values} theme={theme} />;
|
||||
};
|
||||
@@ -1 +0,0 @@
|
||||
export * from './funding-container';
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
LiquidityTable,
|
||||
liquidityProvisionsDataProvider,
|
||||
} from '@vegaprotocol/liquidity';
|
||||
import { getAsset, useMarket } from '@vegaprotocol/markets';
|
||||
import { useMarket } from '@vegaprotocol/markets';
|
||||
import {
|
||||
NetworkParams,
|
||||
useNetworkParams,
|
||||
@@ -42,11 +42,12 @@ export const LiquidityContainer = ({
|
||||
skip: !marketId,
|
||||
});
|
||||
|
||||
const itemAsset = market && getAsset(market);
|
||||
|
||||
const assetDecimalPlaces = itemAsset?.decimals || 0;
|
||||
const quantum = itemAsset?.quantum || 0;
|
||||
const symbol = itemAsset?.symbol;
|
||||
const assetDecimalPlaces =
|
||||
market?.tradableInstrument.instrument.product.settlementAsset.decimals || 0;
|
||||
const quantum =
|
||||
market?.tradableInstrument.instrument.product.settlementAsset.quantum || 0;
|
||||
const symbol =
|
||||
market?.tradableInstrument.instrument.product.settlementAsset.symbol;
|
||||
|
||||
const { params } = useNetworkParams([
|
||||
NetworkParams.market_liquidity_stakeToCcyVolume,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
getAsset,
|
||||
tooltipMapping,
|
||||
useMarket,
|
||||
useStaticMarketData,
|
||||
@@ -25,11 +24,10 @@ export const LiquidityHeader = () => {
|
||||
const { data: marketData } = useStaticMarketData(marketId);
|
||||
const targetStake = marketData?.targetStake;
|
||||
const suppliedStake = marketData?.suppliedStake;
|
||||
|
||||
const asset = market && getAsset(market);
|
||||
|
||||
const assetDecimalPlaces = asset?.decimals || 0;
|
||||
const symbol = asset?.symbol;
|
||||
const assetDecimalPlaces =
|
||||
market?.tradableInstrument.instrument.product.settlementAsset.decimals || 0;
|
||||
const symbol =
|
||||
market?.tradableInstrument.instrument.product.settlementAsset.symbol;
|
||||
|
||||
const { params } = useNetworkParams([
|
||||
NetworkParams.market_liquidity_stakeToCcyVolume,
|
||||
|
||||
@@ -5,7 +5,6 @@ import { MarketSelector } from '../../components/market-selector/market-selector
|
||||
import { MarketHeaderStats } from '../../client-pages/market/market-header-stats';
|
||||
import { useMarket, useMarketList } from '@vegaprotocol/markets';
|
||||
import { useState } from 'react';
|
||||
import { MarketProductPill } from '@vegaprotocol/datagrid';
|
||||
|
||||
export const MarketHeader = () => {
|
||||
const { marketId } = useParams();
|
||||
@@ -26,14 +25,7 @@ export const MarketHeader = () => {
|
||||
onChange={setOpen}
|
||||
trigger={
|
||||
<HeaderTitle>
|
||||
<span>
|
||||
{data.tradableInstrument.instrument.code}
|
||||
<MarketProductPill
|
||||
productType={
|
||||
data.tradableInstrument.instrument.product.__typename
|
||||
}
|
||||
/>
|
||||
</span>
|
||||
{data.tradableInstrument.instrument.code}
|
||||
<VegaIcon name={VegaIconNames.CHEVRON_DOWN} size={14} />
|
||||
</HeaderTitle>
|
||||
}
|
||||
|
||||
@@ -24,37 +24,35 @@ export const AssetDropdown = ({
|
||||
}
|
||||
|
||||
return (
|
||||
assets && (
|
||||
<TradingDropdown
|
||||
trigger={
|
||||
<TradingDropdownTrigger data-testid="asset-trigger">
|
||||
<MarketSelectorButton>
|
||||
{triggerText({ assets, checkedAssets })}
|
||||
</MarketSelectorButton>
|
||||
</TradingDropdownTrigger>
|
||||
}
|
||||
>
|
||||
<TradingDropdownContent>
|
||||
{assets.filter(Boolean).map((a) => {
|
||||
return (
|
||||
<TradingDropdownCheckboxItem
|
||||
key={a.id}
|
||||
checked={checkedAssets.includes(a.id)}
|
||||
onCheckedChange={(checked) => {
|
||||
if (typeof checked === 'boolean') {
|
||||
onSelect(a.id, checked);
|
||||
}
|
||||
}}
|
||||
data-testid={`asset-id-${a.id}`}
|
||||
>
|
||||
{a.symbol}
|
||||
<TradingDropdownItemIndicator />
|
||||
</TradingDropdownCheckboxItem>
|
||||
);
|
||||
})}
|
||||
</TradingDropdownContent>
|
||||
</TradingDropdown>
|
||||
)
|
||||
<TradingDropdown
|
||||
trigger={
|
||||
<TradingDropdownTrigger data-testid="asset-trigger">
|
||||
<MarketSelectorButton>
|
||||
{triggerText({ assets, checkedAssets })}
|
||||
</MarketSelectorButton>
|
||||
</TradingDropdownTrigger>
|
||||
}
|
||||
>
|
||||
<TradingDropdownContent>
|
||||
{assets?.map((a) => {
|
||||
return (
|
||||
<TradingDropdownCheckboxItem
|
||||
key={a.id}
|
||||
checked={checkedAssets.includes(a.id)}
|
||||
onCheckedChange={(checked) => {
|
||||
if (typeof checked === 'boolean') {
|
||||
onSelect(a.id, checked);
|
||||
}
|
||||
}}
|
||||
data-testid={`asset-id-${a.id}`}
|
||||
>
|
||||
{a.symbol}
|
||||
<TradingDropdownItemIndicator />
|
||||
</TradingDropdownCheckboxItem>
|
||||
);
|
||||
})}
|
||||
</TradingDropdownContent>
|
||||
</TradingDropdown>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import type {
|
||||
MarketDataUpdateFieldsFragment,
|
||||
MarketDataUpdateSubscription,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { MarketCandlesDocument, getAsset } from '@vegaprotocol/markets';
|
||||
import { MarketCandlesDocument } from '@vegaprotocol/markets';
|
||||
import { MarketDataUpdateDocument } from '@vegaprotocol/markets';
|
||||
import {
|
||||
AuctionTrigger,
|
||||
@@ -35,7 +35,6 @@ describe('MarketSelectorItem', () => {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
symbol: 'SYM',
|
||||
},
|
||||
@@ -120,7 +119,8 @@ describe('MarketSelectorItem', () => {
|
||||
});
|
||||
|
||||
it('renders market information', async () => {
|
||||
const symbol = getAsset(market).symbol;
|
||||
const symbol =
|
||||
market.tradableInstrument.instrument.product.settlementAsset.symbol;
|
||||
|
||||
const mock: MockedResponse<MarketDataUpdateSubscription> = {
|
||||
request: {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Link } from 'react-router-dom';
|
||||
import classNames from 'classnames';
|
||||
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
||||
import type { MarketMaybeWithDataAndCandles } from '@vegaprotocol/markets';
|
||||
import { calcCandleVolume, getAsset } from '@vegaprotocol/markets';
|
||||
import { calcCandleVolume } from '@vegaprotocol/markets';
|
||||
import { useCandles } from '@vegaprotocol/markets';
|
||||
import { useMarketDataUpdateSubscription } from '@vegaprotocol/markets';
|
||||
import { Sparkline } from '@vegaprotocol/ui-toolkit';
|
||||
@@ -80,6 +80,7 @@ const MarketData = ({
|
||||
? MarketTradingModeMapping[marketTradingMode]
|
||||
: '';
|
||||
|
||||
const instrument = market.tradableInstrument.instrument;
|
||||
const { oneDayCandles } = useCandles({ marketId: market.id });
|
||||
|
||||
const vol = oneDayCandles ? calcCandleVolume(oneDayCandles) : '0';
|
||||
@@ -89,15 +90,12 @@ const MarketData = ({
|
||||
: '0.00';
|
||||
|
||||
const productType = market.tradableInstrument.instrument.product.__typename;
|
||||
const symbol = getAsset(market).symbol || '';
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="w-2/5" role="gridcell">
|
||||
<h3 className="flex items-baseline">
|
||||
<span className="text-sm lg:text-base text-ellipsis whitespace-nowrap overflow-hidden">
|
||||
{market.tradableInstrument.instrument.code}
|
||||
</span>
|
||||
<h3 className="overflow-hidden text-sm text-ellipsis lg:text-base whitespace-nowrap">
|
||||
{market.tradableInstrument.instrument.code}{' '}
|
||||
{allProducts && productType && (
|
||||
<MarketProductPill productType={productType} />
|
||||
)}
|
||||
@@ -110,11 +108,11 @@ const MarketData = ({
|
||||
</div>
|
||||
<div
|
||||
className="w-1/5 overflow-hidden text-xs lg:text-sm whitespace-nowrap text-ellipsis"
|
||||
title={symbol}
|
||||
title={instrument.product.settlementAsset.symbol}
|
||||
data-testid="market-selector-price"
|
||||
role="gridcell"
|
||||
>
|
||||
{price} {symbol}
|
||||
{price} {instrument.product.settlementAsset.symbol}
|
||||
</div>
|
||||
<div
|
||||
className="w-1/5 overflow-hidden text-xs text-right lg:text-sm whitespace-nowrap text-ellipsis"
|
||||
|
||||
@@ -22,7 +22,7 @@ jest.mock('./market-selector-item', () => ({
|
||||
),
|
||||
}));
|
||||
|
||||
// without a real DOM auto-size won't render with an actual height or width
|
||||
// without a real DOM autosize won't render with an actual height or width
|
||||
jest.mock('react-virtualized-auto-sizer', () => {
|
||||
// eslint-disable-next-line react/display-name
|
||||
return ({
|
||||
@@ -41,7 +41,6 @@ describe('MarketSelector', () => {
|
||||
code: 'a',
|
||||
name: 'a',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-0',
|
||||
},
|
||||
@@ -62,7 +61,6 @@ describe('MarketSelector', () => {
|
||||
code: 'b',
|
||||
name: 'b',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-0',
|
||||
},
|
||||
@@ -81,7 +79,6 @@ describe('MarketSelector', () => {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-1',
|
||||
},
|
||||
@@ -97,7 +94,6 @@ describe('MarketSelector', () => {
|
||||
code: 'c',
|
||||
name: 'c',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-1',
|
||||
},
|
||||
@@ -117,7 +113,6 @@ describe('MarketSelector', () => {
|
||||
code: 'cd',
|
||||
name: 'cd',
|
||||
product: {
|
||||
__typename: 'Perpetual',
|
||||
settlementAsset: {
|
||||
id: 'asset-2',
|
||||
},
|
||||
@@ -179,14 +174,21 @@ describe('MarketSelector', () => {
|
||||
);
|
||||
|
||||
await userEvent.click(screen.getByTestId('product-Perpetual'));
|
||||
expect(screen.queryAllByTestId(/market-\d/)).toHaveLength(1);
|
||||
expect(screen.queryAllByTestId(/market-\d/)).toHaveLength(0);
|
||||
expect(screen.getByTestId('no-items')).toHaveTextContent(
|
||||
'Perpetual markets coming soon.'
|
||||
);
|
||||
|
||||
await userEvent.click(screen.getByTestId('product-Future'));
|
||||
expect(screen.queryAllByTestId(/market-\d/)).toHaveLength(3);
|
||||
expect(screen.queryAllByTestId(/market-\d/)).toHaveLength(
|
||||
activeMarkets.length
|
||||
);
|
||||
expect(screen.queryByTestId('no-items')).not.toBeInTheDocument();
|
||||
|
||||
await userEvent.click(screen.getByTestId('product-All'));
|
||||
expect(screen.queryAllByTestId(/market-\d/)).toHaveLength(4);
|
||||
expect(screen.queryAllByTestId(/market-\d/)).toHaveLength(
|
||||
activeMarkets.length
|
||||
);
|
||||
expect(screen.queryByTestId('no-items')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -218,6 +220,38 @@ describe('MarketSelector', () => {
|
||||
expect(screen.getByTestId('market-4')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('filters by asset', async () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<MarketSelector currentMarketId="market-0" onSelect={jest.fn()} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
await userEvent.click(screen.getByTestId('asset-trigger'));
|
||||
expect(screen.getAllByTestId(/asset-id/)).toHaveLength(3);
|
||||
await userEvent.click(screen.getByTestId('asset-id-asset-0'));
|
||||
expect(screen.getAllByTestId(/market-\d/)).toHaveLength(2);
|
||||
expect(screen.getByTestId('market-0')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('market-1')).toBeInTheDocument();
|
||||
|
||||
// reopen asset dropdown and add asset-1
|
||||
await userEvent.click(screen.getByTestId('asset-trigger'));
|
||||
await userEvent.click(screen.getByTestId('asset-id-asset-1'));
|
||||
|
||||
// all markets with asset-0 or asset-1 shown (no market id as market is closed)
|
||||
expect(screen.getAllByTestId(/market-\d/)).toHaveLength(3);
|
||||
expect(screen.getByTestId('market-0')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('market-1')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('market-3')).toBeInTheDocument();
|
||||
|
||||
// reopen and uncheck asset-0
|
||||
await userEvent.click(screen.getByTestId('asset-trigger'));
|
||||
await userEvent.click(screen.getByTestId('asset-id-asset-0'));
|
||||
|
||||
expect(screen.getAllByTestId(/market-\d/)).toHaveLength(1);
|
||||
expect(screen.getByTestId('market-3')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('sorts by gained', async () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import uniqBy from 'lodash/uniqBy';
|
||||
import {
|
||||
getAsset,
|
||||
type MarketMaybeWithDataAndCandles,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { type MarketMaybeWithDataAndCandles } from '@vegaprotocol/markets';
|
||||
import {
|
||||
TradingInput,
|
||||
TinyScroll,
|
||||
@@ -79,7 +76,9 @@ export const MarketSelector = ({
|
||||
</div>
|
||||
<AssetDropdown
|
||||
assets={uniqBy(
|
||||
data?.map((d) => getAsset(d)),
|
||||
data?.map(
|
||||
(d) => d.tradableInstrument.instrument.product.settlementAsset
|
||||
),
|
||||
'id'
|
||||
)}
|
||||
checkedAssets={filter.assets}
|
||||
|
||||
@@ -78,22 +78,22 @@ describe('useMarketSelectorList', () => {
|
||||
},
|
||||
},
|
||||
}),
|
||||
// createMarketFragment({
|
||||
// id: 'market-1',
|
||||
// tradableInstrument: {
|
||||
// instrument: {
|
||||
// product: {
|
||||
// __typename: 'Spot',
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
createMarketFragment({
|
||||
id: 'market-1',
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Spot' as 'Future', // spot isn't in schema yet
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
createMarketFragment({
|
||||
id: 'market-2',
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Perpetual',
|
||||
__typename: 'Perpetual' as 'Future', // spot isn't in schema yet
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -107,20 +107,20 @@ describe('useMarketSelectorList', () => {
|
||||
});
|
||||
const { result, rerender } = setup();
|
||||
expect(result.current.markets).toEqual([markets[0]]);
|
||||
// rerender({
|
||||
// searchTerm: '',
|
||||
// product: Product.Spot as 'Future',
|
||||
// sort: Sort.TopTraded,
|
||||
// assets: [],
|
||||
// });
|
||||
// expect(result.current.markets).toEqual([markets[1]]);
|
||||
rerender({
|
||||
searchTerm: '',
|
||||
product: Product.Spot as 'Future',
|
||||
sort: Sort.TopTraded,
|
||||
assets: [],
|
||||
});
|
||||
expect(result.current.markets).toEqual([markets[1]]);
|
||||
rerender({
|
||||
searchTerm: '',
|
||||
product: Product.Perpetual as 'Future',
|
||||
sort: Sort.TopTraded,
|
||||
assets: [],
|
||||
});
|
||||
// expect(result.current.markets).toEqual([markets[2]]);
|
||||
expect(result.current.markets).toEqual([markets[2]]);
|
||||
rerender({
|
||||
searchTerm: '',
|
||||
product: Product.All,
|
||||
@@ -130,15 +130,13 @@ describe('useMarketSelectorList', () => {
|
||||
expect(result.current.markets).toEqual(markets);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line jest/no-disabled-tests
|
||||
it.skip('filters by asset', () => {
|
||||
it('filters by asset', () => {
|
||||
const markets = [
|
||||
createMarketFragment({
|
||||
id: 'market-0',
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-0',
|
||||
},
|
||||
@@ -151,7 +149,6 @@ describe('useMarketSelectorList', () => {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-0',
|
||||
},
|
||||
@@ -164,7 +161,6 @@ describe('useMarketSelectorList', () => {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-1',
|
||||
},
|
||||
@@ -177,7 +173,6 @@ describe('useMarketSelectorList', () => {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-2',
|
||||
},
|
||||
@@ -198,7 +193,6 @@ describe('useMarketSelectorList', () => {
|
||||
sort: Sort.TopTraded,
|
||||
assets: ['asset-0'],
|
||||
});
|
||||
|
||||
expect(result.current.markets).toEqual([markets[0], markets[1]]);
|
||||
|
||||
rerender({
|
||||
@@ -414,7 +408,7 @@ describe('useMarketSelectorList', () => {
|
||||
const markets = [
|
||||
createMarketFragment({
|
||||
id: 'market-0',
|
||||
// @ts-ignore actual fragment doesn't contain candles and is joined later
|
||||
// @ts-ignore actual fragment doesnt contain candles and is joined later
|
||||
candles: [
|
||||
{
|
||||
close: '100',
|
||||
@@ -426,7 +420,7 @@ describe('useMarketSelectorList', () => {
|
||||
}),
|
||||
createMarketFragment({
|
||||
id: 'market-1',
|
||||
// @ts-ignore actual fragment doesn't contain candles and is joined later
|
||||
// @ts-ignore actual fragment doesnt contain candles and is joined later
|
||||
candles: [
|
||||
{
|
||||
close: '100',
|
||||
@@ -438,7 +432,7 @@ describe('useMarketSelectorList', () => {
|
||||
}),
|
||||
createMarketFragment({
|
||||
id: 'market-2',
|
||||
// @ts-ignore actual fragment doesn't contain candles and is joined later
|
||||
// @ts-ignore actual fragment doesnt contain candles and is joined later
|
||||
candles: [
|
||||
{
|
||||
close: '100',
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { useMemo } from 'react';
|
||||
import orderBy from 'lodash/orderBy';
|
||||
import {
|
||||
calcTradedFactor,
|
||||
getAsset,
|
||||
useMarketList,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { calcTradedFactor, useMarketList } from '@vegaprotocol/markets';
|
||||
import { priceChangePercentage } from '@vegaprotocol/utils';
|
||||
import type { Filter } from '../../components/market-selector/market-selector';
|
||||
import { Sort } from './sort-dropdown';
|
||||
@@ -36,8 +32,9 @@ export const useMarketSelectorList = ({
|
||||
})
|
||||
.filter((m) => {
|
||||
if (assets.length === 0) return true;
|
||||
const asset = getAsset(m);
|
||||
return assets.includes(asset.id);
|
||||
return assets.includes(
|
||||
m.tradableInstrument.instrument.product.settlementAsset.id
|
||||
);
|
||||
})
|
||||
// filter based on search term
|
||||
.filter((m) => {
|
||||
|
||||
@@ -54,7 +54,7 @@ export async function getMarkets() {
|
||||
tags: string[];
|
||||
};
|
||||
product: {
|
||||
settlementAsset: {
|
||||
settlementAssset: {
|
||||
id: string;
|
||||
symbol: string;
|
||||
decimals: number;
|
||||
|
||||
@@ -37,6 +37,7 @@ function createNewMarketProposal(): ProposalSubmissionBody {
|
||||
positionDecimalPlaces: '5',
|
||||
linearSlippageFactor: '0.001',
|
||||
quadraticSlippageFactor: '0',
|
||||
lpPriceRange: '10',
|
||||
instrument: {
|
||||
name: 'Test market 1',
|
||||
code: 'TEST.24h',
|
||||
@@ -131,12 +132,6 @@ function createNewMarketProposal(): ProposalSubmissionBody {
|
||||
sigma: 0.5,
|
||||
},
|
||||
},
|
||||
liquiditySlaParameters: {
|
||||
priceRange: '0.95',
|
||||
commitmentMinTimeFraction: '0.5',
|
||||
performanceHysteresisEpochs: 2,
|
||||
slaCompetitionFactor: '0.75',
|
||||
},
|
||||
},
|
||||
},
|
||||
closingTimestamp,
|
||||
|
||||
@@ -12,18 +12,16 @@ import {
|
||||
export const MarketProductPill = ({
|
||||
productType,
|
||||
}: {
|
||||
productType?: ProductType;
|
||||
productType: ProductType;
|
||||
}) => {
|
||||
return (
|
||||
productType && (
|
||||
<Pill
|
||||
size="xxs"
|
||||
className="uppercase ml-0.5"
|
||||
title={ProductTypeMapping[productType]}
|
||||
>
|
||||
{ProductTypeShortName[productType]}
|
||||
</Pill>
|
||||
)
|
||||
<Pill
|
||||
size="xxs"
|
||||
className="uppercase ml-0.5"
|
||||
title={ProductTypeMapping[productType]}
|
||||
>
|
||||
{ProductTypeShortName[productType]}
|
||||
</Pill>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { FeesBreakdown, getAsset, getQuoteName } from '@vegaprotocol/markets';
|
||||
import { FeesBreakdown } from '@vegaprotocol/markets';
|
||||
import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
|
||||
@@ -45,7 +45,8 @@ export const DealTicketFeeDetails = ({
|
||||
market,
|
||||
}: DealTicketFeeDetailsProps) => {
|
||||
const feeEstimate = useEstimateFees(order);
|
||||
const asset = getAsset(market);
|
||||
const { settlementAsset: asset } =
|
||||
market.tradableInstrument.instrument.product;
|
||||
const { decimals: assetDecimals, quantum } = asset;
|
||||
|
||||
return (
|
||||
@@ -107,7 +108,8 @@ export const DealTicketMarginDetails = ({
|
||||
const marginEstimate = positionEstimate?.margin;
|
||||
const totalBalance =
|
||||
BigInt(generalAccountBalance || '0') + BigInt(marginAccountBalance || '0');
|
||||
const asset = getAsset(market);
|
||||
const { settlementAsset: asset } =
|
||||
market.tradableInstrument.instrument.product;
|
||||
const { decimals: assetDecimals, quantum } = asset;
|
||||
let marginRequiredBestCase: string | undefined = undefined;
|
||||
let marginRequiredWorstCase: string | undefined = undefined;
|
||||
@@ -246,7 +248,7 @@ export const DealTicketMarginDetails = ({
|
||||
[]
|
||||
);
|
||||
|
||||
const quoteName = getQuoteName(market);
|
||||
const quoteName = market.tradableInstrument.instrument.product.quoteName;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2 w-full">
|
||||
|
||||
@@ -28,12 +28,8 @@ import {
|
||||
Intent,
|
||||
Notification,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import {
|
||||
getAsset,
|
||||
getDerivedPrice,
|
||||
getQuoteName,
|
||||
type Market,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { getDerivedPrice } from '@vegaprotocol/markets';
|
||||
import type { Market } from '@vegaprotocol/markets';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { ExpirySelector } from './expiry-selector';
|
||||
import { SideSelector } from './side-selector';
|
||||
@@ -522,8 +518,8 @@ const NotionalAndFees = ({
|
||||
> &
|
||||
Pick<StopOrderProps, 'market' | 'marketPrice'> &
|
||||
Pick<StopOrderFormValues, 'triggerType' | 'triggerPrice'>) => {
|
||||
const quoteName = getQuoteName(market);
|
||||
const asset = getAsset(market);
|
||||
const { quoteName, settlementAsset: asset } =
|
||||
market.tradableInstrument.instrument.product;
|
||||
const isPriceTrigger = triggerType === 'price';
|
||||
const derivedPrice = getDerivedPrice(
|
||||
{
|
||||
@@ -662,7 +658,7 @@ const SubmitButton = ({
|
||||
| 'type'
|
||||
> &
|
||||
Pick<StopOrderProps, 'market'> & { assetUnit?: string }) => {
|
||||
const quoteName = getQuoteName(market);
|
||||
const { quoteName } = market.tradableInstrument.instrument.product;
|
||||
const risesAbove =
|
||||
triggerDirection ===
|
||||
Schema.StopOrderTriggerDirection.TRIGGER_DIRECTION_RISES_ABOVE;
|
||||
@@ -853,7 +849,7 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
return () => subscription.unsubscribe();
|
||||
}, [watch, market.id, updateStoredFormValues]);
|
||||
|
||||
const quoteName = getQuoteName(market);
|
||||
const { quoteName } = market.tradableInstrument.instrument.product;
|
||||
const assetUnit = getAssetUnit(
|
||||
market.tradableInstrument.instrument.metadata.tags
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
formatValue,
|
||||
} from '@vegaprotocol/utils';
|
||||
import { activeOrdersProvider } from '@vegaprotocol/orders';
|
||||
import { getAsset, getDerivedPrice, getQuoteName } from '@vegaprotocol/markets';
|
||||
import { getDerivedPrice } from '@vegaprotocol/markets';
|
||||
import {
|
||||
validateExpiration,
|
||||
validateMarketState,
|
||||
@@ -158,7 +158,7 @@ export const DealTicket = ({
|
||||
});
|
||||
const lastSubmitTime = useRef(0);
|
||||
|
||||
const asset = getAsset(market);
|
||||
const asset = market.tradableInstrument.instrument.product.settlementAsset;
|
||||
const {
|
||||
accountBalance: marginAccountBalance,
|
||||
loading: loadingMarginAccountBalance,
|
||||
@@ -261,7 +261,8 @@ export const DealTicket = ({
|
||||
skip: !normalizedOrder,
|
||||
});
|
||||
|
||||
const assetSymbol = getAsset(market).symbol;
|
||||
const assetSymbol =
|
||||
market.tradableInstrument.instrument.product.settlementAsset.symbol;
|
||||
|
||||
const assetUnit = getAssetUnit(
|
||||
market.tradableInstrument.instrument.metadata.tags
|
||||
@@ -347,7 +348,7 @@ export const DealTicket = ({
|
||||
|
||||
const priceStep = toDecimal(market?.decimalPlaces);
|
||||
const sizeStep = toDecimal(market?.positionDecimalPlaces);
|
||||
const quoteName = getQuoteName(market);
|
||||
const quoteName = market.tradableInstrument.instrument.product.quoteName;
|
||||
const isLimitType = type === Schema.OrderType.TYPE_LIMIT;
|
||||
|
||||
return (
|
||||
@@ -676,7 +677,7 @@ export const DealTicket = ({
|
||||
</Button>
|
||||
<DealTicketMarginDetails
|
||||
onMarketClick={onMarketClick}
|
||||
assetSymbol={asset.symbol}
|
||||
assetSymbol={assetSymbol}
|
||||
marginAccountBalance={marginAccountBalance}
|
||||
generalAccountBalance={generalAccountBalance}
|
||||
positionEstimate={positionEstimate?.estimatePosition}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Link as UILink } from '@vegaprotocol/ui-toolkit';
|
||||
import type { SimpleGridProps } from '@vegaprotocol/ui-toolkit';
|
||||
import type { ReactNode } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { getAsset, type Market, type MarketData } from '@vegaprotocol/markets';
|
||||
import type { Market, MarketData } from '@vegaprotocol/markets';
|
||||
|
||||
export const compileGridData = (
|
||||
market: Pick<
|
||||
@@ -36,11 +36,15 @@ export const compileGridData = (
|
||||
Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET) ||
|
||||
marketData?.trigger ===
|
||||
Schema.AuctionTrigger.AUCTION_TRIGGER_UNABLE_TO_DEPLOY_LP_ORDERS;
|
||||
const asset = getAsset(market);
|
||||
|
||||
const formatStake = (value: string) => {
|
||||
const formattedValue = addDecimalsFormatNumber(value, asset.decimals);
|
||||
return `${formattedValue} ${asset.symbol}`;
|
||||
const formattedValue = addDecimalsFormatNumber(
|
||||
value,
|
||||
market.tradableInstrument.instrument.product.settlementAsset.decimals
|
||||
);
|
||||
const asset =
|
||||
market.tradableInstrument.instrument.product.settlementAsset.symbol;
|
||||
return `${formattedValue} ${asset}`;
|
||||
};
|
||||
|
||||
if (!marketData) return grid;
|
||||
|
||||
@@ -27,7 +27,6 @@ export function generateMarket(override?: PartialDeep<Market>): Market {
|
||||
tags: [],
|
||||
},
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-0',
|
||||
symbol: 'tDAI',
|
||||
@@ -68,6 +67,7 @@ export function generateMarket(override?: PartialDeep<Market>): Market {
|
||||
settlementDataProperty: 'settlement-data-property',
|
||||
},
|
||||
quoteName: 'BTC',
|
||||
__typename: 'Future',
|
||||
},
|
||||
__typename: 'Instrument',
|
||||
},
|
||||
|
||||
@@ -21,7 +21,6 @@ describe('FillsTable', () => {
|
||||
instrument: {
|
||||
code: 'test market',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
decimals: 2,
|
||||
symbol: 'BTC',
|
||||
|
||||
@@ -30,7 +30,6 @@ import BigNumber from 'bignumber.js';
|
||||
import type { Trade } from './fills-data-provider';
|
||||
import type { FillFieldsFragment } from './__generated__/Fills';
|
||||
import { FillActionsDropdown } from './fill-actions-dropdown';
|
||||
import { getAsset } from '@vegaprotocol/markets';
|
||||
|
||||
const TAKER = 'Taker';
|
||||
const MAKER = 'Maker';
|
||||
@@ -142,12 +141,13 @@ const formatPrice = ({
|
||||
if (!data?.market || !isNumeric(value)) {
|
||||
return '-';
|
||||
}
|
||||
const asset = getAsset(data.market);
|
||||
const asset =
|
||||
data?.market.tradableInstrument.instrument.product.settlementAsset.symbol;
|
||||
const valueFormatted = addDecimalsFormatNumber(
|
||||
value,
|
||||
data?.market.decimalPlaces
|
||||
);
|
||||
return `${valueFormatted} ${asset.symbol}`;
|
||||
return `${valueFormatted} ${asset}`;
|
||||
};
|
||||
|
||||
const formatSize = (partyId: string) => {
|
||||
@@ -192,9 +192,8 @@ const formatTotal = ({
|
||||
if (!data?.market || !isNumeric(value)) {
|
||||
return '-';
|
||||
}
|
||||
const { symbol: assetSymbol, decimals: assetDecimals } = getAsset(
|
||||
data.market
|
||||
);
|
||||
const { symbol: assetSymbol, decimals: assetDecimals } =
|
||||
data?.market.tradableInstrument.instrument.product.settlementAsset ?? {};
|
||||
const size = new BigNumber(
|
||||
addDecimal(data?.size, data?.market.positionDecimalPlaces)
|
||||
);
|
||||
@@ -220,8 +219,10 @@ const formatFee = (partyId: string) => {
|
||||
Trade,
|
||||
'market.tradableInstrument.instrument.product'
|
||||
>) => {
|
||||
if (!value || !data || !data?.market) return '-';
|
||||
const asset = getAsset(data.market);
|
||||
if (!value?.settlementAsset || !data) {
|
||||
return '-';
|
||||
}
|
||||
const asset = value.settlementAsset;
|
||||
const { fees: feesObj, role } = getRoleAndFees({ data, partyId });
|
||||
if (!feesObj) return '-';
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ export const generateFill = (override?: PartialDeep<Trade>) => {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
__typename: 'Asset',
|
||||
id: 'asset-id',
|
||||
name: 'asset-id',
|
||||
id: 'assset-id',
|
||||
name: 'assset-id',
|
||||
symbol: 'SYM',
|
||||
decimals: 18,
|
||||
quantum: '1',
|
||||
|
||||
@@ -2,11 +2,7 @@ import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||
import { Orderbook } from './orderbook';
|
||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||
import { marketDepthProvider } from './market-depth-provider';
|
||||
import {
|
||||
getQuoteName,
|
||||
marketDataProvider,
|
||||
marketProvider,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { marketDataProvider, marketProvider } from '@vegaprotocol/markets';
|
||||
import type {
|
||||
MarketDepthQuery,
|
||||
MarketDepthQueryVariables,
|
||||
@@ -57,6 +53,7 @@ export const OrderbookManager = ({
|
||||
dataProvider: marketDataProvider,
|
||||
variables,
|
||||
});
|
||||
|
||||
return (
|
||||
<AsyncRenderer
|
||||
loading={loading || marketDataLoading || marketLoading}
|
||||
@@ -70,7 +67,7 @@ export const OrderbookManager = ({
|
||||
asks={data?.depth.sell ?? []}
|
||||
decimalPlaces={market.decimalPlaces}
|
||||
positionDecimalPlaces={market.positionDecimalPlaces}
|
||||
assetSymbol={getQuoteName(market)}
|
||||
assetSymbol={market.tradableInstrument.instrument.product.quoteName}
|
||||
onClick={onClick}
|
||||
lastTradedPrice={marketData.lastTradedPrice}
|
||||
/>
|
||||
|
||||
@@ -9,10 +9,22 @@ fragment OracleMarketSpecFields on Market {
|
||||
code
|
||||
product {
|
||||
... on Future {
|
||||
...Future
|
||||
}
|
||||
... on Perpetual {
|
||||
...Perpetual
|
||||
dataSourceSpecForSettlementData {
|
||||
id
|
||||
data {
|
||||
...DataSourceSpec
|
||||
}
|
||||
}
|
||||
dataSourceSpecForTradingTermination {
|
||||
id
|
||||
data {
|
||||
...DataSourceSpec
|
||||
}
|
||||
}
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
tradingTerminationProperty
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-9
File diff suppressed because one or more lines are too long
-126
@@ -1,126 +0,0 @@
|
||||
import * as Types from '@vegaprotocol/types';
|
||||
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type FundingPeriodsQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
dateRange?: Types.InputMaybe<Types.DateRange>;
|
||||
pagination?: Types.InputMaybe<Types.Pagination>;
|
||||
}>;
|
||||
|
||||
|
||||
export type FundingPeriodsQuery = { __typename?: 'Query', fundingPeriods: { __typename?: 'FundingPeriodConnection', edges: Array<{ __typename?: 'FundingPeriodEdge', node: { __typename?: 'FundingPeriod', marketId: string, seq: number, startTime: any, endTime?: any | null, fundingPayment?: string | null, fundingRate?: string | null, externalTwap?: string | null, internalTwap?: string | null } }> } };
|
||||
|
||||
export type FundingPeriodDataPointsQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
dateRange?: Types.InputMaybe<Types.DateRange>;
|
||||
pagination?: Types.InputMaybe<Types.Pagination>;
|
||||
}>;
|
||||
|
||||
|
||||
export type FundingPeriodDataPointsQuery = { __typename?: 'Query', fundingPeriodDataPoints: { __typename?: 'FundingPeriodDataPointConnection', edges: Array<{ __typename?: 'FundingPeriodDataPointEdge', node: { __typename?: 'FundingPeriodDataPoint', marketId: string, seq: number, dataPointSource?: Types.FundingPeriodDataPointSource | null, price: string, twap?: string | null, timestamp: any } }> } };
|
||||
|
||||
|
||||
export const FundingPeriodsDocument = gql`
|
||||
query FundingPeriods($marketId: ID!, $dateRange: DateRange, $pagination: Pagination) {
|
||||
fundingPeriods(
|
||||
marketId: $marketId
|
||||
dateRange: $dateRange
|
||||
pagination: $pagination
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
marketId
|
||||
seq
|
||||
startTime
|
||||
endTime
|
||||
fundingPayment
|
||||
fundingRate
|
||||
externalTwap
|
||||
internalTwap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useFundingPeriodsQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useFundingPeriodsQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useFundingPeriodsQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
||||
* you can use to render your UI.
|
||||
*
|
||||
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
||||
*
|
||||
* @example
|
||||
* const { data, loading, error } = useFundingPeriodsQuery({
|
||||
* variables: {
|
||||
* marketId: // value for 'marketId'
|
||||
* dateRange: // value for 'dateRange'
|
||||
* pagination: // value for 'pagination'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useFundingPeriodsQuery(baseOptions: Apollo.QueryHookOptions<FundingPeriodsQuery, FundingPeriodsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<FundingPeriodsQuery, FundingPeriodsQueryVariables>(FundingPeriodsDocument, options);
|
||||
}
|
||||
export function useFundingPeriodsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<FundingPeriodsQuery, FundingPeriodsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<FundingPeriodsQuery, FundingPeriodsQueryVariables>(FundingPeriodsDocument, options);
|
||||
}
|
||||
export type FundingPeriodsQueryHookResult = ReturnType<typeof useFundingPeriodsQuery>;
|
||||
export type FundingPeriodsLazyQueryHookResult = ReturnType<typeof useFundingPeriodsLazyQuery>;
|
||||
export type FundingPeriodsQueryResult = Apollo.QueryResult<FundingPeriodsQuery, FundingPeriodsQueryVariables>;
|
||||
export const FundingPeriodDataPointsDocument = gql`
|
||||
query FundingPeriodDataPoints($marketId: ID!, $dateRange: DateRange, $pagination: Pagination) {
|
||||
fundingPeriodDataPoints(
|
||||
marketId: $marketId
|
||||
dateRange: $dateRange
|
||||
pagination: $pagination
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
marketId
|
||||
seq
|
||||
dataPointSource
|
||||
price
|
||||
twap
|
||||
timestamp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useFundingPeriodDataPointsQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useFundingPeriodDataPointsQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useFundingPeriodDataPointsQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
||||
* you can use to render your UI.
|
||||
*
|
||||
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
||||
*
|
||||
* @example
|
||||
* const { data, loading, error } = useFundingPeriodDataPointsQuery({
|
||||
* variables: {
|
||||
* marketId: // value for 'marketId'
|
||||
* dateRange: // value for 'dateRange'
|
||||
* pagination: // value for 'pagination'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useFundingPeriodDataPointsQuery(baseOptions: Apollo.QueryHookOptions<FundingPeriodDataPointsQuery, FundingPeriodDataPointsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<FundingPeriodDataPointsQuery, FundingPeriodDataPointsQueryVariables>(FundingPeriodDataPointsDocument, options);
|
||||
}
|
||||
export function useFundingPeriodDataPointsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<FundingPeriodDataPointsQuery, FundingPeriodDataPointsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<FundingPeriodDataPointsQuery, FundingPeriodDataPointsQueryVariables>(FundingPeriodDataPointsDocument, options);
|
||||
}
|
||||
export type FundingPeriodDataPointsQueryHookResult = ReturnType<typeof useFundingPeriodDataPointsQuery>;
|
||||
export type FundingPeriodDataPointsLazyQueryHookResult = ReturnType<typeof useFundingPeriodDataPointsLazyQuery>;
|
||||
export type FundingPeriodDataPointsQueryResult = Apollo.QueryResult<FundingPeriodDataPointsQuery, FundingPeriodDataPointsQueryVariables>;
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
export * from './funding-periods';
|
||||
export * from './market-candles';
|
||||
export * from './market-data';
|
||||
export * from './markets';
|
||||
|
||||
+4
-20
@@ -3,23 +3,23 @@ import * as Types from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type MarketDataUpdateFieldsFragment = { __typename?: 'ObservableMarketData', marketId: string, auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null };
|
||||
export type MarketDataUpdateFieldsFragment = { __typename?: 'ObservableMarketData', marketId: string, auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null };
|
||||
|
||||
export type MarketDataUpdateSubscriptionVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type MarketDataUpdateSubscription = { __typename?: 'Subscription', marketsData: Array<{ __typename?: 'ObservableMarketData', marketId: string, auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null }> };
|
||||
export type MarketDataUpdateSubscription = { __typename?: 'Subscription', marketsData: Array<{ __typename?: 'ObservableMarketData', marketId: string, auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null }> };
|
||||
|
||||
export type MarketDataFieldsFragment = { __typename?: 'MarketData', auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, market: { __typename?: 'Market', id: string }, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null };
|
||||
export type MarketDataFieldsFragment = { __typename?: 'MarketData', auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, market: { __typename?: 'Market', id: string }, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null };
|
||||
|
||||
export type MarketDataQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type MarketDataQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', data?: { __typename?: 'MarketData', auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, market: { __typename?: 'Market', id: string }, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null } | null } }> } | null };
|
||||
export type MarketDataQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', data?: { __typename?: 'MarketData', auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, market: { __typename?: 'Market', id: string }, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null } | null } }> } | null };
|
||||
|
||||
export const MarketDataUpdateFieldsFragmentDoc = gql`
|
||||
fragment MarketDataUpdateFields on ObservableMarketData {
|
||||
@@ -34,14 +34,6 @@ export const MarketDataUpdateFieldsFragmentDoc = gql`
|
||||
bestStaticBidVolume
|
||||
bestStaticOfferPrice
|
||||
bestStaticOfferVolume
|
||||
productData {
|
||||
... on PerpetualData {
|
||||
fundingRate
|
||||
fundingPayment
|
||||
externalTwap
|
||||
internalTwap
|
||||
}
|
||||
}
|
||||
indicativePrice
|
||||
indicativeVolume
|
||||
marketState
|
||||
@@ -82,14 +74,6 @@ export const MarketDataFieldsFragmentDoc = gql`
|
||||
bestStaticBidVolume
|
||||
bestStaticOfferPrice
|
||||
bestStaticOfferVolume
|
||||
productData {
|
||||
... on PerpetualData {
|
||||
fundingRate
|
||||
fundingPayment
|
||||
externalTwap
|
||||
internalTwap
|
||||
}
|
||||
}
|
||||
indicativePrice
|
||||
indicativeVolume
|
||||
marketState
|
||||
|
||||
+65
-9
File diff suppressed because one or more lines are too long
@@ -1,98 +1,31 @@
|
||||
fragment DataSourceFilter on Filter {
|
||||
key {
|
||||
name
|
||||
type
|
||||
numberDecimalPlaces
|
||||
}
|
||||
}
|
||||
|
||||
fragment DataSource on DataSourceSpec {
|
||||
id
|
||||
data {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
fragment DataSource on DataSourceDefinition {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
}
|
||||
filters {
|
||||
...DataSourceFilter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
... on DataSourceDefinitionInternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfigurationTime {
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
... on DataSourceSpecConfigurationTimeTrigger {
|
||||
__typename
|
||||
triggers {
|
||||
initial
|
||||
every
|
||||
}
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment Future on Future {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
decimals
|
||||
quantum
|
||||
}
|
||||
dataSourceSpecForSettlementData {
|
||||
...DataSource
|
||||
}
|
||||
dataSourceSpecForTradingTermination {
|
||||
...DataSource
|
||||
}
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
tradingTerminationProperty
|
||||
}
|
||||
}
|
||||
|
||||
fragment Perpetual on Perpetual {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
decimals
|
||||
quantum
|
||||
}
|
||||
dataSourceSpecForSettlementData {
|
||||
...DataSource
|
||||
}
|
||||
dataSourceSpecForSettlementSchedule {
|
||||
...DataSource
|
||||
}
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
settlementScheduleProperty
|
||||
... on DataSourceDefinitionInternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfigurationTime {
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +36,7 @@ query MarketInfo($marketId: ID!) {
|
||||
positionDecimalPlaces
|
||||
state
|
||||
tradingMode
|
||||
lpPriceRange
|
||||
proposal {
|
||||
id
|
||||
rationale {
|
||||
@@ -167,10 +101,29 @@ query MarketInfo($marketId: ID!) {
|
||||
}
|
||||
product {
|
||||
... on Future {
|
||||
...Future
|
||||
}
|
||||
... on Perpetual {
|
||||
...Perpetual
|
||||
quoteName
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
decimals
|
||||
}
|
||||
dataSourceSpecForSettlementData {
|
||||
id
|
||||
data {
|
||||
...DataSource
|
||||
}
|
||||
}
|
||||
dataSourceSpecForTradingTermination {
|
||||
id
|
||||
data {
|
||||
...DataSource
|
||||
}
|
||||
}
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
tradingTerminationProperty
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+47
-104
File diff suppressed because one or more lines are too long
@@ -23,12 +23,12 @@ import type { MarketInfo } from './market-info-data-provider';
|
||||
import { MarketProposalNotification } from '@vegaprotocol/proposals';
|
||||
import {
|
||||
CurrentFeesInfoPanel,
|
||||
FundingInfoPanel,
|
||||
InstrumentInfoPanel,
|
||||
InsurancePoolInfoPanel,
|
||||
KeyDetailsInfoPanel,
|
||||
LiquidityInfoPanel,
|
||||
LiquidityMonitoringParametersInfoPanel,
|
||||
LiquidityPriceRangeInfoPanel,
|
||||
MarketPriceInfoPanel,
|
||||
MarketVolumeInfoPanel,
|
||||
MetadataInfoPanel,
|
||||
@@ -40,15 +40,8 @@ import {
|
||||
SettlementAssetInfoPanel,
|
||||
SuccessionLineInfoPanel,
|
||||
} from './market-info-panels';
|
||||
import type { DataSourceDefinition } from '@vegaprotocol/types';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import {
|
||||
getDataSourceSpecForSettlementSchedule,
|
||||
getDataSourceSpecForSettlementData,
|
||||
getDataSourceSpecForTradingTermination,
|
||||
isPerpetual,
|
||||
isFuture,
|
||||
getSigners,
|
||||
} from '../../product';
|
||||
|
||||
export interface MarketInfoAccordionProps {
|
||||
market: MarketInfo;
|
||||
@@ -95,27 +88,24 @@ export const MarketInfoAccordion = ({
|
||||
market.accountsConnection?.edges
|
||||
);
|
||||
|
||||
const { product } = market.tradableInstrument.instrument;
|
||||
const settlementDataSource = getDataSourceSpecForSettlementData(product);
|
||||
const terminationDataSource = getDataSourceSpecForTradingTermination(product);
|
||||
const settlementScheduleDataSource =
|
||||
getDataSourceSpecForSettlementSchedule(product);
|
||||
const settlementData = market.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.data as DataSourceDefinition;
|
||||
const terminationData = market.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForTradingTermination.data as DataSourceDefinition;
|
||||
|
||||
const showOneOracleSection =
|
||||
(isFuture(product) &&
|
||||
settlementDataSource &&
|
||||
terminationDataSource &&
|
||||
isEqual(
|
||||
getSigners(settlementDataSource),
|
||||
getSigners(terminationDataSource)
|
||||
)) ||
|
||||
(isPerpetual(product) &&
|
||||
settlementDataSource &&
|
||||
settlementScheduleDataSource &&
|
||||
isEqual(
|
||||
getSigners(settlementDataSource),
|
||||
getSigners(settlementScheduleDataSource)
|
||||
));
|
||||
const getSigners = (data: DataSourceDefinition) => {
|
||||
if (data.sourceType.__typename === 'DataSourceDefinitionExternal') {
|
||||
const signers = data.sourceType.sourceType.signers || [];
|
||||
|
||||
return signers.map(({ signer }, i) => {
|
||||
return (
|
||||
(signer.__typename === 'ETHAddress' && signer.address) ||
|
||||
(signer.__typename === 'PubKey' && signer.key)
|
||||
);
|
||||
});
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -168,16 +158,7 @@ export const MarketInfoAccordion = ({
|
||||
title={t('Instrument')}
|
||||
content={<InstrumentInfoPanel market={market} />}
|
||||
/>
|
||||
{settlementScheduleDataSource && (
|
||||
<AccordionItem
|
||||
itemId="funding"
|
||||
title={t('Funding')}
|
||||
content={
|
||||
<FundingInfoPanel dataSource={settlementScheduleDataSource} />
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{showOneOracleSection ? (
|
||||
{isEqual(getSigners(settlementData), getSigners(terminationData)) ? (
|
||||
<AccordionItem
|
||||
itemId="oracles"
|
||||
title={t('Oracle')}
|
||||
@@ -189,32 +170,17 @@ export const MarketInfoAccordion = ({
|
||||
<>
|
||||
<AccordionItem
|
||||
itemId="settlement-oracle"
|
||||
title={t('Settlement oracle')}
|
||||
title={t('Settlement Oracle')}
|
||||
content={
|
||||
<OracleInfoPanel market={market} type="settlementData" />
|
||||
}
|
||||
/>
|
||||
{isPerpetual(product) && (
|
||||
<AccordionItem
|
||||
itemId="settlement-schedule-oracle"
|
||||
title={t('Settlement schedule oracle')}
|
||||
content={
|
||||
<OracleInfoPanel
|
||||
market={market}
|
||||
type="settlementSchedule"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{isFuture(product) && (
|
||||
<AccordionItem
|
||||
itemId="termination-oracle"
|
||||
title={t('Termination oracle')}
|
||||
content={
|
||||
<OracleInfoPanel market={market} type="termination" />
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<AccordionItem
|
||||
itemId="termination-oracle"
|
||||
title={t('Termination Oracle')}
|
||||
content={<OracleInfoPanel market={market} type="termination" />}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<AccordionItem
|
||||
@@ -261,7 +227,7 @@ export const MarketInfoAccordion = ({
|
||||
}
|
||||
)}
|
||||
<AccordionItem
|
||||
itemId="liquidity-monitoring-parameters"
|
||||
itemId="liqudity-monitoring-parameters"
|
||||
title={t('Liquidity monitoring parameters')}
|
||||
content={<LiquidityMonitoringParametersInfoPanel market={market} />}
|
||||
/>
|
||||
@@ -284,6 +250,11 @@ export const MarketInfoAccordion = ({
|
||||
</LiquidityInfoPanel>
|
||||
}
|
||||
/>
|
||||
<AccordionItem
|
||||
itemId="liquidity-price-range"
|
||||
title={t('Liquidity price range')}
|
||||
content={<LiquidityPriceRangeInfoPanel market={market} />}
|
||||
/>
|
||||
</Accordion>
|
||||
</div>
|
||||
{VEGA_TOKEN_URL && market.proposal?.id && (
|
||||
|
||||
@@ -15,9 +15,9 @@ import {
|
||||
VegaIconNames,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import {
|
||||
addDecimalsFormatNumber,
|
||||
formatNumber,
|
||||
formatNumberPercentage,
|
||||
getDateTimeFormat,
|
||||
getMarketExpiryDateFormatted,
|
||||
} from '@vegaprotocol/utils';
|
||||
import type { Get } from 'type-fest';
|
||||
@@ -55,11 +55,8 @@ import {
|
||||
useSuccessorMarketQuery,
|
||||
} from '../../__generated__';
|
||||
import { useSuccessorMarketProposalDetailsQuery } from '@vegaprotocol/proposals';
|
||||
import { getQuoteName, getAsset } from '../../market-utils';
|
||||
import classNames from 'classnames';
|
||||
import compact from 'lodash/compact';
|
||||
import type { DataSourceFragment } from './__generated__/MarketInfo';
|
||||
import { formatDuration } from 'date-fns';
|
||||
|
||||
type MarketInfoProps = {
|
||||
market: MarketInfo;
|
||||
@@ -87,8 +84,10 @@ export const CurrentFeesInfoPanel = ({ market }: MarketInfoProps) => (
|
||||
);
|
||||
|
||||
export const MarketPriceInfoPanel = ({ market }: MarketInfoProps) => {
|
||||
const assetSymbol = getAsset(market).symbol;
|
||||
const quoteUnit = getQuoteName(market);
|
||||
const assetSymbol =
|
||||
market?.tradableInstrument.instrument.product?.settlementAsset.symbol || '';
|
||||
const quoteUnit =
|
||||
market?.tradableInstrument.instrument.product?.quoteName || '';
|
||||
const { data } = useDataProvider({
|
||||
dataProvider: marketDataProvider,
|
||||
variables: { marketId: market.id },
|
||||
@@ -100,11 +99,11 @@ export const MarketPriceInfoPanel = ({ market }: MarketInfoProps) => {
|
||||
markPrice: data?.markPrice,
|
||||
bestBidPrice: data?.bestBidPrice,
|
||||
bestOfferPrice: data?.bestOfferPrice,
|
||||
quoteUnit,
|
||||
quoteUnit: market.tradableInstrument.instrument.product.quoteName,
|
||||
}}
|
||||
decimalPlaces={market.decimalPlaces}
|
||||
/>
|
||||
<p className="mt-2 text-xs">
|
||||
<p className="text-xs mt-2">
|
||||
{t(
|
||||
'There is 1 unit of the settlement asset (%s) to every 1 quote unit (%s).',
|
||||
[assetSymbol, quoteUnit]
|
||||
@@ -151,15 +150,17 @@ export const InsurancePoolInfoPanel = ({
|
||||
Get<MarketInfoWithData, 'accountsConnection.edges[0].node'>
|
||||
>;
|
||||
} & MarketInfoProps) => {
|
||||
const asset = getAsset(market);
|
||||
|
||||
const assetSymbol =
|
||||
market?.tradableInstrument.instrument.product?.settlementAsset.symbol || '';
|
||||
return (
|
||||
<MarketInfoTable
|
||||
data={{
|
||||
balance: account.balance,
|
||||
}}
|
||||
assetSymbol={asset.symbol}
|
||||
decimalPlaces={asset.decimals}
|
||||
assetSymbol={assetSymbol}
|
||||
decimalPlaces={
|
||||
market.tradableInstrument.instrument.product.settlementAsset.decimals
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -201,7 +202,8 @@ export const KeyDetailsInfoPanel = ({
|
||||
skip: !parentMarket?.proposal?.id,
|
||||
});
|
||||
|
||||
const assetDecimals = getAsset(market).decimals;
|
||||
const assetDecimals =
|
||||
market.tradableInstrument.instrument.product.settlementAsset.decimals;
|
||||
|
||||
return (
|
||||
<MarketInfoTable
|
||||
@@ -252,7 +254,9 @@ export const KeyDetailsInfoPanel = ({
|
||||
],
|
||||
marketDecimalPlaces: parentMarket?.decimalPlaces,
|
||||
positionDecimalPlaces: parentMarket?.positionDecimalPlaces,
|
||||
settlementAssetDecimalPlaces: assetDecimals,
|
||||
settlementAssetDecimalPlaces:
|
||||
parentMarket?.tradableInstrument?.instrument?.product
|
||||
?.settlementAsset?.decimals,
|
||||
}
|
||||
}
|
||||
/>
|
||||
@@ -313,12 +317,12 @@ const SuccessionLineItem = ({
|
||||
{marketData ? (
|
||||
marketData.tradableInstrument.instrument.name
|
||||
) : (
|
||||
<span className="block h-4 w-28 bg-vega-clight-500 dark:bg-vega-cdark-500 animate-pulse"></span>
|
||||
<span className="block w-28 h-4 bg-vega-clight-500 dark:bg-vega-cdark-500 animate-pulse"></span>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
data-testid="succession-line-item-market-id"
|
||||
className="mt-1 text-xs truncate"
|
||||
className="text-xs truncate mt-1"
|
||||
>
|
||||
{marketId}
|
||||
</div>
|
||||
@@ -327,7 +331,7 @@ const SuccessionLineItem = ({
|
||||
};
|
||||
|
||||
const SuccessionLink = () => (
|
||||
<div className="leading-none text-center" aria-hidden>
|
||||
<div className="text-center leading-none" aria-hidden>
|
||||
<VegaIcon name={VegaIconNames.ARROW_DOWN} size={12} />
|
||||
</div>
|
||||
);
|
||||
@@ -382,32 +386,36 @@ export const SuccessionLineInfoPanel = ({
|
||||
export const InstrumentInfoPanel = ({
|
||||
market,
|
||||
parentMarket,
|
||||
}: MarketInfoProps) => {
|
||||
return (
|
||||
<MarketInfoTable
|
||||
data={{
|
||||
marketName: market.tradableInstrument.instrument.name,
|
||||
code: market.tradableInstrument.instrument.code,
|
||||
productType: market.tradableInstrument.instrument.product.__typename,
|
||||
quoteName: getQuoteName(market),
|
||||
}}
|
||||
parentData={
|
||||
parentMarket && {
|
||||
marketName: parentMarket?.tradableInstrument?.instrument?.name,
|
||||
code: parentMarket?.tradableInstrument?.instrument?.code,
|
||||
productType:
|
||||
parentMarket?.tradableInstrument?.instrument?.product?.__typename,
|
||||
quoteName: getQuoteName(parentMarket),
|
||||
}
|
||||
}: MarketInfoProps) => (
|
||||
<MarketInfoTable
|
||||
data={{
|
||||
marketName: market.tradableInstrument.instrument.name,
|
||||
code: market.tradableInstrument.instrument.code,
|
||||
productType: market.tradableInstrument.instrument.product.__typename,
|
||||
quoteName: market.tradableInstrument.instrument.product.quoteName,
|
||||
}}
|
||||
parentData={
|
||||
parentMarket && {
|
||||
marketName: parentMarket?.tradableInstrument?.instrument?.name,
|
||||
code: parentMarket?.tradableInstrument?.instrument?.code,
|
||||
productType:
|
||||
parentMarket?.tradableInstrument?.instrument?.product?.__typename,
|
||||
quoteName:
|
||||
parentMarket?.tradableInstrument?.instrument?.product?.quoteName,
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
export const SettlementAssetInfoPanel = ({ market }: MarketInfoProps) => {
|
||||
const assetSymbol = getAsset(market).symbol;
|
||||
const quoteUnit = getQuoteName(market);
|
||||
const assetId = useMemo(() => getAsset(market).id, [market]);
|
||||
const assetSymbol =
|
||||
market?.tradableInstrument.instrument.product?.settlementAsset.symbol || '';
|
||||
const quoteUnit =
|
||||
market?.tradableInstrument.instrument.product?.quoteName || '';
|
||||
const assetId = useMemo(
|
||||
() => market?.tradableInstrument.instrument.product?.settlementAsset.id,
|
||||
[market]
|
||||
);
|
||||
|
||||
const { data: asset } = useAssetDataProvider(assetId ?? '');
|
||||
return asset ? (
|
||||
@@ -419,7 +427,7 @@ export const SettlementAssetInfoPanel = ({ market }: MarketInfoProps) => {
|
||||
dtClassName="text-black dark:text-white text-ui !px-0 !font-normal"
|
||||
ddClassName="text-black dark:text-white text-ui !px-0 !font-normal max-w-full"
|
||||
/>
|
||||
<p className="mt-4 text-xs">
|
||||
<p className="text-xs mt-4">
|
||||
{t(
|
||||
'There is 1 unit of the settlement asset (%s) to every 1 quote unit (%s).',
|
||||
[assetSymbol, quoteUnit]
|
||||
@@ -580,7 +588,8 @@ export const PriceMonitoringBoundsInfoPanel = ({
|
||||
variables: { marketId: market.id },
|
||||
});
|
||||
|
||||
const quoteUnit = getQuoteName(market);
|
||||
const quoteUnit =
|
||||
market?.tradableInstrument.instrument.product?.quoteName || '';
|
||||
|
||||
const trigger =
|
||||
market.priceMonitoringSettings?.parameters?.triggers?.[triggerIndex];
|
||||
@@ -595,7 +604,7 @@ export const PriceMonitoringBoundsInfoPanel = ({
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<div className="mb-2 text-sm grid grid-cols-2">
|
||||
<div className="grid grid-cols-2 text-sm mb-2">
|
||||
<p className="col-span-1">
|
||||
{t('%s probability price bounds', [
|
||||
formatNumberPercentage(
|
||||
@@ -603,7 +612,7 @@ export const PriceMonitoringBoundsInfoPanel = ({
|
||||
),
|
||||
])}
|
||||
</p>
|
||||
<p className="text-right col-span-1">
|
||||
<p className="col-span-1 text-right">
|
||||
{t('Within %s seconds', [formatNumber(trigger.horizonSecs)])}
|
||||
</p>
|
||||
</div>
|
||||
@@ -617,7 +626,7 @@ export const PriceMonitoringBoundsInfoPanel = ({
|
||||
assetSymbol={quoteUnit}
|
||||
/>
|
||||
)}
|
||||
<p className="mt-2 text-xs">
|
||||
<p className="text-xs mt-2">
|
||||
{t('Results in %s seconds auction if breached', [
|
||||
trigger.auctionExtensionSecs.toString(),
|
||||
])}
|
||||
@@ -655,7 +664,10 @@ export const LiquidityMonitoringParametersInfoPanel = ({
|
||||
};
|
||||
|
||||
export const LiquidityInfoPanel = ({ market, children }: MarketInfoProps) => {
|
||||
const asset = getAsset(market);
|
||||
const assetDecimals =
|
||||
market.tradableInstrument.instrument.product.settlementAsset.decimals;
|
||||
const assetSymbol =
|
||||
market?.tradableInstrument.instrument.product?.settlementAsset.symbol || '';
|
||||
const { data } = useDataProvider({
|
||||
dataProvider: marketDataProvider,
|
||||
variables: { marketId: market.id },
|
||||
@@ -668,45 +680,112 @@ export const LiquidityInfoPanel = ({ market, children }: MarketInfoProps) => {
|
||||
suppliedStake: data?.suppliedStake,
|
||||
marketValueProxy: data?.marketValueProxy,
|
||||
}}
|
||||
decimalPlaces={asset.decimals}
|
||||
assetSymbol={asset.symbol}
|
||||
decimalPlaces={assetDecimals}
|
||||
assetSymbol={assetSymbol}
|
||||
/>
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const FundingInfoPanel = ({
|
||||
dataSource,
|
||||
}: {
|
||||
dataSource: DataSourceFragment;
|
||||
}) => {
|
||||
const sourceType = dataSource.data.sourceType.sourceType;
|
||||
if (
|
||||
sourceType.__typename !== 'DataSourceSpecConfigurationTimeTrigger' ||
|
||||
!sourceType.triggers?.[0]?.every
|
||||
) {
|
||||
return null;
|
||||
export const LiquidityPriceRangeInfoPanel = ({
|
||||
market,
|
||||
parentMarket,
|
||||
}: MarketInfoProps) => {
|
||||
const quoteUnit =
|
||||
market?.tradableInstrument.instrument.product?.quoteName || '';
|
||||
const parentQuoteUnit =
|
||||
parentMarket?.tradableInstrument.instrument.product?.quoteName || '';
|
||||
|
||||
const liquidityPriceRange = formatNumberPercentage(
|
||||
new BigNumber(market.lpPriceRange).times(100)
|
||||
);
|
||||
const parentLiquidityPriceRange = parentMarket
|
||||
? formatNumberPercentage(
|
||||
new BigNumber(parentMarket.lpPriceRange).times(100)
|
||||
)
|
||||
: null;
|
||||
|
||||
const { data } = useDataProvider({
|
||||
dataProvider: marketDataProvider,
|
||||
variables: { marketId: market.id },
|
||||
});
|
||||
|
||||
const { data: parentMarketData } = useDataProvider({
|
||||
dataProvider: marketDataProvider,
|
||||
variables: { marketId: parentMarket?.id || '' },
|
||||
skip: !parentMarket,
|
||||
});
|
||||
|
||||
let parentData;
|
||||
|
||||
if (parentMarket && parentMarketData && quoteUnit === parentQuoteUnit) {
|
||||
parentData = {
|
||||
liquidityPriceRange: `${parentLiquidityPriceRange} of mid price`,
|
||||
lowestPrice:
|
||||
parentMarketData?.midPrice &&
|
||||
`${addDecimalsFormatNumber(
|
||||
new BigNumber(1)
|
||||
.minus(parentMarket.lpPriceRange)
|
||||
.times(parentMarketData.midPrice)
|
||||
.toString(),
|
||||
parentMarket.decimalPlaces
|
||||
)} ${quoteUnit}`,
|
||||
highestPrice:
|
||||
parentMarketData?.midPrice &&
|
||||
`${addDecimalsFormatNumber(
|
||||
new BigNumber(1)
|
||||
.plus(parentMarket.lpPriceRange)
|
||||
.times(parentMarketData.midPrice)
|
||||
.toString(),
|
||||
parentMarket.decimalPlaces
|
||||
)} ${quoteUnit}`,
|
||||
};
|
||||
}
|
||||
const { every, initial } = sourceType.triggers[0];
|
||||
const hours = Math.floor(every / (60 * 60));
|
||||
const minutes = Math.floor(every / 60) % 60;
|
||||
const initialLabel = initial
|
||||
? ` ${t('from')} ${getDateTimeFormat().format(new Date(initial * 1000))}`
|
||||
: '';
|
||||
return `${t('every')} ${formatDuration({
|
||||
hours,
|
||||
minutes,
|
||||
})} ${initialLabel}`;
|
||||
|
||||
return (
|
||||
<>
|
||||
<p className="text-sm mb-2">
|
||||
{`For liquidity orders to count towards a commitment, they must be
|
||||
within the liquidity monitoring bounds.`}
|
||||
</p>
|
||||
<p className="text-sm mb-2">
|
||||
{`The liquidity price range is a ${liquidityPriceRange} difference from the mid
|
||||
price.`}
|
||||
</p>
|
||||
<MarketInfoTable
|
||||
data={{
|
||||
liquidityPriceRange: `${liquidityPriceRange} of mid price`,
|
||||
lowestPrice:
|
||||
data?.midPrice &&
|
||||
`${addDecimalsFormatNumber(
|
||||
new BigNumber(1)
|
||||
.minus(market.lpPriceRange)
|
||||
.times(data.midPrice)
|
||||
.toString(),
|
||||
market.decimalPlaces
|
||||
)} ${quoteUnit}`,
|
||||
highestPrice:
|
||||
data?.midPrice &&
|
||||
`${addDecimalsFormatNumber(
|
||||
new BigNumber(1)
|
||||
.plus(market.lpPriceRange)
|
||||
.times(data.midPrice)
|
||||
.toString(),
|
||||
market.decimalPlaces
|
||||
)} ${quoteUnit}`,
|
||||
}}
|
||||
parentData={parentData}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const OracleInfoPanel = ({
|
||||
market,
|
||||
type,
|
||||
parentMarket,
|
||||
}: MarketInfoProps & {
|
||||
type: 'settlementData' | 'termination' | 'settlementSchedule';
|
||||
}) => {
|
||||
}: MarketInfoProps & { type: 'settlementData' | 'termination' }) => {
|
||||
// If this is a successor market, this component will only receive parent market
|
||||
// data if the termination or settlement data is different from the parent.
|
||||
const product = market.tradableInstrument.instrument.product;
|
||||
@@ -714,14 +793,27 @@ export const OracleInfoPanel = ({
|
||||
const { VEGA_EXPLORER_URL, ORACLE_PROOFS_URL } = useEnvironment();
|
||||
const { data } = useOracleProofs(ORACLE_PROOFS_URL);
|
||||
|
||||
const { dataSourceSpecId, dataSourceSpec } = getDataSourceSpec(product, type);
|
||||
const dataSourceSpecId =
|
||||
type === 'settlementData'
|
||||
? product.dataSourceSpecForSettlementData.id
|
||||
: product.dataSourceSpecForTradingTermination.id;
|
||||
|
||||
let parentDataSourceSpecId, parentDataSourceSpec;
|
||||
if (parentProduct) {
|
||||
parentDataSourceSpec = getDataSourceSpec(parentProduct, type);
|
||||
parentDataSourceSpecId = parentDataSourceSpec.dataSourceSpecId;
|
||||
parentDataSourceSpec = parentDataSourceSpec.dataSourceSpec;
|
||||
}
|
||||
const parentDataSourceSpecId =
|
||||
type === 'settlementData'
|
||||
? parentProduct?.dataSourceSpecForSettlementData?.id
|
||||
: parentProduct?.dataSourceSpecForTradingTermination?.id;
|
||||
|
||||
const dataSourceSpec = (
|
||||
type === 'settlementData'
|
||||
? product.dataSourceSpecForSettlementData.data
|
||||
: product.dataSourceSpecForTradingTermination.data
|
||||
) as DataSourceDefinition;
|
||||
|
||||
const parentDataSourceSpec =
|
||||
type === 'settlementData'
|
||||
? parentProduct?.dataSourceSpecForSettlementData?.data
|
||||
: (parentProduct?.dataSourceSpecForTradingTermination
|
||||
?.data as DataSourceDefinition);
|
||||
|
||||
const shouldShowParentData =
|
||||
parentMarket !== undefined &&
|
||||
@@ -745,7 +837,7 @@ export const OracleInfoPanel = ({
|
||||
parentDataSourceSpec &&
|
||||
parentDataSourceSpecId &&
|
||||
parentProduct && (
|
||||
<div className="flex flex-col line-through gap-2 text-vega-dark-300">
|
||||
<div className="flex flex-col gap-2 text-vega-dark-300 line-through">
|
||||
<DataSourceProof
|
||||
data-testid="oracle-proof-links"
|
||||
data={parentDataSourceSpec}
|
||||
@@ -754,44 +846,42 @@ export const OracleInfoPanel = ({
|
||||
dataSourceSpecId={parentDataSourceSpecId}
|
||||
/>
|
||||
|
||||
{dataSourceSpecId && (
|
||||
<ExternalLink
|
||||
data-testid="oracle-spec-links"
|
||||
href={`${VEGA_EXPLORER_URL}/oracles/${dataSourceSpecId}`}
|
||||
>
|
||||
{type === 'settlementData'
|
||||
? t('View settlement data specification')
|
||||
: type === 'settlementSchedule'
|
||||
? t('View settlement schedule specification')
|
||||
: t('View termination specification')}
|
||||
</ExternalLink>
|
||||
)}
|
||||
<ExternalLink
|
||||
data-testid="oracle-spec-links"
|
||||
href={`${VEGA_EXPLORER_URL}/oracles/${
|
||||
type === 'settlementData'
|
||||
? parentProduct.dataSourceSpecForSettlementData.id
|
||||
: parentProduct.dataSourceSpecForTradingTermination.id
|
||||
}`}
|
||||
>
|
||||
{type === 'settlementData'
|
||||
? t('View settlement data specification')
|
||||
: t('View termination specification')}
|
||||
</ExternalLink>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
{dataSourceSpecId && dataSourceSpec && (
|
||||
<DataSourceProof
|
||||
data-testid="oracle-proof-links"
|
||||
data={dataSourceSpec}
|
||||
providers={data}
|
||||
type={type}
|
||||
dataSourceSpecId={dataSourceSpecId}
|
||||
/>
|
||||
)}
|
||||
<DataSourceProof
|
||||
data-testid="oracle-proof-links"
|
||||
data={dataSourceSpec}
|
||||
providers={data}
|
||||
type={type}
|
||||
dataSourceSpecId={dataSourceSpecId}
|
||||
/>
|
||||
|
||||
{dataSourceSpecId && (
|
||||
<ExternalLink
|
||||
data-testid="oracle-spec-links"
|
||||
href={`${VEGA_EXPLORER_URL}/oracles/${dataSourceSpecId}`}
|
||||
>
|
||||
{type === 'settlementData'
|
||||
? t('View settlement data specification')
|
||||
: type === 'settlementSchedule'
|
||||
? t('View settlement schedule specification')
|
||||
: t('View termination specification')}
|
||||
</ExternalLink>
|
||||
)}
|
||||
<ExternalLink
|
||||
data-testid="oracle-spec-links"
|
||||
href={`${VEGA_EXPLORER_URL}/oracles/${
|
||||
type === 'settlementData'
|
||||
? product.dataSourceSpecForSettlementData.id
|
||||
: product.dataSourceSpecForTradingTermination.id
|
||||
}`}
|
||||
>
|
||||
{type === 'settlementData'
|
||||
? t('View settlement data specification')
|
||||
: t('View termination specification')}
|
||||
</ExternalLink>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
@@ -806,14 +896,11 @@ export const DataSourceProof = ({
|
||||
}: {
|
||||
data: DataSourceDefinition;
|
||||
providers: Provider[] | undefined;
|
||||
type: 'settlementData' | 'termination' | 'settlementSchedule';
|
||||
type: 'settlementData' | 'termination';
|
||||
dataSourceSpecId: string;
|
||||
}) => {
|
||||
if (data.sourceType.__typename === 'DataSourceDefinitionExternal') {
|
||||
const signers =
|
||||
('signers' in data.sourceType.sourceType &&
|
||||
data.sourceType.sourceType.signers) ||
|
||||
[];
|
||||
const signers = data.sourceType.sourceType.signers || [];
|
||||
|
||||
if (!providers?.length) {
|
||||
return <NoOracleProof type={type} />;
|
||||
@@ -839,7 +926,7 @@ export const DataSourceProof = ({
|
||||
return (
|
||||
<div>
|
||||
<h3>{t('Internal conditions')}</h3>
|
||||
{data.sourceType.sourceType?.conditions?.map((condition, i) => {
|
||||
{data.sourceType.sourceType?.conditions.map((condition, i) => {
|
||||
if (!condition) return null;
|
||||
return (
|
||||
<p key={i}>
|
||||
@@ -861,59 +948,6 @@ export const DataSourceProof = ({
|
||||
return <div>{t('Invalid data source')}</div>;
|
||||
};
|
||||
|
||||
export const getDataSourceSpec = (
|
||||
product: MarketInfo['tradableInstrument']['instrument']['product'],
|
||||
type: 'settlementData' | 'termination' | 'settlementSchedule'
|
||||
): {
|
||||
dataSourceSpecId: string | undefined;
|
||||
dataSourceSpec: DataSourceDefinition | undefined;
|
||||
} => {
|
||||
let dataSourceSpecId, dataSourceSpec;
|
||||
|
||||
switch (type) {
|
||||
case 'settlementData':
|
||||
switch (product.__typename) {
|
||||
case 'Future':
|
||||
dataSourceSpecId = product.dataSourceSpecForSettlementData.id;
|
||||
dataSourceSpec = product.dataSourceSpecForSettlementData.data;
|
||||
break;
|
||||
case 'Perpetual':
|
||||
dataSourceSpecId = product.dataSourceSpecForSettlementData.id;
|
||||
dataSourceSpec = product.dataSourceSpecForSettlementData.data;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'termination':
|
||||
switch (product.__typename) {
|
||||
case 'Future':
|
||||
dataSourceSpecId = product.dataSourceSpecForTradingTermination.id;
|
||||
dataSourceSpec = product.dataSourceSpecForTradingTermination.data;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'settlementSchedule':
|
||||
switch (product.__typename) {
|
||||
case 'Perpetual':
|
||||
dataSourceSpecId = product.dataSourceSpecForSettlementSchedule.id;
|
||||
dataSourceSpec = product.dataSourceSpecForSettlementSchedule.data;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return {
|
||||
dataSourceSpecId,
|
||||
dataSourceSpec: dataSourceSpec as DataSourceDefinition,
|
||||
};
|
||||
};
|
||||
|
||||
const getSignerProviders = (signer: SignerKind, providers: Provider[]) =>
|
||||
providers.filter((p) => {
|
||||
if (signer.__typename === 'PubKey') {
|
||||
@@ -945,7 +979,7 @@ const OracleLink = ({
|
||||
}: {
|
||||
providers: Provider[];
|
||||
signer: SignerKind;
|
||||
type: 'settlementData' | 'termination' | 'settlementSchedule';
|
||||
type: 'settlementData' | 'termination';
|
||||
dataSourceSpecId: string;
|
||||
}) => {
|
||||
const signerProviders = getSignerProviders(signer, providers);
|
||||
@@ -970,7 +1004,7 @@ const OracleLink = ({
|
||||
const NoOracleProof = ({
|
||||
type,
|
||||
}: {
|
||||
type: 'settlementData' | 'termination' | 'settlementSchedule';
|
||||
type: 'settlementData' | 'termination';
|
||||
}) => {
|
||||
return (
|
||||
<p>
|
||||
|
||||
@@ -92,6 +92,7 @@ export const marketInfoQuery = (
|
||||
short: '0.008571790367285281',
|
||||
long: '0.008508132993273576',
|
||||
},
|
||||
lpPriceRange: '0.02',
|
||||
liquidityMonitoringParameters: {
|
||||
triggeringRatio: '0.7',
|
||||
targetStakeParameters: {
|
||||
@@ -124,7 +125,6 @@ export const marketInfoQuery = (
|
||||
quoteName: 'BTC',
|
||||
settlementAsset: {
|
||||
__typename: 'Asset',
|
||||
quantum: '1',
|
||||
id: 'market-0',
|
||||
symbol: 'tBTC',
|
||||
name: 'tBTC TEST',
|
||||
|
||||
@@ -252,35 +252,26 @@ export const OracleFullProfile = ({
|
||||
>
|
||||
{MarketStateMapping[market.state]}
|
||||
</div>
|
||||
{(market.tradableInstrument.instrument.product.__typename ===
|
||||
'Future' ||
|
||||
market.tradableInstrument.instrument.product.__typename ===
|
||||
'Perpetual') &&
|
||||
market.tradableInstrument.instrument.product && (
|
||||
<div className="col-span-1">
|
||||
{
|
||||
<ExternalLink
|
||||
href={`${VEGA_EXPLORER_URL}/oracles/${market.tradableInstrument?.instrument.product?.dataSourceSpecForSettlementData.id}`}
|
||||
data-testid="block-explorer-link-settlement"
|
||||
>
|
||||
{t('Settlement')}
|
||||
</ExternalLink>
|
||||
}
|
||||
</div>
|
||||
)}
|
||||
{'dataSourceSpecForTradingTermination' in
|
||||
market.tradableInstrument.instrument.product && (
|
||||
<div className="col-span-1">
|
||||
{
|
||||
<ExternalLink
|
||||
href={`${VEGA_EXPLORER_URL}/oracles/${market.tradableInstrument?.instrument.product?.dataSourceSpecForTradingTermination.id}`}
|
||||
data-testid="block-explorer-link-termination"
|
||||
>
|
||||
{t('Termination')}
|
||||
</ExternalLink>
|
||||
}
|
||||
</div>
|
||||
)}
|
||||
<div className="col-span-1">
|
||||
{
|
||||
<ExternalLink
|
||||
href={`${VEGA_EXPLORER_URL}/oracles/${market.tradableInstrument?.instrument.product?.dataSourceSpecForSettlementData.id}`}
|
||||
data-testid="block-explorer-link-settlement"
|
||||
>
|
||||
{t('Settlement')}
|
||||
</ExternalLink>
|
||||
}
|
||||
</div>
|
||||
<div className="col-span-1">
|
||||
{
|
||||
<ExternalLink
|
||||
href={`${VEGA_EXPLORER_URL}/oracles/${market.tradableInstrument?.instrument.product?.dataSourceSpecForTradingTermination.id}`}
|
||||
data-testid="block-explorer-link-termination"
|
||||
>
|
||||
{t('Termination')}
|
||||
</ExternalLink>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
query FundingPeriods(
|
||||
$marketId: ID!
|
||||
$dateRange: DateRange
|
||||
$pagination: Pagination
|
||||
) {
|
||||
fundingPeriods(
|
||||
marketId: $marketId
|
||||
dateRange: $dateRange
|
||||
pagination: $pagination
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
marketId
|
||||
seq
|
||||
startTime
|
||||
endTime
|
||||
fundingPayment
|
||||
fundingRate
|
||||
externalTwap
|
||||
internalTwap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query FundingPeriodDataPoints(
|
||||
$marketId: ID!
|
||||
$dateRange: DateRange
|
||||
$pagination: Pagination
|
||||
) {
|
||||
fundingPeriodDataPoints(
|
||||
marketId: $marketId
|
||||
dateRange: $dateRange
|
||||
pagination: $pagination
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
marketId
|
||||
seq
|
||||
dataPointSource
|
||||
price
|
||||
twap
|
||||
timestamp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ const mockMarket = jest.fn<{ data: MarketFieldsFragment | null }, unknown[]>(
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
dataSourceSpecForSettlementData: {
|
||||
id: dataSourceSpecId,
|
||||
data: {
|
||||
|
||||
@@ -4,14 +4,10 @@ import { useMarket } from '../markets-provider';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import type { Provider } from '../oracle-schema';
|
||||
import {
|
||||
getDataSourceSpecForSettlementData,
|
||||
getDataSourceSpecForTradingTermination,
|
||||
} from '../product';
|
||||
import type { DataSourceFragment } from '../components';
|
||||
import type { DataSourceSpecFragment } from '../__generated__';
|
||||
|
||||
export const getMatchingOracleProvider = (
|
||||
dataSourceSpec: DataSourceFragment['data'],
|
||||
dataSourceSpec: DataSourceSpecFragment,
|
||||
providers: Provider[]
|
||||
) => {
|
||||
return providers.find((provider) => {
|
||||
@@ -24,8 +20,7 @@ export const getMatchingOracleProvider = (
|
||||
}
|
||||
|
||||
if (
|
||||
dataSourceSpec.sourceType.__typename === 'DataSourceDefinitionExternal' &&
|
||||
'signers' in dataSourceSpec.sourceType.sourceType
|
||||
dataSourceSpec.sourceType.__typename === 'DataSourceDefinitionExternal'
|
||||
) {
|
||||
return dataSourceSpec.sourceType.sourceType.signers?.some(
|
||||
(signer) =>
|
||||
@@ -43,8 +38,7 @@ export const useMarketOracle = (
|
||||
marketId: string,
|
||||
dataSourceType:
|
||||
| 'dataSourceSpecForSettlementData'
|
||||
| 'dataSourceSpecForTradingTermination'
|
||||
| 'dataSourceSpecForSettlementSchedule' = 'dataSourceSpecForSettlementData'
|
||||
| 'dataSourceSpecForTradingTermination' = 'dataSourceSpecForSettlementData'
|
||||
): {
|
||||
data?: {
|
||||
provider: NonNullable<ReturnType<typeof getMatchingOracleProvider>>;
|
||||
@@ -63,22 +57,10 @@ export const useMarketOracle = (
|
||||
if (!providers || !market) {
|
||||
return { data: undefined };
|
||||
}
|
||||
let dataSourceSpec: DataSourceFragment | undefined = undefined;
|
||||
const { product } = market.tradableInstrument.instrument;
|
||||
if (dataSourceType === 'dataSourceSpecForSettlementData') {
|
||||
dataSourceSpec = getDataSourceSpecForSettlementData(product);
|
||||
}
|
||||
if (dataSourceType === 'dataSourceSpecForSettlementSchedule') {
|
||||
dataSourceSpec = getDataSourceSpecForSettlementData(product);
|
||||
}
|
||||
if (dataSourceType === 'dataSourceSpecForTradingTermination') {
|
||||
dataSourceSpec = getDataSourceSpecForTradingTermination(product);
|
||||
}
|
||||
|
||||
const provider =
|
||||
dataSourceSpec &&
|
||||
getMatchingOracleProvider(dataSourceSpec.data, providers);
|
||||
if (provider && dataSourceSpec) {
|
||||
const dataSourceSpec =
|
||||
market.tradableInstrument.instrument.product[dataSourceType];
|
||||
const provider = getMatchingOracleProvider(dataSourceSpec.data, providers);
|
||||
if (provider) {
|
||||
return { data: { provider, dataSourceSpecId: dataSourceSpec.id } };
|
||||
}
|
||||
return { data: undefined };
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { Provider } from '../oracle-schema';
|
||||
import type { OracleMarketSpecFieldsFragment } from '../__generated__/OracleMarketsSpec';
|
||||
import { useOracleMarketsSpecQuery } from '../__generated__/OracleMarketsSpec';
|
||||
import { getDataSourceSpecForSettlementData } from '../product';
|
||||
|
||||
export const useOracleMarkets = (
|
||||
provider: Provider
|
||||
@@ -20,16 +19,12 @@ export const useOracleMarkets = (
|
||||
const oracleMarkets = markets?.marketsConnection?.edges
|
||||
?.map((edge) => edge.node)
|
||||
?.filter((node) => {
|
||||
const { product } = node.tradableInstrument.instrument;
|
||||
const sourceType =
|
||||
getDataSourceSpecForSettlementData(product)?.data.sourceType;
|
||||
if (sourceType?.__typename !== 'DataSourceDefinitionExternal') {
|
||||
const p = node.tradableInstrument.instrument.product;
|
||||
const sourceType = p.dataSourceSpecForSettlementData.data.sourceType;
|
||||
if (sourceType.__typename !== 'DataSourceDefinitionExternal') {
|
||||
return false;
|
||||
}
|
||||
const signers =
|
||||
'signers' in sourceType.sourceType
|
||||
? sourceType?.sourceType.signers
|
||||
: undefined;
|
||||
const signers = sourceType?.sourceType.signers;
|
||||
const signerKeys = signers?.filter(Boolean).map((signer) => {
|
||||
if (signer.signer.__typename === 'ETHAddress') {
|
||||
return signer.signer.address;
|
||||
|
||||
@@ -12,4 +12,3 @@ export * from './market-data-provider';
|
||||
export * from './markets-candles-provider';
|
||||
export * from './markets-data-provider';
|
||||
export * from './markets-provider';
|
||||
export * from './product';
|
||||
|
||||
@@ -115,23 +115,6 @@ export const staticMarketDataProvider = makeDerivedDataProvider<
|
||||
});
|
||||
});
|
||||
|
||||
export const fundingRateProvider = makeDerivedDataProvider<
|
||||
string,
|
||||
never,
|
||||
MarketDataQueryVariables
|
||||
>([marketDataProvider], (parts) => {
|
||||
return (
|
||||
(parts[0] as ReturnType<typeof getData>)?.productData?.fundingRate || null
|
||||
);
|
||||
});
|
||||
|
||||
export const useFundingRate = (marketId?: string, skip?: boolean) =>
|
||||
useDataProvider({
|
||||
dataProvider: fundingRateProvider,
|
||||
variables: { marketId: marketId || '' },
|
||||
skip: skip || !marketId,
|
||||
});
|
||||
|
||||
export const useStaticMarketData = (marketId?: string, skip?: boolean) => {
|
||||
return useDataProvider({
|
||||
dataProvider: staticMarketDataProvider,
|
||||
|
||||
@@ -10,14 +10,6 @@ fragment MarketDataUpdateFields on ObservableMarketData {
|
||||
bestStaticBidVolume
|
||||
bestStaticOfferPrice
|
||||
bestStaticOfferVolume
|
||||
productData {
|
||||
... on PerpetualData {
|
||||
fundingRate
|
||||
fundingPayment
|
||||
externalTwap
|
||||
internalTwap
|
||||
}
|
||||
}
|
||||
indicativePrice
|
||||
indicativeVolume
|
||||
marketState
|
||||
@@ -63,14 +55,6 @@ fragment MarketDataFields on MarketData {
|
||||
bestStaticBidVolume
|
||||
bestStaticOfferPrice
|
||||
bestStaticOfferVolume
|
||||
productData {
|
||||
... on PerpetualData {
|
||||
fundingRate
|
||||
fundingPayment
|
||||
externalTwap
|
||||
internalTwap
|
||||
}
|
||||
}
|
||||
indicativePrice
|
||||
indicativeVolume
|
||||
marketState
|
||||
|
||||
@@ -95,7 +95,6 @@ describe('calcTradedFactor', () => {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
decimals: 18,
|
||||
quantum: '1000000000000000000', // 1
|
||||
@@ -116,7 +115,6 @@ describe('calcTradedFactor', () => {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
decimals: 18,
|
||||
quantum: '1', // 0.0000000000000000001
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { formatNumberPercentage, toBigNum } from '@vegaprotocol/utils';
|
||||
import { MarketState, MarketTradingMode } from '@vegaprotocol/types';
|
||||
import * as Schema from '@vegaprotocol/types';
|
||||
import BigNumber from 'bignumber.js';
|
||||
import orderBy from 'lodash/orderBy';
|
||||
import type {
|
||||
@@ -8,46 +8,7 @@ import type {
|
||||
MarketMaybeWithData,
|
||||
MarketMaybeWithDataAndCandles,
|
||||
} from '../';
|
||||
|
||||
export const getAsset = (market: Partial<Market>) => {
|
||||
if (!market.tradableInstrument?.instrument.product) {
|
||||
throw new Error('Failed to retrieve asset. Invalid tradable instrument');
|
||||
}
|
||||
|
||||
const product = market.tradableInstrument.instrument.product;
|
||||
|
||||
if (product.__typename === 'Perpetual' || product.__typename === 'Future') {
|
||||
return product.settlementAsset;
|
||||
}
|
||||
|
||||
if (product.__typename === 'Spot') {
|
||||
// TODO to handle baseAsset for Spots
|
||||
throw new Error('Failed to retrieve asset. Spots not yet implemented');
|
||||
}
|
||||
|
||||
throw new Error('Failed to retrieve asset. Invalid product type');
|
||||
};
|
||||
|
||||
export const getQuoteName = (market: Partial<Market>) => {
|
||||
if (!market.tradableInstrument?.instrument.product) {
|
||||
throw new Error(
|
||||
'Failed to retrieve quoteName. Invalid tradable instrument'
|
||||
);
|
||||
}
|
||||
|
||||
const product = market.tradableInstrument.instrument.product;
|
||||
|
||||
if (product.__typename === 'Perpetual' || product.__typename === 'Future') {
|
||||
return product.quoteName;
|
||||
}
|
||||
|
||||
if (product.__typename === 'Spot') {
|
||||
// TODO to handle baseAsset for Spots
|
||||
throw new Error('Failed to retrieve quoteName. Spots not yet implemented');
|
||||
}
|
||||
|
||||
throw new Error('Failed to retrieve quoteName. Invalid product type');
|
||||
};
|
||||
const { MarketState, MarketTradingMode } = Schema;
|
||||
|
||||
export const totalFees = (fees: Market['fees']['factors']) => {
|
||||
return fees
|
||||
@@ -134,9 +95,12 @@ export const calcCandleVolume = (candles: Candle[]): string | undefined =>
|
||||
export const calcTradedFactor = (m: MarketMaybeWithDataAndCandles) => {
|
||||
const volume = Number(calcCandleVolume(m.candles || []) || 0);
|
||||
const price = m.data?.markPrice ? Number(m.data.markPrice) : 0;
|
||||
const asset = getAsset(m);
|
||||
const quantum = Number(asset.quantum);
|
||||
const decimals = Number(asset.decimals);
|
||||
const quantum = Number(
|
||||
m.tradableInstrument.instrument.product.settlementAsset.quantum
|
||||
);
|
||||
const decimals = Number(
|
||||
m.tradableInstrument.instrument.product.settlementAsset.decimals
|
||||
);
|
||||
const fp = toBigNum(price, decimals);
|
||||
const fq = toBigNum(quantum, decimals);
|
||||
const factor = fq.multipliedBy(fp).multipliedBy(volume);
|
||||
|
||||
@@ -1,3 +1,35 @@
|
||||
fragment DataSourceFilter on Filter {
|
||||
key {
|
||||
name
|
||||
type
|
||||
numberDecimalPlaces
|
||||
}
|
||||
}
|
||||
|
||||
fragment DataSourceSpec on DataSourceDefinition {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
}
|
||||
}
|
||||
filters {
|
||||
...DataSourceFilter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment MarketFields on Market {
|
||||
id
|
||||
decimalPlaces
|
||||
@@ -23,10 +55,30 @@ fragment MarketFields on Market {
|
||||
}
|
||||
product {
|
||||
... on Future {
|
||||
...Future
|
||||
}
|
||||
... on Perpetual {
|
||||
...Perpetual
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
decimals
|
||||
quantum
|
||||
}
|
||||
quoteName
|
||||
dataSourceSpecForTradingTermination {
|
||||
id
|
||||
data {
|
||||
...DataSourceSpec
|
||||
}
|
||||
}
|
||||
dataSourceSpecForSettlementData {
|
||||
id
|
||||
data {
|
||||
...DataSourceSpec
|
||||
}
|
||||
}
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
tradingTerminationProperty
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@ export const createMarketFragment = (
|
||||
tags: [],
|
||||
},
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-0',
|
||||
symbol: 'tDAI',
|
||||
@@ -144,7 +143,8 @@ export const createMarketFragment = (
|
||||
settlementDataProperty: 'settlement-data-property',
|
||||
},
|
||||
quoteName: 'DAI',
|
||||
} as const,
|
||||
__typename: 'Future',
|
||||
},
|
||||
__typename: 'Instrument',
|
||||
},
|
||||
__typename: 'TradableInstrument',
|
||||
@@ -165,7 +165,6 @@ const marketFieldsFragments: MarketFieldsFragment[] = [
|
||||
name: 'SUSPENDED MARKET',
|
||||
code: 'SOLUSD',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-1',
|
||||
symbol: 'XYZalpha',
|
||||
@@ -196,7 +195,6 @@ const marketFieldsFragments: MarketFieldsFragment[] = [
|
||||
code: 'AAPL.MF21',
|
||||
name: 'Apple Monthly (30 Jun 2022)',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-id',
|
||||
name: '',
|
||||
@@ -226,7 +224,6 @@ const marketFieldsFragments: MarketFieldsFragment[] = [
|
||||
code: 'ETHBTC.QM21',
|
||||
name: 'ETHBTC Quarterly (30 Jun 2022)',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
id: 'asset-3',
|
||||
symbol: 'tBTC',
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import type {
|
||||
DataSourceFragment,
|
||||
FutureFragment,
|
||||
MarketInfo,
|
||||
PerpetualFragment,
|
||||
} from './components';
|
||||
|
||||
type Product = MarketInfo['tradableInstrument']['instrument']['product'];
|
||||
|
||||
export const isFuture = (product: Product): product is FutureFragment =>
|
||||
product.__typename === 'Future';
|
||||
|
||||
export const isPerpetual = (product: Product): product is PerpetualFragment =>
|
||||
product.__typename === 'Perpetual';
|
||||
|
||||
export const getDataSourceSpecForSettlementData = (product: Product) =>
|
||||
isFuture(product) || isPerpetual(product)
|
||||
? product.dataSourceSpecForSettlementData
|
||||
: undefined;
|
||||
|
||||
export const getDataSourceSpecForSettlementSchedule = (product: Product) =>
|
||||
isPerpetual(product)
|
||||
? product.dataSourceSpecForSettlementSchedule
|
||||
: undefined;
|
||||
|
||||
export const getDataSourceSpecForTradingTermination = (product: Product) =>
|
||||
isFuture(product) ? product.dataSourceSpecForTradingTermination : undefined;
|
||||
|
||||
export const getDataSourceSpecBinding = (product: Product) =>
|
||||
isFuture(product) || isPerpetual(product)
|
||||
? product.dataSourceSpecBinding
|
||||
: undefined;
|
||||
|
||||
export const getSigners = ({ data }: DataSourceFragment) => {
|
||||
if (data.sourceType.__typename === 'DataSourceDefinitionExternal') {
|
||||
const signers =
|
||||
('signers' in data.sourceType.sourceType &&
|
||||
data.sourceType.sourceType.signers) ||
|
||||
[];
|
||||
|
||||
return signers.map(({ signer }, i) => {
|
||||
return (
|
||||
(signer.__typename === 'ETHAddress' && signer.address) ||
|
||||
(signer.__typename === 'PubKey' && signer.key)
|
||||
);
|
||||
});
|
||||
}
|
||||
return [];
|
||||
};
|
||||
@@ -37,7 +37,7 @@ export const generateOrder = (partialOrder?: PartialDeep<Order>) => {
|
||||
__typename: 'InstrumentMetadata',
|
||||
tags: ['xyz asset'],
|
||||
},
|
||||
name: 'XYZ instrument',
|
||||
name: 'XYZ intrument',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
quoteName: '',
|
||||
|
||||
@@ -47,7 +47,7 @@ export const generateStopOrder = (
|
||||
__typename: 'InstrumentMetadata',
|
||||
tags: ['xyz asset'],
|
||||
},
|
||||
name: 'XYZ instrument',
|
||||
name: 'XYZ intrument',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
quoteName: '',
|
||||
|
||||
@@ -80,6 +80,7 @@ describe('OrderViewDialog', () => {
|
||||
},
|
||||
},
|
||||
],
|
||||
filters: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -102,6 +103,7 @@ describe('OrderViewDialog', () => {
|
||||
},
|
||||
},
|
||||
],
|
||||
filters: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -120,7 +120,6 @@ const marketsData = [
|
||||
name: 'AAVEDAI Monthly (30 Jun 2022)',
|
||||
code: 'AAVEDAI.MF21',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
symbol: 'tDAI',
|
||||
id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61',
|
||||
@@ -151,7 +150,6 @@ const marketsData = [
|
||||
name: 'UNIDAI Monthly (30 Jun 2022)',
|
||||
code: 'UNIDAI.MF21',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
symbol: 'tDAI',
|
||||
id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61',
|
||||
|
||||
@@ -14,10 +14,7 @@ import type {
|
||||
MarketMaybeWithData,
|
||||
MarketDataQueryVariables,
|
||||
} from '@vegaprotocol/markets';
|
||||
import {
|
||||
allMarketsWithLiveDataProvider,
|
||||
getAsset,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { allMarketsWithLiveDataProvider } from '@vegaprotocol/markets';
|
||||
import type {
|
||||
PositionsQuery,
|
||||
PositionFieldsFragment,
|
||||
@@ -65,19 +62,17 @@ export const getMetrics = (
|
||||
if (!data || !data?.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const metrics: Position[] = [];
|
||||
data.forEach((position) => {
|
||||
const market = position.market;
|
||||
if (!market) {
|
||||
return;
|
||||
}
|
||||
|
||||
const marketData = market?.data;
|
||||
const marginAccount = accounts?.find((account) => {
|
||||
return account.market?.id === market?.id;
|
||||
});
|
||||
const asset = getAsset(market);
|
||||
const asset = market.tradableInstrument.instrument.product.settlementAsset;
|
||||
const generalAccount = accounts?.find(
|
||||
(account) =>
|
||||
account.asset.id === asset.id &&
|
||||
|
||||
@@ -111,6 +111,7 @@ fragment NewMarketFields on NewMarket {
|
||||
# triggeringRatio
|
||||
# auctionExtensionSecs
|
||||
# }
|
||||
lpPriceRange
|
||||
# linearSlippageFactor
|
||||
# quadraticSlippageFactor
|
||||
successorConfiguration {
|
||||
@@ -124,139 +125,70 @@ fragment UpdateMarketFields on UpdateMarket {
|
||||
instrument {
|
||||
code
|
||||
product {
|
||||
... on UpdateFutureProduct {
|
||||
quoteName
|
||||
dataSourceSpecForSettlementData {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
quoteName
|
||||
dataSourceSpecForSettlementData {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
}
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
type
|
||||
}
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
type
|
||||
}
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dataSourceSpecForTradingTermination {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
}
|
||||
}
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
type
|
||||
}
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
tradingTerminationProperty
|
||||
}
|
||||
}
|
||||
... on UpdatePerpetualProduct {
|
||||
quoteName
|
||||
dataSourceSpecForSettlementData {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
dataSourceSpecForTradingTermination {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
}
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
type
|
||||
}
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
type
|
||||
}
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dataSourceSpecForSettlementSchedule {
|
||||
sourceType {
|
||||
... on DataSourceDefinitionExternal {
|
||||
sourceType {
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
signer {
|
||||
... on PubKey {
|
||||
key
|
||||
}
|
||||
... on ETHAddress {
|
||||
address
|
||||
}
|
||||
}
|
||||
}
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
type
|
||||
}
|
||||
conditions {
|
||||
operator
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
settlementScheduleProperty
|
||||
}
|
||||
}
|
||||
dataSourceSpecBinding {
|
||||
settlementDataProperty
|
||||
tradingTerminationProperty
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,7 +259,7 @@ fragment UpdateAssetFields on UpdateAsset {
|
||||
}
|
||||
}
|
||||
|
||||
fragment UpdateNetworkParameterFields on UpdateNetworkParameter {
|
||||
fragment UpdateNetworkParameterFiels on UpdateNetworkParameter {
|
||||
networkParameter {
|
||||
key
|
||||
value
|
||||
@@ -383,7 +315,7 @@ fragment ProposalListFields on Proposal {
|
||||
...UpdateAssetFields
|
||||
}
|
||||
... on UpdateNetworkParameter {
|
||||
...UpdateNetworkParameterFields
|
||||
...UpdateNetworkParameterFiels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+59
-127
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user