diff --git a/apps/console-lite-e2e/src/integration/app.test.ts b/apps/console-lite-e2e/src/integration/app.test.ts index 1c170c35f..b40f249dd 100644 --- a/apps/console-lite-e2e/src/integration/app.test.ts +++ b/apps/console-lite-e2e/src/integration/app.test.ts @@ -1,5 +1,17 @@ +import { aliasQuery } from '@vegaprotocol/cypress'; +import { + generateSimpleMarkets, + generateMarketsCandles, +} from '../support/mocks/generate-markets'; + describe('simple trading app', { tags: '@smoke' }, () => { - beforeEach(() => cy.visit('/')); + beforeEach(() => { + cy.mockGQL((req) => { + aliasQuery(req, 'Markets', generateSimpleMarkets()); + aliasQuery(req, 'MarketsCandles', generateMarketsCandles()); + }); + cy.visit('/'); + }); it('render', () => { cy.get('#root').should('exist'); diff --git a/apps/console-lite-e2e/src/integration/market-list.test.ts b/apps/console-lite-e2e/src/integration/market-list.test.ts index d53cae199..9253b93ce 100644 --- a/apps/console-lite-e2e/src/integration/market-list.test.ts +++ b/apps/console-lite-e2e/src/integration/market-list.test.ts @@ -1,9 +1,8 @@ import { aliasQuery } from '@vegaprotocol/cypress'; -import type { Markets } from '@vegaprotocol/market-list'; +import type { MarketsQuery } from '@vegaprotocol/market-list'; import { generateLongListMarkets, generateSimpleMarkets, - generateMarketsData, generateMarketsCandles, } from '../support/mocks/generate-markets'; @@ -12,8 +11,7 @@ describe('market list', { tags: '@smoke' }, () => { beforeEach(() => { cy.mockGQL((req) => { aliasQuery(req, 'Markets', generateSimpleMarkets()); - aliasQuery(req, 'MarketsDataQuery', generateMarketsData()); - aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles()); + aliasQuery(req, 'MarketsCandles', generateMarketsCandles()); }); cy.visit('/markets'); }); @@ -68,8 +66,7 @@ describe('market list', { tags: '@smoke' }, () => { beforeEach(() => { cy.mockGQL((req) => { aliasQuery(req, 'Markets', generateSimpleMarkets()); - aliasQuery(req, 'MarketsDataQuery', generateMarketsData()); - aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles()); + aliasQuery(req, 'MarketsCandles', generateMarketsCandles()); }); }); @@ -81,7 +78,7 @@ describe('market list', { tags: '@smoke' }, () => { it('last asset (if exists)', () => { cy.visit('/markets'); cy.wait('@Markets').then((filters) => { - const data: Markets | undefined = filters?.response?.body?.data; + const data: MarketsQuery | undefined = filters?.response?.body?.data; if (data.marketsConnection.edges.length) { const asset = data.marketsConnection.edges[0].node.tradableInstrument.instrument @@ -107,8 +104,7 @@ describe('market list', { tags: '@smoke' }, () => { cy.viewport(1440, 900); cy.mockGQL((req) => { aliasQuery(req, 'Markets', generateLongListMarkets(1000)); - aliasQuery(req, 'MarketsDataQuery', generateMarketsData()); - aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles()); + aliasQuery(req, 'MarketsCandles', generateMarketsCandles()); }); performance.mark('start-1k'); cy.visit('/markets'); diff --git a/apps/console-lite-e2e/src/integration/market-selector.test.ts b/apps/console-lite-e2e/src/integration/market-selector.test.ts index ad8074bf6..f2f5bfe8c 100644 --- a/apps/console-lite-e2e/src/integration/market-selector.test.ts +++ b/apps/console-lite-e2e/src/integration/market-selector.test.ts @@ -14,15 +14,15 @@ import { generatePartyMarketData } from '../support/mocks/generate-party-market- import { generateMarketMarkPrice } from '../support/mocks/generate-market-mark-price'; import { generateMarketNames } from '../support/mocks/generate-market-names'; import { generateMarketDepth } from '../support/mocks/generate-market-depth'; -import type { Market, Markets } from '@vegaprotocol/market-list'; +import type { Market, MarketsQuery } from '@vegaprotocol/market-list'; describe('market selector', { tags: '@smoke' }, () => { let markets: Market[]; beforeEach(() => { cy.mockGQL((req) => { aliasQuery(req, 'Markets', generateSimpleMarkets()); - aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles()); - aliasQuery(req, 'MarketsDataQuery', generateMarketsData()); + aliasQuery(req, 'MarketsCandles', generateMarketsCandles()); + aliasQuery(req, 'MarketsData', generateMarketsData()); aliasQuery(req, 'DealTicket', generateDealTicket()); aliasQuery(req, 'MarketTags', generateMarketTags()); aliasQuery(req, 'MarketPositions', generateMarketPositions()); @@ -36,7 +36,7 @@ describe('market selector', { tags: '@smoke' }, () => { cy.visit('/markets'); cy.wait('@Markets').then((response) => { - const data: Markets | undefined = response?.response?.body?.data; + const data: MarketsQuery | undefined = response?.response?.body?.data; if (data.marketsConnection.edges.length) { markets = data.marketsConnection.edges.map((edge) => edge.node); } diff --git a/apps/console-lite-e2e/src/integration/market-trade.test.ts b/apps/console-lite-e2e/src/integration/market-trade.test.ts index 9e042ec73..24ccf929f 100644 --- a/apps/console-lite-e2e/src/integration/market-trade.test.ts +++ b/apps/console-lite-e2e/src/integration/market-trade.test.ts @@ -13,15 +13,15 @@ import { generatePartyMarketData } from '../support/mocks/generate-party-market- import { generateMarketMarkPrice } from '../support/mocks/generate-market-mark-price'; import { generateMarketDepth } from '../support/mocks/generate-market-depth'; import { connectVegaWallet } from '../support/connect-wallet'; -import type { Markets, Market } from '@vegaprotocol/market-list'; +import type { MarketsQuery, Market } from '@vegaprotocol/market-list'; describe('Market trade', { tags: '@smoke' }, () => { let markets: Market[]; beforeEach(() => { cy.mockGQL((req) => { aliasQuery(req, 'Markets', generateSimpleMarkets()); - aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles()); - aliasQuery(req, 'MarketsDataQuery', generateMarketsData()); + aliasQuery(req, 'MarketsCandles', generateMarketsCandles()); + aliasQuery(req, 'MarketsData', generateMarketsData()); aliasQuery(req, 'SimpleMarkets', generateSimpleMarkets()); aliasQuery(req, 'DealTicket', generateDealTicket()); aliasQuery(req, 'MarketTags', generateMarketTags()); @@ -34,7 +34,7 @@ describe('Market trade', { tags: '@smoke' }, () => { }); cy.visit('/markets'); cy.wait('@Markets').then((response) => { - const data: Markets | undefined = response?.response?.body?.data; + const data: MarketsQuery | undefined = response?.response?.body?.data; if (data.marketsConnection.edges.length) { markets = data.marketsConnection.edges.map((edge) => edge.node); } diff --git a/apps/console-lite-e2e/src/support/mocks/generate-markets.ts b/apps/console-lite-e2e/src/support/mocks/generate-markets.ts index 9ce814dfc..20fb35439 100644 --- a/apps/console-lite-e2e/src/support/mocks/generate-markets.ts +++ b/apps/console-lite-e2e/src/support/mocks/generate-markets.ts @@ -1,17 +1,16 @@ import merge from 'lodash/merge'; import { MarketState } from '@vegaprotocol/types'; import type { + MarketsQuery, Market, - MarketsCandlesQuery_marketsConnection_edges_node, - MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges, - Markets, MarketsCandlesQuery, + Candle, MarketsDataQuery, } from '@vegaprotocol/market-list'; import { protoMarket, protoCandles } from './commons'; MarketState.STATE_SUSPENDED; -export const generateSimpleMarkets = (): Markets => { +export const generateSimpleMarkets = (): MarketsQuery => { const markets: Market[] = [ { ...protoMarket }, { @@ -512,543 +511,563 @@ export const generateSimpleMarkets = (): Markets => { }; export const generateMarketsCandles = (): MarketsCandlesQuery => { - const markets: MarketsCandlesQuery_marketsConnection_edges_node[] = [ - { - id: protoMarket.id, - __typename: 'Market', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: protoCandles.map((node) => ({ - __typename: 'CandleEdge', - node, - })) as unknown as MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges[], - }, - }, - { - id: '6030e5b4e0ca3297a26081e5af4d453f97f96baab2d74bf56f84efcffc4c382f', - __typename: 'Market', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { open: '723082', close: '726800', __typename: 'Candle' }, - { - open: '726800', - close: '733551', - __typename: 'Candle', - }, - { open: '733557', close: '719960', __typename: 'Candle' }, - { - open: '719961', - close: '707711', - __typename: 'Candle', - }, - { open: '702459', close: '705275', __typename: 'Candle' }, - { - open: '701609', - close: '698494', - __typename: 'Candle', - }, - { open: '698494', close: '702201', __typename: 'Candle' }, - { - open: '704749', - close: '704248', - __typename: 'Candle', - }, - { open: '708562', close: '714712', __typename: 'Candle' }, - { - open: '718434', - close: '732567', - __typename: 'Candle', - }, - { open: '732567', close: '750475', __typename: 'Candle' }, - { - open: '768916', - close: '746371', - __typename: 'Candle', - }, - { open: '740240', close: '744910', __typename: 'Candle' }, - { - open: '746902', - close: '731680', - __typename: 'Candle', - }, - { open: '730156', close: '729021', __typename: 'Candle' }, - { - open: '730503', - close: '738096', - __typename: 'Candle', - }, - { open: '738096', close: '743087', __typename: 'Candle' }, - { - open: '739244', - close: '732352', - __typename: 'Candle', - }, - { open: '732352', close: '751259', __typename: 'Candle' }, - { - open: '751259', - close: '751455', - __typename: 'Candle', - }, - { open: '751455', close: '753990', __typename: 'Candle' }, - { - open: '757174', - close: '761100', - __typename: 'Candle', - }, - { open: '758974', close: '759379', __typename: 'Candle' }, - { - open: '762834', - close: '761777', - __typename: 'Candle', - }, - ].map((node) => ({ - __typename: 'CandleEdge', - node, - })) as unknown as MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges[], - }, - }, - { - id: 'de74a5572045b300e8ec50d136896912ec76e7d7ec135bc305dfd4854d9363a4', - __typename: 'Market', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { open: '14602', close: '14596', __typename: 'Candle' }, - { - open: '14596', - close: '14731', - __typename: 'Candle', - }, - { open: '14732', close: '14592', __typename: 'Candle' }, - { - open: '14592', - close: '14516', - __typename: 'Candle', - }, - { open: '14516', close: '14179', __typename: 'Candle' }, - { - open: '14179', - close: '14031', - __typename: 'Candle', - }, - { open: '14032', close: '14115', __typename: 'Candle' }, - { - open: '14116', - close: '14166', - __typename: 'Candle', - }, - { open: '14166', close: '14377', __typename: 'Candle' }, - { - open: '14377', - close: '14714', - __typename: 'Candle', - }, - { open: '14713', close: '14593', __typename: 'Candle' }, - { - open: '14594', - close: '14273', - __typename: 'Candle', - }, - { open: '14272', close: '14245', __typename: 'Candle' }, - { - open: '14244', - close: '14337', - __typename: 'Candle', - }, - { open: '14338', close: '14384', __typename: 'Candle' }, - { - open: '14385', - close: '14257', - __typename: 'Candle', - }, - { open: '14256', close: '14105', __typename: 'Candle' }, - { - open: '14106', - close: '14067', - __typename: 'Candle', - }, - { open: '14066', close: '14196', __typename: 'Candle' }, - { - open: '14197', - close: '14316', - __typename: 'Candle', - }, - { open: '14315', close: '14377', __typename: 'Candle' }, - { - open: '14378', - close: '14106', - __typename: 'Candle', - }, - { open: '14105', close: '14317', __typename: 'Candle' }, - { - open: '14318', - close: '14467', - __typename: 'Candle', - }, - ].map((node) => ({ - __typename: 'CandleEdge', - node, - })) as unknown as MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges[], - }, - }, - { - id: '87b0bbb3c171baa5d97dfc3852332829c91e5c5dc9f7c8fb584c6d8ac75aaaf2', - __typename: 'Market', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { open: '5700', close: '5688', __typename: 'Candle' }, - { - open: '5688', - close: '5644', - __typename: 'Candle', - }, - { open: '5644', close: '5664', __typename: 'Candle' }, - { - open: '5664', - close: '5694', - __typename: 'Candle', - }, - { open: '5694', close: '5751', __typename: 'Candle' }, - { - open: '5751', - close: '5853', - __typename: 'Candle', - }, - { open: '5853', close: '5773', __typename: 'Candle' }, - { - open: '5773', - close: '5697', - __typename: 'Candle', - }, - { open: '5697', close: '5683', __typename: 'Candle' }, - { - open: '5683', - close: '5655', - __typename: 'Candle', - }, - { open: '5655', close: '5674', __typename: 'Candle' }, - { - open: '5674', - close: '5705', - __typename: 'Candle', - }, - { open: '5705', close: '5648', __typename: 'Candle' }, - { - open: '5648', - close: '5646', - __typename: 'Candle', - }, - { open: '5646', close: '5687', __typename: 'Candle' }, - { - open: '5687', - close: '5675', - __typename: 'Candle', - }, - { open: '5675', close: '5696', __typename: 'Candle' }, - { - open: '5696', - close: '5699', - __typename: 'Candle', - }, - { open: '5699', close: '5731', __typename: 'Candle' }, - { - open: '5731', - close: '5768', - __typename: 'Candle', - }, - ].map((node) => ({ - __typename: 'CandleEdge', - node, - })) as unknown as MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges[], - }, - }, - { - id: '65663ebdc96161162769c4d5c5508137416748178d7cb28e2cb0d07a151a2bc6', - __typename: 'Market', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { open: '6680', close: '6600', __typename: 'Candle' }, - { - open: '6600', - close: '6630', - __typename: 'Candle', - }, - { open: '6630', close: '6677', __typename: 'Candle' }, - { - open: '6735', - close: '6720', - __typename: 'Candle', - }, - { open: '6720', close: '6691', __typename: 'Candle' }, - { - open: '6681', - close: '6730', - __typename: 'Candle', - }, - { open: '6756', close: '6778', __typename: 'Candle' }, - { - open: '6778', - close: '6768', - __typename: 'Candle', - }, - { open: '6768', close: '6834', __typename: 'Candle' }, - { - open: '6834', - close: '7001', - __typename: 'Candle', - }, - { open: '7001', close: '6894', __typename: 'Candle' }, - { - open: '6910', - close: '6867', - __typename: 'Candle', - }, - { open: '6867', close: '6827', __typename: 'Candle' }, - { - open: '6899', - close: '6910', - __typename: 'Candle', - }, - { open: '6868', close: '6902', __typename: 'Candle' }, - { - open: '6905', - close: '6947', - __typename: 'Candle', - }, - { open: '6932', close: '6900', __typename: 'Candle' }, - { - open: '6900', - close: '6911', - __typename: 'Candle', - }, - { open: '6936', close: '6948', __typename: 'Candle' }, - { - open: '6936', - close: '6946', - __typename: 'Candle', - }, - { open: '6946', close: '6906', __typename: 'Candle' }, - { - open: '6947', - close: '6962', - __typename: 'Candle', - }, - { open: '6962', close: '7027', __typename: 'Candle' }, - { - open: '6941', - close: '6921', - __typename: 'Candle', - }, - ].map((node) => ({ - __typename: 'CandleEdge', - node, - })) as unknown as MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges[], - }, - }, - { - id: '234afabd27e3bce1a879039c041f9f00f915d98459935ddafd0169d38dd13850', - __typename: 'Market', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { open: '15126319', close: '15087482', __typename: 'Candle' }, - { - open: '15087482', - close: '15119759', - __typename: 'Candle', - }, - { open: '15119759', close: '15061361', __typename: 'Candle' }, - { - open: '15061361', - close: '14742622', - __typename: 'Candle', - }, - { open: '14742622', close: '14735571', __typename: 'Candle' }, - { - open: '14735571', - close: '14694437', - __typename: 'Candle', - }, - { open: '14694437', close: '14670479', __typename: 'Candle' }, - { - open: '14670479', - close: '14624796', - __typename: 'Candle', - }, - { open: '14621001', close: '14722835', __typename: 'Candle' }, - { - open: '14722835', - close: '14705183', - __typename: 'Candle', - }, - { open: '14705183', close: '14710797', __typename: 'Candle' }, - { - open: '14710796', - close: '14713874', - __typename: 'Candle', - }, - { open: '14713874', close: '14677982', __typename: 'Candle' }, - { - open: '14677982', - close: '14710031', - __typename: 'Candle', - }, - { open: '14751685', close: '14737556', __typename: 'Candle' }, - { - open: '14737556', - close: '14769139', - __typename: 'Candle', - }, - { open: '14760616', close: '14761691', __typename: 'Candle' }, - { - open: '14761691', - close: '14714380', - __typename: 'Candle', - }, - { open: '14714380', close: '14740160', __typename: 'Candle' }, - { - open: '14740160', - close: '14764832', - __typename: 'Candle', - }, - { open: '14764832', close: '14778059', __typename: 'Candle' }, - { - open: '14761936', - close: '14707831', - __typename: 'Candle', - }, - { open: '14707831', close: '14753272', __typename: 'Candle' }, - { - open: '14753272', - close: '14771411', - __typename: 'Candle', - }, - ].map((node) => ({ - __typename: 'CandleEdge', - node, - })) as unknown as MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges[], - }, - }, - { - id: '9f2a3c1caa67bb0773ec18d908d32b55b129b9ec2d106a8e9a87f6aa5c0375a6', - __typename: 'Market', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { open: '71263667', close: '71173749', __typename: 'Candle' }, - { - open: '71173749', - close: '71055959', - __typename: 'Candle', - }, - { open: '71055959', close: '71078605', __typename: 'Candle' }, - { - open: '71078605', - close: '69838205', - __typename: 'Candle', - }, - { open: '69838205', close: '69166023', __typename: 'Candle' }, - { - open: '69166023', - close: '68841759', - __typename: 'Candle', - }, - { open: '68841759', close: '68711290', __typename: 'Candle' }, - { - open: '68711290', - close: '68650154', - __typename: 'Candle', - }, - { open: '68644289', close: '68638322', __typename: 'Candle' }, - { - open: '68704232', - close: '68343581', - __typename: 'Candle', - }, - { open: '67345721', close: '67554701', __typename: 'Candle' }, - { - open: '67533143', - close: '67551571', - __typename: 'Candle', - }, - { open: '67533286', close: '67543539', __typename: 'Candle' }, - { - open: '67580208', - close: '67472337', - __typename: 'Candle', - }, - { open: '67416289', close: '67459697', __typename: 'Candle' }, - { - open: '67396085', - close: '67528265', - __typename: 'Candle', - }, - { open: '67491799', close: '67538833', __typename: 'Candle' }, - { - open: '67493210', - close: '67362908', - __typename: 'Candle', - }, - { open: '67362908', close: '67518182', __typename: 'Candle' }, - { - open: '67518182', - close: '67635775', - __typename: 'Candle', - }, - { open: '67635775', close: '67734861', __typename: 'Candle' }, - { - open: '67714943', - close: '67736742', - __typename: 'Candle', - }, - { open: '67716074', close: '67690826', __typename: 'Candle' }, - { - open: '67714352', - close: '67817444', - __typename: 'Candle', - }, - ].map((node) => ({ - __typename: 'CandleEdge', - node, - })) as unknown as MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges[], - }, - }, - { - id: '8a45ee934d3ddac4b036f9884df1064a5353c620a56f775ba36597d0edef9a7a', - __typename: 'Market', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { open: '5809', close: '5795', __typename: 'Candle' }, - { - open: '5795', - close: '5845', - __typename: 'Candle', - }, - { open: '5845', close: '5779', __typename: 'Candle' }, - { - open: '5779', - close: '5710', - __typename: 'Candle', - }, - { open: '5710', close: '5691', __typename: 'Candle' }, - ].map((node) => ({ - __typename: 'CandleEdge', - node, - })) as unknown as MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges[], - }, - }, - ]; return { marketsConnection: { __typename: 'MarketConnection', - edges: markets.map((node) => ({ - __typename: 'MarketEdge', - node, - })), + edges: [ + { + __typename: 'MarketEdge', + node: { + id: protoMarket.id, + __typename: 'Market', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: protoCandles.map((node) => ({ + __typename: 'CandleEdge', + node: node as unknown as Candle, + })), + }, + }, + }, + { + __typename: 'MarketEdge', + node: { + id: '6030e5b4e0ca3297a26081e5af4d453f97f96baab2d74bf56f84efcffc4c382f', + __typename: 'Market', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { open: '723082', close: '726800', __typename: 'Candle' }, + { + open: '726800', + close: '733551', + __typename: 'Candle', + }, + { open: '733557', close: '719960', __typename: 'Candle' }, + { + open: '719961', + close: '707711', + __typename: 'Candle', + }, + { open: '702459', close: '705275', __typename: 'Candle' }, + { + open: '701609', + close: '698494', + __typename: 'Candle', + }, + { open: '698494', close: '702201', __typename: 'Candle' }, + { + open: '704749', + close: '704248', + __typename: 'Candle', + }, + { open: '708562', close: '714712', __typename: 'Candle' }, + { + open: '718434', + close: '732567', + __typename: 'Candle', + }, + { open: '732567', close: '750475', __typename: 'Candle' }, + { + open: '768916', + close: '746371', + __typename: 'Candle', + }, + { open: '740240', close: '744910', __typename: 'Candle' }, + { + open: '746902', + close: '731680', + __typename: 'Candle', + }, + { open: '730156', close: '729021', __typename: 'Candle' }, + { + open: '730503', + close: '738096', + __typename: 'Candle', + }, + { open: '738096', close: '743087', __typename: 'Candle' }, + { + open: '739244', + close: '732352', + __typename: 'Candle', + }, + { open: '732352', close: '751259', __typename: 'Candle' }, + { + open: '751259', + close: '751455', + __typename: 'Candle', + }, + { open: '751455', close: '753990', __typename: 'Candle' }, + { + open: '757174', + close: '761100', + __typename: 'Candle', + }, + { open: '758974', close: '759379', __typename: 'Candle' }, + { + open: '762834', + close: '761777', + __typename: 'Candle', + }, + ].map((node) => ({ + __typename: 'CandleEdge', + node: node as unknown as Candle, + })), + }, + }, + }, + { + __typename: 'MarketEdge', + node: { + id: 'de74a5572045b300e8ec50d136896912ec76e7d7ec135bc305dfd4854d9363a4', + __typename: 'Market', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { open: '14602', close: '14596', __typename: 'Candle' }, + { + open: '14596', + close: '14731', + __typename: 'Candle', + }, + { open: '14732', close: '14592', __typename: 'Candle' }, + { + open: '14592', + close: '14516', + __typename: 'Candle', + }, + { open: '14516', close: '14179', __typename: 'Candle' }, + { + open: '14179', + close: '14031', + __typename: 'Candle', + }, + { open: '14032', close: '14115', __typename: 'Candle' }, + { + open: '14116', + close: '14166', + __typename: 'Candle', + }, + { open: '14166', close: '14377', __typename: 'Candle' }, + { + open: '14377', + close: '14714', + __typename: 'Candle', + }, + { open: '14713', close: '14593', __typename: 'Candle' }, + { + open: '14594', + close: '14273', + __typename: 'Candle', + }, + { open: '14272', close: '14245', __typename: 'Candle' }, + { + open: '14244', + close: '14337', + __typename: 'Candle', + }, + { open: '14338', close: '14384', __typename: 'Candle' }, + { + open: '14385', + close: '14257', + __typename: 'Candle', + }, + { open: '14256', close: '14105', __typename: 'Candle' }, + { + open: '14106', + close: '14067', + __typename: 'Candle', + }, + { open: '14066', close: '14196', __typename: 'Candle' }, + { + open: '14197', + close: '14316', + __typename: 'Candle', + }, + { open: '14315', close: '14377', __typename: 'Candle' }, + { + open: '14378', + close: '14106', + __typename: 'Candle', + }, + { open: '14105', close: '14317', __typename: 'Candle' }, + { + open: '14318', + close: '14467', + __typename: 'Candle', + }, + ].map((node) => ({ + __typename: 'CandleEdge', + node: node as unknown as Candle, + })), + }, + }, + }, + { + __typename: 'MarketEdge', + node: { + id: '87b0bbb3c171baa5d97dfc3852332829c91e5c5dc9f7c8fb584c6d8ac75aaaf2', + __typename: 'Market', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { open: '5700', close: '5688', __typename: 'Candle' }, + { + open: '5688', + close: '5644', + __typename: 'Candle', + }, + { open: '5644', close: '5664', __typename: 'Candle' }, + { + open: '5664', + close: '5694', + __typename: 'Candle', + }, + { open: '5694', close: '5751', __typename: 'Candle' }, + { + open: '5751', + close: '5853', + __typename: 'Candle', + }, + { open: '5853', close: '5773', __typename: 'Candle' }, + { + open: '5773', + close: '5697', + __typename: 'Candle', + }, + { open: '5697', close: '5683', __typename: 'Candle' }, + { + open: '5683', + close: '5655', + __typename: 'Candle', + }, + { open: '5655', close: '5674', __typename: 'Candle' }, + { + open: '5674', + close: '5705', + __typename: 'Candle', + }, + { open: '5705', close: '5648', __typename: 'Candle' }, + { + open: '5648', + close: '5646', + __typename: 'Candle', + }, + { open: '5646', close: '5687', __typename: 'Candle' }, + { + open: '5687', + close: '5675', + __typename: 'Candle', + }, + { open: '5675', close: '5696', __typename: 'Candle' }, + { + open: '5696', + close: '5699', + __typename: 'Candle', + }, + { open: '5699', close: '5731', __typename: 'Candle' }, + { + open: '5731', + close: '5768', + __typename: 'Candle', + }, + ].map((node) => ({ + __typename: 'CandleEdge', + node: node as unknown as Candle, + })), + }, + }, + }, + { + __typename: 'MarketEdge', + node: { + id: '65663ebdc96161162769c4d5c5508137416748178d7cb28e2cb0d07a151a2bc6', + __typename: 'Market', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { open: '6680', close: '6600', __typename: 'Candle' }, + { + open: '6600', + close: '6630', + __typename: 'Candle', + }, + { open: '6630', close: '6677', __typename: 'Candle' }, + { + open: '6735', + close: '6720', + __typename: 'Candle', + }, + { open: '6720', close: '6691', __typename: 'Candle' }, + { + open: '6681', + close: '6730', + __typename: 'Candle', + }, + { open: '6756', close: '6778', __typename: 'Candle' }, + { + open: '6778', + close: '6768', + __typename: 'Candle', + }, + { open: '6768', close: '6834', __typename: 'Candle' }, + { + open: '6834', + close: '7001', + __typename: 'Candle', + }, + { open: '7001', close: '6894', __typename: 'Candle' }, + { + open: '6910', + close: '6867', + __typename: 'Candle', + }, + { open: '6867', close: '6827', __typename: 'Candle' }, + { + open: '6899', + close: '6910', + __typename: 'Candle', + }, + { open: '6868', close: '6902', __typename: 'Candle' }, + { + open: '6905', + close: '6947', + __typename: 'Candle', + }, + { open: '6932', close: '6900', __typename: 'Candle' }, + { + open: '6900', + close: '6911', + __typename: 'Candle', + }, + { open: '6936', close: '6948', __typename: 'Candle' }, + { + open: '6936', + close: '6946', + __typename: 'Candle', + }, + { open: '6946', close: '6906', __typename: 'Candle' }, + { + open: '6947', + close: '6962', + __typename: 'Candle', + }, + { open: '6962', close: '7027', __typename: 'Candle' }, + { + open: '6941', + close: '6921', + __typename: 'Candle', + }, + ].map((node) => ({ + __typename: 'CandleEdge', + node: node as unknown as Candle, + })), + }, + }, + }, + { + __typename: 'MarketEdge', + node: { + id: '234afabd27e3bce1a879039c041f9f00f915d98459935ddafd0169d38dd13850', + __typename: 'Market', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { open: '15126319', close: '15087482', __typename: 'Candle' }, + { + open: '15087482', + close: '15119759', + __typename: 'Candle', + }, + { open: '15119759', close: '15061361', __typename: 'Candle' }, + { + open: '15061361', + close: '14742622', + __typename: 'Candle', + }, + { open: '14742622', close: '14735571', __typename: 'Candle' }, + { + open: '14735571', + close: '14694437', + __typename: 'Candle', + }, + { open: '14694437', close: '14670479', __typename: 'Candle' }, + { + open: '14670479', + close: '14624796', + __typename: 'Candle', + }, + { open: '14621001', close: '14722835', __typename: 'Candle' }, + { + open: '14722835', + close: '14705183', + __typename: 'Candle', + }, + { open: '14705183', close: '14710797', __typename: 'Candle' }, + { + open: '14710796', + close: '14713874', + __typename: 'Candle', + }, + { open: '14713874', close: '14677982', __typename: 'Candle' }, + { + open: '14677982', + close: '14710031', + __typename: 'Candle', + }, + { open: '14751685', close: '14737556', __typename: 'Candle' }, + { + open: '14737556', + close: '14769139', + __typename: 'Candle', + }, + { open: '14760616', close: '14761691', __typename: 'Candle' }, + { + open: '14761691', + close: '14714380', + __typename: 'Candle', + }, + { open: '14714380', close: '14740160', __typename: 'Candle' }, + { + open: '14740160', + close: '14764832', + __typename: 'Candle', + }, + { open: '14764832', close: '14778059', __typename: 'Candle' }, + { + open: '14761936', + close: '14707831', + __typename: 'Candle', + }, + { open: '14707831', close: '14753272', __typename: 'Candle' }, + { + open: '14753272', + close: '14771411', + __typename: 'Candle', + }, + ].map((node) => ({ + __typename: 'CandleEdge', + node: node as unknown as Candle, + })), + }, + }, + }, + { + __typename: 'MarketEdge', + node: { + id: '9f2a3c1caa67bb0773ec18d908d32b55b129b9ec2d106a8e9a87f6aa5c0375a6', + __typename: 'Market', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { open: '71263667', close: '71173749', __typename: 'Candle' }, + { + open: '71173749', + close: '71055959', + __typename: 'Candle', + }, + { open: '71055959', close: '71078605', __typename: 'Candle' }, + { + open: '71078605', + close: '69838205', + __typename: 'Candle', + }, + { open: '69838205', close: '69166023', __typename: 'Candle' }, + { + open: '69166023', + close: '68841759', + __typename: 'Candle', + }, + { open: '68841759', close: '68711290', __typename: 'Candle' }, + { + open: '68711290', + close: '68650154', + __typename: 'Candle', + }, + { open: '68644289', close: '68638322', __typename: 'Candle' }, + { + open: '68704232', + close: '68343581', + __typename: 'Candle', + }, + { open: '67345721', close: '67554701', __typename: 'Candle' }, + { + open: '67533143', + close: '67551571', + __typename: 'Candle', + }, + { open: '67533286', close: '67543539', __typename: 'Candle' }, + { + open: '67580208', + close: '67472337', + __typename: 'Candle', + }, + { open: '67416289', close: '67459697', __typename: 'Candle' }, + { + open: '67396085', + close: '67528265', + __typename: 'Candle', + }, + { open: '67491799', close: '67538833', __typename: 'Candle' }, + { + open: '67493210', + close: '67362908', + __typename: 'Candle', + }, + { open: '67362908', close: '67518182', __typename: 'Candle' }, + { + open: '67518182', + close: '67635775', + __typename: 'Candle', + }, + { open: '67635775', close: '67734861', __typename: 'Candle' }, + { + open: '67714943', + close: '67736742', + __typename: 'Candle', + }, + { open: '67716074', close: '67690826', __typename: 'Candle' }, + { + open: '67714352', + close: '67817444', + __typename: 'Candle', + }, + ].map((node) => ({ + __typename: 'CandleEdge', + node: node as unknown as Candle, + })), + }, + }, + }, + { + __typename: 'MarketEdge', + node: { + id: '8a45ee934d3ddac4b036f9884df1064a5353c620a56f775ba36597d0edef9a7a', + __typename: 'Market', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { open: '5809', close: '5795', __typename: 'Candle' }, + { + open: '5795', + close: '5845', + __typename: 'Candle', + }, + { open: '5845', close: '5779', __typename: 'Candle' }, + { + open: '5779', + close: '5710', + __typename: 'Candle', + }, + { open: '5710', close: '5691', __typename: 'Candle' }, + ].map((node) => ({ + __typename: 'CandleEdge', + node: node as unknown as Candle, + })), + }, + }, + }, + ], }, }; }; @@ -1088,7 +1107,7 @@ export const generateLongListMarkets = (count: number) => { }; }; -export const generateMarkets = (override?): Markets => { +export const generateMarkets = (override?): MarketsQuery => { const markets = [protoMarket]; const defaultResult = { diff --git a/apps/console-lite/src/app/components/simple-market-list/simple-market-expires.tsx b/apps/console-lite/src/app/components/simple-market-list/simple-market-expires.tsx index b9a5d37cf..e9889f2ff 100644 --- a/apps/console-lite/src/app/components/simple-market-list/simple-market-expires.tsx +++ b/apps/console-lite/src/app/components/simple-market-list/simple-market-expires.tsx @@ -5,7 +5,7 @@ import { EXPIRE_DATE_FORMAT } from '../../constants'; const SimpleMarketExpires = ({ tags, }: { - tags: ReadonlyArray | null; + tags?: ReadonlyArray | null; }) => { if (tags) { const dateFound = tags.reduce((agg, tag) => { diff --git a/apps/console-lite/src/app/components/simple-market-list/simple-market-list.spec.tsx b/apps/console-lite/src/app/components/simple-market-list/simple-market-list.spec.tsx index dca9cbf7e..2eb512efa 100644 --- a/apps/console-lite/src/app/components/simple-market-list/simple-market-list.spec.tsx +++ b/apps/console-lite/src/app/components/simple-market-list/simple-market-list.spec.tsx @@ -58,21 +58,17 @@ let marketsMock = [ }, ] as unknown as Market[]; -const LIB = '@vegaprotocol/market-list'; -const useMarketList = () => { +const LIB = '@vegaprotocol/react-helpers'; +const useDataProvider = () => { return { - data: { - markets: marketsMock, - marketsData: [], - marketsCandles: [], - }, + data: marketsMock, loading: false, error: false, }; }; jest.mock(LIB, () => ({ ...jest.requireActual(LIB), - useMarketList: jest.fn(() => useMarketList()), + useDataProvider: jest.fn(() => useDataProvider()), })); const mockIsTradable = jest.fn((_arg) => true); diff --git a/apps/console-lite/src/app/components/simple-market-list/simple-market-list.tsx b/apps/console-lite/src/app/components/simple-market-list/simple-market-list.tsx index 9bff7520a..4fbd9cb6b 100644 --- a/apps/console-lite/src/app/components/simple-market-list/simple-market-list.tsx +++ b/apps/console-lite/src/app/components/simple-market-list/simple-market-list.tsx @@ -1,7 +1,10 @@ -import React, { useCallback, useEffect, useRef } from 'react'; +import { useCallback, useEffect, useRef, useMemo } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import type { AgGridReact } from 'ag-grid-react'; -import { useScreenDimensions } from '@vegaprotocol/react-helpers'; +import { + useScreenDimensions, + useDataProvider, +} from '@vegaprotocol/react-helpers'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import type { MarketState } from '@vegaprotocol/types'; import useMarketsFilterData from './use-markets-filter-data'; @@ -9,8 +12,9 @@ import useColumnDefinitions from './use-column-definitions'; import SimpleMarketToolbar from './simple-market-toolbar'; import { IS_MARKET_TRADABLE } from '../../constants'; import { ConsoleLiteGrid } from '../console-lite-grid'; -import type { Market, MarketsListData } from '@vegaprotocol/market-list'; -import { useMarketList } from '@vegaprotocol/market-list'; +import type { Market } from '@vegaprotocol/market-list'; +import { Interval } from '@vegaprotocol/types'; +import { marketsWithCandlesProvider } from '@vegaprotocol/market-list'; export type MarketWithPercentChange = Market & { percentChange?: number | '-'; @@ -29,8 +33,19 @@ const SimpleMarketList = () => { const statusesRef = useRef>({}); const gridRef = useRef(null); - const { data, error, loading } = useMarketList(); - const localData = useMarketsFilterData(data as MarketsListData, params); + const variables = useMemo(() => { + const yesterday = Math.round(new Date().getTime() / 1000) - 24 * 3600; + return { + since: new Date(yesterday * 1000).toISOString(), + interval: Interval.INTERVAL_I1H, + }; + }, []); + const { data, error, loading } = useDataProvider({ + dataProvider: marketsWithCandlesProvider, + variables, + noUpdate: true, + }); + const localData = useMarketsFilterData(data, params); const handleOnGridReady = useCallback(() => { gridRef.current?.api?.sizeColumnsToFit(); @@ -38,7 +53,7 @@ const SimpleMarketList = () => { useEffect(() => { const statuses: Record = {}; - data?.markets?.forEach((market) => { + data?.forEach((market) => { statuses[market.id] = market.state || ''; }); statusesRef.current = statuses; @@ -62,7 +77,7 @@ const SimpleMarketList = () => { return (
- + classNamesParam="mb-32 min-h-[300px]" diff --git a/apps/console-lite/src/app/components/simple-market-list/simple-market-toolbar.tsx b/apps/console-lite/src/app/components/simple-market-list/simple-market-toolbar.tsx index b9101fa50..6c51dfbd4 100644 --- a/apps/console-lite/src/app/components/simple-market-list/simple-market-toolbar.tsx +++ b/apps/console-lite/src/app/components/simple-market-list/simple-market-toolbar.tsx @@ -15,13 +15,13 @@ import { } from '@vegaprotocol/ui-toolkit'; import { MarketState } from '@vegaprotocol/types'; import useMarketFiltersData from '../../hooks/use-markets-filter'; -import type { Markets_marketsConnection_edges_node } from '@vegaprotocol/market-list'; +import type { Market } from '@vegaprotocol/market-list'; import { HorizontalMenu } from '../horizontal-menu'; import type { HorizontalMenuItem } from '../horizontal-menu'; import * as constants from './constants'; interface Props { - data: Markets_marketsConnection_edges_node[]; + data: Market[]; } const SimpleMarketToolbar = ({ data }: Props) => { diff --git a/apps/console-lite/src/app/components/simple-market-list/use-column-definitions.tsx b/apps/console-lite/src/app/components/simple-market-list/use-column-definitions.tsx index 8c2b190f6..4a5325333 100644 --- a/apps/console-lite/src/app/components/simple-market-list/use-column-definitions.tsx +++ b/apps/console-lite/src/app/components/simple-market-list/use-column-definitions.tsx @@ -7,7 +7,7 @@ import { Icon } from '@vegaprotocol/ui-toolkit'; import type { ValueSetterParams } from 'ag-grid-community'; import { IconNames } from '@blueprintjs/icons'; import { IS_MARKET_TRADABLE, MARKET_STATES_MAP } from '../../constants'; -import type { Candle, Market } from '@vegaprotocol/market-list'; +import type { MarketWithCandles as Market } from '@vegaprotocol/market-list'; interface Props { isMobile: boolean; @@ -69,15 +69,16 @@ const useColumnDefinitions = ({ isMobile }: Props) => { data, setValue, }: { - data: { id: string; candles: Candle[] }; + data: Market; setValue: (arg: unknown) => void; - }) => ( - - ), + }) => + data.candles && ( + + ), comparator: (valueA: number | '-', valueB: number | '-') => { if (valueA === valueB) return 0; if (valueA === '-') { diff --git a/apps/console-lite/src/app/components/simple-market-list/use-markets-filter-data.ts b/apps/console-lite/src/app/components/simple-market-list/use-markets-filter-data.ts index c4c29b56e..146f20908 100644 --- a/apps/console-lite/src/app/components/simple-market-list/use-markets-filter-data.ts +++ b/apps/console-lite/src/app/components/simple-market-list/use-markets-filter-data.ts @@ -1,12 +1,15 @@ import { useMemo } from 'react'; import { MarketState } from '@vegaprotocol/types'; -import type { MarketsListData } from '@vegaprotocol/market-list'; +import type { MarketWithCandles } from '@vegaprotocol/market-list'; import type { RouterParams } from './simple-market-list'; -const useMarketsFilterData = (data: MarketsListData, params: RouterParams) => { +const useMarketsFilterData = ( + data: MarketWithCandles[] | null, + params: RouterParams +) => { return useMemo(() => { - const markets = - data?.markets?.filter((item) => { + return ( + data?.filter((item) => { if ( params.product && params.product !== @@ -32,21 +35,9 @@ const useMarketsFilterData = (data: MarketsListData, params: RouterParams) => { return false; } return true; - }) || []; - - return markets.map((market) => ({ - ...market, - candles: (data?.marketsCandles || []) - .filter((c) => c.marketId === market.id) - .map((c) => c.candles), - })); - }, [ - data?.marketsCandles, - data?.markets, - params.product, - params.asset, - params.state, - ]); + }) || [] + ); + }, [data, params.product, params.asset, params.state]); }; export default useMarketsFilterData; diff --git a/apps/console-lite/src/app/hooks/use-markets-filter.ts b/apps/console-lite/src/app/hooks/use-markets-filter.ts index 1bba0a7dc..2ffb1ce17 100644 --- a/apps/console-lite/src/app/hooks/use-markets-filter.ts +++ b/apps/console-lite/src/app/hooks/use-markets-filter.ts @@ -14,6 +14,9 @@ const useMarketFilters = (data: Market[]) => { const product = item.tradableInstrument.instrument.product.__typename; const asset = item.tradableInstrument.instrument.product.settlementAsset.symbol; + if (!product) { + return; + } if (!(product in localAssetPerProduct)) { localAssetPerProduct[product] = new Set(); } diff --git a/apps/liquidity-provision-dashboard/project.json b/apps/liquidity-provision-dashboard/project.json index 85fe32878..44bd96f18 100644 --- a/apps/liquidity-provision-dashboard/project.json +++ b/apps/liquidity-provision-dashboard/project.json @@ -50,7 +50,8 @@ "executor": "./tools/executors/webpack:serve", "options": { "buildTarget": "liquidity-provision-dashboard:build", - "hmr": true + "hmr": true, + "port": 4201 }, "configurations": { "development": { diff --git a/apps/trading-e2e/src/integration/home.cy.ts b/apps/trading-e2e/src/integration/home.cy.ts index 6fe1edfd4..13fa69664 100644 --- a/apps/trading-e2e/src/integration/home.cy.ts +++ b/apps/trading-e2e/src/integration/home.cy.ts @@ -63,13 +63,11 @@ describe('home', { tags: '@regression' }, () => { }, }; aliasQuery(req, 'Markets', data); - aliasQuery(req, 'MarketsDataQuery', data); - aliasQuery(req, 'MarketsCandlesQuery', data); + aliasQuery(req, 'MarketsData', data); }); cy.visit('/'); cy.wait('@Markets'); - cy.wait('@MarketsDataQuery'); - cy.wait('@MarketsCandlesQuery'); + cy.wait('@MarketsData'); cy.url().should('eq', Cypress.config().baseUrl + '/markets'); }); }); diff --git a/apps/trading-e2e/src/integration/markets.cy.ts b/apps/trading-e2e/src/integration/markets.cy.ts index 7603bd2bc..b9b2f1c0d 100644 --- a/apps/trading-e2e/src/integration/markets.cy.ts +++ b/apps/trading-e2e/src/integration/markets.cy.ts @@ -13,8 +13,8 @@ describe('markets table', { tags: '@regression' }, () => { cy.visit('/'); cy.wait('@Market'); cy.wait('@Markets'); - cy.wait('@MarketsDataQuery'); - cy.wait('@MarketsCandlesQuery'); + cy.wait('@MarketsData'); + cy.wait('@MarketsCandles'); cy.get('[data-testid^="market-link-"]').should('not.be.empty'); cy.getByTestId('price').invoke('text').should('not.be.empty'); cy.getByTestId('settlement-asset').should('not.be.empty'); @@ -26,8 +26,8 @@ describe('markets table', { tags: '@regression' }, () => { it('renders market list drop down', () => { cy.visit('/'); cy.wait('@Markets'); - cy.wait('@MarketsDataQuery'); - cy.wait('@MarketsCandlesQuery'); + cy.wait('@MarketsData'); + cy.wait('@MarketsCandles'); openMarketDropDown(); cy.getByTestId('price').invoke('text').should('not.be.empty'); cy.getByTestId('trading-mode').should('not.be.empty'); @@ -39,8 +39,8 @@ describe('markets table', { tags: '@regression' }, () => { it('Able to select market from dropdown', () => { cy.visit('/'); cy.wait('@Markets'); - cy.wait('@MarketsDataQuery'); - cy.wait('@MarketsCandlesQuery'); + cy.wait('@MarketsData'); + cy.wait('@MarketsCandles'); openMarketDropDown(); cy.getByTestId('market-link-market-0').should('be.visible').click(); @@ -59,8 +59,8 @@ describe('markets table', { tags: '@regression' }, () => { ]; cy.visit('/'); cy.wait('@Markets'); - cy.wait('@MarketsDataQuery'); - cy.wait('@MarketsCandlesQuery'); + cy.wait('@MarketsData'); + cy.wait('@MarketsCandles'); cy.getByTestId('link').should('have.attr', 'href', '/markets').click(); cy.url().should('eq', Cypress.config('baseUrl') + '/markets'); cy.contains('AAPL.MF21').should('be.visible'); diff --git a/apps/trading-e2e/src/support/mocks/generate-markets.ts b/apps/trading-e2e/src/support/mocks/generate-markets.ts index 8486c31dc..628809415 100644 --- a/apps/trading-e2e/src/support/mocks/generate-markets.ts +++ b/apps/trading-e2e/src/support/mocks/generate-markets.ts @@ -6,16 +6,17 @@ import { } from '@vegaprotocol/types'; import type { PartialDeep } from 'type-fest'; import type { - Markets, - Markets_marketsConnection_edges_node, + MarketsQuery, + Market, MarketsCandlesQuery, - MarketsCandlesQuery_marketsConnection_edges_node, MarketsDataQuery, - MarketsDataQuery_marketsConnection_edges_node, + MarketData, } from '@vegaprotocol/market-list'; -export const generateMarkets = (override?: PartialDeep): Markets => { - const markets: Markets_marketsConnection_edges_node[] = [ +export const generateMarkets = ( + override?: PartialDeep +): MarketsQuery => { + const markets: Market[] = [ { id: 'market-0', decimalPlaces: 5, @@ -194,7 +195,7 @@ export const generateMarkets = (override?: PartialDeep): Markets => { }, ]; - const defaultResult: Markets = { + const defaultResult: MarketsQuery = { marketsConnection: { __typename: 'MarketConnection', edges: markets.map((node) => ({ @@ -210,95 +211,86 @@ export const generateMarkets = (override?: PartialDeep): Markets => { export const generateMarketsData = ( override?: PartialDeep ): MarketsDataQuery => { - const markets: MarketsDataQuery_marketsConnection_edges_node[] = [ + const markets: MarketData[] = [ { - data: { - market: { - id: 'market-0', - __typename: 'Market', - }, - marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, - staticMidPrice: '0', - indicativePrice: '0', - bestStaticBidPrice: '0', - bestStaticOfferPrice: '0', - indicativeVolume: '0', - bestBidPrice: '0', - bestOfferPrice: '0', - markPrice: '4612690058', - trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, - __typename: 'MarketData', + market: { + id: 'market-0', + __typename: 'Market', }, - __typename: 'Market', + marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, + staticMidPrice: '0', + indicativePrice: '0', + bestStaticBidPrice: '0', + bestStaticOfferPrice: '0', + indicativeVolume: '0', + bestBidPrice: '0', + bestOfferPrice: '0', + markPrice: '4612690058', + trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, + __typename: 'MarketData', }, { - data: { - market: { - id: 'market-1', - __typename: 'Market', - }, - marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, - staticMidPrice: '0', - indicativePrice: '0', - bestStaticBidPrice: '0', - bestStaticOfferPrice: '0', - indicativeVolume: '0', - bestBidPrice: '0', - bestOfferPrice: '0', - markPrice: '8441', - trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, - __typename: 'MarketData', + market: { + id: 'market-1', + __typename: 'Market', }, - __typename: 'Market', + marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, + staticMidPrice: '0', + indicativePrice: '0', + bestStaticBidPrice: '0', + bestStaticOfferPrice: '0', + indicativeVolume: '0', + bestBidPrice: '0', + bestOfferPrice: '0', + markPrice: '8441', + trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, + __typename: 'MarketData', }, { - data: { - market: { - id: 'market-2', - __typename: 'Market', - }, - marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, - staticMidPrice: '0', - indicativePrice: '0', - bestStaticBidPrice: '0', - bestStaticOfferPrice: '0', - indicativeVolume: '0', - bestBidPrice: '0', - bestOfferPrice: '0', - markPrice: '4612690058', - trigger: AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY, - __typename: 'MarketData', + market: { + id: 'market-2', + __typename: 'Market', }, - __typename: 'Market', + marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, + staticMidPrice: '0', + indicativePrice: '0', + bestStaticBidPrice: '0', + bestStaticOfferPrice: '0', + indicativeVolume: '0', + bestBidPrice: '0', + bestOfferPrice: '0', + markPrice: '4612690058', + trigger: AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY, + __typename: 'MarketData', }, { - data: { - market: { - id: 'market-3', - __typename: 'Market', - }, - marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, - staticMidPrice: '0', - indicativePrice: '0', - bestStaticBidPrice: '0', - bestStaticOfferPrice: '0', - indicativeVolume: '0', - bestBidPrice: '0', - bestOfferPrice: '0', - markPrice: '4612690058', - trigger: AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY, - __typename: 'MarketData', + market: { + id: 'market-3', + __typename: 'Market', }, - __typename: 'Market', + marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, + staticMidPrice: '0', + indicativePrice: '0', + bestStaticBidPrice: '0', + bestStaticOfferPrice: '0', + indicativeVolume: '0', + bestBidPrice: '0', + bestOfferPrice: '0', + markPrice: '4612690058', + trigger: AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY, + __typename: 'MarketData', }, ]; const defaultResult: MarketsDataQuery = { marketsConnection: { __typename: 'MarketConnection', - edges: markets.map((node) => ({ + edges: markets.map((data) => ({ __typename: 'MarketEdge', - node, + node: { + __typename: 'Market', + data, + }, })), }, }; @@ -307,97 +299,105 @@ export const generateMarketsData = ( }; export const generateMarketsCandles = ( - override?: PartialDeep + override?: PartialDeep ): MarketsCandlesQuery => { - const markets: MarketsCandlesQuery_marketsConnection_edges_node[] = [ - { - __typename: 'Market', - id: 'market-0', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { - __typename: 'CandleEdge', - node: { - __typename: 'Candle', - open: '100', - close: '100', - high: '110', - low: '90', - volume: '1', - }, - }, - ], - }, - }, - { - __typename: 'Market', - id: 'market-1', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { - __typename: 'CandleEdge', - node: { - __typename: 'Candle', - open: '100', - close: '100', - high: '110', - low: '90', - volume: '1', - }, - }, - ], - }, - }, - { - __typename: 'Market', - id: 'market-2', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { - __typename: 'CandleEdge', - node: { - __typename: 'Candle', - open: '100', - close: '100', - high: '110', - low: '90', - volume: '1', - }, - }, - ], - }, - }, - { - __typename: 'Market', - id: 'market-3', - candlesConnection: { - __typename: 'CandleDataConnection', - edges: [ - { - __typename: 'CandleEdge', - node: { - __typename: 'Candle', - open: '100', - close: '100', - high: '110', - low: '90', - volume: '1', - }, - }, - ], - }, - }, - ]; const defaultResult: MarketsCandlesQuery = { marketsConnection: { __typename: 'MarketConnection', - edges: markets.map((node) => ({ - __typename: 'MarketEdge', - node, - })), + edges: [ + { + __typename: 'MarketEdge', + node: { + __typename: 'Market', + id: 'market-0', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { + __typename: 'CandleEdge', + node: { + __typename: 'Candle', + open: '100', + close: '100', + high: '110', + low: '90', + volume: '1', + }, + }, + ], + }, + }, + }, + { + __typename: 'MarketEdge', + node: { + __typename: 'Market', + id: 'market-1', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { + __typename: 'CandleEdge', + node: { + __typename: 'Candle', + open: '100', + close: '100', + high: '110', + low: '90', + volume: '1', + }, + }, + ], + }, + }, + }, + { + __typename: 'MarketEdge', + node: { + __typename: 'Market', + id: 'market-2', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { + __typename: 'CandleEdge', + node: { + __typename: 'Candle', + open: '100', + close: '100', + high: '110', + low: '90', + volume: '1', + }, + }, + ], + }, + }, + }, + { + __typename: 'MarketEdge', + node: { + __typename: 'Market', + id: 'market-3', + candlesConnection: { + __typename: 'CandleDataConnection', + edges: [ + { + __typename: 'CandleEdge', + node: { + __typename: 'Candle', + open: '100', + close: '100', + high: '110', + low: '90', + volume: '1', + }, + }, + ], + }, + }, + }, + ], }, }; diff --git a/apps/trading-e2e/src/support/trading.ts b/apps/trading-e2e/src/support/trading.ts index 47faf4e2b..d6b95b063 100644 --- a/apps/trading-e2e/src/support/trading.ts +++ b/apps/trading-e2e/src/support/trading.ts @@ -36,8 +36,8 @@ export const mockTradingPage = ( }) ); aliasQuery(req, 'Markets', generateMarkets()); - aliasQuery(req, 'MarketsDataQuery', generateMarketsData()); - aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles()); + aliasQuery(req, 'MarketsData', generateMarketsData()); + aliasQuery(req, 'MarketsCandles', generateMarketsCandles()); aliasQuery(req, 'MarketDepth', generateMarketDepth()); aliasQuery(req, 'Orders', generateOrders()); diff --git a/apps/trading/pages/index.page.tsx b/apps/trading/pages/index.page.tsx index eb71788dc..754c1c4ac 100644 --- a/apps/trading/pages/index.page.tsx +++ b/apps/trading/pages/index.page.tsx @@ -1,5 +1,9 @@ -import { useMarketList } from '@vegaprotocol/market-list'; -import { addDecimalsFormatNumber, titlefy } from '@vegaprotocol/react-helpers'; +import { marketsWithDataProvider } from '@vegaprotocol/market-list'; +import { + addDecimalsFormatNumber, + titlefy, + useDataProvider, +} from '@vegaprotocol/react-helpers'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { useRouter } from 'next/router'; import { useEffect } from 'react'; @@ -8,8 +12,10 @@ import { useGlobalStore } from '../stores'; export function Index() { const { replace } = useRouter(); // The default market selected in the platform behind the overlay - // should be the oldest market that is currently trading in continuous mode(i.e. not in auction). - const { data, error, loading } = useMarketList(); + // should be the oldest market that is currently trading in us mode(i.e. not in auction). + const { data, error, loading } = useDataProvider({ + dataProvider: marketsWithDataProvider, + }); const { riskNoticeDialog, update } = useGlobalStore((store) => ({ riskNoticeDialog: store.riskNoticeDialog, update: store.update, @@ -19,12 +25,12 @@ export function Index() { update({ landingDialog: true }); if (data) { - const marketId = data.markets[0]?.id; - const marketName = data.markets[0]?.tradableInstrument.instrument.name; - const marketPrice = data.marketsData[0]?.markPrice + const marketId = data[0]?.id; + const marketName = data[0]?.tradableInstrument.instrument.name; + const marketPrice = data[0]?.data?.markPrice ? addDecimalsFormatNumber( - data.marketsData[0]?.markPrice, - data.markets[0].decimalPlaces + data[0]?.data?.markPrice, + data[0]?.decimalPlaces ) : null; const pageTitle = titlefy([marketName, marketPrice]); diff --git a/libs/assets/src/lib/__generated___/Asset.ts b/libs/assets/src/lib/__generated___/Asset.ts new file mode 100644 index 000000000..af5f4739a --- /dev/null +++ b/libs/assets/src/lib/__generated___/Asset.ts @@ -0,0 +1,59 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type AssetQueryVariables = Types.Exact<{ + assetId: Types.Scalars['ID']; +}>; + + +export type AssetQuery = { __typename?: 'Query', asset?: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string } } | null }; + + +export const AssetDocument = gql` + query Asset($assetId: ID!) { + asset(id: $assetId) { + id + name + symbol + decimals + quantum + source { + ... on ERC20 { + contractAddress + lifetimeLimit + withdrawThreshold + } + } + } +} + `; + +/** + * __useAssetQuery__ + * + * To run a query within a React component, call `useAssetQuery` and pass it any options that fit your needs. + * When your component renders, `useAssetQuery` 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 } = useAssetQuery({ + * variables: { + * assetId: // value for 'assetId' + * }, + * }); + */ +export function useAssetQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(AssetDocument, options); + } +export function useAssetLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(AssetDocument, options); + } +export type AssetQueryHookResult = ReturnType; +export type AssetLazyQueryHookResult = ReturnType; +export type AssetQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/assets/src/lib/__generated___/Assets.ts b/libs/assets/src/lib/__generated___/Assets.ts new file mode 100644 index 000000000..a4d53232e --- /dev/null +++ b/libs/assets/src/lib/__generated___/Assets.ts @@ -0,0 +1,60 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type AssetsConnectionQueryVariables = Types.Exact<{ [key: string]: never; }>; + + +export type AssetsConnectionQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string } } } | null> | null } | null }; + + +export const AssetsConnectionDocument = gql` + query AssetsConnection { + assetsConnection { + edges { + node { + id + name + symbol + decimals + quantum + source { + ... on ERC20 { + contractAddress + lifetimeLimit + withdrawThreshold + } + } + } + } + } +} + `; + +/** + * __useAssetsConnectionQuery__ + * + * To run a query within a React component, call `useAssetsConnectionQuery` and pass it any options that fit your needs. + * When your component renders, `useAssetsConnectionQuery` 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 } = useAssetsConnectionQuery({ + * variables: { + * }, + * }); + */ +export function useAssetsConnectionQuery(baseOptions?: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(AssetsConnectionDocument, options); + } +export function useAssetsConnectionLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(AssetsConnectionDocument, options); + } +export type AssetsConnectionQueryHookResult = ReturnType; +export type AssetsConnectionLazyQueryHookResult = ReturnType; +export type AssetsConnectionQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/candles-chart/src/lib/__generated___/Candles.ts b/libs/candles-chart/src/lib/__generated___/Candles.ts new file mode 100644 index 000000000..7ad5117ac --- /dev/null +++ b/libs/candles-chart/src/lib/__generated___/Candles.ts @@ -0,0 +1,118 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type CandleFieldsFragment = { __typename?: 'Candle', periodStart: string, lastUpdateInPeriod: string, high: string, low: string, open: string, close: string, volume: string }; + +export type CandlesQueryVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; + interval: Types.Interval; + since: Types.Scalars['String']; +}>; + + +export type CandlesQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string } }, candlesConnection?: { __typename?: 'CandleDataConnection', edges?: Array<{ __typename?: 'CandleEdge', node: { __typename?: 'Candle', periodStart: string, lastUpdateInPeriod: string, high: string, low: string, open: string, close: string, volume: string } } | null> | null } | null } | null }; + +export type CandlesEventsSubscriptionVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; + interval: Types.Interval; +}>; + + +export type CandlesEventsSubscription = { __typename?: 'Subscription', candles: { __typename?: 'Candle', periodStart: string, lastUpdateInPeriod: string, high: string, low: string, open: string, close: string, volume: string } }; + +export const CandleFieldsFragmentDoc = gql` + fragment CandleFields on Candle { + periodStart + lastUpdateInPeriod + high + low + open + close + volume +} + `; +export const CandlesDocument = gql` + query Candles($marketId: ID!, $interval: Interval!, $since: String!) { + market(id: $marketId) { + id + decimalPlaces + tradableInstrument { + instrument { + id + name + code + } + } + candlesConnection(interval: $interval, since: $since) { + edges { + node { + ...CandleFields + } + } + } + } +} + ${CandleFieldsFragmentDoc}`; + +/** + * __useCandlesQuery__ + * + * To run a query within a React component, call `useCandlesQuery` and pass it any options that fit your needs. + * When your component renders, `useCandlesQuery` 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 } = useCandlesQuery({ + * variables: { + * marketId: // value for 'marketId' + * interval: // value for 'interval' + * since: // value for 'since' + * }, + * }); + */ +export function useCandlesQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(CandlesDocument, options); + } +export function useCandlesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(CandlesDocument, options); + } +export type CandlesQueryHookResult = ReturnType; +export type CandlesLazyQueryHookResult = ReturnType; +export type CandlesQueryResult = Apollo.QueryResult; +export const CandlesEventsDocument = gql` + subscription CandlesEvents($marketId: ID!, $interval: Interval!) { + candles(marketId: $marketId, interval: $interval) { + ...CandleFields + } +} + ${CandleFieldsFragmentDoc}`; + +/** + * __useCandlesEventsSubscription__ + * + * To run a query within a React component, call `useCandlesEventsSubscription` and pass it any options that fit your needs. + * When your component renders, `useCandlesEventsSubscription` 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 subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useCandlesEventsSubscription({ + * variables: { + * marketId: // value for 'marketId' + * interval: // value for 'interval' + * }, + * }); + */ +export function useCandlesEventsSubscription(baseOptions: Apollo.SubscriptionHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSubscription(CandlesEventsDocument, options); + } +export type CandlesEventsSubscriptionHookResult = ReturnType; +export type CandlesEventsSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/candles-chart/src/lib/__generated___/Chart.ts b/libs/candles-chart/src/lib/__generated___/Chart.ts new file mode 100644 index 000000000..fec36dd6f --- /dev/null +++ b/libs/candles-chart/src/lib/__generated___/Chart.ts @@ -0,0 +1,55 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type ChartQueryVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; +}>; + + +export type ChartQuery = { __typename?: 'Query', market?: { __typename?: 'Market', decimalPlaces: number, data?: { __typename?: 'MarketData', priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string }> | null } | null } | null }; + + +export const ChartDocument = gql` + query Chart($marketId: ID!) { + market(id: $marketId) { + decimalPlaces + data { + priceMonitoringBounds { + minValidPrice + maxValidPrice + referencePrice + } + } + } +} + `; + +/** + * __useChartQuery__ + * + * To run a query within a React component, call `useChartQuery` and pass it any options that fit your needs. + * When your component renders, `useChartQuery` 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 } = useChartQuery({ + * variables: { + * marketId: // value for 'marketId' + * }, + * }); + */ +export function useChartQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(ChartDocument, options); + } +export function useChartLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(ChartDocument, options); + } +export type ChartQueryHookResult = ReturnType; +export type ChartLazyQueryHookResult = ReturnType; +export type ChartQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/deal-ticket/src/components/deal-ticket/__generated___/DealTicket.ts b/libs/deal-ticket/src/components/deal-ticket/__generated___/DealTicket.ts new file mode 100644 index 000000000..0f67de30d --- /dev/null +++ b/libs/deal-ticket/src/components/deal-ticket/__generated___/DealTicket.ts @@ -0,0 +1,79 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type DealTicketMarketFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string } } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } }; + +export type DealTicketQueryVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; +}>; + + +export type DealTicketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string } } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null }; + +export const DealTicketMarketFragmentDoc = gql` + fragment DealTicketMarket on Market { + id + decimalPlaces + positionDecimalPlaces + state + tradingMode + tradableInstrument { + instrument { + id + name + product { + ... on Future { + quoteName + settlementAsset { + id + symbol + name + } + } + } + } + } + depth { + lastTrade { + price + } + } +} + `; +export const DealTicketDocument = gql` + query DealTicket($marketId: ID!) { + market(id: $marketId) { + ...DealTicketMarket + } +} + ${DealTicketMarketFragmentDoc}`; + +/** + * __useDealTicketQuery__ + * + * To run a query within a React component, call `useDealTicketQuery` and pass it any options that fit your needs. + * When your component renders, `useDealTicketQuery` 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 } = useDealTicketQuery({ + * variables: { + * marketId: // value for 'marketId' + * }, + * }); + */ +export function useDealTicketQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(DealTicketDocument, options); + } +export function useDealTicketLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(DealTicketDocument, options); + } +export type DealTicketQueryHookResult = ReturnType; +export type DealTicketLazyQueryHookResult = ReturnType; +export type DealTicketQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/deposits/src/lib/__generated___/Deposit.ts b/libs/deposits/src/lib/__generated___/Deposit.ts new file mode 100644 index 000000000..2d06ea49a --- /dev/null +++ b/libs/deposits/src/lib/__generated___/Deposit.ts @@ -0,0 +1,112 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type DepositFieldsFragment = { __typename?: 'Deposit', id: string, status: Types.DepositStatus, amount: string, createdTimestamp: string, creditedTimestamp?: string | null, txHash?: string | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } }; + +export type DepositsQueryVariables = Types.Exact<{ + partyId: Types.Scalars['ID']; +}>; + + +export type DepositsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, depositsConnection?: { __typename?: 'DepositsConnection', edges?: Array<{ __typename?: 'DepositEdge', node: { __typename?: 'Deposit', id: string, status: Types.DepositStatus, amount: string, createdTimestamp: string, creditedTimestamp?: string | null, txHash?: string | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } | null> | null } | null } | null }; + +export type DepositEventSubscriptionVariables = Types.Exact<{ + partyId: Types.Scalars['ID']; +}>; + + +export type DepositEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', event: { __typename?: 'Account' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit', id: string, status: Types.DepositStatus, amount: string, createdTimestamp: string, creditedTimestamp?: string | null, txHash?: string | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null }; + +export const DepositFieldsFragmentDoc = gql` + fragment DepositFields on Deposit { + id + status + amount + asset { + id + symbol + decimals + } + createdTimestamp + creditedTimestamp + txHash +} + `; +export const DepositsDocument = gql` + query Deposits($partyId: ID!) { + party(id: $partyId) { + id + depositsConnection { + edges { + node { + ...DepositFields + } + } + } + } +} + ${DepositFieldsFragmentDoc}`; + +/** + * __useDepositsQuery__ + * + * To run a query within a React component, call `useDepositsQuery` and pass it any options that fit your needs. + * When your component renders, `useDepositsQuery` 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 } = useDepositsQuery({ + * variables: { + * partyId: // value for 'partyId' + * }, + * }); + */ +export function useDepositsQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(DepositsDocument, options); + } +export function useDepositsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(DepositsDocument, options); + } +export type DepositsQueryHookResult = ReturnType; +export type DepositsLazyQueryHookResult = ReturnType; +export type DepositsQueryResult = Apollo.QueryResult; +export const DepositEventDocument = gql` + subscription DepositEvent($partyId: ID!) { + busEvents(partyId: $partyId, batchSize: 0, types: [Deposit]) { + event { + ... on Deposit { + ...DepositFields + } + } + } +} + ${DepositFieldsFragmentDoc}`; + +/** + * __useDepositEventSubscription__ + * + * To run a query within a React component, call `useDepositEventSubscription` and pass it any options that fit your needs. + * When your component renders, `useDepositEventSubscription` 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 subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useDepositEventSubscription({ + * variables: { + * partyId: // value for 'partyId' + * }, + * }); + */ +export function useDepositEventSubscription(baseOptions: Apollo.SubscriptionHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSubscription(DepositEventDocument, options); + } +export type DepositEventSubscriptionHookResult = ReturnType; +export type DepositEventSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/environment/src/utils/__generated___/Node.ts b/libs/environment/src/utils/__generated___/Node.ts new file mode 100644 index 000000000..1961baca9 --- /dev/null +++ b/libs/environment/src/utils/__generated___/Node.ts @@ -0,0 +1,80 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type StatisticsQueryVariables = Types.Exact<{ [key: string]: never; }>; + + +export type StatisticsQuery = { __typename?: 'Query', statistics: { __typename?: 'Statistics', chainId: string, blockHeight: string } }; + +export type BlockTimeSubscriptionVariables = Types.Exact<{ [key: string]: never; }>; + + +export type BlockTimeSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', id: string }> | null }; + + +export const StatisticsDocument = gql` + query Statistics { + statistics { + chainId + blockHeight + } +} + `; + +/** + * __useStatisticsQuery__ + * + * To run a query within a React component, call `useStatisticsQuery` and pass it any options that fit your needs. + * When your component renders, `useStatisticsQuery` 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 } = useStatisticsQuery({ + * variables: { + * }, + * }); + */ +export function useStatisticsQuery(baseOptions?: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(StatisticsDocument, options); + } +export function useStatisticsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(StatisticsDocument, options); + } +export type StatisticsQueryHookResult = ReturnType; +export type StatisticsLazyQueryHookResult = ReturnType; +export type StatisticsQueryResult = Apollo.QueryResult; +export const BlockTimeDocument = gql` + subscription BlockTime { + busEvents(types: TimeUpdate, batchSize: 1) { + id + } +} + `; + +/** + * __useBlockTimeSubscription__ + * + * To run a query within a React component, call `useBlockTimeSubscription` and pass it any options that fit your needs. + * When your component renders, `useBlockTimeSubscription` 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 subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useBlockTimeSubscription({ + * variables: { + * }, + * }); + */ +export function useBlockTimeSubscription(baseOptions?: Apollo.SubscriptionHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSubscription(BlockTimeDocument, options); + } +export type BlockTimeSubscriptionHookResult = ReturnType; +export type BlockTimeSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/fills/src/lib/__generated___/Fills.ts b/libs/fills/src/lib/__generated___/Fills.ts new file mode 100644 index 000000000..de686417a --- /dev/null +++ b/libs/fills/src/lib/__generated___/Fills.ts @@ -0,0 +1,161 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type FillFieldsFragment = { __typename?: 'Trade', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, market: { __typename?: 'Market', id: string }, buyer: { __typename?: 'Party', id: string }, seller: { __typename?: 'Party', id: string }, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string } }; + +export type FillEdgeFragment = { __typename?: 'TradeEdge', cursor: string, node: { __typename?: 'Trade', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, market: { __typename?: 'Market', id: string }, buyer: { __typename?: 'Party', id: string }, seller: { __typename?: 'Party', id: string }, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string } } }; + +export type FillsQueryVariables = Types.Exact<{ + partyId: Types.Scalars['ID']; + marketId?: Types.InputMaybe; + pagination?: Types.InputMaybe; +}>; + + +export type FillsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, tradesConnection?: { __typename?: 'TradeConnection', edges: Array<{ __typename?: 'TradeEdge', cursor: string, node: { __typename?: 'Trade', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, market: { __typename?: 'Market', id: string }, buyer: { __typename?: 'Party', id: string }, seller: { __typename?: 'Party', id: string }, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string } } }>, pageInfo: { __typename?: 'PageInfo', startCursor: string, endCursor: string, hasNextPage: boolean, hasPreviousPage: boolean } } | null } | null }; + +export type FillsEventSubscriptionVariables = Types.Exact<{ + partyId: Types.Scalars['ID']; +}>; + + +export type FillsEventSubscription = { __typename?: 'Subscription', trades?: Array<{ __typename?: 'TradeUpdate', id: string, marketId: string, buyOrder: string, sellOrder: string, buyerId: string, sellerId: string, aggressor: Types.Side, price: string, size: string, createdAt: string, type: Types.TradeType, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string } }> | null }; + +export const FillFieldsFragmentDoc = gql` + fragment FillFields on Trade { + id + market { + id + } + createdAt + price + size + buyOrder + sellOrder + aggressor + buyer { + id + } + seller { + id + } + buyerFee { + makerFee + infrastructureFee + liquidityFee + } + sellerFee { + makerFee + infrastructureFee + liquidityFee + } +} + `; +export const FillEdgeFragmentDoc = gql` + fragment FillEdge on TradeEdge { + node { + ...FillFields + } + cursor +} + ${FillFieldsFragmentDoc}`; +export const FillsDocument = gql` + query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) { + party(id: $partyId) { + id + tradesConnection(marketId: $marketId, pagination: $pagination) { + edges { + ...FillEdge + } + pageInfo { + startCursor + endCursor + hasNextPage + hasPreviousPage + } + } + } +} + ${FillEdgeFragmentDoc}`; + +/** + * __useFillsQuery__ + * + * To run a query within a React component, call `useFillsQuery` and pass it any options that fit your needs. + * When your component renders, `useFillsQuery` 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 } = useFillsQuery({ + * variables: { + * partyId: // value for 'partyId' + * marketId: // value for 'marketId' + * pagination: // value for 'pagination' + * }, + * }); + */ +export function useFillsQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(FillsDocument, options); + } +export function useFillsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(FillsDocument, options); + } +export type FillsQueryHookResult = ReturnType; +export type FillsLazyQueryHookResult = ReturnType; +export type FillsQueryResult = Apollo.QueryResult; +export const FillsEventDocument = gql` + subscription FillsEvent($partyId: ID!) { + trades(partyId: $partyId) { + id + marketId + buyOrder + sellOrder + buyerId + sellerId + aggressor + price + size + createdAt + type + buyerFee { + makerFee + infrastructureFee + liquidityFee + } + sellerFee { + makerFee + infrastructureFee + liquidityFee + } + } +} + `; + +/** + * __useFillsEventSubscription__ + * + * To run a query within a React component, call `useFillsEventSubscription` and pass it any options that fit your needs. + * When your component renders, `useFillsEventSubscription` 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 subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useFillsEventSubscription({ + * variables: { + * partyId: // value for 'partyId' + * }, + * }); + */ +export function useFillsEventSubscription(baseOptions: Apollo.SubscriptionHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSubscription(FillsEventDocument, options); + } +export type FillsEventSubscriptionHookResult = ReturnType; +export type FillsEventSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/market-depth/src/lib/market-depth-provider.ts b/libs/market-depth/src/lib/market-depth-provider.ts index 2a5c1dcee..ae6c04710 100644 --- a/libs/market-depth/src/lib/market-depth-provider.ts +++ b/libs/market-depth/src/lib/market-depth-provider.ts @@ -60,19 +60,30 @@ const update: Update< > = (data, deltas, reload) => { for (const delta of deltas) { if (delta.marketId !== data.id) { + //console.log('wrong-market'); continue; } const sequenceNumber = Number(delta.sequenceNumber); + console.log(delta.previousSequenceNumber, delta.sequenceNumber); if (sequenceNumber <= sequenceNumbers[delta.marketId]) { + /* + console.log( + 'smaller sequence number', + sequenceNumber, + sequenceNumbers[delta.marketId] + ); + */ return data; } /* - if (sequenceNumber - 1 !== sequenceNumbers[delta.market.id]) { - sequenceNumbers[delta.market.id] = 0; - reload(); - return; - } - */ + if (sequenceNumber - 1 !== sequenceNumbers[delta.market.id]) { + sequenceNumbers[delta.market.id] = 0; + reload(); + return; + } + */ + // const { buy, sell } = delta; + // console.log({ buy, sell }); sequenceNumbers[delta.marketId] = sequenceNumber; const updatedData = { ...data, @@ -84,6 +95,7 @@ const update: Update< if (delta.sell) { updatedData.depth.sell = updateLevels(data.depth.sell ?? [], delta.sell); } + // console.log({ updatedData }); return updatedData; } return data; diff --git a/libs/market-list/src/lib/__generated__/MarketCandlesQuery.ts b/libs/market-list/src/lib/__generated__/MarketCandlesQuery.ts deleted file mode 100644 index 3d47f26c2..000000000 --- a/libs/market-list/src/lib/__generated__/MarketCandlesQuery.ts +++ /dev/null @@ -1,87 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { Interval } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL query operation: MarketCandlesQuery -// ==================================================== - -export interface MarketCandlesQuery_marketsConnection_edges_node_candlesConnection_edges_node { - __typename: "Candle"; - /** - * High price (uint64) - */ - high: string; - /** - * Low price (uint64) - */ - low: string; - /** - * Open price (uint64) - */ - open: string; - /** - * Close price (uint64) - */ - close: string; - /** - * Volume price (uint64) - */ - volume: string; -} - -export interface MarketCandlesQuery_marketsConnection_edges_node_candlesConnection_edges { - __typename: "CandleEdge"; - /** - * The candle - */ - node: MarketCandlesQuery_marketsConnection_edges_node_candlesConnection_edges_node; -} - -export interface MarketCandlesQuery_marketsConnection_edges_node_candlesConnection { - __typename: "CandleDataConnection"; - /** - * The candles - */ - edges: (MarketCandlesQuery_marketsConnection_edges_node_candlesConnection_edges | null)[] | null; -} - -export interface MarketCandlesQuery_marketsConnection_edges_node { - __typename: "Market"; - /** - * Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters using cursor based pagination - */ - candlesConnection: MarketCandlesQuery_marketsConnection_edges_node_candlesConnection | null; -} - -export interface MarketCandlesQuery_marketsConnection_edges { - __typename: "MarketEdge"; - /** - * The market - */ - node: MarketCandlesQuery_marketsConnection_edges_node; -} - -export interface MarketCandlesQuery_marketsConnection { - __typename: "MarketConnection"; - /** - * The markets in this connection - */ - edges: MarketCandlesQuery_marketsConnection_edges[]; -} - -export interface MarketCandlesQuery { - /** - * One or more instruments that are trading on the Vega network - */ - marketsConnection: MarketCandlesQuery_marketsConnection | null; -} - -export interface MarketCandlesQueryVariables { - interval: Interval; - since: string; - marketId: string; -} diff --git a/libs/market-list/src/lib/__generated__/MarketCandlesSub.ts b/libs/market-list/src/lib/__generated__/MarketCandlesSub.ts deleted file mode 100644 index c5a5a4738..000000000 --- a/libs/market-list/src/lib/__generated__/MarketCandlesSub.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { Interval } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL subscription operation: MarketCandlesSub -// ==================================================== - -export interface MarketCandlesSub_candles { - __typename: "Candle"; - /** - * High price (uint64) - */ - high: string; - /** - * Low price (uint64) - */ - low: string; - /** - * Open price (uint64) - */ - open: string; - /** - * Close price (uint64) - */ - close: string; - /** - * Volume price (uint64) - */ - volume: string; -} - -export interface MarketCandlesSub { - /** - * Subscribe to the candles updates - */ - candles: MarketCandlesSub_candles; -} - -export interface MarketCandlesSubVariables { - marketId: string; - interval: Interval; -} diff --git a/libs/market-list/src/lib/__generated__/MarketDataQuery.ts b/libs/market-list/src/lib/__generated__/MarketDataQuery.ts deleted file mode 100644 index b580f692b..000000000 --- a/libs/market-list/src/lib/__generated__/MarketDataQuery.ts +++ /dev/null @@ -1,101 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { AuctionTrigger, MarketTradingMode } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL query operation: MarketDataQuery -// ==================================================== - -export interface MarketDataQuery_marketsConnection_edges_node_data_market { - __typename: "Market"; - /** - * Market ID - */ - id: string; -} - -export interface MarketDataQuery_marketsConnection_edges_node_data { - __typename: "MarketData"; - /** - * Market of the associated mark price - */ - market: MarketDataQuery_marketsConnection_edges_node_data_market; - /** - * The highest price level on an order book for buy orders. - */ - bestBidPrice: string; - /** - * The lowest price level on an order book for offer orders. - */ - bestOfferPrice: string; - /** - * The mark price (an unsigned integer) - */ - markPrice: string; - /** - * What triggered an auction (if an auction was started) - */ - trigger: AuctionTrigger; - /** - * The arithmetic average of the best static bid price and best static offer price - */ - staticMidPrice: string; - /** - * What mode the market is in (auction, continuous, etc) - */ - marketTradingMode: MarketTradingMode; - /** - * Indicative volume if the auction ended now, 0 if not in auction mode - */ - indicativeVolume: string; - /** - * Indicative price if the auction ended now, 0 if not in auction mode - */ - indicativePrice: string; - /** - * The highest price level on an order book for buy orders not including pegged orders. - */ - bestStaticBidPrice: string; - /** - * The lowest price level on an order book for offer orders not including pegged orders. - */ - bestStaticOfferPrice: string; -} - -export interface MarketDataQuery_marketsConnection_edges_node { - __typename: "Market"; - /** - * marketData for the given market - */ - data: MarketDataQuery_marketsConnection_edges_node_data | null; -} - -export interface MarketDataQuery_marketsConnection_edges { - __typename: "MarketEdge"; - /** - * The market - */ - node: MarketDataQuery_marketsConnection_edges_node; -} - -export interface MarketDataQuery_marketsConnection { - __typename: "MarketConnection"; - /** - * The markets in this connection - */ - edges: MarketDataQuery_marketsConnection_edges[]; -} - -export interface MarketDataQuery { - /** - * One or more instruments that are trading on the Vega network - */ - marketsConnection: MarketDataQuery_marketsConnection | null; -} - -export interface MarketDataQueryVariables { - marketId: string; -} diff --git a/libs/market-list/src/lib/__generated__/MarketDataSub.ts b/libs/market-list/src/lib/__generated__/MarketDataSub.ts deleted file mode 100644 index ab4ac3de1..000000000 --- a/libs/market-list/src/lib/__generated__/MarketDataSub.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { AuctionTrigger, MarketTradingMode } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL subscription operation: MarketDataSub -// ==================================================== - -export interface MarketDataSub_marketsData { - __typename: "ObservableMarketData"; - /** - * Market ID of the associated mark price - */ - marketId: string; - /** - * The highest price level on an order book for buy orders. - */ - bestBidPrice: string; - /** - * The lowest price level on an order book for offer orders. - */ - bestOfferPrice: string; - /** - * The mark price (an unsigned integer) - */ - markPrice: string; - /** - * What triggered an auction (if an auction was started) - */ - trigger: AuctionTrigger; - /** - * The arithmetic average of the best static bid price and best static offer price - */ - staticMidPrice: string; - /** - * What mode the market is in (auction, continuous etc) - */ - marketTradingMode: MarketTradingMode; - /** - * Indicative volume if the auction ended now, 0 if not in auction mode - */ - indicativeVolume: string; - /** - * Indicative price if the auction ended now, 0 if not in auction mode - */ - indicativePrice: string; - /** - * The highest price level on an order book for buy orders not including pegged orders. - */ - bestStaticBidPrice: string; - /** - * The lowest price level on an order book for offer orders not including pegged orders - */ - bestStaticOfferPrice: string; -} - -export interface MarketDataSub { - /** - * Subscribe to the mark price changes - */ - marketsData: MarketDataSub_marketsData[]; -} - -export interface MarketDataSubVariables { - marketId: string; -} diff --git a/libs/market-list/src/lib/__generated__/MarketFields.ts b/libs/market-list/src/lib/__generated__/MarketFields.ts deleted file mode 100644 index 60c8f95d5..000000000 --- a/libs/market-list/src/lib/__generated__/MarketFields.ts +++ /dev/null @@ -1,162 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { MarketState, MarketTradingMode } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL fragment: MarketFields -// ==================================================== - -export interface MarketFields_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 MarketFields_fees { - __typename: "Fees"; - /** - * The factors used to calculate the different fees - */ - factors: MarketFields_fees_factors; -} - -export interface MarketFields_tradableInstrument_instrument_metadata { - __typename: "InstrumentMetadata"; - /** - * An arbitrary list of tags to associated to associate to the Instrument (string list) - */ - tags: string[] | null; -} - -export interface MarketFields_tradableInstrument_instrument_product_settlementAsset { - __typename: "Asset"; - /** - * 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; -} - -export interface MarketFields_tradableInstrument_instrument_product { - __typename: "Future"; - /** - * The name of the asset (string) - */ - settlementAsset: MarketFields_tradableInstrument_instrument_product_settlementAsset; - /** - * String representing the quote (e.g. BTCUSD -> USD is quote) - */ - quoteName: string; -} - -export interface MarketFields_tradableInstrument_instrument { - __typename: "Instrument"; - /** - * Uniquely identify an instrument across all instruments available on Vega (string) - */ - id: string; - /** - * Full and fairly descriptive name for the instrument - */ - name: string; - /** - * A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string) - */ - code: string; - /** - * Metadata for this instrument - */ - metadata: MarketFields_tradableInstrument_instrument_metadata; - /** - * A reference to or instance of a fully specified product, including all required product parameters for that product (Product union) - */ - product: MarketFields_tradableInstrument_instrument_product; -} - -export interface MarketFields_tradableInstrument { - __typename: "TradableInstrument"; - /** - * An instance of, or reference to, a fully specified instrument. - */ - instrument: MarketFields_tradableInstrument_instrument; -} - -export interface MarketFields_marketTimestamps { - __typename: "MarketTimestamps"; - /** - * Time when the market is open and ready to accept trades - */ - open: string | null; - /** - * Time when the market is closed - */ - close: string | null; -} - -export interface MarketFields { - __typename: "Market"; - /** - * Market ID - */ - id: string; - /** - * 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; - /** - * The number of decimal places that an integer must be shifted in order to get a correct size (uint64). - * i.e. 0 means there are no fractional orders for the market, and order sizes are always whole sizes. - * 2 means sizes given as 10^2 * desired size, e.g. a desired size of 1.23 is represented as 123 in this market. - * This sets how big the smallest order / position on the market can be. - */ - positionDecimalPlaces: number; - /** - * Current state of the market - */ - state: MarketState; - /** - * Current mode of execution of the market - */ - tradingMode: MarketTradingMode; - /** - * Fees related data - */ - fees: MarketFields_fees; - /** - * An instance of, or reference to, a tradable instrument. - */ - tradableInstrument: MarketFields_tradableInstrument; - /** - * Timestamps for state changes in the market - */ - marketTimestamps: MarketFields_marketTimestamps; -} diff --git a/libs/market-list/src/lib/__generated__/Markets.ts b/libs/market-list/src/lib/__generated__/Markets.ts deleted file mode 100644 index 8e31d6c90..000000000 --- a/libs/market-list/src/lib/__generated__/Markets.ts +++ /dev/null @@ -1,185 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { MarketState, MarketTradingMode } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL query operation: Markets -// ==================================================== - -export interface Markets_marketsConnection_edges_node_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 Markets_marketsConnection_edges_node_fees { - __typename: "Fees"; - /** - * The factors used to calculate the different fees - */ - factors: Markets_marketsConnection_edges_node_fees_factors; -} - -export interface Markets_marketsConnection_edges_node_tradableInstrument_instrument_metadata { - __typename: "InstrumentMetadata"; - /** - * An arbitrary list of tags to associated to associate to the Instrument (string list) - */ - tags: string[] | null; -} - -export interface Markets_marketsConnection_edges_node_tradableInstrument_instrument_product_settlementAsset { - __typename: "Asset"; - /** - * 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; -} - -export interface Markets_marketsConnection_edges_node_tradableInstrument_instrument_product { - __typename: "Future"; - /** - * The name of the asset (string) - */ - settlementAsset: Markets_marketsConnection_edges_node_tradableInstrument_instrument_product_settlementAsset; - /** - * String representing the quote (e.g. BTCUSD -> USD is quote) - */ - quoteName: string; -} - -export interface Markets_marketsConnection_edges_node_tradableInstrument_instrument { - __typename: "Instrument"; - /** - * Uniquely identify an instrument across all instruments available on Vega (string) - */ - id: string; - /** - * Full and fairly descriptive name for the instrument - */ - name: string; - /** - * A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string) - */ - code: string; - /** - * Metadata for this instrument - */ - metadata: Markets_marketsConnection_edges_node_tradableInstrument_instrument_metadata; - /** - * A reference to or instance of a fully specified product, including all required product parameters for that product (Product union) - */ - product: Markets_marketsConnection_edges_node_tradableInstrument_instrument_product; -} - -export interface Markets_marketsConnection_edges_node_tradableInstrument { - __typename: "TradableInstrument"; - /** - * An instance of, or reference to, a fully specified instrument. - */ - instrument: Markets_marketsConnection_edges_node_tradableInstrument_instrument; -} - -export interface Markets_marketsConnection_edges_node_marketTimestamps { - __typename: "MarketTimestamps"; - /** - * Time when the market is open and ready to accept trades - */ - open: string | null; - /** - * Time when the market is closed - */ - close: string | null; -} - -export interface Markets_marketsConnection_edges_node { - __typename: "Market"; - /** - * Market ID - */ - id: string; - /** - * 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; - /** - * The number of decimal places that an integer must be shifted in order to get a correct size (uint64). - * i.e. 0 means there are no fractional orders for the market, and order sizes are always whole sizes. - * 2 means sizes given as 10^2 * desired size, e.g. a desired size of 1.23 is represented as 123 in this market. - * This sets how big the smallest order / position on the market can be. - */ - positionDecimalPlaces: number; - /** - * Current state of the market - */ - state: MarketState; - /** - * Current mode of execution of the market - */ - tradingMode: MarketTradingMode; - /** - * Fees related data - */ - fees: Markets_marketsConnection_edges_node_fees; - /** - * An instance of, or reference to, a tradable instrument. - */ - tradableInstrument: Markets_marketsConnection_edges_node_tradableInstrument; - /** - * Timestamps for state changes in the market - */ - marketTimestamps: Markets_marketsConnection_edges_node_marketTimestamps; -} - -export interface Markets_marketsConnection_edges { - __typename: "MarketEdge"; - /** - * The market - */ - node: Markets_marketsConnection_edges_node; -} - -export interface Markets_marketsConnection { - __typename: "MarketConnection"; - /** - * The markets in this connection - */ - edges: Markets_marketsConnection_edges[]; -} - -export interface Markets { - /** - * One or more instruments that are trading on the Vega network - */ - marketsConnection: Markets_marketsConnection | null; -} diff --git a/libs/market-list/src/lib/__generated__/MarketsCandlesQuery.ts b/libs/market-list/src/lib/__generated__/MarketsCandlesQuery.ts deleted file mode 100644 index 838554a22..000000000 --- a/libs/market-list/src/lib/__generated__/MarketsCandlesQuery.ts +++ /dev/null @@ -1,90 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { Interval } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL query operation: MarketsCandlesQuery -// ==================================================== - -export interface MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges_node { - __typename: "Candle"; - /** - * High price (uint64) - */ - high: string; - /** - * Low price (uint64) - */ - low: string; - /** - * Open price (uint64) - */ - open: string; - /** - * Close price (uint64) - */ - close: string; - /** - * Volume price (uint64) - */ - volume: string; -} - -export interface MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges { - __typename: "CandleEdge"; - /** - * The candle - */ - node: MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges_node; -} - -export interface MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection { - __typename: "CandleDataConnection"; - /** - * The candles - */ - edges: (MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges | null)[] | null; -} - -export interface MarketsCandlesQuery_marketsConnection_edges_node { - __typename: "Market"; - /** - * Market ID - */ - id: string; - /** - * Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters using cursor based pagination - */ - candlesConnection: MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection | null; -} - -export interface MarketsCandlesQuery_marketsConnection_edges { - __typename: "MarketEdge"; - /** - * The market - */ - node: MarketsCandlesQuery_marketsConnection_edges_node; -} - -export interface MarketsCandlesQuery_marketsConnection { - __typename: "MarketConnection"; - /** - * The markets in this connection - */ - edges: MarketsCandlesQuery_marketsConnection_edges[]; -} - -export interface MarketsCandlesQuery { - /** - * One or more instruments that are trading on the Vega network - */ - marketsConnection: MarketsCandlesQuery_marketsConnection | null; -} - -export interface MarketsCandlesQueryVariables { - interval: Interval; - since: string; -} diff --git a/libs/market-list/src/lib/__generated__/MarketsDataQuery.ts b/libs/market-list/src/lib/__generated__/MarketsDataQuery.ts deleted file mode 100644 index 2ae30d2e0..000000000 --- a/libs/market-list/src/lib/__generated__/MarketsDataQuery.ts +++ /dev/null @@ -1,97 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { AuctionTrigger, MarketTradingMode } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL query operation: MarketsDataQuery -// ==================================================== - -export interface MarketsDataQuery_marketsConnection_edges_node_data_market { - __typename: "Market"; - /** - * Market ID - */ - id: string; -} - -export interface MarketsDataQuery_marketsConnection_edges_node_data { - __typename: "MarketData"; - /** - * Market of the associated mark price - */ - market: MarketsDataQuery_marketsConnection_edges_node_data_market; - /** - * The highest price level on an order book for buy orders. - */ - bestBidPrice: string; - /** - * The lowest price level on an order book for offer orders. - */ - bestOfferPrice: string; - /** - * The mark price (an unsigned integer) - */ - markPrice: string; - /** - * What triggered an auction (if an auction was started) - */ - trigger: AuctionTrigger; - /** - * The arithmetic average of the best static bid price and best static offer price - */ - staticMidPrice: string; - /** - * What mode the market is in (auction, continuous, etc) - */ - marketTradingMode: MarketTradingMode; - /** - * Indicative volume if the auction ended now, 0 if not in auction mode - */ - indicativeVolume: string; - /** - * Indicative price if the auction ended now, 0 if not in auction mode - */ - indicativePrice: string; - /** - * The highest price level on an order book for buy orders not including pegged orders. - */ - bestStaticBidPrice: string; - /** - * The lowest price level on an order book for offer orders not including pegged orders. - */ - bestStaticOfferPrice: string; -} - -export interface MarketsDataQuery_marketsConnection_edges_node { - __typename: "Market"; - /** - * marketData for the given market - */ - data: MarketsDataQuery_marketsConnection_edges_node_data | null; -} - -export interface MarketsDataQuery_marketsConnection_edges { - __typename: "MarketEdge"; - /** - * The market - */ - node: MarketsDataQuery_marketsConnection_edges_node; -} - -export interface MarketsDataQuery_marketsConnection { - __typename: "MarketConnection"; - /** - * The markets in this connection - */ - edges: MarketsDataQuery_marketsConnection_edges[]; -} - -export interface MarketsDataQuery { - /** - * One or more instruments that are trading on the Vega network - */ - marketsConnection: MarketsDataQuery_marketsConnection | null; -} diff --git a/libs/market-list/src/lib/__generated___/market-candles.ts b/libs/market-list/src/lib/__generated___/market-candles.ts new file mode 100644 index 000000000..71f08b1ab --- /dev/null +++ b/libs/market-list/src/lib/__generated___/market-candles.ts @@ -0,0 +1,111 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type MarketCandlesFieldsFragment = { __typename?: 'Candle', high: string, low: string, open: string, close: string, volume: string }; + +export type MarketCandlesQueryVariables = Types.Exact<{ + interval: Types.Interval; + since: Types.Scalars['String']; + marketId: Types.Scalars['ID']; +}>; + + +export type MarketCandlesQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', candlesConnection?: { __typename?: 'CandleDataConnection', edges?: Array<{ __typename?: 'CandleEdge', node: { __typename?: 'Candle', high: string, low: string, open: string, close: string, volume: string } } | null> | null } | null } }> } | null }; + +export type MarketCandlesUpdateSubscriptionVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; + interval: Types.Interval; +}>; + + +export type MarketCandlesUpdateSubscription = { __typename?: 'Subscription', candles: { __typename?: 'Candle', high: string, low: string, open: string, close: string, volume: string } }; + +export const MarketCandlesFieldsFragmentDoc = gql` + fragment MarketCandlesFields on Candle { + high + low + open + close + volume +} + `; +export const MarketCandlesDocument = gql` + query MarketCandles($interval: Interval!, $since: String!, $marketId: ID!) { + marketsConnection(id: $marketId) { + edges { + node { + candlesConnection(interval: $interval, since: $since) { + edges { + node { + ...MarketCandlesFields + } + } + } + } + } + } +} + ${MarketCandlesFieldsFragmentDoc}`; + +/** + * __useMarketCandlesQuery__ + * + * To run a query within a React component, call `useMarketCandlesQuery` and pass it any options that fit your needs. + * When your component renders, `useMarketCandlesQuery` 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 } = useMarketCandlesQuery({ + * variables: { + * interval: // value for 'interval' + * since: // value for 'since' + * marketId: // value for 'marketId' + * }, + * }); + */ +export function useMarketCandlesQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(MarketCandlesDocument, options); + } +export function useMarketCandlesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(MarketCandlesDocument, options); + } +export type MarketCandlesQueryHookResult = ReturnType; +export type MarketCandlesLazyQueryHookResult = ReturnType; +export type MarketCandlesQueryResult = Apollo.QueryResult; +export const MarketCandlesUpdateDocument = gql` + subscription MarketCandlesUpdate($marketId: ID!, $interval: Interval!) { + candles(interval: $interval, marketId: $marketId) { + ...MarketCandlesFields + } +} + ${MarketCandlesFieldsFragmentDoc}`; + +/** + * __useMarketCandlesUpdateSubscription__ + * + * To run a query within a React component, call `useMarketCandlesUpdateSubscription` and pass it any options that fit your needs. + * When your component renders, `useMarketCandlesUpdateSubscription` 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 subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useMarketCandlesUpdateSubscription({ + * variables: { + * marketId: // value for 'marketId' + * interval: // value for 'interval' + * }, + * }); + */ +export function useMarketCandlesUpdateSubscription(baseOptions: Apollo.SubscriptionHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSubscription(MarketCandlesUpdateDocument, options); + } +export type MarketCandlesUpdateSubscriptionHookResult = ReturnType; +export type MarketCandlesUpdateSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/market-list/src/lib/__generated___/market-data.ts b/libs/market-list/src/lib/__generated___/market-data.ts new file mode 100644 index 000000000..33ef37b8f --- /dev/null +++ b/libs/market-list/src/lib/__generated___/market-data.ts @@ -0,0 +1,126 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type MarketDataUpdateFieldsFragment = { __typename?: 'ObservableMarketData', marketId: string, bestBidPrice: string, bestOfferPrice: string, markPrice: string, trigger: Types.AuctionTrigger, staticMidPrice: string, marketTradingMode: Types.MarketTradingMode, indicativeVolume: string, indicativePrice: string, bestStaticBidPrice: string, bestStaticOfferPrice: string }; + +export type MarketDataUpdateSubscriptionVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; +}>; + + +export type MarketDataUpdateSubscription = { __typename?: 'Subscription', marketsData: Array<{ __typename?: 'ObservableMarketData', marketId: string, bestBidPrice: string, bestOfferPrice: string, markPrice: string, trigger: Types.AuctionTrigger, staticMidPrice: string, marketTradingMode: Types.MarketTradingMode, indicativeVolume: string, indicativePrice: string, bestStaticBidPrice: string, bestStaticOfferPrice: string }> }; + +export type MarketDataFieldsFragment = { __typename?: 'MarketData', bestBidPrice: string, bestOfferPrice: string, markPrice: string, trigger: Types.AuctionTrigger, staticMidPrice: string, marketTradingMode: Types.MarketTradingMode, indicativeVolume: string, indicativePrice: string, bestStaticBidPrice: string, bestStaticOfferPrice: string, market: { __typename?: 'Market', id: string } }; + +export type MarketDataQueryVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; +}>; + + +export type MarketDataQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', data?: { __typename?: 'MarketData', bestBidPrice: string, bestOfferPrice: string, markPrice: string, trigger: Types.AuctionTrigger, staticMidPrice: string, marketTradingMode: Types.MarketTradingMode, indicativeVolume: string, indicativePrice: string, bestStaticBidPrice: string, bestStaticOfferPrice: string, market: { __typename?: 'Market', id: string } } | null } }> } | null }; + +export const MarketDataUpdateFieldsFragmentDoc = gql` + fragment MarketDataUpdateFields on ObservableMarketData { + marketId + bestBidPrice + bestOfferPrice + markPrice + trigger + staticMidPrice + marketTradingMode + indicativeVolume + indicativePrice + bestStaticBidPrice + bestStaticOfferPrice +} + `; +export const MarketDataFieldsFragmentDoc = gql` + fragment MarketDataFields on MarketData { + market { + id + } + bestBidPrice + bestOfferPrice + markPrice + trigger + staticMidPrice + marketTradingMode + indicativeVolume + indicativePrice + bestStaticBidPrice + bestStaticOfferPrice +} + `; +export const MarketDataUpdateDocument = gql` + subscription MarketDataUpdate($marketId: ID!) { + marketsData(marketIds: [$marketId]) { + ...MarketDataUpdateFields + } +} + ${MarketDataUpdateFieldsFragmentDoc}`; + +/** + * __useMarketDataUpdateSubscription__ + * + * To run a query within a React component, call `useMarketDataUpdateSubscription` and pass it any options that fit your needs. + * When your component renders, `useMarketDataUpdateSubscription` 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 subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useMarketDataUpdateSubscription({ + * variables: { + * marketId: // value for 'marketId' + * }, + * }); + */ +export function useMarketDataUpdateSubscription(baseOptions: Apollo.SubscriptionHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSubscription(MarketDataUpdateDocument, options); + } +export type MarketDataUpdateSubscriptionHookResult = ReturnType; +export type MarketDataUpdateSubscriptionResult = Apollo.SubscriptionResult; +export const MarketDataDocument = gql` + query MarketData($marketId: ID!) { + marketsConnection(id: $marketId) { + edges { + node { + data { + ...MarketDataFields + } + } + } + } +} + ${MarketDataFieldsFragmentDoc}`; + +/** + * __useMarketDataQuery__ + * + * To run a query within a React component, call `useMarketDataQuery` and pass it any options that fit your needs. + * When your component renders, `useMarketDataQuery` 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 } = useMarketDataQuery({ + * variables: { + * marketId: // value for 'marketId' + * }, + * }); + */ +export function useMarketDataQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(MarketDataDocument, options); + } +export function useMarketDataLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(MarketDataDocument, options); + } +export type MarketDataQueryHookResult = ReturnType; +export type MarketDataLazyQueryHookResult = ReturnType; +export type MarketDataQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/market-list/src/lib/__generated___/markets-candles.ts b/libs/market-list/src/lib/__generated___/markets-candles.ts new file mode 100644 index 000000000..4c0cc868b --- /dev/null +++ b/libs/market-list/src/lib/__generated___/markets-candles.ts @@ -0,0 +1,62 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import { MarketCandlesFieldsFragmentDoc } from './market-candles'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type MarketsCandlesQueryVariables = Types.Exact<{ + interval: Types.Interval; + since: Types.Scalars['String']; +}>; + + +export type MarketsCandlesQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, candlesConnection?: { __typename?: 'CandleDataConnection', edges?: Array<{ __typename?: 'CandleEdge', node: { __typename?: 'Candle', high: string, low: string, open: string, close: string, volume: string } } | null> | null } | null } }> } | null }; + + +export const MarketsCandlesDocument = gql` + query MarketsCandles($interval: Interval!, $since: String!) { + marketsConnection { + edges { + node { + id + candlesConnection(interval: $interval, since: $since) { + edges { + node { + ...MarketCandlesFields + } + } + } + } + } + } +} + ${MarketCandlesFieldsFragmentDoc}`; + +/** + * __useMarketsCandlesQuery__ + * + * To run a query within a React component, call `useMarketsCandlesQuery` and pass it any options that fit your needs. + * When your component renders, `useMarketsCandlesQuery` 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 } = useMarketsCandlesQuery({ + * variables: { + * interval: // value for 'interval' + * since: // value for 'since' + * }, + * }); + */ +export function useMarketsCandlesQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(MarketsCandlesDocument, options); + } +export function useMarketsCandlesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(MarketsCandlesDocument, options); + } +export type MarketsCandlesQueryHookResult = ReturnType; +export type MarketsCandlesLazyQueryHookResult = ReturnType; +export type MarketsCandlesQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/market-list/src/lib/__generated___/markets-data.ts b/libs/market-list/src/lib/__generated___/markets-data.ts new file mode 100644 index 000000000..6ff9d71a0 --- /dev/null +++ b/libs/market-list/src/lib/__generated___/markets-data.ts @@ -0,0 +1,52 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import { MarketDataFieldsFragmentDoc } from './market-data'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type MarketsDataQueryVariables = Types.Exact<{ [key: string]: never; }>; + + +export type MarketsDataQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', data?: { __typename?: 'MarketData', bestBidPrice: string, bestOfferPrice: string, markPrice: string, trigger: Types.AuctionTrigger, staticMidPrice: string, marketTradingMode: Types.MarketTradingMode, indicativeVolume: string, indicativePrice: string, bestStaticBidPrice: string, bestStaticOfferPrice: string, market: { __typename?: 'Market', id: string } } | null } }> } | null }; + + +export const MarketsDataDocument = gql` + query MarketsData { + marketsConnection { + edges { + node { + data { + ...MarketDataFields + } + } + } + } +} + ${MarketDataFieldsFragmentDoc}`; + +/** + * __useMarketsDataQuery__ + * + * To run a query within a React component, call `useMarketsDataQuery` and pass it any options that fit your needs. + * When your component renders, `useMarketsDataQuery` 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 } = useMarketsDataQuery({ + * variables: { + * }, + * }); + */ +export function useMarketsDataQuery(baseOptions?: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(MarketsDataDocument, options); + } +export function useMarketsDataLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(MarketsDataDocument, options); + } +export type MarketsDataQueryHookResult = ReturnType; +export type MarketsDataLazyQueryHookResult = ReturnType; +export type MarketsDataQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/market-list/src/lib/__generated___/markets.ts b/libs/market-list/src/lib/__generated___/markets.ts new file mode 100644 index 000000000..bbb9ba3ac --- /dev/null +++ b/libs/market-list/src/lib/__generated___/markets.ts @@ -0,0 +1,89 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type MarketFieldsFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', symbol: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null } }; + +export type MarketsQueryVariables = Types.Exact<{ [key: string]: never; }>; + + +export type MarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', symbol: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null } } }> } | null }; + +export const MarketFieldsFragmentDoc = gql` + fragment MarketFields on Market { + id + decimalPlaces + positionDecimalPlaces + state + tradingMode + fees { + factors { + makerFee + infrastructureFee + liquidityFee + } + } + tradableInstrument { + instrument { + id + name + code + metadata { + tags + } + product { + ... on Future { + settlementAsset { + symbol + decimals + } + quoteName + } + } + } + } + marketTimestamps { + open + close + } +} + `; +export const MarketsDocument = gql` + query Markets { + marketsConnection { + edges { + node { + ...MarketFields + } + } + } +} + ${MarketFieldsFragmentDoc}`; + +/** + * __useMarketsQuery__ + * + * To run a query within a React component, call `useMarketsQuery` and pass it any options that fit your needs. + * When your component renders, `useMarketsQuery` 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 } = useMarketsQuery({ + * variables: { + * }, + * }); + */ +export function useMarketsQuery(baseOptions?: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(MarketsDocument, options); + } +export function useMarketsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(MarketsDocument, options); + } +export type MarketsQueryHookResult = ReturnType; +export type MarketsLazyQueryHookResult = ReturnType; +export type MarketsQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/market-list/src/lib/components/select-market-columns.tsx b/libs/market-list/src/lib/components/select-market-columns.tsx index 211b5a36d..6a058785a 100644 --- a/libs/market-list/src/lib/components/select-market-columns.tsx +++ b/libs/market-list/src/lib/components/select-market-columns.tsx @@ -19,9 +19,11 @@ import Link from 'next/link'; import { calcCandleHigh, calcCandleLow, totalFees } from '../utils'; import type { CandleClose } from '@vegaprotocol/types'; -import type { Market, MarketData, Candle } from '../'; +import type { MarketWithData, MarketWithCandles } from '../'; import isNil from 'lodash/isNil'; +type Market = MarketWithData & MarketWithCandles; + export const cellClassNames = 'py-1 first:text-left text-right'; const FeesInfo = () => { @@ -159,16 +161,14 @@ export type OnCellClickHandler = ( export const columns = ( market: Market, - marketData: MarketData | undefined, - candles: Candle[] | undefined, onSelect: (id: string) => void, onCellClick: OnCellClickHandler ) => { - const candlesClose = candles + const candlesClose = market.candles ?.map((candle) => candle?.close) .filter((c: string | undefined): c is CandleClose => !isNil(c)); - const candleLow = candles && calcCandleLow(candles); - const candleHigh = candles && calcCandleHigh(candles); + const candleLow = market.candles && calcCandleLow(market.candles); + const candleHigh = market.candles && calcCandleHigh(market.candles); const selectMarketColumns: Column[] = [ { kind: ColumnKind.Market, @@ -178,11 +178,11 @@ export const columns = ( }, { kind: ColumnKind.LastPrice, - value: marketData?.markPrice ? ( + value: market.data?.markPrice ? (