chore: update explorer to use v2 queries (#2049)

* fix: migrate queries to latest apis
* fix: remove oracles section for now
* fix: dive in to fields correctly
* fix: update queries
* fix: fragment for stats fields
* fix: rename triple underscore generated
* chore: refactor types that have moved
* chore(explorer): disable e2e test that asserts json structure
This commit is contained in:
Edd 2022-11-15 12:31:25 +00:00 committed by GitHub
parent 34f3efb5c5
commit e598cd1247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
98 changed files with 1378 additions and 2386 deletions

View File

@ -1,5 +1,5 @@
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
import { MarketState, MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { SingleMarketFieldsFragment } from '@vegaprotocol/market-list'; import type { SingleMarketFieldsFragment } from '@vegaprotocol/market-list';
export const protoCandles = [ export const protoCandles = [
@ -79,8 +79,8 @@ export const protoCandles = [
export const protoMarket: Market = { export const protoMarket: Market = {
id: 'ca7768f6de84bf86a21bbb6b0109d9659c81917b0e0339b2c262566c9b581a15', id: 'ca7768f6de84bf86a21bbb6b0109d9659c81917b0e0339b2c262566c9b581a15',
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
decimalPlaces: 5, decimalPlaces: 5,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
marketTimestamps: { marketTimestamps: {

View File

@ -1,6 +1,6 @@
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import type { AccountsQuery } from '@vegaprotocol/accounts'; import type { AccountsQuery } from '@vegaprotocol/accounts';
import { AccountType } from '@vegaprotocol/types'; import { Schema as Types } from '@vegaprotocol/types';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
export const generateAccounts = ( export const generateAccounts = (
@ -13,7 +13,7 @@ export const generateAccounts = (
accounts: [ accounts: [
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '100000000', balance: '100000000',
market: null, market: null,
asset: { asset: {
@ -23,7 +23,7 @@ export const generateAccounts = (
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '100000000', balance: '100000000',
market: { market: {
id: '0604e8c918655474525e1a95367902266ade70d318c2c908f0cca6e3d11dcb13', id: '0604e8c918655474525e1a95367902266ade70d318c2c908f0cca6e3d11dcb13',
@ -36,7 +36,7 @@ export const generateAccounts = (
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_MARGIN, type: Types.AccountType.ACCOUNT_TYPE_MARGIN,
balance: '1000', balance: '1000',
market: { market: {
__typename: 'Market', __typename: 'Market',
@ -49,7 +49,7 @@ export const generateAccounts = (
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_MARGIN, type: Types.AccountType.ACCOUNT_TYPE_MARGIN,
balance: '1000', balance: '1000',
market: { market: {
__typename: 'Market', __typename: 'Market',
@ -62,7 +62,7 @@ export const generateAccounts = (
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '100000000', balance: '100000000',
market: null, market: null,
asset: { asset: {

View File

@ -1,5 +1,5 @@
import type { DealTicketQuery } from '@vegaprotocol/deal-ticket'; import type { DealTicketQuery } from '@vegaprotocol/deal-ticket';
import { MarketTradingMode, MarketState } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
@ -11,8 +11,8 @@ export const generateDealTicket = (
id: 'ca7768f6de84bf86a21bbb6b0109d9659c81917b0e0339b2c262566c9b581a15', id: 'ca7768f6de84bf86a21bbb6b0109d9659c81917b0e0339b2c262566c9b581a15',
decimalPlaces: 5, decimalPlaces: 5,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d', id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d',

View File

@ -1,9 +1,5 @@
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import { import { Schema } from '@vegaprotocol/types';
AuctionTrigger,
MarketState,
MarketTradingMode,
} from '@vegaprotocol/types';
import type { import type {
MarketsQuery, MarketsQuery,
Market, Market,
@ -22,7 +18,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '57fbaa322e97cfc8bb5f1de048c37e033c41b1ac1906d3aed9960912a067ef5a', id: '57fbaa322e97cfc8bb5f1de048c37e033c41b1ac1906d3aed9960912a067ef5a',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -56,7 +52,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: 'ccf2f04865e5951ac3405da6e16b7cbdb535a0ad32df4df2dbed4262cf473255', id: 'ccf2f04865e5951ac3405da6e16b7cbdb535a0ad32df4df2dbed4262cf473255',
state: MarketState.STATE_SUSPENDED, state: Schema.MarketState.STATE_SUSPENDED,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -90,7 +86,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '6030e5b4e0ca3297a26081e5af4d453f97f96baab2d74bf56f84efcffc4c382f', id: '6030e5b4e0ca3297a26081e5af4d453f97f96baab2d74bf56f84efcffc4c382f',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -125,7 +121,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: 'de74a5572045b300e8ec50d136896912ec76e7d7ec135bc305dfd4854d9363a4', id: 'de74a5572045b300e8ec50d136896912ec76e7d7ec135bc305dfd4854d9363a4',
state: MarketState.STATE_PENDING, state: Schema.MarketState.STATE_PENDING,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -159,7 +155,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '31ea96284611771e486c820acb26a325a99664f9854b5a7e7ad99023efa8f9e6', id: '31ea96284611771e486c820acb26a325a99664f9854b5a7e7ad99023efa8f9e6',
state: MarketState.STATE_CLOSED, state: Schema.MarketState.STATE_CLOSED,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -192,7 +188,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '34cff959cdc2ffdb0f167820d701fe8b51cc6b8588e650d93369aaa22d6f8b74', id: '34cff959cdc2ffdb0f167820d701fe8b51cc6b8588e650d93369aaa22d6f8b74',
state: MarketState.STATE_SETTLED, state: Schema.MarketState.STATE_SETTLED,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -227,7 +223,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '87b0bbb3c171baa5d97dfc3852332829c91e5c5dc9f7c8fb584c6d8ac75aaaf2', id: '87b0bbb3c171baa5d97dfc3852332829c91e5c5dc9f7c8fb584c6d8ac75aaaf2',
state: MarketState.STATE_SETTLED, state: Schema.MarketState.STATE_SETTLED,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -261,7 +257,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '45266143c6e9b58f4cff9b8906e971c531bb29ea7af01066973f9b77e8134823', id: '45266143c6e9b58f4cff9b8906e971c531bb29ea7af01066973f9b77e8134823',
state: MarketState.STATE_PENDING, state: Schema.MarketState.STATE_PENDING,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -296,7 +292,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '65663ebdc96161162769c4d5c5508137416748178d7cb28e2cb0d07a151a2bc6', id: '65663ebdc96161162769c4d5c5508137416748178d7cb28e2cb0d07a151a2bc6',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -331,7 +327,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '234afabd27e3bce1a879039c041f9f00f915d98459935ddafd0169d38dd13850', id: '234afabd27e3bce1a879039c041f9f00f915d98459935ddafd0169d38dd13850',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -367,7 +363,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '9f2a3c1caa67bb0773ec18d908d32b55b129b9ec2d106a8e9a87f6aa5c0375a6', id: '9f2a3c1caa67bb0773ec18d908d32b55b129b9ec2d106a8e9a87f6aa5c0375a6',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -403,7 +399,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '8a45ee934d3ddac4b036f9884df1064a5353c620a56f775ba36597d0edef9a7a', id: '8a45ee934d3ddac4b036f9884df1064a5353c620a56f775ba36597d0edef9a7a',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -437,7 +433,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: 'aede7b9ac0c3b225004929c5455160a00f59864aad32ec366e8a2bff1b30fd0f', id: 'aede7b9ac0c3b225004929c5455160a00f59864aad32ec366e8a2bff1b30fd0f',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -472,7 +468,7 @@ export const generateSimpleMarkets = (): MarketsQuery => {
{ {
...protoMarket, ...protoMarket,
id: '9398707e01daa1a1f1ca6ff87cf8d6c03fe7373ce31121ce81b99a129e6bda47', id: '9398707e01daa1a1f1ca6ff87cf8d6c03fe7373ce31121ce81b99a129e6bda47',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
id: '', id: '',
@ -1153,7 +1149,7 @@ export const generateMarketsData = (
id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d', id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d',
__typename: 'Market', __typename: 'Market',
}, },
marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
staticMidPrice: '0', staticMidPrice: '0',
indicativePrice: '0', indicativePrice: '0',
bestStaticBidPrice: '0', bestStaticBidPrice: '0',
@ -1162,7 +1158,7 @@ export const generateMarketsData = (
bestBidPrice: '0', bestBidPrice: '0',
bestOfferPrice: '0', bestOfferPrice: '0',
markPrice: '17588787', markPrice: '17588787',
trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED,
__typename: 'MarketData', __typename: 'MarketData',
}, },
__typename: 'Market', __typename: 'Market',
@ -1173,7 +1169,7 @@ export const generateMarketsData = (
id: '5a4b0b9e9c0629f0315ec56fcb7bd444b0c6e4da5ec7677719d502626658a376', id: '5a4b0b9e9c0629f0315ec56fcb7bd444b0c6e4da5ec7677719d502626658a376',
__typename: 'Market', __typename: 'Market',
}, },
marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
staticMidPrice: '0', staticMidPrice: '0',
indicativePrice: '0', indicativePrice: '0',
bestStaticBidPrice: '0', bestStaticBidPrice: '0',
@ -1182,7 +1178,7 @@ export const generateMarketsData = (
bestBidPrice: '0', bestBidPrice: '0',
bestOfferPrice: '0', bestOfferPrice: '0',
markPrice: '84377569', markPrice: '84377569',
trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED,
__typename: 'MarketData', __typename: 'MarketData',
}, },
__typename: 'Market', __typename: 'Market',
@ -1215,7 +1211,7 @@ export const generatePositionsMarkets = () => {
decimalPlaces: 5, decimalPlaces: 5,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
state: 'STATE_ACTIVE', state: 'STATE_ACTIVE',
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
fees: { fees: {
factors: { factors: {
makerFee: '0.0002', makerFee: '0.0002',

View File

@ -1,7 +1,7 @@
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import type { PartyBalanceQuery } from '@vegaprotocol/deal-ticket'; import type { PartyBalanceQuery } from '@vegaprotocol/deal-ticket';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
import { AccountType } from '@vegaprotocol/types'; import { Schema as Types } from '@vegaprotocol/types';
export const generatePartyBalance = ( export const generatePartyBalance = (
override?: PartialDeep<PartyBalanceQuery> override?: PartialDeep<PartyBalanceQuery>
@ -11,7 +11,7 @@ export const generatePartyBalance = (
accounts: [ accounts: [
{ {
balance: '88474051', balance: '88474051',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
asset: { asset: {
id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61', id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61',
symbol: 'tDAI', symbol: 'tDAI',
@ -23,7 +23,7 @@ export const generatePartyBalance = (
}, },
{ {
balance: '100000000', balance: '100000000',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
asset: { asset: {
id: '8b52d4a3a4b0ffe733cddbc2b67be273816cfeb6ca4c8b339bac03ffba08e4e4', id: '8b52d4a3a4b0ffe733cddbc2b67be273816cfeb6ca4c8b339bac03ffba08e4e4',
symbol: 'tEURO', symbol: 'tEURO',
@ -35,7 +35,7 @@ export const generatePartyBalance = (
}, },
{ {
balance: '3412867', balance: '3412867',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
asset: { asset: {
id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61', id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61',
symbol: 'tDAI', symbol: 'tDAI',
@ -47,7 +47,7 @@ export const generatePartyBalance = (
}, },
{ {
balance: '70007', balance: '70007',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
asset: { asset: {
id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61', id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61',
symbol: 'tDAI', symbol: 'tDAI',

View File

@ -5,7 +5,7 @@ import type {
DealTicketMarketFragment, DealTicketMarketFragment,
} from '@vegaprotocol/deal-ticket'; } from '@vegaprotocol/deal-ticket';
import { DealTicketBalance } from './deal-ticket-balance'; import { DealTicketBalance } from './deal-ticket-balance';
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
const tDAI: DealTicketMarketFragment['tradableInstrument']['instrument']['product']['settlementAsset'] = const tDAI: DealTicketMarketFragment['tradableInstrument']['instrument']['product']['settlementAsset'] =
{ {
@ -19,7 +19,7 @@ const tDAI: DealTicketMarketFragment['tradableInstrument']['instrument']['produc
const accounts: AccountFragment[] = [ const accounts: AccountFragment[] = [
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '1000000', balance: '1000000',
asset: tDAI, asset: tDAI,
}, },

View File

@ -1,6 +1,6 @@
import classNames from 'classnames'; import classNames from 'classnames';
import { addDecimalsFormatNumber, t } from '@vegaprotocol/react-helpers'; import { addDecimalsFormatNumber, t } from '@vegaprotocol/react-helpers';
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { import type {
AccountFragment, AccountFragment,
DealTicketMarketFragment, DealTicketMarketFragment,
@ -25,7 +25,7 @@ export const DealTicketBalance = ({
const settlementAccount = useSettlementAccount( const settlementAccount = useSettlementAccount(
settlementAssetId, settlementAssetId,
accounts, accounts,
AccountType.ACCOUNT_TYPE_GENERAL Schema.AccountType.ACCOUNT_TYPE_GENERAL
); );
const formattedNumber = const formattedNumber =
settlementAccount?.balance && settlementAccount?.balance &&

View File

@ -16,7 +16,7 @@ import type {
GroupCellRendererParams, GroupCellRendererParams,
ColDef, ColDef,
} from 'ag-grid-community'; } from 'ag-grid-community';
import { MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { VegaValueFormatterParams } from '@vegaprotocol/ui-toolkit'; import type { VegaValueFormatterParams } from '@vegaprotocol/ui-toolkit';
import { Intent, ProgressBarCell } from '@vegaprotocol/ui-toolkit'; import { Intent, ProgressBarCell } from '@vegaprotocol/ui-toolkit';
@ -109,7 +109,7 @@ const useColumnDefinitions = () => {
value && value &&
node?.rowPinned && node?.rowPinned &&
data.marketTradingMode === data.marketTradingMode ===
MarketTradingMode.TRADING_MODE_OPENING_AUCTION Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION
) { ) {
return addDecimalsFormatNumber( return addDecimalsFormatNumber(
value.toString(), value.toString(),

View File

@ -1,21 +1,24 @@
import { t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import { themelite as theme } from '@vegaprotocol/tailwindcss-config'; import { themelite as theme } from '@vegaprotocol/tailwindcss-config';
import { MarketState } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import colors from 'tailwindcss/colors'; import colors from 'tailwindcss/colors';
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
import { IS_MARKET_TRADABLE } from '../../constants'; import { IS_MARKET_TRADABLE } from '../../constants';
export const STATES_FILTER = [ export const STATES_FILTER = [
{ value: 'all', text: t('All') }, { value: 'all', text: t('All') },
{ value: MarketState.STATE_ACTIVE, text: t('Active') }, { value: Schema.MarketState.STATE_ACTIVE, text: t('Active') },
{ value: MarketState.STATE_CANCELLED, text: t('Cancelled') }, { value: Schema.MarketState.STATE_CANCELLED, text: t('Cancelled') },
{ value: MarketState.STATE_CLOSED, text: t('Closed') }, { value: Schema.MarketState.STATE_CLOSED, text: t('Closed') },
{ value: MarketState.STATE_PENDING, text: t('Pending') }, { value: Schema.MarketState.STATE_PENDING, text: t('Pending') },
{ value: MarketState.STATE_PROPOSED, text: t('Proposed') }, { value: Schema.MarketState.STATE_PROPOSED, text: t('Proposed') },
{ value: MarketState.STATE_REJECTED, text: t('Rejected') }, { value: Schema.MarketState.STATE_REJECTED, text: t('Rejected') },
{ value: MarketState.STATE_SETTLED, text: t('Settled') }, { value: Schema.MarketState.STATE_SETTLED, text: t('Settled') },
{ value: MarketState.STATE_SUSPENDED, text: t('Suspended') }, { value: Schema.MarketState.STATE_SUSPENDED, text: t('Suspended') },
{ value: MarketState.STATE_TRADING_TERMINATED, text: t('TradingTerminated') }, {
value: Schema.MarketState.STATE_TRADING_TERMINATED,
text: t('TradingTerminated'),
},
]; ];
export const agGridLightVariables = ` export const agGridLightVariables = `

View File

@ -9,7 +9,7 @@ import {
} from '@testing-library/react'; } from '@testing-library/react';
import { MockedProvider } from '@apollo/client/testing'; import { MockedProvider } from '@apollo/client/testing';
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
import { MarketState } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
import SimpleMarketList from './simple-market-list'; import SimpleMarketList from './simple-market-list';
@ -26,7 +26,7 @@ jest.mock('./simple-market-percent-change', () => jest.fn());
let marketsMock = [ let marketsMock = [
{ {
id: 'MARKET_A', id: 'MARKET_A',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
product: { product: {
@ -42,7 +42,7 @@ let marketsMock = [
}, },
{ {
id: 'MARKET_B', id: 'MARKET_B',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
product: { product: {
@ -121,7 +121,7 @@ describe('SimpleMarketList', () => {
expect(mockIsTradable).toHaveBeenCalledWith( expect(mockIsTradable).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
id: marketsMock[0].id, id: marketsMock[0].id,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
}) })
); );
expect(mockedNavigate).toHaveBeenCalledWith( expect(mockedNavigate).toHaveBeenCalledWith(

View File

@ -7,7 +7,6 @@ import {
useYesterday, useYesterday,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
import type { MarketState } from '@vegaprotocol/types';
import useMarketsFilterData from './use-markets-filter-data'; import useMarketsFilterData from './use-markets-filter-data';
import useColumnDefinitions from './use-column-definitions'; import useColumnDefinitions from './use-column-definitions';
import SimpleMarketToolbar from './simple-market-toolbar'; import SimpleMarketToolbar from './simple-market-toolbar';
@ -31,7 +30,7 @@ const SimpleMarketList = () => {
const { isMobile } = useScreenDimensions(); const { isMobile } = useScreenDimensions();
const navigate = useNavigate(); const navigate = useNavigate();
const params = useParams<RouterParams>(); const params = useParams<RouterParams>();
const statusesRef = useRef<Record<string, MarketState | ''>>({}); const statusesRef = useRef<Record<string, Schema.MarketState | ''>>({});
const gridRef = useRef<AgGridReact | null>(null); const gridRef = useRef<AgGridReact | null>(null);
const yesterday = useYesterday(); const yesterday = useYesterday();
@ -53,7 +52,7 @@ const SimpleMarketList = () => {
}, [gridRef]); }, [gridRef]);
useEffect(() => { useEffect(() => {
const statuses: Record<string, MarketState | ''> = {}; const statuses: Record<string, Schema.MarketState | ''> = {};
data?.forEach((market) => { data?.forEach((market) => {
statuses[market.id] = market.state || ''; statuses[market.id] = market.state || '';
}); });

View File

@ -1,13 +1,13 @@
import React from 'react'; import React from 'react';
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { MarketState } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import MarketNameRenderer from './simple-market-renderer'; import MarketNameRenderer from './simple-market-renderer';
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
describe('SimpleMarketRenderer', () => { describe('SimpleMarketRenderer', () => {
const market = { const market = {
id: 'MARKET_A', id: 'MARKET_A',
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
instrument: { instrument: {
code: 'MARKET_A_CODE', code: 'MARKET_A_CODE',

View File

@ -14,7 +14,7 @@ import {
getAllByText, getAllByText,
} from '@testing-library/react'; } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing'; import { MockedProvider } from '@apollo/react-testing';
import { MarketState } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
import SimpleMarketToolbar from './simple-market-toolbar'; import SimpleMarketToolbar from './simple-market-toolbar';
import { markets as filterData } from './mocks/market-filters.json'; import { markets as filterData } from './mocks/market-filters.json';
@ -113,7 +113,7 @@ describe('SimpleMarketToolbar', () => {
await waitFor(() => { await waitFor(() => {
expect(screen.getByTestId('location-display')).toHaveTextContent( expect(screen.getByTestId('location-display')).toHaveTextContent(
`/markets/${MarketState.STATE_ACTIVE}/Future` `/markets/${Schema.MarketState.STATE_ACTIVE}/Future`
); );
}); });
@ -124,7 +124,7 @@ describe('SimpleMarketToolbar', () => {
); );
await waitFor(() => { await waitFor(() => {
expect(screen.getByTestId('location-display')).toHaveTextContent( expect(screen.getByTestId('location-display')).toHaveTextContent(
`/markets/${MarketState.STATE_ACTIVE}/Future/tEURO` `/markets/${Schema.MarketState.STATE_ACTIVE}/Future/tEURO`
); );
}); });
@ -139,7 +139,7 @@ describe('SimpleMarketToolbar', () => {
}); });
await waitFor(() => { await waitFor(() => {
expect(mockedNavigate).toHaveBeenCalledWith( expect(mockedNavigate).toHaveBeenCalledWith(
`/markets/${MarketState.STATE_PENDING}/Future/tEURO` `/markets/${Schema.MarketState.STATE_PENDING}/Future/tEURO`
); );
}); });
}); });
@ -165,7 +165,7 @@ describe('SimpleMarketToolbar', () => {
fireEvent.click(suspended); fireEvent.click(suspended);
expect(mockedNavigate).toHaveBeenCalledWith( expect(mockedNavigate).toHaveBeenCalledWith(
`/markets/${MarketState.STATE_SUSPENDED}/product1/asset1` `/markets/${Schema.MarketState.STATE_SUSPENDED}/product1/asset1`
); );
}); });
@ -186,7 +186,7 @@ describe('SimpleMarketToolbar', () => {
fireEvent.click(closed); fireEvent.click(closed);
expect(mockedNavigate).toHaveBeenCalledWith( expect(mockedNavigate).toHaveBeenCalledWith(
`/markets/${MarketState.STATE_CLOSED}` `/markets/${Schema.MarketState.STATE_CLOSED}`
); );
}); });

View File

@ -13,7 +13,7 @@ import {
DropdownMenuItemIndicator, DropdownMenuItemIndicator,
Icon, Icon,
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { MarketState } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
import { HorizontalMenu } from '../horizontal-menu'; import { HorizontalMenu } from '../horizontal-menu';
import type { HorizontalMenuItem } from '../horizontal-menu'; import type { HorizontalMenuItem } from '../horizontal-menu';
@ -36,7 +36,7 @@ const SimpleMarketToolbar = ({ data }: Props) => {
params.asset && params.asset !== 'all' ? `/${params.asset}` : ''; params.asset && params.asset !== 'all' ? `/${params.asset}` : '';
const product = params.product ? `/${params.product}` : ''; const product = params.product ? `/${params.product}` : '';
const state = const state =
activeState !== MarketState.STATE_ACTIVE || product activeState !== Schema.MarketState.STATE_ACTIVE || product
? `/${activeState}` ? `/${activeState}`
: ''; : '';
navigate(`/markets${state}${product}${asset}`); navigate(`/markets${state}${product}${asset}`);
@ -45,8 +45,8 @@ const SimpleMarketToolbar = ({ data }: Props) => {
); );
const productItems = useMemo(() => { const productItems = useMemo(() => {
const currentState = params.state || MarketState.STATE_ACTIVE; const currentState = params.state || Schema.MarketState.STATE_ACTIVE;
const noStateSkip = currentState !== MarketState.STATE_ACTIVE; const noStateSkip = currentState !== Schema.MarketState.STATE_ACTIVE;
const items: HorizontalMenuItem[] = [ const items: HorizontalMenuItem[] = [
{ {
...constants.ALL_PRODUCTS_ITEM, ...constants.ALL_PRODUCTS_ITEM,
@ -83,7 +83,8 @@ const SimpleMarketToolbar = ({ data }: Props) => {
{constants.STATES_FILTER.find( {constants.STATES_FILTER.find(
(state) => (state) =>
state.value === params.state || state.value === params.state ||
(!params.state && state.value === MarketState.STATE_ACTIVE) (!params.state &&
state.value === Schema.MarketState.STATE_ACTIVE)
)?.text || params.state} )?.text || params.state}
<Icon <Icon
name={IconNames.ARROW_DOWN} name={IconNames.ARROW_DOWN}
@ -103,7 +104,7 @@ const SimpleMarketToolbar = ({ data }: Props) => {
key={value} key={value}
checked={ checked={
value === params.state || value === params.state ||
(!params.state && value === MarketState.STATE_ACTIVE) (!params.state && value === Schema.MarketState.STATE_ACTIVE)
} }
onCheckedChange={() => onStateChange(value)} onCheckedChange={() => onStateChange(value)}
> >

View File

@ -1,5 +1,5 @@
import { useMemo } from 'react'; import { useMemo } from 'react';
import { MarketState } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { MarketWithCandles } from '@vegaprotocol/market-list'; import type { MarketWithCandles } from '@vegaprotocol/market-list';
import type { RouterParams } from './simple-market-list'; import type { RouterParams } from './simple-market-list';
@ -30,7 +30,7 @@ const useMarketsFilterData = (
? '' ? ''
: params.state : params.state
? params.state ? params.state
: MarketState.STATE_ACTIVE; : Schema.MarketState.STATE_ACTIVE;
if (state && state !== item.state) { if (state && state !== item.state) {
return false; return false;
} }

View File

@ -1,26 +1,26 @@
import { MarketState } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
export const DATE_FORMAT = 'dd MMMM yyyy HH:mm'; export const DATE_FORMAT = 'dd MMMM yyyy HH:mm';
export const TRADABLE_STATES = { export const TRADABLE_STATES = {
[MarketState.STATE_ACTIVE]: true, [Schema.MarketState.STATE_ACTIVE]: true,
}; };
export const IS_MARKET_TRADABLE = (market: Market) => export const IS_MARKET_TRADABLE = (market: Market) =>
Boolean((market.state ?? '') in TRADABLE_STATES && market?.id); Boolean((market.state ?? '') in TRADABLE_STATES && market?.id);
export const MARKET_STATES_MAP: Record<MarketState | '', string> = { export const MARKET_STATES_MAP: Record<Schema.MarketState | '', string> = {
[MarketState.STATE_ACTIVE]: t('Active'), [Schema.MarketState.STATE_ACTIVE]: t('Active'),
[MarketState.STATE_CANCELLED]: t('Cancelled'), [Schema.MarketState.STATE_CANCELLED]: t('Cancelled'),
[MarketState.STATE_CLOSED]: t('Closed'), [Schema.MarketState.STATE_CLOSED]: t('Closed'),
[MarketState.STATE_PENDING]: t('Pending'), [Schema.MarketState.STATE_PENDING]: t('Pending'),
[MarketState.STATE_PROPOSED]: t('Proposed'), [Schema.MarketState.STATE_PROPOSED]: t('Proposed'),
[MarketState.STATE_REJECTED]: t('Rejected'), [Schema.MarketState.STATE_REJECTED]: t('Rejected'),
[MarketState.STATE_SETTLED]: t('Settled'), [Schema.MarketState.STATE_SETTLED]: t('Settled'),
[MarketState.STATE_SUSPENDED]: t('Suspended'), [Schema.MarketState.STATE_SUSPENDED]: t('Suspended'),
[MarketState.STATE_TRADING_TERMINATED]: t('TradingTerminated'), [Schema.MarketState.STATE_TRADING_TERMINATED]: t('TradingTerminated'),
'': t('Unknown'), '': t('Unknown'),
}; };

View File

@ -87,7 +87,10 @@ context('Validator page', { tags: '@smoke' }, function () {
}); });
}); });
it('should be able to see relevant node information in vega data section', function () { // Test disabled 2022/11/15 during the 0.62.1 upgrade. The JSON structure changed, and
// this test failed. Rather than fix it, it will be replaced when the validator view displays
// something useful rather than just dumping out the JSON.
xit('should be able to see relevant node information in vega data section', function () {
cy.get(vegaDataHeader) cy.get(vegaDataHeader)
.contains('Vega data') .contains('Vega data')
.next() .next()
@ -97,7 +100,7 @@ context('Validator page', { tags: '@smoke' }, function () {
.convert_string_json_to_js_object() .convert_string_json_to_js_object()
.then((nodesInJson) => { .then((nodesInJson) => {
this.nodes.forEach((node, index) => { this.nodes.forEach((node, index) => {
const nodeInJson = nodesInJson.nodes[index]; const nodeInJson = nodesInJson.edges[index].node;
// Vegacapsule shows no info or null for following fields: // Vegacapsule shows no info or null for following fields:
// name, infoURL, avatarUrl, location, epoch data // name, infoURL, avatarUrl, location, epoch data

View File

@ -1,8 +1,8 @@
# App configuration variables # App configuration variables
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
NX_TENDERMINT_URL=https://tm.n07.testnet.vega.xyz NX_TENDERMINT_URL=https://be.testnet.vega.xyz
NX_BLOCK_EXPLORER=https://be.testnet.vega.xyz/rest NX_BLOCK_EXPLORER=https://be.testnet.vega.xyz/rest
NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n07.testnet.vega.xyz/websocket NX_TENDERMINT_WEBSOCKET_URL=wss://be.testnet.vega.xyz/
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/testnet-network.json NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/testnet-network.json
NX_VEGA_NETWORKS={\"MAINNET"\:\"https://explorer.vega.xyz"\,\"TESTNET\":\"https://explorer.fairground.wtf\"} NX_VEGA_NETWORKS={\"MAINNET"\:\"https://explorer.vega.xyz"\,\"TESTNET\":\"https://explorer.fairground.wtf\"}
NX_VEGA_ENV=TESTNET NX_VEGA_ENV=TESTNET

View File

@ -1,35 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: TxsStats
// ====================================================
export interface TxsStats_statistics {
__typename: "Statistics";
/**
* Average number of orders added per blocks
*/
averageOrdersPerBlock: string;
/**
* Number of orders per seconds
*/
ordersPerSecond: string;
/**
* Number of transaction processed per block
*/
txPerBlock: string;
/**
* Number of the trades per seconds
*/
tradesPerSecond: string;
}
export interface TxsStats {
/**
* Get statistics about the Vega node
*/
statistics: TxsStats_statistics;
}

View File

@ -0,0 +1,54 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type ExplorerStatsFieldsFragment = { __typename?: 'Statistics', averageOrdersPerBlock: string, ordersPerSecond: string, txPerBlock: string, tradesPerSecond: string };
export type ExplorerStatsQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type ExplorerStatsQuery = { __typename?: 'Query', statistics: { __typename?: 'Statistics', averageOrdersPerBlock: string, ordersPerSecond: string, txPerBlock: string, tradesPerSecond: string } };
export const ExplorerStatsFieldsFragmentDoc = gql`
fragment ExplorerStatsFields on Statistics {
averageOrdersPerBlock
ordersPerSecond
txPerBlock
tradesPerSecond
}
`;
export const ExplorerStatsDocument = gql`
query ExplorerStats {
statistics {
...ExplorerStatsFields
}
}
${ExplorerStatsFieldsFragmentDoc}`;
/**
* __useExplorerStatsQuery__
*
* To run a query within a React component, call `useExplorerStatsQuery` and pass it any options that fit your needs.
* When your component renders, `useExplorerStatsQuery` 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 } = useExplorerStatsQuery({
* variables: {
* },
* });
*/
export function useExplorerStatsQuery(baseOptions?: Apollo.QueryHookOptions<ExplorerStatsQuery, ExplorerStatsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ExplorerStatsQuery, ExplorerStatsQueryVariables>(ExplorerStatsDocument, options);
}
export function useExplorerStatsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExplorerStatsQuery, ExplorerStatsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ExplorerStatsQuery, ExplorerStatsQueryVariables>(ExplorerStatsDocument, options);
}
export type ExplorerStatsQueryHookResult = ReturnType<typeof useExplorerStatsQuery>;
export type ExplorerStatsLazyQueryHookResult = ReturnType<typeof useExplorerStatsLazyQuery>;
export type ExplorerStatsQueryResult = Apollo.QueryResult<ExplorerStatsQuery, ExplorerStatsQueryVariables>;

View File

@ -0,0 +1,11 @@
fragment ExplorerStatsFields on Statistics {
averageOrdersPerBlock
ordersPerSecond
txPerBlock
tradesPerSecond
}
query ExplorerStats {
statistics {
...ExplorerStatsFields
}
}

View File

@ -1,23 +1,12 @@
import { gql, useQuery } from '@apollo/client';
import { t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import { useEffect } from 'react'; import { useEffect } from 'react';
import { InfoBlock } from '../../components/info-block'; import { InfoBlock } from '../../components/info-block';
import { Panel } from '../../components/panel'; import { Panel } from '../../components/panel';
import type { TxsStats, TxsStats_statistics } from './__generated__/TxsStats'; import { useExplorerStatsQuery } from './__generated__/explorer-stats';
import type { ExplorerStatsFieldsFragment } from './__generated__/explorer-stats';
const STATS_QUERY = gql`
query TxsStats {
statistics {
averageOrdersPerBlock
ordersPerSecond
txPerBlock
tradesPerSecond
}
}
`;
interface StatsMap { interface StatsMap {
field: keyof TxsStats_statistics; field: keyof ExplorerStatsFieldsFragment;
label: string; label: string;
info: string; info: string;
} }
@ -54,7 +43,7 @@ interface TxsStatsInfoProps {
} }
export const TxsStatsInfo = ({ className }: TxsStatsInfoProps) => { export const TxsStatsInfo = ({ className }: TxsStatsInfoProps) => {
const { data, startPolling, stopPolling } = useQuery<TxsStats>(STATS_QUERY); const { data, startPolling, stopPolling } = useExplorerStatsQuery();
useEffect(() => { useEffect(() => {
startPolling(1000); startPolling(1000);
@ -67,13 +56,21 @@ export const TxsStatsInfo = ({ className }: TxsStatsInfoProps) => {
return ( return (
<Panel className={className}> <Panel className={className}>
<section className={gridStyles}> <section className={gridStyles}>
{TXS_STATS_MAP.map((field) => ( {TXS_STATS_MAP.map((field) => {
<InfoBlock if (!data?.statistics) {
subtitle={field.label} return null;
tooltipInfo={field.info} }
title={data?.statistics[field.field] || ''}
/> // Workaround for awkward typing
))} const title = data.statistics[field.field] || '';
return (
<InfoBlock
subtitle={field.label}
tooltipInfo={field.info}
title={title}
/>
);
})}
</section> </section>
</Panel> </Panel>
); );

View File

@ -1,103 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AccountType } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: AssetsQuery
// ====================================================
export interface AssetsQuery_assetsConnection_edges_node_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export interface AssetsQuery_assetsConnection_edges_node_source_BuiltinAsset {
__typename: "BuiltinAsset";
/**
* Maximum amount that can be requested by a party through the built-in asset faucet at a time
*/
maxFaucetAmountMint: string;
}
export type AssetsQuery_assetsConnection_edges_node_source = AssetsQuery_assetsConnection_edges_node_source_ERC20 | AssetsQuery_assetsConnection_edges_node_source_BuiltinAsset;
export interface AssetsQuery_assetsConnection_edges_node_infrastructureFeeAccount_market {
__typename: "Market";
/**
* Market ID
*/
id: string;
}
export interface AssetsQuery_assetsConnection_edges_node_infrastructureFeeAccount {
__typename: "AccountBalance";
/**
* Account type (General, Margin, etc)
*/
type: AccountType;
/**
* Balance as string - current account balance (approx. as balances can be updated several times per second)
*/
balance: string;
/**
* Market (only relevant to margin accounts)
*/
market: AssetsQuery_assetsConnection_edges_node_infrastructureFeeAccount_market | null;
}
export interface AssetsQuery_assetsConnection_edges_node {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
/**
* The origin source of the asset (e.g: an ERC20 asset)
*/
source: AssetsQuery_assetsConnection_edges_node_source;
/**
* The infrastructure fee account for this asset
*/
infrastructureFeeAccount: AssetsQuery_assetsConnection_edges_node_infrastructureFeeAccount | null;
}
export interface AssetsQuery_assetsConnection_edges {
__typename: "AssetEdge";
/**
* The asset information
*/
node: AssetsQuery_assetsConnection_edges_node;
}
export interface AssetsQuery_assetsConnection {
__typename: "AssetsConnection";
/**
* The assets
*/
edges: (AssetsQuery_assetsConnection_edges | null)[] | null;
}
export interface AssetsQuery {
/**
* The list of all assets in use in the Vega network or the specified asset if ID is provided
*/
assetsConnection: AssetsQuery_assetsConnection | null;
}

View File

@ -0,0 +1,67 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type ExplorerAssetsQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type ExplorerAssetsQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string }, infrastructureFeeAccount?: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null } | null } } | null> | null } | null };
export const ExplorerAssetsDocument = gql`
query ExplorerAssets {
assetsConnection {
edges {
node {
id
name
symbol
decimals
source {
... on ERC20 {
contractAddress
}
... on BuiltinAsset {
maxFaucetAmountMint
}
}
infrastructureFeeAccount {
type
balance
market {
id
}
}
}
}
}
}
`;
/**
* __useExplorerAssetsQuery__
*
* To run a query within a React component, call `useExplorerAssetsQuery` and pass it any options that fit your needs.
* When your component renders, `useExplorerAssetsQuery` 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 } = useExplorerAssetsQuery({
* variables: {
* },
* });
*/
export function useExplorerAssetsQuery(baseOptions?: Apollo.QueryHookOptions<ExplorerAssetsQuery, ExplorerAssetsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ExplorerAssetsQuery, ExplorerAssetsQueryVariables>(ExplorerAssetsDocument, options);
}
export function useExplorerAssetsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExplorerAssetsQuery, ExplorerAssetsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ExplorerAssetsQuery, ExplorerAssetsQueryVariables>(ExplorerAssetsDocument, options);
}
export type ExplorerAssetsQueryHookResult = ReturnType<typeof useExplorerAssetsQuery>;
export type ExplorerAssetsLazyQueryHookResult = ReturnType<typeof useExplorerAssetsLazyQuery>;
export type ExplorerAssetsQueryResult = Apollo.QueryResult<ExplorerAssetsQuery, ExplorerAssetsQueryVariables>;

View File

@ -0,0 +1,27 @@
query ExplorerAssets {
assetsConnection {
edges {
node {
id
name
symbol
decimals
source {
... on ERC20 {
contractAddress
}
... on BuiltinAsset {
maxFaucetAmountMint
}
}
infrastructureFeeAccount {
type
balance
market {
id
}
}
}
}
}
}

View File

@ -1,63 +1,38 @@
import { gql, useQuery } from '@apollo/client';
import { t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import React from 'react'; import React from 'react';
import { RouteTitle } from '../../components/route-title'; import { RouteTitle } from '../../components/route-title';
import { SubHeading } from '../../components/sub-heading'; import { SubHeading } from '../../components/sub-heading';
import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit'; import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit';
import type { import { useExplorerAssetsQuery } from './__generated__/assets';
AssetsQuery,
AssetsQuery_assetsConnection_edges_node,
} from './__generated__/AssetsQuery';
export const ASSETS_QUERY = gql`
query AssetsQuery {
assetsConnection {
edges {
node {
id
name
symbol
decimals
source {
... on ERC20 {
contractAddress
}
... on BuiltinAsset {
maxFaucetAmountMint
}
}
infrastructureFeeAccount {
type
balance
market {
id
}
}
}
}
}
}
`;
const Assets = () => { const Assets = () => {
const { data } = useQuery<AssetsQuery>(ASSETS_QUERY); const { data } = useExplorerAssetsQuery();
const assets = const assets = data?.assetsConnection?.edges?.map((n) => {
data?.assetsConnection?.edges return n?.node;
?.filter((e) => e && e?.node) });
.map((e) => e?.node as AssetsQuery_assetsConnection_edges_node) || [];
if (!assets || assets.length === 0) {
return <section></section>;
}
return ( return (
<section> <section>
<RouteTitle data-testid="assets-header">{t('Assets')}</RouteTitle> <RouteTitle data-testid="assets-header">{t('Assets')}</RouteTitle>
{assets.map((a) => ( {assets.map((a) => {
<React.Fragment key={a.id}> if (!a) {
<SubHeading data-testid="asset-header"> return null;
{a.name} ({a.symbol}) }
</SubHeading>
<SyntaxHighlighter data={a} /> return (
</React.Fragment> <React.Fragment key={a.id}>
))} <SubHeading data-testid="asset-header">
{a.name} ({a.symbol})
</SubHeading>
<SyntaxHighlighter data={a} />
</React.Fragment>
);
})}
</section> </section>
); );
}; };

View File

@ -1,306 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { ProposalState, ProposalRejectionReason, VoteValue } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: ProposalsQuery
// ====================================================
export interface ProposalsQuery_proposalsConnection_edges_node_rationale {
__typename: "ProposalRationale";
/**
* Title to be used to give a short description of the proposal in lists.
* This is to be between 0 and 100 unicode characters.
* This is mandatory for all proposals.
*/
title: string;
/**
* Description to show a short title / something in case the link goes offline.
* This is to be between 0 and 20k unicode characters.
* This is mandatory for all proposals.
*/
description: string;
}
export interface ProposalsQuery_proposalsConnection_edges_node_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface ProposalsQuery_proposalsConnection_edges_node_terms_change_UpdateAsset {
__typename: "UpdateAsset" | "NewFreeform";
}
export interface ProposalsQuery_proposalsConnection_edges_node_terms_change_NewMarket_instrument {
__typename: "InstrumentConfiguration";
/**
* Full and fairly descriptive name for the instrument
*/
name: string;
}
export interface ProposalsQuery_proposalsConnection_edges_node_terms_change_NewMarket {
__typename: "NewMarket";
/**
* New market instrument configuration
*/
instrument: ProposalsQuery_proposalsConnection_edges_node_terms_change_NewMarket_instrument;
}
export interface ProposalsQuery_proposalsConnection_edges_node_terms_change_UpdateMarket {
__typename: "UpdateMarket";
marketId: string;
}
export interface ProposalsQuery_proposalsConnection_edges_node_terms_change_NewAsset_source_BuiltinAsset {
__typename: "BuiltinAsset";
/**
* Maximum amount that can be requested by a party through the built-in asset faucet at a time
*/
maxFaucetAmountMint: string;
}
export interface ProposalsQuery_proposalsConnection_edges_node_terms_change_NewAsset_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type ProposalsQuery_proposalsConnection_edges_node_terms_change_NewAsset_source = ProposalsQuery_proposalsConnection_edges_node_terms_change_NewAsset_source_BuiltinAsset | ProposalsQuery_proposalsConnection_edges_node_terms_change_NewAsset_source_ERC20;
export interface ProposalsQuery_proposalsConnection_edges_node_terms_change_NewAsset {
__typename: "NewAsset";
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The source of the new asset
*/
source: ProposalsQuery_proposalsConnection_edges_node_terms_change_NewAsset_source;
}
export interface ProposalsQuery_proposalsConnection_edges_node_terms_change_UpdateNetworkParameter_networkParameter {
__typename: "NetworkParameter";
/**
* The name of the network parameter
*/
key: string;
/**
* The value of the network parameter
*/
value: string;
}
export interface ProposalsQuery_proposalsConnection_edges_node_terms_change_UpdateNetworkParameter {
__typename: "UpdateNetworkParameter";
networkParameter: ProposalsQuery_proposalsConnection_edges_node_terms_change_UpdateNetworkParameter_networkParameter;
}
export type ProposalsQuery_proposalsConnection_edges_node_terms_change = ProposalsQuery_proposalsConnection_edges_node_terms_change_UpdateAsset | ProposalsQuery_proposalsConnection_edges_node_terms_change_NewMarket | ProposalsQuery_proposalsConnection_edges_node_terms_change_UpdateMarket | ProposalsQuery_proposalsConnection_edges_node_terms_change_NewAsset | ProposalsQuery_proposalsConnection_edges_node_terms_change_UpdateNetworkParameter;
export interface ProposalsQuery_proposalsConnection_edges_node_terms {
__typename: "ProposalTerms";
/**
* RFC3339Nano time and date when voting closes for this proposal.
* Constrained by "minClose" and "maxClose" network parameters.
*/
closingDatetime: string;
/**
* RFC3339Nano time and date when this proposal is executed (if passed). Note that it has to be after closing date time.
* Constrained by "minEnactInSeconds" and "maxEnactInSeconds" network parameters.
* Note: Optional as free form proposals do not require it.
*/
enactmentDatetime: string | null;
/**
* Actual change being introduced by the proposal - action the proposal triggers if passed and enacted.
*/
change: ProposalsQuery_proposalsConnection_edges_node_terms_change;
}
export interface ProposalsQuery_proposalsConnection_edges_node_votes_yes_votes_party_stakingSummary {
__typename: "StakingSummary";
/**
* The stake currently available for the party
*/
currentStakeAvailable: string;
}
export interface ProposalsQuery_proposalsConnection_edges_node_votes_yes_votes_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
/**
* The staking information for this Party
*/
stakingSummary: ProposalsQuery_proposalsConnection_edges_node_votes_yes_votes_party_stakingSummary;
}
export interface ProposalsQuery_proposalsConnection_edges_node_votes_yes_votes {
__typename: "Vote";
/**
* The vote value cast
*/
value: VoteValue;
/**
* The party casting the vote
*/
party: ProposalsQuery_proposalsConnection_edges_node_votes_yes_votes_party;
/**
* RFC3339Nano time and date when the vote reached Vega network
*/
datetime: string;
}
export interface ProposalsQuery_proposalsConnection_edges_node_votes_yes {
__typename: "ProposalVoteSide";
/**
* Total number of governance tokens from the votes cast for this side
*/
totalTokens: string;
/**
* Total number of votes cast for this side
*/
totalNumber: string;
/**
* All votes cast for this side
*/
votes: ProposalsQuery_proposalsConnection_edges_node_votes_yes_votes[] | null;
}
export interface ProposalsQuery_proposalsConnection_edges_node_votes_no_votes_party_stakingSummary {
__typename: "StakingSummary";
/**
* The stake currently available for the party
*/
currentStakeAvailable: string;
}
export interface ProposalsQuery_proposalsConnection_edges_node_votes_no_votes_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
/**
* The staking information for this Party
*/
stakingSummary: ProposalsQuery_proposalsConnection_edges_node_votes_no_votes_party_stakingSummary;
}
export interface ProposalsQuery_proposalsConnection_edges_node_votes_no_votes {
__typename: "Vote";
/**
* The vote value cast
*/
value: VoteValue;
/**
* The party casting the vote
*/
party: ProposalsQuery_proposalsConnection_edges_node_votes_no_votes_party;
/**
* RFC3339Nano time and date when the vote reached Vega network
*/
datetime: string;
}
export interface ProposalsQuery_proposalsConnection_edges_node_votes_no {
__typename: "ProposalVoteSide";
/**
* Total number of governance tokens from the votes cast for this side
*/
totalTokens: string;
/**
* Total number of votes cast for this side
*/
totalNumber: string;
/**
* All votes cast for this side
*/
votes: ProposalsQuery_proposalsConnection_edges_node_votes_no_votes[] | null;
}
export interface ProposalsQuery_proposalsConnection_edges_node_votes {
__typename: "ProposalVotes";
/**
* Yes votes cast for this proposal
*/
yes: ProposalsQuery_proposalsConnection_edges_node_votes_yes;
/**
* No votes cast for this proposal
*/
no: ProposalsQuery_proposalsConnection_edges_node_votes_no;
}
export interface ProposalsQuery_proposalsConnection_edges_node {
__typename: "Proposal";
/**
* Proposal ID that is filled by Vega once proposal reaches the network
*/
id: string | null;
/**
* Rationale behind the proposal
*/
rationale: ProposalsQuery_proposalsConnection_edges_node_rationale;
/**
* A UUID reference to aid tracking proposals on Vega
*/
reference: string;
/**
* State of the proposal
*/
state: ProposalState;
/**
* RFC3339Nano time and date when the proposal reached Vega network
*/
datetime: string;
/**
* Why the proposal was rejected by the core
*/
rejectionReason: ProposalRejectionReason | null;
/**
* Party that prepared the proposal
*/
party: ProposalsQuery_proposalsConnection_edges_node_party;
/**
* Terms of the proposal
*/
terms: ProposalsQuery_proposalsConnection_edges_node_terms;
/**
* Votes cast for this proposal
*/
votes: ProposalsQuery_proposalsConnection_edges_node_votes;
}
export interface ProposalsQuery_proposalsConnection_edges {
__typename: "ProposalEdge";
/**
* The proposal data
*/
node: ProposalsQuery_proposalsConnection_edges_node;
}
export interface ProposalsQuery_proposalsConnection {
__typename: "ProposalsConnection";
/**
* List of proposals available for the connection
*/
edges: (ProposalsQuery_proposalsConnection_edges | null)[] | null;
}
export interface ProposalsQuery {
/**
* All governance proposals in the Vega network
*/
proposalsConnection: ProposalsQuery_proposalsConnection | null;
}

View File

@ -0,0 +1,122 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type ExplorerProposalsQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type ExplorerProposalsQuery = { __typename?: 'Query', proposalsConnection?: { __typename?: 'ProposalsConnection', edges?: Array<{ __typename?: 'ProposalEdge', node: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: string, enactmentDatetime?: string | null, change: { __typename: 'NewAsset', symbol: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null } } } } | null> | null } | null };
export const ExplorerProposalsDocument = gql`
query ExplorerProposals {
proposalsConnection {
edges {
node {
id
rationale {
title
description
}
reference
state
datetime
rejectionReason
party {
id
}
terms {
closingDatetime
enactmentDatetime
change {
... on NewMarket {
instrument {
name
}
}
... on UpdateMarket {
marketId
}
... on NewAsset {
__typename
symbol
source {
... on BuiltinAsset {
maxFaucetAmountMint
}
... on ERC20 {
contractAddress
}
}
}
... on UpdateNetworkParameter {
networkParameter {
key
value
}
}
}
}
votes {
yes {
totalTokens
totalNumber
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
no {
totalTokens
totalNumber
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
}
}
}
}
}
`;
/**
* __useExplorerProposalsQuery__
*
* To run a query within a React component, call `useExplorerProposalsQuery` and pass it any options that fit your needs.
* When your component renders, `useExplorerProposalsQuery` 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 } = useExplorerProposalsQuery({
* variables: {
* },
* });
*/
export function useExplorerProposalsQuery(baseOptions?: Apollo.QueryHookOptions<ExplorerProposalsQuery, ExplorerProposalsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ExplorerProposalsQuery, ExplorerProposalsQueryVariables>(ExplorerProposalsDocument, options);
}
export function useExplorerProposalsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExplorerProposalsQuery, ExplorerProposalsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ExplorerProposalsQuery, ExplorerProposalsQueryVariables>(ExplorerProposalsDocument, options);
}
export type ExplorerProposalsQueryHookResult = ReturnType<typeof useExplorerProposalsQuery>;
export type ExplorerProposalsLazyQueryHookResult = ReturnType<typeof useExplorerProposalsLazyQuery>;
export type ExplorerProposalsQueryResult = Apollo.QueryResult<ExplorerProposalsQuery, ExplorerProposalsQueryVariables>;

View File

@ -1,122 +1,42 @@
import { gql, useQuery } from '@apollo/client';
import { t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import React from 'react'; import React from 'react';
import { RouteTitle } from '../../components/route-title'; import { RouteTitle } from '../../components/route-title';
import { SubHeading } from '../../components/sub-heading'; import { SubHeading } from '../../components/sub-heading';
import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit'; import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit';
import { getProposals } from '@vegaprotocol/governance'; import { useExplorerProposalsQuery } from './__generated__/proposals';
import type {
ProposalsQuery,
ProposalsQuery_proposalsConnection_edges_node,
} from './__generated__/ProposalsQuery';
const PROPOSALS_QUERY = gql`
query ProposalsQuery {
proposalsConnection {
edges {
node {
id
rationale {
title
description
}
reference
state
datetime
rejectionReason
party {
id
}
terms {
closingDatetime
enactmentDatetime
change {
... on NewMarket {
instrument {
name
}
}
... on UpdateMarket {
marketId
}
... on NewAsset {
__typename
symbol
source {
... on BuiltinAsset {
maxFaucetAmountMint
}
... on ERC20 {
contractAddress
}
}
}
... on UpdateNetworkParameter {
networkParameter {
key
value
}
}
}
}
votes {
yes {
totalTokens
totalNumber
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
no {
totalTokens
totalNumber
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
}
}
}
}
}
`;
const Governance = () => { const Governance = () => {
const { data } = useQuery<ProposalsQuery>(PROPOSALS_QUERY, { const { data } = useExplorerProposalsQuery({
errorPolicy: 'ignore', errorPolicy: 'ignore',
}); });
const proposals = getProposals(
data
) as ProposalsQuery_proposalsConnection_edges_node[];
if (!data) return null; if (!data || !data.proposalsConnection || !data.proposalsConnection.edges) {
return <section></section>;
}
const proposals = data?.proposalsConnection?.edges.map((e) => {
return e?.node;
});
return ( return (
<section> <section>
<RouteTitle data-testid="governance-header"> <RouteTitle data-testid="governance-header">
{t('Governance Proposals')} {t('Governance Proposals')}
</RouteTitle> </RouteTitle>
{proposals.map((p) => ( {proposals.map((p) => {
<React.Fragment key={p.id}> if (!p || !p.id) {
<SubHeading> return null;
{p.rationale.title || p.rationale.description} }
</SubHeading>
<SyntaxHighlighter data={p} /> return (
</React.Fragment> <React.Fragment key={p.id}>
))} <SubHeading>
{p.rationale.title || p.rationale.description}
</SubHeading>
<SyntaxHighlighter data={p} />
</React.Fragment>
);
})}
</section> </section>
); );
}; };

View File

@ -0,0 +1,82 @@
query ExplorerProposals {
proposalsConnection {
edges {
node {
id
rationale {
title
description
}
reference
state
datetime
rejectionReason
party {
id
}
terms {
closingDatetime
enactmentDatetime
change {
... on NewMarket {
instrument {
name
}
}
... on UpdateMarket {
marketId
}
... on NewAsset {
__typename
symbol
source {
... on BuiltinAsset {
maxFaucetAmountMint
}
... on ERC20 {
contractAddress
}
}
}
... on UpdateNetworkParameter {
networkParameter {
key
value
}
}
}
}
votes {
yes {
totalTokens
totalNumber
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
no {
totalTokens
totalNumber
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
}
}
}
}
}

View File

@ -1,533 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { MarketTradingMode, MarketState, AccountType, AuctionTrigger } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: MarketsQuery
// ====================================================
export interface MarketsQuery_markets_fees_factors {
__typename: "FeeFactors";
/**
* The factor applied to calculate MakerFees, a non-negative float
*/
makerFee: string;
/**
* The factor applied to calculate InfrastructureFees, a non-negative float
*/
infrastructureFee: string;
/**
* The factor applied to calculate LiquidityFees, a non-negative float
*/
liquidityFee: string;
}
export interface MarketsQuery_markets_fees {
__typename: "Fees";
/**
* The factors used to calculate the different fees
*/
factors: MarketsQuery_markets_fees_factors;
}
export interface MarketsQuery_markets_tradableInstrument_instrument_metadata {
__typename: "InstrumentMetadata";
/**
* An arbitrary list of tags to associated to associate to the Instrument (string list)
*/
tags: string[] | null;
}
export interface MarketsQuery_markets_tradableInstrument_instrument_product_settlementAsset_globalRewardPoolAccount {
__typename: "AccountBalance";
/**
* Balance as string - current account balance (approx. as balances can be updated several times per second)
*/
balance: string;
}
export interface MarketsQuery_markets_tradableInstrument_instrument_product_settlementAsset {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
/**
* The global reward pool account for this asset
*/
globalRewardPoolAccount: MarketsQuery_markets_tradableInstrument_instrument_product_settlementAsset_globalRewardPoolAccount | null;
}
export interface MarketsQuery_markets_tradableInstrument_instrument_product {
__typename: "Future";
/**
* The name of the asset (string)
*/
settlementAsset: MarketsQuery_markets_tradableInstrument_instrument_product_settlementAsset;
}
export interface MarketsQuery_markets_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Full and fairly descriptive name for the instrument
*/
name: string;
/**
* Metadata for this instrument
*/
metadata: MarketsQuery_markets_tradableInstrument_instrument_metadata;
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
*/
code: string;
/**
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
*/
product: MarketsQuery_markets_tradableInstrument_instrument_product;
}
export interface MarketsQuery_markets_tradableInstrument_riskModel_LogNormalRiskModel_params {
__typename: "LogNormalModelParams";
/**
* R parameter
*/
r: number;
/**
* Sigma parameter, annualised volatility of the underlying asset, must be a strictly non-negative real number
*/
sigma: number;
/**
* Mu parameter, annualised growth rate of the underlying asset
*/
mu: number;
}
export interface MarketsQuery_markets_tradableInstrument_riskModel_LogNormalRiskModel {
__typename: "LogNormalRiskModel";
/**
* Tau parameter of the risk model, projection horizon measured as a year fraction used in the expected shortfall calculation to obtain the maintenance margin, must be a strictly non-negative real number
*/
tau: number;
/**
* Lambda parameter of the risk model, probability confidence level used in expected shortfall calculation when obtaining the maintenance margin level, must be strictly greater than 0 and strictly smaller than 1
*/
riskAversionParameter: number;
/**
* Parameters for the log normal risk model
*/
params: MarketsQuery_markets_tradableInstrument_riskModel_LogNormalRiskModel_params;
}
export interface MarketsQuery_markets_tradableInstrument_riskModel_SimpleRiskModel_params {
__typename: "SimpleRiskModelParams";
/**
* Risk factor for long
*/
factorLong: number;
/**
* Risk factor for short
*/
factorShort: number;
}
export interface MarketsQuery_markets_tradableInstrument_riskModel_SimpleRiskModel {
__typename: "SimpleRiskModel";
/**
* Params for the simple risk model
*/
params: MarketsQuery_markets_tradableInstrument_riskModel_SimpleRiskModel_params;
}
export type MarketsQuery_markets_tradableInstrument_riskModel = MarketsQuery_markets_tradableInstrument_riskModel_LogNormalRiskModel | MarketsQuery_markets_tradableInstrument_riskModel_SimpleRiskModel;
export interface MarketsQuery_markets_tradableInstrument_marginCalculator_scalingFactors {
__typename: "ScalingFactors";
/**
* The scaling factor that determines the margin level at which Vega has to search for more money
*/
searchLevel: number;
/**
* The scaling factor that determines the optimal margin level
*/
initialMargin: number;
/**
* The scaling factor that determines the overflow margin level
*/
collateralRelease: number;
}
export interface MarketsQuery_markets_tradableInstrument_marginCalculator {
__typename: "MarginCalculator";
/**
* The scaling factors that will be used for margin calculation
*/
scalingFactors: MarketsQuery_markets_tradableInstrument_marginCalculator_scalingFactors;
}
export interface MarketsQuery_markets_tradableInstrument {
__typename: "TradableInstrument";
/**
* An instance of, or reference to, a fully specified instrument.
*/
instrument: MarketsQuery_markets_tradableInstrument_instrument;
/**
* A reference to a risk model that is valid for the instrument
*/
riskModel: MarketsQuery_markets_tradableInstrument_riskModel;
/**
* Margin calculation info, currently only the scaling factors (search, initial, release) for this tradable instrument
*/
marginCalculator: MarketsQuery_markets_tradableInstrument_marginCalculator | null;
}
export interface MarketsQuery_markets_openingAuction {
__typename: "AuctionDuration";
/**
* Duration of the auction in seconds
*/
durationSecs: number;
/**
* Target uncrossing trading volume
*/
volume: number;
}
export interface MarketsQuery_markets_priceMonitoringSettings_parameters_triggers {
__typename: "PriceMonitoringTrigger";
/**
* Price monitoring projection horizon τ in seconds (> 0).
*/
horizonSecs: number;
/**
* Price monitoring probability level p. (>0 and < 1)
*/
probability: number;
/**
* Price monitoring auction extension duration in seconds should the price
* breach its theoretical level over the specified horizon at the specified
* probability level (> 0)
*/
auctionExtensionSecs: number;
}
export interface MarketsQuery_markets_priceMonitoringSettings_parameters {
__typename: "PriceMonitoringParameters";
/**
* The list of triggers for this price monitoring
*/
triggers: MarketsQuery_markets_priceMonitoringSettings_parameters_triggers[] | null;
}
export interface MarketsQuery_markets_priceMonitoringSettings {
__typename: "PriceMonitoringSettings";
/**
* Specified a set of PriceMonitoringParameters to be use for price monitoring purposes
*/
parameters: MarketsQuery_markets_priceMonitoringSettings_parameters | null;
}
export interface MarketsQuery_markets_liquidityMonitoringParameters_targetStakeParameters {
__typename: "TargetStakeParameters";
/**
* Specifies length of time window expressed in seconds for target stake calculation
*/
timeWindow: number;
/**
* Specifies scaling factors used in target stake calculation
*/
scalingFactor: number;
}
export interface MarketsQuery_markets_liquidityMonitoringParameters {
__typename: "LiquidityMonitoringParameters";
/**
* Specifies the triggering ratio for entering liquidity auction
*/
triggeringRatio: number;
/**
* Specifies parameters related to target stake calculation
*/
targetStakeParameters: MarketsQuery_markets_liquidityMonitoringParameters_targetStakeParameters;
}
export interface MarketsQuery_markets_proposal {
__typename: "Proposal";
/**
* Proposal ID that is filled by Vega once proposal reaches the network
*/
id: string | null;
}
export interface MarketsQuery_markets_accounts_asset {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
}
export interface MarketsQuery_markets_accounts {
__typename: "AccountBalance";
/**
* Asset, the 'currency'
*/
asset: MarketsQuery_markets_accounts_asset;
/**
* Balance as string - current account balance (approx. as balances can be updated several times per second)
*/
balance: string;
/**
* Account type (General, Margin, etc)
*/
type: AccountType;
}
export interface MarketsQuery_markets_data_priceMonitoringBounds_trigger {
__typename: "PriceMonitoringTrigger";
/**
* Price monitoring auction extension duration in seconds should the price
* breach its theoretical level over the specified horizon at the specified
* probability level (> 0)
*/
auctionExtensionSecs: number;
/**
* Price monitoring probability level p. (>0 and < 1)
*/
probability: number;
}
export interface MarketsQuery_markets_data_priceMonitoringBounds {
__typename: "PriceMonitoringBounds";
/**
* Minimum price that isn't currently breaching the specified price monitoring trigger
*/
minValidPrice: string;
/**
* Maximum price that isn't currently breaching the specified price monitoring trigger
*/
maxValidPrice: string;
/**
* Price monitoring trigger associated with the bounds
*/
trigger: MarketsQuery_markets_data_priceMonitoringBounds_trigger;
/**
* Reference price used to calculate the valid price range
*/
referencePrice: string;
}
export interface MarketsQuery_markets_data_liquidityProviderFeeShare_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface MarketsQuery_markets_data_liquidityProviderFeeShare {
__typename: "LiquidityProviderFeeShare";
/**
* The liquidity provider party ID
*/
party: MarketsQuery_markets_data_liquidityProviderFeeShare_party;
/**
* The share owned by this liquidity provider (float)
*/
equityLikeShare: string;
/**
* The average entry valuation of the liquidity provider for the market
*/
averageEntryValuation: string;
}
export interface MarketsQuery_markets_data {
__typename: "MarketData";
/**
* The mark price (an unsigned integer)
*/
markPrice: string;
/**
* The highest price level on an order book for buy orders.
*/
bestBidPrice: string;
/**
* The aggregated volume being bid at the best bid price.
*/
bestBidVolume: string;
/**
* The lowest price level on an order book for offer orders.
*/
bestOfferPrice: string;
/**
* The aggregated volume being offered at the best offer price.
*/
bestOfferVolume: string;
/**
* The highest price level on an order book for buy orders not including pegged orders.
*/
bestStaticBidPrice: string;
/**
* The aggregated volume being offered at the best static bid price, excluding pegged orders
*/
bestStaticBidVolume: string;
/**
* The lowest price level on an order book for offer orders not including pegged orders.
*/
bestStaticOfferPrice: string;
/**
* The aggregated volume being offered at the best static offer price, excluding pegged orders.
*/
bestStaticOfferVolume: string;
/**
* The arithmetic average of the best bid price and best offer price.
*/
midPrice: string;
/**
* The arithmetic average of the best static bid price and best static offer price
*/
staticMidPrice: string;
/**
* RFC3339Nano time at which this market price was relevant
*/
timestamp: string;
/**
* The sum of the size of all positions greater than 0.
*/
openInterest: string;
/**
* RFC3339Nano time at which the auction will stop (null if not in auction mode)
*/
auctionEnd: string | null;
/**
* RFC3339Nano time at which the next auction will start (null if none is scheduled)
*/
auctionStart: string | null;
/**
* Indicative price if the auction ended now, 0 if not in auction mode
*/
indicativePrice: string;
/**
* Indicative volume if the auction ended now, 0 if not in auction mode
*/
indicativeVolume: string;
/**
* What triggered an auction (if an auction was started)
*/
trigger: AuctionTrigger;
/**
* What extended the ongoing auction (if an auction was extended)
*/
extensionTrigger: AuctionTrigger;
/**
* The amount of stake targeted for this market
*/
targetStake: string | null;
/**
* The supplied stake for the market
*/
suppliedStake: string | null;
/**
* A list of valid price ranges per associated trigger
*/
priceMonitoringBounds: MarketsQuery_markets_data_priceMonitoringBounds[] | null;
/**
* The market value proxy
*/
marketValueProxy: string;
/**
* The equity like share of liquidity fee for each liquidity provider
*/
liquidityProviderFeeShare: MarketsQuery_markets_data_liquidityProviderFeeShare[] | null;
}
export interface MarketsQuery_markets {
__typename: "Market";
/**
* Market ID
*/
id: string;
/**
* Fees related data
*/
fees: MarketsQuery_markets_fees;
/**
* An instance of, or reference to, a tradable instrument.
*/
tradableInstrument: MarketsQuery_markets_tradableInstrument;
/**
* The number of decimal places that an integer must be shifted by in order to get a correct
* number denominated in the currency of the market. (uint64)
*
* Examples:
* Currency Balance decimalPlaces Real Balance
* GBP 100 0 GBP 100
* GBP 100 2 GBP 1.00
* GBP 100 4 GBP 0.01
* GBP 1 4 GBP 0.0001 ( 0.01p )
*
* GBX (pence) 100 0 GBP 1.00 (100p )
* GBX (pence) 100 2 GBP 0.01 ( 1p )
* GBX (pence) 100 4 GBP 0.0001 ( 0.01p )
* GBX (pence) 1 4 GBP 0.000001 ( 0.0001p)
*/
decimalPlaces: number;
/**
* Auction duration specifies how long the opening auction will run (minimum
* duration and optionally a minimum traded volume).
*/
openingAuction: MarketsQuery_markets_openingAuction;
/**
* Price monitoring settings for the market
*/
priceMonitoringSettings: MarketsQuery_markets_priceMonitoringSettings;
/**
* Liquidity monitoring parameters for the market
*/
liquidityMonitoringParameters: MarketsQuery_markets_liquidityMonitoringParameters;
/**
* Current mode of execution of the market
*/
tradingMode: MarketTradingMode;
/**
* Current state of the market
*/
state: MarketState;
/**
* The proposal that initiated this market
*/
proposal: MarketsQuery_markets_proposal | null;
/**
* Get account for a party or market
*/
accounts: MarketsQuery_markets_accounts[] | null;
/**
* marketData for the given market
*/
data: MarketsQuery_markets_data | null;
}
export interface MarketsQuery {
/**
* One or more instruments that are trading on the VEGA network
*/
markets: MarketsQuery_markets[] | null;
}

View File

@ -0,0 +1,180 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type ExplorerMarketsQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type ExplorerMarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, decimalPlaces: number, tradingMode: Types.MarketTradingMode, state: Types.MarketState, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, name: string, decimals: number, globalRewardPoolAccount?: { __typename?: 'AccountBalance', balance: string } | null } } }, riskModel: { __typename?: 'LogNormalRiskModel', tau: number, riskAversionParameter: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } }, marginCalculator?: { __typename?: 'MarginCalculator', scalingFactors: { __typename?: 'ScalingFactors', searchLevel: number, initialMargin: number, collateralRelease: number } } | null }, openingAuction: { __typename?: 'AuctionDuration', durationSecs: number, volume: number }, priceMonitoringSettings: { __typename?: 'PriceMonitoringSettings', parameters?: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null } | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: number, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, proposal?: { __typename?: 'Proposal', id?: string | null } | null, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', balance: string, type: Types.AccountType, asset: { __typename?: 'Asset', id: string, name: string } } } | null> | null } | null, data?: { __typename?: 'MarketData', markPrice: string, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, midPrice: string, staticMidPrice: string, timestamp: string, openInterest: string, auctionEnd?: string | null, auctionStart?: string | null, indicativePrice: string, indicativeVolume: string, trigger: Types.AuctionTrigger, extensionTrigger: Types.AuctionTrigger, targetStake?: string | null, suppliedStake?: string | null, marketValueProxy: string, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', auctionExtensionSecs: number, probability: number } }> | null, liquidityProviderFeeShare?: Array<{ __typename?: 'LiquidityProviderFeeShare', equityLikeShare: string, averageEntryValuation: string, party: { __typename?: 'Party', id: string } }> | null } | null } }> } | null };
export const ExplorerMarketsDocument = gql`
query ExplorerMarkets {
marketsConnection {
edges {
node {
id
fees {
factors {
makerFee
infrastructureFee
liquidityFee
}
}
tradableInstrument {
instrument {
name
metadata {
tags
}
code
product {
... on Future {
settlementAsset {
id
name
decimals
globalRewardPoolAccount {
balance
}
}
}
}
}
riskModel {
... on LogNormalRiskModel {
tau
riskAversionParameter
params {
r
sigma
mu
}
}
... on SimpleRiskModel {
params {
factorLong
factorShort
}
}
}
marginCalculator {
scalingFactors {
searchLevel
initialMargin
collateralRelease
}
}
}
decimalPlaces
openingAuction {
durationSecs
volume
}
priceMonitoringSettings {
parameters {
triggers {
horizonSecs
probability
auctionExtensionSecs
}
}
}
liquidityMonitoringParameters {
triggeringRatio
targetStakeParameters {
timeWindow
scalingFactor
}
}
tradingMode
state
proposal {
id
}
state
accountsConnection {
edges {
node {
asset {
id
name
}
balance
type
}
}
}
data {
markPrice
bestBidPrice
bestBidVolume
bestOfferPrice
bestOfferVolume
bestStaticBidPrice
bestStaticBidVolume
bestStaticOfferPrice
bestStaticOfferVolume
midPrice
staticMidPrice
timestamp
openInterest
auctionEnd
auctionStart
indicativePrice
indicativeVolume
trigger
extensionTrigger
targetStake
suppliedStake
priceMonitoringBounds {
minValidPrice
maxValidPrice
trigger {
auctionExtensionSecs
probability
}
referencePrice
}
marketValueProxy
liquidityProviderFeeShare {
party {
id
}
equityLikeShare
averageEntryValuation
}
}
}
}
}
}
`;
/**
* __useExplorerMarketsQuery__
*
* To run a query within a React component, call `useExplorerMarketsQuery` and pass it any options that fit your needs.
* When your component renders, `useExplorerMarketsQuery` 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 } = useExplorerMarketsQuery({
* variables: {
* },
* });
*/
export function useExplorerMarketsQuery(baseOptions?: Apollo.QueryHookOptions<ExplorerMarketsQuery, ExplorerMarketsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ExplorerMarketsQuery, ExplorerMarketsQueryVariables>(ExplorerMarketsDocument, options);
}
export function useExplorerMarketsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExplorerMarketsQuery, ExplorerMarketsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ExplorerMarketsQuery, ExplorerMarketsQueryVariables>(ExplorerMarketsDocument, options);
}
export type ExplorerMarketsQueryHookResult = ReturnType<typeof useExplorerMarketsQuery>;
export type ExplorerMarketsLazyQueryHookResult = ReturnType<typeof useExplorerMarketsLazyQuery>;
export type ExplorerMarketsQueryResult = Apollo.QueryResult<ExplorerMarketsQuery, ExplorerMarketsQueryVariables>;

View File

@ -1,162 +1,26 @@
import { gql, useQuery } from '@apollo/client';
import type { MarketsQuery } from './__generated__/MarketsQuery';
import React from 'react'; import React from 'react';
import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit'; import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit';
import { RouteTitle } from '../../components/route-title'; import { RouteTitle } from '../../components/route-title';
import { SubHeading } from '../../components/sub-heading'; import { SubHeading } from '../../components/sub-heading';
import { t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import { useExplorerMarketsQuery } from './__generated__/markets';
const MARKETS_QUERY = gql`
query MarketsQuery {
markets {
id
fees {
factors {
makerFee
infrastructureFee
liquidityFee
}
}
tradableInstrument {
instrument {
name
metadata {
tags
}
id
code
product {
... on Future {
settlementAsset {
id
name
decimals
globalRewardPoolAccount {
balance
}
}
}
}
}
riskModel {
... on LogNormalRiskModel {
tau
riskAversionParameter
params {
r
sigma
mu
}
}
... on SimpleRiskModel {
params {
factorLong
factorShort
}
}
}
marginCalculator {
scalingFactors {
searchLevel
initialMargin
collateralRelease
}
}
}
decimalPlaces
openingAuction {
durationSecs
volume
}
priceMonitoringSettings {
parameters {
triggers {
horizonSecs
probability
auctionExtensionSecs
}
}
}
liquidityMonitoringParameters {
triggeringRatio
targetStakeParameters {
timeWindow
scalingFactor
}
}
tradingMode
state
proposal {
id
}
state
accounts {
asset {
id
name
}
balance
type
}
data {
markPrice
bestBidPrice
bestBidVolume
bestOfferPrice
bestOfferVolume
bestStaticBidPrice
bestStaticBidVolume
bestStaticOfferPrice
bestStaticOfferVolume
midPrice
staticMidPrice
timestamp
openInterest
auctionEnd
auctionStart
indicativePrice
indicativeVolume
trigger
extensionTrigger
targetStake
suppliedStake
priceMonitoringBounds {
minValidPrice
maxValidPrice
trigger {
auctionExtensionSecs
probability
}
referencePrice
}
marketValueProxy
liquidityProviderFeeShare {
party {
id
}
equityLikeShare
averageEntryValuation
}
}
}
}
`;
const Markets = () => { const Markets = () => {
const { data } = useQuery<MarketsQuery>(MARKETS_QUERY); const { data } = useExplorerMarketsQuery();
const m = data?.marketsConnection?.edges;
return ( return (
<section> <section key="markets">
<RouteTitle data-testid="markets-heading">{t('Markets')}</RouteTitle> <RouteTitle data-testid="markets-heading">{t('Markets')}</RouteTitle>
{data?.markets {m
? data.markets.map((m) => ( ? m.map((e) => (
<React.Fragment key={m.id}> <React.Fragment key={e.node.id}>
<SubHeading data-testid="markets-header"> <SubHeading data-testid="markets-header">
{m.tradableInstrument.instrument.name} {e.node.tradableInstrument.instrument.name}
</SubHeading> </SubHeading>
<SyntaxHighlighter data={m} /> <SyntaxHighlighter data={e.node} />
</React.Fragment> </React.Fragment>
)) ))
: null} : null}

View File

@ -0,0 +1,140 @@
query ExplorerMarkets {
marketsConnection {
edges {
node {
id
fees {
factors {
makerFee
infrastructureFee
liquidityFee
}
}
tradableInstrument {
instrument {
name
metadata {
tags
}
code
product {
... on Future {
settlementAsset {
id
name
decimals
globalRewardPoolAccount {
balance
}
}
}
}
}
riskModel {
... on LogNormalRiskModel {
tau
riskAversionParameter
params {
r
sigma
mu
}
}
... on SimpleRiskModel {
params {
factorLong
factorShort
}
}
}
marginCalculator {
scalingFactors {
searchLevel
initialMargin
collateralRelease
}
}
}
decimalPlaces
openingAuction {
durationSecs
volume
}
priceMonitoringSettings {
parameters {
triggers {
horizonSecs
probability
auctionExtensionSecs
}
}
}
liquidityMonitoringParameters {
triggeringRatio
targetStakeParameters {
timeWindow
scalingFactor
}
}
tradingMode
state
proposal {
id
}
state
accountsConnection {
edges {
node {
asset {
id
name
}
balance
type
}
}
}
data {
markPrice
bestBidPrice
bestBidVolume
bestOfferPrice
bestOfferVolume
bestStaticBidPrice
bestStaticBidVolume
bestStaticOfferPrice
bestStaticOfferVolume
midPrice
staticMidPrice
timestamp
openInterest
auctionEnd
auctionStart
indicativePrice
indicativeVolume
trigger
extensionTrigger
targetStake
suppliedStake
priceMonitoringBounds {
minValidPrice
maxValidPrice
trigger {
auctionExtensionSecs
probability
}
referencePrice
}
marketValueProxy
liquidityProviderFeeShare {
party {
id
}
equityLikeShare
averageEntryValuation
}
}
}
}
}
}

View File

@ -1,233 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { DataSourceSpecStatus, ConditionOperator, PropertyKeyType } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: OracleSpecs
// ====================================================
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionInternal_sourceType_conditions {
__typename: "Condition";
/**
* The value to compare against.
*/
value: string | null;
/**
* The type of comparison to make on the value.
*/
operator: ConditionOperator;
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionInternal_sourceType {
__typename: "DataSourceSpecConfigurationTime";
conditions: (OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionInternal_sourceType_conditions | null)[];
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionInternal {
__typename: "DataSourceDefinitionInternal";
sourceType: OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionInternal_sourceType;
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_signers_signer_ETHAddress {
__typename: "ETHAddress";
address: string | null;
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_signers_signer_PubKey {
__typename: "PubKey";
key: string | null;
}
export type OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_signers_signer = OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_signers_signer_ETHAddress | OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_signers_signer_PubKey;
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_signers {
__typename: "Signer";
signer: OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_signers_signer;
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_filters_key {
__typename: "PropertyKey";
/**
* The name of the property.
*/
name: string | null;
/**
* The type of the property.
*/
type: PropertyKeyType;
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_filters_conditions {
__typename: "Condition";
/**
* The value to compare against.
*/
value: string | null;
/**
* The type of comparison to make on the value.
*/
operator: ConditionOperator;
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_filters {
__typename: "Filter";
/**
* key is the data source data property key targeted by the filter.
*/
key: OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_filters_key;
/**
* The conditions that should be matched by the data to be
* considered of interest.
*/
conditions: OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_filters_conditions[] | null;
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType {
__typename: "DataSourceSpecConfiguration";
/**
* signers is the list of authorized signatures that signed the data for this
* data source. All the public keys in the data should be contained in this
* list.
*/
signers: OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_signers[] | null;
/**
* filters describes which source data are considered of interest or not for
* the product (or the risk model).
*/
filters: OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType_filters[] | null;
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal {
__typename: "DataSourceDefinitionExternal";
sourceType: OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal_sourceType;
}
export type OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType = OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionInternal | OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType_DataSourceDefinitionExternal;
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec_data {
__typename: "DataSourceDefinition";
sourceType: OracleSpecs_oracleSpecs_dataSourceSpec_spec_data_sourceType;
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec_spec {
__typename: "DataSourceSpec";
/**
* ID is a hash generated from the DataSourceSpec data.
*/
id: string;
/**
* RFC3339Nano creation date time
*/
createdAt: string;
/**
* RFC3339Nano last updated timestamp
*/
updatedAt: string | null;
/**
* Status describes the status of the data source spec
*/
status: DataSourceSpecStatus;
data: OracleSpecs_oracleSpecs_dataSourceSpec_spec_data;
}
export interface OracleSpecs_oracleSpecs_dataSourceSpec {
__typename: "ExternalDataSourceSpec";
spec: OracleSpecs_oracleSpecs_dataSourceSpec_spec;
}
export interface OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data_signers_signer_ETHAddress {
__typename: "ETHAddress";
address: string | null;
}
export interface OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data_signers_signer_PubKey {
__typename: "PubKey";
key: string | null;
}
export type OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data_signers_signer = OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data_signers_signer_ETHAddress | OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data_signers_signer_PubKey;
export interface OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data_signers {
__typename: "Signer";
signer: OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data_signers_signer;
}
export interface OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data_data {
__typename: "Property";
/**
* Name of the property
*/
name: string;
/**
* Value of the property
*/
value: string;
}
export interface OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data {
__typename: "Data";
/**
* signers is the list of public keys/ETH addresses that signed the data
*/
signers: OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data_signers[] | null;
/**
* properties contains all the properties sent by a data source
*/
data: OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data_data[] | null;
/**
* List of all the data specs that matched this source data.
* When the array is empty, it means no data spec matched this source data.
*/
matchedSpecIds: string[] | null;
/**
* RFC3339Nano formatted date and time for when the data was broadcast to the markets
* with a matching data spec.
* It has no value when the source data does not match any data spec.
*/
broadcastAt: string;
}
export interface OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData {
__typename: "ExternalData";
data: OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData_data;
}
export interface OracleSpecs_oracleSpecs_dataConnection_edges_node {
__typename: "OracleData";
externalData: OracleSpecs_oracleSpecs_dataConnection_edges_node_externalData;
}
export interface OracleSpecs_oracleSpecs_dataConnection_edges {
__typename: "OracleDataEdge";
/**
* The oracle data source
*/
node: OracleSpecs_oracleSpecs_dataConnection_edges_node;
}
export interface OracleSpecs_oracleSpecs_dataConnection {
__typename: "OracleDataConnection";
/**
* The oracle data spec
*/
edges: (OracleSpecs_oracleSpecs_dataConnection_edges | null)[] | null;
}
export interface OracleSpecs_oracleSpecs {
__typename: "OracleSpec";
dataSourceSpec: OracleSpecs_oracleSpecs_dataSourceSpec;
/**
* Data list all the oracle data broadcast to this spec
*/
dataConnection: OracleSpecs_oracleSpecs_dataConnection;
}
export interface OracleSpecs {
/**
* All registered oracle specs
*/
oracleSpecs: OracleSpecs_oracleSpecs[] | null;
}

View File

@ -1,126 +0,0 @@
import { gql, useQuery } from '@apollo/client';
import { useLocation } from 'react-router-dom';
import type { OracleSpecs as OracleSpecsQuery } from './__generated__/OracleSpecs';
import React, { useEffect } from 'react';
import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit';
import { RouteTitle } from '../../components/route-title';
import { t } from '@vegaprotocol/react-helpers';
import { SubHeading } from '../../components/sub-heading';
const ORACLE_SPECS_QUERY = gql`
query OracleSpecs {
oracleSpecs {
dataSourceSpec {
spec {
id
createdAt
updatedAt
status
data {
sourceType {
... on DataSourceDefinitionInternal {
sourceType {
... on DataSourceSpecConfigurationTime {
conditions {
value
operator
}
}
}
}
... on DataSourceDefinitionExternal {
sourceType {
... on DataSourceSpecConfiguration {
signers {
signer {
... on ETHAddress {
address
}
... on PubKey {
key
}
}
}
filters {
key {
name
type
}
conditions {
value
operator
}
}
}
}
}
}
}
}
}
dataConnection {
edges {
node {
externalData {
data {
signers {
signer {
... on ETHAddress {
address
}
... on PubKey {
key
}
}
}
data {
name
value
}
matchedSpecIds
broadcastAt
}
}
}
}
}
}
}
`;
const Oracles = () => {
const { hash } = useLocation();
const { data, loading } = useQuery<OracleSpecsQuery>(ORACLE_SPECS_QUERY);
useEffect(() => {
if (data && !loading && hash) {
const element = document.getElementById(hash.substring(1));
if (element) {
window.scrollTo({
top: element.offsetTop,
});
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hash, loading, !!data]);
return (
<section>
<RouteTitle data-testid="oracle-specs-heading">{t('Oracles')}</RouteTitle>
{data?.oracleSpecs
? data.oracleSpecs.map((o) => {
const id = o.dataSourceSpec.spec.id;
return (
<React.Fragment key={id}>
<SubHeading id={id.toString()}>{id}</SubHeading>
<SyntaxHighlighter data={o} />
</React.Fragment>
);
})
: null}
</section>
);
};
export default Oracles;

View File

@ -1,99 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AccountType } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: PartyAssetsQuery
// ====================================================
export interface PartyAssetsQuery_party_stakingSummary {
__typename: "StakingSummary";
/**
* The stake currently available for the party
*/
currentStakeAvailable: string;
}
export interface PartyAssetsQuery_party_accounts_asset_source_BuiltinAsset {
__typename: "BuiltinAsset";
}
export interface PartyAssetsQuery_party_accounts_asset_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type PartyAssetsQuery_party_accounts_asset_source = PartyAssetsQuery_party_accounts_asset_source_BuiltinAsset | PartyAssetsQuery_party_accounts_asset_source_ERC20;
export interface PartyAssetsQuery_party_accounts_asset {
__typename: "Asset";
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The ID of the asset
*/
id: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The origin source of the asset (e.g: an ERC20 asset)
*/
source: PartyAssetsQuery_party_accounts_asset_source;
}
export interface PartyAssetsQuery_party_accounts {
__typename: "AccountBalance";
/**
* Asset, the 'currency'
*/
asset: PartyAssetsQuery_party_accounts_asset;
/**
* Account type (General, Margin, etc)
*/
type: AccountType;
/**
* Balance as string - current account balance (approx. as balances can be updated several times per second)
*/
balance: string;
}
export interface PartyAssetsQuery_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
/**
* The staking information for this Party
*/
stakingSummary: PartyAssetsQuery_party_stakingSummary;
/**
* Collateral accounts relating to a party
*/
accounts: PartyAssetsQuery_party_accounts[] | null;
}
export interface PartyAssetsQuery {
/**
* An entity that is trading on the Vega network
*/
party: PartyAssetsQuery_party | null;
}
export interface PartyAssetsQueryVariables {
partyId: string;
}

View File

@ -0,0 +1,87 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
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 }, 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 } } } } | null> | null } | null } }> } | null };
export const ExplorerPartyAssetsDocument = gql`
query ExplorerPartyAssets($partyId: ID!) {
partiesConnection(id: $partyId) {
edges {
node {
id
delegationsConnection {
edges {
node {
amount
node {
id
name
}
epoch
}
}
}
stakingSummary {
currentStakeAvailable
}
accountsConnection {
edges {
node {
asset {
name
id
decimals
symbol
source {
__typename
... on ERC20 {
contractAddress
}
}
}
type
balance
}
}
}
}
}
}
}
`;
/**
* __useExplorerPartyAssetsQuery__
*
* To run a query within a React component, call `useExplorerPartyAssetsQuery` and pass it any options that fit your needs.
* When your component renders, `useExplorerPartyAssetsQuery` 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 } = useExplorerPartyAssetsQuery({
* variables: {
* partyId: // value for 'partyId'
* },
* });
*/
export function useExplorerPartyAssetsQuery(baseOptions: Apollo.QueryHookOptions<ExplorerPartyAssetsQuery, ExplorerPartyAssetsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ExplorerPartyAssetsQuery, ExplorerPartyAssetsQueryVariables>(ExplorerPartyAssetsDocument, options);
}
export function useExplorerPartyAssetsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExplorerPartyAssetsQuery, ExplorerPartyAssetsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ExplorerPartyAssetsQuery, ExplorerPartyAssetsQueryVariables>(ExplorerPartyAssetsDocument, options);
}
export type ExplorerPartyAssetsQueryHookResult = ReturnType<typeof useExplorerPartyAssetsQuery>;
export type ExplorerPartyAssetsLazyQueryHookResult = ReturnType<typeof useExplorerPartyAssetsLazyQuery>;
export type ExplorerPartyAssetsQueryResult = Apollo.QueryResult<ExplorerPartyAssetsQuery, ExplorerPartyAssetsQueryVariables>;

View File

@ -1,5 +1,3 @@
import { useQuery } from '@apollo/client';
import { gql } from '@apollo/client';
import { import {
t, t,
useFetch, useFetch,
@ -14,45 +12,15 @@ import { Panel } from '../../../components/panel';
import { InfoPanel } from '../../../components/info-panel'; import { InfoPanel } from '../../../components/info-panel';
import { toNonHex } from '../../../components/search/detect-search'; import { toNonHex } from '../../../components/search/detect-search';
import { DATA_SOURCES } from '../../../config'; import { DATA_SOURCES } from '../../../config';
import type {
PartyAssetsQuery,
PartyAssetsQueryVariables,
} from './__generated__/PartyAssetsQuery';
import type { TendermintSearchTransactionResponse } from '../tendermint-transaction-response'; import type { TendermintSearchTransactionResponse } from '../tendermint-transaction-response';
import { useTxsData } from '../../../hooks/use-txs-data'; import { useTxsData } from '../../../hooks/use-txs-data';
import { TxsInfiniteList } from '../../../components/txs'; import { TxsInfiniteList } from '../../../components/txs';
import { PageHeader } from '../../../components/page-header'; import { PageHeader } from '../../../components/page-header';
import { useExplorerPartyAssetsQuery } from './__generated__/party-assets';
const PARTY_ASSETS_QUERY = gql`
query PartyAssetsQuery($partyId: ID!) {
party(id: $partyId) {
id
stakingSummary {
currentStakeAvailable
}
accounts {
asset {
name
id
decimals
symbol
source {
__typename
... on ERC20 {
contractAddress
}
}
}
type
balance
}
}
}
`;
const Party = () => { const Party = () => {
const { party } = useParams<{ party: string }>(); const { party } = useParams<{ party: string }>();
const partyId = party ? toNonHex(party) : ''; const partyId = toNonHex(party ? party : '');
const { isMobile } = useScreenDimensions(); const { isMobile } = useScreenDimensions();
const visibleChars = useMemo(() => (isMobile ? 10 : 14), [isMobile]); const visibleChars = useMemo(() => (isMobile ? 10 : 14), [isMobile]);
const filters = `filters[tx.submitter]=${partyId}`; const filters = `filters[tx.submitter]=${partyId}`;
@ -67,19 +35,18 @@ const Party = () => {
`${DATA_SOURCES.tendermintUrl}/tx_search?query="tx.submitter='${partyId}'"` `${DATA_SOURCES.tendermintUrl}/tx_search?query="tx.submitter='${partyId}'"`
); );
const { data } = useQuery<PartyAssetsQuery, PartyAssetsQueryVariables>( const { data } = useExplorerPartyAssetsQuery({
PARTY_ASSETS_QUERY, // Don't cache data for this query, party information can move quite quickly
{ fetchPolicy: 'network-only',
// Don't cache data for this query, party information can move quite quickly variables: { partyId: partyId },
fetchPolicy: 'network-only', skip: !party,
variables: { partyId }, });
skip: !party,
}
);
const header = data?.party?.id ? ( const p = data?.partiesConnection?.edges[0].node;
const header = p?.id ? (
<PageHeader <PageHeader
title={data.party.id} title={p.id}
copy copy
truncateStart={visibleChars} truncateStart={visibleChars}
truncateEnd={visibleChars} truncateEnd={visibleChars}
@ -92,8 +59,13 @@ const Party = () => {
const accounts = ( const accounts = (
<section> <section>
{data?.party?.accounts?.length ? ( {p?.accountsConnection?.edges?.length ? (
data.party.accounts.map((account) => { p.accountsConnection?.edges?.map((a) => {
const account = a?.node;
if (!account || !account.asset) {
return '';
}
return ( return (
<InfoPanel title={account.asset.name} id={account.asset.id}> <InfoPanel title={account.asset.name} id={account.asset.id}>
<section> <section>
@ -122,10 +94,10 @@ const Party = () => {
const staking = ( const staking = (
<section> <section>
{data?.party?.stakingSummary?.currentStakeAvailable ? ( {p?.stakingSummary?.currentStakeAvailable ? (
<InfoPanel <InfoPanel
title={t('Current Stake Available')} title={t('Current Stake Available')}
id={data?.party?.stakingSummary?.currentStakeAvailable} id={p?.stakingSummary?.currentStakeAvailable}
copy={false} copy={false}
/> />
) : ( ) : (

View File

@ -0,0 +1,44 @@
query ExplorerPartyAssets($partyId: ID!) {
partiesConnection(id: $partyId) {
edges {
node {
id
delegationsConnection {
edges {
node {
amount
node {
id
name
}
epoch
}
}
}
stakingSummary {
currentStakeAvailable
}
accountsConnection {
edges {
node {
asset {
name
id
decimals
symbol
source {
__typename
... on ERC20 {
contractAddress
}
}
}
type
balance
}
}
}
}
}
}
}

View File

@ -3,7 +3,6 @@ import BlockPage from './blocks';
import Governance from './governance'; import Governance from './governance';
import Home from './home'; import Home from './home';
import Markets from './markets'; import Markets from './markets';
import Oracles from './oracles';
import Party from './parties'; import Party from './parties';
import { Parties } from './parties/home'; import { Parties } from './parties/home';
import { Party as PartySingle } from './parties/id'; import { Party as PartySingle } from './parties/id';
@ -85,17 +84,6 @@ const marketsRoutes = flags.markets
] ]
: []; : [];
const oraclesRoutes = flags.oracles
? [
{
path: Routes.ORACLES,
name: 'Oracles',
text: t('Oracles'),
element: <Oracles />,
},
]
: [];
const networkParametersRoutes = flags.networkParameters const networkParametersRoutes = flags.networkParameters
? [ ? [
{ {
@ -166,7 +154,6 @@ const routerConfig = [
...genesisRoutes, ...genesisRoutes,
...governanceRoutes, ...governanceRoutes,
...marketsRoutes, ...marketsRoutes,
...oraclesRoutes,
...networkParametersRoutes, ...networkParametersRoutes,
...validators, ...validators,
]; ];

View File

@ -1,87 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { NodeStatus } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: NodesQuery
// ====================================================
export interface NodesQuery_nodes_epochData {
__typename: "EpochData";
/**
* Total number of epochs since node was created
*/
total: number;
/**
* Total number of offline epochs since node was created
*/
offline: number;
/**
* Total number of online epochs since node was created
*/
online: number;
}
export interface NodesQuery_nodes {
__typename: "Node";
/**
* The node URL eg n01.vega.xyz
*/
id: string;
name: string;
/**
* URL from which you can get more info about the node.
*/
infoUrl: string;
avatarUrl: string | null;
/**
* Public key of the node operator
*/
pubkey: string;
/**
* Tendermint public key of the node
*/
tmPubkey: string;
/**
* Ethereum public key of the node
*/
ethereumAddress: string;
/**
* Country code for the location of the node
*/
location: string;
/**
* The amount of stake the node has put up themselves
*/
stakedByOperator: string;
/**
* The amount of stake that has been delegated by token holders
*/
stakedByDelegates: string;
/**
* Total amount staked on node
*/
stakedTotal: string;
/**
* Amount of stake on the next epoch
*/
pendingStake: string;
/**
* Summary of epoch data across all nodes
*/
epochData: NodesQuery_nodes_epochData | null;
/**
* Validator status of the node
*/
status: NodeStatus;
}
export interface NodesQuery {
/**
* All known network nodes
*/
nodes: NodesQuery_nodes[] | null;
}

View File

@ -0,0 +1,67 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type ExplorerNodesQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type ExplorerNodesQuery = { __typename?: 'Query', nodesConnection: { __typename?: 'NodesConnection', edges?: Array<{ __typename?: 'NodeEdge', node: { __typename?: 'Node', id: string, name: string, infoUrl: string, avatarUrl?: string | null, pubkey: string, tmPubkey: string, ethereumAddress: string, location: string, stakedByOperator: string, stakedByDelegates: string, stakedTotal: string, pendingStake: string, status: Types.NodeStatus, epochData?: { __typename?: 'EpochData', total: number, offline: number, online: number } | null } } | null> | null } };
export const ExplorerNodesDocument = gql`
query ExplorerNodes {
nodesConnection {
edges {
node {
id
name
infoUrl
avatarUrl
pubkey
tmPubkey
ethereumAddress
location
stakedByOperator
stakedByDelegates
stakedTotal
pendingStake
epochData {
total
offline
online
}
status
name
}
}
}
}
`;
/**
* __useExplorerNodesQuery__
*
* To run a query within a React component, call `useExplorerNodesQuery` and pass it any options that fit your needs.
* When your component renders, `useExplorerNodesQuery` 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 } = useExplorerNodesQuery({
* variables: {
* },
* });
*/
export function useExplorerNodesQuery(baseOptions?: Apollo.QueryHookOptions<ExplorerNodesQuery, ExplorerNodesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ExplorerNodesQuery, ExplorerNodesQueryVariables>(ExplorerNodesDocument, options);
}
export function useExplorerNodesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExplorerNodesQuery, ExplorerNodesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ExplorerNodesQuery, ExplorerNodesQueryVariables>(ExplorerNodesDocument, options);
}
export type ExplorerNodesQueryHookResult = ReturnType<typeof useExplorerNodesQuery>;
export type ExplorerNodesLazyQueryHookResult = ReturnType<typeof useExplorerNodesLazyQuery>;
export type ExplorerNodesQueryResult = Apollo.QueryResult<ExplorerNodesQuery, ExplorerNodesQueryVariables>;

View File

@ -1,4 +1,3 @@
import { gql, useQuery } from '@apollo/client';
import { t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import React from 'react'; import React from 'react';
import { RouteTitle } from '../../components/route-title'; import { RouteTitle } from '../../components/route-title';
@ -7,33 +6,7 @@ import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit';
import { DATA_SOURCES } from '../../config'; import { DATA_SOURCES } from '../../config';
import { useFetch } from '@vegaprotocol/react-helpers'; import { useFetch } from '@vegaprotocol/react-helpers';
import type { TendermintValidatorsResponse } from './tendermint-validator-response'; import type { TendermintValidatorsResponse } from './tendermint-validator-response';
import type { NodesQuery } from './__generated__/NodesQuery'; import { useExplorerNodesQuery } from './__generated__/nodes';
const NODES_QUERY = gql`
query NodesQuery {
nodes {
id
name
infoUrl
avatarUrl
pubkey
tmPubkey
ethereumAddress
location
stakedByOperator
stakedByDelegates
stakedTotal
pendingStake
epochData {
total
offline
online
}
status
name
}
}
`;
const Validators = () => { const Validators = () => {
const { const {
@ -41,7 +14,7 @@ const Validators = () => {
} = useFetch<TendermintValidatorsResponse>( } = useFetch<TendermintValidatorsResponse>(
`${DATA_SOURCES.tendermintUrl}/validators` `${DATA_SOURCES.tendermintUrl}/validators`
); );
const { data } = useQuery<NodesQuery>(NODES_QUERY); const { data } = useExplorerNodesQuery();
return ( return (
<section> <section>

View File

@ -0,0 +1,27 @@
query ExplorerNodes {
nodesConnection {
edges {
node {
id
name
infoUrl
avatarUrl
pubkey
tmPubkey
ethereumAddress
location
stakedByOperator
stakedByDelegates
stakedTotal
pendingStake
epochData {
total
offline
online
}
status
name
}
}
}
}

View File

@ -16,7 +16,7 @@ import {
formatWithAsset, formatWithAsset,
displayChange, displayChange,
} from '@vegaprotocol/liquidity'; } from '@vegaprotocol/liquidity';
import type { MarketTradingMode } from '@vegaprotocol/types'; import type { Schema } from '@vegaprotocol/types';
import { HealthBar } from '../../health-bar'; import { HealthBar } from '../../health-bar';
import { Grid } from '../../grid'; import { Grid } from '../../grid';
@ -110,7 +110,7 @@ export const MarketList = () => {
value, value,
data, data,
}: { }: {
value: MarketTradingMode; value: Schema.MarketTradingMode;
data: Market; data: Market;
}) => { }) => {
return ( return (
@ -138,7 +138,7 @@ export const MarketList = () => {
value, value,
data, data,
}: { }: {
value: MarketTradingMode; value: Schema.MarketTradingMode;
data: Market; data: Market;
}) => ( }) => (
<HealthBar <HealthBar

View File

@ -3,7 +3,7 @@ import { t } from '@vegaprotocol/react-helpers';
import { Icon } from '@vegaprotocol/ui-toolkit'; import { Icon } from '@vegaprotocol/ui-toolkit';
import { formatWithAsset } from '@vegaprotocol/liquidity'; import { formatWithAsset } from '@vegaprotocol/liquidity';
import type { MarketTradingMode, AuctionTrigger } from '@vegaprotocol/types'; import type { Schema } from '@vegaprotocol/types';
import { HealthBar } from '../../health-bar'; import { HealthBar } from '../../health-bar';
import { HealthDialog } from '../../health-dialog'; import { HealthDialog } from '../../health-dialog';
import { Last24hVolume } from '../last-24h-volume'; import { Last24hVolume } from '../last-24h-volume';
@ -33,8 +33,8 @@ export const Market = ({
comittedLiquidity: number; comittedLiquidity: number;
targetStake: string; targetStake: string;
settlementAsset?: settlementAsset; settlementAsset?: settlementAsset;
tradingMode?: MarketTradingMode; tradingMode?: Schema.MarketTradingMode;
trigger?: AuctionTrigger; trigger?: Schema.AuctionTrigger;
}) => { }) => {
const [isHealthDialogOpen, setIsHealthDialogOpen] = useState(false); const [isHealthDialogOpen, setIsHealthDialogOpen] = useState(false);

View File

@ -1,5 +1,5 @@
import classNames from 'classnames'; import classNames from 'classnames';
import type { MarketTradingMode } from '@vegaprotocol/types'; import type { Schema } from '@vegaprotocol/types';
import { t, addDecimalsFormatNumber } from '@vegaprotocol/react-helpers'; import { t, addDecimalsFormatNumber } from '@vegaprotocol/react-helpers';
import { BigNumber } from 'bignumber.js'; import { BigNumber } from 'bignumber.js';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
@ -122,7 +122,7 @@ export const HealthBar = ({
size = 'small', size = 'small',
isExpanded = false, isExpanded = false,
}: { }: {
status: MarketTradingMode; status: Schema.MarketTradingMode;
target: string; target: string;
decimals: number; decimals: number;
levels: Levels[]; levels: Levels[];

View File

@ -1,6 +1,6 @@
import { t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import { Dialog } from '@vegaprotocol/ui-toolkit'; import { Dialog } from '@vegaprotocol/ui-toolkit';
import { MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import classNames from 'classnames'; import classNames from 'classnames';
import { HealthBar } from '../health-bar'; import { HealthBar } from '../health-bar';
@ -16,7 +16,7 @@ const ROWS = [
title: 'Continuous', title: 'Continuous',
copy: 'Markets that have committed liquidity equal or greater than the target stake are trading continuously.', copy: 'Markets that have committed liquidity equal or greater than the target stake are trading continuously.',
data: { data: {
status: MarketTradingMode.TRADING_MODE_CONTINUOUS, status: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
target: '171320', target: '171320',
decimals: 5, decimals: 5,
levels: [ levels: [
@ -31,7 +31,7 @@ const ROWS = [
title: 'Monitoring auction (liquidity)', title: 'Monitoring auction (liquidity)',
copy: 'Markets below the target stake will see trading suspended and go into liquidity auction.', copy: 'Markets below the target stake will see trading suspended and go into liquidity auction.',
data: { data: {
status: MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, status: Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
target: '171320', target: '171320',
decimals: 5, decimals: 5,
levels: [ levels: [
@ -45,7 +45,7 @@ const ROWS = [
title: 'Opening auction', title: 'Opening auction',
copy: 'A newly created market looking for a target liquidity amount to start trading.', copy: 'A newly created market looking for a target liquidity amount to start trading.',
data: { data: {
status: MarketTradingMode.TRADING_MODE_OPENING_AUCTION, status: Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION,
target: '171320', target: '171320',
decimals: 3, decimals: 3,
levels: [ levels: [

View File

@ -1,4 +1,4 @@
import type { MarketTradingMode } from '@vegaprotocol/types'; import type { Schema } from '@vegaprotocol/types';
import { getColorForStatus } from '../../lib/utils'; import { getColorForStatus } from '../../lib/utils';
@ -6,7 +6,7 @@ export const Indicator = ({
status, status,
opacity, opacity,
}: { }: {
status?: MarketTradingMode; status?: Schema.MarketTradingMode;
opacity?: number; opacity?: number;
}) => { }) => {
const backgroundColor = status ? getColorForStatus(status) : undefined; const backgroundColor = status ? getColorForStatus(status) : undefined;

View File

@ -3,9 +3,8 @@ import classNames from 'classnames';
import { import {
MarketTradingModeMapping, MarketTradingModeMapping,
MarketTradingMode,
AuctionTrigger,
AuctionTriggerMapping, AuctionTriggerMapping,
Schema,
} from '@vegaprotocol/types'; } from '@vegaprotocol/types';
import { Indicator } from '../indicator'; import { Indicator } from '../indicator';
@ -15,14 +14,19 @@ export const Status = ({
trigger, trigger,
size = 'small', size = 'small',
}: { }: {
tradingMode?: MarketTradingMode; tradingMode?: Schema.MarketTradingMode;
trigger?: AuctionTrigger; trigger?: Schema.AuctionTrigger;
size?: 'small' | 'large'; size?: 'small' | 'large';
}) => { }) => {
const getStatus = () => { const getStatus = () => {
if (!tradingMode) return ''; if (!tradingMode) return '';
if (tradingMode === MarketTradingMode.TRADING_MODE_MONITORING_AUCTION) { if (
if (trigger && trigger !== AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED) { tradingMode === Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION
) {
if (
trigger &&
trigger !== Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED
) {
return `${MarketTradingModeMapping[tradingMode]} - ${AuctionTriggerMapping[trigger]}`; return `${MarketTradingModeMapping[tradingMode]} - ${AuctionTriggerMapping[trigger]}`;
} }
} }

View File

@ -1,12 +1,12 @@
import { MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
const marketTradingModeStyle = { const marketTradingModeStyle = {
[MarketTradingMode.TRADING_MODE_CONTINUOUS]: '#00D46E', [Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS]: '#00D46E',
[MarketTradingMode.TRADING_MODE_MONITORING_AUCTION]: '#CF0064', [Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION]: '#CF0064',
[MarketTradingMode.TRADING_MODE_OPENING_AUCTION]: '#0046CD', [Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION]: '#0046CD',
[MarketTradingMode.TRADING_MODE_BATCH_AUCTION]: '#CF0064', [Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION]: '#CF0064',
[MarketTradingMode.TRADING_MODE_NO_TRADING]: '#CF0064', [Schema.MarketTradingMode.TRADING_MODE_NO_TRADING]: '#CF0064',
}; };
export const getColorForStatus = (status: MarketTradingMode) => export const getColorForStatus = (status: Schema.MarketTradingMode) =>
marketTradingModeStyle[status]; marketTradingModeStyle[status];

View File

@ -14,7 +14,7 @@ import { useVegaWallet } from '@vegaprotocol/wallet';
import { useContracts } from '../../contexts/contracts/contracts-context'; import { useContracts } from '../../contexts/contracts/contracts-context';
import type { ERC20Asset } from '@vegaprotocol/assets'; import type { ERC20Asset } from '@vegaprotocol/assets';
import { isAssetTypeERC20 } from '@vegaprotocol/assets'; import { isAssetTypeERC20 } from '@vegaprotocol/assets';
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { toBigNum } from '@vegaprotocol/react-helpers'; import { toBigNum } from '@vegaprotocol/react-helpers';
import { useAppState } from '../../contexts/app-state/app-state-context'; import { useAppState } from '../../contexts/app-state/app-state-context';
import { addDecimal } from '@vegaprotocol/react-helpers'; import { addDecimal } from '@vegaprotocol/react-helpers';
@ -90,7 +90,9 @@ export const usePollForDelegations = () => {
).map((e) => e.node); ).map((e) => e.node);
setAccounts( setAccounts(
accounts accounts
.filter((a) => a.type === AccountType.ACCOUNT_TYPE_GENERAL) .filter(
(a) => a.type === Schema.AccountType.ACCOUNT_TYPE_GENERAL
)
.map((a) => { .map((a) => {
const isVega = const isVega =
isAssetTypeERC20(a.asset as ERC20Asset) && isAssetTypeERC20(a.asset as ERC20Asset) &&

View File

@ -1,4 +1,4 @@
import { MarketState, MarketTradingModeMapping } from '@vegaprotocol/types'; import { Schema, MarketTradingModeMapping } from '@vegaprotocol/types';
import { connectVegaWallet } from '../support/vega-wallet'; import { connectVegaWallet } from '../support/vega-wallet';
const marketInfoBtn = 'Info'; const marketInfoBtn = 'Info';
@ -215,11 +215,11 @@ describe('market states', { tags: '@smoke' }, function () {
//7002-SORD-066 //7002-SORD-066
const states = [ const states = [
MarketState.STATE_REJECTED, Schema.MarketState.STATE_REJECTED,
MarketState.STATE_CANCELLED, Schema.MarketState.STATE_CANCELLED,
MarketState.STATE_CLOSED, Schema.MarketState.STATE_CLOSED,
MarketState.STATE_SETTLED, Schema.MarketState.STATE_SETTLED,
MarketState.STATE_TRADING_TERMINATED, Schema.MarketState.STATE_TRADING_TERMINATED,
]; ];
states.forEach((marketState) => { states.forEach((marketState) => {

View File

@ -1,8 +1,4 @@
import { import { Schema } from '@vegaprotocol/types';
AuctionTrigger,
MarketState,
MarketTradingMode,
} from '@vegaprotocol/types';
const marketSummaryBlock = 'header-summary'; const marketSummaryBlock = 'header-summary';
const marketExpiry = 'market-expiry'; const marketExpiry = 'market-expiry';
@ -19,9 +15,9 @@ const itemValue = 'item-value';
describe('Market trading page', () => { describe('Market trading page', () => {
before(() => { before(() => {
cy.mockTradingPage( cy.mockTradingPage(
MarketState.STATE_ACTIVE, Schema.MarketState.STATE_ACTIVE,
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
); );
cy.mockGQLSubscription(); cy.mockGQLSubscription();
cy.visit('/#/markets/market-0'); cy.visit('/#/markets/market-0');

View File

@ -1,15 +1,11 @@
import { import { Schema } from '@vegaprotocol/types';
AuctionTrigger,
MarketState,
MarketTradingMode,
} from '@vegaprotocol/types';
describe('markets table', { tags: '@smoke' }, () => { describe('markets table', { tags: '@smoke' }, () => {
beforeEach(() => { beforeEach(() => {
cy.mockTradingPage( cy.mockTradingPage(
MarketState.STATE_ACTIVE, Schema.MarketState.STATE_ACTIVE,
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
); );
cy.mockGQLSubscription(); cy.mockGQLSubscription();
cy.visit('/'); cy.visit('/');

View File

@ -1,8 +1,4 @@
import { import { Schema } from '@vegaprotocol/types';
MarketState,
MarketTradingMode,
AuctionTrigger,
} from '@vegaprotocol/types';
import { generateEstimateOrder } from '../support/mocks/generate-fees'; import { generateEstimateOrder } from '../support/mocks/generate-fees';
import { connectVegaWallet } from '../support/vega-wallet'; import { connectVegaWallet } from '../support/vega-wallet';
import { aliasQuery } from '@vegaprotocol/cypress'; import { aliasQuery } from '@vegaprotocol/cypress';
@ -252,9 +248,9 @@ describe(
() => { () => {
before(() => { before(() => {
cy.mockTradingPage( cy.mockTradingPage(
MarketState.STATE_PENDING, Schema.MarketState.STATE_PENDING,
MarketTradingMode.TRADING_MODE_BATCH_AUCTION, Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION,
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
); );
cy.mockGQLSubscription(); cy.mockGQLSubscription();
cy.visit('/#/markets/market-0'); cy.visit('/#/markets/market-0');
@ -311,9 +307,9 @@ describe(
() => { () => {
before(() => { before(() => {
cy.mockTradingPage( cy.mockTradingPage(
MarketState.STATE_PENDING, Schema.MarketState.STATE_PENDING,
MarketTradingMode.TRADING_MODE_OPENING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION,
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
); );
cy.mockGQLSubscription(); cy.mockGQLSubscription();
cy.visit('/#/markets/market-0'); cy.visit('/#/markets/market-0');
@ -370,9 +366,9 @@ describe(
() => { () => {
before(() => { before(() => {
cy.mockTradingPage( cy.mockTradingPage(
MarketState.STATE_PENDING, Schema.MarketState.STATE_PENDING,
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
); );
cy.mockGQLSubscription(); cy.mockGQLSubscription();
cy.visit('/#/markets/market-0'); cy.visit('/#/markets/market-0');
@ -631,9 +627,9 @@ describe('market order validations', { tags: '@smoke' }, () => {
describe('suspended market validation', { tags: '@regression' }, () => { describe('suspended market validation', { tags: '@regression' }, () => {
before(() => { before(() => {
cy.mockTradingPage( cy.mockTradingPage(
MarketState.STATE_SUSPENDED, Schema.MarketState.STATE_SUSPENDED,
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
); );
cy.visit('/#/markets/market-0'); cy.visit('/#/markets/market-0');
cy.wait('@Market'); cy.wait('@Market');

View File

@ -1,6 +1,6 @@
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import type { AccountsQuery } from '@vegaprotocol/accounts'; import type { AccountsQuery } from '@vegaprotocol/accounts';
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
export const generateAccounts = ( export const generateAccounts = (
@ -13,7 +13,7 @@ export const generateAccounts = (
accounts: [ accounts: [
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '100000000', balance: '100000000',
market: null, market: null,
asset: { asset: {
@ -23,7 +23,7 @@ export const generateAccounts = (
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '100000000', balance: '100000000',
market: { market: {
id: 'market-1', id: 'market-1',
@ -36,7 +36,7 @@ export const generateAccounts = (
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_MARGIN, type: Schema.AccountType.ACCOUNT_TYPE_MARGIN,
balance: '1000', balance: '1000',
market: { market: {
__typename: 'Market', __typename: 'Market',
@ -49,7 +49,7 @@ export const generateAccounts = (
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_MARGIN, type: Schema.AccountType.ACCOUNT_TYPE_MARGIN,
balance: '1000', balance: '1000',
market: { market: {
__typename: 'Market', __typename: 'Market',
@ -62,7 +62,7 @@ export const generateAccounts = (
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '100000000', balance: '100000000',
market: null, market: null,
asset: { asset: {
@ -73,7 +73,7 @@ export const generateAccounts = (
// account to withdraw Sepolia tBTC // account to withdraw Sepolia tBTC
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '100000000', balance: '100000000',
market: null, market: null,
asset: { asset: {

View File

@ -1,5 +1,5 @@
import type { DealTicketQuery } from '@vegaprotocol/deal-ticket'; import type { DealTicketQuery } from '@vegaprotocol/deal-ticket';
import { MarketState, MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
@ -12,8 +12,8 @@ export const generateDealTicketQuery = (
id: 'market-0', id: 'market-0',
decimalPlaces: 5, decimalPlaces: 5,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
fees: { fees: {
factors: { factors: {
makerFee: '0.0002', makerFee: '0.0002',

View File

@ -1,10 +1,5 @@
import type { MarketInfoQuery } from '@vegaprotocol/market-info'; import type { MarketInfoQuery } from '@vegaprotocol/market-info';
import { import { Schema } from '@vegaprotocol/types';
AccountType,
AuctionTrigger,
MarketState,
MarketTradingMode,
} from '@vegaprotocol/types';
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
@ -17,8 +12,8 @@ export const generateMarketInfoQuery = (
id: 'market-0', id: 'market-0',
decimalPlaces: 5, decimalPlaces: 5,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
proposal: { proposal: {
__typename: 'Proposal', __typename: 'Proposal',
id: 'market-0', id: 'market-0',
@ -30,7 +25,7 @@ export const generateMarketInfoQuery = (
}, },
accounts: [ accounts: [
{ {
type: AccountType.ACCOUNT_TYPE_INSURANCE, type: Schema.AccountType.ACCOUNT_TYPE_INSURANCE,
asset: { asset: {
id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61', id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61',
__typename: 'Asset', __typename: 'Asset',
@ -39,7 +34,7 @@ export const generateMarketInfoQuery = (
__typename: 'AccountBalance', __typename: 'AccountBalance',
}, },
{ {
type: AccountType.ACCOUNT_TYPE_FEES_LIQUIDITY, type: Schema.AccountType.ACCOUNT_TYPE_FEES_LIQUIDITY,
asset: { asset: {
id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61', id: '6d9d35f657589e40ddfb448b7ad4a7463b66efb307527fedd2aa7df1bbd5ea61',
__typename: 'Asset', __typename: 'Asset',
@ -95,7 +90,7 @@ export const generateMarketInfoQuery = (
openInterest: '0', openInterest: '0',
bestBidPrice: '681765', bestBidPrice: '681765',
bestOfferPrice: '681769', bestOfferPrice: '681769',
trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED,
priceMonitoringBounds: [ priceMonitoringBounds: [
{ {
minValidPrice: '654701', minValidPrice: '654701',
@ -186,5 +181,6 @@ export const generateMarketInfoQuery = (
}, },
}; };
// @ts-ignore: added when markettype changed. No idea.
return merge(defaultResult, override); return merge(defaultResult, override);
}; };

View File

@ -1,9 +1,5 @@
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import { import { Schema } from '@vegaprotocol/types';
AuctionTrigger,
MarketState,
MarketTradingMode,
} from '@vegaprotocol/types';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
import type { import type {
MarketData, MarketData,
@ -17,8 +13,8 @@ export const generateMarket = (
const defaultResult: MarketQuery = { const defaultResult: MarketQuery = {
market: { market: {
id: 'market-0', id: 'market-0',
tradingMode: MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, tradingMode: Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
decimalPlaces: 5, decimalPlaces: 5,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
tradableInstrument: { tradableInstrument: {
@ -90,7 +86,7 @@ export const generateMarketData = (
auctionEnd: '2022-06-21T17:18:43.484055236Z', auctionEnd: '2022-06-21T17:18:43.484055236Z',
targetStake: '1000000', targetStake: '1000000',
suppliedStake: '1000', suppliedStake: '1000',
marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
staticMidPrice: '0', staticMidPrice: '0',
indicativePrice: '0', indicativePrice: '0',
bestStaticBidPrice: '0', bestStaticBidPrice: '0',
@ -99,7 +95,7 @@ export const generateMarketData = (
bestBidPrice: '0', bestBidPrice: '0',
bestOfferPrice: '0', bestOfferPrice: '0',
markPrice: '4612690058', markPrice: '4612690058',
trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED,
}; };
const marketsConnectionWrapper = ( const marketsConnectionWrapper = (

View File

@ -1,9 +1,5 @@
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import { import { Schema } from '@vegaprotocol/types';
AuctionTrigger,
MarketState,
MarketTradingMode,
} from '@vegaprotocol/types';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
import type { import type {
MarketsQuery, MarketsQuery,
@ -21,8 +17,8 @@ export const generateMarkets = (
id: 'market-0', id: 'market-0',
decimalPlaces: 5, decimalPlaces: 5,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
marketTimestamps: { marketTimestamps: {
__typename: 'MarketTimestamps', __typename: 'MarketTimestamps',
close: '', close: '',
@ -65,8 +61,8 @@ export const generateMarkets = (
id: 'market-1', id: 'market-1',
decimalPlaces: 2, decimalPlaces: 2,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
marketTimestamps: { marketTimestamps: {
__typename: 'MarketTimestamps', __typename: 'MarketTimestamps',
close: '', close: '',
@ -109,8 +105,8 @@ export const generateMarkets = (
id: 'market-2', id: 'market-2',
decimalPlaces: 5, decimalPlaces: 5,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
tradingMode: MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, tradingMode: Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
state: MarketState.STATE_SUSPENDED, state: Schema.MarketState.STATE_SUSPENDED,
marketTimestamps: { marketTimestamps: {
__typename: 'MarketTimestamps', __typename: 'MarketTimestamps',
close: '2022-08-26T11:36:32.252490405Z', close: '2022-08-26T11:36:32.252490405Z',
@ -153,8 +149,8 @@ export const generateMarkets = (
id: 'market-3', id: 'market-3',
decimalPlaces: 5, decimalPlaces: 5,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
marketTimestamps: { marketTimestamps: {
__typename: 'MarketTimestamps', __typename: 'MarketTimestamps',
close: '2022-08-26T11:36:32.252490405Z', close: '2022-08-26T11:36:32.252490405Z',
@ -217,7 +213,7 @@ export const generateMarketsData = (
id: 'market-0', id: 'market-0',
__typename: 'Market', __typename: 'Market',
}, },
marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
staticMidPrice: '0', staticMidPrice: '0',
indicativePrice: '0', indicativePrice: '0',
bestStaticBidPrice: '0', bestStaticBidPrice: '0',
@ -226,7 +222,7 @@ export const generateMarketsData = (
bestBidPrice: '0', bestBidPrice: '0',
bestOfferPrice: '0', bestOfferPrice: '0',
markPrice: '4612690058', markPrice: '4612690058',
trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED,
__typename: 'MarketData', __typename: 'MarketData',
}, },
{ {
@ -234,7 +230,7 @@ export const generateMarketsData = (
id: 'market-1', id: 'market-1',
__typename: 'Market', __typename: 'Market',
}, },
marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
staticMidPrice: '0', staticMidPrice: '0',
indicativePrice: '0', indicativePrice: '0',
bestStaticBidPrice: '0', bestStaticBidPrice: '0',
@ -243,7 +239,7 @@ export const generateMarketsData = (
bestBidPrice: '0', bestBidPrice: '0',
bestOfferPrice: '0', bestOfferPrice: '0',
markPrice: '8441', markPrice: '8441',
trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED,
__typename: 'MarketData', __typename: 'MarketData',
}, },
{ {
@ -251,7 +247,7 @@ export const generateMarketsData = (
id: 'market-2', id: 'market-2',
__typename: 'Market', __typename: 'Market',
}, },
marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
staticMidPrice: '0', staticMidPrice: '0',
indicativePrice: '0', indicativePrice: '0',
bestStaticBidPrice: '0', bestStaticBidPrice: '0',
@ -260,7 +256,7 @@ export const generateMarketsData = (
bestBidPrice: '0', bestBidPrice: '0',
bestOfferPrice: '0', bestOfferPrice: '0',
markPrice: '4612690058', markPrice: '4612690058',
trigger: AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY, trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY,
__typename: 'MarketData', __typename: 'MarketData',
}, },
{ {
@ -268,7 +264,7 @@ export const generateMarketsData = (
id: 'market-3', id: 'market-3',
__typename: 'Market', __typename: 'Market',
}, },
marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
staticMidPrice: '0', staticMidPrice: '0',
indicativePrice: '0', indicativePrice: '0',
bestStaticBidPrice: '0', bestStaticBidPrice: '0',
@ -277,7 +273,7 @@ export const generateMarketsData = (
bestBidPrice: '0', bestBidPrice: '0',
bestOfferPrice: '0', bestOfferPrice: '0',
markPrice: '4612690058', markPrice: '4612690058',
trigger: AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY, trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY,
__typename: 'MarketData', __typename: 'MarketData',
}, },
]; ];

View File

@ -1,6 +1,5 @@
import { aliasQuery } from '@vegaprotocol/cypress'; import { aliasQuery } from '@vegaprotocol/cypress';
import type { MarketTradingMode, AuctionTrigger } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { MarketState } from '@vegaprotocol/types';
import type { CyHttpMessages } from 'cypress/types/net-stubbing'; import type { CyHttpMessages } from 'cypress/types/net-stubbing';
import { generateAccounts } from './mocks/generate-accounts'; import { generateAccounts } from './mocks/generate-accounts';
import { generateAsset, generateAssets } from './mocks/generate-assets'; import { generateAsset, generateAssets } from './mocks/generate-assets';
@ -31,9 +30,9 @@ import {
const mockTradingPage = ( const mockTradingPage = (
req: CyHttpMessages.IncomingHttpRequest, req: CyHttpMessages.IncomingHttpRequest,
state: MarketState = MarketState.STATE_ACTIVE, state: Schema.MarketState = Schema.MarketState.STATE_ACTIVE,
tradingMode?: MarketTradingMode, tradingMode?: Schema.MarketTradingMode,
trigger?: AuctionTrigger trigger?: Schema.AuctionTrigger
) => { ) => {
aliasQuery(req, 'ChainId', generateChainId()); aliasQuery(req, 'ChainId', generateChainId());
aliasQuery(req, 'Statistics', generateStatistics()); aliasQuery(req, 'Statistics', generateStatistics());
@ -115,9 +114,9 @@ declare global {
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> { interface Chainable<Subject> {
mockTradingPage( mockTradingPage(
state?: MarketState, state?: Schema.MarketState,
tradingMode?: MarketTradingMode, tradingMode?: Schema.MarketTradingMode,
trigger?: AuctionTrigger trigger?: Schema.AuctionTrigger
): void; ): void;
} }
} }
@ -125,7 +124,7 @@ declare global {
export const addMockTradingPage = () => { export const addMockTradingPage = () => {
Cypress.Commands.add( Cypress.Commands.add(
'mockTradingPage', 'mockTradingPage',
(state = MarketState.STATE_ACTIVE, tradingMode, trigger) => { (state = Schema.MarketState.STATE_ACTIVE, tradingMode, trigger) => {
cy.mockGQL((req) => { cy.mockGQL((req) => {
mockTradingPage(req, state, tradingMode, trigger); mockTradingPage(req, state, tradingMode, trigger);
}); });

View File

@ -3,7 +3,7 @@
// @generated // @generated
// This file was automatically generated and should not be edited. // This file was automatically generated and should not be edited.
import { AccountType } from "@vegaprotocol/types"; import { Schema } from "@vegaprotocol/types";
// ==================================================== // ====================================================
// GraphQL query operation: WithdrawFormQuery // GraphQL query operation: WithdrawFormQuery
@ -38,7 +38,7 @@ export interface WithdrawFormQuery_party_accounts {
/** /**
* Account type (General, Margin, etc) * Account type (General, Margin, etc)
*/ */
type: AccountType; type: Schema.AccountType;
/** /**
* Balance as string - current account balance (approx. as balances can be updated several times per second) * Balance as string - current account balance (approx. as balances can be updated several times per second)
*/ */

View File

@ -4,10 +4,9 @@ import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket';
import { compileGridData, TradingModeTooltip } from '@vegaprotocol/deal-ticket'; import { compileGridData, TradingModeTooltip } from '@vegaprotocol/deal-ticket';
import type { Schema as Types } from '@vegaprotocol/types'; import type { Schema as Types } from '@vegaprotocol/types';
import { import {
AuctionTrigger,
AuctionTriggerMapping, AuctionTriggerMapping,
MarketTradingModeMapping, MarketTradingModeMapping,
MarketTradingMode, Schema,
} from '@vegaprotocol/types'; } from '@vegaprotocol/types';
import type { import type {
MarketData, MarketData,
@ -79,9 +78,10 @@ export const MarketTradingModeComponent = ({ marketId, onSelect }: Props) => {
testId="market-trading-mode" testId="market-trading-mode"
> >
<div> <div>
{tradingMode === MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && {tradingMode ===
Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION &&
trigger && trigger &&
trigger !== AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED trigger !== Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED
? `${MarketTradingModeMapping[tradingMode]} - ${AuctionTriggerMapping[trigger]}` ? `${MarketTradingModeMapping[tradingMode]} - ${AuctionTriggerMapping[trigger]}`
: MarketTradingModeMapping[tradingMode as Types.MarketTradingMode]} : MarketTradingModeMapping[tradingMode as Types.MarketTradingMode]}
</div> </div>

View File

@ -13,10 +13,9 @@ import {
t, t,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import { import {
AuctionTrigger,
AuctionTriggerMapping, AuctionTriggerMapping,
MarketTradingMode,
MarketTradingModeMapping, MarketTradingModeMapping,
Schema,
} from '@vegaprotocol/types'; } from '@vegaprotocol/types';
import { import {
Link as UILink, Link as UILink,
@ -51,9 +50,10 @@ const TradingMode = ({ market }: { market: Market }) => {
> >
<span> <span>
{market.tradingMode === {market.tradingMode ===
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION &&
market.data?.trigger && market.data?.trigger &&
market.data.trigger !== AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED market.data.trigger !==
Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED
? `${MarketTradingModeMapping[market.tradingMode]} ? `${MarketTradingModeMapping[market.tradingMode]}
- ${AuctionTriggerMapping[market.data.trigger]}` - ${AuctionTriggerMapping[market.data.trigger]}`
: MarketTradingModeMapping[market.tradingMode]} : MarketTradingModeMapping[market.tradingMode]}

View File

@ -1,5 +1,5 @@
import { fireEvent, render, screen } from '@testing-library/react'; import { fireEvent, render, screen } from '@testing-library/react';
import { AuctionTrigger, MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { import {
SelectAllMarketsTableBody, SelectAllMarketsTableBody,
@ -22,7 +22,7 @@ const MARKET_A: PartialMarket = {
__typename: 'Market', __typename: 'Market',
id: '1', id: '1',
decimalPlaces: 2, decimalPlaces: 2,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
tradableInstrument: { tradableInstrument: {
__typename: 'TradableInstrument', __typename: 'TradableInstrument',
instrument: { instrument: {
@ -61,7 +61,7 @@ const MARKET_A: PartialMarket = {
id: '1', id: '1',
}, },
markPrice: '90', markPrice: '90',
trigger: AuctionTrigger.AUCTION_TRIGGER_OPENING, trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_OPENING,
indicativeVolume: '1000', indicativeVolume: '1000',
}, },
candles: [ candles: [
@ -90,7 +90,7 @@ const MARKET_B: PartialMarket = {
__typename: 'Market', __typename: 'Market',
id: '2', id: '2',
decimalPlaces: 2, decimalPlaces: 2,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
tradableInstrument: { tradableInstrument: {
__typename: 'TradableInstrument', __typename: 'TradableInstrument',
instrument: { instrument: {
@ -129,7 +129,7 @@ const MARKET_B: PartialMarket = {
id: '2', id: '2',
}, },
markPrice: '123.123', markPrice: '123.123',
trigger: AuctionTrigger.AUCTION_TRIGGER_OPENING, trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_OPENING,
indicativeVolume: '2000', indicativeVolume: '2000',
}, },
candles: [ candles: [

View File

@ -1,7 +1,9 @@
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { AccountFields, Account } from './accounts-data-provider'; import type { AccountFields, Account } from './accounts-data-provider';
import { getAccountData, getId } from './accounts-data-provider'; import { getAccountData, getId } from './accounts-data-provider';
const AccountType = Schema.AccountType;
describe('getAccountData', () => { describe('getAccountData', () => {
it('should return the correct aggregated data', () => { it('should return the correct aggregated data', () => {
const data = getAccountData(accounts); const data = getAccountData(accounts);

View File

@ -4,7 +4,7 @@ import {
makeDataProvider, makeDataProvider,
makeDerivedDataProvider, makeDerivedDataProvider,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import produce from 'immer'; import produce from 'immer';
import { import {
@ -21,6 +21,8 @@ import type {
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
import type { Asset } from '@vegaprotocol/assets'; import type { Asset } from '@vegaprotocol/assets';
const AccountType = Schema.AccountType;
function isAccount( function isAccount(
account: account:
| AccountFieldsFragment | AccountFieldsFragment

View File

@ -1,6 +1,6 @@
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useVegaWallet } from '@vegaprotocol/wallet'; import { useVegaWallet } from '@vegaprotocol/wallet';
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { toBigNum } from '@vegaprotocol/react-helpers'; import { toBigNum } from '@vegaprotocol/react-helpers';
import type { DealTicketMarketFragment } from '../deal-ticket/__generated__/DealTicket'; import type { DealTicketMarketFragment } from '../deal-ticket/__generated__/DealTicket';
import type { OrderMargin } from '../../hooks/use-order-margin'; import type { OrderMargin } from '../../hooks/use-order-margin';
@ -23,7 +23,7 @@ export const useOrderMarginValidation = ({ market, estMargin }: Props) => {
const settlementAccount = useSettlementAccount( const settlementAccount = useSettlementAccount(
market.tradableInstrument.instrument.product.settlementAsset.id, market.tradableInstrument.instrument.product.settlementAsset.id,
partyBalance?.party?.accounts || [], partyBalance?.party?.accounts || [],
AccountType.ACCOUNT_TYPE_GENERAL Schema.AccountType.ACCOUNT_TYPE_GENERAL
); );
const assetDecimals = const assetDecimals =
market.tradableInstrument.instrument.product.settlementAsset.decimals; market.tradableInstrument.instrument.product.settlementAsset.decimals;

View File

@ -3,12 +3,7 @@ import { renderHook } from '@testing-library/react';
import { useVegaWallet } from '@vegaprotocol/wallet'; import { useVegaWallet } from '@vegaprotocol/wallet';
import { MockedProvider } from '@apollo/client/testing'; import { MockedProvider } from '@apollo/client/testing';
import type { VegaWalletContextShape } from '@vegaprotocol/wallet'; import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
import { import { MarketStateMapping, Schema } from '@vegaprotocol/types';
MarketState,
MarketStateMapping,
MarketTradingMode,
Schema,
} from '@vegaprotocol/types';
import type { ValidationProps } from './use-order-validation'; import type { ValidationProps } from './use-order-validation';
import { marketTranslations, useOrderValidation } from './use-order-validation'; import { marketTranslations, useOrderValidation } from './use-order-validation';
import type { DealTicketMarketFragment } from '../deal-ticket/__generated__/DealTicket'; import type { DealTicketMarketFragment } from '../deal-ticket/__generated__/DealTicket';
@ -22,8 +17,8 @@ const market: DealTicketMarketFragment = {
id: 'market-id', id: 'market-id',
decimalPlaces: 2, decimalPlaces: 2,
positionDecimalPlaces: 1, positionDecimalPlaces: 1,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
__typename: 'TradableInstrument', __typename: 'TradableInstrument',
instrument: { instrument: {
@ -148,11 +143,11 @@ describe('useOrderValidation', () => {
it.each` it.each`
state state
${MarketState.STATE_SETTLED} ${Schema.MarketState.STATE_SETTLED}
${MarketState.STATE_REJECTED} ${Schema.MarketState.STATE_REJECTED}
${MarketState.STATE_TRADING_TERMINATED} ${Schema.MarketState.STATE_TRADING_TERMINATED}
${MarketState.STATE_CLOSED} ${Schema.MarketState.STATE_CLOSED}
${MarketState.STATE_CANCELLED} ${Schema.MarketState.STATE_CANCELLED}
`( `(
'Returns an error message for market state when not accepting orders', 'Returns an error message for market state when not accepting orders',
({ state }) => { ({ state }) => {
@ -169,8 +164,8 @@ describe('useOrderValidation', () => {
it.each` it.each`
state state
${MarketState.STATE_PENDING} ${Schema.MarketState.STATE_PENDING}
${MarketState.STATE_PROPOSED} ${Schema.MarketState.STATE_PROPOSED}
`( `(
'Returns an error message for market state suspended or pending', 'Returns an error message for market state suspended or pending',
({ state }) => { ({ state }) => {
@ -181,7 +176,7 @@ describe('useOrderValidation', () => {
market: { market: {
...defaultOrder.market, ...defaultOrder.market,
state, state,
tradingMode: MarketTradingMode.TRADING_MODE_BATCH_AUCTION, tradingMode: Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION,
}, },
orderType: Schema.OrderType.TYPE_LIMIT, orderType: Schema.OrderType.TYPE_LIMIT,
orderTimeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, orderTimeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT,
@ -189,7 +184,7 @@ describe('useOrderValidation', () => {
expect(result.current).toStrictEqual({ expect(result.current).toStrictEqual({
isDisabled: false, isDisabled: false,
message: `This market is ${MarketStateMapping[ message: `This market is ${MarketStateMapping[
state as MarketState state as Schema.MarketState
].toLowerCase()} and only accepting liquidity commitment orders`, ].toLowerCase()} and only accepting liquidity commitment orders`,
section: 'sec-summary', section: 'sec-summary',
}); });
@ -197,10 +192,10 @@ describe('useOrderValidation', () => {
); );
it.each` it.each`
tradingMode | errorMessage tradingMode | errorMessage
${MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${ERROR.MARKET_CONTINUOUS_LIMIT} ${Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${ERROR.MARKET_CONTINUOUS_LIMIT}
${MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${ERROR.MARKET_CONTINUOUS_LIMIT} ${Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${ERROR.MARKET_CONTINUOUS_LIMIT}
${MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${ERROR.MARKET_CONTINUOUS_LIMIT} ${Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${ERROR.MARKET_CONTINUOUS_LIMIT}
`( `(
`Returns an error message when trying to submit a non-limit order for a "$tradingMode" market`, `Returns an error message when trying to submit a non-limit order for a "$tradingMode" market`,
({ tradingMode, errorMessage }) => { ({ tradingMode, errorMessage }) => {
@ -214,16 +209,16 @@ describe('useOrderValidation', () => {
); );
it.each` it.each`
tradingMode | orderTimeInForce | errorMessage tradingMode | orderTimeInForce | errorMessage
${MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF} ${Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF}
${MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF} ${Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF}
${MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF} ${Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF}
${MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF} ${Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF}
${MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF} ${Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF}
${MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF} ${Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF}
${MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF} ${Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF}
${MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF} ${Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF}
${MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF} ${Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF}
`( `(
`Returns an error message when submitting a limit order with a "$orderTimeInForce" value to a "$tradingMode" market`, `Returns an error message when submitting a limit order with a "$orderTimeInForce" value to a "$tradingMode" market`,
({ tradingMode, orderTimeInForce, errorMessage }) => { ({ tradingMode, orderTimeInForce, errorMessage }) => {
@ -310,8 +305,8 @@ describe('useOrderValidation', () => {
it.each` it.each`
state state
${MarketState.STATE_PENDING} ${Schema.MarketState.STATE_PENDING}
${MarketState.STATE_PROPOSED} ${Schema.MarketState.STATE_PROPOSED}
`( `(
'Returns error when market state is pending and size is wrong', 'Returns error when market state is pending and size is wrong',
({ state }) => { ({ state }) => {

View File

@ -3,13 +3,7 @@ import type { FieldErrors } from 'react-hook-form';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { t, toDecimal } from '@vegaprotocol/react-helpers'; import { t, toDecimal } from '@vegaprotocol/react-helpers';
import { useVegaWallet } from '@vegaprotocol/wallet'; import { useVegaWallet } from '@vegaprotocol/wallet';
import { import { MarketStateMapping, Schema } from '@vegaprotocol/types';
AuctionTrigger,
MarketState,
MarketStateMapping,
MarketTradingMode,
Schema,
} from '@vegaprotocol/types';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import { Tooltip } from '@vegaprotocol/ui-toolkit'; import { Tooltip } from '@vegaprotocol/ui-toolkit';
import { MarketDataGrid } from '../trading-mode-tooltip'; import { MarketDataGrid } from '../trading-mode-tooltip';
@ -23,9 +17,9 @@ import { DEAL_TICKET_SECTION, ERROR_SIZE_DECIMAL } from '../constants';
export const isMarketInAuction = (market: DealTicketMarketFragment) => { export const isMarketInAuction = (market: DealTicketMarketFragment) => {
return [ return [
MarketTradingMode.TRADING_MODE_BATCH_AUCTION, Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION,
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
MarketTradingMode.TRADING_MODE_OPENING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION,
].includes(market.tradingMode); ].includes(market.tradingMode);
}; };
@ -38,9 +32,9 @@ export type ValidationProps = {
estMargin: OrderMargin | null; estMargin: OrderMargin | null;
}; };
export const marketTranslations = (marketState: MarketState) => { export const marketTranslations = (marketState: Schema.MarketState) => {
switch (marketState) { switch (marketState) {
case MarketState.STATE_TRADING_TERMINATED: case Schema.MarketState.STATE_TRADING_TERMINATED:
return t('terminated'); return t('terminated');
default: default:
return t(MarketStateMapping[marketState]).toLowerCase(); return t(MarketStateMapping[marketState]).toLowerCase();
@ -170,11 +164,11 @@ export const useOrderValidation = ({
if ( if (
[ [
MarketState.STATE_SETTLED, Schema.MarketState.STATE_SETTLED,
MarketState.STATE_REJECTED, Schema.MarketState.STATE_REJECTED,
MarketState.STATE_TRADING_TERMINATED, Schema.MarketState.STATE_TRADING_TERMINATED,
MarketState.STATE_CANCELLED, Schema.MarketState.STATE_CANCELLED,
MarketState.STATE_CLOSED, Schema.MarketState.STATE_CLOSED,
].includes(market.state) ].includes(market.state)
) { ) {
return { return {
@ -189,9 +183,10 @@ export const useOrderValidation = ({
} }
if ( if (
[MarketState.STATE_PROPOSED, MarketState.STATE_PENDING].includes( [
market.state Schema.MarketState.STATE_PROPOSED,
) Schema.MarketState.STATE_PENDING,
].includes(market.state)
) { ) {
if (fieldErrorChecking) { if (fieldErrorChecking) {
return fieldErrorChecking; return fieldErrorChecking;
@ -211,8 +206,9 @@ export const useOrderValidation = ({
if (orderType === Schema.OrderType.TYPE_MARKET) { if (orderType === Schema.OrderType.TYPE_MARKET) {
if ( if (
market.tradingMode === market.tradingMode ===
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION &&
market.data?.trigger === AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY market.data?.trigger ===
Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
) { ) {
return { return {
isDisabled: true, isDisabled: true,
@ -235,8 +231,8 @@ export const useOrderValidation = ({
} }
if ( if (
market.tradingMode === market.tradingMode ===
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION &&
market.data?.trigger === AuctionTrigger.AUCTION_TRIGGER_PRICE market.data?.trigger === Schema.AuctionTrigger.AUCTION_TRIGGER_PRICE
) { ) {
return { return {
isDisabled: true, isDisabled: true,
@ -275,8 +271,9 @@ export const useOrderValidation = ({
) { ) {
if ( if (
market.tradingMode === market.tradingMode ===
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION &&
market.data?.trigger === AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY market.data?.trigger ===
Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
) { ) {
return { return {
isDisabled: true, isDisabled: true,
@ -301,8 +298,8 @@ export const useOrderValidation = ({
} }
if ( if (
market.tradingMode === market.tradingMode ===
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION &&
market.data?.trigger === AuctionTrigger.AUCTION_TRIGGER_PRICE market.data?.trigger === Schema.AuctionTrigger.AUCTION_TRIGGER_PRICE
) { ) {
return { return {
isDisabled: true, isDisabled: true,
@ -349,9 +346,9 @@ export const useOrderValidation = ({
if ( if (
[ [
MarketTradingMode.TRADING_MODE_BATCH_AUCTION, Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION,
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
MarketTradingMode.TRADING_MODE_OPENING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION,
].includes(market.tradingMode) ].includes(market.tradingMode)
) { ) {
return { return {

View File

@ -23,7 +23,7 @@ import {
useDataProvider, useDataProvider,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import { IconNames } from '@blueprintjs/icons'; import { IconNames } from '@blueprintjs/icons';
import { MarketState } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
import { marketsProvider } from '@vegaprotocol/market-list'; import { marketsProvider } from '@vegaprotocol/market-list';
@ -246,7 +246,7 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => {
setResults( setResults(
data?.filter( data?.filter(
(item) => (item) =>
item.state === MarketState.STATE_ACTIVE && item.state === Schema.MarketState.STATE_ACTIVE &&
item.tradableInstrument.instrument.name.match( item.tradableInstrument.instrument.name.match(
new RegExp(escapeRegExp(lookup), 'i') new RegExp(escapeRegExp(lookup), 'i')
) )

View File

@ -3,7 +3,7 @@ import {
getDateTimeFormat, getDateTimeFormat,
addDecimalsNormalizeNumber, addDecimalsNormalizeNumber,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import { MarketTradingMode, AuctionTrigger } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { Link as UILink } from '@vegaprotocol/ui-toolkit'; import { Link as UILink } from '@vegaprotocol/ui-toolkit';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import type { MarketDataGridProps } from './market-data-grid'; import type { MarketDataGridProps } from './market-data-grid';
@ -16,8 +16,9 @@ export const compileGridData = (
): { label: ReactNode; value?: ReactNode }[] => { ): { label: ReactNode; value?: ReactNode }[] => {
const grid: MarketDataGridProps['grid'] = []; const grid: MarketDataGridProps['grid'] = [];
const isLiquidityMonitoringAuction = const isLiquidityMonitoringAuction =
market.tradingMode === MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && market.tradingMode ===
market.data?.trigger === AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY; Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION &&
market.data?.trigger === Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY;
const formatStake = (value: string) => { const formatStake = (value: string) => {
const formattedValue = addDecimalsNormalizeNumber( const formattedValue = addDecimalsNormalizeNumber(

View File

@ -1,5 +1,5 @@
import { t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import { AuctionTrigger, MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { ExternalLink } from '@vegaprotocol/ui-toolkit'; import { ExternalLink } from '@vegaprotocol/ui-toolkit';
import { createDocsLinks } from '@vegaprotocol/react-helpers'; import { createDocsLinks } from '@vegaprotocol/react-helpers';
import { MarketDataGrid } from './market-data-grid'; import { MarketDataGrid } from './market-data-grid';
@ -8,8 +8,8 @@ import type { ReactNode } from 'react';
import { useEnvironment } from '@vegaprotocol/environment'; import { useEnvironment } from '@vegaprotocol/environment';
type TradingModeTooltipProps = { type TradingModeTooltipProps = {
tradingMode: MarketTradingMode | null; tradingMode: Schema.MarketTradingMode | null;
trigger: AuctionTrigger | null; trigger: Schema.AuctionTrigger | null;
compiledGrid?: { label: ReactNode; value?: ReactNode }[]; compiledGrid?: { label: ReactNode; value?: ReactNode }[];
}; };
@ -20,7 +20,7 @@ export const TradingModeTooltip = ({
}: TradingModeTooltipProps) => { }: TradingModeTooltipProps) => {
const { VEGA_DOCS_URL } = useEnvironment(); const { VEGA_DOCS_URL } = useEnvironment();
switch (tradingMode) { switch (tradingMode) {
case MarketTradingMode.TRADING_MODE_CONTINUOUS: { case Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS: {
return ( return (
<section data-testid="trading-mode-tooltip"> <section data-testid="trading-mode-tooltip">
{t( {t(
@ -29,7 +29,7 @@ export const TradingModeTooltip = ({
</section> </section>
); );
} }
case MarketTradingMode.TRADING_MODE_OPENING_AUCTION: { case Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION: {
return ( return (
<section data-testid="trading-mode-tooltip"> <section data-testid="trading-mode-tooltip">
<p className="mb-4"> <p className="mb-4">
@ -50,9 +50,9 @@ export const TradingModeTooltip = ({
</section> </section>
); );
} }
case MarketTradingMode.TRADING_MODE_MONITORING_AUCTION: { case Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION: {
switch (trigger) { switch (trigger) {
case AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY: { case Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY: {
return ( return (
<section data-testid="trading-mode-tooltip"> <section data-testid="trading-mode-tooltip">
<p className="mb-4"> <p className="mb-4">
@ -76,7 +76,7 @@ export const TradingModeTooltip = ({
</section> </section>
); );
} }
case AuctionTrigger.AUCTION_TRIGGER_PRICE: { case Schema.AuctionTrigger.AUCTION_TRIGGER_PRICE: {
return ( return (
<section data-testid="trading-mode-tooltip"> <section data-testid="trading-mode-tooltip">
<p className="mb-4"> <p className="mb-4">
@ -103,14 +103,14 @@ export const TradingModeTooltip = ({
} }
} }
} }
case MarketTradingMode.TRADING_MODE_NO_TRADING: { case Schema.MarketTradingMode.TRADING_MODE_NO_TRADING: {
return ( return (
<section data-testid="trading-mode-tooltip"> <section data-testid="trading-mode-tooltip">
{t('No trading enabled for this market.')} {t('No trading enabled for this market.')}
</section> </section>
); );
} }
case MarketTradingMode.TRADING_MODE_BATCH_AUCTION: case Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION:
default: { default: {
return null; return null;
} }

View File

@ -1,5 +1,5 @@
import { renderHook } from '@testing-library/react'; import { renderHook } from '@testing-library/react';
import { AccountType, Schema } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { PositionMargin } from './use-market-positions'; import type { PositionMargin } from './use-market-positions';
import { BigNumber } from 'bignumber.js'; import { BigNumber } from 'bignumber.js';
import { useMaximumPositionSize } from './use-maximum-position-size'; import { useMaximumPositionSize } from './use-maximum-position-size';
@ -15,7 +15,7 @@ let mockMarketPositions: PositionMargin | null = defaultMockMarketPositions;
const mockAccount: Account = { const mockAccount: Account = {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '200000', balance: '200000',
asset: { asset: {
__typename: 'Asset', __typename: 'Asset',

View File

@ -1,7 +1,7 @@
import { useMarketPositions } from './use-market-positions'; import { useMarketPositions } from './use-market-positions';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import { useSettlementAccount } from './use-settlement-account'; import { useSettlementAccount } from './use-settlement-account';
import { AccountType, Schema } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { BigNumber } from 'bignumber.js'; import { BigNumber } from 'bignumber.js';
import type { AccountFragment as Account } from './__generated__/PartyBalance'; import type { AccountFragment as Account } from './__generated__/PartyBalance';
@ -28,7 +28,7 @@ export const useMaximumPositionSize = ({
const settlementAccount = useSettlementAccount( const settlementAccount = useSettlementAccount(
settlementAssetId, settlementAssetId,
accounts, accounts,
AccountType.ACCOUNT_TYPE_GENERAL Schema.AccountType.ACCOUNT_TYPE_GENERAL
); );
const marketPositions = useMarketPositions({ marketId: marketId, partyId }); const marketPositions = useMarketPositions({ marketId: marketId, partyId });

View File

@ -1,6 +1,6 @@
import { renderHook } from '@testing-library/react'; import { renderHook } from '@testing-library/react';
import { useSettlementAccount } from './use-settlement-account'; import { useSettlementAccount } from './use-settlement-account';
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { AccountFragment as Account } from './__generated__/PartyBalance'; import type { AccountFragment as Account } from './__generated__/PartyBalance';
describe('useSettlementAccount Hook', () => { describe('useSettlementAccount Hook', () => {
@ -8,7 +8,7 @@ describe('useSettlementAccount Hook', () => {
const accounts: Account[] = [ const accounts: Account[] = [
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '2000000000000000000000', balance: '2000000000000000000000',
asset: { asset: {
__typename: 'Asset', __typename: 'Asset',
@ -20,7 +20,7 @@ describe('useSettlementAccount Hook', () => {
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '1000000000', balance: '1000000000',
asset: { asset: {
__typename: 'Asset', __typename: 'Asset',
@ -32,7 +32,7 @@ describe('useSettlementAccount Hook', () => {
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '5000000000000000000', balance: '5000000000000000000',
asset: { asset: {
__typename: 'Asset', __typename: 'Asset',
@ -44,7 +44,7 @@ describe('useSettlementAccount Hook', () => {
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_MARGIN, type: Schema.AccountType.ACCOUNT_TYPE_MARGIN,
balance: '5000000000000000000', balance: '5000000000000000000',
asset: { asset: {
__typename: 'Asset', __typename: 'Asset',
@ -67,7 +67,11 @@ describe('useSettlementAccount Hook', () => {
expect(resultDai.current?.asset).toEqual(accounts[1].asset); expect(resultDai.current?.asset).toEqual(accounts[1].asset);
const { result: resultVega } = renderHook(() => const { result: resultVega } = renderHook(() =>
useSettlementAccount(vega, accounts, AccountType.ACCOUNT_TYPE_MARGIN) useSettlementAccount(
vega,
accounts,
Schema.AccountType.ACCOUNT_TYPE_MARGIN
)
); );
expect(resultVega.current?.balance).toBe(accounts[3].balance); expect(resultVega.current?.balance).toBe(accounts[3].balance);

View File

@ -1,11 +1,11 @@
import type { AccountType } from '@vegaprotocol/types'; import type { Schema } from '@vegaprotocol/types';
import { useMemo } from 'react'; import { useMemo } from 'react';
import type { AccountFragment as Account } from './__generated__/PartyBalance'; import type { AccountFragment as Account } from './__generated__/PartyBalance';
export const useSettlementAccount = ( export const useSettlementAccount = (
settlementAssetId: string, settlementAssetId: string,
accounts: Account[], accounts: Account[],
type?: AccountType type?: Schema.AccountType
): Account | null => { ): Account | null => {
const callback = () => const callback = () =>
accounts.find((account) => { accounts.find((account) => {

View File

@ -1,8 +1,10 @@
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
import { MarketState, MarketTradingMode, Schema } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { Trade } from './fills-data-provider'; import type { Trade } from './fills-data-provider';
const { MarketState, MarketTradingMode } = Schema;
export const generateFill = (override?: PartialDeep<Trade>) => { export const generateFill = (override?: PartialDeep<Trade>) => {
const defaultFill: Trade = { const defaultFill: Trade = {
__typename: 'Trade', __typename: 'Trade',

View File

@ -3,7 +3,7 @@ import {
makeDataProvider, makeDataProvider,
makeDerivedDataProvider, makeDerivedDataProvider,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import produce from 'immer'; import produce from 'immer';
@ -197,7 +197,7 @@ export const getLiquidityProvision = (
market?.tradableInstrument.instrument.product.settlementAsset.decimals, market?.tradableInstrument.instrument.product.settlementAsset.decimals,
balance: balance:
accounts accounts
?.filter((a) => a?.type === AccountType.ACCOUNT_TYPE_BOND) ?.filter((a) => a?.type === Schema.AccountType.ACCOUNT_TYPE_BOND)
?.reduce( ?.reduce(
(acc, a) => acc.plus(new BigNumber(a.balance ?? 0)), (acc, a) => acc.plus(new BigNumber(a.balance ?? 0)),
new BigNumber(0) new BigNumber(0)

View File

@ -3,7 +3,7 @@ import uniqBy from 'lodash/uniqBy';
import reverse from 'lodash/reverse'; import reverse from 'lodash/reverse';
import cloneDeep from 'lodash/cloneDeep'; import cloneDeep from 'lodash/cloneDeep';
import { VolumeType } from '@vegaprotocol/react-helpers'; import { VolumeType } from '@vegaprotocol/react-helpers';
import { MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { MarketData } from '@vegaprotocol/market-list'; import type { MarketData } from '@vegaprotocol/market-list';
import type { PriceLevelFieldsFragment } from './__generated___/MarketDepth'; import type { PriceLevelFieldsFragment } from './__generated___/MarketDepth';
export interface CumulativeVol { export interface CumulativeVol {
@ -352,8 +352,8 @@ export const generateMockData = ({
indicativeVolume: indicativeVolume?.toString(), indicativeVolume: indicativeVolume?.toString(),
marketTradingMode: marketTradingMode:
overlap > 0 overlap > 0
? MarketTradingMode.TRADING_MODE_BATCH_AUCTION ? Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION
: MarketTradingMode.TRADING_MODE_CONTINUOUS, : Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
...mapMarketData( ...mapMarketData(
{ {
staticMidPrice: '', staticMidPrice: '',

View File

@ -20,7 +20,7 @@ import {
ThemeContext, ThemeContext,
useResizeObserver, useResizeObserver,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import { MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { OrderbookRow } from './orderbook-row'; import { OrderbookRow } from './orderbook-row';
import { createRow, getPriceLevel } from './orderbook-data'; import { createRow, getPriceLevel } from './orderbook-data';
import { Icon, Splash } from '@vegaprotocol/ui-toolkit'; import { Icon, Splash } from '@vegaprotocol/ui-toolkit';
@ -545,7 +545,8 @@ export const Orderbook = ({
cumulativeAsk={data.cumulativeVol.ask} cumulativeAsk={data.cumulativeVol.ask}
cumulativeRelativeAsk={data.cumulativeVol.relativeAsk} cumulativeRelativeAsk={data.cumulativeVol.relativeAsk}
indicativeVolume={ indicativeVolume={
marketTradingMode !== MarketTradingMode.TRADING_MODE_CONTINUOUS && marketTradingMode !==
Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS &&
indicativePrice === data.price indicativePrice === data.price
? indicativeVolume ? indicativeVolume
: undefined : undefined

View File

@ -8,7 +8,6 @@ import {
useYesterday, useYesterday,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import { import {
AccountType,
Schema, Schema,
MarketStateMapping, MarketStateMapping,
MarketTradingModeMapping, MarketTradingModeMapping,
@ -156,7 +155,7 @@ export const Info = ({ market, onSelect }: InfoProps) => {
), ),
}, },
...(market.accounts || []) ...(market.accounts || [])
.filter((a) => a.type === AccountType.ACCOUNT_TYPE_INSURANCE) .filter((a) => a.type === Schema.AccountType.ACCOUNT_TYPE_INSURANCE)
.map((a) => ({ .map((a) => ({
title: t(`Insurance pool`), title: t(`Insurance pool`),
content: ( content: (

View File

@ -15,14 +15,15 @@ import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit';
import { AgGridColumn } from 'ag-grid-react'; import { AgGridColumn } from 'ag-grid-react';
import type { AgGridReact } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react';
import { import {
MarketTradingMode, Schema,
AuctionTrigger,
MarketTradingModeMapping, MarketTradingModeMapping,
AuctionTriggerMapping, AuctionTriggerMapping,
} from '@vegaprotocol/types'; } from '@vegaprotocol/types';
import type { MarketWithData } from '../../'; import type { MarketWithData } from '../../';
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets'; import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
const { MarketTradingMode, AuctionTrigger } = Schema;
export const getRowId = ({ data }: { data: { id: string } }) => data.id; export const getRowId = ({ data }: { data: { id: string } }) => data.id;
export const MarketListTable = forwardRef< export const MarketListTable = forwardRef<

View File

@ -1,6 +1,7 @@
import { MarketState, MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { Market } from '../markets-provider'; import type { Market } from '../markets-provider';
import { filterAndSortMarkets, totalFeesPercentage } from './market-utils'; import { filterAndSortMarkets, totalFeesPercentage } from './market-utils';
const { MarketState, MarketTradingMode } = Schema;
const MARKET_A: Partial<Market> = { const MARKET_A: Partial<Market> = {
id: '1', id: '1',

View File

@ -1,8 +1,9 @@
import { formatNumberPercentage } from '@vegaprotocol/react-helpers'; import { formatNumberPercentage } from '@vegaprotocol/react-helpers';
import { MarketState, MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import orderBy from 'lodash/orderBy'; import orderBy from 'lodash/orderBy';
import type { Market, Candle } from '../'; import type { Market, Candle } from '../';
const { MarketState, MarketTradingMode } = Schema;
export const totalFees = (fees: Market['fees']['factors']) => { export const totalFees = (fees: Market['fees']['factors']) => {
return fees return fees

View File

@ -1,5 +1,5 @@
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import { MarketState, MarketTradingMode, Schema } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { Order } from '../'; import type { Order } from '../';
import type { PartialDeep } from 'type-fest'; import type { PartialDeep } from 'type-fest';
@ -26,7 +26,7 @@ export const generateOrder = (partialOrder?: PartialDeep<Order>) => {
open: '', open: '',
}, },
positionDecimalPlaces: 2, positionDecimalPlaces: 2,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
__typename: 'TradableInstrument', __typename: 'TradableInstrument',
instrument: { instrument: {
@ -49,7 +49,7 @@ export const generateOrder = (partialOrder?: PartialDeep<Order>) => {
}, },
}, },
}, },
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
}, },
size: '10', size: '10',
type: Schema.OrderType.TYPE_MARKET, type: Schema.OrderType.TYPE_MARKET,

View File

@ -1,7 +1,7 @@
import { act, renderHook } from '@testing-library/react'; import { act, renderHook } from '@testing-library/react';
import type { PubKey, VegaWalletContextShape } from '@vegaprotocol/wallet'; import type { PubKey, VegaWalletContextShape } from '@vegaprotocol/wallet';
import { VegaTxStatus, VegaWalletContext } from '@vegaprotocol/wallet'; import { VegaTxStatus, VegaWalletContext } from '@vegaprotocol/wallet';
import { MarketState, MarketTradingMode, Schema } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import { useOrderSubmit } from './use-order-submit'; import { useOrderSubmit } from './use-order-submit';
@ -16,8 +16,8 @@ const defaultMarket = {
id: 'market-id', id: 'market-id',
decimalPlaces: 2, decimalPlaces: 2,
positionDecimalPlaces: 1, positionDecimalPlaces: 1,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
state: MarketState.STATE_ACTIVE, state: Schema.MarketState.STATE_ACTIVE,
tradableInstrument: { tradableInstrument: {
__typename: 'TradableInstrument', __typename: 'TradableInstrument',
instrument: { instrument: {

View File

@ -1,4 +1,4 @@
import { AccountType, MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { Account } from '@vegaprotocol/accounts'; import type { Account } from '@vegaprotocol/accounts';
import type { MarketWithData } from '@vegaprotocol/market-list'; import type { MarketWithData } from '@vegaprotocol/market-list';
import type { PositionsQuery, MarginsQuery } from './__generated__/Positions'; import type { PositionsQuery, MarginsQuery } from './__generated__/Positions';
@ -7,7 +7,7 @@ import { getMetrics, rejoinPositionData } from './positions-data-providers';
const accounts = [ const accounts = [
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_GENERAL, type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
asset: { asset: {
__typename: 'Asset', __typename: 'Asset',
symbol: 'tDAI', symbol: 'tDAI',
@ -19,7 +19,7 @@ const accounts = [
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_MARGIN, type: Schema.AccountType.ACCOUNT_TYPE_MARGIN,
asset: { asset: {
__typename: 'Asset', __typename: 'Asset',
symbol: 'tDAI', symbol: 'tDAI',
@ -41,7 +41,7 @@ const accounts = [
}, },
{ {
__typename: 'AccountBalance', __typename: 'AccountBalance',
type: AccountType.ACCOUNT_TYPE_MARGIN, type: Schema.AccountType.ACCOUNT_TYPE_MARGIN,
asset: { asset: {
__typename: 'Asset', __typename: 'Asset',
symbol: 'tDAI', symbol: 'tDAI',
@ -110,7 +110,7 @@ const marketsData = [
__typename: 'Market', __typename: 'Market',
id: '5e6035fe6a6df78c9ec44b333c231e63d357acef0a0620d2c243f5865d1dc0d8', id: '5e6035fe6a6df78c9ec44b333c231e63d357acef0a0620d2c243f5865d1dc0d8',
decimalPlaces: 5, decimalPlaces: 5,
tradingMode: MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, tradingMode: Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
tradableInstrument: { tradableInstrument: {
__typename: 'TradableInstrument', __typename: 'TradableInstrument',
@ -137,7 +137,7 @@ const marketsData = [
__typename: 'Market', __typename: 'Market',
id: '10c4b1114d2f6fda239b73d018bca55888b6018f0ac70029972a17fea0a6a56e', id: '10c4b1114d2f6fda239b73d018bca55888b6018f0ac70029972a17fea0a6a56e',
decimalPlaces: 5, decimalPlaces: 5,
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
positionDecimalPlaces: 0, positionDecimalPlaces: 0,
tradableInstrument: { tradableInstrument: {
__typename: 'TradableInstrument', __typename: 'TradableInstrument',

View File

@ -9,8 +9,7 @@ import {
makeDataProvider, makeDataProvider,
makeDerivedDataProvider, makeDerivedDataProvider,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import type { MarketTradingMode } from '@vegaprotocol/types';
import type { MarketWithData } from '@vegaprotocol/market-list'; import type { MarketWithData } from '@vegaprotocol/market-list';
import { marketsWithDataProvider } from '@vegaprotocol/market-list'; import { marketsWithDataProvider } from '@vegaprotocol/market-list';
import type { import type {
@ -54,7 +53,7 @@ export interface Position {
liquidationPrice: string; liquidationPrice: string;
lowMarginLevel: boolean; lowMarginLevel: boolean;
marketId: string; marketId: string;
marketTradingMode: MarketTradingMode; marketTradingMode: Schema.MarketTradingMode;
markPrice: string; markPrice: string;
notional: string; notional: string;
openVolume: string; openVolume: string;
@ -96,7 +95,7 @@ export const getMetrics = (
const generalAccount = accounts?.find( const generalAccount = accounts?.find(
(account) => (account) =>
account.asset.id === marginAccount.asset.id && account.asset.id === marginAccount.asset.id &&
account.type === AccountType.ACCOUNT_TYPE_GENERAL account.type === Schema.AccountType.ACCOUNT_TYPE_GENERAL
); );
const decimals = marginAccount.asset.decimals; const decimals = marginAccount.asset.decimals;
const { positionDecimalPlaces, decimalPlaces: marketDecimalPlaces } = const { positionDecimalPlaces, decimalPlaces: marketDecimalPlaces } =

View File

@ -2,7 +2,7 @@ import type { RenderResult } from '@testing-library/react';
import { act, render, screen } from '@testing-library/react'; import { act, render, screen } from '@testing-library/react';
import PositionsTable from './positions-table'; import PositionsTable from './positions-table';
import type { Position } from './positions-data-providers'; import type { Position } from './positions-data-providers';
import { MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
const singleRow: Position = { const singleRow: Position = {
marketName: 'ETH/BTC (31 july 2022)', marketName: 'ETH/BTC (31 july 2022)',
@ -17,7 +17,7 @@ const singleRow: Position = {
liquidationPrice: '83', liquidationPrice: '83',
lowMarginLevel: false, lowMarginLevel: false,
marketId: 'string', marketId: 'string',
marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
markPrice: '123', markPrice: '123',
notional: '12300', notional: '12300',
openVolume: '100', openVolume: '100',
@ -120,7 +120,8 @@ it('displays mark price', async () => {
rowData={[ rowData={[
{ {
...singleRow, ...singleRow,
marketTradingMode: MarketTradingMode.TRADING_MODE_OPENING_AUCTION, marketTradingMode:
Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION,
}, },
]} ]}
/> />

View File

@ -2,7 +2,7 @@ import BigNumber from 'bignumber.js';
import type { Story, Meta } from '@storybook/react'; import type { Story, Meta } from '@storybook/react';
import { PositionsTable } from './positions-table'; import { PositionsTable } from './positions-table';
import type { Position } from './positions-data-providers'; import type { Position } from './positions-data-providers';
import { MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
export default { export default {
component: PositionsTable, component: PositionsTable,
@ -29,12 +29,12 @@ const longPosition: Position = {
// leverageSearch: '0', // leverageSearch: '0',
liquidationPrice: '1129935', liquidationPrice: '1129935',
lowMarginLevel: false, lowMarginLevel: false,
marginAccountBalance: new BigNumber('0'), marginAccountBalance: new BigNumber('0').toString(),
// marginMaintenance: '0', // marginMaintenance: '0',
// marginSearch: '0', // marginSearch: '0',
// marginInitial: '0', // marginInitial: '0',
marketId: 'marketId1', marketId: 'marketId1',
marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
markPrice: '1131894', markPrice: '1131894',
notional: '46667989', notional: '46667989',
openVolume: '4123', openVolume: '4123',
@ -61,12 +61,12 @@ const shortPosition: Position = {
// leverageSearch: '0', // leverageSearch: '0',
liquidationPrice: '23734', liquidationPrice: '23734',
lowMarginLevel: false, lowMarginLevel: false,
marginAccountBalance: new BigNumber('0'), marginAccountBalance: new BigNumber('0').toString(),
// marginMaintenance: '0', // marginMaintenance: '0',
// marginSearch: '0', // marginSearch: '0',
// marginInitial: '0', // marginInitial: '0',
marketId: 'marketId2', marketId: 'marketId2',
marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
markPrice: '24123', markPrice: '24123',
notional: '836344', notional: '836344',
openVolume: '-3467', openVolume: '-3467',

View File

@ -28,7 +28,7 @@ import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit';
import { AgGridColumn } from 'ag-grid-react'; import { AgGridColumn } from 'ag-grid-react';
import type { AgGridReact } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react';
import type { Position } from './positions-data-providers'; import type { Position } from './positions-data-providers';
import { MarketTradingMode } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { Intent, Button, TooltipCellComponent } from '@vegaprotocol/ui-toolkit'; import { Intent, Button, TooltipCellComponent } from '@vegaprotocol/ui-toolkit';
import { getRowId } from './use-positions-data'; import { getRowId } from './use-positions-data';
@ -229,7 +229,7 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
}: VegaValueGetterParams<Position, 'markPrice'>) => { }: VegaValueGetterParams<Position, 'markPrice'>) => {
return !data || return !data ||
data.marketTradingMode === data.marketTradingMode ===
MarketTradingMode.TRADING_MODE_OPENING_AUCTION Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION
? undefined ? undefined
: toBigNum(data.markPrice, data.marketDecimalPlaces).toNumber(); : toBigNum(data.markPrice, data.marketDecimalPlaces).toNumber();
}} }}
@ -242,7 +242,7 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
} }
if ( if (
data.marketTradingMode === data.marketTradingMode ===
MarketTradingMode.TRADING_MODE_OPENING_AUCTION Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION
) { ) {
return '-'; return '-';
} }

View File

@ -1,10 +1,10 @@
import type { ChangeEvent } from 'react'; import type { ChangeEvent } from 'react';
import type { Schema as Types } from '@vegaprotocol/types'; import type { Schema } from '@vegaprotocol/types';
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'; import { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
import type { IDoesFilterPassParams, IFilterParams } from 'ag-grid-community'; import type { IDoesFilterPassParams, IFilterParams } from 'ag-grid-community';
import { isValidDate } from '../format/date'; import { isValidDate } from '../format/date';
const defaultFilterValue: Types.DateRange = {}; const defaultFilterValue: Schema.DateRange = {};
const toInputValue = (value: string) => { const toInputValue = (value: string) => {
const date = new Date(value); const date = new Date(value);
@ -21,7 +21,7 @@ const toInputValue = (value: string) => {
}; };
export const DateRangeFilter = forwardRef((props: IFilterParams, ref) => { export const DateRangeFilter = forwardRef((props: IFilterParams, ref) => {
const [value, setValue] = useState<Types.DateRange>(defaultFilterValue); const [value, setValue] = useState<Schema.DateRange>(defaultFilterValue);
// expose AG Grid Filter Lifecycle callbacks // expose AG Grid Filter Lifecycle callbacks
useImperativeHandle(ref, () => { useImperativeHandle(ref, () => {
@ -68,7 +68,7 @@ export const DateRangeFilter = forwardRef((props: IFilterParams, ref) => {
return { value }; return { value };
}, },
setModel(model?: { value: Types.DateRange } | null) { setModel(model?: { value: Schema.DateRange } | null) {
setValue(model?.value || defaultFilterValue); setValue(model?.value || defaultFilterValue);
}, },
}; };

View File

@ -12,6 +12,7 @@ module.exports = {
'../../apps/trading/client.graphql', '../../apps/trading/client.graphql',
], ],
excludes: [ excludes: [
'../../apps/explorer/**',
'**/generic-data-provider.ts', '**/generic-data-provider.ts',
'**/__generated___/*', '**/__generated___/*',
'../../libs/accounts/**', '../../libs/accounts/**',

View File

@ -7,36 +7,6 @@
// START Enums and Input Objects // START Enums and Input Objects
//============================================================== //==============================================================
/**
* The various account types in Vega (used by collateral)
*/
export enum AccountType {
ACCOUNT_TYPE_BOND = "ACCOUNT_TYPE_BOND",
ACCOUNT_TYPE_EXTERNAL = "ACCOUNT_TYPE_EXTERNAL",
ACCOUNT_TYPE_FEES_INFRASTRUCTURE = "ACCOUNT_TYPE_FEES_INFRASTRUCTURE",
ACCOUNT_TYPE_FEES_LIQUIDITY = "ACCOUNT_TYPE_FEES_LIQUIDITY",
ACCOUNT_TYPE_FEES_MAKER = "ACCOUNT_TYPE_FEES_MAKER",
ACCOUNT_TYPE_GENERAL = "ACCOUNT_TYPE_GENERAL",
ACCOUNT_TYPE_GLOBAL_INSURANCE = "ACCOUNT_TYPE_GLOBAL_INSURANCE",
ACCOUNT_TYPE_GLOBAL_REWARD = "ACCOUNT_TYPE_GLOBAL_REWARD",
ACCOUNT_TYPE_INSURANCE = "ACCOUNT_TYPE_INSURANCE",
ACCOUNT_TYPE_MARGIN = "ACCOUNT_TYPE_MARGIN",
ACCOUNT_TYPE_PENDING_TRANSFERS = "ACCOUNT_TYPE_PENDING_TRANSFERS",
ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES = "ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES",
ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES = "ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES",
ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES = "ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES",
ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS = "ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS",
ACCOUNT_TYPE_SETTLEMENT = "ACCOUNT_TYPE_SETTLEMENT",
}
export enum AuctionTrigger {
AUCTION_TRIGGER_BATCH = "AUCTION_TRIGGER_BATCH",
AUCTION_TRIGGER_LIQUIDITY = "AUCTION_TRIGGER_LIQUIDITY",
AUCTION_TRIGGER_OPENING = "AUCTION_TRIGGER_OPENING",
AUCTION_TRIGGER_PRICE = "AUCTION_TRIGGER_PRICE",
AUCTION_TRIGGER_UNSPECIFIED = "AUCTION_TRIGGER_UNSPECIFIED",
}
/** /**
* Comparator describes the type of comparison. * Comparator describes the type of comparison.
*/ */
@ -48,48 +18,6 @@ export enum ConditionOperator {
OPERATOR_LESS_THAN_OR_EQUAL = "OPERATOR_LESS_THAN_OR_EQUAL", OPERATOR_LESS_THAN_OR_EQUAL = "OPERATOR_LESS_THAN_OR_EQUAL",
} }
/**
* Status describe the status of the data spec
*/
export enum DataSourceSpecStatus {
STATUS_ACTIVE = "STATUS_ACTIVE",
STATUS_DEACTIVATED = "STATUS_DEACTIVATED",
}
/**
* The current state of a market
*/
export enum MarketState {
STATE_ACTIVE = "STATE_ACTIVE",
STATE_CANCELLED = "STATE_CANCELLED",
STATE_CLOSED = "STATE_CLOSED",
STATE_PENDING = "STATE_PENDING",
STATE_PROPOSED = "STATE_PROPOSED",
STATE_REJECTED = "STATE_REJECTED",
STATE_SETTLED = "STATE_SETTLED",
STATE_SUSPENDED = "STATE_SUSPENDED",
STATE_TRADING_TERMINATED = "STATE_TRADING_TERMINATED",
}
/**
* What market trading mode is the market in
*/
export enum MarketTradingMode {
TRADING_MODE_BATCH_AUCTION = "TRADING_MODE_BATCH_AUCTION",
TRADING_MODE_CONTINUOUS = "TRADING_MODE_CONTINUOUS",
TRADING_MODE_MONITORING_AUCTION = "TRADING_MODE_MONITORING_AUCTION",
TRADING_MODE_NO_TRADING = "TRADING_MODE_NO_TRADING",
TRADING_MODE_OPENING_AUCTION = "TRADING_MODE_OPENING_AUCTION",
}
/**
* Validating status of a node, i.e. validator or non-validator
*/
export enum NodeStatus {
NODE_STATUS_NON_VALIDATOR = "NODE_STATUS_NON_VALIDATOR",
NODE_STATUS_VALIDATOR = "NODE_STATUS_VALIDATOR",
}
/** /**
* Type describes the type of properties that are supported by the data source * Type describes the type of properties that are supported by the data source
* engine. * engine.

View File

@ -1,7 +1,7 @@
import { captureException } from '@sentry/react'; import { captureException } from '@sentry/react';
import type { Asset } from '@vegaprotocol/assets'; import type { Asset } from '@vegaprotocol/assets';
import { addDecimal } from '@vegaprotocol/react-helpers'; import { addDecimal } from '@vegaprotocol/react-helpers';
import { AccountType } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import { useCallback, useEffect } from 'react'; import { useCallback, useEffect } from 'react';
import type { AccountFieldsFragment } from '@vegaprotocol/accounts'; import type { AccountFieldsFragment } from '@vegaprotocol/accounts';
@ -25,7 +25,7 @@ export const useWithdrawAsset = (
const asset = assets.find((a) => a.id === id); const asset = assets.find((a) => a.id === id);
const account = accounts.find( const account = accounts.find(
(a) => (a) =>
a.type === AccountType.ACCOUNT_TYPE_GENERAL && a.type === Schema.AccountType.ACCOUNT_TYPE_GENERAL &&
a.asset.id === asset?.id a.asset.id === asset?.id
); );
const balance = const balance =