Compare commits

...
129 changed files with 1652 additions and 2181 deletions
@@ -68,5 +68,5 @@ export interface Deposits {
/** /**
* The list of all assets in use in the Vega network or the specified asset if ID is provided * The list of all assets in use in the Vega network or the specified asset if ID is provided
*/ */
assetsConnection: Deposits_assetsConnection; assetsConnection: Deposits_assetsConnection | null;
} }
@@ -6,7 +6,7 @@ const defaultOptions = {} as const;
export type DepositsQueryVariables = Types.Exact<{ [key: string]: never; }>; export type DepositsQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type DepositsQuery = { __typename?: 'Query', assetsConnection: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } } | null> | null } }; export type DepositsQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } } | null> | null } | null };
export const DepositsDocument = gql` export const DepositsDocument = gql`
@@ -1,20 +1,15 @@
fragment SimpleMarketDataFields on MarketData { fragment SimpleMarketDataFields on ObservableMarketData {
market { marketId
id marketState
state
}
} }
query SimpleMarkets($CandleSince: String!) { query SimpleMarkets($CandleSince: String!) {
markets { markets {
id id
name
state state
data {
...SimpleMarketDataFields
}
tradableInstrument { tradableInstrument {
instrument { instrument {
name
code code
metadata { metadata {
tags tags
@@ -37,8 +32,8 @@ query SimpleMarkets($CandleSince: String!) {
} }
} }
subscription SimpleMarketDataSub { subscription SimpleMarketDataSub($marketIds: [ID!]!) {
marketData { marketsData(marketIds: $marketIds) {
...SimpleMarketDataFields ...SimpleMarketDataFields
} }
} }
@@ -1,30 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { MarketState } from "@vegaprotocol/types";
// ====================================================
// GraphQL fragment: SimpleMarketDataFields
// ====================================================
export interface SimpleMarketDataFields_market {
__typename: "Market";
/**
* Market ID
*/
id: string;
/**
* Current state of the market
*/
state: MarketState;
}
export interface SimpleMarketDataFields {
__typename: "MarketData";
/**
* market ID of the associated mark price
*/
market: SimpleMarketDataFields_market;
}
@@ -9,29 +9,25 @@ import { MarketState } from "@vegaprotocol/types";
// GraphQL subscription operation: SimpleMarketDataSub // GraphQL subscription operation: SimpleMarketDataSub
// ==================================================== // ====================================================
export interface SimpleMarketDataSub_marketData_market { export interface SimpleMarketDataSub_marketsData {
__typename: "Market"; __typename: "ObservableMarketData";
/** /**
* Market ID * current state of the market
*/ */
id: string; marketState: MarketState;
/**
* Current state of the market
*/
state: MarketState;
}
export interface SimpleMarketDataSub_marketData {
__typename: "MarketData";
/** /**
* market ID of the associated mark price * market ID of the associated mark price
*/ */
market: SimpleMarketDataSub_marketData_market; marketId: string;
} }
export interface SimpleMarketDataSub { export interface SimpleMarketDataSub {
/** /**
* Subscribe to the mark price changes * Subscribe to the mark price changes
*/ */
marketData: SimpleMarketDataSub_marketData; marketsData: SimpleMarketDataSub_marketsData[];
}
export interface SimpleMarketDataSubVariables {
marketIds: string[];
} }
@@ -3,39 +3,36 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client'; import * as Apollo from '@apollo/client';
const defaultOptions = {} as const; const defaultOptions = {} as const;
export type SimpleMarketDataFieldsFragment = { __typename?: 'MarketData', market: { __typename?: 'Market', id: string, state: Types.MarketState } }; export type SimpleMarketDataFieldsFragment = { __typename?: 'ObservableMarketData', marketId: string, marketState: Types.MarketState };
export type SimpleMarketsQueryVariables = Types.Exact<{ export type SimpleMarketsQueryVariables = Types.Exact<{
CandleSince: Types.Scalars['String']; CandleSince: Types.Scalars['String'];
}>; }>;
export type SimpleMarketsQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, name: string, state: Types.MarketState, data?: { __typename?: 'MarketData', market: { __typename?: 'Market', id: string, state: Types.MarketState } } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', symbol: string } } } }, candles?: Array<{ __typename?: 'Candle', open: string, close: string } | null> | null }> | null }; export type SimpleMarketsQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', symbol: string } } } }, candles?: Array<{ __typename?: 'Candle', open: string, close: string } | null> | null }> | null };
export type SimpleMarketDataSubSubscriptionVariables = Types.Exact<{ [key: string]: never; }>; export type SimpleMarketDataSubSubscriptionVariables = Types.Exact<{
marketIds: Array<Types.Scalars['ID']> | Types.Scalars['ID'];
}>;
export type SimpleMarketDataSubSubscription = { __typename?: 'Subscription', marketData: { __typename?: 'MarketData', market: { __typename?: 'Market', id: string, state: Types.MarketState } } }; export type SimpleMarketDataSubSubscription = { __typename?: 'Subscription', marketsData: Array<{ __typename?: 'ObservableMarketData', marketId: string, marketState: Types.MarketState }> };
export const SimpleMarketDataFieldsFragmentDoc = gql` export const SimpleMarketDataFieldsFragmentDoc = gql`
fragment SimpleMarketDataFields on MarketData { fragment SimpleMarketDataFields on ObservableMarketData {
market { marketId
id marketState
state
}
} }
`; `;
export const SimpleMarketsDocument = gql` export const SimpleMarketsDocument = gql`
query SimpleMarkets($CandleSince: String!) { query SimpleMarkets($CandleSince: String!) {
markets { markets {
id id
name
state state
data {
...SimpleMarketDataFields
}
tradableInstrument { tradableInstrument {
instrument { instrument {
name
code code
metadata { metadata {
tags tags
@@ -57,7 +54,7 @@ export const SimpleMarketsDocument = gql`
} }
} }
} }
${SimpleMarketDataFieldsFragmentDoc}`; `;
/** /**
* __useSimpleMarketsQuery__ * __useSimpleMarketsQuery__
@@ -87,8 +84,8 @@ export type SimpleMarketsQueryHookResult = ReturnType<typeof useSimpleMarketsQue
export type SimpleMarketsLazyQueryHookResult = ReturnType<typeof useSimpleMarketsLazyQuery>; export type SimpleMarketsLazyQueryHookResult = ReturnType<typeof useSimpleMarketsLazyQuery>;
export type SimpleMarketsQueryResult = Apollo.QueryResult<SimpleMarketsQuery, SimpleMarketsQueryVariables>; export type SimpleMarketsQueryResult = Apollo.QueryResult<SimpleMarketsQuery, SimpleMarketsQueryVariables>;
export const SimpleMarketDataSubDocument = gql` export const SimpleMarketDataSubDocument = gql`
subscription SimpleMarketDataSub { subscription SimpleMarketDataSub($marketIds: [ID!]!) {
marketData { marketsData(marketIds: $marketIds) {
...SimpleMarketDataFields ...SimpleMarketDataFields
} }
} }
@@ -106,10 +103,11 @@ export const SimpleMarketDataSubDocument = gql`
* @example * @example
* const { data, loading, error } = useSimpleMarketDataSubSubscription({ * const { data, loading, error } = useSimpleMarketDataSubSubscription({
* variables: { * variables: {
* marketIds: // value for 'marketIds'
* }, * },
* }); * });
*/ */
export function useSimpleMarketDataSubSubscription(baseOptions?: Apollo.SubscriptionHookOptions<SimpleMarketDataSubSubscription, SimpleMarketDataSubSubscriptionVariables>) { export function useSimpleMarketDataSubSubscription(baseOptions: Apollo.SubscriptionHookOptions<SimpleMarketDataSubSubscription, SimpleMarketDataSubSubscriptionVariables>) {
const options = {...defaultOptions, ...baseOptions} const options = {...defaultOptions, ...baseOptions}
return Apollo.useSubscription<SimpleMarketDataSubSubscription, SimpleMarketDataSubSubscriptionVariables>(SimpleMarketDataSubDocument, options); return Apollo.useSubscription<SimpleMarketDataSubSubscription, SimpleMarketDataSubSubscriptionVariables>(SimpleMarketDataSubDocument, options);
} }
@@ -42,12 +42,10 @@ export const MARKETS_QUERY = gql`
`; `;
const MARKET_DATA_SUB = gql` const MARKET_DATA_SUB = gql`
subscription SimpleMarketDataSub { subscription SimpleMarketDataSub($marketIds: [ID!]!) {
marketData { marketsData(marketIds: $marketIds) {
market { marketState
id marketId
state
}
} }
} }
`; `;
@@ -103,7 +103,7 @@ export interface PartyMarketData_party {
/** /**
* Margin levels for a market * Margin levels for a market
*/ */
marginsConnection: PartyMarketData_party_marginsConnection; marginsConnection: PartyMarketData_party_marginsConnection | null;
} }
export interface PartyMarketData { export interface PartyMarketData {
@@ -91,7 +91,7 @@ export interface MarketPositions_party {
/** /**
* Trading positions relating to a party * Trading positions relating to a party
*/ */
positionsConnection: MarketPositions_party_positionsConnection; positionsConnection: MarketPositions_party_positionsConnection | null;
} }
export interface MarketPositions { export interface MarketPositions {
@@ -8,7 +8,7 @@ export type MarketPositionsQueryVariables = Types.Exact<{
}>; }>;
export type MarketPositionsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', decimals: number }, market?: { __typename?: 'Market', id: string } | null }> | null, positionsConnection: { __typename?: 'PositionConnection', edges?: Array<{ __typename?: 'PositionEdge', node: { __typename?: 'Position', openVolume: string, market: { __typename?: 'Market', id: string } } }> | null } } | null }; export type MarketPositionsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', decimals: number }, market?: { __typename?: 'Market', id: string } | null }> | null, positionsConnection?: { __typename?: 'PositionConnection', edges?: Array<{ __typename?: 'PositionEdge', node: { __typename?: 'Position', openVolume: string, market: { __typename?: 'Market', id: string } } }> | null } | null } | null };
export const MarketPositionsDocument = gql` export const MarketPositionsDocument = gql`
@@ -8,7 +8,7 @@ export type PartyMarketDataQueryVariables = Types.Exact<{
}>; }>;
export type PartyMarketDataQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, decimals: number }, market?: { __typename?: 'Market', id: string } | null }> | null, marginsConnection: { __typename?: 'MarginConnection', edges?: Array<{ __typename?: 'MarginEdge', node: { __typename?: 'MarginLevels', initialLevel: string, maintenanceLevel: string, searchLevel: string, market: { __typename?: 'Market', id: string } } }> | null } } | null }; export type PartyMarketDataQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, decimals: number }, market?: { __typename?: 'Market', id: string } | null }> | null, marginsConnection?: { __typename?: 'MarginConnection', edges?: Array<{ __typename?: 'MarginEdge', node: { __typename?: 'MarginLevels', initialLevel: string, maintenanceLevel: string, searchLevel: string, market: { __typename?: 'Market', id: string } } }> | null } | null } | null };
export const PartyMarketDataDocument = gql` export const PartyMarketDataDocument = gql`
@@ -96,5 +96,5 @@ export interface AssetsQuery {
/** /**
* The list of all assets in use in the Vega network or the specified asset if ID is provided * The list of all assets in use in the Vega network or the specified asset if ID is provided
*/ */
assetsConnection: AssetsQuery_assetsConnection; assetsConnection: AssetsQuery_assetsConnection | null;
} }
@@ -6,7 +6,7 @@ const defaultOptions = {} as const;
export type AssetsQueryQueryVariables = Types.Exact<{ [key: string]: never; }>; export type AssetsQueryQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type AssetsQueryQuery = { __typename?: 'Query', assetsConnection: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string }, infrastructureFeeAccount: { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null } } } | null> | null } }; export type AssetsQueryQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string }, infrastructureFeeAccount: { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null } } } | null> | null } | null };
export const AssetsQueryDocument = gql` export const AssetsQueryDocument = gql`
@@ -1,5 +1,6 @@
import compact from 'lodash/compact';
import { gql, useQuery } from '@apollo/client'; import { gql, useQuery } from '@apollo/client';
import { getAssets, t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import React from 'react'; import React from 'react';
import { RouteTitle } from '../../components/route-title'; import { RouteTitle } from '../../components/route-title';
import { SubHeading } from '../../components/sub-heading'; import { SubHeading } from '../../components/sub-heading';
@@ -39,7 +40,7 @@ export const ASSETS_QUERY = gql`
const Assets = () => { const Assets = () => {
const { data } = useQuery<AssetsQuery>(ASSETS_QUERY); const { data } = useQuery<AssetsQuery>(ASSETS_QUERY);
const assets = getAssets(data); const assets = compact(data?.assetsConnection?.edges).map((e) => e.node);
return ( return (
<section> <section>
@@ -302,5 +302,5 @@ export interface ProposalsQuery {
/** /**
* All governance proposals in the Vega network * All governance proposals in the Vega network
*/ */
proposalsConnection: ProposalsQuery_proposalsConnection; proposalsConnection: ProposalsQuery_proposalsConnection | null;
} }
@@ -1,3 +1,4 @@
import compact from 'lodash/compact';
import { gql, useQuery } from '@apollo/client'; import { gql, useQuery } from '@apollo/client';
import { t } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/react-helpers';
import React from 'react'; import React from 'react';
@@ -99,9 +100,10 @@ const Governance = () => {
const { data } = useQuery<ProposalsQuery>(PROPOSALS_QUERY, { const { data } = useQuery<ProposalsQuery>(PROPOSALS_QUERY, {
errorPolicy: 'ignore', errorPolicy: 'ignore',
}); });
const proposals = getProposals(
data const proposals = compact(data?.proposalsConnection?.edges).map(
) as ProposalsQuery_proposalsConnection_edges_node[]; (e) => e.node
);
if (!data) return null; if (!data) return null;
return ( return (
@@ -1,7 +1,6 @@
query MarketsQuery { query MarketsQuery {
markets { markets {
id id
name
fees { fees {
factors { factors {
makerFee makerFee
@@ -6,14 +6,13 @@ const defaultOptions = {} as const;
export type MarketsQueryQueryVariables = Types.Exact<{ [key: string]: never; }>; export type MarketsQueryQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type MarketsQueryQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, name: string, decimalPlaces: number, tradingMode: Types.MarketTradingMode, state: Types.MarketState, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, id: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, name: string, decimals: number, globalRewardPoolAccount?: { __typename?: 'Account', balance: string } | null } } }, riskModel: { __typename?: 'LogNormalRiskModel', tau: number, riskAversionParameter: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } }, marginCalculator?: { __typename?: 'MarginCalculator', scalingFactors: { __typename?: 'ScalingFactors', searchLevel: number, initialMargin: number, collateralRelease: number } } | null }, openingAuction: { __typename?: 'AuctionDuration', durationSecs: number, volume: number }, priceMonitoringSettings: { __typename?: 'PriceMonitoringSettings', parameters?: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null } | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: number, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, proposal?: { __typename?: 'Proposal', id?: string | null } | null, accounts?: Array<{ __typename?: 'Account', balance: string, type: Types.AccountType, asset: { __typename?: 'Asset', id: string, name: string } }> | null, data?: { __typename?: 'MarketData', markPrice: string, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, midPrice: string, staticMidPrice: string, timestamp: string, openInterest: string, auctionEnd?: string | null, auctionStart?: string | null, indicativePrice: string, indicativeVolume: string, trigger: Types.AuctionTrigger, extensionTrigger: Types.AuctionTrigger, targetStake?: string | null, suppliedStake?: string | null, marketValueProxy: string, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', auctionExtensionSecs: number, probability: number } }> | null, liquidityProviderFeeShare?: Array<{ __typename?: 'LiquidityProviderFeeShare', equityLikeShare: string, averageEntryValuation: string, party: { __typename?: 'Party', id: string } }> | null } | null }> | null }; export type MarketsQueryQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, decimalPlaces: number, tradingMode: Types.MarketTradingMode, state: Types.MarketState, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, id: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, name: string, decimals: number, globalRewardPoolAccount?: { __typename?: 'Account', balance: string } | null } } }, riskModel: { __typename?: 'LogNormalRiskModel', tau: number, riskAversionParameter: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } }, marginCalculator?: { __typename?: 'MarginCalculator', scalingFactors: { __typename?: 'ScalingFactors', searchLevel: number, initialMargin: number, collateralRelease: number } } | null }, openingAuction: { __typename?: 'AuctionDuration', durationSecs: number, volume: number }, priceMonitoringSettings: { __typename?: 'PriceMonitoringSettings', parameters?: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null } | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: number, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, proposal?: { __typename?: 'Proposal', id?: string | null } | null, accounts?: Array<{ __typename?: 'Account', balance: string, type: Types.AccountType, asset: { __typename?: 'Asset', id: string, name: string } }> | null, data?: { __typename?: 'MarketData', markPrice: string, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, midPrice: string, staticMidPrice: string, timestamp: string, openInterest: string, auctionEnd?: string | null, auctionStart?: string | null, indicativePrice: string, indicativeVolume: string, trigger: Types.AuctionTrigger, extensionTrigger: Types.AuctionTrigger, targetStake?: string | null, suppliedStake?: string | null, marketValueProxy: string, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', auctionExtensionSecs: number, probability: number } }> | null, liquidityProviderFeeShare?: Array<{ __typename?: 'LiquidityProviderFeeShare', equityLikeShare: string, averageEntryValuation: string, party: { __typename?: 'Party', id: string } }> | null } | null }> | null };
export const MarketsQueryDocument = gql` export const MarketsQueryDocument = gql`
query MarketsQuery { query MarketsQuery {
markets { markets {
id id
name
fees { fees {
factors { factors {
makerFee makerFee
@@ -48,7 +48,7 @@ export interface ProposalFields_terms_change_NewMarket_instrument_futureProduct_
export interface ProposalFields_terms_change_NewMarket_instrument_futureProduct { export interface ProposalFields_terms_change_NewMarket_instrument_futureProduct {
__typename: "FutureProduct"; __typename: "FutureProduct";
/** /**
* Product asset ID * Product asset
*/ */
settlementAsset: ProposalFields_terms_change_NewMarket_instrument_futureProduct_settlementAsset; settlementAsset: ProposalFields_terms_change_NewMarket_instrument_futureProduct_settlementAsset;
} }
@@ -10,7 +10,7 @@ export type ProposalQueryVariables = Types.Exact<{
}>; }>;
export type ProposalQuery = { __typename?: 'Query', proposal: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: string, enactmentDatetime?: string | null, change: { __typename: 'NewAsset', name: string, symbol: string, source: { __typename: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename: 'ERC20', contractAddress: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', decimalPlaces: number, metadata?: Array<string> | null, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null } } } }; export type ProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: string, enactmentDatetime?: string | null, change: { __typename: 'NewAsset', name: string, symbol: string, source: { __typename: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename: 'ERC20', contractAddress: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', decimalPlaces: number, metadata?: Array<string> | null, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null } } } | null };
export type ProposalsQueryVariables = Types.Exact<{ [key: string]: never; }>; export type ProposalsQueryVariables = Types.Exact<{ [key: string]: never; }>;
@@ -6,7 +6,7 @@ import { ProposalVotesTable } from '../proposal-votes-table';
import { VoteDetails } from '../vote-details'; import { VoteDetails } from '../vote-details';
interface ProposalProps { interface ProposalProps {
proposal: Proposal_proposal; proposal: Proposal_proposal | null;
} }
export const Proposal = ({ proposal }: ProposalProps) => { export const Proposal = ({ proposal }: ProposalProps) => {
@@ -48,7 +48,7 @@ export interface Proposal_proposal_terms_change_NewMarket_instrument_futureProdu
export interface Proposal_proposal_terms_change_NewMarket_instrument_futureProduct { export interface Proposal_proposal_terms_change_NewMarket_instrument_futureProduct {
__typename: "FutureProduct"; __typename: "FutureProduct";
/** /**
* Product asset ID * Product asset
*/ */
settlementAsset: Proposal_proposal_terms_change_NewMarket_instrument_futureProduct_settlementAsset; settlementAsset: Proposal_proposal_terms_change_NewMarket_instrument_futureProduct_settlementAsset;
} }
@@ -318,7 +318,7 @@ export interface Proposal {
/** /**
* A governance proposal located by either its ID or reference. If both are set, ID is used. * A governance proposal located by either its ID or reference. If both are set, ID is used.
*/ */
proposal: Proposal_proposal; proposal: Proposal_proposal | null;
} }
export interface ProposalVariables { export interface ProposalVariables {
@@ -48,7 +48,7 @@ export interface Proposals_proposalsConnection_edges_node_terms_change_NewMarket
export interface Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument_futureProduct { export interface Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument_futureProduct {
__typename: "FutureProduct"; __typename: "FutureProduct";
/** /**
* Product asset ID * Product asset
*/ */
settlementAsset: Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument_futureProduct_settlementAsset; settlementAsset: Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument_futureProduct_settlementAsset;
} }
@@ -334,5 +334,5 @@ export interface Proposals {
/** /**
* All governance proposals in the Vega network * All governance proposals in the Vega network
*/ */
proposalsConnection: Proposals_proposalsConnection; proposalsConnection: Proposals_proposalsConnection | null;
} }
@@ -1,13 +1,14 @@
import compact from 'lodash/compact';
import orderBy from 'lodash/orderBy';
import { gql, useQuery } from '@apollo/client'; import { gql, useQuery } from '@apollo/client';
import { getNotRejectedProposals } from '@vegaprotocol/governance';
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit'; import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { SplashLoader } from '../../../components/splash-loader'; import { SplashLoader } from '../../../components/splash-loader';
import { ProposalsList } from '../components/proposals-list'; import { ProposalsList } from '../components/proposals-list';
import { PROPOSAL_FRAGMENT } from '../proposal-fragment'; import { PROPOSAL_FRAGMENT } from '../proposal-fragment';
import type { Proposals } from './__generated__/Proposals'; import type { Proposals } from './__generated__/Proposals';
import { ProposalState } from '@vegaprotocol/types';
export const PROPOSALS_QUERY = gql` export const PROPOSALS_QUERY = gql`
${PROPOSAL_FRAGMENT} ${PROPOSAL_FRAGMENT}
@@ -30,7 +31,18 @@ export const ProposalsContainer = () => {
errorPolicy: 'ignore', errorPolicy: 'ignore',
}); });
const proposals = useMemo(() => getNotRejectedProposals(data), [data]); const proposals = compact(data?.proposalsConnection?.edges)
.map((e) => e.node)
.filter((p) => p.state !== ProposalState.STATE_REJECTED);
const orderedProposals = orderBy(
proposals,
[
(p) => new Date(p.terms.enactmentDatetime || 0).getTime(), // has to be defaulted to 0 because new Date(null).getTime() -> NaN which is first when ordered.
(p) => new Date(p.terms.closingDatetime).getTime(),
(p) => p.id,
],
['desc', 'desc', 'desc']
);
if (error) { if (error) {
return ( return (
@@ -48,5 +60,5 @@ export const ProposalsContainer = () => {
); );
} }
return <ProposalsList proposals={proposals} />; return <ProposalsList proposals={orderedProposals} />;
}; };
@@ -1,3 +1,5 @@
import compact from 'lodash/compact';
import orderBy from 'lodash/orderBy';
import { useQuery } from '@apollo/client'; import { useQuery } from '@apollo/client';
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit'; import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
import { useMemo } from 'react'; import { useMemo } from 'react';
@@ -5,15 +7,26 @@ import { useTranslation } from 'react-i18next';
import { SplashLoader } from '../../../components/splash-loader'; import { SplashLoader } from '../../../components/splash-loader';
import { RejectedProposalsList } from '../components/proposals-list'; import { RejectedProposalsList } from '../components/proposals-list';
import { getRejectedProposals } from '@vegaprotocol/governance';
import { PROPOSALS_QUERY } from '../proposals'; import { PROPOSALS_QUERY } from '../proposals';
import type { Proposals } from '../proposals/__generated__/Proposals'; import type { Proposals } from '../proposals/__generated__/Proposals';
import { ProposalState } from '@vegaprotocol/types';
export const RejectedProposalsContainer = () => { export const RejectedProposalsContainer = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const { data, loading, error } = useQuery<Proposals>(PROPOSALS_QUERY); const { data, loading, error } = useQuery<Proposals>(PROPOSALS_QUERY);
const proposals = useMemo(() => getRejectedProposals(data), [data]); const proposals = compact(data?.proposalsConnection?.edges)
.map((e) => e.node)
.filter((p) => p.state === ProposalState.STATE_REJECTED);
const orderedProposals = orderBy(
proposals,
[
(p) => new Date(p.terms.enactmentDatetime || 0).getTime(), // has to be defaulted to 0 because new Date(null).getTime() -> NaN which is first when ordered.
(p) => new Date(p.terms.closingDatetime).getTime(),
(p) => p.id,
],
['desc', 'desc', 'desc']
);
if (error) { if (error) {
return ( return (
@@ -31,5 +44,5 @@ export const RejectedProposalsContainer = () => {
); );
} }
return <RejectedProposalsList proposals={proposals} />; return <RejectedProposalsList proposals={orderedProposals} />;
}; };
@@ -127,7 +127,7 @@ describe('markets table', () => {
} }
function verifyMarketSummaryDisplayed() { function verifyMarketSummaryDisplayed() {
const marketSummaryBlock = 'market-summary'; const marketSummaryBlock = 'header-summary';
const percentageValue = 'price-change-percentage'; const percentageValue = 'price-change-percentage';
const priceChangeValue = 'price-change'; const priceChangeValue = 'price-change';
const tradingVolume = 'trading-volume'; const tradingVolume = 'trading-volume';
+1 -1
View File
@@ -1,6 +1,6 @@
# App configuration variables # App configuration variables
NX_VEGA_ENV=TESTNET NX_VEGA_ENV=TESTNET
NX_VEGA_URL=https://api.n09.testnet.vega.xyz/graphql NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8 NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
NX_ETHERSCAN_URL=https://ropsten.etherscan.io NX_ETHERSCAN_URL=https://ropsten.etherscan.io
NX_VEGA_NETWORKS={\"MAINNET\":\"https://alpha.console.vega.xyz\"} NX_VEGA_NETWORKS={\"MAINNET\":\"https://alpha.console.vega.xyz\"}
+1 -1
View File
@@ -1,6 +1,6 @@
export const Footer = () => { export const Footer = () => {
return ( return (
<footer className="px-4 py-2 text-xs border-t border-neutral-300 dark:border-neutral-600 bg-neutral-100 dark:bg-neutral-800"> <footer className="px-4 py-2 text-xs border-t border-default bg-neutral-100 dark:bg-neutral-800">
<div className="flex justify-between"> <div className="flex justify-between">
<div>Status</div> <div>Status</div>
</div> </div>
+10 -9
View File
@@ -5,19 +5,20 @@ import { cloneElement } from 'react';
interface TradeMarketHeaderProps { interface TradeMarketHeaderProps {
title: ReactNode; title: ReactNode;
children: ReactElement[]; children: Array<ReactElement | null>;
} }
export const Header = ({ title, children }: TradeMarketHeaderProps) => { export const Header = ({ title, children }: TradeMarketHeaderProps) => {
return ( return (
<header className="w-screen xl:px-4 pt-4 border-b border-neutral-300 dark:border-neutral-600"> <header className="w-screen xl:px-4 pt-4 border-b border-default">
<div className="xl:flex xl:gap-4 items-start"> <div className="xl:flex xl:gap-4 items-start">
<div className="px-4 mb-2">{title}</div> <div className="mb-4 xl:mb-0">{title}</div>
<div <div
data-testid="market-summary" data-testid="header-summary"
className="flex flex-nowrap items-start xl:flex-1 w-full overflow-x-auto text-xs " className="flex flex-nowrap items-start xl:flex-1 w-full overflow-x-auto text-xs "
> >
{Children.map(children, (child, index) => { {Children.map(children, (child, index) => {
if (!child) return null;
return cloneElement(child, { return cloneElement(child, {
id: `header-stat-${index}`, id: `header-stat-${index}`,
}); });
@@ -40,17 +41,17 @@ export const HeaderStat = ({
description?: string | ReactNode; description?: string | ReactNode;
}) => { }) => {
const itemClass = const itemClass =
'min-w-min w-[120px] whitespace-nowrap pb-3 px-4 border-l border-neutral-300 dark:border-neutral-600'; 'min-w-min w-[120px] whitespace-nowrap pb-3 px-4 border-l border-default';
const itemHeading = 'text-neutral-400'; const itemHeading = 'text-neutral-500 dark:text-neutral-400';
return ( return (
<div className={itemClass}> <div className={itemClass}>
<div id={id}>{heading}</div>
<Tooltip description={description}> <Tooltip description={description}>
<div id={id} className={itemHeading}> <div aria-labelledby={id} className={itemHeading}>
{heading} {children}
</div> </div>
</Tooltip> </Tooltip>
<div aria-labelledby={id}>{children}</div>
</div> </div>
); );
}; };
+1 -1
View File
@@ -1,7 +1,7 @@
import classNames from 'classnames'; import classNames from 'classnames';
export function Vega({ className }: { className?: string }) { export function Vega({ className }: { className?: string }) {
const svgClasses = classNames(className, 'fill-white'); const svgClasses = classNames(className, 'fill-current');
return ( return (
<svg <svg
width="86" width="86"
+2 -2
View File
@@ -20,7 +20,7 @@ export const Navbar = ({ theme, toggleTheme }: NavbarProps) => {
})); }));
const tradingPath = marketId ? `/markets/${marketId}` : '/markets'; const tradingPath = marketId ? `/markets/${marketId}` : '/markets';
return ( return (
<div className="px-4 flex items-stretch border-b border-neutral-300 dark:border-neutral-400 bg-black"> <div className="px-4 flex items-stretch border-b border-default bg-black text-white">
<div className="flex gap-4 mr-4 items-center h-full"> <div className="flex gap-4 mr-4 items-center h-full">
<Link href="/" passHref={true}> <Link href="/" passHref={true}>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
@@ -28,7 +28,7 @@ export const Navbar = ({ theme, toggleTheme }: NavbarProps) => {
<Vega className="w-13" /> <Vega className="w-13" />
</a> </a>
</Link> </Link>
<NetworkSwitcher fixedBg="dark" /> <NetworkSwitcher theme="dark" />
</div> </div>
<nav className="flex items-center"> <nav className="flex items-center">
{[ {[
@@ -30,7 +30,6 @@ export const VegaWalletConnectButton = ({
return ( return (
<DropdownMenu open={dropdownOpen}> <DropdownMenu open={dropdownOpen}>
<DropdownMenuTrigger <DropdownMenuTrigger
className="text-white hover:!bg-neutral-700"
data-testid="manage-vega-wallet" data-testid="manage-vega-wallet"
onClick={() => setDropdownOpen((curr) => !curr)} onClick={() => setDropdownOpen((curr) => !curr)}
> >
@@ -1,7 +1,6 @@
query Market($marketId: ID!, $interval: Interval!, $since: String!) { query Market($marketId: ID!, $interval: Interval!, $since: String!) {
market(id: $marketId) { market(id: $marketId) {
id id
name
tradingMode tradingMode
state state
decimalPlaces decimalPlaces
+3 -3
View File
@@ -20,7 +20,7 @@ export interface Market_market_data_market {
export interface Market_market_data { export interface Market_market_data {
__typename: "MarketData"; __typename: "MarketData";
/** /**
* market ID of the associated mark price * market of the associated mark price
*/ */
market: Market_market_data_market; market: Market_market_data_market;
/** /**
@@ -202,14 +202,14 @@ export interface Market_market {
/** /**
* decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct * decimalPlaces indicates 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) * number denominated in the currency of the market. (uint64)
* *
* Examples: * Examples:
* Currency Balance decimalPlaces Real Balance * Currency Balance decimalPlaces Real Balance
* GBP 100 0 GBP 100 * GBP 100 0 GBP 100
* GBP 100 2 GBP 1.00 * GBP 100 2 GBP 1.00
* GBP 100 4 GBP 0.01 * GBP 100 4 GBP 0.01
* GBP 1 4 GBP 0.0001 ( 0.01p ) * GBP 1 4 GBP 0.0001 ( 0.01p )
* *
* GBX (pence) 100 0 GBP 1.00 (100p ) * GBX (pence) 100 0 GBP 1.00 (100p )
* GBX (pence) 100 2 GBP 0.01 ( 1p ) * GBX (pence) 100 2 GBP 0.01 ( 1p )
* GBX (pence) 100 4 GBP 0.0001 ( 0.01p ) * GBX (pence) 100 4 GBP 0.0001 ( 0.01p )
@@ -10,14 +10,13 @@ export type MarketQueryVariables = Types.Exact<{
}>; }>;
export type MarketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, name: 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 } } } }, 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 }, candles?: Array<{ __typename?: 'Candle', open: string, close: string, volume: string } | null> | null } | null };
export const MarketDocument = gql` export const MarketDocument = gql`
query Market($marketId: ID!, $interval: Interval!, $since: String!) { query Market($marketId: ID!, $interval: Interval!, $since: String!) {
market(id: $marketId) { market(id: $marketId) {
id id
name
tradingMode tradingMode
state state
decimalPlaces decimalPlaces
@@ -57,6 +56,7 @@ export const MarketDocument = gql`
id id
symbol symbol
name name
decimals
} }
} }
} }
+90 -126
View File
@@ -20,7 +20,6 @@ import {
ResizableGrid, ResizableGrid,
ResizableGridPanel, ResizableGridPanel,
ButtonLink, ButtonLink,
Tooltip,
PriceCellChange, PriceCellChange,
Link, Link,
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
@@ -41,6 +40,7 @@ import {
} from '@vegaprotocol/types'; } from '@vegaprotocol/types';
import { TradingModeTooltip } from '../../components/trading-mode-tooltip'; import { TradingModeTooltip } from '../../components/trading-mode-tooltip';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { Header, HeaderStat } from '../../components/header';
const TradingViews = { const TradingViews = {
Candles: CandlesChartContainer, Candles: CandlesChartContainer,
@@ -62,15 +62,16 @@ type ExpiryLabelProps = {
}; };
const ExpiryLabel = ({ market }: ExpiryLabelProps) => { const ExpiryLabel = ({ market }: ExpiryLabelProps) => {
let content = null;
if (market.marketTimestamps.close === null) { if (market.marketTimestamps.close === null) {
return <>{t('Not time-based')}</>; content = t('Not time-based');
} else {
const closeDate = new Date(market.marketTimestamps.close);
const isExpired = Date.now() - closeDate.valueOf() > 0;
const expiryDate = getDateFormat().format(closeDate);
content = `${isExpired ? `${t('Expired')} ` : ''} ${expiryDate}`;
} }
return <div data-testid="trading-expiry">{content}</div>;
const closeDate = new Date(market.marketTimestamps.close);
const isExpired = Date.now() - closeDate.valueOf() > 0;
const expiryDate = getDateFormat().format(closeDate);
return <>{`${isExpired ? `${t('Expired')} ` : ''} ${expiryDate}`}</>;
}; };
type ExpiryTooltipContentProps = { type ExpiryTooltipContentProps = {
@@ -115,6 +116,7 @@ export const TradeMarketHeader = ({
market, market,
onSelect, onSelect,
}: TradeMarketHeaderProps) => { }: TradeMarketHeaderProps) => {
const { push } = useRouter();
const { VEGA_EXPLORER_URL } = useEnvironment(); const { VEGA_EXPLORER_URL } = useEnvironment();
const { setAssetDetailsDialogOpen, setAssetDetailsDialogSymbol } = const { setAssetDetailsDialogOpen, setAssetDetailsDialogSymbol } =
useAssetDetailsDialogStore(); useAssetDetailsDialogStore();
@@ -122,123 +124,92 @@ export const TradeMarketHeader = ({
const candlesClose: string[] = (market?.candles || []) const candlesClose: string[] = (market?.candles || [])
.map((candle) => candle?.close) .map((candle) => candle?.close)
.filter((c): c is CandleClose => c !== null); .filter((c): c is CandleClose => c !== null);
const hasExpiry = market.marketTimestamps.close !== null;
const symbol = const symbol =
market.tradableInstrument.instrument.product?.settlementAsset?.symbol; market.tradableInstrument.instrument.product?.settlementAsset?.symbol;
const itemClass =
'min-w-min w-[120px] whitespace-nowrap pb-3 px-4 border-l border-neutral-300 dark:border-neutral-600';
const itemHeading = 'text-neutral-500 dark:text-neutral-400';
const { push } = useRouter();
return ( return (
<header className="w-screen px-4 border-b border-neutral-300 dark:border-neutral-600"> <Header
<div className="xl:flex xl:gap-4 items-start"> title={
<div> <SelectMarketPopover
<SelectMarketPopover marketName={market.tradableInstrument.instrument.name}
marketName={market.tradableInstrument.instrument.name} onSelect={onSelect}
onSelect={onSelect} />
}
>
<HeaderStat
heading={t('Expiry')}
description={
<ExpiryTooltipContent
market={market}
explorerUrl={VEGA_EXPLORER_URL}
/> />
}
>
<ExpiryLabel market={market} />
</HeaderStat>
<HeaderStat heading={t('Change (24h)')}>
<PriceCellChange
candles={candlesClose}
decimalPlaces={market.decimalPlaces}
/>
</HeaderStat>
<HeaderStat heading={t('Volume')}>
<div data-testid="trading-volume">
{market.data && market.data.indicativeVolume !== '0'
? addDecimalsFormatNumber(
market.data.indicativeVolume,
market.positionDecimalPlaces
)
: '-'}
</div> </div>
<div </HeaderStat>
data-testid="market-summary" <HeaderStat
className="flex flex-nowrap items-start mt-3 xl:flex-1 w-full overflow-x-auto text-xs " heading={t('Trading mode')}
> description={
<div className={itemClass}> <TradingModeTooltip
<div className={itemHeading}>{t('Expiry')}</div> market={market}
<Tooltip onSelect={(marketId: string) => {
align="start" onSelect(marketId);
description={ push(`/liquidity/${marketId}`);
<ExpiryTooltipContent }}
market={market} />
explorerUrl={VEGA_EXPLORER_URL} }
/> >
} <div data-testid="trading-mode">
> {market.tradingMode ===
<div MarketTradingMode.TRADING_MODE_MONITORING_AUCTION &&
data-testid="trading-expiry" market.data?.trigger &&
className={classNames({ market.data.trigger !== AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED
'underline decoration-dashed': !hasExpiry, ? `${MarketTradingModeMapping[market.tradingMode]}
})}
>
<ExpiryLabel market={market} />
</div>
</Tooltip>
</div>
<div className={itemClass}>
<div className={itemHeading}>{t('Change (24h)')}</div>
<PriceCellChange
candles={candlesClose}
decimalPlaces={market.decimalPlaces}
/>
</div>
<div className={itemClass}>
<div className={itemHeading}>{t('Volume')}</div>
<div data-testid="trading-volume">
{market.data && market.data.indicativeVolume !== '0'
? addDecimalsFormatNumber(
market.data.indicativeVolume,
market.positionDecimalPlaces
)
: '-'}
</div>
</div>
<div className={itemClass}>
<div className={itemHeading}>{t('Trading mode')}</div>
<Tooltip
align="start"
description={
<TradingModeTooltip
market={market}
onSelect={(marketId: string) => {
onSelect(marketId);
push(`/liquidity/${marketId}`);
}}
/>
}
>
<div data-testid="trading-mode">
{market.tradingMode ===
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION &&
market.data?.trigger &&
market.data.trigger !==
AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED
? `${MarketTradingModeMapping[market.tradingMode]}
- ${AuctionTriggerMapping[market.data.trigger]}` - ${AuctionTriggerMapping[market.data.trigger]}`
: MarketTradingModeMapping[market.tradingMode]} : MarketTradingModeMapping[market.tradingMode]}
</div>
</Tooltip>
</div>
<div className={itemClass}>
<div className={itemHeading}>{t('Price')}</div>
<div data-testid="mark-price">
{market.data && market.data.markPrice !== '0'
? addDecimalsFormatNumber(
market.data.markPrice,
market.decimalPlaces
)
: '-'}
</div>
</div>
{symbol && (
<div className={itemClass}>
<div className={itemHeading}>{t('Settlement asset')}</div>
<div data-testid="trading-mode">
<ButtonLink
onClick={() => {
setAssetDetailsDialogOpen(true);
setAssetDetailsDialogSymbol(symbol);
}}
>
{symbol}
</ButtonLink>
</div>
</div>
)}
</div> </div>
</div> </HeaderStat>
</header> <HeaderStat heading={t('Price')}>
<div data-testid="mark-price">
{market.data && market.data.markPrice !== '0'
? addDecimalsFormatNumber(
market.data.markPrice,
market.decimalPlaces
)
: '-'}
</div>
</HeaderStat>
{symbol ? (
<HeaderStat heading={t('Settlement asset')}>
<div data-testid="trading-mode">
<ButtonLink
onClick={() => {
setAssetDetailsDialogOpen(true);
setAssetDetailsDialogSymbol(symbol);
}}
>
{symbol}
</ButtonLink>
</div>
</HeaderStat>
) : null}
</Header>
); );
}; };
@@ -346,14 +317,7 @@ const TradeGridChild = ({ children }: TradeGridChildProps) => {
return ( return (
<section className="h-full"> <section className="h-full">
<AutoSizer> <AutoSizer>
{({ width, height }) => ( {({ width, height }) => <div style={{ width, height }}>{children}</div>}
<div
style={{ width, height }}
className="overflow-auto border-[1px] dark:border-neutral-600"
>
{children}
</div>
)}
</AutoSizer> </AutoSizer>
</section> </section>
); );
@@ -398,7 +362,7 @@ export const TradePanels = ({ market, onSelect }: TradePanelsProps) => {
)} )}
</AutoSizer> </AutoSizer>
</div> </div>
<div className="flex flex-nowrap overflow-x-auto max-w-full border-t border-neutral-300 dark:border-neutral-600"> <div className="flex flex-nowrap overflow-x-auto max-w-full border-t border-default">
{Object.keys(TradingViews).map((key) => { {Object.keys(TradingViews).map((key) => {
const isActive = view === key; const isActive = view === key;
const className = classNames('p-4 min-w-[100px] capitalize', { const className = classNames('p-4 min-w-[100px] capitalize', {
@@ -1,46 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL fragment: AssetFields
// ====================================================
export interface AssetFields_source_BuiltinAsset {
__typename: "BuiltinAsset";
}
export interface AssetFields_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type AssetFields_source = AssetFields_source_BuiltinAsset | AssetFields_source_ERC20;
export interface AssetFields {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
/**
* The origin source of the asset (e.g: an ERC20 asset)
*/
source: AssetFields_source;
}
@@ -1,119 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AccountType } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: WithdrawFormQuery
// ====================================================
export interface WithdrawFormQuery_party_withdrawals {
__typename: "Withdrawal";
/**
* The Vega internal ID of the withdrawal
*/
id: string;
/**
* Hash of the transaction on the foreign chain
*/
txHash: string | null;
}
export interface WithdrawFormQuery_party_accounts_asset {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
}
export interface WithdrawFormQuery_party_accounts {
__typename: "Account";
/**
* Account type (General, Margin, etc)
*/
type: AccountType;
/**
* Balance as string - current account balance (approx. as balances can be updated several times per second)
*/
balance: string;
/**
* Asset, the 'currency'
*/
asset: WithdrawFormQuery_party_accounts_asset;
}
export interface WithdrawFormQuery_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
/**
* The list of all withdrawals initiated by the party
*/
withdrawals: WithdrawFormQuery_party_withdrawals[] | null;
/**
* Collateral accounts relating to a party
*/
accounts: WithdrawFormQuery_party_accounts[] | null;
}
export interface WithdrawFormQuery_assets_source_BuiltinAsset {
__typename: "BuiltinAsset";
}
export interface WithdrawFormQuery_assets_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type WithdrawFormQuery_assets_source = WithdrawFormQuery_assets_source_BuiltinAsset | WithdrawFormQuery_assets_source_ERC20;
export interface WithdrawFormQuery_assets {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
/**
* The origin source of the asset (e.g: an ERC20 asset)
*/
source: WithdrawFormQuery_assets_source;
}
export interface WithdrawFormQuery {
/**
* An entity that is trading on the Vega network
*/
party: WithdrawFormQuery_party | null;
/**
* The list of all assets in use in the Vega network
*/
assets: WithdrawFormQuery_assets[] | null;
}
export interface WithdrawFormQueryVariables {
partyId: string;
}
@@ -68,5 +68,5 @@ export interface DepositPage {
/** /**
* The list of all assets in use in the Vega network or the specified asset if ID is provided * The list of all assets in use in the Vega network or the specified asset if ID is provided
*/ */
assetsConnection: DepositPage_assetsConnection; assetsConnection: DepositPage_assetsConnection | null;
} }
@@ -6,7 +6,7 @@ const defaultOptions = {} as const;
export type DepositPageQueryVariables = Types.Exact<{ [key: string]: never; }>; export type DepositPageQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type DepositPageQuery = { __typename?: 'Query', assetsConnection: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } } | null> | null } }; export type DepositPageQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } } | null> | null } | null };
export const DepositPageDocument = gql` export const DepositPageDocument = gql`
+4
View File
@@ -18,3 +18,7 @@ html.dark {
--focus-border: theme('colors.vega.yellow'); --focus-border: theme('colors.vega.yellow');
--separator-border: theme('colors.neutral.600'); --separator-border: theme('colors.neutral.600');
} }
.border-default {
@apply border-neutral-300 dark:border-neutral-600;
}
+20 -15
View File
@@ -1,26 +1,29 @@
fragment AccountFields on Account { fragment AccountFields on AccountUpdate {
type type
balance balance
market { assetId
id marketId
tradableInstrument {
instrument {
name
}
}
}
asset {
id
symbol
decimals
}
} }
query Accounts($partyId: ID!) { query Accounts($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
accounts { accounts {
...AccountFields type
balance
market {
id
tradableInstrument {
instrument {
name
}
}
}
asset {
id
symbol
decimals
}
} }
} }
} }
@@ -28,5 +31,7 @@ query Accounts($partyId: ID!) {
subscription AccountEvents($partyId: ID!) { subscription AccountEvents($partyId: ID!) {
accounts(partyId: $partyId) { accounts(partyId: $partyId) {
...AccountFields ...AccountFields
marketId
assetId
} }
} }
@@ -3,7 +3,7 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client'; import * as Apollo from '@apollo/client';
const defaultOptions = {} as const; const defaultOptions = {} as const;
export type AccountFieldsFragment = { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string } } } | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } }; export type AccountFieldsFragment = { __typename?: 'AccountUpdate', type: Types.AccountType, balance: string, assetId: string, marketId?: string | null };
export type AccountsQueryVariables = Types.Exact<{ export type AccountsQueryVariables = Types.Exact<{
partyId: Types.Scalars['ID']; partyId: Types.Scalars['ID'];
@@ -17,25 +17,14 @@ export type AccountEventsSubscriptionVariables = Types.Exact<{
}>; }>;
export type AccountEventsSubscription = { __typename?: 'Subscription', accounts: { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string } } } | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } }; export type AccountEventsSubscription = { __typename?: 'Subscription', accounts: Array<{ __typename?: 'AccountUpdate', marketId?: string | null, assetId: string, type: Types.AccountType, balance: string }> };
export const AccountFieldsFragmentDoc = gql` export const AccountFieldsFragmentDoc = gql`
fragment AccountFields on Account { fragment AccountFields on AccountUpdate {
type type
balance balance
market { assetId
id marketId
tradableInstrument {
instrument {
name
}
}
}
asset {
id
symbol
decimals
}
} }
`; `;
export const AccountsDocument = gql` export const AccountsDocument = gql`
@@ -43,11 +32,25 @@ export const AccountsDocument = gql`
party(id: $partyId) { party(id: $partyId) {
id id
accounts { accounts {
...AccountFields type
balance
market {
id
tradableInstrument {
instrument {
name
}
}
}
asset {
id
symbol
decimals
}
} }
} }
} }
${AccountFieldsFragmentDoc}`; `;
/** /**
* __useAccountsQuery__ * __useAccountsQuery__
@@ -80,6 +83,8 @@ export const AccountEventsDocument = gql`
subscription AccountEvents($partyId: ID!) { subscription AccountEvents($partyId: ID!) {
accounts(partyId: $partyId) { accounts(partyId: $partyId) {
...AccountFields ...AccountFields
marketId
assetId
} }
} }
${AccountFieldsFragmentDoc}`; ${AccountFieldsFragmentDoc}`;
+55 -16
View File
@@ -2,51 +2,90 @@ import produce from 'immer';
import { import {
AccountsDocument, AccountsDocument,
AccountEventsDocument, AccountEventsDocument,
} from './__generated__/Accounts'; } from './__generated___/Accounts';
import type { import type {
AccountFieldsFragment,
AccountsQuery, AccountsQuery,
AccountEventsSubscription, AccountEventsSubscription,
} from './__generated__/Accounts'; AccountFieldsFragment,
} from './__generated___/Accounts';
import { makeDataProvider } from '@vegaprotocol/react-helpers'; import { makeDataProvider } from '@vegaprotocol/react-helpers';
import type { AccountType } from '@vegaprotocol/types';
export const getId = (data: AccountFieldsFragment) => interface Account {
type: AccountType;
balance: string;
market: {
id: string;
name: string;
} | null;
asset: {
symbol: string;
decimals: number;
};
}
export const getId = (data: Account) =>
`${data.type}-${data.asset.symbol}-${data.market?.id ?? 'null'}`; `${data.type}-${data.asset.symbol}-${data.market?.id ?? 'null'}`;
const update = ( const update = (data: Account[], delta: Account[]) => {
data: AccountFieldsFragment[],
delta: AccountFieldsFragment
) => {
return produce(data, (draft) => { return produce(data, (draft) => {
// @ts-ignore FIXME stagnet3 update
const id = getId(delta); const id = getId(delta);
const index = draft.findIndex((a) => getId(a) === id); const index = draft.findIndex((a) => getId(a) === id);
if (index !== -1) { if (index !== -1) {
// @ts-ignore FIXME stagnet3 update
draft[index] = delta; draft[index] = delta;
} else { } else {
// @ts-ignore FIXME stagnet3 update
draft.push(delta); draft.push(delta);
} }
}); });
}; };
const getData = ( const getData = (responseData: AccountsQuery): Account[] | null => {
responseData: AccountsQuery if (!responseData?.party?.accounts?.length) return null;
): AccountFieldsFragment[] | null => { return responseData.party?.accounts?.map((a) => {
return responseData.party?.accounts ?? null; return {
type: a.type,
balance: a.balance,
market: a.market
? {
id: a.market.id,
name: a.market.tradableInstrument.instrument.name,
}
: null,
asset: {
symbol: a.asset.symbol,
decimals: a.asset.decimals,
},
};
});
}; };
const getDelta = ( const getDelta = (subscriptionData: AccountEventsSubscription): Account[] => {
subscriptionData: AccountEventsSubscription // return subscriptionData.accounts
): AccountFieldsFragment => subscriptionData.accounts;
// what to do here?
// @ts-ignore how to retrieve market data for each account?
return subscriptionData.accounts.map((a) => ({
type: a.type,
balance: a.balance,
asset: {},
market: a.marketId ? {} : null,
}));
};
export const accountsDataProvider = makeDataProvider< export const accountsDataProvider = makeDataProvider<
AccountsQuery, AccountsQuery,
AccountFieldsFragment[], Account[],
AccountEventsSubscription, AccountEventsSubscription,
AccountFieldsFragment AccountFieldsFragment
>({ >({
query: AccountsDocument, query: AccountsDocument,
subscriptionQuery: AccountEventsDocument, subscriptionQuery: AccountEventsDocument,
// @ts-ignore FIXME stagnet3 update
update, update,
getData, getData,
// @ts-ignore FIXME stagnet3 update
getDelta, getDelta,
}); });
@@ -6,7 +6,7 @@ const defaultOptions = {} as const;
export type AssetsConnectionQueryVariables = Types.Exact<{ [key: string]: never; }>; 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 } }; 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` export const AssetsConnectionDocument = gql`
+2 -2
View File
@@ -9,9 +9,9 @@ import {
Splash, Splash,
Tooltip, Tooltip,
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { useAssetsConnectionQuery } from './__generated__/Assets';
import type { Schema } from '@vegaprotocol/types'; import type { Schema } from '@vegaprotocol/types';
import create from 'zustand'; import create from 'zustand';
import { useAssetsConnectionQuery } from './__generated___/Assets';
export type AssetDetailsDialogStore = { export type AssetDetailsDialogStore = {
isAssetDetailsDialogOpen: boolean; isAssetDetailsDialogOpen: boolean;
@@ -54,7 +54,7 @@ export const AssetDetailsDialog = ({
const { data } = useAssetsConnectionQuery(); const { data } = useAssetsConnectionQuery();
const symbol = const symbol =
typeof assetSymbol === 'string' ? assetSymbol : assetSymbol.symbol; typeof assetSymbol === 'string' ? assetSymbol : assetSymbol.symbol;
const asset = data?.assetsConnection.edges?.find( const asset = data?.assetsConnection?.edges?.find(
(e) => e?.node.symbol === symbol (e) => e?.node.symbol === symbol
); );
+1 -1
View File
@@ -1,2 +1,2 @@
export * from './__generated__/Assets'; export * from './__generated___/Assets';
export * from './asset-details-dialog'; export * from './asset-details-dialog';
@@ -1,7 +1,6 @@
query DealTicketQuery($marketId: ID!) { query DealTicketQuery($marketId: ID!) {
market(id: $marketId) { market(id: $marketId) {
id id
name
decimalPlaces decimalPlaces
positionDecimalPlaces positionDecimalPlaces
state state
@@ -1,4 +1,4 @@
query MarketNames { query DealTicketMarketNames {
markets { markets {
id id
state state
@@ -8,14 +8,13 @@ export type DealTicketQueryQueryVariables = Types.Exact<{
}>; }>;
export type DealTicketQueryQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, name: 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 type DealTicketQueryQuery = { __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 DealTicketQueryDocument = gql` export const DealTicketQueryDocument = gql`
query DealTicketQuery($marketId: ID!) { query DealTicketQuery($marketId: ID!) {
market(id: $marketId) { market(id: $marketId) {
id id
name
decimalPlaces decimalPlaces
positionDecimalPlaces positionDecimalPlaces
state state
@@ -3,14 +3,14 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client'; import * as Apollo from '@apollo/client';
const defaultOptions = {} as const; const defaultOptions = {} as const;
export type MarketNamesQueryVariables = Types.Exact<{ [key: string]: never; }>; export type DealTicketMarketNamesQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type MarketNamesQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string, name: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string } } } }> | null }; export type DealTicketMarketNamesQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string, name: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string } } } }> | null };
export const MarketNamesDocument = gql` export const DealTicketMarketNamesDocument = gql`
query MarketNames { query DealTicketMarketNames {
markets { markets {
id id
state state
@@ -33,28 +33,28 @@ export const MarketNamesDocument = gql`
`; `;
/** /**
* __useMarketNamesQuery__ * __useDealTicketMarketNamesQuery__
* *
* To run a query within a React component, call `useMarketNamesQuery` and pass it any options that fit your needs. * To run a query within a React component, call `useDealTicketMarketNamesQuery` and pass it any options that fit your needs.
* When your component renders, `useMarketNamesQuery` returns an object from Apollo Client that contains loading, error, and data properties * When your component renders, `useDealTicketMarketNamesQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI. * 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; * @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 * @example
* const { data, loading, error } = useMarketNamesQuery({ * const { data, loading, error } = useDealTicketMarketNamesQuery({
* variables: { * variables: {
* }, * },
* }); * });
*/ */
export function useMarketNamesQuery(baseOptions?: Apollo.QueryHookOptions<MarketNamesQuery, MarketNamesQueryVariables>) { export function useDealTicketMarketNamesQuery(baseOptions?: Apollo.QueryHookOptions<DealTicketMarketNamesQuery, DealTicketMarketNamesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions} const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<MarketNamesQuery, MarketNamesQueryVariables>(MarketNamesDocument, options); return Apollo.useQuery<DealTicketMarketNamesQuery, DealTicketMarketNamesQueryVariables>(DealTicketMarketNamesDocument, options);
} }
export function useMarketNamesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<MarketNamesQuery, MarketNamesQueryVariables>) { export function useDealTicketMarketNamesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<DealTicketMarketNamesQuery, DealTicketMarketNamesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions} const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<MarketNamesQuery, MarketNamesQueryVariables>(MarketNamesDocument, options); return Apollo.useLazyQuery<DealTicketMarketNamesQuery, DealTicketMarketNamesQueryVariables>(DealTicketMarketNamesDocument, options);
} }
export type MarketNamesQueryHookResult = ReturnType<typeof useMarketNamesQuery>; export type DealTicketMarketNamesQueryHookResult = ReturnType<typeof useDealTicketMarketNamesQuery>;
export type MarketNamesLazyQueryHookResult = ReturnType<typeof useMarketNamesLazyQuery>; export type DealTicketMarketNamesLazyQueryHookResult = ReturnType<typeof useDealTicketMarketNamesLazyQuery>;
export type MarketNamesQueryResult = Apollo.QueryResult<MarketNamesQuery, MarketNamesQueryVariables>; export type DealTicketMarketNamesQueryResult = Apollo.QueryResult<DealTicketMarketNamesQuery, DealTicketMarketNamesQueryVariables>;
@@ -1,2 +0,0 @@
export * from './DealTicketQuery';
export * from './MarketNames';
-94
View File
@@ -1,94 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { DepositStatus } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: Deposits
// ====================================================
export interface Deposits_party_depositsConnection_edges_node_asset {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
}
export interface Deposits_party_depositsConnection_edges_node {
__typename: "Deposit";
/**
* The Vega internal ID of the deposit
*/
id: string;
/**
* The current status of the deposit
*/
status: DepositStatus;
/**
* The amount to be withdrawn
*/
amount: string;
/**
* The asset to be withdrawn
*/
asset: Deposits_party_depositsConnection_edges_node_asset;
/**
* RFC3339Nano time at which the deposit was created
*/
createdTimestamp: string;
/**
* RFC3339Nano time at which the deposit was finalised
*/
creditedTimestamp: string | null;
/**
* Hash of the transaction on the foreign chain
*/
txHash: string | null;
}
export interface Deposits_party_depositsConnection_edges {
__typename: "DepositEdge";
node: Deposits_party_depositsConnection_edges_node;
}
export interface Deposits_party_depositsConnection {
__typename: "DepositsConnection";
/**
* The deposits
*/
edges: (Deposits_party_depositsConnection_edges | null)[] | null;
}
export interface Deposits_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
/**
* The list of all deposits for a party by the party
*/
depositsConnection: Deposits_party_depositsConnection;
}
export interface Deposits {
/**
* An entity that is trading on the Vega network
*/
party: Deposits_party | null;
}
export interface DepositsVariables {
partyId: string;
}
+1 -1
View File
@@ -79,7 +79,7 @@ export interface DepositsQuery_party {
/** /**
* The list of all deposits for a party by the party * The list of all deposits for a party by the party
*/ */
depositsConnection: DepositsQuery_party_depositsConnection; depositsConnection: DepositsQuery_party_depositsConnection | null;
} }
export interface DepositsQuery { export interface DepositsQuery {
+9 -6
View File
@@ -11,7 +11,10 @@ import type {
DepositEventSub_busEvents_event, DepositEventSub_busEvents_event,
DepositEventSub_busEvents_event_Deposit, DepositEventSub_busEvents_event_Deposit,
} from './__generated__/DepositEventSub'; } from './__generated__/DepositEventSub';
import type { Deposits, DepositsVariables } from './__generated__/Deposits'; import type {
DepositsQuery,
DepositsQueryVariables,
} from './__generated__/DepositsQuery';
const DEPOSIT_FRAGMENT = gql` const DEPOSIT_FRAGMENT = gql`
fragment DepositFields on Deposit { fragment DepositFields on Deposit {
@@ -61,15 +64,15 @@ const DEPOSITS_BUS_EVENT_SUB = gql`
export const useDeposits = () => { export const useDeposits = () => {
const { keypair } = useVegaWallet(); const { keypair } = useVegaWallet();
const { data, loading, error, subscribeToMore } = useQuery< const { data, loading, error, subscribeToMore } = useQuery<
Deposits, DepositsQuery,
DepositsVariables DepositsQueryVariables
>(DEPOSITS_QUERY, { >(DEPOSITS_QUERY, {
variables: { partyId: keypair?.pub || '' }, variables: { partyId: keypair?.pub || '' },
skip: !keypair?.pub, skip: !keypair?.pub,
}); });
const deposits = useMemo(() => { const deposits = useMemo(() => {
if (!data?.party?.depositsConnection.edges?.length) { if (!data?.party?.depositsConnection?.edges?.length) {
return []; return [];
} }
@@ -98,7 +101,7 @@ export const useDeposits = () => {
}; };
const updateQuery: UpdateQueryFn< const updateQuery: UpdateQueryFn<
Deposits, DepositsQuery,
DepositEventSubVariables, DepositEventSubVariables,
DepositEventSub DepositEventSub
> = (prev, { subscriptionData, variables }) => { > = (prev, { subscriptionData, variables }) => {
@@ -108,7 +111,7 @@ const updateQuery: UpdateQueryFn<
} }
const curr = const curr =
compact(prev.party?.depositsConnection.edges?.map((e) => e?.node)) || []; compact(prev.party?.depositsConnection?.edges?.map((e) => e?.node)) || [];
const incoming = subscriptionData.data.busEvents const incoming = subscriptionData.data.busEvents
.map((e) => e.event) .map((e) => e.event)
.filter(isDepositEvent); .filter(isDepositEvent);
@@ -69,11 +69,7 @@ const NetworkLabel = ({
</span> </span>
); );
export const NetworkSwitcher = ({ export const NetworkSwitcher = ({ theme }: { theme?: 'dark' | 'light' }) => {
fixedBg,
}: {
fixedBg?: 'dark' | 'light';
}) => {
const { VEGA_ENV, VEGA_NETWORKS } = useEnvironment(); const { VEGA_ENV, VEGA_NETWORKS } = useEnvironment();
const [isOpen, setOpen] = useState(false); const [isOpen, setOpen] = useState(false);
const [isAdvancedView, setAdvancedView] = useState(false); const [isAdvancedView, setAdvancedView] = useState(false);
@@ -88,10 +84,9 @@ export const NetworkSwitcher = ({
[setOpen, setAdvancedView] [setOpen, setAdvancedView]
); );
const dropdownTriggerClasses = classNames('hover:!bg-neutral-700', { const dropdownTriggerClasses = classNames({
'dark:text-white dark:bg-black text-black bg-white': !fixedBg, 'text-black hover:!bg-neutral-300': theme === 'light',
'text-black bg-white': fixedBg === 'light', 'text-white hover:!bg-neutral-700': theme === 'dark',
'text-white bg-black': fixedBg === 'dark',
}); });
return ( return (
@@ -23,7 +23,7 @@ export const getMockBusEventsResult = (): BlockTime => ({
busEvents: [ busEvents: [
{ {
__typename: 'BusEvent', __typename: 'BusEvent',
eventId: '0', id: '0',
}, },
], ],
}); });
+1 -1
View File
@@ -12,7 +12,7 @@ export interface BlockTime_busEvents {
/** /**
* the ID for this event * the ID for this event
*/ */
eventId: string; id: string;
} }
export interface BlockTime { export interface BlockTime {
+1 -1
View File
@@ -14,7 +14,7 @@ export const STATS_QUERY = gql`
export const TIME_UPDATE_SUBSCRIPTION = gql` export const TIME_UPDATE_SUBSCRIPTION = gql`
subscription BlockTime { subscription BlockTime {
busEvents(types: TimeUpdate, batchSize: 1) { busEvents(types: TimeUpdate, batchSize: 1) {
eventId id
} }
} }
`; `;
-1
View File
@@ -1,4 +1,3 @@
export * from './lib/fills-container'; export * from './lib/fills-container';
export * from './lib/__generated__/FillFields';
export * from './lib/__generated__/Fills'; export * from './lib/__generated__/Fills';
export * from './lib/__generated__/FillsSub'; export * from './lib/__generated__/FillsSub';
+63 -49
View File
@@ -1,57 +1,52 @@
fragment FillFields on Trade {
id
createdAt
price
size
buyOrder
sellOrder
aggressor
buyer {
id
}
seller {
id
}
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
market {
id
name
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
product {
... on Future {
settlementAsset {
id
symbol
decimals
}
}
}
}
}
}
}
query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) { query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
party(id: $partyId) { party(id: $partyId) {
id id
tradesConnection(marketId: $marketId, pagination: $pagination) { tradesConnection(marketId: $marketId, pagination: $pagination) {
edges { edges {
node { node {
...FillFields id
createdAt
price
size
buyOrder
sellOrder
aggressor
buyer {
id
}
seller {
id
}
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
market {
id
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
product {
... on Future {
settlementAsset {
id
symbol
decimals
}
}
}
}
}
}
} }
cursor cursor
} }
@@ -67,6 +62,25 @@ query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
subscription FillsSub($partyId: ID!) { subscription FillsSub($partyId: ID!) {
trades(partyId: $partyId) { trades(partyId: $partyId) {
...FillFields id
createdAt
price
size
buyOrder
sellOrder
aggressor
buyerId
sellerId
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
marketId
} }
} }
-198
View File
@@ -1,198 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { Side } from "@vegaprotocol/types";
// ====================================================
// GraphQL fragment: FillFields
// ====================================================
export interface FillFields_buyer {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface FillFields_seller {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface FillFields_buyerFee {
__typename: "TradeFee";
/**
* The maker fee, paid by the aggressive party to the other party (the one who had an order in the book)
*/
makerFee: string;
/**
* The infrastructure fee, a fee paid to the validators to maintain the Vega network
*/
infrastructureFee: string;
/**
* The fee paid to the liquidity providers that committed liquidity to the market
*/
liquidityFee: string;
}
export interface FillFields_sellerFee {
__typename: "TradeFee";
/**
* The maker fee, paid by the aggressive party to the other party (the one who had an order in the book)
*/
makerFee: string;
/**
* The infrastructure fee, a fee paid to the validators to maintain the Vega network
*/
infrastructureFee: string;
/**
* The fee paid to the liquidity providers that committed liquidity to the market
*/
liquidityFee: string;
}
export interface FillFields_market_tradableInstrument_instrument_product_settlementAsset {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
}
export interface FillFields_market_tradableInstrument_instrument_product {
__typename: "Future";
/**
* The name of the asset (string)
*/
settlementAsset: FillFields_market_tradableInstrument_instrument_product_settlementAsset;
}
export interface FillFields_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
*/
code: string;
/**
* Full and fairly descriptive name for the instrument
*/
name: string;
/**
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
*/
product: FillFields_market_tradableInstrument_instrument_product;
}
export interface FillFields_market_tradableInstrument {
__typename: "TradableInstrument";
/**
* An instance of, or reference to, a fully specified instrument.
*/
instrument: FillFields_market_tradableInstrument_instrument;
}
export interface FillFields_market {
__typename: "Market";
/**
* Market ID
*/
id: string;
/**
* decimalPlaces indicates 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;
/**
* positionDecimalPlaces indicates 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;
/**
* An instance of, or reference to, a tradable instrument.
*/
tradableInstrument: FillFields_market_tradableInstrument;
}
export interface FillFields {
__typename: "Trade";
/**
* The hash of the trade data
*/
id: string;
/**
* RFC3339Nano time for when the trade occurred
*/
createdAt: string;
/**
* The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64)
*/
price: string;
/**
* The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64)
*/
size: string;
/**
* The order that bought
*/
buyOrder: string;
/**
* The order that sold
*/
sellOrder: string;
/**
* The aggressor indicates whether this trade was related to a BUY or SELL
*/
aggressor: Side;
/**
* The party that bought
*/
buyer: FillFields_buyer;
/**
* The party that sold
*/
seller: FillFields_seller;
/**
* The fee paid by the buyer side of the trade
*/
buyerFee: FillFields_buyerFee;
/**
* The fee paid by the seller side of the trade
*/
sellerFee: FillFields_sellerFee;
/**
* The market the trade occurred on
*/
market: FillFields_market;
}
+25 -25
View File
@@ -9,22 +9,6 @@ import { Pagination, Side } from "@vegaprotocol/types";
// GraphQL query operation: Fills // GraphQL query operation: Fills
// ==================================================== // ====================================================
export interface Fills_party_tradesConnection_edges_node_buyer {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface Fills_party_tradesConnection_edges_node_seller {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface Fills_party_tradesConnection_edges_node_buyerFee { export interface Fills_party_tradesConnection_edges_node_buyerFee {
__typename: "TradeFee"; __typename: "TradeFee";
/** /**
@@ -57,6 +41,22 @@ export interface Fills_party_tradesConnection_edges_node_sellerFee {
liquidityFee: string; liquidityFee: string;
} }
export interface Fills_party_tradesConnection_edges_node_buyer {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface Fills_party_tradesConnection_edges_node_seller {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface Fills_party_tradesConnection_edges_node_market_tradableInstrument_instrument_product_settlementAsset { export interface Fills_party_tradesConnection_edges_node_market_tradableInstrument_instrument_product_settlementAsset {
__typename: "Asset"; __typename: "Asset";
/** /**
@@ -175,14 +175,6 @@ export interface Fills_party_tradesConnection_edges_node {
* The aggressor indicates whether this trade was related to a BUY or SELL * The aggressor indicates whether this trade was related to a BUY or SELL
*/ */
aggressor: Side; aggressor: Side;
/**
* The party that bought
*/
buyer: Fills_party_tradesConnection_edges_node_buyer;
/**
* The party that sold
*/
seller: Fills_party_tradesConnection_edges_node_seller;
/** /**
* The fee paid by the buyer side of the trade * The fee paid by the buyer side of the trade
*/ */
@@ -191,6 +183,14 @@ export interface Fills_party_tradesConnection_edges_node {
* The fee paid by the seller side of the trade * The fee paid by the seller side of the trade
*/ */
sellerFee: Fills_party_tradesConnection_edges_node_sellerFee; sellerFee: Fills_party_tradesConnection_edges_node_sellerFee;
/**
* The party that bought
*/
buyer: Fills_party_tradesConnection_edges_node_buyer;
/**
* The party that sold
*/
seller: Fills_party_tradesConnection_edges_node_seller;
/** /**
* The market the trade occurred on * The market the trade occurred on
*/ */
@@ -229,7 +229,7 @@ export interface Fills_party {
* Party identifier * Party identifier
*/ */
id: string; id: string;
tradesConnection: Fills_party_tradesConnection; tradesConnection: Fills_party_tradesConnection | null;
} }
export interface Fills { export interface Fills {
+8 -112
View File
@@ -9,22 +9,6 @@ import { Side } from "@vegaprotocol/types";
// GraphQL subscription operation: FillsSub // GraphQL subscription operation: FillsSub
// ==================================================== // ====================================================
export interface FillsSub_trades_buyer {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface FillsSub_trades_seller {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface FillsSub_trades_buyerFee { export interface FillsSub_trades_buyerFee {
__typename: "TradeFee"; __typename: "TradeFee";
/** /**
@@ -57,96 +41,8 @@ export interface FillsSub_trades_sellerFee {
liquidityFee: string; liquidityFee: string;
} }
export interface FillsSub_trades_market_tradableInstrument_instrument_product_settlementAsset {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
}
export interface FillsSub_trades_market_tradableInstrument_instrument_product {
__typename: "Future";
/**
* The name of the asset (string)
*/
settlementAsset: FillsSub_trades_market_tradableInstrument_instrument_product_settlementAsset;
}
export interface FillsSub_trades_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
*/
code: string;
/**
* Full and fairly descriptive name for the instrument
*/
name: string;
/**
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
*/
product: FillsSub_trades_market_tradableInstrument_instrument_product;
}
export interface FillsSub_trades_market_tradableInstrument {
__typename: "TradableInstrument";
/**
* An instance of, or reference to, a fully specified instrument.
*/
instrument: FillsSub_trades_market_tradableInstrument_instrument;
}
export interface FillsSub_trades_market {
__typename: "Market";
/**
* Market ID
*/
id: string;
/**
* decimalPlaces indicates 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;
/**
* positionDecimalPlaces indicates 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;
/**
* An instance of, or reference to, a tradable instrument.
*/
tradableInstrument: FillsSub_trades_market_tradableInstrument;
}
export interface FillsSub_trades { export interface FillsSub_trades {
__typename: "Trade"; __typename: "TradeUpdate";
/** /**
* The hash of the trade data * The hash of the trade data
*/ */
@@ -160,7 +56,7 @@ export interface FillsSub_trades {
*/ */
price: string; 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; size: string;
/** /**
@@ -178,11 +74,15 @@ export interface FillsSub_trades {
/** /**
* The party that bought * The party that bought
*/ */
buyer: FillsSub_trades_buyer; buyerId: string;
/** /**
* The party that sold * The party that sold
*/ */
seller: FillsSub_trades_seller; sellerId: string;
/**
* The market the trade occurred on
*/
marketId: string;
/** /**
* The fee paid by the buyer side of the trade * The fee paid by the buyer side of the trade
*/ */
@@ -191,10 +91,6 @@ export interface FillsSub_trades {
* The fee paid by the seller side of the trade * The fee paid by the seller side of the trade
*/ */
sellerFee: FillsSub_trades_sellerFee; sellerFee: FillsSub_trades_sellerFee;
/**
* The market the trade occurred on
*/
market: FillsSub_trades_market;
} }
export interface FillsSub { export interface FillsSub {
+68 -56
View File
@@ -3,8 +3,6 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client'; import * as Apollo from '@apollo/client';
const defaultOptions = {} as const; const defaultOptions = {} as const;
export type FillFieldsFragment = { __typename?: 'Trade', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, 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 }, market: { __typename?: 'Market', id: string, name: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, code: string, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } } } };
export type FillsQueryVariables = Types.Exact<{ export type FillsQueryVariables = Types.Exact<{
partyId: Types.Scalars['ID']; partyId: Types.Scalars['ID'];
marketId?: Types.InputMaybe<Types.Scalars['ID']>; marketId?: Types.InputMaybe<Types.Scalars['ID']>;
@@ -12,63 +10,16 @@ export type FillsQueryVariables = Types.Exact<{
}>; }>;
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, 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 }, market: { __typename?: 'Market', id: string, name: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, code: string, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } } } } }>, pageInfo: { __typename?: 'PageInfo', startCursor: string, endCursor: string, hasNextPage: boolean, hasPreviousPage: boolean } } } | null }; 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, 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 }, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, code: string, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } } } } }>, pageInfo: { __typename?: 'PageInfo', startCursor: string, endCursor: string, hasNextPage: boolean, hasPreviousPage: boolean } } | null } | null };
export type FillsSubSubscriptionVariables = Types.Exact<{ export type FillsSubSubscriptionVariables = Types.Exact<{
partyId: Types.Scalars['ID']; partyId: Types.Scalars['ID'];
}>; }>;
export type FillsSubSubscription = { __typename?: 'Subscription', trades?: Array<{ __typename?: 'Trade', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, 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 }, market: { __typename?: 'Market', id: string, name: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, code: string, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } } } }> | null }; export type FillsSubSubscription = { __typename?: 'Subscription', trades?: Array<{ __typename?: 'TradeUpdate', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, buyerId: string, sellerId: string, marketId: string, 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
createdAt
price
size
buyOrder
sellOrder
aggressor
buyer {
id
}
seller {
id
}
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
market {
id
name
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
product {
... on Future {
settlementAsset {
id
symbol
decimals
}
}
}
}
}
}
}
`;
export const FillsDocument = gql` export const FillsDocument = gql`
query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) { query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
party(id: $partyId) { party(id: $partyId) {
@@ -76,7 +27,49 @@ export const FillsDocument = gql`
tradesConnection(marketId: $marketId, pagination: $pagination) { tradesConnection(marketId: $marketId, pagination: $pagination) {
edges { edges {
node { node {
...FillFields id
createdAt
price
size
buyOrder
sellOrder
aggressor
buyer {
id
}
seller {
id
}
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
market {
id
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
product {
... on Future {
settlementAsset {
id
symbol
decimals
}
}
}
}
}
}
} }
cursor cursor
} }
@@ -89,7 +82,7 @@ export const FillsDocument = gql`
} }
} }
} }
${FillFieldsFragmentDoc}`; `;
/** /**
* __useFillsQuery__ * __useFillsQuery__
@@ -123,10 +116,29 @@ export type FillsQueryResult = Apollo.QueryResult<FillsQuery, FillsQueryVariable
export const FillsSubDocument = gql` export const FillsSubDocument = gql`
subscription FillsSub($partyId: ID!) { subscription FillsSub($partyId: ID!) {
trades(partyId: $partyId) { trades(partyId: $partyId) {
...FillFields id
createdAt
price
size
buyOrder
sellOrder
aggressor
buyerId
sellerId
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
marketId
} }
} }
${FillFieldsFragmentDoc}`; `;
/** /**
* __useFillsSubSubscription__ * __useFillsSubSubscription__
+68 -58
View File
@@ -6,72 +6,64 @@ import {
defaultAppend as append, defaultAppend as append,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import type { PageInfo } from '@vegaprotocol/react-helpers'; import type { PageInfo } from '@vegaprotocol/react-helpers';
import type { FillFields } from './__generated__/FillFields';
import type { import type {
Fills, Fills,
Fills_party_tradesConnection_edges, Fills_party_tradesConnection_edges,
Fills_party_tradesConnection_edges_node, Fills_party_tradesConnection_edges_node,
} from './__generated__/Fills'; } from './__generated__/Fills';
import type { FillsSub } from './__generated__/FillsSub'; import type { FillsSub, FillsSub_trades } from './__generated__/FillsSub';
const FILL_FRAGMENT = gql`
fragment FillFields on Trade {
id
createdAt
price
size
buyOrder
sellOrder
aggressor
buyer {
id
}
seller {
id
}
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
market {
id
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
name
product {
... on Future {
settlementAsset {
id
symbol
decimals
}
}
}
}
}
}
}
`;
export const FILLS_QUERY = gql` export const FILLS_QUERY = gql`
${FILL_FRAGMENT}
query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) { query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
party(id: $partyId) { party(id: $partyId) {
id id
tradesConnection(marketId: $marketId, pagination: $pagination) { tradesConnection(marketId: $marketId, pagination: $pagination) {
edges { edges {
node { node {
...FillFields id
createdAt
price
size
buyOrder
sellOrder
aggressor
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
buyer {
id
}
seller {
id
}
market {
id
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
name
product {
... on Future {
settlementAsset {
id
symbol
decimals
}
}
}
}
}
}
} }
cursor cursor
} }
@@ -87,17 +79,35 @@ export const FILLS_QUERY = gql`
`; `;
export const FILLS_SUB = gql` export const FILLS_SUB = gql`
${FILL_FRAGMENT}
subscription FillsSub($partyId: ID!) { subscription FillsSub($partyId: ID!) {
trades(partyId: $partyId) { trades(partyId: $partyId) {
...FillFields id
createdAt
price
size
buyOrder
sellOrder
aggressor
buyerId
sellerId
marketId
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
} }
} }
`; `;
const update = ( const update = (
data: (Fills_party_tradesConnection_edges | null)[], data: (Fills_party_tradesConnection_edges | null)[],
delta: FillFields[] delta: FillsSub_trades[]
) => { ) => {
return produce(data, (draft) => { return produce(data, (draft) => {
orderBy(delta, 'createdAt').forEach((node) => { orderBy(delta, 'createdAt').forEach((node) => {
@@ -122,10 +132,10 @@ const update = (
const getData = ( const getData = (
responseData: Fills responseData: Fills
): Fills_party_tradesConnection_edges[] | null => ): Fills_party_tradesConnection_edges[] | null =>
responseData.party?.tradesConnection.edges || null; responseData.party?.tradesConnection?.edges || null;
const getPageInfo = (responseData: Fills): PageInfo | null => const getPageInfo = (responseData: Fills): PageInfo | null =>
responseData.party?.tradesConnection.pageInfo || null; responseData.party?.tradesConnection?.pageInfo || null;
const getDelta = (subscriptionData: FillsSub) => subscriptionData.trades || []; const getDelta = (subscriptionData: FillsSub) => subscriptionData.trades || [];
@@ -29,7 +29,7 @@ export const getProposals = (data?: ProposalsConnection) => {
return proposals ? (proposals as Proposal[]) : []; return proposals ? (proposals as Proposal[]) : [];
}; };
const orderByDate = (arr: Proposal[]) => export const orderByDate = (arr: Proposal[]) =>
orderBy( orderBy(
arr, arr,
[ [
@@ -1,9 +1,9 @@
query MarketLiquidity($marketId: ID!, $partyId: String) { query MarketLiquidity($marketId: ID!, $partyId: ID!) {
market(id: $marketId) { market(id: $marketId) {
id id
decimalPlaces decimalPlaces
positionDecimalPlaces positionDecimalPlaces
liquidityProvisionsConnection(party: $partyId) { liquidityProvisionsConnection(partyId: $partyId) {
edges { edges {
node { node {
id id
+8 -8
View File
@@ -46,7 +46,7 @@ export interface MarketLiquidity_market_liquidityProvisionsConnection_edges_node
/** /**
* Collateral accounts relating to a party * Collateral accounts relating to a party
*/ */
accountsConnection: MarketLiquidity_market_liquidityProvisionsConnection_edges_node_party_accountsConnection; accountsConnection: MarketLiquidity_market_liquidityProvisionsConnection_edges_node_party_accountsConnection | null;
} }
export interface MarketLiquidity_market_liquidityProvisionsConnection_edges_node { export interface MarketLiquidity_market_liquidityProvisionsConnection_edges_node {
@@ -56,7 +56,7 @@ export interface MarketLiquidity_market_liquidityProvisionsConnection_edges_node
*/ */
id: string | null; id: string | null;
/** /**
* The Id of the party making this commitment * The party making this commitment
*/ */
party: MarketLiquidity_market_liquidityProvisionsConnection_edges_node_party; party: MarketLiquidity_market_liquidityProvisionsConnection_edges_node_party;
/** /**
@@ -72,7 +72,7 @@ export interface MarketLiquidity_market_liquidityProvisionsConnection_edges_node
*/ */
commitmentAmount: string; commitmentAmount: string;
/** /**
* Nominated liquidity fee factor, which is an input to the calculation of maker fees on the market, as per setting fees and rewarding liquidity providers. * Nominated liquidity fee factor, which is an input to the calculation of liquidity fees on the market, as per setting fees and rewarding liquidity providers.
*/ */
fee: string; fee: string;
/** /**
@@ -174,7 +174,7 @@ export interface MarketLiquidity_market_data_liquidityProviderFeeShare {
export interface MarketLiquidity_market_data { export interface MarketLiquidity_market_data {
__typename: "MarketData"; __typename: "MarketData";
/** /**
* market ID of the associated mark price * market of the associated mark price
*/ */
market: MarketLiquidity_market_data_market; market: MarketLiquidity_market_data_market;
/** /**
@@ -208,14 +208,14 @@ export interface MarketLiquidity_market {
/** /**
* decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct * decimalPlaces indicates 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) * number denominated in the currency of the market. (uint64)
* *
* Examples: * Examples:
* Currency Balance decimalPlaces Real Balance * Currency Balance decimalPlaces Real Balance
* GBP 100 0 GBP 100 * GBP 100 0 GBP 100
* GBP 100 2 GBP 1.00 * GBP 100 2 GBP 1.00
* GBP 100 4 GBP 0.01 * GBP 100 4 GBP 0.01
* GBP 1 4 GBP 0.0001 ( 0.01p ) * GBP 1 4 GBP 0.0001 ( 0.01p )
* *
* GBX (pence) 100 0 GBP 1.00 (100p ) * GBX (pence) 100 0 GBP 1.00 (100p )
* GBX (pence) 100 2 GBP 0.01 ( 1p ) * GBX (pence) 100 2 GBP 0.01 ( 1p )
* GBX (pence) 100 4 GBP 0.0001 ( 0.01p ) * GBX (pence) 100 4 GBP 0.0001 ( 0.01p )
@@ -232,7 +232,7 @@ export interface MarketLiquidity_market {
/** /**
* The list of the liquidity provision commitments for this market * The list of the liquidity provision commitments for this market
*/ */
liquidityProvisionsConnection: MarketLiquidity_market_liquidityProvisionsConnection; liquidityProvisionsConnection: MarketLiquidity_market_liquidityProvisionsConnection | null;
/** /**
* An instance of, or reference to, a tradable instrument. * An instance of, or reference to, a tradable instrument.
*/ */
@@ -252,5 +252,5 @@ export interface MarketLiquidity {
export interface MarketLiquidityVariables { export interface MarketLiquidityVariables {
marketId: string; marketId: string;
partyId?: string | null; partyId: string;
} }
-1
View File
@@ -1 +0,0 @@
export * from './MarketLiquidity';
@@ -0,0 +1,106 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type MarketLiquidityQueryVariables = Types.Exact<{
marketId: Types.Scalars['ID'];
partyId: Types.Scalars['ID'];
}>;
export type MarketLiquidityQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, liquidityProvisionsConnection?: { __typename?: 'LiquidityProvisionsConnection', edges?: Array<{ __typename?: 'LiquidityProvisionsEdge', node: { __typename?: 'LiquidityProvision', id?: string | null, createdAt: string, updatedAt?: string | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'Account', type: Types.AccountType, balance: string } } | null> | null } | null } } } | null> | null } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string, name: string, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } }, data?: { __typename?: 'MarketData', suppliedStake?: string | null, openInterest: string, targetStake?: string | null, marketValueProxy: string, market: { __typename?: 'Market', id: string }, liquidityProviderFeeShare?: Array<{ __typename?: 'LiquidityProviderFeeShare', equityLikeShare: string, averageEntryValuation: string, party: { __typename?: 'Party', id: string } }> | null } | null } | null };
export const MarketLiquidityDocument = gql`
query MarketLiquidity($marketId: ID!, $partyId: ID!) {
market(id: $marketId) {
id
decimalPlaces
positionDecimalPlaces
liquidityProvisionsConnection(partyId: $partyId) {
edges {
node {
id
party {
id
accountsConnection(marketId: $marketId, type: ACCOUNT_TYPE_BOND) {
edges {
node {
type
balance
}
}
}
}
createdAt
updatedAt
commitmentAmount
fee
status
}
}
}
tradableInstrument {
instrument {
code
name
product {
... on Future {
settlementAsset {
id
symbol
decimals
}
}
}
}
}
data {
market {
id
}
suppliedStake
openInterest
targetStake
marketValueProxy
liquidityProviderFeeShare {
party {
id
}
equityLikeShare
averageEntryValuation
}
}
}
}
`;
/**
* __useMarketLiquidityQuery__
*
* To run a query within a React component, call `useMarketLiquidityQuery` and pass it any options that fit your needs.
* When your component renders, `useMarketLiquidityQuery` 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 } = useMarketLiquidityQuery({
* variables: {
* marketId: // value for 'marketId'
* partyId: // value for 'partyId'
* },
* });
*/
export function useMarketLiquidityQuery(baseOptions: Apollo.QueryHookOptions<MarketLiquidityQuery, MarketLiquidityQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<MarketLiquidityQuery, MarketLiquidityQueryVariables>(MarketLiquidityDocument, options);
}
export function useMarketLiquidityLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<MarketLiquidityQuery, MarketLiquidityQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<MarketLiquidityQuery, MarketLiquidityQueryVariables>(MarketLiquidityDocument, options);
}
export type MarketLiquidityQueryHookResult = ReturnType<typeof useMarketLiquidityQuery>;
export type MarketLiquidityLazyQueryHookResult = ReturnType<typeof useMarketLiquidityLazyQuery>;
export type MarketLiquidityQueryResult = Apollo.QueryResult<MarketLiquidityQuery, MarketLiquidityQueryVariables>;
+1 -1
View File
@@ -1,3 +1,3 @@
export * from './__generated__'; export * from './__generated__/MarketLiquidity';
export * from './liquidity-data-provider'; export * from './liquidity-data-provider';
export * from './liquidity-table'; export * from './liquidity-table';
@@ -6,17 +6,17 @@ import BigNumber from 'bignumber.js';
import type { import type {
MarketLiquidity, MarketLiquidity,
MarketLiquidity_market_data_liquidityProviderFeeShare, MarketLiquidity_market_data_liquidityProviderFeeShare,
} from './__generated__'; } from './__generated__/MarketLiquidity';
const SISKA_NETWORK_PARAMETER = 'market.liquidity.stakeToCcySiskas'; const SISKA_NETWORK_PARAMETER = 'market.liquidity.stakeToCcySiskas';
const MARKET_LIQUIDITY_QUERY = gql` const MARKET_LIQUIDITY_QUERY = gql`
query MarketLiquidity($marketId: ID!, $partyId: String) { query MarketLiquidity($marketId: ID!, $partyId: ID!) {
market(id: $marketId) { market(id: $marketId) {
id id
decimalPlaces decimalPlaces
positionDecimalPlaces positionDecimalPlaces
liquidityProvisionsConnection(party: $partyId) { liquidityProvisionsConnection(partyId: $partyId) {
edges { edges {
node { node {
id id
@@ -123,11 +123,11 @@ export const useLiquidityProvision = ({
) // if partyId is provided, filter out other parties ) // if partyId is provided, filter out other parties
.map((provider: MarketLiquidity_market_data_liquidityProviderFeeShare) => { .map((provider: MarketLiquidity_market_data_liquidityProviderFeeShare) => {
const liquidityProvisionConnection = const liquidityProvisionConnection =
data?.market?.liquidityProvisionsConnection.edges?.find( data?.market?.liquidityProvisionsConnection?.edges?.find(
(e) => e?.node.party.id === provider.party.id (e) => e?.node.party.id === provider.party.id
); );
const balance = const balance =
liquidityProvisionConnection?.node?.party.accountsConnection.edges?.reduce( liquidityProvisionConnection?.node?.party.accountsConnection?.edges?.reduce(
(acc, e) => { (acc, e) => {
return e?.node.type === AccountType.ACCOUNT_TYPE_BOND // just an extra check to make sure we only use bond accounts return e?.node.type === AccountType.ACCOUNT_TYPE_BOND // just an extra check to make sure we only use bond accounts
? acc.plus(new BigNumber(e?.node.balance ?? 0)) ? acc.plus(new BigNumber(e?.node.balance ?? 0))
+3 -17
View File
@@ -33,23 +33,9 @@ query MarketDepth($marketId: ID!) {
} }
} }
subscription MarketDepthSubscription($marketId: ID!) { subscription MarketDepthSubscription($marketIds: [ID!]!) {
marketDepthUpdate(marketId: $marketId) { marketsDepthUpdate(marketIds: $marketIds) {
market { marketId
id
positionDecimalPlaces
data {
staticMidPrice
marketTradingMode
indicativeVolume
indicativePrice
bestStaticBidPrice
bestStaticOfferPrice
market {
id
}
}
}
sell { sell {
price price
volume volume
+2 -2
View File
@@ -24,7 +24,7 @@ export interface MarketDepth_market_data {
*/ */
staticMidPrice: string; staticMidPrice: string;
/** /**
* what state the market is in (auction, continuous, etc) * what mode the market is in (auction, continuous, etc)
*/ */
marketTradingMode: MarketTradingMode; marketTradingMode: MarketTradingMode;
/** /**
@@ -44,7 +44,7 @@ export interface MarketDepth_market_data {
*/ */
bestStaticOfferPrice: string; bestStaticOfferPrice: string;
/** /**
* market ID of the associated mark price * market of the associated mark price
*/ */
market: MarketDepth_market_data_market; market: MarketDepth_market_data_market;
} }
@@ -3,72 +3,11 @@
// @generated // @generated
// This file was automatically generated and should not be edited. // This file was automatically generated and should not be edited.
import { MarketTradingMode } from "@vegaprotocol/types";
// ==================================================== // ====================================================
// GraphQL subscription operation: MarketDepthSubscription // GraphQL subscription operation: MarketDepthSubscription
// ==================================================== // ====================================================
export interface MarketDepthSubscription_marketDepthUpdate_market_data_market { export interface MarketDepthSubscription_marketsDepthUpdate_sell {
__typename: "Market";
/**
* Market ID
*/
id: string;
}
export interface MarketDepthSubscription_marketDepthUpdate_market_data {
__typename: "MarketData";
/**
* the arithmetic average of the best static bid price and best static offer price
*/
staticMidPrice: string;
/**
* what state 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;
/**
* market ID of the associated mark price
*/
market: MarketDepthSubscription_marketDepthUpdate_market_data_market;
}
export interface MarketDepthSubscription_marketDepthUpdate_market {
__typename: "Market";
/**
* Market ID
*/
id: string;
/**
* positionDecimalPlaces indicates 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;
/**
* marketData for the given market
*/
data: MarketDepthSubscription_marketDepthUpdate_market_data | null;
}
export interface MarketDepthSubscription_marketDepthUpdate_sell {
__typename: "PriceLevel"; __typename: "PriceLevel";
/** /**
* The price of all the orders at this level (uint64) * The price of all the orders at this level (uint64)
@@ -84,7 +23,7 @@ export interface MarketDepthSubscription_marketDepthUpdate_sell {
numberOfOrders: string; numberOfOrders: string;
} }
export interface MarketDepthSubscription_marketDepthUpdate_buy { export interface MarketDepthSubscription_marketsDepthUpdate_buy {
__typename: "PriceLevel"; __typename: "PriceLevel";
/** /**
* The price of all the orders at this level (uint64) * The price of all the orders at this level (uint64)
@@ -100,20 +39,20 @@ export interface MarketDepthSubscription_marketDepthUpdate_buy {
numberOfOrders: string; numberOfOrders: string;
} }
export interface MarketDepthSubscription_marketDepthUpdate { export interface MarketDepthSubscription_marketsDepthUpdate {
__typename: "MarketDepthUpdate"; __typename: "ObservableMarketDepthUpdate";
/** /**
* Market * Market ID
*/ */
market: MarketDepthSubscription_marketDepthUpdate_market; marketId: string;
/** /**
* Sell side price levels (if available) * Sell side price levels (if available)
*/ */
sell: MarketDepthSubscription_marketDepthUpdate_sell[] | null; sell: MarketDepthSubscription_marketsDepthUpdate_sell[] | null;
/** /**
* Buy side price levels (if available) * Buy side price levels (if available)
*/ */
buy: MarketDepthSubscription_marketDepthUpdate_buy[] | null; buy: MarketDepthSubscription_marketsDepthUpdate_buy[] | null;
/** /**
* Sequence number for the current snapshot of the market depth. It is always increasing but not monotonic. * Sequence number for the current snapshot of the market depth. It is always increasing but not monotonic.
*/ */
@@ -124,7 +63,7 @@ export interface MarketDepthSubscription {
/** /**
* Subscribe to price level market depth updates * Subscribe to price level market depth updates
*/ */
marketDepthUpdate: MarketDepthSubscription_marketDepthUpdate; marketsDepthUpdate: MarketDepthSubscription_marketsDepthUpdate[];
} }
export interface MarketDepthSubscriptionVariables { export interface MarketDepthSubscriptionVariables {
@@ -11,11 +11,11 @@ export type MarketDepthQueryVariables = Types.Exact<{
export type MarketDepthQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, data?: { __typename?: 'MarketData', staticMidPrice: string, marketTradingMode: Types.MarketTradingMode, indicativeVolume: string, indicativePrice: string, bestStaticBidPrice: string, bestStaticOfferPrice: string, market: { __typename?: 'Market', id: string } } | null, depth: { __typename?: 'MarketDepth', sequenceNumber: string, lastTrade?: { __typename?: 'Trade', price: string } | null, sell?: Array<{ __typename?: 'PriceLevel', price: string, volume: string, numberOfOrders: string }> | null, buy?: Array<{ __typename?: 'PriceLevel', price: string, volume: string, numberOfOrders: string }> | null } } | null }; export type MarketDepthQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, data?: { __typename?: 'MarketData', staticMidPrice: string, marketTradingMode: Types.MarketTradingMode, indicativeVolume: string, indicativePrice: string, bestStaticBidPrice: string, bestStaticOfferPrice: string, market: { __typename?: 'Market', id: string } } | null, depth: { __typename?: 'MarketDepth', sequenceNumber: string, lastTrade?: { __typename?: 'Trade', price: string } | null, sell?: Array<{ __typename?: 'PriceLevel', price: string, volume: string, numberOfOrders: string }> | null, buy?: Array<{ __typename?: 'PriceLevel', price: string, volume: string, numberOfOrders: string }> | null } } | null };
export type MarketDepthSubscriptionSubscriptionVariables = Types.Exact<{ export type MarketDepthSubscriptionSubscriptionVariables = Types.Exact<{
marketId: Types.Scalars['ID']; marketIds: Array<Types.Scalars['ID']> | Types.Scalars['ID'];
}>; }>;
export type MarketDepthSubscriptionSubscription = { __typename?: 'Subscription', marketDepthUpdate: { __typename?: 'MarketDepthUpdate', sequenceNumber: string, market: { __typename?: 'Market', id: string, positionDecimalPlaces: number, data?: { __typename?: 'MarketData', staticMidPrice: string, marketTradingMode: Types.MarketTradingMode, indicativeVolume: string, indicativePrice: string, bestStaticBidPrice: string, bestStaticOfferPrice: string, market: { __typename?: 'Market', id: string } } | null }, sell?: Array<{ __typename?: 'PriceLevel', price: string, volume: string, numberOfOrders: string }> | null, buy?: Array<{ __typename?: 'PriceLevel', price: string, volume: string, numberOfOrders: string }> | null } }; export type MarketDepthSubscriptionSubscription = { __typename?: 'Subscription', marketsDepthUpdate: Array<{ __typename?: 'ObservableMarketDepthUpdate', marketId: string, sequenceNumber: string, sell?: Array<{ __typename?: 'PriceLevel', price: string, volume: string, numberOfOrders: string }> | null, buy?: Array<{ __typename?: 'PriceLevel', price: string, volume: string, numberOfOrders: string }> | null }> };
export const MarketDepthDocument = gql` export const MarketDepthDocument = gql`
@@ -83,23 +83,9 @@ export type MarketDepthQueryHookResult = ReturnType<typeof useMarketDepthQuery>;
export type MarketDepthLazyQueryHookResult = ReturnType<typeof useMarketDepthLazyQuery>; export type MarketDepthLazyQueryHookResult = ReturnType<typeof useMarketDepthLazyQuery>;
export type MarketDepthQueryResult = Apollo.QueryResult<MarketDepthQuery, MarketDepthQueryVariables>; export type MarketDepthQueryResult = Apollo.QueryResult<MarketDepthQuery, MarketDepthQueryVariables>;
export const MarketDepthSubscriptionDocument = gql` export const MarketDepthSubscriptionDocument = gql`
subscription MarketDepthSubscription($marketId: ID!) { subscription MarketDepthSubscription($marketIds: [ID!]!) {
marketDepthUpdate(marketId: $marketId) { marketsDepthUpdate(marketIds: $marketIds) {
market { marketId
id
positionDecimalPlaces
data {
staticMidPrice
marketTradingMode
indicativeVolume
indicativePrice
bestStaticBidPrice
bestStaticOfferPrice
market {
id
}
}
}
sell { sell {
price price
volume volume
@@ -127,7 +113,7 @@ export const MarketDepthSubscriptionDocument = gql`
* @example * @example
* const { data, loading, error } = useMarketDepthSubscriptionSubscription({ * const { data, loading, error } = useMarketDepthSubscriptionSubscription({
* variables: { * variables: {
* marketId: // value for 'marketId' * marketIds: // value for 'marketIds'
* }, * },
* }); * });
*/ */
+2 -2
View File
@@ -16,9 +16,9 @@ import {
useState, useState,
useContext, useContext,
} from 'react'; } from 'react';
import type { MarketDepthSubscription_marketDepthUpdate } from './__generated__/MarketDepthSubscription';
import type { DepthChartProps } from 'pennant'; import type { DepthChartProps } from 'pennant';
import { parseLevel, updateLevels } from './depth-chart-utils'; import { parseLevel, updateLevels } from './depth-chart-utils';
import type { MarketDepthSubscription_marketsDepthUpdate } from './__generated__/MarketDepthSubscription';
interface DepthChartManagerProps { interface DepthChartManagerProps {
marketId: string; marketId: string;
@@ -40,7 +40,7 @@ export const DepthChartContainer = ({ marketId }: DepthChartManagerProps) => {
// Apply updates to the table // Apply updates to the table
const update = useCallback( const update = useCallback(
({ delta }: { delta: MarketDepthSubscription_marketDepthUpdate }) => { ({ delta }: { delta: MarketDepthSubscription_marketsDepthUpdate }) => {
if (!dataRef.current) { if (!dataRef.current) {
return false; return false;
} }
@@ -50,22 +50,8 @@ const MARKET_DEPTH_QUERY = gql`
export const MARKET_DEPTH_SUBSCRIPTION_QUERY = gql` export const MARKET_DEPTH_SUBSCRIPTION_QUERY = gql`
subscription MarketDepthSubscription($marketId: ID!) { subscription MarketDepthSubscription($marketId: ID!) {
marketDepthUpdate(marketId: $marketId) { marketsDepthUpdate(marketIds: [$marketId]) {
market { marketId
id
positionDecimalPlaces
data {
staticMidPrice
marketTradingMode
indicativeVolume
indicativePrice
bestStaticBidPrice
bestStaticOfferPrice
market {
id
}
}
}
sell { sell {
price price
volume volume
+6 -5
View File
@@ -8,10 +8,11 @@ import {
useState, useState,
useMemo, useMemo,
useCallback, useCallback,
useContext,
} from 'react'; } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { formatNumber, t, useThemeSwitcher } from '@vegaprotocol/react-helpers'; import { formatNumber, t, ThemeContext } from '@vegaprotocol/react-helpers';
import { MarketTradingMode } from '@vegaprotocol/types'; import { MarketTradingMode } from '@vegaprotocol/types';
import { OrderbookRow } from './orderbook-row'; import { OrderbookRow } from './orderbook-row';
import { createRow, getPriceLevel } from './orderbook-data'; import { createRow, getPriceLevel } from './orderbook-data';
@@ -27,7 +28,7 @@ interface OrderbookProps extends OrderbookData {
const HorizontalLine = ({ top, testId }: { top: string; testId: string }) => ( const HorizontalLine = ({ top, testId }: { top: string; testId: string }) => (
<div <div
className="absolute border-b border-neutral-300 dark:border-neutral-600 inset-x-0" className="absolute border-b border-default inset-x-0"
style={{ top }} style={{ top }}
data-testid={testId} data-testid={testId}
/> />
@@ -106,7 +107,7 @@ export const Orderbook = ({
resolution, resolution,
onResolutionChange, onResolutionChange,
}: OrderbookProps) => { }: OrderbookProps) => {
const [theme] = useThemeSwitcher(); const theme = useContext(ThemeContext);
const scrollElement = useRef<HTMLDivElement>(null); const scrollElement = useRef<HTMLDivElement>(null);
// scroll offset for which rendered rows are selected, will change after user will scroll to margin of rendered data // scroll offset for which rendered rows are selected, will change after user will scroll to margin of rendered data
const [scrollOffset, setScrollOffset] = useState(0); const [scrollOffset, setScrollOffset] = useState(0);
@@ -320,7 +321,7 @@ export const Orderbook = ({
data-testid="scroll" data-testid="scroll"
> >
<div <div
className="sticky top-0 grid grid-cols-4 gap-2 text-right border-b pt-2 bg-white dark:bg-black z-10 border-neutral-300 dark:border-neutral-600" className="sticky top-0 grid grid-cols-4 gap-2 text-right border-b pt-2 bg-white dark:bg-black z-10 border-default"
style={{ gridAutoRows: '17px' }} style={{ gridAutoRows: '17px' }}
> >
<div>{t('Bid vol')}</div> <div>{t('Bid vol')}</div>
@@ -344,7 +345,7 @@ export const Orderbook = ({
)} )}
</div> </div>
<div <div
className="sticky bottom-0 grid grid-cols-4 gap-2 border-t-[1px] border-neutral-300 dark:border-neutral-600 mt-2 z-10 bg-white dark:bg-black" className="sticky bottom-0 grid grid-cols-4 gap-2 border-t-[1px] border-default mt-2 z-10 bg-white dark:bg-black"
style={{ gridAutoRows: '17px' }} style={{ gridAutoRows: '17px' }}
> >
<div className="col-start-2"> <div className="col-start-2">
@@ -1,11 +1,11 @@
query MarketNames { query MarketInfoMarketNames {
markets { markets {
id id
name
state state
tradableInstrument { tradableInstrument {
instrument { instrument {
code code
name
metadata { metadata {
tags tags
} }
@@ -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 MarketInfoMarketNamesQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type MarketInfoMarketNamesQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string, name: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string } } } }> | null };
export const MarketInfoMarketNamesDocument = gql`
query MarketInfoMarketNames {
markets {
id
state
tradableInstrument {
instrument {
code
name
metadata {
tags
}
product {
... on Future {
quoteName
}
}
}
}
}
}
`;
/**
* __useMarketInfoMarketNamesQuery__
*
* To run a query within a React component, call `useMarketInfoMarketNamesQuery` and pass it any options that fit your needs.
* When your component renders, `useMarketInfoMarketNamesQuery` 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 } = useMarketInfoMarketNamesQuery({
* variables: {
* },
* });
*/
export function useMarketInfoMarketNamesQuery(baseOptions?: Apollo.QueryHookOptions<MarketInfoMarketNamesQuery, MarketInfoMarketNamesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<MarketInfoMarketNamesQuery, MarketInfoMarketNamesQueryVariables>(MarketInfoMarketNamesDocument, options);
}
export function useMarketInfoMarketNamesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<MarketInfoMarketNamesQuery, MarketInfoMarketNamesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<MarketInfoMarketNamesQuery, MarketInfoMarketNamesQueryVariables>(MarketInfoMarketNamesDocument, options);
}
export type MarketInfoMarketNamesQueryHookResult = ReturnType<typeof useMarketInfoMarketNamesQuery>;
export type MarketInfoMarketNamesLazyQueryHookResult = ReturnType<typeof useMarketInfoMarketNamesLazyQuery>;
export type MarketInfoMarketNamesQueryResult = Apollo.QueryResult<MarketInfoMarketNamesQuery, MarketInfoMarketNamesQueryVariables>;
@@ -119,22 +119,6 @@ export interface MarketInfoQuery_market_priceMonitoringSettings {
parameters: MarketInfoQuery_market_priceMonitoringSettings_parameters | null; parameters: MarketInfoQuery_market_priceMonitoringSettings_parameters | null;
} }
export interface MarketInfoQuery_market_riskFactors {
__typename: "RiskFactor";
/**
* market the risk factor was emitted for
*/
market: string;
/**
* short factor
*/
short: string;
/**
* long factor
*/
long: string;
}
export interface MarketInfoQuery_market_data_market { export interface MarketInfoQuery_market_data_market {
__typename: "Market"; __typename: "Market";
/** /**
@@ -184,7 +168,7 @@ export interface MarketInfoQuery_market_data_priceMonitoringBounds {
export interface MarketInfoQuery_market_data { export interface MarketInfoQuery_market_data {
__typename: "MarketData"; __typename: "MarketData";
/** /**
* market ID of the associated mark price * market of the associated mark price
*/ */
market: MarketInfoQuery_market_data_market; market: MarketInfoQuery_market_data_market;
/** /**
@@ -507,10 +491,6 @@ export interface MarketInfoQuery_market {
* Price monitoring settings for the market * Price monitoring settings for the market
*/ */
priceMonitoringSettings: MarketInfoQuery_market_priceMonitoringSettings; priceMonitoringSettings: MarketInfoQuery_market_priceMonitoringSettings;
/**
* risk factors for the market
*/
riskFactors: MarketInfoQuery_market_riskFactors | null;
/** /**
* marketData for the given market * marketData for the given market
*/ */
@@ -1 +0,0 @@
export * from './MarketInfoQuery';
@@ -335,7 +335,7 @@ export const Info = ({ market, onSelect }: InfoProps) => {
<p className={headerClassName}>{t('Market data')}</p> <p className={headerClassName}>{t('Market data')}</p>
<Accordion panels={marketDataPanels} /> <Accordion panels={marketDataPanels} />
</div> </div>
<div className="mb-4"> <div className="mb-8">
<p className={headerClassName}>{t('Market specification')}</p> <p className={headerClassName}>{t('Market specification')}</p>
<Accordion panels={marketSpecPanels} /> <Accordion panels={marketSpecPanels} />
</div> </div>
+8 -17
View File
@@ -1,20 +1,6 @@
fragment MarketDataFields on MarketData {
market {
id
state
tradingMode
}
bestBidPrice
bestOfferPrice
markPrice
trigger
indicativeVolume
}
query MarketList($interval: Interval!, $since: String!) { query MarketList($interval: Interval!, $since: String!) {
markets { markets {
id id
name
decimalPlaces decimalPlaces
positionDecimalPlaces positionDecimalPlaces
state state
@@ -68,8 +54,13 @@ query MarketList($interval: Interval!, $since: String!) {
} }
} }
subscription MarketDataSub { subscription MarketDataSub($marketIds: [ID!]!) {
marketData { marketsData(marketIds: $marketIds) {
...MarketDataFields marketId
bestBidPrice
bestOfferPrice
markPrice
trigger
indicativeVolume
} }
} }
@@ -1,54 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { MarketState, MarketTradingMode, AuctionTrigger } from "@vegaprotocol/types";
// ====================================================
// GraphQL fragment: MarketDataFields
// ====================================================
export interface MarketDataFields_market {
__typename: "Market";
/**
* Market ID
*/
id: string;
/**
* Current state of the market
*/
state: MarketState;
/**
* Current mode of execution of the market
*/
tradingMode: MarketTradingMode;
}
export interface MarketDataFields {
__typename: "MarketData";
/**
* market ID of the associated mark price
*/
market: MarketDataFields_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;
/**
* indicative volume if the auction ended now, 0 if not in auction mode
*/
indicativeVolume: string;
}
+16 -20
View File
@@ -9,28 +9,20 @@ import { MarketState, MarketTradingMode, AuctionTrigger } from "@vegaprotocol/ty
// GraphQL subscription operation: MarketDataSub // GraphQL subscription operation: MarketDataSub
// ==================================================== // ====================================================
export interface MarketDataSub_marketData_market { export interface MarketDataSub_marketsData {
__typename: "Market"; __typename: "ObservableMarketData";
/**
* Market ID
*/
id: string;
/**
* Current state of the market
*/
state: MarketState;
/**
* Current mode of execution of the market
*/
tradingMode: MarketTradingMode;
}
export interface MarketDataSub_marketData {
__typename: "MarketData";
/** /**
* market ID of the associated mark price * market ID of the associated mark price
*/ */
market: MarketDataSub_marketData_market; marketId: string;
/**
* current state of the market
*/
marketState: MarketState;
/**
* what mode the market is in (auction, continuous etc)
*/
marketTradingMode: MarketTradingMode;
/** /**
* the highest price level on an order book for buy orders. * the highest price level on an order book for buy orders.
*/ */
@@ -57,5 +49,9 @@ export interface MarketDataSub {
/** /**
* Subscribe to the mark price changes * Subscribe to the mark price changes
*/ */
marketData: MarketDataSub_marketData; marketsData: MarketDataSub_marketsData[];
}
export interface MarketDataSubVariables {
marketIds: string[];
} }
+1 -1
View File
@@ -52,7 +52,7 @@ export interface MarketList_markets_data_market {
export interface MarketList_markets_data { export interface MarketList_markets_data {
__typename: "MarketData"; __typename: "MarketData";
/** /**
* market ID of the associated mark price * market of the associated mark price
*/ */
market: MarketList_markets_data_market; market: MarketList_markets_data_market;
/** /**
@@ -3,40 +3,26 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client'; import * as Apollo from '@apollo/client';
const defaultOptions = {} as const; const defaultOptions = {} as const;
export type MarketDataFieldsFragment = { __typename?: 'MarketData', bestBidPrice: string, bestOfferPrice: string, markPrice: string, trigger: Types.AuctionTrigger, indicativeVolume: string, market: { __typename?: 'Market', id: string, state: Types.MarketState, tradingMode: Types.MarketTradingMode } };
export type MarketListQueryVariables = Types.Exact<{ export type MarketListQueryVariables = Types.Exact<{
interval: Types.Interval; interval: Types.Interval;
since: Types.Scalars['String']; since: Types.Scalars['String'];
}>; }>;
export type MarketListQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, name: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, data?: { __typename?: 'MarketData', bestBidPrice: string, bestOfferPrice: string, markPrice: string, trigger: Types.AuctionTrigger, indicativeVolume: string, market: { __typename?: 'Market', id: string, state: Types.MarketState, tradingMode: Types.MarketTradingMode } } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', symbol: string } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null }, candles?: Array<{ __typename?: 'Candle', open: string, close: string, high: string, low: string } | null> | null }> | null }; export type MarketListQuery = { __typename?: 'Query', markets?: Array<{ __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 } }, data?: { __typename?: 'MarketData', bestBidPrice: string, bestOfferPrice: string, markPrice: string, trigger: Types.AuctionTrigger, indicativeVolume: string, market: { __typename?: 'Market', id: string, state: Types.MarketState, tradingMode: Types.MarketTradingMode } } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', symbol: string } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null }, candles?: Array<{ __typename?: 'Candle', open: string, close: string, high: string, low: string } | null> | null }> | null };
export type MarketDataSubSubscriptionVariables = Types.Exact<{ [key: string]: never; }>; export type MarketDataSubSubscriptionVariables = Types.Exact<{
marketIds: Array<Types.Scalars['ID']> | Types.Scalars['ID'];
}>;
export type MarketDataSubSubscription = { __typename?: 'Subscription', marketData: { __typename?: 'MarketData', bestBidPrice: string, bestOfferPrice: string, markPrice: string, trigger: Types.AuctionTrigger, indicativeVolume: string, market: { __typename?: 'Market', id: string, state: Types.MarketState, tradingMode: Types.MarketTradingMode } } }; export type MarketDataSubSubscription = { __typename?: 'Subscription', marketsData: Array<{ __typename?: 'ObservableMarketData', marketId: string, bestBidPrice: string, bestOfferPrice: string, markPrice: string, trigger: Types.AuctionTrigger, indicativeVolume: string }> };
export const MarketDataFieldsFragmentDoc = gql`
fragment MarketDataFields on MarketData {
market {
id
state
tradingMode
}
bestBidPrice
bestOfferPrice
markPrice
trigger
indicativeVolume
}
`;
export const MarketListDocument = gql` export const MarketListDocument = gql`
query MarketList($interval: Interval!, $since: String!) { query MarketList($interval: Interval!, $since: String!) {
markets { markets {
id id
name
decimalPlaces decimalPlaces
positionDecimalPlaces positionDecimalPlaces
state state
@@ -120,12 +106,17 @@ export type MarketListQueryHookResult = ReturnType<typeof useMarketListQuery>;
export type MarketListLazyQueryHookResult = ReturnType<typeof useMarketListLazyQuery>; export type MarketListLazyQueryHookResult = ReturnType<typeof useMarketListLazyQuery>;
export type MarketListQueryResult = Apollo.QueryResult<MarketListQuery, MarketListQueryVariables>; export type MarketListQueryResult = Apollo.QueryResult<MarketListQuery, MarketListQueryVariables>;
export const MarketDataSubDocument = gql` export const MarketDataSubDocument = gql`
subscription MarketDataSub { subscription MarketDataSub($marketIds: [ID!]!) {
marketData { marketsData(marketIds: $marketIds) {
...MarketDataFields marketId
bestBidPrice
bestOfferPrice
markPrice
trigger
indicativeVolume
} }
} }
${MarketDataFieldsFragmentDoc}`; `;
/** /**
* __useMarketDataSubSubscription__ * __useMarketDataSubSubscription__
@@ -139,10 +130,11 @@ export const MarketDataSubDocument = gql`
* @example * @example
* const { data, loading, error } = useMarketDataSubSubscription({ * const { data, loading, error } = useMarketDataSubSubscription({
* variables: { * variables: {
* marketIds: // value for 'marketIds'
* }, * },
* }); * });
*/ */
export function useMarketDataSubSubscription(baseOptions?: Apollo.SubscriptionHookOptions<MarketDataSubSubscription, MarketDataSubSubscriptionVariables>) { export function useMarketDataSubSubscription(baseOptions: Apollo.SubscriptionHookOptions<MarketDataSubSubscription, MarketDataSubSubscriptionVariables>) {
const options = {...defaultOptions, ...baseOptions} const options = {...defaultOptions, ...baseOptions}
return Apollo.useSubscription<MarketDataSubSubscription, MarketDataSubSubscriptionVariables>(MarketDataSubDocument, options); return Apollo.useSubscription<MarketDataSubSubscription, MarketDataSubSubscriptionVariables>(MarketDataSubDocument, options);
} }
@@ -24,7 +24,7 @@ import type {
} from '../__generated__/MarketList'; } from '../__generated__/MarketList';
import isNil from 'lodash/isNil'; import isNil from 'lodash/isNil';
export const cellClassNames = 'px-0 py-1 first:text-left text-right'; export const cellClassNames = 'py-1 first:text-left text-right';
const FeesInfo = () => { const FeesInfo = () => {
return ( return (
@@ -7,7 +7,7 @@ export const SelectMarketTableHeader = ({
headers = columnHeaders, headers = columnHeaders,
}) => { }) => {
return ( return (
<tr className="sticky top-0 z-10 border-b border-neutral-300 dark:border-neutral-600 bg-inherit"> <tr className="sticky top-0 z-10 border-b border-default bg-inherit">
{headers.map(({ value, className, onlyOnDetailed }, i) => { {headers.map(({ value, className, onlyOnDetailed }, i) => {
const thClass = classNames( const thClass = classNames(
'font-normal text-neutral-500 dark:text-neutral-400', 'font-normal text-neutral-500 dark:text-neutral-400',
@@ -76,7 +76,7 @@ export const SelectAllMarketsTableBody = ({
if (!data) return null; if (!data) return null;
return ( return (
<> <>
<thead className="bg-neutral-50 dark:bg-neutral-800"> <thead className="bg-neutral-100 dark:bg-neutral-800">
<SelectMarketTableHeader detailed={true} headers={headers} /> <SelectMarketTableHeader detailed={true} headers={headers} />
</thead> </thead>
{/* Border styles required to create space between tbody elements margin/padding dont work */} {/* Border styles required to create space between tbody elements margin/padding dont work */}
@@ -101,7 +101,7 @@ export const SelectMarketPopover = ({
onSelect: (id: string) => void; onSelect: (id: string) => void;
}) => { }) => {
const triggerClasses = const triggerClasses =
'sm:text-lg md:text-xl lg:text-2xl font-medium flex items-center gap-4 whitespace-nowrap my-3 hover:text-neutral-500 dark:hover:text-neutral-300'; 'sm:text-lg md:text-xl lg:text-2xl flex items-center gap-2 whitespace-nowrap hover:text-neutral-500 dark:hover:text-neutral-300';
const { keypair } = useVegaWallet(); const { keypair } = useVegaWallet();
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const { data, loading: marketsLoading } = useMarketList(); const { data, loading: marketsLoading } = useMarketList();
@@ -27,21 +27,6 @@ export const useMarketList = () => {
}; };
}; };
const MARKET_DATA_FRAGMENT = gql`
fragment MarketDataFields on MarketData {
market {
id
state
tradingMode
}
bestBidPrice
bestOfferPrice
markPrice
trigger
indicativeVolume
}
`;
export const MARKET_LIST_QUERY = gql` export const MARKET_LIST_QUERY = gql`
query MarketList($interval: Interval!, $since: String!) { query MarketList($interval: Interval!, $since: String!) {
markets { markets {
@@ -101,10 +86,16 @@ export const MARKET_LIST_QUERY = gql`
`; `;
const MARKET_DATA_SUB = gql` const MARKET_DATA_SUB = gql`
${MARKET_DATA_FRAGMENT} subscription MarketDataSub($marketIds: [ID!]!) {
subscription MarketDataSub { marketsData(marketIds: $marketIds) {
marketData { marketId
...MarketDataFields marketState
marketTradingMode
bestBidPrice
bestOfferPrice
markPrice
trigger
indicativeVolume
} }
} }
`; `;
@@ -1,126 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "@vegaprotocol/types";
// ====================================================
// GraphQL fragment: OrderFields
// ====================================================
export interface OrderFields_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
*/
code: string;
/**
* Full and fairly descriptive name for the instrument
*/
name: string;
}
export interface OrderFields_market_tradableInstrument {
__typename: "TradableInstrument";
/**
* An instance of, or reference to, a fully specified instrument.
*/
instrument: OrderFields_market_tradableInstrument_instrument;
}
export interface OrderFields_market {
__typename: "Market";
/**
* Market ID
*/
id: string;
/**
* decimalPlaces indicates 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;
/**
* positionDecimalPlaces indicates 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;
/**
* An instance of, or reference to, a tradable instrument.
*/
tradableInstrument: OrderFields_market_tradableInstrument;
}
export interface OrderFields {
__typename: "Order";
/**
* Hash of the order data
*/
id: string;
/**
* The market the order is trading on (probably stored internally as a hash of the market details)
*/
market: OrderFields_market;
/**
* Type the order type (defaults to PARTY)
*/
type: OrderType | null;
/**
* Whether the order is to buy or sell
*/
side: Side;
/**
* Total number of contracts that may be bought or sold (immutable) (uint64)
*/
size: string;
/**
* The status of an order, for example 'Active'
*/
status: OrderStatus;
/**
* Reason for the order to be rejected
*/
rejectionReason: OrderRejectionReason | null;
/**
* The worst price the order will trade at (e.g. buy for price or less, sell for price or more) (uint64)
*/
price: string;
/**
* The timeInForce of order (determines how and if it executes, and whether it persists on the book)
*/
timeInForce: OrderTimeInForce;
/**
* Number of contracts remaining of the total that have not yet been bought or sold (uint64)
*/
remaining: string;
/**
* Expiration time of this order (ISO-8601 RFC3339+Nano formatted date)
*/
expiresAt: string | null;
/**
* RFC3339Nano formatted date and time for when the order was created (timestamp)
*/
createdAt: string;
/**
* RFC3339Nano time the order was altered
*/
updatedAt: string | null;
}
@@ -9,78 +9,14 @@ import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce }
// GraphQL subscription operation: OrderSub // GraphQL subscription operation: OrderSub
// ==================================================== // ====================================================
export interface OrderSub_orders_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
*/
code: string;
/**
* Full and fairly descriptive name for the instrument
*/
name: string;
}
export interface OrderSub_orders_market_tradableInstrument {
__typename: "TradableInstrument";
/**
* An instance of, or reference to, a fully specified instrument.
*/
instrument: OrderSub_orders_market_tradableInstrument_instrument;
}
export interface OrderSub_orders_market {
__typename: "Market";
/**
* Market ID
*/
id: string;
/**
* decimalPlaces indicates 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;
/**
* positionDecimalPlaces indicates 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;
/**
* An instance of, or reference to, a tradable instrument.
*/
tradableInstrument: OrderSub_orders_market_tradableInstrument;
}
export interface OrderSub_orders { export interface OrderSub_orders {
__typename: "Order"; __typename: "OrderUpdate";
/** /**
* Hash of the order data * Hash of the order data
*/ */
id: string; id: string;
/** /**
* The market the order is trading on (probably stored internally as a hash of the market details) * The order type
*/
market: OrderSub_orders_market;
/**
* Type the order type (defaults to PARTY)
*/ */
type: OrderType | null; type: OrderType | null;
/** /**
@@ -88,7 +24,7 @@ export interface OrderSub_orders {
*/ */
side: Side; side: Side;
/** /**
* Total number of contracts that may be bought or sold (immutable) (uint64) * Total number of units that may be bought or sold (immutable) (uint64)
*/ */
size: string; size: string;
/** /**
@@ -96,7 +32,7 @@ export interface OrderSub_orders {
*/ */
status: OrderStatus; status: OrderStatus;
/** /**
* Reason for the order to be rejected * Why the order was rejected
*/ */
rejectionReason: OrderRejectionReason | null; rejectionReason: OrderRejectionReason | null;
/** /**
@@ -108,7 +44,7 @@ export interface OrderSub_orders {
*/ */
timeInForce: OrderTimeInForce; timeInForce: OrderTimeInForce;
/** /**
* Number of contracts remaining of the total that have not yet been bought or sold (uint64) * Number of units remaining of the total that have not yet been bought or sold (uint64)
*/ */
remaining: string; remaining: string;
/** /**
@@ -123,6 +59,10 @@ export interface OrderSub_orders {
* RFC3339Nano time the order was altered * RFC3339Nano time the order was altered
*/ */
updatedAt: string | null; updatedAt: string | null;
/**
* The market the order is trading on (probably stored internally as a hash of the market details)
*/
marketId: string;
} }
export interface OrderSub { export interface OrderSub {
@@ -76,11 +76,7 @@ export interface Orders_party_ordersConnection_edges_node {
*/ */
id: string; id: string;
/** /**
* The market the order is trading on (probably stored internally as a hash of the market details) * The order type
*/
market: Orders_party_ordersConnection_edges_node_market;
/**
* Type the order type (defaults to PARTY)
*/ */
type: OrderType | null; type: OrderType | null;
/** /**
@@ -88,7 +84,7 @@ export interface Orders_party_ordersConnection_edges_node {
*/ */
side: Side; side: Side;
/** /**
* Total number of contracts that may be bought or sold (immutable) (uint64) * Total number of units that may be bought or sold (immutable) (uint64)
*/ */
size: string; size: string;
/** /**
@@ -96,7 +92,7 @@ export interface Orders_party_ordersConnection_edges_node {
*/ */
status: OrderStatus; status: OrderStatus;
/** /**
* Reason for the order to be rejected * Why the order was rejected
*/ */
rejectionReason: OrderRejectionReason | null; rejectionReason: OrderRejectionReason | null;
/** /**
@@ -108,7 +104,7 @@ export interface Orders_party_ordersConnection_edges_node {
*/ */
timeInForce: OrderTimeInForce; timeInForce: OrderTimeInForce;
/** /**
* Number of contracts remaining of the total that have not yet been bought or sold (uint64) * Number of units remaining of the total that have not yet been bought or sold (uint64)
*/ */
remaining: string; remaining: string;
/** /**
@@ -123,6 +119,10 @@ export interface Orders_party_ordersConnection_edges_node {
* RFC3339Nano time the order was altered * RFC3339Nano time the order was altered
*/ */
updatedAt: string | null; updatedAt: string | null;
/**
* The market the order is trading on (probably stored internally as a hash of the market details)
*/
market: Orders_party_ordersConnection_edges_node_market;
} }
export interface Orders_party_ordersConnection_edges { export interface Orders_party_ordersConnection_edges {
@@ -160,7 +160,7 @@ export interface Orders_party {
/** /**
* Orders relating to a party * Orders relating to a party
*/ */
ordersConnection: Orders_party_ordersConnection; ordersConnection: Orders_party_ordersConnection | null;
} }
export interface Orders { export interface Orders {
@@ -10,48 +10,40 @@ import type { PageInfo } from '@vegaprotocol/react-helpers';
import type { import type {
Orders, Orders,
Orders_party_ordersConnection_edges, Orders_party_ordersConnection_edges,
OrderSub, } from './__generated__/Orders';
OrderFields, import type { OrderSub, OrderSub_orders } from './__generated__/OrderSub';
} from '../';
const ORDER_FRAGMENT = gql`
fragment OrderFields on Order {
id
market {
id
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
name
}
}
}
type
side
size
status
rejectionReason
price
timeInForce
remaining
expiresAt
createdAt
updatedAt
}
`;
export const ORDERS_QUERY = gql` export const ORDERS_QUERY = gql`
${ORDER_FRAGMENT}
query Orders($partyId: ID!, $pagination: Pagination) { query Orders($partyId: ID!, $pagination: Pagination) {
party(id: $partyId) { party(id: $partyId) {
id id
ordersConnection(pagination: $pagination) { ordersConnection(pagination: $pagination) {
edges { edges {
node { node {
...OrderFields id
type
side
size
status
rejectionReason
price
timeInForce
remaining
expiresAt
createdAt
updatedAt
market {
id
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
name
}
}
}
} }
cursor cursor
} }
@@ -67,17 +59,28 @@ export const ORDERS_QUERY = gql`
`; `;
export const ORDERS_SUB = gql` export const ORDERS_SUB = gql`
${ORDER_FRAGMENT}
subscription OrderSub($partyId: ID!) { subscription OrderSub($partyId: ID!) {
orders(partyId: $partyId) { orders(partyId: $partyId) {
...OrderFields id
type
side
size
status
rejectionReason
price
timeInForce
remaining
expiresAt
createdAt
updatedAt
marketId
} }
} }
`; `;
export const update = ( export const update = (
data: Orders_party_ordersConnection_edges[], data: Orders_party_ordersConnection_edges[],
delta: OrderFields[] delta: OrderSub_orders[]
) => { ) => {
return produce(data, (draft) => { return produce(data, (draft) => {
// A single update can contain the same order with multiple updates, so we need to find // A single update can contain the same order with multiple updates, so we need to find
@@ -108,12 +111,12 @@ export const update = (
const getData = ( const getData = (
responseData: Orders responseData: Orders
): Orders_party_ordersConnection_edges[] | null => ): Orders_party_ordersConnection_edges[] | null =>
responseData?.party?.ordersConnection.edges || null; responseData?.party?.ordersConnection?.edges || null;
const getDelta = (subscriptionData: OrderSub) => subscriptionData.orders || []; const getDelta = (subscriptionData: OrderSub) => subscriptionData.orders || [];
const getPageInfo = (responseData: Orders): PageInfo | null => const getPageInfo = (responseData: Orders): PageInfo | null =>
responseData.party?.ordersConnection.pageInfo || null; responseData.party?.ordersConnection?.pageInfo || null;
export const ordersDataProvider = makeDataProvider({ export const ordersDataProvider = makeDataProvider({
query: ORDERS_QUERY, query: ORDERS_QUERY,
@@ -87,34 +87,32 @@ export const OrderEditDialog = ({
</div> </div>
)} )}
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 py-4"> <form
<form onSubmit={handleSubmit(onSubmit)} data-testid="edit-order"> onSubmit={handleSubmit(onSubmit)}
<FormGroup label={t('Entry price')} labelFor="entryPrice"> data-testid="edit-order"
<Input className="w-1/2 mt-4"
type="number" >
step={step} <FormGroup label={t('Entry price')} labelFor="entryPrice">
{...register('entryPrice', { <Input
required: t('You need to provide a price'), type="number"
validate: { step={step}
min: (value) => {...register('entryPrice', {
Number(value) > 0 required: t('You need to provide a price'),
? true validate: {
: t('The price cannot be negative'), min: (value) =>
}, Number(value) > 0 ? true : t('The price cannot be negative'),
})} },
id="entryPrice" })}
/> id="entryPrice"
{errors.entryPrice?.message && ( />
<InputError intent="danger"> {errors.entryPrice?.message && (
{errors.entryPrice.message} <InputError intent="danger">{errors.entryPrice.message}</InputError>
</InputError> )}
)} </FormGroup>
</FormGroup> <Button variant="primary" size="md" type="submit">
<Button variant="primary" size="md" type="submit"> {t('Update')}
{t('Update')} </Button>
</Button> </form>
</form>
</div>
</Dialog> </Dialog>
); );
}; };

Some files were not shown because too many files have changed in this diff Show More