chore: replace market candles with candlesConnection

This commit is contained in:
Bartłomiej Głownia 2022-09-16 10:41:42 +02:00
parent c3675cb900
commit 094b41e8ef
32 changed files with 391 additions and 122 deletions

View File

@ -265,7 +265,7 @@ export interface ProposalsQuery_proposalsConnection_edges_node {
*/
datetime: string;
/**
* Reason for the proposal to be rejected by the core
* Why the proposal was rejected by the core
*/
rejectionReason: ProposalRejectionReason | null;
/**

View File

@ -293,7 +293,7 @@ export interface ProposalFields {
*/
datetime: string;
/**
* Reason for the proposal to be rejected by the core
* Why the proposal was rejected by the core
*/
rejectionReason: ProposalRejectionReason | null;
/**

View File

@ -293,7 +293,7 @@ export interface Proposal_proposal {
*/
datetime: string;
/**
* Reason for the proposal to be rejected by the core
* Why the proposal was rejected by the core
*/
rejectionReason: ProposalRejectionReason | null;
/**

View File

@ -293,7 +293,7 @@ export interface Proposals_proposalsConnection_edges_node {
*/
datetime: string;
/**
* Reason for the proposal to be rejected by the core
* Why the proposal was rejected by the core
*/
rejectionReason: ProposalRejectionReason | null;
/**

View File

@ -113,7 +113,7 @@ export const generateMarketInfoQuery = (
},
__typename: 'LiquidityMonitoringParameters',
},
candles: [],
candlesConnection: null,
tradableInstrument: {
__typename: 'TradableInstrument',
instrument: {

View File

@ -75,20 +75,29 @@ export const generateMarket = (override?: PartialDeep<Market>): Market => {
close: null,
__typename: 'MarketTimestamps',
},
candles: [
candlesConnection: {
__typename: 'CandleDataConnection',
edges: [
{
__typename: 'CandleEdge',
node: {
open: '2095312844',
close: '2090090607',
volume: '4847',
__typename: 'Candle',
},
},
{
__typename: 'CandleEdge',
node: {
open: '2090090000',
close: '2090090607',
volume: '4847',
__typename: 'Candle',
},
},
],
},
__typename: 'Market',
},
};

View File

@ -319,7 +319,7 @@ export const generateMarketsCandles = (
{
__typename: 'CandleEdge',
node: {
__typename: 'CandleNode',
__typename: 'Candle',
open: '100',
close: '100',
high: '110',
@ -339,7 +339,7 @@ export const generateMarketsCandles = (
{
__typename: 'CandleEdge',
node: {
__typename: 'CandleNode',
__typename: 'Candle',
open: '100',
close: '100',
high: '110',
@ -359,7 +359,7 @@ export const generateMarketsCandles = (
{
__typename: 'CandleEdge',
node: {
__typename: 'CandleNode',
__typename: 'Candle',
open: '100',
close: '100',
high: '110',
@ -379,7 +379,7 @@ export const generateMarketsCandles = (
{
__typename: 'CandleEdge',
node: {
__typename: 'CandleNode',
__typename: 'Candle',
open: '100',
close: '100',
high: '110',

View File

@ -18,7 +18,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
id: '066468C06549101DAF7BC51099E1412A0067DC08C246B7D8013C9D0CBF1E8EE7',
market: {
__typename: 'Market',
id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d',
id: 'market-0',
},
size: '10',
type: OrderType.TYPE_LIMIT,
@ -37,7 +37,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
id: '48DB6767E4E4E0F649C5A13ABFADE39F8451C27DA828DAF14B7A1E8E5EBDAD99',
market: {
__typename: 'Market',
id: '5a4b0b9e9c0629f0315ec56fcb7bd444b0c6e4da5ec7677719d502626658a376',
id: 'market-1',
},
size: '1',
type: OrderType.TYPE_LIMIT,
@ -56,7 +56,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
id: '4e93702990712c41f6995fcbbd94f60bb372ad12d64dfa7d96d205c49f790336',
market: {
__typename: 'Market',
id: 'c6f4337b31ed57a961969c3ba10297b369d01b9e75a4cbb96db4fc62886444e6',
id: 'market-2',
},
size: '1',
type: OrderType.TYPE_LIMIT,
@ -75,7 +75,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
id: '94737d2bafafa4bc3b80a56ef084ae52a983b91aa067c31e243c61a0f962a836',
market: {
__typename: 'Market',
id: 'a316fa51dab97d76a1472c2f22906f4e461728e04355096788165d5b13999ed5',
id: 'market-3',
},
size: '1',
type: OrderType.TYPE_LIMIT,
@ -94,7 +94,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
id: '94aead3ca92dc932efcb503631b03a410e2a5d4606cae6083e2406dc38e52f78',
market: {
__typename: 'Market',
id: 'a316fa51dab97d76a1472c2f22906f4e461728e04355096788165d5b13999ed5',
id: 'market-3',
},
size: '10',
type: OrderType.TYPE_LIMIT,

View File

@ -13,7 +13,7 @@ export const generateTrades = (override?: PartialDeep<Trades>): Trades => {
size: '24',
createdAt: '2022-04-06T16:19:42.692598951Z',
market: {
id: '0c3c1490db767f926d24fb674b4235a9aa339614915a4ab96cbfc0e1ad83c0ff',
id: 'market-0',
__typename: 'Market',
},
__typename: 'Trade',
@ -24,7 +24,7 @@ export const generateTrades = (override?: PartialDeep<Trades>): Trades => {
size: '7',
createdAt: '2022-04-07T06:59:44.835686754Z',
market: {
id: '0c3c1490db767f926d24fb674b4235a9aa339614915a4ab96cbfc0e1ad83c0ff',
id: 'market-0',
__typename: 'Market',
},
__typename: 'Trade',
@ -35,7 +35,7 @@ export const generateTrades = (override?: PartialDeep<Trades>): Trades => {
size: '18',
createdAt: '2022-04-07T17:56:47.997938583Z',
market: {
id: '0c3c1490db767f926d24fb674b4235a9aa339614915a4ab96cbfc0e1ad83c0ff',
id: 'market-0',
__typename: 'Market',
},
__typename: 'Trade',

View File

@ -50,10 +50,14 @@ query Market($marketId: ID!, $interval: Interval!, $since: String!) {
open
close
}
candles(interval: $interval, since: $since) {
candlesConnection(interval: $interval, since: $since) {
edges {
node {
open
close
volume
}
}
}
}
}

View File

@ -65,13 +65,17 @@ const MARKET_QUERY = gql`
open
close
}
candles(interval: $interval, since: $since) {
candlesConnection(interval: $interval, since: $since) {
edges {
node {
open
close
volume
}
}
}
}
}
`;
const MarketPage = ({ id }: { id?: string }) => {

View File

@ -169,7 +169,7 @@ export interface Market_market_marketTimestamps {
close: string | null;
}
export interface Market_market_candles {
export interface Market_market_candlesConnection_edges_node {
__typename: "Candle";
/**
* Open price (uint64)
@ -185,6 +185,19 @@ export interface Market_market_candles {
volume: string;
}
export interface Market_market_candlesConnection_edges {
__typename: "CandleEdge";
node: Market_market_candlesConnection_edges_node;
}
export interface Market_market_candlesConnection {
__typename: "CandleDataConnection";
/**
* The candles
*/
edges: (Market_market_candlesConnection_edges | null)[] | null;
}
export interface Market_market {
__typename: "Market";
/**
@ -236,9 +249,9 @@ export interface Market_market {
*/
marketTimestamps: Market_market_marketTimestamps;
/**
* Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters
* Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters using cursor based pagination
*/
candles: (Market_market_candles | null)[] | null;
candlesConnection: Market_market_candlesConnection | null;
}
export interface Market {

View File

@ -10,7 +10,7 @@ export type MarketQueryVariables = Types.Exact<{
}>;
export type MarketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, tradingMode: Types.MarketTradingMode, state: Types.MarketState, decimalPlaces: number, positionDecimalPlaces: number, data?: { __typename?: 'MarketData', auctionStart?: string | null, auctionEnd?: string | null, markPrice: string, indicativeVolume: string, indicativePrice: string, suppliedStake?: string | null, targetStake?: string | null, bestBidVolume: string, bestOfferVolume: string, bestStaticBidVolume: string, bestStaticOfferVolume: string, trigger: Types.AuctionTrigger, market: { __typename?: 'Market', id: string } } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, oracleSpecForTradingTermination: { __typename?: 'OracleSpec', id: string }, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null }, candles?: Array<{ __typename?: 'Candle', open: string, close: string, volume: string } | null> | null } | null };
export type MarketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, tradingMode: Types.MarketTradingMode, state: Types.MarketState, decimalPlaces: number, positionDecimalPlaces: number, data?: { __typename?: 'MarketData', auctionStart?: string | null, auctionEnd?: string | null, markPrice: string, indicativeVolume: string, indicativePrice: string, suppliedStake?: string | null, targetStake?: string | null, bestBidVolume: string, bestOfferVolume: string, bestStaticBidVolume: string, bestStaticOfferVolume: string, trigger: Types.AuctionTrigger, market: { __typename?: 'Market', id: string } } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, oracleSpecForTradingTermination: { __typename?: 'OracleSpec', id: string }, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null }, candlesConnection?: { __typename?: 'CandleDataConnection', edges?: Array<{ __typename?: 'CandleEdge', node: { __typename?: 'Candle', open: string, close: string, volume: string } } | null> | null } | null } | null };
export const MarketDocument = gql`
@ -66,12 +66,16 @@ export const MarketDocument = gql`
open
close
}
candles(interval: $interval, since: $since) {
candlesConnection(interval: $interval, since: $since) {
edges {
node {
open
close
volume
}
}
}
}
}
`;

View File

@ -121,8 +121,8 @@ export const TradeMarketHeader = ({
const { setAssetDetailsDialogOpen, setAssetDetailsDialogSymbol } =
useAssetDetailsDialogStore();
const candlesClose: string[] = (market?.candles || [])
.map((candle) => candle?.close)
const candlesClose: string[] = (market?.candlesConnection?.edges || [])
.map((candle) => candle?.node.close)
.filter((c): c is CandleClose => c !== null);
const symbol =
market.tradableInstrument.instrument.product?.settlementAsset?.symbol;

View File

@ -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<AssetsConnectionQuery, AssetsConnectionQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<AssetsConnectionQuery, AssetsConnectionQueryVariables>(AssetsConnectionDocument, options);
}
export function useAssetsConnectionLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<AssetsConnectionQuery, AssetsConnectionQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<AssetsConnectionQuery, AssetsConnectionQueryVariables>(AssetsConnectionDocument, options);
}
export type AssetsConnectionQueryHookResult = ReturnType<typeof useAssetsConnectionQuery>;
export type AssetsConnectionLazyQueryHookResult = ReturnType<typeof useAssetsConnectionLazyQuery>;
export type AssetsConnectionQueryResult = Apollo.QueryResult<AssetsConnectionQuery, AssetsConnectionQueryVariables>;

View File

@ -1,5 +1,5 @@
fragment CandleFields on Candle {
datetime
periodStart
high
low
open
@ -18,11 +18,15 @@ query Candles($marketId: ID!, $interval: Interval!, $since: String!) {
code
}
}
candles(interval: $interval, since: $since) {
candlesConnection(interval: $interval, since: $since) {
edges {
node {
...CandleFields
}
}
}
}
}
subscription CandlesEvents($marketId: ID!, $interval: Interval!) {
candles(marketId: $marketId, interval: $interval) {

View File

@ -24,7 +24,7 @@ export type CandlesEventsSubscription = { __typename?: 'Subscription', candles:
export const CandleFieldsFragmentDoc = gql`
fragment CandleFields on Candle {
datetime
periodStart
high
low
open

View File

@ -0,0 +1,117 @@
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, 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, 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, high: string, low: string, open: string, close: string, volume: string } };
export const CandleFieldsFragmentDoc = gql`
fragment CandleFields on Candle {
periodStart
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<CandlesQuery, CandlesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<CandlesQuery, CandlesQueryVariables>(CandlesDocument, options);
}
export function useCandlesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<CandlesQuery, CandlesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<CandlesQuery, CandlesQueryVariables>(CandlesDocument, options);
}
export type CandlesQueryHookResult = ReturnType<typeof useCandlesQuery>;
export type CandlesLazyQueryHookResult = ReturnType<typeof useCandlesLazyQuery>;
export type CandlesQueryResult = Apollo.QueryResult<CandlesQuery, CandlesQueryVariables>;
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<CandlesEventsSubscription, CandlesEventsSubscriptionVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useSubscription<CandlesEventsSubscription, CandlesEventsSubscriptionVariables>(CandlesEventsDocument, options);
}
export type CandlesEventsSubscriptionHookResult = ReturnType<typeof useCandlesEventsSubscription>;
export type CandlesEventsSubscriptionResult = Apollo.SubscriptionResult<CandlesEventsSubscription>;

View File

@ -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<ChartQuery, ChartQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ChartQuery, ChartQueryVariables>(ChartDocument, options);
}
export function useChartLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ChartQuery, ChartQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ChartQuery, ChartQueryVariables>(ChartDocument, options);
}
export type ChartQueryHookResult = ReturnType<typeof useChartQuery>;
export type ChartLazyQueryHookResult = ReturnType<typeof useChartLazyQuery>;
export type ChartQueryResult = Apollo.QueryResult<ChartQuery, ChartQueryVariables>;

View File

@ -84,7 +84,7 @@ export interface Fills_party_tradesConnection_edges_node {
*/
price: string;
/**
* The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64)
* The number of units traded, will always be <= the remaining size of both orders immediately before the trade (uint64)
*/
size: string;
/**

View File

@ -28,7 +28,7 @@ export interface ProposalEvent_busEvents_event_Proposal {
*/
state: ProposalState;
/**
* Reason for the proposal to be rejected by the core
* Why the proposal was rejected by the core
*/
rejectionReason: ProposalRejectionReason | null;
/**

View File

@ -79,9 +79,13 @@ query MarketInfoQuery($marketId: ID!, $interval: Interval!, $since: String!) {
scalingFactor
}
}
candles(interval: $interval, since: $since) {
candlesConnection(interval: $interval, since: $since) {
edges {
node {
volume
}
}
}
tradableInstrument {
instrument {
id

View File

@ -10,7 +10,7 @@ export type MarketInfoQueryQueryVariables = Types.Exact<{
}>;
export type MarketInfoQueryQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string } }> | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, priceMonitoringSettings: { __typename?: 'PriceMonitoringSettings', parameters?: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null } | null }, riskFactors?: { __typename?: 'RiskFactor', market: string, short: string, long: string } | null, data?: { __typename?: 'MarketData', markPrice: string, indicativeVolume: string, bestBidVolume: string, bestOfferVolume: string, bestStaticBidVolume: string, bestStaticOfferVolume: string, openInterest: string, bestBidPrice: string, bestOfferPrice: string, trigger: Types.AuctionTrigger, market: { __typename?: 'Market', id: string }, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null } | null, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: number, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, candles?: Array<{ __typename?: 'Candle', volume: string } | null> | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string }, oracleSpecForSettlementPrice: { __typename?: 'OracleSpec', id: string }, oracleSpecForTradingTermination: { __typename?: 'OracleSpec', id: string }, oracleSpecBinding: { __typename?: 'OracleSpecToFutureBinding', settlementPriceProperty: string, tradingTerminationProperty: string } } }, riskModel: { __typename?: 'LogNormalRiskModel', tau: number, riskAversionParameter: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null };
export type MarketInfoQueryQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string } }> | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, priceMonitoringSettings: { __typename?: 'PriceMonitoringSettings', parameters?: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null } | null }, riskFactors?: { __typename?: 'RiskFactor', market: string, short: string, long: string } | null, data?: { __typename?: 'MarketData', markPrice: string, indicativeVolume: string, bestBidVolume: string, bestOfferVolume: string, bestStaticBidVolume: string, bestStaticOfferVolume: string, openInterest: string, bestBidPrice: string, bestOfferPrice: string, trigger: Types.AuctionTrigger, market: { __typename?: 'Market', id: string }, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null } | null, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: number, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, candlesConnection?: { __typename?: 'CandleDataConnection', edges?: Array<{ __typename?: 'CandleEdge', node: { __typename?: 'Candle', volume: string } } | null> | null } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string }, oracleSpecForSettlementPrice: { __typename?: 'OracleSpec', id: string }, oracleSpecForTradingTermination: { __typename?: 'OracleSpec', id: string }, oracleSpecBinding: { __typename?: 'OracleSpecToFutureBinding', settlementPriceProperty: string, tradingTerminationProperty: string } } }, riskModel: { __typename?: 'LogNormalRiskModel', tau: number, riskAversionParameter: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null };
export const MarketInfoQueryDocument = gql`
@ -95,9 +95,13 @@ export const MarketInfoQueryDocument = gql`
scalingFactor
}
}
candles(interval: $interval, since: $since) {
candlesConnection(interval: $interval, since: $since) {
edges {
node {
volume
}
}
}
tradableInstrument {
instrument {
id

View File

@ -249,7 +249,7 @@ export interface MarketInfoQuery_market_liquidityMonitoringParameters {
targetStakeParameters: MarketInfoQuery_market_liquidityMonitoringParameters_targetStakeParameters;
}
export interface MarketInfoQuery_market_candles {
export interface MarketInfoQuery_market_candlesConnection_edges_node {
__typename: "Candle";
/**
* Volume price (uint64)
@ -257,6 +257,19 @@ export interface MarketInfoQuery_market_candles {
volume: string;
}
export interface MarketInfoQuery_market_candlesConnection_edges {
__typename: "CandleEdge";
node: MarketInfoQuery_market_candlesConnection_edges_node;
}
export interface MarketInfoQuery_market_candlesConnection {
__typename: "CandleDataConnection";
/**
* The candles
*/
edges: (MarketInfoQuery_market_candlesConnection_edges | null)[] | null;
}
export interface MarketInfoQuery_market_tradableInstrument_instrument_metadata {
__typename: "InstrumentMetadata";
/**
@ -500,9 +513,9 @@ export interface MarketInfoQuery_market {
*/
liquidityMonitoringParameters: MarketInfoQuery_market_liquidityMonitoringParameters;
/**
* Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters
* Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters using cursor based pagination
*/
candles: (MarketInfoQuery_market_candles | null)[] | null;
candlesConnection: MarketInfoQuery_market_candlesConnection | null;
/**
* An instance of, or reference to, a tradable instrument.
*/

View File

@ -74,9 +74,13 @@ export const MARKET_INFO_QUERY = gql`
scalingFactor
}
}
candles(interval: $interval, since: $since) {
candlesConnection(interval: $interval, since: $since) {
edges {
node {
volume
}
}
}
tradableInstrument {
instrument {
id

View File

@ -20,7 +20,7 @@ import { MARKET_INFO_QUERY } from './info-market-query';
import type {
MarketInfoQuery,
MarketInfoQuery_market,
MarketInfoQuery_market_candles,
MarketInfoQuery_market_candlesConnection_edges,
} from './__generated__/MarketInfoQuery';
import { MarketInfoTable } from './info-key-value-table';
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
@ -39,10 +39,16 @@ export interface InfoProps {
export const calcCandleVolume = (
m: MarketInfoQuery_market
): string | undefined => {
return m.candles
?.reduce((acc: BigNumber, c: MarketInfoQuery_market_candles | null) => {
return acc.plus(new BigNumber(c?.volume ?? 0));
}, new BigNumber(m.candles?.[0]?.volume ?? 0))
return m.candlesConnection?.edges
?.reduce(
(
acc: BigNumber,
c: MarketInfoQuery_market_candlesConnection_edges | null
) => {
return acc.plus(new BigNumber(c?.node?.volume ?? 0));
},
new BigNumber(m.candlesConnection?.edges[0]?.node.volume ?? 0)
)
?.toString();
};

View File

@ -10,7 +10,7 @@ import { Interval } from "@vegaprotocol/types";
// ====================================================
export interface MarketCandlesQuery_marketsConnection_edges_node_candlesConnection_edges_node {
__typename: "CandleNode";
__typename: "Candle";
/**
* High price (uint64)
*/

View File

@ -10,7 +10,7 @@ import { Interval } from "@vegaprotocol/types";
// ====================================================
export interface MarketsCandlesQuery_marketsConnection_edges_node_candlesConnection_edges_node {
__typename: "CandleNode";
__typename: "Candle";
/**
* High price (uint64)
*/

View File

@ -54,7 +54,7 @@ const update = (data: Candle[], delta: MarketCandlesSub_candles) => {
...data,
{
...delta,
__typename: 'CandleNode',
__typename: 'Candle',
} as Candle,
]
: data;

View File

@ -28,7 +28,7 @@ export interface Trades_market_tradesConnection_edges_node {
*/
price: string;
/**
* The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64)
* The number of units traded, will always be <= the remaining size of both orders immediately before the trade (uint64)
*/
size: string;
/**

View File

@ -157,7 +157,7 @@ export enum OracleSpecStatus {
}
/**
* Reason for the order being rejected by the core node
* Why the order was rejected by the core node
*/
export enum OrderRejectionReason {
ORDER_ERROR_AMEND_FAILURE = "ORDER_ERROR_AMEND_FAILURE",
@ -252,7 +252,7 @@ export enum PropertyKeyType {
}
/**
* Reason for the proposal being rejected by the core node
* Why the proposal was rejected by the core node
*/
export enum ProposalRejectionReason {
PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE = "PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE",

View File

@ -85,7 +85,7 @@ export enum AccountType {
ACCOUNT_TYPE_PENDING_TRANSFERS = 'ACCOUNT_TYPE_PENDING_TRANSFERS',
/** RewardLpReceivedFees - an account holding rewards for a liquidity provider's received fees */
ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES = 'ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES',
/** RewardMakerPaidFees - an account holding rewards for taker paid fees */
/** RewardMakerPaidFees - an account holding rewards for maker paid fees */
ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES = 'ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES',
/** RewardMakerReceivedFees - an account holding rewards for maker received fees */
ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES = 'ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES',
@ -333,18 +333,16 @@ export type Candle = {
__typename?: 'Candle';
/** Close price (uint64) */
close: Scalars['String'];
/** RFC3339Nano formatted date and time for the candle */
datetime: Scalars['String'];
/** High price (uint64) */
high: Scalars['String'];
/** Interval price (string) */
interval: Interval;
/** RFC3339Nano formatted date and time for the candle end time, or last updated time if the candle is still open */
lastUpdateInPeriod: Scalars['String'];
/** Low price (uint64) */
low: Scalars['String'];
/** Open price (uint64) */
open: Scalars['String'];
/** Unix epoch+nanoseconds for when the candle occurred */
timestamp: Scalars['String'];
/** RFC3339Nano formatted date and time for the candle start time */
periodStart: Scalars['String'];
/** Volume price (uint64) */
volume: Scalars['String'];
};
@ -360,25 +358,7 @@ export type CandleDataConnection = {
export type CandleEdge = {
__typename?: 'CandleEdge';
cursor: Scalars['String'];
node: CandleNode;
};
export type CandleNode = {
__typename?: 'CandleNode';
/** Close price (uint64) */
close: Scalars['String'];
/** High price (uint64) */
high: Scalars['String'];
/** RFC3339Nano formatted date and time for the candle */
lastUpdate: Scalars['String'];
/** Low price (uint64) */
low: Scalars['String'];
/** Open price (uint64) */
open: Scalars['String'];
/** Unix epoch+nanoseconds for when the candle occurred */
start: Scalars['String'];
/** Volume price (uint64) */
volume: Scalars['String'];
node: Candle;
};
/** Condition describes the condition that must be validated by the oracle engine */
@ -824,8 +804,8 @@ export type Future = {
quoteName: Scalars['String'];
/** The name of the asset (string) */
settlementAsset: Asset;
/** The number of decimal places implied by the settlement price emitted by the settlement oracle */
settlementPriceDecimals: Scalars['Int'];
/** The number of decimal places implied by the settlement data (such as price) emitted by the settlement oracle */
settlementDataDecimals: Scalars['Int'];
};
export type FutureProduct = {
@ -843,8 +823,8 @@ export type FutureProduct = {
quoteName: Scalars['String'];
/** Product asset */
settlementAsset: Asset;
/** The number of decimal places implied by the settlement price emitted by the settlement oracle */
settlementPriceDecimals: Scalars['Int'];
/** The number of decimal places implied by the settlement data (such as price) emitted by the settlement oracle */
settlementDataDecimals: Scalars['Int'];
};
/** Describes something that can be traded on Vega */
@ -1178,11 +1158,6 @@ export type Market = {
accounts?: Maybe<Array<Account>>;
/** Get account for a party or market */
accountsConnection?: Maybe<AccountsConnection>;
/**
* Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters
* @deprecated Use the 'candlesConnection' field instead
*/
candles?: Maybe<Array<Maybe<Candle>>>;
/** Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters using cursor based pagination */
candlesConnection?: Maybe<CandleDataConnection>;
/** marketData for the given market */
@ -1274,13 +1249,6 @@ export type MarketaccountsConnectionArgs = {
};
/** Represents a product & associated parameters that can be traded on Vega, has an associated OrderBook and Trade history */
export type MarketcandlesArgs = {
interval: Interval;
since: Scalars['String'];
};
/** Represents a product & associated parameters that can be traded on Vega, has an associated OrderBook and Trade history */
export type MarketcandlesConnectionArgs = {
interval: Interval;
@ -2117,7 +2085,7 @@ export type OrderEstimate = {
totalFeeAmount: Scalars['String'];
};
/** Reason for the order being rejected by the core node */
/** Why the order was rejected by the core node */
export enum OrderRejectionReason {
/** Amending the order failed */
ORDER_ERROR_AMEND_FAILURE = 'ORDER_ERROR_AMEND_FAILURE',
@ -2805,7 +2773,7 @@ export type Proposal = {
rationale: ProposalRationale;
/** A UUID reference to aid tracking proposals on Vega */
reference: Scalars['String'];
/** Reason for the proposal to be rejected by the core */
/** Why the proposal was rejected by the core */
rejectionReason?: Maybe<ProposalRejectionReason>;
/** Required liquidity provider equity like share majority for this proposal to succeed */
requiredLpMajority?: Maybe<Scalars['String']>;
@ -2849,7 +2817,7 @@ export type ProposalRationale = {
title: Scalars['String'];
};
/** Reason for the proposal being rejected by the core node */
/** Why the proposal was rejected by the core node */
export enum ProposalRejectionReason {
/** The specified close time is too late based on network parameters */
PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE = 'PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE',
@ -4102,7 +4070,7 @@ export type Trade = {
sellerAuctionBatch?: Maybe<Scalars['Int']>;
/** The fee paid by the seller side of the trade */
sellerFee: TradeFee;
/** The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64) */
/** The number of units traded, will always be <= the remaining size of both orders immediately before the trade (uint64) */
size: Scalars['String'];
/** The type of trade */
type: TradeType;